Class: JIT::BoolConstant
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary (collapse)
-
- (BoolConstant) initialize(function, val, *type)
constructor
A new instance of BoolConstant.
-
- (Boolean) to_b
The boolean represented by this constant.
-
- (Integer) to_i
Gets the integer represented by this constant as a Ruby object.
Methods inherited from Bool
Methods inherited from Primitive
#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #>, #>=, #>>, #^, #eq, #ne, #|, #~
Methods inherited from Value
#address, #addressable?, #cast, create, #function, #set_addressable, #store, #to_bool, #to_not_bool, #type, wrap
Constructor Details
- (BoolConstant) initialize(function, val, *type)
A new instance of BoolConstant
90 91 92 93 94 95 96 97 98 |
# File 'lib/libjit/constant.rb', line 90 def initialize(function, val, *type) @function = function type ||= Type.create(:bool) @type = Type.create *type val = 1 if val == true val = 0 if val == false @jit_t = LibJIT.jit_value_create_nint_constant(@function.jit_t, @type.jit_t, val) end |
Instance Method Details
- (Boolean) to_b
The boolean represented by this constant.
108 109 110 |
# File 'lib/libjit/constant.rb', line 108 def to_b to_i != 0 end |
- (Integer) to_i
Gets the integer represented by this constant as a Ruby object.
103 104 105 |
# File 'lib/libjit/constant.rb', line 103 def to_i @i ||= LibJIT.jit_value_get_nint_constant jit_t end |