From 5feecff9d93522002c74a1423d138c2aa8bc150d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 3 Sep 2024 03:53:36 -0400 Subject: Deprecate `Where` and change channel API to use a boolean `front` value --- compile.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 5c4cc592..69fa345c 100644 --- a/compile.c +++ b/compile.c @@ -2404,28 +2404,26 @@ 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")); + arg_t *front_default_end = new(arg_t, .name="front", .type=Type(BoolType), .default_val=FakeAST(Bool, false)); + arg_t *front_default_start = new(arg_t, .name="front", .type=Type(BoolType), .default_val=FakeAST(Bool, true)); 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, .next=where_default_end); + arg_t *arg_spec = new(arg_t, .name="item", .type=item_t, .next=front_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), .next=where_default_end); + arg_t *arg_spec = new(arg_t, .name="to_give", .type=Type(ArrayType, .item_type=item_t), .next=front_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); - arg_t *arg_spec = where_default_start; + arg_t *arg_spec = front_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); - arg_t *arg_spec = where_default_start; + arg_t *arg_spec = front_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")) { -- cgit v1.2.3