mirah 0.0.4-java → 0.0.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/History.txt +23 -0
  2. data/README.txt +13 -5
  3. data/Rakefile +30 -2
  4. data/bin/duby +16 -0
  5. data/bin/dubyc +16 -0
  6. data/bin/dubyp +16 -0
  7. data/bin/jrubyp +16 -0
  8. data/bin/mirah +17 -1
  9. data/bin/mirah.cmd +15 -0
  10. data/bin/mirahc +17 -1
  11. data/bin/mirahc.cmd +16 -1
  12. data/bin/mirahp +17 -1
  13. data/bin/mirahp.cmd +16 -1
  14. data/examples/appengine/Rakefile +17 -2
  15. data/examples/appengine/src/org/mirah/MirahApp.mirah +15 -0
  16. data/examples/bintrees.mirah +15 -0
  17. data/examples/construction.mirah +15 -0
  18. data/examples/dynamic.mirah +15 -0
  19. data/examples/edb.mirah +15 -0
  20. data/examples/fib.mirah +15 -0
  21. data/examples/fields.mirah +15 -0
  22. data/examples/fractal.mirah +15 -0
  23. data/examples/java_thing.mirah +15 -0
  24. data/examples/plugins/appengine/Rakefile +19 -4
  25. data/examples/plugins/appengine/lib/com/google/appengine/ext/duby/db/datastore.rb +21 -6
  26. data/examples/plugins/appengine/src/com/google/appengine/ext/duby/db/Model.duby +15 -0
  27. data/examples/plugins/appengine/test/com/google/appengine/ext/duby/db/ModelTest.duby +15 -0
  28. data/examples/simple_class.mirah +16 -1
  29. data/examples/sort_closure.mirah +15 -0
  30. data/examples/swing.mirah +17 -2
  31. data/examples/tak.mirah +15 -0
  32. data/examples/wiki/Rakefile +17 -2
  33. data/examples/wiki/src/org/mirah/wiki/MirahWiki.duby +15 -0
  34. data/examples/wiki/war/src/org/mirah/wiki/MirahWiki.duby +339 -0
  35. data/examples/wiki/war/src/org/mirah/wiki/edit.eduby.html +42 -0
  36. data/examples/wiki/war/src/org/mirah/wiki/error.eduby.html +2 -0
  37. data/examples/wiki/war/src/org/mirah/wiki/layout.eduby.html +69 -0
  38. data/examples/wiki/war/src/org/mirah/wiki/parser.eduby.html +7 -0
  39. data/examples/wiki/war/src/org/mirah/wiki/view.eduby.html +15 -0
  40. data/javalib/mirah-bootstrap.jar +0 -0
  41. data/javalib/mirah-parser.jar +0 -0
  42. data/lib/duby.rb +15 -0
  43. data/lib/mirah/appengine_tasks.rb +20 -6
  44. data/lib/mirah/ast/call.rb +19 -4
  45. data/lib/mirah/ast/class.rb +19 -4
  46. data/lib/mirah/ast/flow.rb +16 -1
  47. data/lib/mirah/ast/intrinsics.rb +36 -21
  48. data/lib/mirah/ast/literal.rb +16 -1
  49. data/lib/mirah/ast/local.rb +16 -1
  50. data/lib/mirah/ast/method.rb +18 -3
  51. data/lib/mirah/ast/scope.rb +19 -4
  52. data/lib/mirah/ast/structure.rb +16 -1
  53. data/lib/mirah/ast/type.rb +24 -9
  54. data/lib/mirah/ast.rb +24 -9
  55. data/lib/mirah/compiler.rb +16 -1
  56. data/lib/mirah/env.rb +16 -1
  57. data/lib/mirah/jvm/base.rb +18 -3
  58. data/lib/mirah/jvm/compiler.rb +35 -21
  59. data/lib/mirah/jvm/method_lookup.rb +16 -1
  60. data/lib/mirah/jvm/source_compiler.rb +29 -14
  61. data/lib/mirah/jvm/source_generator/builder.rb +21 -6
  62. data/lib/mirah/jvm/source_generator/loops.rb +16 -1
  63. data/lib/mirah/jvm/source_generator/precompile.rb +17 -2
  64. data/lib/mirah/jvm/source_generator/typer.rb +17 -2
  65. data/lib/mirah/jvm/typer.rb +19 -4
  66. data/lib/mirah/jvm/types/basic_types.rb +16 -1
  67. data/lib/mirah/jvm/types/boolean.rb +17 -2
  68. data/lib/mirah/jvm/types/enumerable.rb +21 -6
  69. data/lib/mirah/jvm/types/extensions.rb +16 -1
  70. data/lib/mirah/jvm/types/factory.rb +18 -3
  71. data/lib/mirah/jvm/types/floats.rb +16 -1
  72. data/lib/mirah/jvm/types/integers.rb +22 -7
  73. data/lib/mirah/jvm/types/intrinsics.rb +29 -14
  74. data/lib/mirah/jvm/types/literals.rb +16 -1
  75. data/lib/mirah/jvm/types/methods.rb +24 -9
  76. data/lib/mirah/jvm/types/number.rb +16 -1
  77. data/lib/mirah/jvm/types.rb +23 -4
  78. data/lib/mirah/nbcompiler.rb +19 -4
  79. data/lib/mirah/plugin/edb.rb +18 -3
  80. data/lib/mirah/plugin/gwt.rb +22 -7
  81. data/lib/mirah/plugin/java.rb +18 -3
  82. data/lib/mirah/transform.rb +35 -20
  83. data/lib/mirah/transform2.rb +20 -5
  84. data/lib/mirah/typer.rb +23 -8
  85. data/lib/mirah/version.rb +18 -0
  86. data/lib/mirah.rb +101 -50
  87. data/lib/mirah_task.rb +27 -12
  88. data/test/test_ast.rb +16 -1
  89. data/test/test_compilation.rb +18 -3
  90. data/test/test_env.rb +26 -11
  91. data/test/test_gwt.rb +18 -3
  92. data/test/test_java_typer.rb +27 -12
  93. data/test/test_javac_compiler.rb +17 -2
  94. data/test/test_jvm_compiler.rb +44 -14
  95. data/test/test_typer.rb +16 -1
  96. metadata +203 -193
