diff options
| author | Marc Vertes <mvertes@free.fr> | 2024-03-08 19:29:34 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2024-03-08 19:29:34 +0100 |
| commit | 8c4fa9d85cd274439dbd7d0a5c699fe1cea557dc (patch) | |
| tree | a8c910cf13aa06e61ee2db40b5dd2f1f63a25b9d /parser/decl.go | |
| parent | 828cfd1c8da5e243fd0f34530fb1a7faab49784e (diff) | |
feat: add type representation in vm package
Type and Value types in vm package are now used in place of reflect.Type
and reflect.Value. It allows to remove the dependency on reflect for
parser and compiler packages.
The main purpose of Type is to provide a solution to implement recursive
structs, named types, interfaces and methods, despite the limitations of
Go reflect. The goal is to provide the thinnest layer around reflect.
Diffstat (limited to 'parser/decl.go')
| -rw-r--r-- | parser/decl.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/parser/decl.go b/parser/decl.go index 2c8941d..d794131 100644 --- a/parser/decl.go +++ b/parser/decl.go @@ -4,14 +4,14 @@ import ( "errors" "go/constant" "go/token" - "reflect" "strings" "github.com/mvertes/parscan/lang" "github.com/mvertes/parscan/scanner" + "github.com/mvertes/parscan/vm" ) -var nilValue = reflect.ValueOf(nil) +var nilValue = vm.ValueOf(nil) func (p *Parser) ParseConst(in Tokens) (out Tokens, err error) { if len(in) < 2 { @@ -78,7 +78,7 @@ func (p *Parser) parseConstLine(in Tokens) (out Tokens, err error) { kind: symConst, index: unsetAddr, cval: cval, - value: reflect.ValueOf(constValue(cval)), + value: vm.ValueOf(constValue(cval)), local: p.funcScope != "", used: true, } @@ -225,7 +225,7 @@ func (p *Parser) parseTypeLine(in Tokens) (out Tokens, err error) { if err != nil { return out, err } - p.addSym(unsetAddr, in[0].Str, reflect.New(typ).Elem(), symType, typ, p.funcScope != "") + p.addSym(unsetAddr, in[0].Str, vm.NewValue(typ), symType, typ, p.funcScope != "") return out, err } |
