Class: LLVM::Value
- Inherits:
-
Object
- Object
- LLVM::Value
- Includes:
- PointerIdentity
- Defined in:
- lib/llvm/core/value.rb
Direct Known Subclasses
Class Method Summary collapse
- .from_ptr(ptr) ⇒ Object
- .from_ptr_kind(ptr) ⇒ Object
- .to_ptr ⇒ Object
-
.type ⇒ Object
Returns the Value type.
Instance Method Summary collapse
-
#add_attribute(attr) ⇒ Object
Adds attr to this value’s attributes.
- #allocated_type ⇒ Object
-
#constant? ⇒ Boolean
Returns whether the value is constant.
-
#dump ⇒ Object
Print the value’s IR to stdout.
-
#global_parent ⇒ Object
Get the parent module of a global variable, including functions.
-
#kind ⇒ Object
Returns the value’s kind.
-
#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.
-
#remove_attribute(attr) ⇒ Object
Removes the given attribute from the function.
- #to_s ⇒ Object
-
#type ⇒ Object
Returns the value’s type.
-
#undefined? ⇒ Boolean
Returns whether the value is undefined.
Methods included from PointerIdentity
Class Method Details
.from_ptr(ptr) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/llvm/core/value.rb', line 8 def self.from_ptr(ptr) return if ptr.null? val = allocate val.instance_variable_set(:@ptr, ptr) val end |
.from_ptr_kind(ptr) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/llvm/core/value.rb', line 15 def self.from_ptr_kind(ptr) return if ptr.null? kind = C.get_value_kind(ptr) case kind when :instruction Instruction.from_ptr(ptr) when :const_int Int.from_ptr(ptr) when :const_fp Float.from_ptr(ptr) when :poison Poison.from_ptr(ptr) when :global_variable GlobalValue.from_ptr(ptr) else raise "from_ptr_kind cannot handle: #{kind}" end 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, "#{name}.type() is abstract." end |
Instance Method Details
#add_attribute(attr) ⇒ Object
Adds attr to this value’s attributes.
103 104 105 106 107 108 109 110 111 |
# File 'lib/llvm/core/value.rb', line 103 def add_attribute(attr) fun = param_parent return unless fun index = param_index(fun) return unless index fun.add_attribute(attr, index) end |
#allocated_type ⇒ Object
54 55 56 |
# File 'lib/llvm/core/value.rb', line 54 def allocated_type Type.from_ptr(C.get_allocated_type(self), nil) end |
#constant? ⇒ Boolean
Returns whether the value is constant.
79 80 81 82 83 84 |
# File 'lib/llvm/core/value.rb', line 79 def constant? case C.is_constant(self) when 0 then false when 1 then true end end |
#dump ⇒ Object
Print the value’s IR to stdout.
70 71 72 |
# File 'lib/llvm/core/value.rb', line 70 def dump C.dump_value(self) end |
#global_parent ⇒ Object
Get the parent module of a global variable, including functions
125 126 127 |
# File 'lib/llvm/core/value.rb', line 125 def global_parent LLVM::Module.from_ptr(C.get_global_parent(self)) end |
#kind ⇒ Object
Returns the value’s kind.
50 51 52 |
# File 'lib/llvm/core/value.rb', line 50 def kind C.get_value_kind(self) end |
#name ⇒ Object
Returns the value’s name.
59 60 61 |
# File 'lib/llvm/core/value.rb', line 59 def name C.get_value_name(self) end |
#name=(str) ⇒ Object
Sets the value’s name to str.
64 65 66 67 |
# File 'lib/llvm/core/value.rb', line 64 def name=(str) C.set_value_name(self, str) str end |
#null? ⇒ Boolean
Returns whether the value is null.
87 88 89 90 91 92 |
# File 'lib/llvm/core/value.rb', line 87 def null? case C.is_null(self) when 0 then false when 1 then true end end |
#remove_attribute(attr) ⇒ Object
Removes the given attribute from the function.
114 115 116 117 118 119 120 121 122 |
# File 'lib/llvm/core/value.rb', line 114 def remove_attribute(attr) fun = param_parent return unless fun index = param_index(fun) return unless index fun.remove_attribute(attr, index) end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/llvm/core/value.rb', line 74 def to_s C.print_value_to_string(self) end |