Class: Citrus::Array
- Inherits:
-
Object
- Object
- Citrus::Array
- Defined in:
- lib/citrus/compiler/array.rb
Instance Attribute Summary collapse
- #length ⇒ Object
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pointer, length = nil) ⇒ Array
constructor
A new instance of Array.
Constructor Details
#initialize(pointer, length = nil) ⇒ Array
Returns a new instance of Array.
16 17 18 19 |
# File 'lib/citrus/compiler/array.rb', line 16 def initialize(pointer, length=nil) @pointer = pointer @length = length end |
Instance Attribute Details
#length ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/citrus/compiler/array.rb', line 21 def length unless @length.nil? return @length else return @length = INT.from_i(LLVM::C.LLVMGetArrayLength(LLVM::Type(@pointer).element_type)) end end |
#pointer ⇒ Object
Returns the value of attribute pointer.
5 6 7 |
# File 'lib/citrus/compiler/array.rb', line 5 def pointer @pointer end |
Class Method Details
.create(values, builder) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/citrus/compiler/array.rb', line 7 def self.create(values, builder) ary = builder.alloca(LLVM::Array(LLVM::Type(values.first), values.size)) for index in 0...values.size ptr = builder.gep(ary, [INT.from_i(0), INT.from_i(index)]) builder.store(values[index], ptr) end self.new(ary) end |