mirah 0.1.2-java → 0.1.3-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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +225 -0
  3. data/Rakefile +108 -315
  4. data/TODO.md +100 -0
  5. data/bin/bundler +16 -0
  6. data/bin/rake +16 -0
  7. data/dist/mirahc.jar +0 -0
  8. data/examples/appengine/Readme +0 -1
  9. data/examples/literals.mirah +17 -0
  10. data/examples/macros/string_each_char.mirah +1 -1
  11. data/lib/mirah.rb +11 -21
  12. data/lib/mirah/transform/transformer.rb +1 -2
  13. data/lib/mirah/util/class_loader.rb +1 -1
  14. data/lib/mirah/util/logging.rb +0 -63
  15. data/lib/mirah/util/process_errors.rb +1 -0
  16. data/lib/mirah/version.rb +1 -1
  17. data/{examples/simple_class.mirah~ → test/artifacts/jar_test.rb} +7 -11
  18. data/{lib/mirah/commands.rb → test/artifacts/jruby_test.rb} +8 -5
  19. data/test/core/typer_test.rb +29 -11
  20. data/test/core/util/argument_processor_test.rb +24 -23
  21. data/test/core/util/class_loader_test.rb +7 -4
  22. data/test/core/util/{compilation_state_test.rb → jvm_version_test.rb} +20 -16
  23. data/test/fixtures/org/foo/ImplicitClassRetAnno.java +4 -0
  24. data/test/fixtures/org/foo/IntAnno.java +9 -0
  25. data/test/jvm/annotations_test.rb +11 -11
  26. data/test/jvm/blocks_test.rb +16 -12
  27. data/test/jvm/constructors_test.rb +8 -8
  28. data/test/jvm/enumerable_test.rb +48 -24
  29. data/test/jvm/generics_test.rb +3 -7
  30. data/test/jvm/import_test.rb +14 -0
  31. data/test/jvm/interface_test.rb +9 -24
  32. data/test/jvm/jvm_commands_test.rb +22 -4
  33. data/test/jvm/jvm_compiler_test.rb +124 -79
  34. data/test/jvm/list_extensions_test.rb +1 -1
  35. data/test/jvm/macros_test.rb +67 -14
  36. data/test/jvm/main_method_test.rb +1 -1
  37. data/test/jvm/new_backend_test_helper.rb +100 -3
  38. data/{lib/mirah/jvm/types/bitescript_ext.rb → test/jvm/static_fields_test.rb} +22 -21
  39. data/test/mirrors/base_type_test.rb +4 -3
  40. data/test/mirrors/bytecode_mirror_test.rb +35 -15
  41. data/test/mirrors/generics_test.rb +14 -5
  42. data/test/mirrors/member_test.rb +2 -1
  43. data/test/mirrors/method_lookup_test.rb +18 -6
  44. data/test/mirrors/mirrors_test.rb +87 -20
  45. data/test/mirrors/simple_async_mirror_loader_test.rb +7 -3
  46. data/test/mirrors/simple_mirror_loader_test.rb +5 -5
  47. data/test/test_helper.rb +25 -1
  48. metadata +18 -78
  49. data/bin/mirahp +0 -27
  50. data/bin/mirahp.cmd +0 -16
  51. data/examples/Fib.class +0 -0
  52. data/javalib/mirah-bootstrap.jar +0 -0
  53. data/javalib/mirah-builtins.jar +0 -0
  54. data/javalib/mirah-compiler.jar +0 -0
  55. data/javalib/mirah-mirrors.jar +0 -0
  56. data/javalib/mirah-newast-transitional.jar +0 -0
  57. data/javalib/mirah-parser.jar +0 -0
  58. data/javalib/mirah-util.jar +0 -0
  59. data/lib/mirah/ast.rb +0 -43
  60. data/lib/mirah/ast/scope.rb +0 -262
  61. data/lib/mirah/commands/base.rb +0 -59
  62. data/lib/mirah/commands/compile.rb +0 -39
  63. data/lib/mirah/commands/parse.rb +0 -36
  64. data/lib/mirah/commands/run.rb +0 -78
  65. data/lib/mirah/generator.rb +0 -150
  66. data/lib/mirah/jvm/compiler.rb +0 -50
  67. data/lib/mirah/jvm/compiler/base.rb +0 -421
  68. data/lib/mirah/jvm/compiler/jvm_bytecode.rb +0 -1194
  69. data/lib/mirah/jvm/method_lookup.rb +0 -307
  70. data/lib/mirah/jvm/types.rb +0 -45
  71. data/lib/mirah/jvm/types/array_type.rb +0 -60
  72. data/lib/mirah/jvm/types/ast_ext.rb +0 -31
  73. data/lib/mirah/jvm/types/basic_types.rb +0 -41
  74. data/lib/mirah/jvm/types/block_type.rb +0 -15
  75. data/lib/mirah/jvm/types/boolean.rb +0 -70
  76. data/lib/mirah/jvm/types/enumerable.rb +0 -80
  77. data/lib/mirah/jvm/types/extensions.rb +0 -110
  78. data/lib/mirah/jvm/types/factory.rb +0 -830
  79. data/lib/mirah/jvm/types/floats.rb +0 -99
  80. data/lib/mirah/jvm/types/generic_type.rb +0 -72
  81. data/lib/mirah/jvm/types/implicit_nil_type.rb +0 -29
  82. data/lib/mirah/jvm/types/integers.rb +0 -131
  83. data/lib/mirah/jvm/types/interface_definition.rb +0 -20
  84. data/lib/mirah/jvm/types/intrinsics.rb +0 -385
  85. data/lib/mirah/jvm/types/literals.rb +0 -89
  86. data/lib/mirah/jvm/types/meta_type.rb +0 -54
  87. data/lib/mirah/jvm/types/methods.rb +0 -946
  88. data/lib/mirah/jvm/types/null_type.rb +0 -39
  89. data/lib/mirah/jvm/types/number.rb +0 -184
  90. data/lib/mirah/jvm/types/primitive_type.rb +0 -76
  91. data/lib/mirah/jvm/types/source_mirror.rb +0 -274
  92. data/lib/mirah/jvm/types/type.rb +0 -311
  93. data/lib/mirah/jvm/types/type_definition.rb +0 -72
  94. data/lib/mirah/jvm/types/void_type.rb +0 -19
  95. data/lib/mirah/util/compilation_state.rb +0 -60
  96. data/test/core/commands_test.rb +0 -89
  97. data/test/core/generator_test.rb +0 -26
  98. data/test/fixtures/org/foo/LowerCaseInnerClass$inner.class +0 -0
  99. data/test/fixtures/org/foo/LowerCaseInnerClass.class +0 -0
  100. data/test/jvm/bytecode_test_helper.rb +0 -193
  101. data/test/jvm/factory_test.rb +0 -28
  102. data/test/jvm/java_typer_test.rb +0 -283
