diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-07-10 13:42:58 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-07-10 13:42:58 -0400 |
| commit | 068d0e8563dab7708711e0171ba1190d6037f0c9 (patch) | |
| tree | 97797b983af875147e05ad5a0e233b1d8928c5c2 /compile.c | |
| parent | 10e86153a2c619d7f853ab149e451a9cc05fdb27 (diff) | |
Add array:to() to split out functionality of array:from()
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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)); |
