/
TryStatement.ts
38 lines (34 loc) · 1.2 KB
/
TryStatement.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
37
38
import { ExecutionPathOptions } from '../ExecutionPathOptions';
import BlockStatement from './BlockStatement';
import CatchClause from './CatchClause';
import * as NodeType from './NodeType';
import { INCLUDE_VARIABLES, IncludeChildren, StatementBase } from './shared/Node';
export default class TryStatement extends StatementBase {
block!: BlockStatement;
finalizer!: BlockStatement | null;
handler!: CatchClause | null;
type!: NodeType.tTryStatement;
private directlyIncluded = false;
hasEffects(options: ExecutionPathOptions): boolean {
return (
this.block.body.length > 0 ||
(this.handler !== null && this.handler.hasEffects(options)) ||
(this.finalizer !== null && this.finalizer.hasEffects(options))
);
}
include(includeChildrenRecursively: IncludeChildren) {
if (!this.directlyIncluded || !this.context.tryCatchDeoptimization) {
this.included = true;
this.directlyIncluded = true;
this.block.include(
this.context.tryCatchDeoptimization ? INCLUDE_VARIABLES : includeChildrenRecursively
);
}
if (this.handler !== null) {
this.handler.include(includeChildrenRecursively);
}
if (this.finalizer !== null) {
this.finalizer.include(includeChildrenRecursively);
}
}
}