diff options
| author | Mel <einebeere@gmail.com> | 2022-05-18 02:19:35 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-05-18 02:19:35 +0200 |
| commit | 0a7927ed8257857c8d114387f12844312f6da51c (patch) | |
| tree | 5fa9829606be6dc1c0f0d4b092a4bc29a96e24a0 /pkg | |
| parent | 3abe18ffca484efc3553aa4ec9cb677eb19cdaf4 (diff) | |
| download | jinx-0a7927ed8257857c8d114387f12844312f6da51c.tar.zst jinx-0a7927ed8257857c8d114387f12844312f6da51c.zip | |
Start call stack with at least one frame
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/lang/vm/stack.go | 4 | ||||
| -rw-r--r-- | pkg/lang/vm/vm.go | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/pkg/lang/vm/stack.go b/pkg/lang/vm/stack.go index 433c0b7..1d028e5 100644 --- a/pkg/lang/vm/stack.go +++ b/pkg/lang/vm/stack.go @@ -4,6 +4,10 @@ import "jinx/pkg/lang/vm/value" type CallStack []*LocalStack +func NewCallStack() CallStack { + return []*LocalStack{{}} +} + func (cs *CallStack) Push() { *cs = append(*cs, &LocalStack{}) } diff --git a/pkg/lang/vm/vm.go b/pkg/lang/vm/vm.go index 434eae3..a6e1fb8 100644 --- a/pkg/lang/vm/vm.go +++ b/pkg/lang/vm/vm.go @@ -13,8 +13,9 @@ type VM struct { func New(code *code.Code) *VM { return &VM{ - code: code, - pc: 0, + code: code, + pc: 0, + stack: NewCallStack(), } } |
