Class: LLVM::GenericValue
- Inherits:
-
Object
- Object
- LLVM::GenericValue
- Defined in:
- lib/llvm/execution_engine.rb
Class Method Summary collapse
-
.from_b(b) ⇒ Object
Creates a GenericValue from a Ruby boolean.
-
.from_f(f) ⇒ Object
Creates a Generic Value from a Float.
-
.from_i(i, type = LLVM::Int, signed = true) ⇒ Object
Creates a Generic Value from an integer.
-
.from_ptr(ptr) ⇒ Object
Creates a GenericValue from an FFI::Pointer.
Instance Method Summary collapse
-
#initialize(ptr) ⇒ GenericValue
constructor
A new instance of GenericValue.
-
#to_b ⇒ Object
Converts a GenericValue to a Ruby boolean.
-
#to_f(type = LLVM::Float.type) ⇒ Object
Converts a GenericValue to a Ruby Float.
-
#to_i(signed = true) ⇒ Object
Converts a GenericValue to a Ruby Integer.
- #to_ptr ⇒ Object
Constructor Details
#initialize(ptr) ⇒ GenericValue
Returns a new instance of GenericValue.
106 107 108 |
# File 'lib/llvm/execution_engine.rb', line 106 def initialize(ptr) @ptr = ptr end |
Class Method Details
.from_b(b) ⇒ Object
Creates a GenericValue from a Ruby boolean.
128 129 130 |
# File 'lib/llvm/execution_engine.rb', line 128 def self.from_b(b) from_i(b ? 1 : 0, LLVM::Int1, false) end |
.from_f(f) ⇒ Object
Creates a Generic Value from a Float.
122 123 124 125 |
# File 'lib/llvm/execution_engine.rb', line 122 def self.from_f(f) type = LLVM::Float.type new(C.LLVMCreateGenericValueOfFloat(type, f)) end |
.from_i(i, type = LLVM::Int, signed = true) ⇒ Object
Creates a Generic Value from an integer. Type is the size of integer to create (ex. Int32, Int8, etc.)
117 118 119 |
# File 'lib/llvm/execution_engine.rb', line 117 def self.from_i(i, type = LLVM::Int, signed = true) new(C.LLVMCreateGenericValueOfInt(type, i, signed ? 1 : 0)) end |
.from_ptr(ptr) ⇒ Object
Creates a GenericValue from an FFI::Pointer.
133 134 135 |
# File 'lib/llvm/execution_engine.rb', line 133 def self.from_ptr(ptr) new(ptr) end |
Instance Method Details
#to_b ⇒ Object
Converts a GenericValue to a Ruby boolean.
148 149 150 |
# File 'lib/llvm/execution_engine.rb', line 148 def to_b to_i(false) != 0 end |
#to_f(type = LLVM::Float.type) ⇒ Object
Converts a GenericValue to a Ruby Float.
143 144 145 |
# File 'lib/llvm/execution_engine.rb', line 143 def to_f(type = LLVM::Float.type) C.LLVMGenericValueToFloat(type, self) end |
#to_i(signed = true) ⇒ Object
Converts a GenericValue to a Ruby Integer.
138 139 140 |
# File 'lib/llvm/execution_engine.rb', line 138 def to_i(signed = true) C.LLVMGenericValueToInt(self, signed ? 1 : 0) end |
#to_ptr ⇒ Object
111 112 113 |
# File 'lib/llvm/execution_engine.rb', line 111 def to_ptr @ptr end |