Skip to content

Commit

Permalink
Add def foo(@@arg): ...; co-expression syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
nicowilliams committed Mar 22, 2019
1 parent 1dba290 commit 773a93b
Show file tree
Hide file tree
Showing 9 changed files with 2,190 additions and 1,564 deletions.
9 changes: 9 additions & 0 deletions src/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,11 @@ block gen_function(const char* name, block formals, block body) {
if (i->op == CLOSURE_PARAM_REGULAR) {
i->op = CLOSURE_PARAM;
body = gen_var_binding(gen_call(i->symbol, gen_noop()), i->symbol, body);
} else if (i->op == CLOSURE_PARAM_COEXPR) {
i->op = CLOSURE_PARAM;
block coexp = gen_function(i->symbol, gen_noop(), BLOCK(gen_op_unbound(LOADV,i->symbol), gen_call("fhread", gen_noop())));
block_bind_subblock(coexp, body, OP_IS_CALL_PSEUDO | OP_HAS_BINDING, 0);
body = gen_var_binding(gen_call("coexp", gen_lambda(gen_call(i->symbol, gen_noop()))), i->symbol, BLOCK(coexp, body));
}
block_bind_subblock(inst_block(i), body, OP_IS_CALL_PSEUDO | OP_HAS_BINDING, 0);
}
Expand All @@ -581,6 +586,10 @@ block gen_function(const char* name, block formals, block body) {
return b;
}

block gen_param_coexpr(const char* name) {
return gen_op_unbound(CLOSURE_PARAM_COEXPR, name);
}

block gen_param_regular(const char* name) {
return gen_op_unbound(CLOSURE_PARAM_REGULAR, name);
}
Expand Down
1 change: 1 addition & 0 deletions src/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ block gen_import(const char* name, const char *as, int is_data);
block gen_import_meta(block import, block metadata);
block gen_function(const char* name, block formals, block body);
block gen_param_regular(const char* name);
block gen_param_coexpr(const char* name);
block gen_param(const char* name);
block gen_lambda(block body);
block gen_call(const char* name, block body);
Expand Down
Loading

0 comments on commit 773a93b

Please sign in to comment.