diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2022-04-09 14:31:45 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2022-04-09 14:31:45 -0400 |
commit | 3b5a23a17fb479444e9130b03e0a7af49bbb561e (patch) | |
tree | 9cb1dab8d120a6e279a09a6dd34777b700d1293d | |
parent | 28371ad11afce98913b6427ea7dc82f64ac48b3c (diff) |
[EVAL] Fix function calls
-rw-r--r-- | src/texec/eval.go | 25 | ||||
-rw-r--r-- | src/texec/libtnsl.go | 12 |
2 files changed, 29 insertions, 8 deletions
diff --git a/src/texec/eval.go b/src/texec/eval.go index f88c5e2..e1f3752 100644 --- a/src/texec/eval.go +++ b/src/texec/eval.go @@ -455,6 +455,14 @@ func getLiteralType(v tparse.Node) TType { } } +func typePrepend(t TType, p string) TType { + return TType{append(t.Pre, p), t.T, t.Post} +} + +func typeStrip(t TType) TType { + return TType{append([]string{}, t.Pre[1:]...), t.T, t.Post} +} + // Convert Value to Struct from Array (cvsa) // USE ONLY IN THE CASE OF tStruct! func cvsa(sct TArtifact, dat []interface{}) VarMap { @@ -496,7 +504,7 @@ func cata(st TArtifact, dat []interface{}) []interface{} { case VarMap: out = append(out, csts(st, v)) default: - out = append(out, v) + out = append(out, convertValPS(TType{[]string{}, st, ""}, 0, v)) } } @@ -536,6 +544,7 @@ func csts(st TArtifact, dat VarMap) VarMap { } func convertValPS(to TType, sk int, dat interface{}) interface{} { + fmt.Println(to) if isPointer(to, sk) || equateTypePSO(to, tFile, sk) { return dat } @@ -575,7 +584,7 @@ func convertValPS(to TType, sk int, dat interface{}) interface{} { return int(numcv) } else if equateTypePSO(to, tFloat, sk) { return float64(numcv) - } else if equateTypePSO(to, tByte, sk) { + } else if equateTypePSO(to, tByte, sk) || equateTypePSO(to, tCharp, sk) { return byte(numcv) } else if equateTypePSO(to, tBool, sk) { return numcv != 0 @@ -710,12 +719,16 @@ func isArray(t TType, skp int) bool { // Deals with call and index nodes func evalCIN(v tparse.Node, ctx *VarMap, wk *TVariable) *TVariable { + fmt.Println(v, wk) if v.Sub[0].Data.Data == "call" { args := []TVariable{} - - pth := wk.Type.T - if wk != nil && wk.Data != nil { - args = append(args, *wk) + + pth := TArtifact{[]string{}, v.Data.Data} + if wk != nil { + pth = wk.Type.T + if wk.Data != nil { + args = append(args, *wk) + } } for i := 0; i < len(v.Sub[0].Sub); i++ { diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go index 0f02f32..581d15e 100644 --- a/src/texec/libtnsl.go +++ b/src/texec/libtnsl.go @@ -117,11 +117,19 @@ func tnslFileEval(file, in TVariable, function string) TVariable { // Generic IO funcs func tprint(in TVariable) { - fmt.Print(in.Data) + if equateType(in.Type, tString) { + fmt.Print(datToString(in.Data)) + } else { + fmt.Print(in.Data) + } } func tprintln(in TVariable) { - fmt.Println(in.Data) + if equateType(in.Type, tString) { + fmt.Println(datToString(in.Data)) + } else { + fmt.Println(in.Data) + } } func datToString(dat interface{}) string { |