From c1a0c728da2a8f4cb9d077e41da32806864f3b53 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 21 Jan 2022 15:02:35 -0500 Subject: [EVAL] change how structs are represented --- src/texec/eval.go | 42 +++++++++++++++++++++++++++++++++--------- src/texec/world.go | 1 - src/texec/worldbuilder.go | 15 ++++++++++++--- 3 files changed, 45 insertions(+), 13 deletions(-) (limited to 'src/texec') diff --git a/src/texec/eval.go b/src/texec/eval.go index 7db07b0..548a30a 100644 --- a/src/texec/eval.go +++ b/src/texec/eval.go @@ -151,7 +151,6 @@ func equateTypePS(a, b TType, preskip int) bool { } if len(a.T.Path) != len(b.T.Path) || len(a.Pre) - preskip - cc != len(b.Pre) { - fmt.Println("[EVAL] Equate type died at len check.") return false } @@ -160,25 +159,21 @@ func equateTypePS(a, b TType, preskip int) bool { preskip++ continue } else if a.Pre[i] != b.Pre[i - preskip] { - fmt.Println("[EVAL] Equate type died at pre check.") return false } } for i := 0; i < len(a.T.Path); i++ { if a.T.Path[i] != b.T.Path[i] { - fmt.Println("[EVAL] Equate type died at path check.") return false } } if a.T.Name != b.T.Name { - fmt.Println("[EVAL] Equate type died at name check.") return false } if (a.Post == "`" && b.Post != "`") || (b.Post == "`" && a.Post != "`") { - fmt.Println("[EVAL] Equate type died at rel check.") return false } @@ -265,6 +260,14 @@ func getIntLiteral(v tparse.Node) int { return int(i) } +func getLiteralComposite(v tparse.Node) []interface{} { + out := []interface{}{} + + for i := 0; i < len(v.Sub); i++ { + getLiteral(v.Sub) + } +} + func getLiteral(v tparse.Node, t TType) interface{} { if equateType(t, tInt) { @@ -275,10 +278,23 @@ func getLiteral(v tparse.Node, t TType) interface{} { return getStringLiteral(v) } - return nil + return getLiteralComposite() } +func compositeToStruct(str TVariable, cmp []interface{}) VarMap { + vars = str.Data.([]TVariable) + if len(vars) != len(cmp) { + return nil + } + + out := make(VarMap) + + for i:=0;i