From 649ae829220d6ddd8758d24c3bc2ea7d43e788d6 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Wed, 20 Mar 2024 11:15:48 +0100 Subject: 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 --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 5e0989b..f566510 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "io" "log" "os" + "reflect" "github.com/mvertes/parscan/lang/golang" "github.com/mvertes/parscan/parser" @@ -15,7 +16,7 @@ import ( ) type Interpreter interface { - Eval(string) (any, error) + Eval(string) (reflect.Value, error) } func main() { @@ -44,7 +45,7 @@ func repl(interp Interpreter, in io.Reader) (err error) { text += liner.Text() res, err := interp.Eval(text + "\n") if err == nil { - if res != nil { + if !res.IsNil() { fmt.Println(": ", res) } text, prompt = "", "> " -- cgit v1.2.3