From 6a32a7bc5f6320902cd5c2910a1353a0f7039237 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 23 Nov 2023 17:56:35 +0100 Subject: 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. --- lang/token.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lang/token.go') 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, // - -- cgit v1.2.3