瀏覽代碼

Working on vm.

Beoran 5 年之前
父節點
當前提交
668350870d
共有 1 個文件被更改,包括 8 次插入12 次删除
  1. 8 12
      vm.go

+ 8 - 12
vm.go

@@ -618,11 +618,16 @@ func (vm *VM) AddTrace(err error) error {
 }
 
 func (vm *VM) CallCallable(callable Callable, arguments ...Value) []Value {
-	// defer vm.PopFrame()
+	defer vm.PopFrame()
 	defer vm.PopScope()
-	// vm.PushNewFrame(callable.Position())
+	vm.PushNewFrame(callable.Position())
 	vm.PushNewScope()
-	return callable.Call(vm, arguments...)
+	result := callable.Call(vm, arguments...)
+	
+		
+	
+	
+	return result
 }
 
 func (vm *VM) CallNamed(name string, arguments ...Value) []Value {
@@ -723,9 +728,6 @@ func (vm *VM) RunChildren(ast Ast, args ...Value) []Value {
 	*/	
 	result := []Value{}
 	for _, child := range ast.Children() {
-        position := ast.Token().Position
-        vm.PushNewFrame(&position)
-        defer vm.PopFrame()
 		val := child.Run(vm, args...)
 		
 		if vm.Frame.returned || vm.Frame.failed {
@@ -756,9 +758,6 @@ func (vm *VM) RunChildren(ast Ast, args ...Value) []Value {
 func (vm *VM) RunChildrenLastResult(ast Ast, args ...Value) Value {
 	var result Value = EmptyValue{}
 	for _, child := range ast.Children() {
-        position := ast.Token().Position
-        vm.PushNewFrame(&position)
-        defer vm.PopFrame()
 		
         val := child.Run(vm, args...)
 		
@@ -792,9 +791,6 @@ func (vm *VM) RunChildrenLastResult(ast Ast, args ...Value) Value {
 func (vm *VM) RunChildrenFirstResult(ast Ast, args ...Value) Value {
 	var result Value = EmptyValue{}
 	for _, child := range ast.Children() {
-        position := ast.Token().Position
-        vm.PushNewFrame(&position)
-        defer vm.PopFrame()
 		
         val := child.Run(vm, args...)