Class: LLVM::Value
- Inherits:
-
Object
- Object
- LLVM::Value
- Defined in:
- lib/llvm/core/value.rb
Direct Known Subclasses
Class Method Summary collapse
- .from_ptr(ptr) ⇒ Object
- .to_ptr ⇒ Object
-
.type ⇒ Object
Returns the Value type.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks if the value is equal to other.
-
#add_attribute(attr) ⇒ Object
Adds attr to this value’s attributes.
-
#constant? ⇒ Boolean
Returns whether the value is constant.
-
#dump ⇒ Object
Print the value’s IR to stdout.
-
#eql?(other) ⇒ Boolean
Checks if the value is equal to other.
-
#initialize(ptr) ⇒ Value
constructor
A new instance of Value.
-
#name ⇒ Object
Returns the value’s name.
-
#name=(str) ⇒ Object
Sets the value’s name to str.
-
#null? ⇒ Boolean
Returns whether the value is null.
- #to_ptr ⇒ Object
-
#type ⇒ Object
Returns the value’s type.
-
#undefined? ⇒ Boolean
Returns whether the value is undefined.
Constructor Details
#initialize(ptr) ⇒ Value
Returns a new instance of Value.
11 12 13 |
# File 'lib/llvm/core/value.rb', line 11 def initialize(ptr) @ptr = ptr end |
Class Method Details
.from_ptr(ptr) ⇒ Object
4 5 6 |
# File 'lib/llvm/core/value.rb', line 4 def self.from_ptr(ptr) new(ptr) unless ptr.null? end |
.to_ptr ⇒ Object
40 41 42 |
# File 'lib/llvm/core/value.rb', line 40 def self.to_ptr type.to_ptr end |
.type ⇒ Object
Returns the Value type. This is abstract and is overidden by its subclasses.
36 37 38 |
# File 'lib/llvm/core/value.rb', line 36 def self.type raise NotImplementedError, "#{self.name}.type() is abstract." end |
Instance Method Details
#==(other) ⇒ Object
Checks if the value is equal to other.
21 22 23 24 25 26 27 28 |
# File 'lib/llvm/core/value.rb', line 21 def ==(other) case other when LLVM::Value @ptr == other.to_ptr else false end end |
#add_attribute(attr) ⇒ Object
Adds attr to this value’s attributes.
90 91 92 |
# File 'lib/llvm/core/value.rb', line 90 def add_attribute(attr) C.LLVMAddAttribute(self, attr) end |
#constant? ⇒ Boolean
Returns whether the value is constant.
66 67 68 69 70 71 |
# File 'lib/llvm/core/value.rb', line 66 def constant? case C.LLVMIsConstant(self) when 0 then false when 1 then true end end |
#dump ⇒ Object
Print the value’s IR to stdout.
61 62 63 |
# File 'lib/llvm/core/value.rb', line 61 def dump C.LLVMDumpValue(self) end |
#eql?(other) ⇒ Boolean
Checks if the value is equal to other.
31 32 33 |
# File 'lib/llvm/core/value.rb', line 31 def eql?(other) other.instance_of?(self.class) && self == other end |
#name ⇒ Object
Returns the value’s name.
50 51 52 |
# File 'lib/llvm/core/value.rb', line 50 def name C.LLVMGetValueName(self) end |
#name=(str) ⇒ Object
Sets the value’s name to str.
55 56 57 58 |
# File 'lib/llvm/core/value.rb', line 55 def name=(str) C.LLVMSetValueName(self, str) str end |
#null? ⇒ Boolean
Returns whether the value is null.
74 75 76 77 78 79 |
# File 'lib/llvm/core/value.rb', line 74 def null? case C.LLVMIsNull(self) when 0 then false when 1 then true end end |
#to_ptr ⇒ Object
16 17 18 |
# File 'lib/llvm/core/value.rb', line 16 def to_ptr @ptr end |
#type ⇒ Object
Returns the value’s type.
45 46 47 |
# File 'lib/llvm/core/value.rb', line 45 def type Type.from_ptr(C.LLVMTypeOf(self)) end |
#undefined? ⇒ Boolean
Returns whether the value is undefined.
82 83 84 85 86 87 |
# File 'lib/llvm/core/value.rb', line 82 def undefined? case C.LLVMIsUndef(self) when 0 then false when 1 then true end end |