Parcourir la source

Working on vm.

Beoran il y a 5 ans
Parent
commit
668350870d
1 fichiers modifiés avec 8 ajouts et 12 suppressions
  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...)