Skip to content

Commit 3f7c1e2

Browse files
committed
Implement LOAD_GLOBAL
1 parent 00d856f commit 3f7c1e2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

vm/eval.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,8 @@ func do_FOR_ITER(vm *Vm, delta int32) {
533533

534534
// Loads the global named co_names[namei] onto the stack.
535535
func do_LOAD_GLOBAL(vm *Vm, namei int32) {
536-
vm.NotImplemented("LOAD_GLOBAL", namei)
536+
// FIXME what if global doesn't exist?
537+
vm.PUSH(vm.globals[vm.co.Names[namei]])
537538
}
538539

539540
// Pushes a block for a loop onto the block stack. The block spans
@@ -626,6 +627,9 @@ func do_RAISE_VARARGS(vm *Vm, argc int32) {
626627
// function arguments, and the function itself off the stack, and
627628
// pushes the return value.
628629
func do_CALL_FUNCTION(vm *Vm, argc int32) {
630+
fmt.Printf("Stack: %v\n", vm.stack)
631+
fmt.Printf("Locals: %v\n", vm.locals)
632+
fmt.Printf("Globals: %v\n", vm.globals)
629633
nargs := int(argc & 0xFF)
630634
nkwargs := int((argc >> 8) & 0xFF)
631635
p, q := len(vm.stack)-2*nkwargs, len(vm.stack)

0 commit comments

Comments
 (0)