From 688f883e16e98a94c9654fa2bf6fc8257f01e2e6 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 15 Aug 2024 03:01:04 -0400 Subject: Add array:find() --- compile.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compile.c') 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); -- cgit v1.2.3