summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/texec/eval.go52
-rw-r--r--src/texec/worldbuilder.go3
2 files changed, 23 insertions, 32 deletions
diff --git a/src/texec/eval.go b/src/texec/eval.go
index 40e2523..dff3ef2 100644
--- a/src/texec/eval.go
+++ b/src/texec/eval.go
@@ -789,34 +789,11 @@ func evalDotChain(v tparse.Node, ctx *VarMap) *TVariable {
if wnd.Data.Data != "self" {
out = &TVariable{out.Type, &(out.Data)}
}
-
- if len(v.Sub[0].Sub) > 0 {
- out = evalCIN(v.Sub[0], ctx, out)
- }
-
- v = v.Sub[1]
- if v.Data.Data == "." {
- wnd = &(v.Sub[0])
- } else {
- wnd = &v
- }
}
- wrk := TArtifact{[]string{}, ""}
+ wrk := TArtifact{[]string{}, wnd.Data.Data}
for ;; {
- if out == nil {
- if wrk.Name != "" {
- wrk.Path = append(wrk.Path, wrk.Name)
- }
- wrk.Name = wnd.Data.Data
-
- tmp := searchDef(wrk)
- if tmp != nil {
- out = &TVariable{tmp.Type, &(tmp.Data)}
- }
- }
-
if len(wnd.Sub) > 0 {
if out == nil {
out = evalCIN(*wnd, ctx, &TVariable{TType{[]string{}, wrk, ""}, nil})
@@ -827,14 +804,8 @@ func evalDotChain(v tparse.Node, ctx *VarMap) *TVariable {
}
out = evalCIN(*wnd, ctx, out)
}
- } else if out != nil {
- tmp, prs := (*(out.Data.(*interface{}))).(VarMap)[wnd.Data.Data]
- if !prs {
- errOutNode("Unable to find struct variable (dot)", v)
- }
- out = &TVariable{tmp.Type, &(tmp.Data)}
}
-
+
if v.Data.Data == "." {
v = v.Sub[1]
if v.Data.Data == "." {
@@ -842,9 +813,28 @@ func evalDotChain(v tparse.Node, ctx *VarMap) *TVariable {
} else {
wnd = &v
}
+
+ wrk.Path = append(wrk.Path, wrk.Name)
+ wrk.Name = wnd.Data.Data
+
} else {
break
}
+
+ if out == nil {
+ tmp := searchDef(wrk)
+ if tmp != nil {
+ out = &TVariable{tmp.Type, &(tmp.Data)}
+ }
+ } else if len(wnd.Sub) == 0 || wnd.Sub[0].Data.Data != "call" {
+ tmp, prs := (*(out.Data.(*interface{}))).(VarMap)[wnd.Data.Data]
+ if !prs {
+ fmt.Println(wnd)
+ fmt.Println(out)
+ errOutNode("Unable to find struct variable (dot)", v)
+ }
+ out = &TVariable{tmp.Type, &(tmp.Data)}
+ }
}
return out
diff --git a/src/texec/worldbuilder.go b/src/texec/worldbuilder.go
index 6a5fb33..69be803 100644
--- a/src/texec/worldbuilder.go
+++ b/src/texec/worldbuilder.go
@@ -99,7 +99,8 @@ func modDefStruct(n tparse.Node, m *TModule) {
func modDefEnum(n tparse.Node, m *TModule) {
name := n.Sub[0].Data.Data
- t := getType(n.Sub[1].Sub[0])
+ t := getType(n.Sub[1])
+ fmt.Println(t)
s, vs := modDefVars(n.Sub[2], t)
out := TVariable{tEnum, make(VarMap)}
for i := 0; i < len(s); i++ {