From 31e3793202402fda21905027c18ebfa5c8d8c832 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 14 Jan 2026 18:44:17 +0100 Subject: fix: improve handling of indirections Added 2 VM instructions, FnewE variant of Fnew with a dereference, and FieldE, variant of Field with dereference. It's now possible to pointers in structs and literal composites. --- symbol/symbol.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'symbol/symbol.go') diff --git a/symbol/symbol.go b/symbol/symbol.go index 2ed8907..5e8610a 100644 --- a/symbol/symbol.go +++ b/symbol/symbol.go @@ -4,6 +4,7 @@ package symbol import ( "fmt" "go/constant" + "reflect" "strings" "github.com/mvertes/parscan/vm" @@ -47,15 +48,18 @@ type Symbol struct { // return fmt.Sprintf("{Kind: %v, Name: %v, Index: %v, Type: %v}\n", s.Kind, s.Name, s.Index, s.Type) //} -// IsConst return true if symbol is a constant. +// IsConst returns true if symbol is a constant. func (s *Symbol) IsConst() bool { return s.Kind == Const } -// IsType return true if symbol is a type. +// IsType returns true if symbol is a type. func (s *Symbol) IsType() bool { return s.Kind == Type } -// IsFunc return true if symbol is a function. +// IsFunc returns true if symbol is a function. func (s *Symbol) IsFunc() bool { return s.Kind == Func } +// IsPtr returns true if symbol is a pointer. +func (s *Symbol) IsPtr() bool { return s.Type.Rtype.Kind() == reflect.Pointer } + // Vtype returns the VM type of a symbol. func Vtype(s *Symbol) *vm.Type { if s.Type != nil { -- cgit v1.2.3