aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-05-12 20:13:19 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-05-12 20:13:19 -0400
commit02fe49a7646807964d214605a478c90d82d2c8a3 (patch)
treef732f3db3b6d7e2eebed68dc4c6f1af57a313279 /types.c
parent934fd8a173ccad9aa1291c658dbac712eef78b4b (diff)
Deprecate interfaces (RIP)
Diffstat (limited to 'types.c')
-rw-r--r--types.c38
1 files changed, 4 insertions, 34 deletions
diff --git a/types.c b/types.c
index f7270a98..f2acb0ba 100644
--- a/types.c
+++ b/types.c
@@ -45,9 +45,6 @@ CORD type_to_cord(type_t *t) {
auto struct_ = Match(t, StructType);
return struct_->name;
}
- case InterfaceType: {
- return Match(t, InterfaceType)->name;
- }
case PointerType: {
auto ptr = Match(t, PointerType);
CORD sigil = ptr->is_stack ? "&" : "@";
@@ -216,7 +213,6 @@ bool has_heap_memory(type_t *t)
}
return false;
}
- case InterfaceType: return true;
default: return false;
}
}
@@ -309,7 +305,6 @@ bool can_leave_uninitialized(type_t *t)
}
return true;
}
- case InterfaceType: return false;
default: return false;
}
}
@@ -337,13 +332,6 @@ static bool _can_have_cycles(type_t *t, table_t *seen)
}
return false;
}
- case InterfaceType: {
- for (arg_t *field = Match(t, InterfaceType)->fields; field; field = field->next) {
- if (_can_have_cycles(field->type, seen))
- return true;
- }
- return false;
- }
default: return false;
}
}
@@ -390,13 +378,6 @@ type_t *replace_type(type_t *t, type_t *target, type_t *replacement)
Match((struct type_s*)t, EnumType)->tags = tags;
return t;
}
- case InterfaceType: {
- auto interface = Match(t, InterfaceType);
- arg_t *fields = LIST_MAP(interface->fields, field, .type=replace_type(field->type, target, replacement));
- t = COPY(t);
- Match((struct type_s*)t, InterfaceType)->fields = fields;
- return t;
- }
default: return t;
}
#undef COPY
@@ -417,8 +398,8 @@ size_t type_size(type_t *t)
case FunctionType: return sizeof(void*);
case ClosureType: return sizeof(struct {void *fn, *userdata;});
case PointerType: return sizeof(void*);
- case StructType: case InterfaceType: {
- arg_t *fields = t->tag == StructType ? Match(t, StructType)->fields : Match(t, InterfaceType)->fields;
+ case StructType: {
+ arg_t *fields = Match(t, StructType)->fields;
size_t size = t->tag == StructType ? 0 : sizeof(void*);
for (arg_t *field = fields; field; field = field->next) {
type_t *field_type = field->type;
@@ -468,8 +449,8 @@ size_t type_align(type_t *t)
case FunctionType: return __alignof__(void*);
case ClosureType: return __alignof__(struct {void *fn, *userdata;});
case PointerType: return __alignof__(void*);
- case StructType: case InterfaceType: {
- arg_t *fields = t->tag == StructType ? Match(t, StructType)->fields : Match(t, InterfaceType)->fields;
+ case StructType: {
+ arg_t *fields = Match(t, StructType)->fields;
size_t align = t->tag == StructType ? 0 : sizeof(void*);
for (arg_t *field = fields; field; field = field->next) {
size_t field_align = type_align(field->type);
@@ -505,17 +486,6 @@ type_t *get_field_type(type_t *t, const char *field_name)
}
return NULL;
}
- case InterfaceType: {
- auto interface = Match(t, InterfaceType);
- for (arg_t *field = interface->fields; field; field = field->next) {
- if (streq(field->name, field_name)) {
- if (field->type->tag == PointerType)
- return Match(field->type, PointerType)->pointed;
- return field->type;
- }
- }
- return NULL;
- }
case EnumType: {
auto e = Match(t, EnumType);
for (tag_t *tag = e->tags; tag; tag = tag->next) {