MCPcopy
hub / github.com/rollup/rollup / MethodBase

Class MethodBase

src/ast/nodes/shared/MethodBase.ts:31–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29import type { DeclarationPatternNode } from './Pattern';
30
31export default class MethodBase extends NodeBase implements DeoptimizableEntity {
32 declare key: ExpressionNode | PrivateIdentifier;
33 declare kind: 'constructor' | 'method' | 'init' | 'get' | 'set';
34 declare value: ExpressionNode | (ExpressionNode & DeclarationPatternNode);
35
36 get computed(): boolean {
37 return isFlagSet(this.flags, Flag.computed);
38 }
39 set computed(value: boolean) {
40 this.flags = setFlag(this.flags, Flag.computed, value);
41 }
42
43 private accessedValue: [expression: ExpressionEntity, isPure: boolean] | null = null;
44
45 deoptimizeArgumentsOnInteractionAtPath(
46 interaction: NodeInteraction,
47 path: ObjectPath,
48 recursionTracker: EntityPathTracker
49 ): void {
50 if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
51 return this.value.deoptimizeArgumentsOnInteractionAtPath(
52 {
53 args: interaction.args,
54 type: INTERACTION_CALLED,
55 withNew: false
56 },
57 EMPTY_PATH,
58 recursionTracker
59 );
60 }
61 if (interaction.type === INTERACTION_ASSIGNED && this.kind === 'set' && path.length === 0) {
62 return this.value.deoptimizeArgumentsOnInteractionAtPath(
63 {
64 args: interaction.args,
65 type: INTERACTION_CALLED,
66 withNew: false
67 },
68 EMPTY_PATH,
69 recursionTracker
70 );
71 }
72 this.getAccessedValue()[0].deoptimizeArgumentsOnInteractionAtPath(
73 interaction,
74 path,
75 recursionTracker
76 );
77 }
78
79 // As getter properties directly receive their values from fixed function
80 // expressions, there is no known situation where a getter is deoptimized.
81 deoptimizeCache(): void {}
82
83 deoptimizePath(path: ObjectPath): void {
84 this.getAccessedValue()[0].deoptimizePath(path);
85 }
86
87 getLiteralValueAtPath(
88 path: ObjectPath,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…