summaryrefslogtreecommitdiff
path: root/tnslc/compile/struct.tnsl
diff options
context:
space:
mode:
authorCircleShift <kgunger12@gmail.com>2025-12-18 20:25:21 -0500
committerCircleShift <kgunger12@gmail.com>2025-12-18 20:25:21 -0500
commita87a01d2d80e3bb764b9aa2051c9be7f47f977a6 (patch)
treeb77d8c0bfa261ea6ecef63c3b668d8d7ee770692 /tnslc/compile/struct.tnsl
parent0587f854d80a9ad95c459b45509fcda7926cde20 (diff)
is_primitive helper
Diffstat (limited to 'tnslc/compile/struct.tnsl')
-rw-r--r--tnslc/compile/struct.tnsl32
1 files changed, 31 insertions, 1 deletions
diff --git a/tnslc/compile/struct.tnsl b/tnslc/compile/struct.tnsl
index eba1488..715d576 100644
--- a/tnslc/compile/struct.tnsl
+++ b/tnslc/compile/struct.tnsl
@@ -13,6 +13,19 @@ struct Struct {
~uint8 PRIMITIVE_4 = "uint32,int32,float32\0"
~uint8 PRIMITIVE_8 = "uint64,int64,float64,int,uint,float,void\0"
+/; _is_primitive(~uint8 str) [int]
+ /; if (parse._in_csv(PRIMITIVE_1, str) == true)
+ return 1
+ ;; else if (parse._in_csv(PRIMITIVE_2, str) == true)
+ return 2
+ ;; else if (parse._in_csv(PRIMITIVE_4, str) == true)
+ return 4
+ ;; else if (parse._in_csv(PRIMITIVE_8, str) == true)
+ return 8
+ ;/
+ return 0
+;/
+
/; is_primitive (~parse.Node tn) [int]
/; if (tn`.sub.count < 1)
return 0
@@ -31,7 +44,24 @@ struct Struct {
return 8
;/
- return 0
+ int id = 0 - 1
+ /; loop (int i = 0; i < tn`.sub.count) [i++]
+ n = tn`.sub.get(i)
+ /; if (n`._type == parse.NTYPE_ID)
+ /; if (id < 0)
+ id = i
+ ;; else
+ return 0
+ ;/
+ ;/
+ ;/
+
+ /; if (id < 0)
+ return 0
+ ;/
+
+ n = tn`.sub.get(id)
+ return _is_primitive(n`.data)
;/
/; _print_type(~parse.Node tn)