data/bin/mirahp DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env jruby
2
-
3
- # Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
4
- # All contributing project authors may be found in the NOTICE file.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require 'rubygems'
19
-
20
- begin
21
- require 'mirah'
22
- rescue LoadError
23
- $: << File.dirname(File.dirname(__FILE__)) + '/lib'
24
- require 'mirah'
25
- end
26
-
27
- puts Mirah.parse(*ARGV).inspect
@@ -1,16 +0,0 @@
1
- @REM Copyright (c) 2010 The Mirah project authors. All Rights Reserved.
2
- @REM All contributing project authors may be found in the NOTICE file.
3
- @REM
4
- @REM Licensed under the Apache License, Version 2.0 (the "License");
5
- @REM you may not use this file except in compliance with the License.
6
- @REM You may obtain a copy of the License at
7
- @REM
8
- @REM http://www.apache.org/licenses/LICENSE-2.0
9
- @REM
10
- @REM Unless required by applicable law or agreed to in writing, software
11
- @REM distributed under the License is distributed on an "AS IS" BASIS,
12
- @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- @REM See the License for the specific language governing permissions and
14
- @REM limitations under the License.
15
-
16
- @jruby "%~dpn0" %*
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,43 +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/util/delegate'
17
- require 'mirah/transform'
18
- require 'mirah/ast/scope'
19
-
20
- module Mirah
21
- module AST
22
- class << self
23
- attr_accessor :verbose
24
- end
25
-
26
- java_import 'mirah.lang.ast.Array'
27
- java_import 'mirah.lang.ast.Annotation'
28
- java_import 'mirah.lang.ast.Constant'
29
- java_import 'mirah.lang.ast.EmptyArray'
30
- java_import 'mirah.lang.ast.Fixnum'
31
- java_import 'mirah.lang.ast.HashEntry'
32
- java_import 'mirah.lang.ast.LocalAccess'
33
- java_import 'mirah.lang.ast.Node'
34
- java_import 'mirah.lang.ast.NodeList'
35
- java_import 'mirah.lang.ast.Noop'
36
- java_import 'mirah.lang.ast.OptionalArgument'
37
- java_import 'mirah.lang.ast.Position'
38
- java_import 'mirah.lang.ast.SimpleString'
39
- java_import 'mirah.lang.ast.TypeName'
40
- java_import 'mirah.lang.ast.TypeRef'
41
-
42
- end
43
- end
@@ -1,262 +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 StaticScope
19
- java_import 'java.util.LinkedHashMap'
20
- java_import 'org.mirah.typer.Scope'
21
- java_import 'org.mirah.typer.AssignableTypeFuture'
22
- java_import 'org.mirah.typer.BaseTypeFuture'
23
- java_import 'org.mirah.typer.LocalFuture'
24
- java_import 'org.mirah.typer.ErrorType'
25
- include Scope
26
-
27
- attr_reader :parent
28
- attr_writer :self_type, :self_node
29
-
30
- def initialize(node, scoper, parent=nil)
31
- @scope_node = node
32
- @vars = {}
33
- @var_types = {}
34
- @parent = parent
35
- @children = {}
36
- @imports = {}
37
- @search_packages = []
38
- @shadowed = {}
39
- @scoper = scoper
40
- @temps = Hash.new {|h,k| h[k] = -1}
41
- @package_block = nil
42
- end
43
-
44
- def context
45
- @scope_node
46
- end
47
-
48
- def to_s
49
- #"#<StaticScope node=#{@scope_node.to_s}>"
50
- inspect
51
- end
52
-
53
- def inspect
54
- result = "#<StaticScope\n node=#{@scope_node.inspect}\n "
55
- result << "parent=#{@parent}\n " if @parent
56
- result << "vars=#{locals.inspect}\n " if @vars.size > 0
57
- result << "shadowed=#{@shadowed.keys.inspect}\n " if @shadowed.size > 0
58
- result << "captured=#{capturedLocals.inspect}\n " if capturedLocals.size > 0
59
- result << "temps=#{@temps.keys.inspect}\n " if @temps.size > 0
60
- result << "package=#{@package}\n " if @package
61
- result << "imports=#{@imports.inspect}\n " if @imports.size > 0
62
- result << "search=#{@search_packages.inspect}\n " if @search_packages.size > 0
63
- result << "self=#{@self_node.inspect}\n " if @self_node
64
- if @self_type
65
- result << "self_type=#{@self_type}"
66
- if @self_type.isResolved
67
- result << " (#{@self_type.resolve.full_name})"
68
- end
69
- result << "\n "
70
- end
71
- result << ">"
72
- end
73
-
74
- def toString; inspect; end
75
-
76
- def <<(name)
77
- @vars[name] = true
78
- end
79
-
80
- def shadow(name)
81
- @shadowed[name] = @vars[name] = true
82
- end
83
-
84
- def shadowed?(name)
85
- @shadowed[name]
86
- end
87
-
88
- def locals
89
- @vars.keys
90
- end
91
-
92
- def capturedLocals
93
- locals.select {|name| self.captured?(name)}
94
- end
95
-
96
- def temp(name="tmp")
97
- "#{name}$#{@temps[name] += 1}"
98
- end
99
-
100
- def local_type(name, position=nil)
101
- @var_types[name] ||= begin
102
- type = LocalFuture.new(name, position)
103
- type.onUpdate {|_, resolved| self << name unless resolved.isError}
104
- if parent && !shadowed?(name)
105
- # TODO what if a var of the same name is later declared in the parent scope?
106
- type.parent_set(parent.local_type(name, position))
107
- end
108
- type
109
- end
110
- end
111
-
112
- def include?(name, include_parent=true)
113
- @vars.include?(name) ||
114
- (include_parent && parent && parent.include?(name))
115
- end
116
-
117
- def captured?(name)
118
- if !include?(name, false)
119
- return false
120
- elsif parent && parent.include?(name)
121
- return true
122
- else
123
- return children.any? {|child| child.include?(name, false)}
124
- end
125
- end
126
-
127
- def isCaptured(name)
128
- self.captured?(name)
129
- end
130
-
131
- def children
132
- @children.keys
133
- end
134
-
135
- def add_child(scope)
136
- @children[scope] = true
137
- end
138
-
139
- def remove_child(scope)
140
- @children.delete(scope)
141
- end
142
-
143
- def parent=(parent)
144
- @parent.remove_child(self) if @parent
145
- parent.add_child(self)
146
- @parent = parent
147
- end
148
-
149
- def outer_scope
150
- node = @scope_node
151
- return nil if node.nil? || node.parent.nil?
152
- @scoper.getScope(node)
153
- end
154
-
155
- def self_type
156
- if @self_type.nil? && parent
157
- @self_type = parent.self_type
158
- end
159
- @self_type
160
- end
161
-
162
- def self_node
163
- if @self_node.nil? && parent
164
- @self_node = parent.self_node
165
- end
166
- @self_node
167
- end
168
-
169
- def binding_type
170
- if parent
171
- parent.binding_type
172
- else
173
- @binding_type
174
- end
175
- end
176
-
177
- def binding_type=(type)
178
- if parent
179
- parent.binding_type = type
180
- else
181
- @binding_type = type
182
- end
183
- end
184
- alias :binding_type_set :binding_type=
185
-
186
- def has_binding?
187
- @binding_type != nil || (parent && parent.has_binding?)
188
- end
189
-
190
- def package
191
- @package || (outer_scope && outer_scope.package)
192
- end
193
-
194
- def package=(package)
195
- raise ArgumentError, "Package already set to #{@package.inspect}" if @package
196
- @package = package
197
- if @package_block
198
- @package_block.call
199
- end
200
- end
201
-
202
- def on_package_change(&block)
203
- @package_block = block
204
- end
205
-
206
- def fetch_imports(map)
207
- parent_scope = outer_scope
208
- parent_scope.fetch_imports(map) if parent_scope
209
-
210
- map.update(@imports)
211
- end
212
-
213
- def fetch_packages(list)
214
- parent_scope = outer_scope
215
- parent_scope.fetch_packages(list) if parent_scope
216
-
217
- list.concat(@search_packages)
218
- end
219
-
220
- def imports
221
- @cached_imports ||= fetch_imports({})
222
- end
223
-
224
- def search_packages
225
- @cached_packages ||= fetch_packages([])
226
- end
227
-
228
- def staticImport(type)
229
- future = BaseTypeFuture.new(self_type.position)
230
- extended = self_type.resolve.include(type.resolve)
231
- future.resolved(extended)
232
- self.self_type = future
233
- end
234
-
235
- def import(full_name, short_name)
236
- return if full_name == short_name
237
- if short_name == '*'
238
- @search_packages << full_name.sub(/\.\*$/, '')
239
- @cached_packages = nil
240
- else
241
- @imports[short_name] = full_name
242
- @cached_imports = nil
243
- end
244
- end
245
- def selfType
246
- self_type
247
- end # Should this be resolved?
248
- def selfType_set(type)
249
- self.self_type = type
250
- end
251
- def parent_set(scope)
252
- self.parent = scope
253
- end
254
- def package_set(package)
255
- self.package = package
256
- end
257
- def resetDefaultSelfNode
258
- self.self_node = :self
259
- end
260
- end
261
- end
262
- end
@@ -1,59 +0,0 @@
1
- # Copyright (c) 2010-2013 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/util/compilation_state'
17
- require 'mirah/util/argument_processor'
18
- require 'mirah/errors'
19
-
20
- module Mirah
21
- module Commands
22
- class Base
23
- include Mirah::Logging::Logged
24
- def initialize(args)
25
- @state = Mirah::Util::CompilationState.new
26
- @state.command = command_name
27
- @args = args
28
- @argument_processor = Mirah::Util::ArgumentProcessor.new(@state, @args)
29
- end
30
-
31
- attr_accessor :state, :args, :argument_processor
32
-
33
- def execute_base
34
- argument_processor.process
35
- if argument_processor.exit?
36
- exit argument_processor.exit_status_code
37
- end
38
- # because MirahCommand is a JRuby Java class, SystemExit bubbles through and makes noise
39
- # so we use a catch/throw to early exit instead
40
- # see util/process_errors.rb
41
- status = catch(:exit) do
42
- begin
43
- yield
44
- rescue Mirah::InternalCompilerError => ice
45
- Mirah.print_error(ice.message, ice.position) if ice.node
46
- raise ice.cause || ice
47
- rescue Mirah::MirahError => ex
48
- Mirah.print_error(ex.message, ex.position)
49
- log "{0}\n{1}", [ex.message, ex.backtrace.join("\n")]
50
- throw :exit, 1
51
- end
52
- 0
53
- end
54
- exit status if status > 0
55
- true
56
- end
57
- end
58
- end
59
- end
@@ -1,39 +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/generator'
17
- require 'fileutils'
18
-
19
- module Mirah
20
- module Commands
21
- class Compile < Base
22
- def execute
23
- execute_base do
24
- generator = Mirah::Generator.new(@state, @state.compiler_class, true, @state.verbose)
25
-
26
- generator.generate(@state.args).each do |result|
27
- filename = "#{@state.destination}#{result.filename}"
28
- FileUtils.mkdir_p(File.dirname(filename))
29
- File.open(filename, 'wb') {|f| f.write(result.bytes)}
30
- end
31
- end
32
- end
33
-
34
- def command_name
35
- :compile
36
- end
37
- end
38
- end
39
- end