diff options
Diffstat (limited to 'tnslc/compile')
| -rw-r--r-- | tnslc/compile/struct.tnsl | 32 |
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) |