From 362f7c9c45598b429c92e67756f41b690043e0c4 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Fri, 22 Mar 2024 16:59:25 +0100 Subject: feat: add initial support for import, provide minimal fmt (#6) The `import` statement is now parsed. It only provides minimal support for the `fmt` package (only `Println` symbol is defined). This should be sufficient to pass a few tests. Full support of package namespaces, source and binary imports will be supported later, based on this work. --- parser/symbol.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'parser/symbol.go') diff --git a/parser/symbol.go b/parser/symbol.go index c75f241..c8d89db 100644 --- a/parser/symbol.go +++ b/parser/symbol.go @@ -17,18 +17,20 @@ const ( symConst // a Go constant symVar // a Go variable, located in the VM memory symFunc // a Go function, located in the VM code + symPkg // a Go package ) const unsetAddr = -65535 type symbol struct { - kind symKind - index int // address of symbol in frame - Type *vm.Type // - value vm.Value // - cval constant.Value // - local bool // if true address is relative to local frame, otherwise global - used bool // + kind symKind + index int // address of symbol in frame + pkgPath string // + Type *vm.Type // + value vm.Value // + cval constant.Value // + local bool // if true address is relative to local frame, otherwise global + used bool // } func symtype(s *symbol) *vm.Type { -- cgit v1.2.3