diff options
m--------- | deps/ejit | 0 | ||||
-rw-r--r-- | examples/global-loop.ph (renamed from examples/ok-loop-huge.ph) | 0 | ||||
-rw-r--r-- | examples/local-loop.ph | 12 | ||||
-rw-r--r-- | src/lower.c | 3 |
4 files changed, 15 insertions, 0 deletions
diff --git a/deps/ejit b/deps/ejit -Subproject ba9145b0b7af2a82c62f8dfa28807958af5d0c8 +Subproject 57f6b41047e95374701ee276248f0f861516845 diff --git a/examples/ok-loop-huge.ph b/examples/global-loop.ph index 2381537..2381537 100644 --- a/examples/ok-loop-huge.ph +++ b/examples/global-loop.ph diff --git a/examples/local-loop.ph b/examples/local-loop.ph new file mode 100644 index 0000000..2b7d870 --- /dev/null +++ b/examples/local-loop.ph @@ -0,0 +1,12 @@ +procedure SUM{num[int]} return int +var sum = 0 +var idx = 0 +is + do + sum = sum + idx, + idx = idx + 1 + until idx = num, + return sum +end procedure + +print SUM(1000000001) diff --git a/src/lower.c b/src/lower.c index 7f74a50..f08d5a0 100644 --- a/src/lower.c +++ b/src/lower.c @@ -907,12 +907,15 @@ static struct ejit_reloc branch_if(struct fn *f, struct ast *cond, bool branch) static void lower_until(struct fn *f, struct ast *n) { struct ejit_label l = ejit_label(f->f); + ejit_inc_prio(f->f, 100); /* completely arbitrary */ lower_list(f, until_body(n)); struct ast *cond = until_cond(n); struct ejit_reloc branch = branch_if(f, cond, false); ejit_patch(f->f, branch, l); + ejit_dec_prio(f->f, 100); + n->l = null_loc(); } |