mirah 0.0.12-java → 0.1.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. data/History.txt +372 -0
  2. data/README.txt +4 -5
  3. data/Rakefile +178 -55
  4. data/examples/appengine/Readme +3 -3
  5. data/examples/appengine/src/org/mirah/MirahApp.mirah +1 -1
  6. data/examples/appengine/src/org/mirah/list.dhtml +1 -1
  7. data/examples/bintrees.mirah +1 -1
  8. data/examples/edb.mirah +1 -1
  9. data/examples/fib.mirah +1 -1
  10. data/examples/interfaces.mirah +1 -1
  11. data/examples/macros/{string-each-char.mirah → string_each_char.mirah} +4 -5
  12. data/examples/maven/README.txt +1 -1
  13. data/examples/maven/src/main/mirah/hello_mirah.mirah +1 -1
  14. data/examples/plugins/appengine/Rakefile +1 -1
  15. data/examples/plugins/appengine/src/com/google/appengine/ext/duby/db/MetaModel.mirah +1 -1
  16. data/examples/plugins/appengine/src/com/google/appengine/ext/duby/db/Model.duby +1 -1
  17. data/examples/plugins/appengine/test/com/google/appengine/ext/duby/db/ModelTest.duby +1 -1
  18. data/examples/rosettacode/100-doors.mirah +6 -6
  19. data/examples/rosettacode/README.txt +3 -3
  20. data/examples/rosettacode/boolean-values.mirah +1 -1
  21. data/examples/rosettacode/comments.mirah +1 -1
  22. data/examples/rosettacode/count-occurrences-of-a-substring.mirah +1 -1
  23. data/examples/rosettacode/factorial.mirah +1 -1
  24. data/examples/rosettacode/fibonacci.mirah +1 -1
  25. data/examples/rosettacode/fizz-buzz.mirah +2 -2
  26. data/examples/rosettacode/flatten-a-list.mirah +4 -4
  27. data/examples/rosettacode/guess-the-number.mirah +2 -2
  28. data/examples/rosettacode/hamming-numbers.mirah +4 -4
  29. data/examples/rosettacode/is-string-numeric.mirah +22 -22
  30. data/examples/rosettacode/palindrome.mirah +2 -2
  31. data/examples/rosettacode/random-numbers.mirah +1 -1
  32. data/examples/rosettacode/repeat-a-string.mirah +1 -1
  33. data/examples/rosettacode/reverse-a-string.mirah +1 -1
  34. data/examples/rosettacode/rot-13.mirah +5 -5
  35. data/examples/rosettacode/secure-temporary-file.mirah +2 -2
  36. data/examples/rosettacode/sleep.mirah +1 -1
  37. data/examples/rosettacode/string-length.mirah +5 -5
  38. data/examples/swing.mirah +1 -1
  39. data/examples/test.edb +1 -1
  40. data/javalib/mirah-bootstrap.jar +0 -0
  41. data/javalib/mirah-builtins.jar +0 -0
  42. data/javalib/mirah-parser.jar +0 -0
  43. data/javalib/mirah-util.jar +0 -0
  44. data/lib/duby.rb +1 -1
  45. data/lib/mirah.rb +50 -28
  46. data/lib/mirah/ast.rb +15 -605
  47. data/lib/mirah/ast/scope.rb +98 -69
  48. data/lib/mirah/commands.rb +1 -1
  49. data/lib/mirah/commands/base.rb +7 -7
  50. data/lib/mirah/commands/compile.rb +3 -3
  51. data/lib/mirah/commands/parse.rb +7 -5
  52. data/lib/mirah/commands/run.rb +12 -19
  53. data/lib/mirah/compiler.rb +15 -23
  54. data/lib/mirah/errors.rb +16 -1
  55. data/lib/mirah/generator.rb +79 -39
  56. data/lib/mirah/jvm/compiler.rb +1 -19
  57. data/lib/mirah/jvm/compiler/base.rb +233 -90
  58. data/lib/mirah/jvm/compiler/jvm_bytecode.rb +675 -363
  59. data/lib/mirah/jvm/method_lookup.rb +134 -65
  60. data/lib/mirah/jvm/typer.rb +10 -5
  61. data/lib/mirah/jvm/types.rb +10 -2
  62. data/lib/mirah/jvm/types/array_type.rb +10 -12
  63. data/lib/mirah/{compiler/type.rb → jvm/types/ast_ext.rb} +12 -8
  64. data/lib/mirah/jvm/types/basic_types.rb +26 -33
  65. data/lib/mirah/jvm/types/bitescript_ext.rb +1 -1
  66. data/lib/mirah/jvm/types/block_type.rb +15 -0
  67. data/lib/mirah/jvm/types/boolean.rb +8 -4
  68. data/lib/mirah/jvm/types/dynamic_type.rb +12 -13
  69. data/lib/mirah/jvm/types/enumerable.rb +7 -7
  70. data/lib/mirah/jvm/types/extensions.rb +11 -6
  71. data/lib/mirah/jvm/types/factory.rb +624 -94
  72. data/lib/mirah/jvm/types/floats.rb +21 -15
  73. data/lib/mirah/jvm/types/generic_type.rb +72 -0
  74. data/lib/mirah/jvm/types/implicit_nil_type.rb +29 -0
  75. data/lib/mirah/jvm/types/integers.rb +26 -71
  76. data/lib/mirah/jvm/types/interface_definition.rb +3 -3
  77. data/lib/mirah/jvm/types/intrinsics.rb +203 -168
  78. data/lib/mirah/jvm/types/literals.rb +6 -6
  79. data/lib/mirah/jvm/types/meta_type.rb +13 -4
  80. data/lib/mirah/jvm/types/methods.rb +281 -93
  81. data/lib/mirah/jvm/types/null_type.rb +17 -5
  82. data/lib/mirah/jvm/types/number.rb +10 -7
  83. data/lib/mirah/jvm/types/primitive_type.rb +17 -6
  84. data/lib/mirah/jvm/types/source_mirror.rb +12 -7
  85. data/lib/mirah/jvm/types/type.rb +107 -23
  86. data/lib/mirah/jvm/types/type_definition.rb +25 -10
  87. data/lib/mirah/jvm/types/unreachable_type.rb +1 -1
  88. data/lib/mirah/jvm/types/void_type.rb +3 -3
  89. data/lib/mirah/parser.rb +154 -16
  90. data/lib/mirah/plugin/edb.rb +1 -1
  91. data/lib/mirah/transform.rb +1 -2
  92. data/lib/mirah/transform/ast_ext.rb +24 -43
  93. data/lib/mirah/transform/transformer.rb +29 -224
  94. data/lib/mirah/typer.rb +2 -16
  95. data/lib/mirah/util/argument_processor.rb +25 -10
  96. data/lib/mirah/util/class_loader.rb +1 -1
  97. data/lib/mirah/util/compilation_state.rb +16 -17
  98. data/lib/mirah/util/delegate.rb +2 -2
  99. data/lib/mirah/util/logging.rb +110 -0
  100. data/lib/mirah/util/process_errors.rb +69 -11
  101. data/lib/mirah/version.rb +1 -1
  102. data/test/core/commands_test.rb +6 -24
  103. data/test/core/env_test.rb +5 -5
  104. data/{lib/mirah/jvm/source_generator/typer.rb → test/core/generator_test.rb} +9 -9
  105. data/test/core/typer_test.rb +196 -158
  106. data/test/core/util/argument_processor_test.rb +10 -10
  107. data/test/core/util/class_loader_test.rb +6 -5
  108. data/test/fixtures/org/foo/LowerCaseInnerClass$inner.class +0 -0
  109. data/test/fixtures/org/foo/LowerCaseInnerClass.class +0 -0
  110. data/test/fixtures/org/foo/LowerCaseInnerClass.java +7 -0
  111. data/test/jvm/annotations_test.rb +5 -5
  112. data/test/jvm/blocks_test.rb +140 -88
  113. data/test/jvm/bytecode_test_helper.rb +112 -94
  114. data/test/jvm/cast_test.rb +162 -0
  115. data/test/jvm/constructors_test.rb +18 -8
  116. data/test/jvm/enumerable_test.rb +77 -44
  117. data/test/jvm/example_test.rb +53 -0
  118. data/test/jvm/factory_test.rb +7 -1
  119. data/test/jvm/generics_test.rb +57 -0
  120. data/test/jvm/hash_test.rb +106 -0
  121. data/test/jvm/import_test.rb +81 -0
  122. data/test/jvm/interface_test.rb +73 -0
  123. data/test/jvm/java_typer_test.rb +92 -66
  124. data/{lib/mirah/typer/base.rb → test/jvm/jvm_commands_test.rb} +6 -10
  125. data/test/jvm/jvm_compiler_test.rb +170 -604
  126. data/test/jvm/list_extensions_test.rb +23 -0
  127. data/test/jvm/macros_test.rb +197 -32
  128. data/test/jvm/main_method_test.rb +4 -4
  129. data/test/jvm/numeric_extensions_test.rb +13 -0
  130. data/test/jvm/rescue_test.rb +73 -16
  131. data/test/jvm/varargs_test.rb +65 -0
  132. data/test/test_helper.rb +1 -2
  133. metadata +234 -251
  134. data/examples/SortClosure$__xform_tmp_1.class +0 -0
  135. data/examples/SortClosure$__xform_tmp_2.class +0 -0
  136. data/examples/SortClosure.class +0 -0
  137. data/examples/macros/StringEachChar$Extension1.class +0 -0
  138. data/lib/mirah/ast/call.rb +0 -345
  139. data/lib/mirah/ast/class.rb +0 -359
  140. data/lib/mirah/ast/flow.rb +0 -381
  141. data/lib/mirah/ast/intrinsics.rb +0 -563
  142. data/lib/mirah/ast/literal.rb +0 -178
  143. data/lib/mirah/ast/local.rb +0 -112
  144. data/lib/mirah/ast/method.rb +0 -408
  145. data/lib/mirah/ast/structure.rb +0 -387
  146. data/lib/mirah/ast/type.rb +0 -146
  147. data/lib/mirah/commands/base.rb~ +0 -57
  148. data/lib/mirah/compiler/call.rb +0 -45
  149. data/lib/mirah/compiler/class.rb +0 -81
  150. data/lib/mirah/compiler/flow.rb +0 -109
  151. data/lib/mirah/compiler/literal.rb +0 -130
  152. data/lib/mirah/compiler/local.rb +0 -59
  153. data/lib/mirah/compiler/method.rb +0 -44
  154. data/lib/mirah/compiler/structure.rb +0 -65
  155. data/lib/mirah/jvm/compiler/java_source.rb +0 -787
  156. data/lib/mirah/jvm/method_lookup.rb~ +0 -247
  157. data/lib/mirah/jvm/source_generator/builder.rb +0 -468
  158. data/lib/mirah/jvm/source_generator/loops.rb +0 -131
  159. data/lib/mirah/jvm/source_generator/precompile.rb +0 -210
  160. data/lib/mirah/plugin/gwt.rb +0 -189
  161. data/lib/mirah/plugin/java.rb +0 -70
  162. data/lib/mirah/transform/error.rb +0 -13
  163. data/lib/mirah/transform/helper.rb +0 -765
  164. data/lib/mirah/typer/simple.rb +0 -384
  165. data/lib/mirah/version.rb~ +0 -18
  166. data/test/core/ast_test.rb +0 -382
  167. data/test/core/compilation_test.rb +0 -130
  168. data/test/core/macros_test.rb +0 -61
  169. data/test/jvm/javac_test_helper.rb +0 -89
  170. data/test/jvm/jvm_compiler_test.rb~ +0 -2181
  171. data/test/plugins/gwt_test.rb +0 -69
