summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-10-30 21:17:42 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2019-10-30 21:17:42 -0400
commit4ee46b53971e876d93fea0c0a2ba358cad51be21 (patch)
tree431d4694c62236b36a2e10fbb2ca50b3d4aff7e1 /types.c
parentfdc1946407222c340609d6c993138690a508a641 (diff)
probably got structs working (but not .)
Diffstat (limited to 'types.c')
-rw-r--r--types.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/types.c b/types.c
index eb5b0df..65534a1 100644
--- a/types.c
+++ b/types.c
@@ -45,6 +45,7 @@ static bool type_eq(Type *a, Type *b) {
return a->user.name == b->user.name;
case TYPE_BUILTIN:
return a->builtin == b->builtin;
+ case TYPE_STRUCT: return false;
case TYPE_FN: {
if (arr_len(a->fn.types) != arr_len(b->fn.types)) return false;
@@ -367,6 +368,12 @@ static bool type_resolve(Typer *tr, Type *t, Location where) {
return false;
}
break;
+ case TYPE_STRUCT:
+ arr_foreach(t->struc.fields, Field, f) {
+ if (!type_resolve(tr, f->type, where))
+ return false;
+ }
+ break;
case TYPE_UNKNOWN:
case TYPE_VOID:
case TYPE_TYPE:
@@ -384,6 +391,7 @@ static bool type_can_be_truthy(Type *t) {
case TYPE_ARR:
case TYPE_TYPE:
case TYPE_USER:
+ case TYPE_STRUCT:
return false;
case TYPE_FN:
case TYPE_UNKNOWN:
@@ -413,6 +421,7 @@ static Status type_cast_status(Type *from, Type *to) {
}
switch (from->kind) {
case TYPE_UNKNOWN: return STATUS_NONE;
+ case TYPE_STRUCT:
case TYPE_TYPE:
case TYPE_VOID:
return STATUS_ERR;
@@ -436,6 +445,7 @@ static Status type_cast_status(Type *from, Type *to) {
case TYPE_TYPE:
case TYPE_TUPLE:
case TYPE_SLICE:
+ case TYPE_STRUCT:
case TYPE_ARR:
case TYPE_VOID:
case TYPE_USER: /* handled above */