summaryrefslogtreecommitdiff
path: root/symbol/symbol.go
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2026-01-14 18:44:17 +0100
committerMarc Vertes <mvertes@free.fr>2026-01-14 18:44:17 +0100
commit31e3793202402fda21905027c18ebfa5c8d8c832 (patch)
treedbe52ae31fada099bc65fcd9c7d61f6266c6ba78 /symbol/symbol.go
parentde3baf0e06862f0420950f025b3328068f3b6df2 (diff)
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.
Diffstat (limited to 'symbol/symbol.go')
-rw-r--r--symbol/symbol.go10
1 files changed, 7 insertions, 3 deletions
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 {