Class: Duby::JVM::Types::IntegerType
- Inherits:
-
Number
- Object
- AST::Node
- AST::TypeReference
- Type
- PrimitiveType
- Number
- Duby::JVM::Types::IntegerType
- Defined in:
- lib/duby/jvm/types/integers.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
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
- #init_value(builder) ⇒ Object
- #jump_if(builder, op, label) ⇒ Object
- #literal(builder, value) ⇒ Object
- #load(builder, index) ⇒ Object
- #math_type ⇒ Object
- #prefix ⇒ Object
- #widen(builder, type) ⇒ Object
Methods inherited from Number
#add_delegates, #boolean_operator, #delegate_intrinsic, #math_operator, #suffix, #unary_operator
Methods inherited from PrimitiveType
#convertible_to?, #initialize, #interfaces, #newarray, #primitive?, #primitive_type
Methods inherited from Type
#add_method, #aload, #array?, #array_type, #assignable_from?, #astore, #basic_type, #compatible?, #component_type, #constructor, #declared_class_methods, #declared_instance_methods, #declared_intrinsics, #get_method, #initialize, #inspect, #interface?, #interfaces, #intrinsics, #is_parent, #iterable?, #java_method, #jvm_type, #meta, #meta?, #newarray, #primitive?, #return, #store, #superclass, #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?, #component_type, #eql?, #error?, #hash, #initialize, #is_parent, #iterable?, #meta?, #narrow, #primitive?, #to_s, #unmeta, #unreachable?
Methods included from AST::Named
Methods inherited from AST::Node
#[], #each, #expr?, #initialize, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s
Constructor Details
This class inherits a constructor from Duby::JVM::Types::PrimitiveType
Instance Method Details
#add_intrinsics ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/duby/jvm/types/integers.rb', line 57 def add_intrinsics super math_operator('<<', 'shl') math_operator('>>', 'shr') math_operator('>>>', 'ushr') math_operator('|', 'or') math_operator('&', 'and') math_operator('^', 'xor') unary_operator('~', 'not') end |
#init_value(builder) ⇒ Object
22 23 24 |
# File 'lib/duby/jvm/types/integers.rb', line 22 def init_value(builder) builder.iconst_0 end |
#jump_if(builder, op, label) ⇒ Object
53 54 55 |
# File 'lib/duby/jvm/types/integers.rb', line 53 def jump_if(builder, op, label) builder.send "if_icmp#{op}", label end |
#literal(builder, value) ⇒ Object
18 19 20 |
# File 'lib/duby/jvm/types/integers.rb', line 18 def literal(builder, value) builder.push_int(value) end |
#load(builder, index) ⇒ Object
26 27 28 |
# File 'lib/duby/jvm/types/integers.rb', line 26 def load(builder, index) builder.iload(index) end |
#prefix ⇒ Object
45 46 47 |
# File 'lib/duby/jvm/types/integers.rb', line 45 def prefix 'i' end |
#widen(builder, type) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/duby/jvm/types/integers.rb', line 30 def widen(builder, type) case type when Byte, Short, Int # do nothing when Long builder.i2l when Float builder.i2f when Double builder.i2d else raise ArgumentError, "Invalid widening conversion from #{name} to #{type}" end end |