Class: Mirah::JVM::Types::LongType

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

Constant Summary

Constants inherited from Number

Number::TYPE_ORDERING

Constants inherited from PrimitiveType

PrimitiveType::WIDENING_CONVERSIONS

Constants included from Logging::Logged

Logging::Logged::VLEVELS

Instance Attribute Summary

Attributes inherited from Type

#inner_class, #name, #type_system

Instance Method Summary collapse

Methods inherited from Number

#add_delegates, #boolean_operator, #compile_boolean_operator, #delegate_intrinsic, #invert_op, #jump_if, #math_operator, #suffix, #unary_operator

Methods inherited from PrimitiveType

#box, #box_type, #convertible_to?, #initialize, #interfaces, #newarray, #primitive?, #primitive_type, #superclass, #wrapper_name

Methods inherited from Type

#abstract?, #add_compiled_macro, #add_enumerable_macros, #add_method, #add_method_listener, #aload, #ancestors_and_interfaces, #array?, #array_type, #assignableFrom, #assignable_from?, #astore, #basic_type, #class_id, #compatible?, #component_type, #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, #initialize, #inner_class?, #inner_class_getter, #inspect, #interface?, #interfaces, #internal_name, #intrinsics, #isAnnotation, #isArray, #isBlock, #isEnum, #isError, #isGeneric, #isMeta, #isPrimitive, #is_parent, #iterable?, #java_method, #jvm_type, #load, #load_extensions, #macro, #macros, #matchesAnything, #meta, #meta?, #method_listeners, #method_updated, #newarray, #pop, #primitive?, #read_macrodef_annotation, #retention, #return, #store, #superclass, #to_s, #type_parameters, #ungeneric, #unmeta, #void?, #widen

Methods included from Logging::Logged

#error, #info, #log, #logger, #logger_name, #logging?, #vlog, #warning

Methods included from MethodLookup

#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

This class inherits a constructor from Mirah::JVM::Types::PrimitiveType

Instance Method Details

#add_intrinsicsObject



120
121
122
123
124
125
126
127
128
129
# File 'lib/mirah/jvm/types/integers.rb', line 120

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

#compile_widen(builder, type) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/mirah/jvm/types/integers.rb', line 105

def compile_widen(builder, type)
  case type.name
  when 'long'
    # do nothing
  when 'float'
    builder.l2f
  when 'double'
    builder.l2d
  when wrapper_name, 'java.lang.Object'
    builder.invokestatic @wrapper, "valueOf", [@wrapper, builder.send(name)]
  else
    raise ArgumentError, "Invalid widening conversion from Int to #{type}"
  end
end

#init_value(builder) ⇒ Object



97
98
99
# File 'lib/mirah/jvm/types/integers.rb', line 97

def init_value(builder)
  builder.lconst_0
end

#literal(builder, value) ⇒ Object



93
94
95
# File 'lib/mirah/jvm/types/integers.rb', line 93

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

#math_typeObject



89
90
91
# File 'lib/mirah/jvm/types/integers.rb', line 89

def math_type
  @type_system.type(nil, 'long')
end

#prefixObject



85
86
87
# File 'lib/mirah/jvm/types/integers.rb', line 85

def prefix
  'l'
end

#wide?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/mirah/jvm/types/integers.rb', line 101

def wide?
  true
end