class RbScheme::VM::Stack

Constants

OFFSET

Public Class Methods

new() click to toggle source
# File lib/rb-scheme/vm/stack.rb, line 5
def initialize
  @stack ||= Array.new(1000)
end

Public Instance Methods

index(stack_p, i) click to toggle source
# File lib/rb-scheme/vm/stack.rb, line 16
def index(stack_p, i)
  @stack[stack_p - (i + OFFSET)]
end
index_set!(stack_p, i, val) click to toggle source
# File lib/rb-scheme/vm/stack.rb, line 20
def index_set!(stack_p, i, val)
  @stack[stack_p - (i + OFFSET)] = val
end
push(val, stack_p) click to toggle source
# File lib/rb-scheme/vm/stack.rb, line 9
def push(val, stack_p)
  @stack[stack_p] = val
  stack_p + 1
end
restore_stack(saved_stack) click to toggle source
# File lib/rb-scheme/vm/stack.rb, line 34
def restore_stack(saved_stack)
  s = saved_stack.length
  i = 0
  until i == s do
    @stack[i] = saved_stack[i]
    i += 1
  end
  s
end
save_stack(stack_p) click to toggle source
# File lib/rb-scheme/vm/stack.rb, line 24
def save_stack(stack_p)
  v = Array.new(stack_p)
  i = 0
  until i == stack_p
    v[i] = @stack[i]
    i += 1
  end
  v
end