Class: Mirah::JVM::Types::ArrayType
- Inherits:
-
Type
- Object
- Type
- Mirah::JVM::Types::ArrayType
show all
- Defined in:
- lib/mirah/jvm/types/array_type.rb,
lib/mirah/jvm/types/intrinsics.rb
Constant Summary
Logging::Logged::VLEVELS
Instance Attribute Summary collapse
Attributes inherited from Type
#inner_class, #name, #type_system
Instance Method Summary
collapse
Methods inherited from Type
#abstract?, #add_compiled_macro, #add_enumerable_macros, #add_method, #add_method_listener, #aload, #ancestors_and_interfaces, #array_type, #assignableFrom, #assignable_from?, #astore, #class_id, #compatible?, #constructor, #declared_class_methods, #declared_constructors, #declared_instance_methods, #declared_intrinsics, #declared_macros, #dynamic?, #error?, #expand_each, #field_getter, #field_setter, #find_callable_macros, #find_callable_macros2, #find_callable_methods, #find_callable_methods2, #find_callable_static_methods, #flags, #full_name, #generic, #generic?, #getAsmType, #getDeclaredField, #getDeclaredFields, #get_method, #hasStaticField, #include, #init_value, #inner_class_getter, #inspect, #interface?, #internal_name, #intrinsics, #isAnnotation, #isArray, #isBlock, #isEnum, #isError, #isGeneric, #isMeta, #isPrimitive, #is_parent, #java_method, #jvm_type, #load, #load_extensions, #macro, #macros, #matchesAnything, #meta?, #method_listeners, #method_updated, #newarray, #pop, #prefix, #primitive?, #read_macrodef_annotation, #retention, #return, #store, #to_s, #type_parameters, #ungeneric, #unmeta, #void?, #wide?, #widen
#error, #info, #log, #logger, #logger_name, #logging?, #vlog, #warning
#each_is_exact, #each_is_exact_or_subtype_or_convertible, #field_lookup, #find_jls, #find_jls2, #find_method, #find_method2, #inner_class, #is_more_specific?, #phase1, #phase2, #phase3, #primitive_convertible?
Constructor Details
#initialize(component_type) ⇒ ArrayType
Returns a new instance of ArrayType.
7
8
9
10
11
12
13
|
# File 'lib/mirah/jvm/types/array_type.rb', line 7
def initialize(component_type)
@component_type = component_type
@name = component_type.name
@type_system = component_type.type_system
self.intrinsics
end
|
Instance Attribute Details
#component_type ⇒ Object
Returns the value of attribute component_type.
5
6
7
|
# File 'lib/mirah/jvm/types/array_type.rb', line 5
def component_type
@component_type
end
|
Instance Method Details
#add_intrinsics ⇒ Object
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
# File 'lib/mirah/jvm/types/intrinsics.rb', line 259
def add_intrinsics
super
load_extensions(EnumerableExtensions.java_class) if EnumerableExtensions
load_extensions(ArrayExtensions.java_class) if ArrayExtensions
int_type = @type_system.type(nil, 'int')
add_method(
'[]', [int_type], component_type, "ARRAY_ACCESS") do |compiler, call, expression|
if expression
compiler.visit(call.target, true)
compiler.visit(call.parameters(0), true)
component_type.aload(compiler.method)
end
end
add_method('[]=',
[int_type, component_type],
component_type, "ARRAY_ASSIGN") do |compiler, call, expression|
compiler.visit(call.target, true)
convert_args(compiler, call.parameters, [@type_system.type(nil, 'int'), component_type])
component_type.astore(compiler.method)
if expression
compiler.visit(call.parameters(1), true)
end
end
add_method('length', [], int_type, "ARRAY_LENGTH") do |compiler, call, expression|
compiler.visit(call.target, true)
compiler.method.arraylength
end
end
|
#array? ⇒ Boolean
15
16
17
|
# File 'lib/mirah/jvm/types/array_type.rb', line 15
def array?
true
end
|
#basic_type ⇒ Object
27
28
29
|
# File 'lib/mirah/jvm/types/array_type.rb', line 27
def basic_type
component_type.basic_type
end
|
#inner_class? ⇒ Boolean
23
24
25
|
# File 'lib/mirah/jvm/types/array_type.rb', line 23
def inner_class?
basic_type.inner_class?
end
|
#interfaces(include_parent = true) ⇒ Object
48
49
50
|
# File 'lib/mirah/jvm/types/array_type.rb', line 48
def interfaces(include_parent=true)
[]
end
|
#iterable? ⇒ Boolean
19
20
21
|
# File 'lib/mirah/jvm/types/array_type.rb', line 19
def iterable?
true
end
|
52
53
54
|
# File 'lib/mirah/jvm/types/array_type.rb', line 52
def meta
@meta ||= ArrayMetaType.new(self)
end
|
#superclass ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/mirah/jvm/types/array_type.rb', line 31
def superclass
object_type = @type_system.type(nil, 'java.lang.Object')
if component_type.primitive?
object_type
elsif component_type.array?
object_type
else
if component_type == object_type
object_type
else
component_type.superclass.array_type
end
end
end
|