Class: Duby::JVM::Types::ArrayType
- Defined in:
- lib/duby/jvm/types.rb,
lib/duby/jvm/types/intrinsics.rb
Constant Summary
Constants included from MethodLookup
MethodLookup::BOOLEAN, MethodLookup::BYTE, MethodLookup::CHAR, MethodLookup::DOUBLE, MethodLookup::FLOAT, MethodLookup::INT, MethodLookup::LONG, MethodLookup::PrimitiveConversions, MethodLookup::SHORT
Constants inherited from AST::TypeReference
AST::TypeReference::ErrorType, AST::TypeReference::NoType, AST::TypeReference::NullType, AST::TypeReference::UnreachableType
Instance Attribute Summary collapse
-
#component_type ⇒ Object
readonly
Returns the value of attribute component_type.
Attributes inherited from AST::TypeReference
Attributes included from AST::Named
Attributes inherited from AST::Node
#children, #inferred_type, #newline, #parent, #position
Instance Method Summary collapse
- #add_intrinsics ⇒ Object
- #array? ⇒ Boolean
- #basic_type ⇒ Object
-
#initialize(component_type) ⇒ ArrayType
constructor
A new instance of ArrayType.
- #iterable? ⇒ Boolean
- #jvm_type ⇒ Object
- #superclass ⇒ Object
Methods inherited from Type
#add_method, #aload, #array_type, #assignable_from?, #astore, #compatible?, #constructor, #declared_class_methods, #declared_instance_methods, #declared_intrinsics, #get_method, #init_value, #inspect, #interface?, #interfaces, #intrinsics, #is_parent, #java_method, #load, #meta, #meta?, #newarray, #prefix, #primitive?, #return, #store, #to_source, #unmeta, #void?, #wide?
Methods included from MethodLookup
#each_is_exact, #each_is_exact_or_subtype_or_convertible, #find_jls, #find_method, #is_more_specific?, #log, #phase1, #phase2, #phase3, #primitive_convertible?
Methods inherited from AST::TypeReference
#==, #compatible?, #eql?, #error?, #hash, #is_parent, #meta?, #narrow, #primitive?, #to_s, #unmeta, #unreachable?
Methods included from AST::Named
Methods inherited from AST::Node
#[], #each, #expr?, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
#initialize(component_type) ⇒ ArrayType
Returns a new instance of ArrayType.
233 234 235 236 |
# File 'lib/duby/jvm/types.rb', line 233 def initialize(component_type) @component_type = component_type @name = component_type.name end |
Instance Attribute Details
#component_type ⇒ Object (readonly)
Returns the value of attribute component_type.
231 232 233 |
# File 'lib/duby/jvm/types.rb', line 231 def component_type @component_type end |
Instance Method Details
#add_intrinsics ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/duby/jvm/types/intrinsics.rb', line 96 def add_intrinsics super add_method( '[]', [Int], component_type) do |compiler, call, expression| if expression call.target.compile(compiler, true) call.parameters[0].compile(compiler, true) component_type.aload(compiler.method) end end add_method('[]=', [Int, component_type], component_type) do |compiler, call, expression| call.target.compile(compiler, true) convert_args(compiler, call.parameters, [Int, component_type]) component_type.astore(compiler.method) if expression call.parameters[1].compile(compiler, true) end end add_method('length', [], Int) do |compiler, call, expression| call.target.compile(compiler, true) compiler.method.arraylength end end |
#basic_type ⇒ Object
250 251 252 |
# File 'lib/duby/jvm/types.rb', line 250 def basic_type component_type.basic_type end |
#jvm_type ⇒ Object
238 239 240 |
# File 'lib/duby/jvm/types.rb', line 238 def jvm_type @component_type.jvm_type end |