From a4d7fb2da6a8390b818dae8d07391c7d76e365e9 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 15 Nov 2023 11:59:15 +0100 Subject: parser: hande const declarations Only symbols are produced, no bytecode is emitted. The constant expressions are evaluated at compile time using the stdlib package go/constant. The parser handles implicit repetition of the last non-empty expression list. The iota symbol is reset to 0 and incremented for each line of a const block. To be done in a next commit: type conversions. --- vm/vm.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'vm') diff --git a/vm/vm.go b/vm/vm.go index ba1f97e..f7f4d78 100644 --- a/vm/vm.go +++ b/vm/vm.go @@ -71,12 +71,14 @@ var strop = [...]string{ // for VM tracing. Subi: "Subi", } +type Code [][]int64 + // Machine represents a virtual machine. type Machine struct { - code [][]int64 // code to execute - mem []any // memory, as a stack - ip, fp int // instruction and frame pointer - ic uint64 // instruction counter, incremented at each instruction executed + code Code // code to execute + mem []any // memory, as a stack + ip, fp int // instruction and frame pointer + ic uint64 // instruction counter, incremented at each instruction executed // flags uint // to set options such as restrict CallX, etc... } -- cgit v1.2.3