aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-18 23:59:13 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-18 23:59:13 -0400
commit8363d53bd27c621cb342fea15736a3b11231f2a4 (patch)
tree094530cdd947f57197171f1dda58057739d63151 /compile.c
parent9e07c6adc7a0616eec40e78024a8501ec7d96559 (diff)
Update channel API to take a Where parameter
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/compile.c b/compile.c
index 477913c7..e674d8fa 100644
--- a/compile.c
+++ b/compile.c
@@ -2363,24 +2363,30 @@ CORD compile(env_t *env, ast_t *ast)
case ChannelType: {
type_t *item_t = Match(self_value_t, ChannelType)->item_type;
CORD padded_item_size = CORD_asprintf("%ld", padded_type_size(item_t));
+ arg_t *where_default_end = new(arg_t, .name="where", .type=WHERE_TYPE,
+ .default_val=FakeAST(FieldAccess, .fielded=FakeAST(Var, "Where"), .field="End"));
+ arg_t *where_default_start = new(arg_t, .name="where", .type=WHERE_TYPE,
+ .default_val=FakeAST(FieldAccess, .fielded=FakeAST(Var, "Where"), .field="Start"));
if (streq(call->name, "give")) {
CORD self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec = new(arg_t, .name="item", .type=item_t);
+ arg_t *arg_spec = new(arg_t, .name="item", .type=item_t, .next=where_default_end);
return CORD_all("Channel$give_value(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
padded_item_size, ")");
} else if (streq(call->name, "give_all")) {
CORD self = compile_to_pointer_depth(env, call->self, 0, false);
- arg_t *arg_spec = new(arg_t, .name="to_give", .type=Type(ArrayType, .item_type=item_t));
+ arg_t *arg_spec = new(arg_t, .name="to_give", .type=Type(ArrayType, .item_type=item_t), .next=where_default_end);
return CORD_all("Channel$give_all(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
padded_item_size, ")");
} else if (streq(call->name, "get")) {
CORD self = compile_to_pointer_depth(env, call->self, 0, false);
- (void)compile_arguments(env, ast, NULL, call->args);
- return CORD_all("Channel$get_value(", self, ", ", compile_type(item_t), ", ", padded_item_size, ")");
+ arg_t *arg_spec = where_default_start;
+ return CORD_all("Channel$get_value(", self, ", ", compile_arguments(env, ast, arg_spec, call->args),
+ ", ", compile_type(item_t), ", ", padded_item_size, ")");
} else if (streq(call->name, "peek")) {
CORD self = compile_to_pointer_depth(env, call->self, 0, false);
- (void)compile_arguments(env, ast, NULL, call->args);
- return CORD_all("Channel$peek_value(", self, ", ", compile_type(item_t), ")");
+ arg_t *arg_spec = where_default_start;
+ return CORD_all("Channel$peek_value(", self, ", ", compile_arguments(env, ast, arg_spec, call->args),
+ ", ", compile_type(item_t), ")");
} else if (streq(call->name, "clear")) {
CORD self = compile_to_pointer_depth(env, call->self, 0, false);
(void)compile_arguments(env, ast, NULL, call->args);