Class: Citrus::Variable
- Inherits:
-
Object
- Object
- Citrus::Variable
- Defined in:
- lib/citrus/compiler/variable.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
Returns the value of attribute pointer.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #assign(value, builder) ⇒ Object
-
#initialize(value, builder) ⇒ Variable
constructor
A new instance of Variable.
- #value(builder) ⇒ Object
Constructor Details
#initialize(value, builder) ⇒ Variable
Returns a new instance of Variable.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/citrus/compiler/variable.rb', line 7 def initialize(value, builder) @value = nil if value.is_a?(Citrus::Array) @value = value @type = LLVM::Type(value.pointer) else @type = LLVM::Type(value) end build_initialize(value, builder) end |
Instance Attribute Details
#pointer ⇒ Object (readonly)
Returns the value of attribute pointer.
5 6 7 |
# File 'lib/citrus/compiler/variable.rb', line 5 def pointer @pointer end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/citrus/compiler/variable.rb', line 4 def type @type end |
Instance Method Details
#assign(value, builder) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/citrus/compiler/variable.rb', line 18 def assign(value, builder) if value.is_a?(Citrus::Array) @value = value @type = LLVM::Type(value.pointer) end build_assign(value, builder) end |
#value(builder) ⇒ Object
26 27 28 29 |
# File 'lib/citrus/compiler/variable.rb', line 26 def value(builder) val = build_load(builder) return @value.nil? ? val : @value end |