From 068d0e8563dab7708711e0171ba1190d6037f0c9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 10 Jul 2024 13:42:58 -0400 Subject: Add array:to() to split out functionality of array:from() --- compile.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 9d6b1665..fe6d8454 100644 --- a/compile.c +++ b/compile.c @@ -1815,9 +1815,12 @@ CORD compile(env_t *env, ast_t *ast) return CORD_all("Array$clear(", self, ")"); } else if (streq(call->name, "from")) { CORD self = compile_to_pointer_depth(env, call->self, 1, false); - arg_t *arg_spec = new(arg_t, .name="first", .type=Type(IntType, .bits=64), .default_val=FakeAST(Int, .i=1, .bits=64), - .next=new(arg_t, .name="last", .type=Type(IntType, .bits=64), .default_val=FakeAST(Int, .i=-1, .bits=64))); + arg_t *arg_spec = new(arg_t, .name="first", .type=Type(IntType, .bits=64)); return CORD_all("Array$from(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ")"); + } else if (streq(call->name, "to")) { + CORD self = compile_to_pointer_depth(env, call->self, 1, false); + arg_t *arg_spec = new(arg_t, .name="last", .type=Type(IntType, .bits=64)); + return CORD_all("Array$to(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ")"); } else if (streq(call->name, "by")) { CORD self = compile_to_pointer_depth(env, call->self, 1, false); arg_t *arg_spec = new(arg_t, .name="stride", .type=Type(IntType, .bits=64)); -- cgit v1.2.3