-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
DoWhileStatement.ts
36 lines (33 loc) · 1.2 KB
/
DoWhileStatement.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { HasEffectsContext, InclusionContext } from '../ExecutionContext';
import * as NodeType from './NodeType';
import { ExpressionNode, IncludeChildren, StatementBase, StatementNode } from './shared/Node';
export default class DoWhileStatement extends StatementBase {
body!: StatementNode;
test!: ExpressionNode;
type!: NodeType.tDoWhileStatement;
hasEffects(context: HasEffectsContext): boolean {
if (this.test.hasEffects(context)) return true;
const {
breakFlow,
ignore: { breaks, continues }
} = context;
context.ignore.breaks = true;
context.ignore.continues = true;
if (this.body.hasEffects(context)) return true;
context.ignore.breaks = breaks;
context.ignore.continues = continues;
if (context.breakFlow instanceof Set && context.breakFlow.has(null)) {
context.breakFlow = breakFlow;
}
return false;
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren) {
this.included = true;
this.test.include(context, includeChildrenRecursively);
const { breakFlow } = context;
this.body.include(context, includeChildrenRecursively);
if (context.breakFlow instanceof Set && context.breakFlow.has(null)) {
context.breakFlow = breakFlow;
}
}
}