Class: Duby::JVM::Types::FloatLiteral

Inherits:
NarrowingType show all
Defined in:
lib/duby/jvm/types/literals.rb

Constant Summary collapse

FLOAT_RANGE =
java.lang.Float::MIN_VALUE .. java.lang.Float::MAX_VALUE
NaN =
java.lang.Float::NaN
POSITIVE_INFINITY =
java.lang.Float::POSITIVE_INFINITY
NEGATIVE_INFINITY =
java.lang.Float::NEGATIVE_INFINITY

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 NarrowingType

#hash, #narrow!

Methods inherited from PrimitiveType

#add_intrinsics, #convertible_to?, #interfaces, #newarray, #primitive?, #primitive_type

Methods inherited from Type

#add_intrinsics, #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, #init_value, #inspect, #interface?, #interfaces, #intrinsics, #is_parent, #iterable?, #java_method, #jvm_type, #load, #meta, #meta?, #newarray, #prefix, #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, #is_parent, #iterable?, #meta?, #narrow, #primitive?, #to_s, #unmeta, #unreachable?

Methods included from AST::Named

#to_s

Methods inherited from AST::Node

#[], #each, #expr?, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp, #to_s

Constructor Details

#initialize(literal) ⇒ FloatLiteral

Returns a new instance of FloatLiteral.



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/duby/jvm/types/literals.rb', line 70

def initialize(literal)
  narrowed_type = case literal
  when FLOAT_RANGE, NaN, POSITIVE_INFINITY, NEGATIVE_INFINITY
    Float
  else
    Double
  end
  
  # TODO Double should be default once it supports operators
  super(narrowed_type, narrowed_type)
end