Class: LLVM::Value

Inherits:
Object
  • Object
show all
Includes:
PointerIdentity
Defined in:
lib/llvm/core/value.rb

Direct Known Subclasses

Argument, BasicBlock, User

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Class Method Details

.from_ptr(ptr) ⇒ Object



6
7
8
9
10
11
# File 'lib/llvm/core/value.rb', line 6

def self.from_ptr(ptr)
  return if ptr.null?
  val = allocate
  val.instance_variable_set(:@ptr, ptr)
  val
end

.to_ptrObject



18
19
20
# File 'lib/llvm/core/value.rb', line 18

def self.to_ptr
  type.to_ptr
end

.typeObject

Returns the Value type. This is abstract and is overidden by its subclasses.

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/llvm/core/value.rb', line 14

def self.type
  raise NotImplementedError, "#{self.name}.type() is abstract."
end

Instance Method Details

#add_attribute(attr) ⇒ Object

Adds attr to this value’s attributes.



68
69
70
# File 'lib/llvm/core/value.rb', line 68

def add_attribute(attr)
  C.add_attribute(self, attr)
end

#constant?Boolean

Returns whether the value is constant.

Returns:

  • (Boolean)


44
45
46
47
48
49
# File 'lib/llvm/core/value.rb', line 44

def constant?
  case C.is_constant(self)
  when 0 then false
  when 1 then true
  end
end

#dumpObject

Print the value’s IR to stdout.



39
40
41
# File 'lib/llvm/core/value.rb', line 39

def dump
  C.dump_value(self)
end

#nameObject

Returns the value’s name.



28
29
30
# File 'lib/llvm/core/value.rb', line 28

def name
  C.get_value_name(self)
end

#name=(str) ⇒ Object

Sets the value’s name to str.



33
34
35
36
# File 'lib/llvm/core/value.rb', line 33

def name=(str)
  C.set_value_name(self, str)
  str
end

#null?Boolean

Returns whether the value is null.

Returns:

  • (Boolean)


52
53
54
55
56
57
# File 'lib/llvm/core/value.rb', line 52

def null?
  case C.is_null(self)
  when 0 then false
  when 1 then true
  end
end

#typeObject

Returns the value’s type.



23
24
25
# File 'lib/llvm/core/value.rb', line 23

def type
  Type.from_ptr(C.type_of(self), nil)
end

#undefined?Boolean

Returns whether the value is undefined.

Returns:

  • (Boolean)


60
61
62
63
64
65
# File 'lib/llvm/core/value.rb', line 60

def undefined?
  case C.is_undef(self)
  when 0 then false
  when 1 then true
  end
end