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.
- checksums.yaml +4 -4
- data/History.txt +225 -0
- data/Rakefile +108 -315
- data/TODO.md +100 -0
- data/bin/bundler +16 -0
- data/bin/rake +16 -0
- data/dist/mirahc.jar +0 -0
- data/examples/appengine/Readme +0 -1
- data/examples/literals.mirah +17 -0
- data/examples/macros/string_each_char.mirah +1 -1
- data/lib/mirah.rb +11 -21
- data/lib/mirah/transform/transformer.rb +1 -2
- data/lib/mirah/util/class_loader.rb +1 -1
- data/lib/mirah/util/logging.rb +0 -63
- data/lib/mirah/util/process_errors.rb +1 -0
- data/lib/mirah/version.rb +1 -1
- data/{examples/simple_class.mirah~ → test/artifacts/jar_test.rb} +7 -11
- data/{lib/mirah/commands.rb → test/artifacts/jruby_test.rb} +8 -5
- data/test/core/typer_test.rb +29 -11
- data/test/core/util/argument_processor_test.rb +24 -23
- data/test/core/util/class_loader_test.rb +7 -4
- data/test/core/util/{compilation_state_test.rb → jvm_version_test.rb} +20 -16
- data/test/fixtures/org/foo/ImplicitClassRetAnno.java +4 -0
- data/test/fixtures/org/foo/IntAnno.java +9 -0
- data/test/jvm/annotations_test.rb +11 -11
- data/test/jvm/blocks_test.rb +16 -12
- data/test/jvm/constructors_test.rb +8 -8
- data/test/jvm/enumerable_test.rb +48 -24
- data/test/jvm/generics_test.rb +3 -7
- data/test/jvm/import_test.rb +14 -0
- data/test/jvm/interface_test.rb +9 -24
- data/test/jvm/jvm_commands_test.rb +22 -4
- data/test/jvm/jvm_compiler_test.rb +124 -79
- data/test/jvm/list_extensions_test.rb +1 -1
- data/test/jvm/macros_test.rb +67 -14
- data/test/jvm/main_method_test.rb +1 -1
- data/test/jvm/new_backend_test_helper.rb +100 -3
- data/{lib/mirah/jvm/types/bitescript_ext.rb → test/jvm/static_fields_test.rb} +22 -21
- data/test/mirrors/base_type_test.rb +4 -3
- data/test/mirrors/bytecode_mirror_test.rb +35 -15
- data/test/mirrors/generics_test.rb +14 -5
- data/test/mirrors/member_test.rb +2 -1
- data/test/mirrors/method_lookup_test.rb +18 -6
- data/test/mirrors/mirrors_test.rb +87 -20
- data/test/mirrors/simple_async_mirror_loader_test.rb +7 -3
- data/test/mirrors/simple_mirror_loader_test.rb +5 -5
- data/test/test_helper.rb +25 -1
- metadata +18 -78
- data/bin/mirahp +0 -27
- data/bin/mirahp.cmd +0 -16
- data/examples/Fib.class +0 -0
- data/javalib/mirah-bootstrap.jar +0 -0
- data/javalib/mirah-builtins.jar +0 -0
- data/javalib/mirah-compiler.jar +0 -0
- data/javalib/mirah-mirrors.jar +0 -0
- data/javalib/mirah-newast-transitional.jar +0 -0
- data/javalib/mirah-parser.jar +0 -0
- data/javalib/mirah-util.jar +0 -0
- data/lib/mirah/ast.rb +0 -43
- data/lib/mirah/ast/scope.rb +0 -262
- data/lib/mirah/commands/base.rb +0 -59
- data/lib/mirah/commands/compile.rb +0 -39
- data/lib/mirah/commands/parse.rb +0 -36
- data/lib/mirah/commands/run.rb +0 -78
- data/lib/mirah/generator.rb +0 -150
- data/lib/mirah/jvm/compiler.rb +0 -50
- data/lib/mirah/jvm/compiler/base.rb +0 -421
- data/lib/mirah/jvm/compiler/jvm_bytecode.rb +0 -1194
- data/lib/mirah/jvm/method_lookup.rb +0 -307
- data/lib/mirah/jvm/types.rb +0 -45
- data/lib/mirah/jvm/types/array_type.rb +0 -60
- data/lib/mirah/jvm/types/ast_ext.rb +0 -31
- data/lib/mirah/jvm/types/basic_types.rb +0 -41
- data/lib/mirah/jvm/types/block_type.rb +0 -15
- data/lib/mirah/jvm/types/boolean.rb +0 -70
- data/lib/mirah/jvm/types/enumerable.rb +0 -80
- data/lib/mirah/jvm/types/extensions.rb +0 -110
- data/lib/mirah/jvm/types/factory.rb +0 -830
- data/lib/mirah/jvm/types/floats.rb +0 -99
- data/lib/mirah/jvm/types/generic_type.rb +0 -72
- data/lib/mirah/jvm/types/implicit_nil_type.rb +0 -29
- data/lib/mirah/jvm/types/integers.rb +0 -131
- data/lib/mirah/jvm/types/interface_definition.rb +0 -20
- data/lib/mirah/jvm/types/intrinsics.rb +0 -385
- data/lib/mirah/jvm/types/literals.rb +0 -89
- data/lib/mirah/jvm/types/meta_type.rb +0 -54
- data/lib/mirah/jvm/types/methods.rb +0 -946
- data/lib/mirah/jvm/types/null_type.rb +0 -39
- data/lib/mirah/jvm/types/number.rb +0 -184
- data/lib/mirah/jvm/types/primitive_type.rb +0 -76
- data/lib/mirah/jvm/types/source_mirror.rb +0 -274
- data/lib/mirah/jvm/types/type.rb +0 -311
- data/lib/mirah/jvm/types/type_definition.rb +0 -72
- data/lib/mirah/jvm/types/void_type.rb +0 -19
- data/lib/mirah/util/compilation_state.rb +0 -60
- data/test/core/commands_test.rb +0 -89
- data/test/core/generator_test.rb +0 -26
- data/test/fixtures/org/foo/LowerCaseInnerClass$inner.class +0 -0
- data/test/fixtures/org/foo/LowerCaseInnerClass.class +0 -0
- data/test/jvm/bytecode_test_helper.rb +0 -193
- data/test/jvm/factory_test.rb +0 -28
- data/test/jvm/java_typer_test.rb +0 -283
|
@@ -1,307 +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 JVM
|
|
18
|
-
module MethodLookup
|
|
19
|
-
java_import 'mirah.lang.ast.ConstructorDefinition'
|
|
20
|
-
|
|
21
|
-
def find_method2(mapped_type, name, mapped_params, macro_params, meta, scope=nil, &block)
|
|
22
|
-
find_method(mapped_type, name, mapped_params, macro_params, meta, scope, &block)
|
|
23
|
-
rescue NameError => ex
|
|
24
|
-
raise ex unless ex.message.include?(name)
|
|
25
|
-
if block_given?
|
|
26
|
-
block.call(ex)
|
|
27
|
-
end
|
|
28
|
-
ex
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def find_method(mapped_type, name, mapped_params, macro_params, meta, scope=nil, &block)
|
|
32
|
-
if mapped_type.error?
|
|
33
|
-
raise "WTF?!?"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
if name == 'new' && meta # we're calling SomeClass.new
|
|
37
|
-
name = "<init>"
|
|
38
|
-
constructor = true
|
|
39
|
-
mapped_type = mapped_type.unmeta
|
|
40
|
-
meta = false
|
|
41
|
-
elsif name == 'new' && !meta # we're calling some_instance.new
|
|
42
|
-
constructor = false
|
|
43
|
-
elsif name == '<init>' && !meta # how do we get here?
|
|
44
|
-
constructor = true
|
|
45
|
-
elsif name == 'initialize' && !meta && scope
|
|
46
|
-
context = scope.context
|
|
47
|
-
if context.kind_of?(ConstructorDefinition) || context.findAncesor(ConstructorDefinition.class)
|
|
48
|
-
constructor = true
|
|
49
|
-
name = '<init>'
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
if block_given?
|
|
54
|
-
if constructor
|
|
55
|
-
mapped_type.add_method_listener('initialize') {block.call(find_method2(mapped_type.meta, 'new', mapped_params, macro_params, true))}
|
|
56
|
-
else
|
|
57
|
-
mapped_type.add_method_listener(name) {block.call(find_method2(mapped_type, name, mapped_params, macro_params, meta))}
|
|
58
|
-
end
|
|
59
|
-
block.call(find_method(mapped_type, name, mapped_params, macro_params, meta))
|
|
60
|
-
return
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
begin
|
|
64
|
-
unless mapped_params.any? {|p| p.nil? || p.isError}
|
|
65
|
-
if constructor
|
|
66
|
-
method = mapped_type.constructor(*mapped_params)
|
|
67
|
-
else
|
|
68
|
-
method = mapped_type.java_method(name, *mapped_params)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
rescue NameError => ex
|
|
72
|
-
# TODO return nil instead of raising an exception if the method doesn't exist.
|
|
73
|
-
raise ex unless ex.message =~ /#{Regexp.quote(mapped_type.name)}\.#{Regexp.quote(name)}|No constructor #{Regexp.quote(mapped_type.name)}/
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
macro = mapped_type.macro(name, macro_params)
|
|
77
|
-
if method && macro
|
|
78
|
-
method = nil # Need full lookup to determine precedence.
|
|
79
|
-
elsif method.nil? && macro
|
|
80
|
-
method = macro
|
|
81
|
-
elsif method.nil?
|
|
82
|
-
# exact args failed, do a deeper search
|
|
83
|
-
log "No exact match for #{mapped_type.name}.#{name}(#{mapped_params.map(&:name).join ', '})" if mapped_params.all?
|
|
84
|
-
|
|
85
|
-
method = find_jls(mapped_type, name, mapped_params, macro_params, meta, constructor, scope)
|
|
86
|
-
|
|
87
|
-
unless method
|
|
88
|
-
log "Failed to locate method #{mapped_type.name}.#{name}(#{mapped_params.map(&:name).join ', '})" if mapped_params.all?
|
|
89
|
-
return nil
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
log "Found method #{method.declaring_class.name}.#{name}(#{method.argument_types.map(&:name).join ', '}) from #{mapped_type.name}" if method
|
|
94
|
-
return method
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def find_jls(mapped_type, name, mapped_params, macro_params, meta, constructor, scope=nil)
|
|
98
|
-
interfaces = []
|
|
99
|
-
by_name = if constructor
|
|
100
|
-
mapped_type.unmeta.declared_constructors
|
|
101
|
-
elsif meta
|
|
102
|
-
mapped_type.find_callable_static_methods(name)
|
|
103
|
-
else
|
|
104
|
-
mapped_type.find_callable_methods(name)
|
|
105
|
-
end
|
|
106
|
-
method = find_jls2(mapped_type, name, mapped_params, meta, by_name, true, scope)
|
|
107
|
-
return method if (constructor || macro_params.nil?)
|
|
108
|
-
macros = mapped_type.find_callable_macros(name)
|
|
109
|
-
if macros.size != 0
|
|
110
|
-
log "Found potential macro match for #{mapped_type.name}.#{name}(#{macro_params.map(&:full_name).join ', '})"
|
|
111
|
-
macro = find_jls2(mapped_type, name, macro_params, meta, macros, false, scope)
|
|
112
|
-
end
|
|
113
|
-
if macro && method
|
|
114
|
-
raise "Ambiguous targets invoking #{mapped_type}.#{name}:\n#{macro} and #{method}"
|
|
115
|
-
end
|
|
116
|
-
macro || method
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def find_jls2(mapped_type, name, mapped_params, meta, by_name, include_fields=true, scope=nil)
|
|
120
|
-
return nil if mapped_params.any? {|p| p.nil? || p.isError}
|
|
121
|
-
|
|
122
|
-
# filter by arity, varargs
|
|
123
|
-
by_name_and_arity = by_name.select {|m| m.argument_types.size == mapped_params.size }
|
|
124
|
-
|
|
125
|
-
phase1_methods = phase1(mapped_params, by_name_and_arity)
|
|
126
|
-
|
|
127
|
-
if phase1_methods.size > 1
|
|
128
|
-
method_list = phase1_methods.map do |m|
|
|
129
|
-
case m.member
|
|
130
|
-
when BiteScript::ASM::MethodMirror
|
|
131
|
-
m.member.inspect
|
|
132
|
-
else
|
|
133
|
-
"#{m.name}(#{m.parameter_types.map(&:name).join(', ')})"
|
|
134
|
-
end
|
|
135
|
-
end.join("\n")
|
|
136
|
-
raise "Ambiguous targets invoking #{mapped_type}.#{name}:\n#{method_list}"
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
phase1_methods[0] ||
|
|
140
|
-
phase2(mapped_params, by_name) ||
|
|
141
|
-
phase3(mapped_params, by_name)[0] ||
|
|
142
|
-
(include_fields &&
|
|
143
|
-
(field_lookup(mapped_params, mapped_type, meta, name, scope) ||
|
|
144
|
-
inner_class(mapped_params, mapped_type, meta, name)))
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def phase1(mapped_params, potentials)
|
|
148
|
-
log "Beginning JLS phase 1 search with params (#{mapped_params.map(&:name).join ', '})"
|
|
149
|
-
|
|
150
|
-
# cycle through methods looking for more specific matches; gather matches of equal specificity
|
|
151
|
-
methods = potentials.inject([]) do |currents, potential|
|
|
152
|
-
method_params = potential.argument_types
|
|
153
|
-
next currents unless method_params.all?
|
|
154
|
-
|
|
155
|
-
# exact match always wins; duplicates not possible
|
|
156
|
-
if each_is_exact(mapped_params, method_params)
|
|
157
|
-
return [potential]
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
# otherwise, check for potential match and compare to current
|
|
161
|
-
# TODO: missing ambiguity check; picks first method of equal specificity
|
|
162
|
-
# Picking the first method means we prefer methods from the child class,
|
|
163
|
-
# which is important if the parent class is not accessible (like AbstractStringBuilder).
|
|
164
|
-
if each_is_exact_or_subtype_or_convertible(mapped_params, method_params)
|
|
165
|
-
if !currents.empty?
|
|
166
|
-
if is_more_specific?(currents[0].argument_types, potential.argument_types)
|
|
167
|
-
# currents are better, try next potential
|
|
168
|
-
#next
|
|
169
|
-
elsif is_more_specific?(potential.argument_types, currents[0].argument_types)
|
|
170
|
-
# potential is better, dump all currents
|
|
171
|
-
currents = [potential]
|
|
172
|
-
else
|
|
173
|
-
# equal specificity, append to currents
|
|
174
|
-
currents << potential
|
|
175
|
-
end
|
|
176
|
-
else
|
|
177
|
-
# no previous matches, use potential
|
|
178
|
-
currents = [potential]
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
currents
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
methods
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def is_more_specific?(potential, current)
|
|
189
|
-
each_is_exact_or_subtype_or_convertible(potential, current)
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
def phase2(mapped_params, potentials)
|
|
193
|
-
nil
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def phase3(mapped_params, potentials)
|
|
197
|
-
potential_varargs = potentials.select{|m| m.respond_to?(:varargs?) && m.varargs? }
|
|
198
|
-
methods = potential_varargs.inject([]) do |currents, potential|
|
|
199
|
-
method_params = potential.argument_types
|
|
200
|
-
# match n-1 params of potential
|
|
201
|
-
non_varargs_params, possible_varargs_params = mapped_params.partition.with_index{|param,i| i < method_params.size-1}
|
|
202
|
-
|
|
203
|
-
vararg_types = possible_varargs_params.size.times.map{ method_params.last.component_type }
|
|
204
|
-
|
|
205
|
-
if each_is_exact(non_varargs_params, method_params[0..-2]) &&
|
|
206
|
-
each_is_exact(possible_varargs_params, vararg_types)
|
|
207
|
-
return [potential]
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
if each_is_exact_or_subtype_or_convertible(non_varargs_params, method_params[0..-2]) &&
|
|
211
|
-
each_is_exact_or_subtype_or_convertible(possible_varargs_params, vararg_types)
|
|
212
|
-
currents << potential
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
currents
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
def field_lookup(mapped_params, mapped_type, meta, name, scope)
|
|
220
|
-
log("Attempting #{meta ? 'static' : 'instance'} field lookup for '#{name}' on class #{mapped_type}")
|
|
221
|
-
# if we get to this point, the potentials do not match, so we ignore them
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
# search for a field of the given name
|
|
225
|
-
if name =~ /_set$/
|
|
226
|
-
# setter
|
|
227
|
-
setter = true
|
|
228
|
-
name = name[0..-5]
|
|
229
|
-
field = mapped_type.field_setter(name)
|
|
230
|
-
else
|
|
231
|
-
# getter
|
|
232
|
-
setter = false
|
|
233
|
-
|
|
234
|
-
# field accesses don't take arguments
|
|
235
|
-
return if mapped_params.size > 0
|
|
236
|
-
field = mapped_type.field_getter(name)
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
return nil unless field
|
|
240
|
-
|
|
241
|
-
if (meta && !field.static?) ||
|
|
242
|
-
(!meta && field.static?)
|
|
243
|
-
return nil
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
# check accessibility
|
|
247
|
-
# TODO: protected field access check appropriate to current type
|
|
248
|
-
if setter
|
|
249
|
-
if field.final?
|
|
250
|
-
log "cannot set final field '#{name}' on class #{mapped_type}"
|
|
251
|
-
return nil
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
unless field.public?
|
|
255
|
-
from = " from #{scope.selfType.resolve.name}" if scope
|
|
256
|
-
log "cannot access field '#{name}' on class #{mapped_type}#{from}"
|
|
257
|
-
return nil
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
field
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
def inner_class(params, type, meta, name)
|
|
264
|
-
return unless params.empty? && meta
|
|
265
|
-
log("Attempting inner class lookup for '#{name}' on #{type}")
|
|
266
|
-
type.inner_class_getter(name)
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
def each_is_exact(incoming, target)
|
|
270
|
-
incoming.zip(target).all? { |in_type, target_type| target_type == in_type }
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
def each_is_exact_or_subtype_or_convertible(incoming, target)
|
|
274
|
-
incoming.zip(target).each do |in_type, target_type|
|
|
275
|
-
|
|
276
|
-
# exact match
|
|
277
|
-
next if target_type == in_type
|
|
278
|
-
|
|
279
|
-
unless target_type.respond_to?(:primitive?) && in_type.respond_to?(:primitive?)
|
|
280
|
-
puts "Huh?"
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
# primitive is safely convertible
|
|
284
|
-
if target_type.primitive?
|
|
285
|
-
if in_type.primitive?
|
|
286
|
-
next if primitive_convertible? in_type, target_type
|
|
287
|
-
end
|
|
288
|
-
return false
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
# object type is assignable
|
|
292
|
-
compatible = if target_type.respond_to?(:compatible?)
|
|
293
|
-
target_type.compatible? in_type
|
|
294
|
-
else
|
|
295
|
-
target_type.assignable_from? in_type
|
|
296
|
-
end
|
|
297
|
-
return false unless compatible
|
|
298
|
-
end
|
|
299
|
-
return true
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
def primitive_convertible?(in_type, target_type)
|
|
303
|
-
in_type.convertible_to?(target_type)
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
end
|
|
307
|
-
end
|
data/lib/mirah/jvm/types.rb
DELETED
|
@@ -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
|
-
require 'bitescript'
|
|
17
|
-
require 'mirah/ast'
|
|
18
|
-
require 'mirah/jvm/method_lookup'
|
|
19
|
-
require 'mirah/util/logging'
|
|
20
|
-
#require 'mirah/jvm/compiler'
|
|
21
|
-
require 'set'
|
|
22
|
-
module Mirah::JVM
|
|
23
|
-
module Types
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
require 'mirah/jvm/types/type'
|
|
27
|
-
require 'mirah/jvm/types/primitive_type'
|
|
28
|
-
require 'mirah/jvm/types/meta_type'
|
|
29
|
-
require 'mirah/jvm/types/generic_type'
|
|
30
|
-
require 'mirah/jvm/types/null_type'
|
|
31
|
-
require 'mirah/jvm/types/implicit_nil_type'
|
|
32
|
-
require 'mirah/jvm/types/void_type'
|
|
33
|
-
require 'mirah/jvm/types/block_type'
|
|
34
|
-
require 'mirah/jvm/types/array_type'
|
|
35
|
-
require 'mirah/jvm/types/type_definition'
|
|
36
|
-
require 'mirah/jvm/types/interface_definition'
|
|
37
|
-
require 'mirah/jvm/types/intrinsics'
|
|
38
|
-
require 'mirah/jvm/types/methods'
|
|
39
|
-
require 'mirah/jvm/types/number'
|
|
40
|
-
require 'mirah/jvm/types/integers'
|
|
41
|
-
require 'mirah/jvm/types/boolean'
|
|
42
|
-
require 'mirah/jvm/types/floats'
|
|
43
|
-
require 'mirah/jvm/types/literals'
|
|
44
|
-
require 'mirah/jvm/types/factory'
|
|
45
|
-
require 'mirah/jvm/types/extensions'
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module Mirah
|
|
2
|
-
module JVM
|
|
3
|
-
module Types
|
|
4
|
-
class ArrayType < Type
|
|
5
|
-
attr_reader :component_type
|
|
6
|
-
|
|
7
|
-
def initialize(component_type)
|
|
8
|
-
@component_type = component_type
|
|
9
|
-
|
|
10
|
-
@name = component_type.name
|
|
11
|
-
@type_system = component_type.type_system
|
|
12
|
-
self.intrinsics
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def array?
|
|
16
|
-
true
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def iterable?
|
|
20
|
-
true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def inner_class?
|
|
24
|
-
basic_type.inner_class?
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def basic_type
|
|
28
|
-
component_type.basic_type
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def superclass
|
|
32
|
-
object_type = @type_system.type(nil, 'java.lang.Object')
|
|
33
|
-
if component_type.primitive?
|
|
34
|
-
object_type
|
|
35
|
-
elsif component_type.array?
|
|
36
|
-
# fix covariance here for arrays of arrays
|
|
37
|
-
# see #55
|
|
38
|
-
object_type
|
|
39
|
-
else
|
|
40
|
-
if component_type == object_type
|
|
41
|
-
object_type
|
|
42
|
-
else
|
|
43
|
-
component_type.superclass.array_type
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def interfaces(include_parent=true)
|
|
49
|
-
[]
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def meta
|
|
53
|
-
@meta ||= ArrayMetaType.new(self)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
class ArrayMetaType < MetaType; end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
@@ -1,31 +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
|
-
class Java::MirahLangAst::NodeImpl
|
|
17
|
-
def annotated_abstract?
|
|
18
|
-
annotations.each do |anno|
|
|
19
|
-
if anno.type.typeref.name == 'org.mirah.jvm.types.Modifiers'
|
|
20
|
-
anno.values.each do |entry|
|
|
21
|
-
if entry.key.identifier == 'flags'
|
|
22
|
-
entry.value.values.each do |value|
|
|
23
|
-
return true if value.identifier == 'ABSTRACT'
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
false
|
|
30
|
-
end
|
|
31
|
-
end
|
|
@@ -1,41 +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::JVM::Types
|
|
17
|
-
class TypeFactory
|
|
18
|
-
def create_basic_types
|
|
19
|
-
@known_types.update(
|
|
20
|
-
'boolean' => BooleanType.new(self, 'boolean', java.lang.Boolean),
|
|
21
|
-
'byte' => IntegerType.new(self, 'byte', java.lang.Byte),
|
|
22
|
-
'char' => CharacterType.new(self, 'char', java.lang.Character),
|
|
23
|
-
'short' => IntegerType.new(self, 'short', java.lang.Short),
|
|
24
|
-
'int' => IntegerType.new(self, 'int', java.lang.Integer),
|
|
25
|
-
'long' => LongType.new(self, 'long', java.lang.Long),
|
|
26
|
-
'float' => FloatType.new(self, 'float', java.lang.Float),
|
|
27
|
-
'double' => DoubleType.new(self, 'double', java.lang.Double)
|
|
28
|
-
)
|
|
29
|
-
@known_types['fixnum'] = @known_types['int']
|
|
30
|
-
@known_types['Object'] = type(nil, 'java.lang.Object')
|
|
31
|
-
@known_types['string'] = @known_types['String'] = @known_types['java.lang.String'] =
|
|
32
|
-
StringType.new(self, get_mirror('java.lang.String'))
|
|
33
|
-
type(nil, 'java.lang.Class')
|
|
34
|
-
@known_types['Iterable'] = @known_types['java.lang.Iterable'] =
|
|
35
|
-
IterableType.new(self, get_mirror('java.lang.Iterable'))
|
|
36
|
-
@known_types['void'] = VoidType.new(self)
|
|
37
|
-
@known_types['null'] = NullType.new(self)
|
|
38
|
-
@known_types['implicit_nil'] = ImplicitNilType.new(self)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|