summaryrefslogtreecommitdiff
path: root/parser/interpreter.go
diff options
context:
space:
mode:
authorAntonio Navarro Perez <antnavper@gmail.com>2024-03-20 11:15:48 +0100
committerAntonio Navarro Perez <antnavper@gmail.com>2024-03-20 11:15:48 +0100
commit649ae829220d6ddd8758d24c3bc2ea7d43e788d6 (patch)
treeca5bccce3a8ac04a96fc795b06bc40d08384286d /parser/interpreter.go
parent5da3a651ba08859ccc1cdf1094603411696c8df2 (diff)
feat: Add simple Dump creation and recovery.
Memory Dump functionality that can restore the previous VM state. It dumps *global* variables, the only ones defining the program state. The dump depends on the program itself, and on the index system, which right now is defined by the variable order. Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
Diffstat (limited to 'parser/interpreter.go')
-rw-r--r--parser/interpreter.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/parser/interpreter.go b/parser/interpreter.go
index 3ecbc46..d820416 100644
--- a/parser/interpreter.go
+++ b/parser/interpreter.go
@@ -1,6 +1,8 @@
package parser
import (
+ "reflect"
+
"github.com/mvertes/parscan/scanner"
"github.com/mvertes/parscan/vm"
)
@@ -16,7 +18,7 @@ func NewInterpreter(s *scanner.Scanner) *Interpreter {
return &Interpreter{NewCompiler(s), &vm.Machine{}}
}
-func (i *Interpreter) Eval(src string) (res any, err error) {
+func (i *Interpreter) Eval(src string) (res reflect.Value, err error) {
codeOffset := len(i.Code)
dataOffset := 0
if codeOffset > 0 {