diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 22:55:03 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 22:55:03 -0400 |
| commit | 0d36812c6af951a41caac77d5f312949f3bc521f (patch) | |
| tree | ae0f545805c524ffa467b925687bf70e88e2bc58 /src/compile/tables.c | |
| parent | fa7a0ddc0963deb387f0cae7bb22ca968ee9146f (diff) | |
Deprecate binary ops (other than ++) for tables. Instead use proper
methods: t.with(other), t.without(other), t.intersection(other),
t.difference(other)
Diffstat (limited to 'src/compile/tables.c')
| -rw-r--r-- | src/compile/tables.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/compile/tables.c b/src/compile/tables.c index b6efdecd..814d81f5 100644 --- a/src/compile/tables.c +++ b/src/compile/tables.c @@ -139,5 +139,25 @@ Text_t compile_table_method_call(env_t *env, ast_t *ast) { self = compile_to_pointer_depth(env, call->self, 0, false); arg_t *arg_spec = new (arg_t, .name = "fallback", .type = Type(OptionalType, self_value_t)); return Texts("Table$with_fallback(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ")"); + } else if (streq(call->name, "intersection")) { + 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$intersection(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ", + compile_type_info(self_value_t), ")"); + } 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, "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, "difference")) { + 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$difference(", 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"); } |
