Class: Builder
Class Method Summary collapse
Instance Method Summary collapse
- #locals ⇒ Object
- #peek(n = 1) ⇒ Object
- #pop ⇒ Object
- #push(val) ⇒ Object
- #stack ⇒ Object
- #stack_ptr ⇒ Object
- #topn(n) ⇒ Object
Class Method Details
.set_globals(b) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/ruby_vm.rb', line 29 def self.set_globals(b) @@stack = b.alloca(VALUE, 100) @@stack_ptr = b.alloca(P_VALUE, 0) b.store(@@stack, @@stack_ptr) @@locals = b.alloca(VALUE, 100) end |
Instance Method Details
#locals ⇒ Object
71 72 73 |
# File 'lib/ruby_vm.rb', line 71 def locals @@locals end |
#peek(n = 1) ⇒ Object
58 59 60 61 62 |
# File 'lib/ruby_vm.rb', line 58 def peek(n = 1) sp = load(stack_ptr) peek_sp = gep(sp, (-n).llvm) load(peek_sp) end |
#pop ⇒ Object
51 52 53 54 55 56 |
# File 'lib/ruby_vm.rb', line 51 def pop sp = load(stack_ptr) new_sp = gep(sp, -1.llvm) store(new_sp, stack_ptr) load(new_sp) end |
#push(val) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/ruby_vm.rb', line 44 def push(val) sp = load(stack_ptr) store(val, sp) new_sp = gep(sp, 1.llvm) store(new_sp, stack_ptr) end |
#stack ⇒ Object
36 37 38 |
# File 'lib/ruby_vm.rb', line 36 def stack @@stack end |
#stack_ptr ⇒ Object
40 41 42 |
# File 'lib/ruby_vm.rb', line 40 def stack_ptr @@stack_ptr end |