diff options
| author | 2022-08-11 07:48:24 +0200 | |
|---|---|---|
| committer | 2022-08-11 07:48:24 +0200 | |
| commit | 86aa2d6ab3a003652159fa37828c27744a2cb45d (patch) | |
| tree | 6695bdf09255c649be5f934a42a455a906817151 | |
| parent | 09ebbe187819f54b514db79c4382c26cda425250 (diff) | |
mcall ty
| -rw-r--r-- | bootstrap/cgen.c | 1 | ||||
| -rw-r--r-- | bootstrap/parse.c | 1 | ||||
| -rw-r--r-- | src/all.hff | 10 | ||||
| -rw-r--r-- | src/main.cff | 2 | ||||
| -rw-r--r-- | src/vec.hff | 2 |
5 files changed, 13 insertions, 3 deletions
diff --git a/bootstrap/cgen.c b/bootstrap/cgen.c index 9053331..9a28829 100644 --- a/bootstrap/cgen.c +++ b/bootstrap/cgen.c @@ -606,7 +606,6 @@ static void defctype(const struct type *ty, void *_); static void genfn(bool externp, const char *cname, struct fn *fn) { liftnested(fn->body); - defctype(fn->retty,NULL); if (!externp) pri("static "); pri("%t %s(", fn->retty, cname); diff --git a/bootstrap/parse.c b/bootstrap/parse.c index daf632d..18aa13b 100644 --- a/bootstrap/parse.c +++ b/bootstrap/parse.c @@ -1233,6 +1233,7 @@ pexpostfix(struct parser *P) { if (met) { ex.t = Emcall; ex.mcall.met = met; + ex.ty = ty->fn.retty; vec_slice_cpy(&ex.mcall.args, &args); } else { ex.call.callee = exprdup(ex); diff --git a/src/all.hff b/src/all.hff index e8298b0..13051c6 100644 --- a/src/all.hff +++ b/src/all.hff @@ -16,6 +16,16 @@ defmacro assert { ] } +defmacro foreach(x, i, a, ...body) [ + { + let $a = a; + for let i = 0; i < $a.#len; ++i { + let x = $a[i]; + { body } + } + } +] + /// Types struct Type; diff --git a/src/main.cff b/src/main.cff index 4315ce1..9280443 100644 --- a/src/main.cff +++ b/src/main.cff @@ -12,7 +12,7 @@ extern fn main(argc int, argv **u8) int { for let i = 1; i < argc; ++i { args->push(argv[i]); } - vec_each(s, i, args, + foreach(s, i, args->compact(), printf("%d: %s\n", i, s); ) } diff --git a/src/vec.hff b/src/vec.hff index fb44196..9099b85 100644 --- a/src/vec.hff +++ b/src/vec.hff @@ -39,7 +39,7 @@ defmacro vec_each(x, i, v, ...body) [ { let $v = v; for let i = 0; i < $v.len; ++i { - let x = v.dat[i]; + let x = $v.dat[i]; { body } } } |