summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2023-11-23 17:56:35 +0100
committerMarc Vertes <mvertes@free.fr>2023-11-24 09:12:46 +0100
commit6a32a7bc5f6320902cd5c2910a1353a0f7039237 (patch)
tree0fcce51e4d4f54d48d57a5dda8a896a35264f68b /lang
parentc548093d79edece3c1cbb7e4dc03d92fe45b1cc7 (diff)
parser: fix allocation of local variables
A 'New' instruction is added in VM to manage initialisation of typed variables in the stack. The instantiated type symbols are now added to global data. Accessing and setting values by address is now working.
Diffstat (limited to 'lang')
-rw-r--r--lang/token.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/lang/token.go b/lang/token.go
index 40e6bfc..5205efc 100644
--- a/lang/token.go
+++ b/lang/token.go
@@ -59,7 +59,7 @@ const (
// Unary operations
Plus // unary +
Minus // unary -
- Address // unary &
+ Addr // unary &
Deref // unary *
BitComp // unary ^
Arrow // unary ->
@@ -107,19 +107,20 @@ const (
// Internal virtual machine tokens (no corresponding keyword)
Call
CallX
+ EqualSet
Grow
Index
- Label
JumpFalse
JumpSetFalse
JumpSetTrue
- EqualSet
+ Label
+ New
)
// TODO: define UnaryOp per language
var UnaryOp = map[TokenId]TokenId{
Add: Plus, // +
- And: Address, // &
+ And: Addr, // &
Not: Not, // !
Mul: Deref, // *
Sub: Minus, // -