summaryrefslogtreecommitdiff
path: root/tnslc
diff options
context:
space:
mode:
Diffstat (limited to 'tnslc')
-rw-r--r--tnslc/compile/struct.tnsl32
-rw-r--r--tnslc/test.tnsl26
2 files changed, 34 insertions, 24 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)
diff --git a/tnslc/test.tnsl b/tnslc/test.tnsl
index fd29a23..b36a0d2 100644
--- a/tnslc/test.tnsl
+++ b/tnslc/test.tnsl
@@ -1,27 +1,7 @@
-/; module Container
- /; module m1
- struct Box {
- ~uint8 data
- }
- ;/
-
- /; module m2
- struct Crate {
- {}m1.Box boxes
- }
- ;/
-
-;/
-
-struct Option {
- bool has_crate,
- Container.m2.Crate crate
-}
-
-
/; main (int argc, ~~uint8 argv) [int]
-
- return 0
+ asm "mov r10, rdi"
+ asm "mov r11, rsi"
+ return argc
;/