Class: Duby::JVM::Types::LongType

Inherits:
Number show all
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

#array, #meta

Attributes included from AST::Named

#name

Attributes inherited from AST::Node

#children, #inferred_type, #newline, #parent, #position

Instance Method Summary collapse

Methods inherited from Number

#add_delegates, #boolean_operator, #delegate_intrinsic, #jump_if, #math_operator, #math_type, #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, #load, #meta, #meta?, #newarray, #primitive?, #return, #store, #superclass, #to_source, #unmeta, #void?

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

#to_s

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_intrinsicsObject



99
100
101
102
103
104
105
106
107
108
# File 'lib/duby/jvm/types/integers.rb', line 99

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



78
79
80
# File 'lib/duby/jvm/types/integers.rb', line 78

def init_value(builder)
  builder.lconst_0
end

#literal(builder, value) ⇒ Object



74
75
76
# File 'lib/duby/jvm/types/integers.rb', line 74

def literal(builder, value)
  builder.ldc_long(value)
end

#prefixObject



70
71
72
# File 'lib/duby/jvm/types/integers.rb', line 70

def prefix
  'l'
end

#wide?Boolean

Returns:



82
83
84
# File 'lib/duby/jvm/types/integers.rb', line 82

def wide?
  true
end

#widen(builder, type) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/duby/jvm/types/integers.rb', line 86

def widen(builder, type)
  case type
  when Long
    # do nothing
  when Float
    builder.l2f
  when Double
    builder.l2d
  else
    raise ArgumentError, "Invalid widening conversion from Int to #{type}"
  end
end