mirah 0.0.7-java → 0.0.8-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +181 -0
- data/README.txt +6 -10
- data/Rakefile +86 -9
- data/bin/mirah +2 -0
- data/bin/mirahc +2 -0
- data/bin/mirahp +2 -0
- data/{bin/dubyp → examples/interfaces.mirah} +16 -9
- data/examples/macros/square.mirah +12 -0
- data/examples/macros/square_int.mirah +12 -0
- data/examples/macros/string-each-char.mirah +14 -0
- data/examples/maven/README.txt +2 -0
- data/examples/maven/pom.xml +23 -0
- data/examples/maven/src/main/mirah/hello_mirah.mirah +9 -0
- data/examples/rosettacode/100-doors.mirah +44 -0
- data/examples/rosettacode/99-bottles-of-beer.mirah +13 -0
- data/examples/rosettacode/README.txt +9 -0
- data/examples/rosettacode/boolean-values.mirah +29 -0
- data/examples/rosettacode/comments.mirah +2 -0
- data/examples/rosettacode/copy-a-string.mirah +10 -0
- data/examples/rosettacode/count-occurrences-of-a-substring.mirah +40 -0
- data/examples/rosettacode/create-a-file.mirah +6 -0
- data/examples/rosettacode/empty-string.mirah +9 -0
- data/examples/rosettacode/factorial.mirah +10 -0
- data/examples/rosettacode/fibonacci.mirah +21 -0
- data/examples/rosettacode/file-size.mirah +5 -0
- data/examples/rosettacode/fizz-buzz.mirah +21 -0
- data/examples/rosettacode/flatten-a-list.mirah +24 -0
- data/examples/rosettacode/guess-the-number.mirah +21 -0
- data/examples/rosettacode/is-string-numeric.mirah +127 -0
- data/examples/rosettacode/palindrome.mirah +14 -0
- data/examples/rosettacode/repeat-a-string.mirah +9 -0
- data/examples/rosettacode/reverse-a-string.mirah +6 -0
- data/examples/rosettacode/rot-13.mirah +20 -0
- data/examples/rosettacode/user-input.mirah +4 -0
- data/examples/sort_closure.mirah +1 -1
- data/javalib/dynalink-0.2.jar +0 -0
- data/javalib/mirah-bootstrap.jar +0 -0
- data/lib/mirah.rb +7 -16
- data/lib/mirah/ast.rb +22 -92
- data/lib/mirah/ast/call.rb +41 -9
- data/lib/mirah/ast/class.rb +34 -6
- data/lib/mirah/ast/flow.rb +17 -5
- data/lib/mirah/ast/intrinsics.rb +50 -8
- data/lib/mirah/ast/literal.rb +7 -0
- data/lib/mirah/ast/local.rb +9 -1
- data/lib/mirah/ast/method.rb +21 -8
- data/lib/mirah/ast/scope.rb +1 -1
- data/lib/mirah/ast/structure.rb +81 -15
- data/lib/mirah/ast/type.rb +4 -0
- data/{bin/dubyc → lib/mirah/commands.rb} +4 -11
- data/lib/mirah/commands/base.rb +54 -0
- data/lib/mirah/commands/compile.rb +39 -0
- data/{examples/wiki/Rakefile → lib/mirah/commands/parse.rb} +18 -17
- data/lib/mirah/commands/run.rb +73 -0
- data/lib/mirah/compiler.rb +37 -417
- data/lib/mirah/compiler/call.rb +45 -0
- data/lib/mirah/compiler/class.rb +81 -0
- data/lib/mirah/compiler/flow.rb +109 -0
- data/lib/mirah/compiler/literal.rb +130 -0
- data/lib/mirah/compiler/local.rb +59 -0
- data/lib/mirah/compiler/method.rb +44 -0
- data/lib/mirah/compiler/structure.rb +65 -0
- data/lib/mirah/compiler/type.rb +27 -0
- data/lib/mirah/env.rb +4 -6
- data/lib/mirah/generator.rb +61 -0
- data/lib/mirah/jvm/compiler.rb +8 -867
- data/lib/mirah/jvm/compiler/base.rb +270 -0
- data/lib/mirah/jvm/compiler/java_source.rb +779 -0
- data/lib/mirah/jvm/compiler/jvm_bytecode.rb +851 -0
- data/lib/mirah/jvm/method_lookup.rb +21 -2
- data/lib/mirah/jvm/source_generator/builder.rb +10 -13
- data/lib/mirah/jvm/source_generator/loops.rb +99 -93
- data/lib/mirah/jvm/source_generator/precompile.rb +3 -2
- data/lib/mirah/jvm/typer.rb +3 -3
- data/lib/mirah/jvm/types.rb +10 -426
- data/lib/mirah/jvm/types/array_type.rb +62 -0
- data/lib/mirah/jvm/types/basic_types.rb +1 -0
- data/lib/mirah/jvm/types/dynamic_type.rb +46 -0
- data/lib/mirah/jvm/types/factory.rb +23 -5
- data/lib/mirah/jvm/types/interface_definition.rb +20 -0
- data/lib/mirah/jvm/types/intrinsics.rb +15 -3
- data/lib/mirah/jvm/types/meta_type.rb +45 -0
- data/lib/mirah/jvm/types/methods.rb +12 -5
- data/lib/mirah/jvm/types/null_type.rb +27 -0
- data/lib/mirah/jvm/types/primitive_type.rb +38 -0
- data/lib/mirah/jvm/types/source_mirror.rb +266 -0
- data/lib/mirah/jvm/types/type.rb +173 -0
- data/lib/mirah/jvm/types/type_definition.rb +55 -0
- data/lib/mirah/jvm/types/unreachable_type.rb +27 -0
- data/lib/mirah/jvm/types/void_type.rb +19 -0
- data/lib/mirah/parser.rb +90 -0
- data/lib/mirah/plugin/gwt.rb +5 -5
- data/lib/mirah/plugin/java.rb +1 -1
- data/lib/mirah/transform.rb +4 -321
- data/lib/mirah/transform/ast_ext.rb +63 -0
- data/lib/mirah/transform/error.rb +13 -0
- data/lib/mirah/transform/helper.rb +761 -0
- data/lib/mirah/transform/transformer.rb +255 -0
- data/lib/mirah/typer.rb +2 -383
- data/{bin/duby → lib/mirah/typer/base.rb} +12 -10
- data/lib/mirah/typer/simple.rb +377 -0
- data/lib/mirah/util/argument_processor.rb +114 -0
- data/lib/mirah/util/class_loader.rb +37 -0
- data/lib/mirah/util/compilation_state.rb +51 -0
- data/lib/mirah/util/process_errors.rb +33 -0
- data/lib/mirah/version.rb +1 -1
- data/lib/mirah_task.rb +3 -2
- data/test/{test_ast.rb → core/test_ast.rb} +6 -0
- data/test/{test_compilation.rb → core/test_compilation.rb} +0 -0
- data/test/{test_env.rb → core/test_env.rb} +24 -25
- data/test/{test_macros.rb → core/test_macros.rb} +2 -4
- data/test/{test_typer.rb → core/test_typer.rb} +0 -3
- data/test/jvm/bytecode_test_helper.rb +181 -0
- data/test/{test_javac_compiler.rb → jvm/javac_test_helper.rb} +38 -22
- data/test/jvm/test_enumerable.rb +304 -0
- data/test/{test_java_typer.rb → jvm/test_java_typer.rb} +2 -4
- data/test/{test_jvm_compiler.rb → jvm/test_jvm_compiler.rb} +146 -443
- data/test/jvm/test_macros.rb +147 -0
- data/test/jvm/test_main_method.rb +15 -0
- data/test/{test_gwt.rb → plugins/test_gwt.rb} +0 -2
- metadata +103 -91
- data/bin/jrubyp +0 -52
- data/examples/wiki/src/org/mirah/wiki/MirahWiki.duby +0 -339
- data/examples/wiki/src/org/mirah/wiki/edit.eduby.html +0 -42
- data/examples/wiki/src/org/mirah/wiki/error.eduby.html +0 -2
- data/examples/wiki/src/org/mirah/wiki/layout.eduby.html +0 -69
- data/examples/wiki/src/org/mirah/wiki/parser.eduby.html +0 -7
- data/examples/wiki/src/org/mirah/wiki/view.eduby.html +0 -15
- data/examples/wiki/war/WEB-INF/classes/test/HeredocContext.class +0 -0
- data/examples/wiki/war/WEB-INF/classes/test/MirahParser.class +0 -0
- data/examples/wiki/war/WEB-INF/lib/appengine-api.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/dubydatastore.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/jmeta-runtime.jar +0 -0
- data/examples/wiki/war/WEB-INF/lib/pegdown-stubs.jar +0 -0
- data/examples/wiki/war/WEB-INF/pegdown.jar +0 -0
- data/examples/wiki/war/app.yaml +0 -21
- data/examples/wiki/war/public/favicon.ico +0 -0
- data/examples/wiki/war/public/images/appengine_duby.png +0 -0
- data/examples/wiki/war/public/images/back.gif +0 -0
- data/examples/wiki/war/public/images/dir.gif +0 -0
- data/examples/wiki/war/public/images/file.gif +0 -0
- data/examples/wiki/war/public/javascripts/prettify.js +0 -61
- data/examples/wiki/war/public/robots.txt +0 -0
- data/examples/wiki/war/public/stylesheets/main.css +0 -156
- data/examples/wiki/war/public/stylesheets/prettify.css +0 -1
- data/examples/wiki/war/public/stylesheets/sh_style.css +0 -66
- data/examples/wiki/war/public/stylesheets/source.css +0 -21
- data/examples/wiki/war/public/wmd/images/bg-fill.png +0 -0
- data/examples/wiki/war/public/wmd/images/bg.png +0 -0
- data/examples/wiki/war/public/wmd/images/blockquote.png +0 -0
- data/examples/wiki/war/public/wmd/images/bold.png +0 -0
- data/examples/wiki/war/public/wmd/images/code.png +0 -0
- data/examples/wiki/war/public/wmd/images/h1.png +0 -0
- data/examples/wiki/war/public/wmd/images/hr.png +0 -0
- data/examples/wiki/war/public/wmd/images/img.png +0 -0
- data/examples/wiki/war/public/wmd/images/italic.png +0 -0
- data/examples/wiki/war/public/wmd/images/link.png +0 -0
- data/examples/wiki/war/public/wmd/images/ol.png +0 -0
- data/examples/wiki/war/public/wmd/images/redo.png +0 -0
- data/examples/wiki/war/public/wmd/images/separator.png +0 -0
- data/examples/wiki/war/public/wmd/images/ul.png +0 -0
- data/examples/wiki/war/public/wmd/images/undo.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd-on.png +0 -0
- data/examples/wiki/war/public/wmd/images/wmd.png +0 -0
- data/examples/wiki/war/public/wmd/showdown.js +0 -421
- data/examples/wiki/war/public/wmd/wmd-base.js +0 -1799
- data/examples/wiki/war/public/wmd/wmd-plus.js +0 -311
- data/examples/wiki/war/public/wmd/wmd.js +0 -73
- data/examples/wiki/war/src/org/mirah/wiki/MirahWiki.duby +0 -339
- data/examples/wiki/war/src/org/mirah/wiki/edit.eduby.html +0 -42
- data/examples/wiki/war/src/org/mirah/wiki/error.eduby.html +0 -2
- data/examples/wiki/war/src/org/mirah/wiki/layout.eduby.html +0 -69
- data/examples/wiki/war/src/org/mirah/wiki/parser.eduby.html +0 -7
- data/examples/wiki/war/src/org/mirah/wiki/view.eduby.html +0 -15
- data/javalib/dynalink-0.1.jar +0 -0
- data/javalib/jsr292-mock.jar +0 -0
- data/lib/mirah/class_loader.rb +0 -35
- data/lib/mirah/compilation_state.rb +0 -28
- data/lib/mirah/impl.rb +0 -273
- data/lib/mirah/jvm/base.rb +0 -267
- data/lib/mirah/jvm/source_compiler.rb +0 -760
- data/lib/mirah/transform2.rb +0 -752
@@ -0,0 +1,45 @@
|
|
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
|
@@ -0,0 +1,81 @@
|
|
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
|
@@ -0,0 +1,109 @@
|
|
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
|
@@ -0,0 +1,130 @@
|
|
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
|
@@ -0,0 +1,59 @@
|
|
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
|
@@ -0,0 +1,44 @@
|
|
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 Arguments
|
19
|
+
def compile(compiler, expression)
|
20
|
+
# TODO: what does it mean for a method to be an expression?
|
21
|
+
args.each {|arg| compiler.declare_argument(arg.name, arg.inferred_type)} if args
|
22
|
+
rescue Exception => ex
|
23
|
+
raise Mirah::InternalCompilerError.wrap(ex, self)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class MethodDefinition
|
28
|
+
def compile(compiler, expression)
|
29
|
+
# TODO: what does it mean for a method to be an expression?
|
30
|
+
compiler.define_method(self)
|
31
|
+
rescue Exception => ex
|
32
|
+
raise Mirah::InternalCompilerError.wrap(ex, self)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class ConstructorDefinition
|
37
|
+
def compile(compiler, expression)
|
38
|
+
compiler.constructor(self)
|
39
|
+
rescue Exception => ex
|
40
|
+
raise Mirah::InternalCompilerError.wrap(ex, self)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|