aboutsummaryrefslogtreecommitdiff
path: root/src/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-17 16:54:57 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-17 16:54:57 -0400
commit602cedd03b0c3d6ef176efafb08f51bde9bfe543 (patch)
tree8b135f17daa62591c63c4bdcd980bc3da224b4d8 /src/compile.c
parent27d9689e2f6ff5ccfedb8a56e58bffbaf4e9a310 (diff)
Fix List.slice()
Diffstat (limited to 'src/compile.c')
-rw-r--r--src/compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/compile.c b/src/compile.c
index 1648363a..cc9a7bd6 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -3337,6 +3337,10 @@ Text_t compile(env_t *env, ast_t *ast)
self = compile_to_pointer_depth(env, call->self, 0, true);
arg_t *arg_spec = new(arg_t, .name="last", .type=INT_TYPE);
return Texts("List$to(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ")");
+ } else if (streq(call->name, "slice")) {
+ self = compile_to_pointer_depth(env, call->self, 0, true);
+ arg_t *arg_spec = new(arg_t, .name="first", .type=INT_TYPE, .next=new(arg_t, .name="last", .type=INT_TYPE));
+ return Texts("List$slice(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ")");
} else if (streq(call->name, "by")) {
self = compile_to_pointer_depth(env, call->self, 0, true);
arg_t *arg_spec = new(arg_t, .name="stride", .type=INT_TYPE);