summaryrefslogtreecommitdiff
path: root/main.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 /main.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 'main.go')
-rw-r--r--main.go5
1 files changed, 3 insertions, 2 deletions
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 = "", "> "