/
ExecutionContext.ts
51 lines (44 loc) · 1.26 KB
/
ExecutionContext.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
39
40
41
42
43
44
45
46
47
48
49
50
51
import { ExpressionEntity } from './nodes/shared/Expression';
import { PathTracker } from './utils/PathTracker';
import ThisVariable from './variables/ThisVariable';
interface ExecutionContextIgnore {
breaks: boolean;
continues: boolean;
labels: Set<string>;
returnAwaitYield: boolean;
}
export const BREAKFLOW_NONE: false = false;
export const BREAKFLOW_ERROR_RETURN: true = true;
export type BreakFlow = typeof BREAKFLOW_NONE | typeof BREAKFLOW_ERROR_RETURN | Set<string | null>;
export interface InclusionContext {
breakFlow: BreakFlow;
}
export interface HasEffectsContext extends InclusionContext {
accessed: PathTracker;
assigned: PathTracker;
called: PathTracker;
ignore: ExecutionContextIgnore;
instantiated: PathTracker;
replacedVariableInits: Map<ThisVariable, ExpressionEntity>;
}
export function createInclusionContext(): InclusionContext {
return {
breakFlow: BREAKFLOW_NONE
};
}
export function createHasEffectsContext(): HasEffectsContext {
return {
accessed: new PathTracker(),
assigned: new PathTracker(),
breakFlow: BREAKFLOW_NONE,
called: new PathTracker(),
ignore: {
breaks: false,
continues: false,
labels: new Set(),
returnAwaitYield: false
},
instantiated: new PathTracker(),
replacedVariableInits: new Map()
};
}