codegen.c: should not `loop_push()` before constant folding.

Otherwise, the following code will crash:

```ruby
1.times{{}until 1; break}
```
parent 89ea41f1
......@@ -2263,11 +2263,6 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_WHILE:
case NODE_UNTIL:
{
struct loopinfo *lp = loop_push(s, LOOP_NORMAL);
uint32_t pos = JMPLINK_START;
if (!val) lp->reg = -1;
lp->pc0 = new_label(s);
if (true_always(tree->car)) {
if (nt == NODE_UNTIL) {
if (val) {
......@@ -2286,6 +2281,12 @@ codegen(codegen_scope *s, node *tree, int val)
goto exit;
}
}
uint32_t pos = JMPLINK_START;
struct loopinfo *lp = loop_push(s, LOOP_NORMAL);
if (!val) lp->reg = -1;
lp->pc0 = new_label(s);
codegen(s, tree->car, VAL);
pop();
if (nt == NODE_WHILE) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment