/
ObjectMember.ts
69 lines (61 loc) · 1.98 KB
/
ObjectMember.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { CallOptions } from '../../CallOptions';
import { DeoptimizableEntity } from '../../DeoptimizableEntity';
import { HasEffectsContext } from '../../ExecutionContext';
import { NodeEvent } from '../../NodeEvents';
import { ObjectPath, PathTracker } from '../../utils/PathTracker';
import { ExpressionEntity, LiteralValueOrUnknown } from './Expression';
export class ObjectMember extends ExpressionEntity {
constructor(private readonly object: ExpressionEntity, private readonly key: string) {
super();
}
deoptimizePath(path: ObjectPath): void {
this.object.deoptimizePath([this.key, ...path]);
}
deoptimizeThisOnEventAtPath(
event: NodeEvent,
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
): void {
this.object.deoptimizeThisOnEventAtPath(
event,
[this.key, ...path],
thisParameter,
recursionTracker
);
}
getLiteralValueAtPath(
path: ObjectPath,
recursionTracker: PathTracker,
origin: DeoptimizableEntity
): LiteralValueOrUnknown {
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
}
getReturnExpressionWhenCalledAtPath(
path: ObjectPath,
callOptions: CallOptions,
recursionTracker: PathTracker,
origin: DeoptimizableEntity
): ExpressionEntity {
return this.object.getReturnExpressionWhenCalledAtPath(
[this.key, ...path],
callOptions,
recursionTracker,
origin
);
}
hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
if (path.length === 0) return false;
return this.object.hasEffectsWhenAccessedAtPath([this.key, ...path], context);
}
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
return this.object.hasEffectsWhenAssignedAtPath([this.key, ...path], context);
}
hasEffectsWhenCalledAtPath(
path: ObjectPath,
callOptions: CallOptions,
context: HasEffectsContext
): boolean {
return this.object.hasEffectsWhenCalledAtPath([this.key, ...path], callOptions, context);
}
}