data/lib/mirah/ast.rb CHANGED
@@ -1,7 +1,22 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah/transform'
2
17
  require 'mirah/ast/scope'
3
18
 
4
- module Duby
19
+ module Mirah
5
20
  module AST
6
21
  class << self
7
22
  attr_accessor :verbose
@@ -46,8 +61,8 @@ module Duby
46
61
 
47
62
  def initialize(parent, position, children = [])
48
63
  JRuby.reference(self.class).setRubyClassAllocator(JRuby.reference(self.class).reified_class)
49
- unless parent.nil? || Duby::AST::Node === parent
50
- raise "Duby::AST::Node.new parent #{parent.class} must be nil or === Duby::AST::Node."
64
+ unless parent.nil? || Mirah::AST::Node === parent
65
+ raise "Mirah::AST::Node.new parent #{parent.class} must be nil or === Mirah::AST::Node."
51
66
  end
52
67
 
53
68
  @parent = parent
@@ -130,13 +145,13 @@ module Duby
130
145
  extra_indent = 0
131
146
  if child
132
147
  name = self.class.child_name(i)
133
- if Duby::AST.verbose && name
148
+ if Mirah::AST.verbose && name
134
149
  str << "\n#{indent_str} #{name}:"
135
150
  extra_indent = 1
136
151
  end
137
152
  if ::Array === child
138
153
  child.each {|ary_child|
139
- if Duby::AST.verbose && Node === ary_child && ary_child.parent != self
154
+ if Mirah::AST.verbose && Node === ary_child && ary_child.parent != self
140
155
  str << "\n#{indent_str} (wrong parent)"
141
156
  end
142
157
  str << "\n#{ary_child.inspect(indent + extra_indent + 1)}"
@@ -144,7 +159,7 @@ module Duby
144
159
  elsif ::Hash === child
145
160
  str << "\n#{indent_str} #{child.inspect}"
146
161
  else
147
- if Duby::AST.verbose && Node === child && child.parent != self
162
+ if Mirah::AST.verbose && Node === child && child.parent != self
148
163
  str << "\n#{indent_str} (wrong parent)"
149
164
  end
150
165
  str << "\n#{child.inspect(indent + extra_indent + 1)}"
@@ -234,7 +249,7 @@ module Duby
234
249
 
235
250
  def inferred_type!
236
251
  unless @inferred_type
237
- raise Duby::Typer::InferenceError.new(
252
+ raise Mirah::Typer::InferenceError.new(
238
253
  "Internal Error: #{self.class} never inferred", self)
239
254
  end
240
255
  inferred_type
@@ -327,7 +342,7 @@ module Duby
327
342
  begin
328
343
  typer.type_reference(scope, name, @array, true)
329
344
  rescue NameError => ex
330
- typer.known_types[@name] = Duby::AST.error_type
345
+ typer.known_types[@name] = Mirah::AST.error_type
331
346
  raise ex
332
347
  end
333
348
  end
@@ -337,7 +352,7 @@ module Duby
337
352
  begin
338
353
  typer.type_reference(scope, @name, @array)
339
354
  rescue NameError => ex
340
- typer.known_types[@name] = Duby::AST.error_type
355
+ typer.known_types[@name] = Mirah::AST.error_type
341
356
  raise ex
342
357
  end
343
358
  end
@@ -1,6 +1,21 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah'
2
17
 
3
- module Duby
18
+ module Mirah
4
19
  module AST
5
20
  class Fixnum
6
21
  def compile(compiler, expression)
data/lib/mirah/env.rb CHANGED
@@ -1,6 +1,21 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'rbconfig'
2
17
 
3
- module Duby
18
+ module Mirah
4
19
  module Env
5
20
 
6
21
  # Returns the system PATH_SEPARATOR environment variable value. This is used when
@@ -1,4 +1,19 @@
1
- module Duby
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah
2
17
  module Compiler
3
18
  class JVMCompilerBase
4
19
  attr_accessor :filename, :method, :static, :class
@@ -26,7 +41,7 @@ module Duby
26
41
  begin
27
42
  ast.compile(self, expression)
28
43
  rescue => ex
29
- Duby.print_error(ex.message, ast.position)
44
+ Mirah.print_error(ex.message, ast.position)
30
45
  raise ex
31
46
  end
32
47
  log "Compilation successful!"
@@ -177,7 +192,7 @@ module Duby
177
192
 
178
193
  def body(body, expression)
179
194
  saved_self = @self_scope
180
- if body.kind_of?(Duby::AST::ScopedBody)
195
+ if body.kind_of?(Mirah::AST::ScopedBody)
181
196
  scope = body.static_scope
182
197
  declare_locals(scope)
183
198
  if scope != @self_scope
@@ -1,3 +1,18 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah'
2
17
  require 'mirah/jvm/base'
3
18
  require 'mirah/jvm/method_lookup'
@@ -6,7 +21,7 @@ require 'mirah/typer'
6
21
  require 'mirah/plugin/java'
7
22
  require 'bitescript'
8
23
 
9
- module Duby
24
+ module Mirah
10
25
  module AST
11
26
  class FunctionalCall
12
27
  attr_accessor :target
@@ -21,8 +36,8 @@ module Duby
21
36
  class JVM < JVMCompilerBase
22
37
  java_import java.lang.System
23
38
  java_import java.io.PrintStream
24
- include Duby::JVM::MethodLookup
25
- Types = Duby::JVM::Types
39
+ include Mirah::JVM::MethodLookup
40
+ Types = Mirah::JVM::Types
26
41
 
27
42
  class << self
28
43
  attr_accessor :verbose
@@ -55,7 +70,6 @@ module Duby
55
70
 
56
71
  def initialize
57
72
  super
58
- BiteScript.bytecode_version = BiteScript::JAVA1_5
59
73
  @jump_scope = []
60
74
  end
61
75
 
@@ -70,7 +84,7 @@ module Duby
70
84
  end
71
85
 
72
86
  def push_jump_scope(node)
73
- raise "Not a node" unless Duby::AST::Node === node
87
+ raise "Not a node" unless Mirah::AST::Node === node
74
88
  begin
75
89
  @jump_scope << node
76
90
  yield
@@ -82,7 +96,7 @@ module Duby
82
96
  def find_ensures(before)
83
97
  found = []
84
98
  @jump_scope.reverse_each do |scope|
85
- if Duby::AST::Ensure === scope
99
+ if Mirah::AST::Ensure === scope
86
100
  found << scope
87
101
  end
88
102
  break if before === scope
@@ -300,19 +314,19 @@ module Duby
300
314
 
301
315
  def break(node)
302
316
  error("break outside of loop", node) unless @break_label
303
- handle_ensures(find_ensures(Duby::AST::Loop))
317
+ handle_ensures(find_ensures(Mirah::AST::Loop))
304
318
  @method.goto(@break_label)
305
319
  end
306
320
 
307
321
  def next(node)
308
322
  error("next outside of loop", node) unless @next_label
309
- handle_ensures(find_ensures(Duby::AST::Loop))
323
+ handle_ensures(find_ensures(Mirah::AST::Loop))
310
324
  @method.goto(@next_label)
311
325
  end
312
326
 
313
327
  def redo(node)
314
328
  error("redo outside of loop", node) unless @redo_label
315
- handle_ensures(find_ensures(Duby::AST::Loop))
329
+ handle_ensures(find_ensures(Mirah::AST::Loop))
316
330
  @method.goto(@redo_label)
317
331
  end
318
332
 
@@ -320,7 +334,7 @@ module Duby
320
334
  unless predicate.inferred_type == Types::Boolean
321
335
  raise "Expected boolean, found #{predicate.inferred_type}"
322
336
  end
323
- if Duby::AST::Call === predicate
337
+ if Mirah::AST::Call === predicate
324
338
  method = extract_method(predicate)
325
339
  if method.respond_to? :jump_if
326
340
  method.jump_if(self, predicate, target)
@@ -335,7 +349,7 @@ module Duby
335
349
  unless predicate.inferred_type == Types::Boolean
336
350
  raise "Expected boolean, found #{predicate.inferred_type}"
337
351
  end
338
- if Duby::AST::Call === predicate
352
+ if Mirah::AST::Call === predicate
339
353
  method = extract_method(predicate)
340
354
  if method.respond_to? :jump_if_not
341
355
  method.jump_if_not(self, predicate, target)
@@ -487,7 +501,7 @@ module Duby
487
501
 
488
502
  def annotation_value(builder, name, value)
489
503
  case value
490
- when Duby::AST::Annotation
504
+ when Mirah::AST::Annotation
491
505
  type = value.type
492
506
  type = type.jvm_type if type.respond_to?(:jvm_type)
493
507
  builder.annotation(name, type) do |child|
@@ -634,7 +648,7 @@ module Duby
634
648
  def build_string(nodes, expression)
635
649
  if expression
636
650
  # could probably be more efficient with non-default constructor
637
- builder_class = Duby::AST.type(nil, 'java.lang.StringBuilder')
651
+ builder_class = Mirah::AST.type(nil, 'java.lang.StringBuilder')
638
652
  @method.new builder_class
639
653
  @method.dup
640
654
  @method.invokespecial builder_class, "<init>", [@method.void]
@@ -759,7 +773,7 @@ module Duby
759
773
 
760
774
  def return(return_node)
761
775
  return_node.value.compile(self, true) if return_node.value
762
- handle_ensures(find_ensures(Duby::AST::MethodDefinition))
776
+ handle_ensures(find_ensures(Mirah::AST::MethodDefinition))
763
777
  return_node.inferred_type.return(@method)
764
778
  end
765
779
 
@@ -835,7 +849,7 @@ module Duby
835
849
  end
836
850
  end
837
851
 
838
- class ClosureCompiler < Duby::Compiler::JVM
852
+ class ClosureCompiler < Mirah::Compiler::JVM
839
853
  def initialize(file, type, parent)
840
854
  @file = file
841
855
  @type = type
@@ -869,16 +883,16 @@ module Duby
869
883
  end
870
884
 
871
885
  if __FILE__ == $0
872
- Duby::Typer.verbose = true
873
- Duby::AST.verbose = true
874
- Duby::Compiler::JVM.verbose = true
875
- ast = Duby::AST.parse(File.read(ARGV[0]))
886
+ Mirah::Typer.verbose = true
887
+ Mirah::AST.verbose = true
888
+ Mirah::Compiler::JVM.verbose = true
889
+ ast = Mirah::AST.parse(File.read(ARGV[0]))
876
890
 
877
- typer = Duby::Typer::Simple.new(:script)
891
+ typer = Mirah::Typer::Simple.new(:script)
878
892
  ast.infer(typer)
879
893
  typer.resolve(true)
880
894
 
881
- compiler = Duby::Compiler::JVM.new(ARGV[0])
895
+ compiler = Mirah::Compiler::JVM.new(ARGV[0])
882
896
  compiler.compile(ast)
883
897
 
884
898
  compiler.generate
@@ -1,4 +1,19 @@
1
- module Duby
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ module Mirah
2
17
  module JVM
3
18
  module MethodLookup
4
19
  # dummy log; it's expected the inclusion target will have it
@@ -1,3 +1,18 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah'
2
17
  require 'mirah/ast'
3
18
  require 'mirah/jvm/types'
@@ -12,10 +27,10 @@ class String
12
27
  end
13
28
  end
14
29
 
15
- module Duby
30
+ module Mirah
16
31
  module Compiler
17
32
  class JavaSource < JVMCompilerBase
18
- JVMTypes = Duby::JVM::Types
33
+ JVMTypes = Mirah::JVM::Types
19
34
  attr_accessor :lvalue
20
35
 
21
36
  Operators = [
@@ -34,7 +49,7 @@ module Duby
34
49
  end
35
50
 
36
51
  def file_builder(filename)
37
- Duby::JavaSource::Builder.new(filename, self)
52
+ Mirah::JavaSource::Builder.new(filename, self)
38
53
  end
39
54
 
40
55
  def output_type
@@ -185,8 +200,8 @@ module Duby
185
200
  @method.declare_local(type, name)
186
201
  end
187
202
 
188
- def declare_field(name, type, annotations)
189
- @class.declare_field(name, type, @static, 'private', annotations)
203
+ def declare_field(name, type, annotations, static_field)
204
+ @class.declare_field(name, type, @static || static_field, 'private', annotations)
190
205
  end
191
206
 
192
207
  def local(scope, name, type)
@@ -194,9 +209,9 @@ module Duby
194
209
  @method.print name
195
210
  end
196
211
 
197
- def field(name, type, annotations)
212
+ def field(name, type, annotations, static_field)
198
213
  name = name[1..-1] if name =~ /^@/
199
- declare_field(name, type, annotations)
214
+ declare_field(name, type, annotations, static_field)
200
215
  @method.print "#{this}.#{name}"
201
216
  end
202
217
 
@@ -258,9 +273,9 @@ module Duby
258
273
  declare_local(name, type)
259
274
  end
260
275
 
261
- def field_assign(name, type, expression, value, annotations)
276
+ def field_assign(name, type, expression, value, annotations, static_field)
262
277
  name = name[1..-1] if name =~ /^@/
263
- declare_field(name, type, annotations)
278
+ declare_field(name, type, annotations, static_field)
264
279
  lvalue = "#{@lvalue if expression}#{this}.#{name} = "
265
280
  store_value(lvalue, value)
266
281
  end
@@ -377,7 +392,7 @@ module Duby
377
392
  end
378
393
 
379
394
  def expr?(target, params)
380
- !([target] + params).any? {|x| x.kind_of? Duby::AST::TempValue}
395
+ !([target] + params).any? {|x| x.kind_of? Mirah::AST::TempValue}
381
396
  end
382
397
 
383
398
  def operator(target, op, params, expression)
@@ -409,7 +424,7 @@ module Duby
409
424
  else
410
425
  nodes.map do |node|
411
426
  tempval = node.precompile(self)
412
- if node == tempval && !node.kind_of?(Duby::AST::Literal)
427
+ if node == tempval && !node.kind_of?(Mirah::AST::Literal)
413
428
  tempval = node.temp(self)
414
429
  end
415
430
  tempval
@@ -457,7 +472,7 @@ module Duby
457
472
 
458
473
  def call(call, expression)
459
474
  return cast(call, expression) if call.cast?
460
- if Duby::AST::Constant === call.target
475
+ if Mirah::AST::Constant === call.target
461
476
  target = call.target.inferred_type.to_source
462
477
  else
463
478
  target = call.precompile_target(self)
@@ -564,7 +579,7 @@ module Duby
564
579
  if method.argument_types.size == 1
565
580
  @method.print " = ("
566
581
  end
567
- elsif Duby::JVM::Types::Intrinsic === method
582
+ elsif Mirah::JVM::Types::Intrinsic === method
568
583
  method.call(self, call, expression)
569
584
  return
570
585
  else
@@ -663,7 +678,7 @@ module Duby
663
678
  @method.print(lvalue)
664
679
  end
665
680
  first = true
666
- unless nodes[0].kind_of?(Duby::AST::String)
681
+ unless nodes[0].kind_of?(Mirah::AST::String)
667
682
  @method.print '""'
668
683
  first = false
669
684
  end
@@ -1,6 +1,21 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah/jvm/types'
2
17
 
3
- module Duby
18
+ module Mirah
4
19
  class JVM::Types::Type
5
20
  def to_source
6
21
  java_name = name
@@ -10,7 +25,7 @@ module Duby
10
25
  end
11
26
 
12
27
  module JavaSource
13
- JVMTypes ||= Duby::JVM::Types
28
+ JVMTypes ||= Mirah::JVM::Types
14
29
 
15
30
  class Builder
16
31
  attr_accessor :package, :classes, :filename, :compiler
@@ -165,7 +180,7 @@ module Duby
165
180
 
166
181
  class ClassBuilder
167
182
  include Helper
168
- include Duby::Compiler::JVM::JVMLogger
183
+ include Mirah::Compiler::JVM::JVMLogger
169
184
  attr_reader :package, :name, :superclass, :filename, :class_name, :out
170
185
  attr_reader :interfaces, :abstract
171
186
  def initialize(builder, name, superclass, interfaces, abstract)
@@ -263,7 +278,7 @@ module Duby
263
278
 
264
279
  def build_method(name, visibility, static, exceptions, type, *args)
265
280
  finish_declaration
266
- type ||= Duby::AST::type(nil, :void)
281
+ type ||= Mirah::AST::type(nil, :void)
267
282
  @methods << MethodBuilder.new(self,
268
283
  :name => name,
269
284
  :visibility => visibility,
@@ -313,7 +328,7 @@ module Duby
313
328
  def build_method(name, visibility, static, exceptions, type, *args)
314
329
  raise "Interfaces can't have static methods" if static
315
330
  finish_declaration
316
- type ||= Duby::AST::type(nil, :void)
331
+ type ||= Mirah::AST::type(nil, :void)
317
332
  @methods << MethodBuilder.new(self,
318
333
  :name => name,
319
334
  :visibility => visibility,
@@ -363,7 +378,7 @@ module Duby
363
378
  print ' throws '
364
379
  @exceptions.each_with_index do |exception, i|
365
380
  print ', ' unless i == 0
366
- print exception.name
381
+ print exception.to_source
367
382
  end
368
383
  end
369
384
  if @abstract
@@ -1,4 +1,19 @@
1
- class Duby::Compiler::JavaSource < Duby::Compiler::JVMCompilerBase
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ class Mirah::Compiler::JavaSource < Mirah::Compiler::JVMCompilerBase
2
17
  class SimpleWhileLoop
3
18
  attr_reader :compiler, :loop
4
19
  def initialize(loop, compiler)
@@ -1,6 +1,21 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah/ast'
2
17
 
3
- module Duby::AST
18
+ module Mirah::AST
4
19
  class TempValue
5
20
  def initialize(node, compiler=nil, value=nil)
6
21
  if compiler.nil?
@@ -77,7 +92,7 @@ module Duby::AST
77
92
  def expr?(compiler)
78
93
  target.expr?(compiler) &&
79
94
  parameters.all? {|p| p.expr?(compiler)} &&
80
- !method.return_type.kind_of?(Duby::AST::InlineCode) &&
95
+ !method.return_type.kind_of?(Mirah::AST::InlineCode) &&
81
96
  !method.return_type.void?
82
97
  end
83
98
 
@@ -1,10 +1,25 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah/jvm/typer'
2
17
  require 'mirah/jvm/source_generator/builder'
3
18
 
4
- module Duby
19
+ module Mirah
5
20
  module Typer
6
21
  class JavaSource < JVM
7
- include Duby::JVM::Types
22
+ include Mirah::JVM::Types
8
23
 
9
24
  end
10
25
  end
@@ -1,11 +1,26 @@
1
+ # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
+ # All contributing project authors may be found in the NOTICE file.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
1
16
  require 'mirah/typer'
2
17
  require 'mirah/jvm/types'
3
18
  require 'mirah/jvm/types/factory'
4
19
 
5
- module Duby
20
+ module Mirah
6
21
  module Typer
7
22
  class JVM < Simple
8
- include Duby::JVM::Types
23
+ include Mirah::JVM::Types
9
24
 
10
25
  attr_reader :transformer
11
26
 
@@ -21,7 +36,7 @@ module Duby
21
36
  end
22
37
 
23
38
  def set_filename(scope, filename)
24
- classname = Duby::Compiler::JVM.classname_from_filename(filename)
39
+ classname = Mirah::Compiler::JVM.classname_from_filename(filename)
25
40
  main_class = @factory.declare_type(scope, classname)
26
41
  @known_types['self'] = main_class.meta
27
42
  end
@@ -95,7 +110,7 @@ module Duby
95
110
  return_type = sig_args.delete(:return)
96
111
  exceptions = sig_args.delete(:throws)
97
112
  args = method_def.arguments.args || []
98
- static = method_def.kind_of? Duby::AST::StaticMethodDefinition
113
+ static = method_def.kind_of? Mirah::AST::StaticMethodDefinition
99
114
  if sig_args.size != args.size
100
115
  # If the superclass declares one method with the same name and
101
116
  # same number of arguments, assume we're overriding it.