aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-15 03:01:04 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-15 03:01:04 -0400
commit688f883e16e98a94c9654fa2bf6fc8257f01e2e6 (patch)
treebd2bf0ea244eebaa308e5489fd99c418395def38 /compile.c
parent66ae30ac29d93ac7346bbb465e6c49f540ec4079 (diff)
Add array:find()
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 71800a97..ee4d2e5a 100644
--- a/compile.c
+++ b/compile.c
@@ -2194,6 +2194,11 @@ CORD compile(env_t *env, ast_t *ast)
CORD self = compile_to_pointer_depth(env, call->self, 1, false);
(void)compile_arguments(env, ast, NULL, call->args);
return CORD_all("Array$clear(", self, ")");
+ } else if (streq(call->name, "find")) {
+ CORD self = compile_to_pointer_depth(env, call->self, 0, false);
+ arg_t *arg_spec = new(arg_t, .name="item", .type=item_t);
+ return CORD_all("Array$find_value(", self, ", ", compile_arguments(env, ast, arg_spec, call->args),
+ ", ", compile_type_info(env, self_value_t), ")");
} else if (streq(call->name, "from")) {
CORD self = compile_to_pointer_depth(env, call->self, 0, false);
arg_t *arg_spec = new(arg_t, .name="first", .type=INT_TYPE);