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

Inherits:
Number show all
Defined in:
lib/duby/jvm/types/integers.rb

Constant Summary

Constants inherited from AST::TypeReference

AST::TypeReference::BlockType, AST::TypeReference::ErrorType, AST::TypeReference::NoType, AST::TypeReference::NullType, AST::TypeReference::UnreachableType

Instance Attribute Summary

Attributes inherited from Type

#inner_class

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, #box, #delegate_intrinsic, #jump_if, #math_operator, #suffix, #unary_operator

Methods inherited from PrimitiveType

#convertible_to?, #initialize, #interfaces, #newarray, #primitive?, #primitive_type, #superclass

Methods inherited from Type

#add_enumerable_macros, #add_macro, #add_method, #aload, #array?, #array_type, #assignable_from?, #astore, #basic_type, #compatible?, #component_type, #constructor, #declared_class_methods, #declared_constructors, #declared_instance_methods, #declared_intrinsics, #dynamic?, #expand_each, #field_getter, #field_setter, #get_method, #initialize, #inner_class?, #inner_class_getter, #inspect, #interface?, #interfaces, #intrinsics, #is_parent, #iterable?, #java_method, #jvm_type, #load, #log, #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, #field_lookup, #find_jls, #find_method, #inner_class, #is_more_specific?, #log, #phase1, #phase2, #phase3, #primitive_convertible?

Methods inherited from AST::TypeReference

#==, #block?, #compatible?, #component_type, #eql?, #error?, #hash, #initialize, #is_parent, #iterable?, #meta?, #narrow, #null?, #primitive?, #to_s, #unmeta, #unreachable?

Methods included from AST::Named

#to_s

Methods inherited from AST::Node

#<<, ===, #[], #_set_parent, child, child_name, #each, #empty?, #expr?, #initialize, #initialize_copy, #insert, #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



160
161
162
163
164
165
166
167
168
169
# File 'lib/duby/jvm/types/integers.rb', line 160

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

#box_typeObject



131
132
133
# File 'lib/duby/jvm/types/integers.rb', line 131

def box_type
  java.lang.Long
end

#init_value(builder) ⇒ Object



139
140
141
# File 'lib/duby/jvm/types/integers.rb', line 139

def init_value(builder)
  builder.lconst_0
end

#literal(builder, value) ⇒ Object



135
136
137
# File 'lib/duby/jvm/types/integers.rb', line 135

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

#math_typeObject



127
128
129
# File 'lib/duby/jvm/types/integers.rb', line 127

def math_type
  Long
end

#prefixObject



123
124
125
# File 'lib/duby/jvm/types/integers.rb', line 123

def prefix
  'l'
end

#wide?Boolean

Returns:



143
144
145
# File 'lib/duby/jvm/types/integers.rb', line 143

def wide?
  true
end

#widen(builder, type) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/duby/jvm/types/integers.rb', line 147

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