summaryrefslogtreecommitdiff
path: root/parser/interpreter.go
diff options
context:
space:
mode:
Diffstat (limited to 'parser/interpreter.go')
-rw-r--r--parser/interpreter.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/parser/interpreter.go b/parser/interpreter.go
index c5e463a..3ecbc46 100644
--- a/parser/interpreter.go
+++ b/parser/interpreter.go
@@ -34,6 +34,9 @@ func (i *Interpreter) Eval(src string) (res any, err error) {
}
i.Push(i.Data[dataOffset:]...)
i.PushCode(i.Code[codeOffset:]...)
+ if s, ok := i.symbols["main"]; ok {
+ i.PushCode([]int64{0, vm.Calli, i.Data[s.index].Data.Int()})
+ }
i.PushCode([]int64{0, vm.Exit})
i.SetIP(max(codeOffset, i.Entry))
if debug {
@@ -43,10 +46,3 @@ func (i *Interpreter) Eval(src string) (res any, err error) {
err = i.Run()
return i.Top().Data, err
}
-
-func max(a, b int) int {
- if a > b {
- return a
- }
- return b
-}