Class: RLTK::CG::ConstantReal Abstract
- Inherits:
-
ConstantNumber
- Object
- Value
- User
- Constant
- ConstantNumber
- RLTK::CG::ConstantReal
- Includes:
- Filigree::AbstractClass
- Defined in:
- lib/rltk/cg/value.rb
Overview
All real constants inherit from this class.
Instance Attribute Summary
Attributes included from BindingClass
Instance Method Summary collapse
-
#%(rhs) ⇒ ConstantReal
Instance of the same class.
-
#*(rhs) ⇒ ConstantReal
Instance of the same class.
-
#+(rhs) ⇒ ConstantReal
Instance of the same class.
-
#-(rhs) ⇒ ConstantReal
Instance of the same class.
-
#-@ ⇒ ConstantReal
Instance of the same class.
-
#/(rhs) ⇒ ConstantReal
Instance of the same class.
-
#cast(type) ⇒ ConstantNumber
Cast this constant real to another number type.
-
#cmp(pred, rhs) ⇒ Int1
Value used to represent a Boolean value.
-
#extend(type) ⇒ ConstantReal
Extend a constant real number to a larger size.
-
#initialize(num_or_string, size = nil) ⇒ ConstantReal
constructor
Create a constant real number using a Ruby value or a string.
-
#to_i(type = NativeIntType, signed = true) ⇒ Object
Convert this real number into an integer.
-
#truncate(type) ⇒ ConstantReal
Truncate a constant real number to a smaller size.
Methods inherited from ConstantNumber
Methods inherited from Constant
#addr_space_cast, #bitcast_to, #get_element_ptr, #get_element_ptr_in_bounds
Methods inherited from User
Methods inherited from Value
#==, #attributes, #bitcast, #constant?, #dump, #hash, #name, #name=, #null?, #print, #trunc, #trunc_or_bitcast, #type, #undefined?, #zextend, #zextend_or_bitcast
Methods included from BindingClass
Constructor Details
#initialize(num_or_string, size = nil) ⇒ ConstantReal
Create a constant real number using a Ruby value or a string.
942 943 944 945 946 947 948 949 950 951 952 953 |
# File 'lib/rltk/cg/value.rb', line 942 def initialize(num_or_string, size = nil) @ptr = if num_or_string.is_a?(::Float) Bindings.const_real(self.type, num_or_string) elsif size Bindings.const_real_of_string_and_size(self.type, num_or_string, size) else Bindings.const_real_of_string(self.type, num_or_string) end end |
Instance Method Details
#%(rhs) ⇒ ConstantReal
Returns Instance of the same class.
1003 1004 1005 |
# File 'lib/rltk/cg/value.rb', line 1003 def %(rhs) self.class.new(Bindings.const_f_remm(@ptr, rhs)) end |
#*(rhs) ⇒ ConstantReal
Returns Instance of the same class.
985 986 987 |
# File 'lib/rltk/cg/value.rb', line 985 def *(rhs) self.class.new(Bindings.const_f_mul(@ptr, rhs)) end |
#+(rhs) ⇒ ConstantReal
Returns Instance of the same class.
967 968 969 |
# File 'lib/rltk/cg/value.rb', line 967 def +(rhs) self.class.new(Bindings.const_f_add(@ptr, rhs)) end |
#-(rhs) ⇒ ConstantReal
Returns Instance of the same class.
976 977 978 |
# File 'lib/rltk/cg/value.rb', line 976 def -(rhs) self.class.new(Bindings.const_f_sub(@ptr, rhs)) end |
#-@ ⇒ ConstantReal
Returns Instance of the same class.
958 959 960 |
# File 'lib/rltk/cg/value.rb', line 958 def -@ self.class.new(Bindings.const_f_neg(@ptr)) end |
#/(rhs) ⇒ ConstantReal
Returns Instance of the same class.
994 995 996 |
# File 'lib/rltk/cg/value.rb', line 994 def /(rhs) self.class.new(Bindings.const_f_div(@ptr, rhs)) end |
#cast(type) ⇒ ConstantNumber
Cast this constant real to another number type.
1024 1025 1026 |
# File 'lib/rltk/cg/value.rb', line 1024 def cast(type) type.value_class.new(Bindings.const_fp_cast(@ptr, check_cg_type(type, NumberType))) end |
#cmp(pred, rhs) ⇒ Int1
Returns Value used to represent a Boolean value.
1015 1016 1017 |
# File 'lib/rltk/cg/value.rb', line 1015 def cmp(pred, rhs) Int1.new(Bindings.const_f_cmp(pred, @ptr, rhs)) end |
#extend(type) ⇒ ConstantReal
Extend a constant real number to a larger size.
1043 1044 1045 |
# File 'lib/rltk/cg/value.rb', line 1043 def extend(type) type.value_class.new(Bindings.const_fp_ext(@ptr, check_cg_type(type, RealType))) end |
#to_i(type = NativeIntType, signed = true) ⇒ Object
Convert this real number into an integer.
1034 1035 1036 |
# File 'lib/rltk/cg/value.rb', line 1034 def to_i(type = NativeIntType, signed = true) type.value_class.new(Bindings.send(signed ? :const_fp_to_si : :const_fp_to_ui, @ptr, check_cg_type(type, BasicIntType))) end |
#truncate(type) ⇒ ConstantReal
Truncate a constant real number to a smaller size.
1052 1053 1054 |
# File 'lib/rltk/cg/value.rb', line 1052 def truncate(type) type.value_class.new(Bindings.const_fp_trunc(@ptr, check_cg_type(type, RealType))) end |