aboutsummaryrefslogtreecommitdiff
path: root/src/type.cff
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-17 22:47:36 +0200
committerlemon <lsof@mailbox.org>2022-08-17 22:47:36 +0200
commit1c25c197d860ad49bb6a84e077a54e5aaf441bbd (patch)
tree8f7b963d1c891cfaa2d490a2f651ac0b8fa83c42 /src/type.cff
parent86242b6cc1f53a86fcce1312211d3232661bf454 (diff)
parse defmacro
Diffstat (limited to 'src/type.cff')
-rw-r--r--src/type.cff11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/type.cff b/src/type.cff
index e3989c7..980a83a 100644
--- a/src/type.cff
+++ b/src/type.cff
@@ -10,7 +10,10 @@ struct TypeTraits {
h = fnv1a_i(h, ty.konst ? 1 : 0);
switch ty.u {
- case Void; case Bool;
+ case Void;
+
+ case Bool;
+ h = fnv1a_i(h, ty.size);
case Flo;
h = fnv1a_i(h, ty.size);
@@ -121,12 +124,14 @@ extern fn completetype(ty *const Type) bool {
case Void; return #f;
case Fn; return #f;
case Arr a; return a.length >= 0;
+ case Agg agg; return !agg.fwd;
}
return #t;
}
extern static ty_void *const Type = {},
ty_bool *const Type = {},
+ ty_intbool *const Type = {},
ty_i8 *const Type = {},
ty_u8 *const Type = {},
ty_i16 *const Type = {},
@@ -159,6 +164,7 @@ extern fn putprimtypes(env *Env) void {
{ "u32", &ty_u32, { .size: 4, .u: :Int { .sgn: #f }}},
{ "int", &ty_int, { g_targ.intsize, .u: :Int { .sgn: #t }}},
{ "uint", &ty_uint, { g_targ.intsize, .u: :Int { .sgn: #f }}},
+ { "intbool",&ty_intbool,{ .size: g_targ.intsize, .u: :Bool }},
{ "isize", &ty_isize,{ g_targ.sizesize, .u: :Int { .sgn: #t }}},
{ "usize", &ty_usize,{ g_targ.sizesize, .u: :Int { .sgn: #f }}},
{ "i64", &ty_i64, { .size: 8, g_targ.i64align, .u: :Int { .sgn: #t }}},
@@ -242,6 +248,9 @@ extern fn typeof2(a *const Type, b *const Type) *const Type {
if a == unconstify(b) {
return b;
}
+ if a->is(:Bool) and b->is(:Bool) {
+ return a.size > b.size ? a : b;
+ }
if a->is(:Arr) and b->is(:Arr) {
a = arraydecay(a);
}