Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor side effect handling for property interactions (#4522)
* Rename event -> interaction * Refactor MemberExpression assignment logic to prepare for new interactions * Use objects for interactions * Add additional interaction parameters * Pick "this"-argument from interaction * Use interaction for getReturnExpression * Replace dedicated methods with hasEffectsOnInteractionAtPath * Fix accessor handling for loops and updated expressions * Simplify assignment handling * Change assignment to use args property * Simplify ObjectEntity effect handling * Cache remaining interactions that may be cached * Improve coverage
- Loading branch information
1 parent
35e7657
commit c443303
Showing
59 changed files
with
1,147 additions
and
1,058 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import SpreadElement from './nodes/SpreadElement'; | ||
import { ExpressionEntity, UNKNOWN_EXPRESSION } from './nodes/shared/Expression'; | ||
|
||
export const INTERACTION_ACCESSED = 0; | ||
export const INTERACTION_ASSIGNED = 1; | ||
export const INTERACTION_CALLED = 2; | ||
|
||
export interface NodeInteractionAccessed { | ||
thisArg: ExpressionEntity | null; | ||
type: typeof INTERACTION_ACCESSED; | ||
} | ||
|
||
export const NODE_INTERACTION_UNKNOWN_ACCESS: NodeInteractionAccessed = { | ||
thisArg: null, | ||
type: INTERACTION_ACCESSED | ||
}; | ||
|
||
export interface NodeInteractionAssigned { | ||
args: readonly [ExpressionEntity]; | ||
thisArg: ExpressionEntity | null; | ||
type: typeof INTERACTION_ASSIGNED; | ||
} | ||
|
||
export const UNKNOWN_ARG = [UNKNOWN_EXPRESSION] as const; | ||
|
||
export const NODE_INTERACTION_UNKNOWN_ASSIGNMENT: NodeInteractionAssigned = { | ||
args: UNKNOWN_ARG, | ||
thisArg: null, | ||
type: INTERACTION_ASSIGNED | ||
}; | ||
|
||
export interface NodeInteractionCalled { | ||
args: readonly (ExpressionEntity | SpreadElement)[]; | ||
thisArg: ExpressionEntity | null; | ||
type: typeof INTERACTION_CALLED; | ||
withNew: boolean; | ||
} | ||
|
||
export const NO_ARGS = []; | ||
|
||
// While this is technically a call without arguments, we can compare against | ||
// this reference in places where precise values or thisArg would make a | ||
// difference | ||
export const NODE_INTERACTION_UNKNOWN_CALL: NodeInteractionCalled = { | ||
args: NO_ARGS, | ||
thisArg: null, | ||
type: INTERACTION_CALLED, | ||
withNew: false | ||
}; | ||
|
||
export type NodeInteraction = | ||
| NodeInteractionAccessed | ||
| NodeInteractionAssigned | ||
| NodeInteractionCalled; | ||
|
||
export type NodeInteractionWithThisArg = NodeInteraction & { thisArg: ExpressionEntity }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.