aboutsummaryrefslogtreecommitdiff
path: root/src/compile
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-21 15:43:59 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-21 15:43:59 -0400
commit71f73d8b3ce63f9a3685bc1a1686ef4fab3294a6 (patch)
tree99fe1309fa4d24609867dcc62859caed909a76d9 /src/compile
parentf5612e38183dc20d18f207f8ab055574a4d93ad0 (diff)
Deprecate sets
Diffstat (limited to 'src/compile')
-rw-r--r--src/compile/binops.c18
-rw-r--r--src/compile/compilation.h1
-rw-r--r--src/compile/conditionals.c2
-rw-r--r--src/compile/expressions.c14
-rw-r--r--src/compile/fieldaccess.c7
-rw-r--r--src/compile/functions.c11
-rw-r--r--src/compile/indexing.c2
-rw-r--r--src/compile/lists.c2
-rw-r--r--src/compile/loops.c39
-rw-r--r--src/compile/optionals.c3
-rw-r--r--src/compile/pointers.c2
-rw-r--r--src/compile/promotions.c9
-rw-r--r--src/compile/sets.c138
-rw-r--r--src/compile/sets.h11
-rw-r--r--src/compile/text.c1
-rw-r--r--src/compile/types.c8
16 files changed, 34 insertions, 234 deletions
diff --git a/src/compile/binops.c b/src/compile/binops.c
index 9710019b..0bff98c0 100644
--- a/src/compile/binops.c
+++ b/src/compile/binops.c
@@ -160,8 +160,8 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) {
return Texts("(", lhs, " + ", rhs, ")");
}
case Minus: {
- if (overall_t->tag == SetType)
- return Texts("Table$without(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")");
+ if (overall_t->tag == TableType)
+ return Texts("Table$minus(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")");
if (overall_t->tag != IntType && overall_t->tag != NumType && overall_t->tag != ByteType)
code_err(ast,
"Math operations are only supported for values of the same "
@@ -204,8 +204,8 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) {
case And: {
if (overall_t->tag == BoolType) return Texts("(", lhs, " && ", rhs, ")");
else if (overall_t->tag == IntType || overall_t->tag == ByteType) return Texts("(", lhs, " & ", rhs, ")");
- else if (overall_t->tag == SetType)
- return Texts("Table$overlap(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")");
+ else if (overall_t->tag == TableType)
+ return Texts("Table$and(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")");
else
code_err(ast, "The 'and' operator isn't supported between ", type_to_text(lhs_t), " and ",
type_to_text(rhs_t), " values");
@@ -218,18 +218,18 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) {
return Texts("(", lhs, " || ", rhs, ")");
} else if (overall_t->tag == IntType || overall_t->tag == ByteType) {
return Texts("(", lhs, " | ", rhs, ")");
- } else if (overall_t->tag == SetType) {
- return Texts("Table$with(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")");
+ } else if (overall_t->tag == TableType) {
+ return Texts("Table$or(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")");
} else {
- code_err(ast, "The 'or' operator isn't supported between ", type_to_text(lhs_t), " and ", type_to_text(rhs_t),
- " values");
+ code_err(ast, "The 'or' operator isn't supported between ", type_to_text(lhs_t), " and ",
+ type_to_text(rhs_t), " values");
}
}
case Xor: {
// TODO: support optional values in `xor` expressions
if (overall_t->tag == BoolType || overall_t->tag == IntType || overall_t->tag == ByteType)
return Texts("(", lhs, " ^ ", rhs, ")");
- else if (overall_t->tag == SetType)
+ else if (overall_t->tag == TableType)
return Texts("Table$xor(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")");
else
code_err(ast, "The 'xor' operator isn't supported between ", type_to_text(lhs_t), " and ",
diff --git a/src/compile/compilation.h b/src/compile/compilation.h
index c034295f..d881684b 100644
--- a/src/compile/compilation.h
+++ b/src/compile/compilation.h
@@ -26,7 +26,6 @@
#include "pointers.h" // IWYU pragma: export
#include "promotions.h" // IWYU pragma: export
#include "reductions.h" // IWYU pragma: export
-#include "sets.h" // IWYU pragma: export
#include "statements.h" // IWYU pragma: export
#include "structs.h" // IWYU pragma: export
#include "tables.h" // IWYU pragma: export
diff --git a/src/compile/conditionals.c b/src/compile/conditionals.c
index 7fcd6cc8..caebdbde 100644
--- a/src/compile/conditionals.c
+++ b/src/compile/conditionals.c
@@ -18,7 +18,7 @@ Text_t compile_condition(env_t *env, ast_t *ast) {
return Texts("(", compile(env, ast), ").length");
} else if (t->tag == ListType) {
return Texts("(", compile(env, ast), ").length");
- } else if (t->tag == TableType || t->tag == SetType) {
+ } else if (t->tag == TableType) {
return Texts("(", compile(env, ast), ").entries.length");
} else if (t->tag == OptionalType) {
return Texts("!", check_none(t, compile(env, ast)));
diff --git a/src/compile/expressions.c b/src/compile/expressions.c
index 16b94d73..c511bea1 100644
--- a/src/compile/expressions.c
+++ b/src/compile/expressions.c
@@ -13,8 +13,7 @@ public
Text_t compile_maybe_incref(env_t *env, ast_t *ast, type_t *t) {
if (is_idempotent(ast) && can_be_mutated(env, ast)) {
if (t->tag == ListType) return Texts("LIST_COPY(", compile_to_type(env, ast, t), ")");
- else if (t->tag == TableType || t->tag == SetType)
- return Texts("TABLE_COPY(", compile_to_type(env, ast, t), ")");
+ else if (t->tag == TableType) return Texts("TABLE_COPY(", compile_to_type(env, ast, t), ")");
}
return compile_to_type(env, ast, t);
}
@@ -44,7 +43,6 @@ Text_t compile_empty(type_t *t) {
case BoolType: return Text("((Bool_t)no)");
case ListType: return Text("((List_t){})");
case TableType:
- case SetType: return Text("((Table_t){})");
case TextType: return Text("Text(\"\")");
case CStringType: return Text("\"\"");
case PointerType: {
@@ -93,8 +91,7 @@ Text_t compile(env_t *env, ast_t *ast) {
if (t->tag == BoolType) return Texts("!(", compile(env, value), ")");
else if (t->tag == IntType || t->tag == ByteType) return Texts("~(", compile(env, value), ")");
else if (t->tag == ListType) return Texts("((", compile(env, value), ").length == 0)");
- else if (t->tag == SetType || t->tag == TableType)
- return Texts("((", compile(env, value), ").entries.length == 0)");
+ else if (t->tag == TableType) return Texts("((", compile(env, value), ").entries.length == 0)");
else if (t->tag == TextType) return Texts("(", compile(env, value), ".length == 0)");
else if (t->tag == OptionalType) return check_none(t, compile(env, value));
@@ -197,13 +194,6 @@ Text_t compile(env_t *env, ast_t *ast) {
type_t *table_type = get_type(env, ast);
return compile_typed_table(env, ast, table_type);
}
- case Set: {
- DeclareMatch(set, ast, Set);
- if (!set->items) return Text("((Table_t){})");
-
- type_t *set_type = get_type(env, ast);
- return compile_typed_set(env, ast, set_type);
- }
case Comprehension: {
ast_t *base = Match(ast, Comprehension)->expr;
while (base->tag == Comprehension)
diff --git a/src/compile/fieldaccess.c b/src/compile/fieldaccess.c
index 24e091f0..65c8f92b 100644
--- a/src/compile/fieldaccess.c
+++ b/src/compile/fieldaccess.c
@@ -48,13 +48,6 @@ Text_t compile_field_access(env_t *env, ast_t *ast) {
return Texts("Int$from_int64((", compile_to_pointer_depth(env, f->fielded, 0, false), ").length)");
code_err(ast, "There is no ", f->field, " field on lists");
}
- case SetType: {
- if (streq(f->field, "items"))
- return Texts("LIST_COPY((", compile_to_pointer_depth(env, f->fielded, 0, false), ").entries)");
- else if (streq(f->field, "length"))
- return Texts("Int$from_int64((", compile_to_pointer_depth(env, f->fielded, 0, false), ").entries.length)");
- code_err(ast, "There is no '", f->field, "' field on sets");
- }
case TableType: {
if (streq(f->field, "length")) {
return Texts("Int$from_int64((", compile_to_pointer_depth(env, f->fielded, 0, false), ").entries.length)");
diff --git a/src/compile/functions.c b/src/compile/functions.c
index d113316b..e2fa8a11 100644
--- a/src/compile/functions.c
+++ b/src/compile/functions.c
@@ -302,8 +302,7 @@ Text_t compile_lambda(env_t *env, ast_t *ast) {
assert(b);
Text_t binding_code = b->code;
if (entry->b->type->tag == ListType) userdata = Texts(userdata, ", LIST_COPY(", binding_code, ")");
- else if (entry->b->type->tag == TableType || entry->b->type->tag == SetType)
- userdata = Texts(userdata, ", TABLE_COPY(", binding_code, ")");
+ else if (entry->b->type->tag == TableType) userdata = Texts(userdata, ", TABLE_COPY(", binding_code, ")");
else userdata = Texts(userdata, ", ", binding_code);
}
userdata = Texts(userdata, ")");
@@ -388,11 +387,6 @@ static void add_closed_vars(Table_t *closed_vars, env_t *enclosing_scope, env_t
add_closed_vars(closed_vars, enclosing_scope, env, item->ast);
break;
}
- case Set: {
- for (ast_list_t *item = Match(ast, Set)->items; item; item = item->next)
- add_closed_vars(closed_vars, enclosing_scope, env, item->ast);
- break;
- }
case Table: {
add_closed_vars(closed_vars, enclosing_scope, env, Match(ast, Table)->default_value);
add_closed_vars(closed_vars, enclosing_scope, env, Match(ast, Table)->fallback);
@@ -413,7 +407,7 @@ static void add_closed_vars(Table_t *closed_vars, env_t *enclosing_scope, env_t
return add_closed_vars(closed_vars, enclosing_scope, env, loop);
}
- // List/Set/Table comprehension:
+ // List/Table comprehension:
ast_t *body = comp->expr;
if (comp->filter) body = WrapAST(comp->expr, If, .condition = comp->filter, .body = body);
ast_t *loop = WrapAST(ast, For, .vars = comp->vars, .iter = comp->iter, .body = body);
@@ -839,7 +833,6 @@ Text_t compile_method_call(env_t *env, ast_t *ast) {
switch (self_value_t->tag) {
case ListType: return compile_list_method_call(env, ast);
- case SetType: return compile_set_method_call(env, ast);
case TableType: return compile_table_method_call(env, ast);
default: {
DeclareMatch(methodcall, ast, MethodCall);
diff --git a/src/compile/indexing.c b/src/compile/indexing.c
index 771e9acd..af5056d7 100644
--- a/src/compile/indexing.c
+++ b/src/compile/indexing.c
@@ -22,7 +22,7 @@ Text_t compile_indexing(env_t *env, ast_t *ast, bool checked) {
DeclareMatch(ptr, indexed_type, PointerType);
if (ptr->pointed->tag == ListType) {
return Texts("*({ List_t *list = ", compile(env, indexing->indexed), "; LIST_INCREF(*list); list; })");
- } else if (ptr->pointed->tag == TableType || ptr->pointed->tag == SetType) {
+ } else if (ptr->pointed->tag == TableType) {
return Texts("*({ Table_t *t = ", compile(env, indexing->indexed), "; TABLE_INCREF(*t); t; })");
} else {
return Texts("*(", compile(env, indexing->indexed), ")");
diff --git a/src/compile/lists.c b/src/compile/lists.c
index d9d71278..4fe83d16 100644
--- a/src/compile/lists.c
+++ b/src/compile/lists.c
@@ -253,7 +253,7 @@ Text_t compile_list_method_call(env_t *env, ast_t *ast) {
} else if (streq(call->name, "unique")) {
self = compile_to_pointer_depth(env, call->self, 0, false);
(void)compile_arguments(env, ast, NULL, call->args);
- return Texts("Table$from_entries(", self, ", Set$info(", compile_type_info(item_t), "))");
+ return Texts("Table$from_entries(", self, ", Table$info(", compile_type_info(item_t), ", &Void$info)).items");
} else if (streq(call->name, "pop")) {
EXPECT_POINTER();
arg_t *arg_spec = new (arg_t, .name = "index", .type = INT_TYPE, .default_val = FakeAST(Int, "-1"));
diff --git a/src/compile/loops.c b/src/compile/loops.c
index b68c908f..588be4f0 100644
--- a/src/compile/loops.c
+++ b/src/compile/loops.c
@@ -188,33 +188,24 @@ Text_t compile_for_loop(env_t *env, ast_t *ast) {
}
return loop;
}
- case SetType:
case TableType: {
Text_t loop = Text("for (int64_t i = 0; i < iterating.length; ++i) {\n");
if (for_->vars) {
- if (iter_value_t->tag == SetType) {
- if (for_->vars->next) code_err(for_->vars->next->ast, "This is too many variables for this loop");
- Text_t item = compile(body_scope, for_->vars->ast);
- type_t *item_type = Match(iter_value_t, SetType)->item_type;
- loop = Texts(loop, compile_declaration(item_type, item), " = *(", compile_type(item_type), "*)(",
- "iterating.data + i*iterating.stride);\n");
- } else {
- Text_t key = compile(body_scope, for_->vars->ast);
- type_t *key_t = Match(iter_value_t, TableType)->key_type;
- loop = Texts(loop, compile_declaration(key_t, key), " = *(", compile_type(key_t), "*)(",
- "iterating.data + i*iterating.stride);\n");
-
- if (for_->vars->next) {
- if (for_->vars->next->next)
- code_err(for_->vars->next->next->ast, "This is too many variables for this loop");
-
- type_t *value_t = Match(iter_value_t, TableType)->value_type;
- Text_t value = compile(body_scope, for_->vars->next->ast);
- Text_t value_offset = Texts("offsetof(struct { ", compile_declaration(key_t, Text("k")), "; ",
- compile_declaration(value_t, Text("v")), "; }, v)");
- loop = Texts(loop, compile_declaration(value_t, value), " = *(", compile_type(value_t), "*)(",
- "iterating.data + i*iterating.stride + ", value_offset, ");\n");
- }
+ Text_t key = compile(body_scope, for_->vars->ast);
+ type_t *key_t = Match(iter_value_t, TableType)->key_type;
+ loop = Texts(loop, compile_declaration(key_t, key), " = *(", compile_type(key_t), "*)(",
+ "iterating.data + i*iterating.stride);\n");
+
+ if (for_->vars->next) {
+ if (for_->vars->next->next)
+ code_err(for_->vars->next->next->ast, "This is too many variables for this loop");
+
+ type_t *value_t = Match(iter_value_t, TableType)->value_type;
+ Text_t value = compile(body_scope, for_->vars->next->ast);
+ Text_t value_offset = Texts("offsetof(struct { ", compile_declaration(key_t, Text("k")), "; ",
+ compile_declaration(value_t, Text("v")), "; }, v)");
+ loop = Texts(loop, compile_declaration(value_t, value), " = *(", compile_type(value_t), "*)(",
+ "iterating.data + i*iterating.stride + ", value_offset, ");\n");
}
}
diff --git a/src/compile/optionals.c b/src/compile/optionals.c
index 234a1cd2..86b4f771 100644
--- a/src/compile/optionals.c
+++ b/src/compile/optionals.c
@@ -72,7 +72,6 @@ Text_t compile_none(type_t *t) {
case ByteType: return Text("NONE_BYTE");
case ListType: return Text("NONE_LIST");
case TableType: return Text("NONE_TABLE");
- case SetType: return Text("NONE_TABLE");
case TextType: return Text("NONE_TEXT");
case CStringType: return Text("NULL");
case PointerType: return Texts("((", compile_type(t), ")NULL)");
@@ -101,7 +100,7 @@ Text_t check_none(type_t *t, Text_t value) {
else if (t->tag == NumType)
return Texts(Match(t, NumType)->bits == TYPE_NBITS64 ? "Num$isnan(" : "Num32$isnan(", value, ")");
else if (t->tag == ListType) return Texts("((", value, ").length < 0)");
- else if (t->tag == TableType || t->tag == SetType) return Texts("((", value, ").entries.length < 0)");
+ else if (t->tag == TableType) return Texts("((", value, ").entries.length < 0)");
else if (t->tag == BoolType) return Texts("((", value, ") == NONE_BOOL)");
else if (t->tag == TextType) return Texts("((", value, ").length < 0)");
else if (t->tag == IntType || t->tag == ByteType || t->tag == StructType) return Texts("(", value, ").is_none");
diff --git a/src/compile/pointers.c b/src/compile/pointers.c
index 31687d78..11348330 100644
--- a/src/compile/pointers.c
+++ b/src/compile/pointers.c
@@ -44,7 +44,7 @@ Text_t compile_to_pointer_depth(env_t *env, ast_t *ast, int64_t target_depth, bo
}
if (needs_incref && t->tag == ListType) val = Texts("LIST_COPY(", val, ")");
- else if (needs_incref && (t->tag == TableType || t->tag == SetType)) val = Texts("TABLE_COPY(", val, ")");
+ else if (needs_incref && t->tag == TableType) val = Texts("TABLE_COPY(", val, ")");
return val;
}
diff --git a/src/compile/promotions.c b/src/compile/promotions.c
index 3441632e..d453b764 100644
--- a/src/compile/promotions.c
+++ b/src/compile/promotions.c
@@ -101,13 +101,6 @@ bool promote(env_t *env, ast_t *ast, Text_t *code, type_t *actual, type_t *neede
return true;
}
- // Set -> List promotion:
- if (needed->tag == ListType && actual->tag == SetType
- && type_eq(Match(needed, ListType)->item_type, Match(actual, SetType)->item_type)) {
- *code = Texts("(", *code, ").entries");
- return true;
- }
-
return false;
}
@@ -141,8 +134,6 @@ Text_t compile_to_type(env_t *env, ast_t *ast, type_t *t) {
return compile_typed_list(env, ast, t);
} else if (t->tag == TableType && ast->tag == Table) {
return compile_typed_table(env, ast, t);
- } else if (t->tag == SetType && ast->tag == Set) {
- return compile_typed_set(env, ast, t);
}
type_t *actual = get_type(env, ast);
diff --git a/src/compile/sets.c b/src/compile/sets.c
deleted file mode 100644
index 3346a9aa..00000000
--- a/src/compile/sets.c
+++ /dev/null
@@ -1,138 +0,0 @@
-// This file defines how to compile sets
-
-#include "../ast.h"
-#include "../environment.h"
-#include "../stdlib/datatypes.h"
-#include "../stdlib/text.h"
-#include "../typecheck.h"
-#include "../types.h"
-#include "compilation.h"
-
-static ast_t *add_to_set_comprehension(ast_t *item, ast_t *subject) {
- return WrapAST(item, MethodCall, .name = "add", .self = subject, .args = new (arg_ast_t, .value = item));
-}
-
-Text_t compile_typed_set(env_t *env, ast_t *ast, type_t *set_type) {
- DeclareMatch(set, ast, Set);
- if (!set->items) return Text("((Table_t){})");
-
- type_t *item_type = Match(set_type, SetType)->item_type;
-
- int64_t n = 0;
- for (ast_list_t *item = set->items; item; item = item->next) {
- ++n;
- if (item->ast->tag == Comprehension) goto set_comprehension;
- }
-
- { // No comprehension:
- Text_t code = Texts("Set(", compile_type(item_type), ", ", compile_type_info(item_type), ", ", n);
- env_t *scope = item_type->tag == EnumType ? with_enum_scope(env, item_type) : env;
- for (ast_list_t *item = set->items; item; item = item->next) {
- code = Texts(code, ", ", compile_to_type(scope, item->ast, item_type));
- }
- return Texts(code, ")");
- }
-
-set_comprehension: {
- static int64_t comp_num = 1;
- env_t *scope = item_type->tag == EnumType ? with_enum_scope(env, item_type) : fresh_scope(env);
- const char *comprehension_name = String("set$", comp_num++);
- ast_t *comprehension_var =
- LiteralCode(Texts("&", comprehension_name), .type = Type(PointerType, .pointed = set_type, .is_stack = true));
- Text_t code = Texts("({ Table_t ", comprehension_name, " = {};");
- Closure_t comp_action = {.fn = add_to_set_comprehension, .userdata = comprehension_var};
- scope->comprehension_action = &comp_action;
- for (ast_list_t *item = set->items; item; item = item->next) {
- if (item->ast->tag == Comprehension) code = Texts(code, "\n", compile_statement(scope, item->ast));
- else code = Texts(code, compile_statement(env, add_to_set_comprehension(item->ast, comprehension_var)));
- }
- code = Texts(code, " ", comprehension_name, "; })");
- return code;
-}
-}
-
-public
-Text_t compile_set_method_call(env_t *env, ast_t *ast) {
- DeclareMatch(call, ast, MethodCall);
- type_t *self_t = get_type(env, call->self);
-
- int64_t pointer_depth = 0;
- type_t *self_value_t = self_t;
- for (; self_value_t->tag == PointerType; self_value_t = Match(self_value_t, PointerType)->pointed)
- pointer_depth += 1;
-
- Text_t self = compile(env, call->self);
-#define EXPECT_POINTER() \
- do { \
- if (pointer_depth < 1) code_err(call->self, "I expected a set pointer here, not a set value"); \
- else if (pointer_depth > 1) code_err(call->self, "I expected a set pointer here, not a nested set pointer"); \
- } while (0)
- DeclareMatch(set, self_value_t, SetType);
- if (streq(call->name, "has")) {
- self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec = new (arg_t, .name = "key", .type = set->item_type);
- return Texts("Table$has_value(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
- compile_type_info(self_value_t), ")");
- } else if (streq(call->name, "add")) {
- EXPECT_POINTER();
- arg_t *arg_spec = new (arg_t, .name = "item", .type = set->item_type);
- return Texts("Table$set_value(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", NULL, ",
- compile_type_info(self_value_t), ")");
- } else if (streq(call->name, "add_all")) {
- EXPECT_POINTER();
- arg_t *arg_spec =
- new (arg_t, .name = "items", .type = Type(ListType, .item_type = Match(self_value_t, SetType)->item_type));
- return Texts("({ Table_t *set = ", self, "; ",
- "List_t to_add = ", compile_arguments(env, ast, arg_spec, call->args), "; ",
- "for (int64_t i = 0; i < to_add.length; i++)\n"
- "Table$set(set, to_add.data + i*to_add.stride, NULL, ",
- compile_type_info(self_value_t), ");\n", "(void)0; })");
- } else if (streq(call->name, "remove")) {
- EXPECT_POINTER();
- arg_t *arg_spec = new (arg_t, .name = "item", .type = set->item_type);
- return Texts("Table$remove_value(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
- compile_type_info(self_value_t), ")");
- } else if (streq(call->name, "remove_all")) {
- EXPECT_POINTER();
- arg_t *arg_spec =
- new (arg_t, .name = "items", .type = Type(ListType, .item_type = Match(self_value_t, SetType)->item_type));
- return Texts("({ Table_t *set = ", self, "; ",
- "List_t to_add = ", compile_arguments(env, ast, arg_spec, call->args), "; ",
- "for (int64_t i = 0; i < to_add.length; i++)\n"
- "Table$remove(set, to_add.data + i*to_add.stride, ",
- compile_type_info(self_value_t), ");\n", "(void)0; })");
- } else if (streq(call->name, "clear")) {
- EXPECT_POINTER();
- (void)compile_arguments(env, ast, NULL, call->args);
- return Texts("Table$clear(", self, ")");
- } else if (streq(call->name, "with")) {
- self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec = new (arg_t, .name = "other", .type = self_value_t);
- return Texts("Table$with(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
- compile_type_info(self_value_t), ")");
- } else if (streq(call->name, "overlap")) {
- self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec = new (arg_t, .name = "other", .type = self_value_t);
- return Texts("Table$overlap(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
- compile_type_info(self_value_t), ")");
- } else if (streq(call->name, "without")) {
- self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec = new (arg_t, .name = "other", .type = self_value_t);
- return Texts("Table$without(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
- compile_type_info(self_value_t), ")");
- } else if (streq(call->name, "is_subset_of")) {
- self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec =
- new (arg_t, .name = "other", .type = self_value_t,
- .next = new (arg_t, .name = "strict", .type = Type(BoolType), .default_val = FakeAST(Bool, false)));
- return Texts("Table$is_subset_of(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
- compile_type_info(self_value_t), ")");
- } else if (streq(call->name, "is_superset_of")) {
- self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec =
- new (arg_t, .name = "other", .type = self_value_t,
- .next = new (arg_t, .name = "strict", .type = Type(BoolType), .default_val = FakeAST(Bool, false)));
- return Texts("Table$is_superset_of(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
- compile_type_info(self_value_t), ")");
- } else code_err(ast, "There is no '", call->name, "' method for tables");
-}
diff --git a/src/compile/sets.h b/src/compile/sets.h
deleted file mode 100644
index 1582e3cd..00000000
--- a/src/compile/sets.h
+++ /dev/null
@@ -1,11 +0,0 @@
-// This file defines how to compile sets
-
-#pragma once
-
-#include "../ast.h"
-#include "../environment.h"
-#include "../stdlib/datatypes.h"
-#include "../types.h"
-
-Text_t compile_typed_set(env_t *env, ast_t *ast, type_t *set_type);
-Text_t compile_set_method_call(env_t *env, ast_t *ast);
diff --git a/src/compile/text.c b/src/compile/text.c
index afb412e9..637ad60c 100644
--- a/src/compile/text.c
+++ b/src/compile/text.c
@@ -30,7 +30,6 @@ Text_t expr_as_text(Text_t expr, type_t *t, Text_t color) {
}
case TextType: return Texts("Text$as_text(stack(", expr, "), ", color, ", ", compile_type_info(t), ")");
case ListType: return Texts("List$as_text(stack(", expr, "), ", color, ", ", compile_type_info(t), ")");
- case SetType: return Texts("Table$as_text(stack(", expr, "), ", color, ", ", compile_type_info(t), ")");
case TableType: return Texts("Table$as_text(stack(", expr, "), ", color, ", ", compile_type_info(t), ")");
case FunctionType:
case ClosureType: return Texts("Func$as_text(stack(", expr, "), ", color, ", ", compile_type_info(t), ")");
diff --git a/src/compile/types.c b/src/compile/types.c
index 6b6f48f8..e407a6d0 100644
--- a/src/compile/types.c
+++ b/src/compile/types.c
@@ -33,7 +33,6 @@ Text_t compile_type(type_t *t) {
else return namespace_name(text->env, text->env->namespace, Text("$type"));
}
case ListType: return Text("List_t");
- case SetType: return Text("Table_t");
case TableType: return Text("Table_t");
case FunctionType: {
DeclareMatch(fn, t, FunctionType);
@@ -71,8 +70,7 @@ Text_t compile_type(type_t *t) {
case BoolType:
case ByteType:
case ListType:
- case TableType:
- case SetType: return Texts("Optional", compile_type(nonnull));
+ case TableType: return Texts("Optional", compile_type(nonnull));
case StructType: {
if (nonnull == PATH_TYPE) return Text("OptionalPath_t");
if (nonnull == PATH_TYPE_TYPE) return Text("OptionalPathType_t");
@@ -118,10 +116,6 @@ Text_t compile_type_info(type_t *t) {
type_t *item_t = Match(t, ListType)->item_type;
return Texts("List$info(", compile_type_info(item_t), ")");
}
- case SetType: {
- type_t *item_type = Match(t, SetType)->item_type;
- return Texts("Set$info(", compile_type_info(item_type), ")");
- }
case TableType: {
DeclareMatch(table, t, TableType);
type_t *key_type = table->key_type;