Skip to content

Commit 4b5b736

Browse files
committed
Feature(compiler): Scope - support continueBlock
1 parent 2b9e868 commit 4b5b736

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/backend/llvm/code-generation/do-statement.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ export class DoStatementGenerator implements NodeGenerateInterface<ts.DoStatemen
1717
ctx.scope.enclosureFunction.llvmFunction.addBasicBlock(next);
1818

1919
ctx.scope.breakBlock = next;
20+
ctx.scope.continueBlock = conditionBlock;
2021

2122
builder.createBr(positiveBlock);
2223
builder.setInsertionPoint(positiveBlock);
2324

2425
passStatement(<any>node.statement, ctx, builder);
2526

27+
ctx.scope.breakBlock = null;
2628
ctx.scope.continueBlock = null;
2729

2830
builder.createBr(conditionBlock);

src/backend/llvm/code-generation/for-statement.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class ForStatementGenerator implements NodeGenerateInterface<ts.ForStatem
4646
}
4747

4848
ctx.scope.breakBlock = next;
49+
ctx.scope.continueBlock = startBlock;
4950

5051
builder.setInsertionPoint(bodyBlock);
5152
passStatement(node.statement, ctx, builder);
@@ -65,6 +66,7 @@ export class ForStatementGenerator implements NodeGenerateInterface<ts.ForStatem
6566
builder.createBr(startBlock);
6667

6768
ctx.scope.breakBlock = null;
69+
ctx.scope.continueBlock = null;
6870

6971
builder.setInsertionPoint(next);
7072
}

src/backend/llvm/scope.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ export class Scope {
2020
public enclosureFunction: EnclosureFunction;
2121
public functions: FunctionsTable = new FunctionsTable();
2222
public variables: VariablesTable = new VariablesTable();
23-
public breakBlock: llvm.BasicBlock|null;
23+
public breakBlock: llvm.BasicBlock|null = null;
24+
public continueBlock: llvm.BasicBlock|null = null;
2425
}

0 commit comments

Comments
 (0)