@@ -1,57 +0,0 @@
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
- require 'mirah/jvm/types'
17
- require 'mirah/util/compilation_state'
18
- require 'mirah/util/argument_processor'
19
- require 'mirah/errors'
20
-
21
- module Mirah
22
- module Commands
23
- class Base
24
- def initialize(args)
25
- Mirah::AST.type_factory = Mirah::JVM::Types::TypeFactory.new
26
- @state = Mirah::Util::CompilationState.new
27
- @state.command = command_name
28
- @args = args
29
- @argument_processor = Mirah::Util::ArgumentProcessor.new(@state, @args)
30
- end
31
-
32
- attr_accessor :state, :args, :argument_processor
33
-
34
- def execute_base
35
- # because MirahCommand is a JRuby Java class, SystemExit bubbles through and makes noise
36
- # so we use a catch/throw to early exit instead
37
- # see util/process_errors.rb
38
- status = catch(:exit) do
39
- begin
40
- argument_processor.process
41
- yield
42
- rescue Mirah::InternalCompilerError => ice
43
- Mirah.print_error(ice.message, ice.position) if ice.node
44
- raise ice.cause if (ice.cause && state.verbose)
45
- raise ice
46
- rescue Mirah::MirahError => ex
47
- Mirah.print_error(ex.message, ex.position)
48
- puts ex.backtrace if state.verbose
49
- throw :exit, 1
50
- end
51
- 0
52
- end
53
- exit status if status > 0
54
- end
55
- end
56
- end
57
- end
@@ -1,45 +0,0 @@
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
17
- module AST
18
- class FunctionalCall
19
- def compile(compiler, expression)
20
- compiler.line(line_number)
21
- compiler.self_call(self, expression)
22
- rescue Exception => ex
23
- raise Mirah::InternalCompilerError.wrap(ex, self)
24
- end
25
- end
26
-
27
- class Call
28
- def compile(compiler, expression)
29
- compiler.line(line_number)
30
- compiler.call(self, expression)
31
- rescue Exception => ex
32
- raise Mirah::InternalCompilerError.wrap(ex, self)
33
- end
34
- end
35
-
36
- class Super
37
- def compile(compiler, expression)
38
- compiler.line(line_number)
39
- compiler.super_call(self, expression)
40
- rescue Exception => ex
41
- raise Mirah::InternalCompilerError.wrap(ex, self)
42
- end
43
- end
44
- end
45
- end
@@ -1,81 +0,0 @@
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
17
- module AST
18
- class ClassDefinition
19
- def compile(compiler, expression)
20
- compiler.define_class(self, expression)
21
- rescue Exception => ex
22
- raise Mirah::InternalCompilerError.wrap(ex, self)
23
- end
24
- end
25
-
26
- class ClosureDefinition
27
- def compile(compiler, expression)
28
- compiler.define_closure(self, expression)
29
- rescue Exception => ex
30
- raise Mirah::InternalCompilerError.wrap(ex, self)
31
- end
32
- end
33
-
34
- class AccessLevel
35
- def compile(compiler, expression); end
36
- end
37
-
38
- class FieldDeclaration
39
- def compile(compiler, expression)
40
- compiler.field_declare(name, inferred_type, annotations, static)
41
- rescue Exception => ex
42
- raise Mirah::InternalCompilerError.wrap(ex, self)
43
- end
44
- end
45
-
46
- class FieldAssignment
47
- def compile(compiler, expression)
48
- compiler.line(line_number)
49
- compiler.field_assign(name, inferred_type, expression, value, annotations, static)
50
- rescue Exception => ex
51
- raise Mirah::InternalCompilerError.wrap(ex, self)
52
- end
53
- end
54
-
55
- class Field
56
- def compile(compiler, expression)
57
- compiler.line(line_number)
58
- if expression
59
- compiler.field(name, inferred_type, annotations, static)
60
- end
61
- rescue Exception => ex
62
- raise Mirah::InternalCompilerError.wrap(ex, self)
63
- end
64
- end
65
-
66
- class Include
67
- def compile(compiler, expression); end
68
- end
69
-
70
- class Constant
71
- def compile(compiler, expression)
72
- if expression
73
- compiler.line(line_number)
74
- compiler.constant(self)
75
- end
76
- rescue Exception => ex
77
- raise Mirah::InternalCompilerError.wrap(ex, self)
78
- end
79
- end
80
- end
81
- end
@@ -1,109 +0,0 @@
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
17
- module AST
18
- class If
19
- def compile(compiler, expression)
20
- compiler.line(line_number)
21
- compiler.branch(self, expression)
22
- rescue Exception => ex
23
- raise Mirah::InternalCompilerError.wrap(ex, self)
24
- end
25
- end
26
-
27
- class Condition
28
- def compile(compiler, expression)
29
- # TODO: can a condition ever be an expression? I don't think it can...
30
- compiler.line(line_number)
31
- predicate.compile(compiler, expression)
32
- rescue Exception => ex
33
- raise Mirah::InternalCompilerError.wrap(ex, self)
34
- end
35
- end
36
-
37
- class Loop
38
- def compile(compiler, expression)
39
- compiler.line(line_number)
40
- compiler.loop(self, expression)
41
- rescue Exception => ex
42
- raise Mirah::InternalCompilerError.wrap(ex, self)
43
- end
44
- end
45
-
46
- class Return
47
- def compile(compiler, expression)
48
- compiler.line(line_number)
49
- compiler.return(self)
50
- rescue Exception => ex
51
- raise Mirah::InternalCompilerError.wrap(ex, self)
52
- end
53
- end
54
-
55
- class Break
56
- def compile(compiler, expression)
57
- compiler.line(line_number)
58
- compiler.break(self)
59
- rescue Exception => ex
60
- raise Mirah::InternalCompilerError.wrap(ex, self)
61
- end
62
- end
63
-
64
- class Next
65
- def compile(compiler, expression)
66
- compiler.line(line_number)
67
- compiler.next(self)
68
- rescue Exception => ex
69
- raise Mirah::InternalCompilerError.wrap(ex, self)
70
- end
71
- end
72
-
73
- class Redo
74
- def compile(compiler, expression)
75
- compiler.line(line_number)
76
- compiler.redo(self)
77
- rescue Exception => ex
78
- raise Mirah::InternalCompilerError.wrap(ex, self)
79
- end
80
- end
81
-
82
- class Raise
83
- def compile(compiler, expression)
84
- compiler.line(line_number)
85
- compiler._raise(exception)
86
- rescue Exception => ex
87
- raise Mirah::InternalCompilerError.wrap(ex, self)
88
- end
89
- end
90
-
91
- class Rescue
92
- def compile(compiler, expression)
93
- compiler.line(line_number)
94
- compiler.rescue(self, expression)
95
- rescue Exception => ex
96
- raise Mirah::InternalCompilerError.wrap(ex, self)
97
- end
98
- end
99
-
100
- class Ensure
101
- def compile(compiler, expression)
102
- compiler.line(line_number)
103
- compiler.ensure(self, expression)
104
- rescue Exception => ex
105
- raise Mirah::InternalCompilerError.wrap(ex, self)
106
- end
107
- end
108
- end
109
- end
@@ -1,130 +0,0 @@
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
17
- module AST
18
- class Fixnum
19
- def compile(compiler, expression)
20
- if expression
21
- compiler.line(line_number)
22
- compiler.fixnum(inferred_type, literal)
23
- end
24
- rescue Exception => ex
25
- raise Mirah::InternalCompilerError.wrap(ex, self)
26
- end
27
- end
28
-
29
- class Regexp
30
- def compile(compiler, expression)
31
- if expression
32
- compiler.line(line_number)
33
- compiler.regexp(literal)
34
- end
35
- rescue Exception => ex
36
- raise Mirah::InternalCompilerError.wrap(ex, self)
37
- end
38
- end
39
-
40
- class String
41
- def compile(compiler, expression)
42
- if expression
43
- compiler.line(line_number)
44
- compiler.string(literal)
45
- end
46
- rescue Exception => ex
47
- raise Mirah::InternalCompilerError.wrap(ex, self)
48
- end
49
- end
50
-
51
- class StringConcat
52
- def compile(compiler, expression)
53
- compiler.build_string(children, expression)
54
- rescue Exception => ex
55
- raise Mirah::InternalCompilerError.wrap(ex, self)
56
- end
57
- end
58
-
59
- class ToString
60
- def compile(compiler, expression)
61
- compiler.to_string(body, expression)
62
- rescue Exception => ex
63
- raise Mirah::InternalCompilerError.wrap(ex, self)
64
- end
65
- end
66
-
67
- class Float
68
- def compile(compiler, expression)
69
- if expression
70
- compiler.line(line_number)
71
- compiler.float(inferred_type, literal)
72
- end
73
- rescue Exception => ex
74
- raise Mirah::InternalCompilerError.wrap(ex, self)
75
- end
76
- end
77
-
78
- class Boolean
79
- def compile(compiler, expression)
80
- if expression
81
- compiler.line(line_number)
82
- compiler.boolean(literal)
83
- end
84
- rescue Exception => ex
85
- raise Mirah::InternalCompilerError.wrap(ex, self)
86
- end
87
- end
88
-
89
- class Array
90
- def compile(compiler, expression)
91
- compiler.array(self, expression)
92
- rescue Exception => ex
93
- raise Mirah::InternalCompilerError.wrap(ex, self)
94
- end
95
- end
96
-
97
- class Null
98
- def compile(compiler, expression)
99
- if expression
100
- compiler.line(line_number)
101
- compiler.null
102
- end
103
- rescue Exception => ex
104
- raise Mirah::InternalCompilerError.wrap(ex, self)
105
- end
106
- end
107
-
108
- class EmptyArray
109
- def compile(compiler, expression)
110
- if expression
111
- compiler.line(line_number)
112
- compiler.empty_array(component_type, size)
113
- end
114
- rescue Exception => ex
115
- raise Mirah::InternalCompilerError.wrap(ex, self)
116
- end
117
- end
118
-
119
- class Self
120
- def compile(compiler, expression)
121
- if expression
122
- compiler.line(line_number)
123
- compiler.compile_self
124
- end
125
- rescue Exception => ex
126
- raise Mirah::InternalCompilerError.wrap(ex, self)
127
- end
128
- end
129
- end
130
- end
@@ -1,59 +0,0 @@
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
17
- module AST
18
- class LocalDeclaration
19
- def compile(compiler, expression)
20
- compiler.line(line_number)
21
- if captured? && scope.has_binding?
22
- compiler.captured_local_declare(containing_scope, name, type)
23
- else
24
- compiler.local_declare(containing_scope, name, type)
25
- end
26
- rescue Exception => ex
27
- raise Mirah::InternalCompilerError.wrap(ex, self)
28
- end
29
- end
30
-
31
- class LocalAssignment
32
- def compile(compiler, expression)
33
- compiler.line(line_number)
34
- if captured? && scope.has_binding?
35
- compiler.captured_local_assign(self, expression)
36
- else
37
- compiler.local_assign(containing_scope, name, inferred_type, expression, value)
38
- end
39
- rescue Exception => ex
40
- raise Mirah::InternalCompilerError.wrap(ex, self)
41
- end
42
- end
43
-
44
- class Local
45
- def compile(compiler, expression)
46
- if expression
47
- compiler.line(line_number)
48
- if captured? && scope.has_binding?
49
- compiler.captured_local(containing_scope, name, inferred_type)
50
- else
51
- compiler.local(containing_scope, name, inferred_type)
52
- end
53
- end
54
- rescue Exception => ex
55
- raise Mirah::InternalCompilerError.wrap(ex, self)
56
- end
57
- end
58
- end
59
- end