mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-10-26 23:32:02 +03:00
Follow up renaming GeneratorEntry (#2298)
Summary: Release notes: none Follow up to https://github.com/facebook/prepack/pull/2296. Renames some classes and types to the new naming format, rather than BuildNode. Pull Request resolved: https://github.com/facebook/prepack/pull/2298 Differential Revision: D8930893 Pulled By: trueadm fbshipit-source-id: a3b86cfc6670da67222c960818e6c186af05d271
This commit is contained in:
parent
bf0ed59174
commit
19272b5725
@ -521,9 +521,9 @@ export default function(realm: Realm): ObjectValue {
|
|||||||
if (text instanceof AbstractValue && text.kind === "JSON.stringify(...)") {
|
if (text instanceof AbstractValue && text.kind === "JSON.stringify(...)") {
|
||||||
// Enable cloning via JSON.parse(JSON.stringify(...)).
|
// Enable cloning via JSON.parse(JSON.stringify(...)).
|
||||||
// text is abstract, so we are doing abstract interpretation
|
// text is abstract, so we are doing abstract interpretation
|
||||||
let temporalBuildNodeEntryArgs = realm.derivedIds.get(text.intrinsicName);
|
let temporalOperationEntryArgs = realm.derivedIds.get(text.intrinsicName);
|
||||||
invariant(temporalBuildNodeEntryArgs !== undefined);
|
invariant(temporalOperationEntryArgs !== undefined);
|
||||||
let args = temporalBuildNodeEntryArgs.args;
|
let args = temporalOperationEntryArgs.args;
|
||||||
invariant(args[0] instanceof Value); // since text.kind === "JSON.stringify(...)"
|
invariant(args[0] instanceof Value); // since text.kind === "JSON.stringify(...)"
|
||||||
let inputClone = args[0]; // A temporal copy of the object that was the argument to stringify
|
let inputClone = args[0]; // A temporal copy of the object that was the argument to stringify
|
||||||
// Clone it so that every call to parse produces a different instance from stringify's clone
|
// Clone it so that every call to parse produces a different instance from stringify's clone
|
||||||
|
@ -142,12 +142,12 @@ export class ReactEquivalenceSet {
|
|||||||
if (!this.residualReactElementVisitor.wasTemporalAliasDeclaredInCurrentScope(temporalAlias)) {
|
if (!this.residualReactElementVisitor.wasTemporalAliasDeclaredInCurrentScope(temporalAlias)) {
|
||||||
return temporalAlias;
|
return temporalAlias;
|
||||||
}
|
}
|
||||||
let temporalBuildNodeEntry = this.realm.getTemporalBuildNodeEntryFromDerivedValue(temporalAlias);
|
let temporalOperationEntry = this.realm.getTemporalOperationEntryFromDerivedValue(temporalAlias);
|
||||||
|
|
||||||
if (temporalBuildNodeEntry === undefined) {
|
if (temporalOperationEntry === undefined) {
|
||||||
return temporalAlias;
|
return temporalAlias;
|
||||||
}
|
}
|
||||||
let temporalArgs = temporalBuildNodeEntry.args;
|
let temporalArgs = temporalOperationEntry.args;
|
||||||
if (temporalArgs.length === 0) {
|
if (temporalArgs.length === 0) {
|
||||||
return temporalAlias;
|
return temporalAlias;
|
||||||
}
|
}
|
||||||
@ -168,9 +168,9 @@ export class ReactEquivalenceSet {
|
|||||||
}
|
}
|
||||||
} else if (arg instanceof AbstractObjectValue && !arg.values.isTop() && arg.kind !== "conditional") {
|
} else if (arg instanceof AbstractObjectValue && !arg.values.isTop() && arg.kind !== "conditional") {
|
||||||
// Might be a temporal, so let's check
|
// Might be a temporal, so let's check
|
||||||
let childTemporalBuildNodeEntry = this.realm.getTemporalBuildNodeEntryFromDerivedValue(arg);
|
let childTemporalOperationEntry = this.realm.getTemporalOperationEntryFromDerivedValue(arg);
|
||||||
|
|
||||||
if (childTemporalBuildNodeEntry !== undefined) {
|
if (childTemporalOperationEntry !== undefined) {
|
||||||
equivalenceArg = this._getTemporalValue(arg, visitedValues);
|
equivalenceArg = this._getTemporalValue(arg, visitedValues);
|
||||||
invariant(equivalenceArg instanceof AbstractObjectValue);
|
invariant(equivalenceArg instanceof AbstractObjectValue);
|
||||||
|
|
||||||
|
@ -948,12 +948,12 @@ function applyClonedTemporalAlias(realm: Realm, props: ObjectValue, clonedProps:
|
|||||||
// be a better option.
|
// be a better option.
|
||||||
invariant(false, "TODO applyClonedTemporalAlias conditional");
|
invariant(false, "TODO applyClonedTemporalAlias conditional");
|
||||||
}
|
}
|
||||||
let temporalBuildNodeEntry = realm.getTemporalBuildNodeEntryFromDerivedValue(temporalAlias);
|
let temporalOperationEntry = realm.getTemporalOperationEntryFromDerivedValue(temporalAlias);
|
||||||
if (!(temporalBuildNodeEntry instanceof TemporalObjectAssignEntry)) {
|
if (!(temporalOperationEntry instanceof TemporalObjectAssignEntry)) {
|
||||||
invariant(false, "TODO nont TemporalObjectAssignEntry");
|
invariant(false, "TODO nont TemporalObjectAssignEntry");
|
||||||
}
|
}
|
||||||
invariant(temporalBuildNodeEntry !== undefined);
|
invariant(temporalOperationEntry !== undefined);
|
||||||
let temporalArgs = temporalBuildNodeEntry.args;
|
let temporalArgs = temporalOperationEntry.args;
|
||||||
// replace the original props with the cloned one
|
// replace the original props with the cloned one
|
||||||
let [to, ...sources] = temporalArgs.map(arg => (arg === props ? clonedProps : arg));
|
let [to, ...sources] = temporalArgs.map(arg => (arg === props ? clonedProps : arg));
|
||||||
|
|
||||||
|
20
src/realm.js
20
src/realm.js
@ -68,7 +68,7 @@ import {
|
|||||||
createOperationDescriptor,
|
createOperationDescriptor,
|
||||||
Generator,
|
Generator,
|
||||||
PreludeGenerator,
|
PreludeGenerator,
|
||||||
type TemporalBuildNodeEntry,
|
type TemporalOperationEntry,
|
||||||
} from "./utils/generator.js";
|
} from "./utils/generator.js";
|
||||||
import { Environment, Functions, Join, Properties, To, Widen, Path } from "./singletons.js";
|
import { Environment, Functions, Join, Properties, To, Widen, Path } from "./singletons.js";
|
||||||
import type { ReactSymbolTypes } from "./react/utils.js";
|
import type { ReactSymbolTypes } from "./react/utils.js";
|
||||||
@ -382,8 +382,8 @@ export class Realm {
|
|||||||
$GlobalEnv: LexicalEnvironment;
|
$GlobalEnv: LexicalEnvironment;
|
||||||
intrinsics: Intrinsics;
|
intrinsics: Intrinsics;
|
||||||
|
|
||||||
derivedIds: Map<string, TemporalBuildNodeEntry>;
|
derivedIds: Map<string, TemporalOperationEntry>;
|
||||||
temporalEntryArgToEntries: Map<Value, Set<TemporalBuildNodeEntry>>;
|
temporalEntryArgToEntries: Map<Value, Set<TemporalOperationEntry>>;
|
||||||
temporalEntryCounter: number;
|
temporalEntryCounter: number;
|
||||||
|
|
||||||
instantRender: {
|
instantRender: {
|
||||||
@ -1816,21 +1816,21 @@ export class Realm {
|
|||||||
return !this._abstractValuesDefined.has(nameString);
|
return !this._abstractValuesDefined.has(nameString);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemporalBuildNodeEntryFromDerivedValue(value: Value): void | TemporalBuildNodeEntry {
|
getTemporalOperationEntryFromDerivedValue(value: Value): void | TemporalOperationEntry {
|
||||||
let name = value.intrinsicName;
|
let name = value.intrinsicName;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let temporalBuildNodeEntry = value.$Realm.derivedIds.get(name);
|
let temporalOperationEntry = value.$Realm.derivedIds.get(name);
|
||||||
return temporalBuildNodeEntry;
|
return temporalOperationEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemporalGeneratorEntriesReferencingArg(arg: AbstractValue | ObjectValue): void | Set<TemporalBuildNodeEntry> {
|
getTemporalGeneratorEntriesReferencingArg(arg: AbstractValue | ObjectValue): void | Set<TemporalOperationEntry> {
|
||||||
return this.temporalEntryArgToEntries.get(arg);
|
return this.temporalEntryArgToEntries.get(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveTemporalGeneratorEntryArgs(temporalBuildNodeEntry: TemporalBuildNodeEntry): void {
|
saveTemporalGeneratorEntryArgs(temporalOperationEntry: TemporalOperationEntry): void {
|
||||||
let args = temporalBuildNodeEntry.args;
|
let args = temporalOperationEntry.args;
|
||||||
for (let arg of args) {
|
for (let arg of args) {
|
||||||
let temporalEntries = this.temporalEntryArgToEntries.get(arg);
|
let temporalEntries = this.temporalEntryArgToEntries.get(arg);
|
||||||
|
|
||||||
@ -1838,7 +1838,7 @@ export class Realm {
|
|||||||
temporalEntries = new Set();
|
temporalEntries = new Set();
|
||||||
this.temporalEntryArgToEntries.set(arg, temporalEntries);
|
this.temporalEntryArgToEntries.set(arg, temporalEntries);
|
||||||
}
|
}
|
||||||
temporalEntries.add(temporalBuildNodeEntry);
|
temporalEntries.add(temporalOperationEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
} from "../values/index.js";
|
} from "../values/index.js";
|
||||||
import type { BabelNodeStatement } from "@babel/types";
|
import type { BabelNodeStatement } from "@babel/types";
|
||||||
import type { SerializedBody } from "./types.js";
|
import type { SerializedBody } from "./types.js";
|
||||||
import { Generator, type TemporalBuildNodeEntry } from "../utils/generator.js";
|
import { Generator, type TemporalOperationEntry } from "../utils/generator.js";
|
||||||
import invariant from "../invariant.js";
|
import invariant from "../invariant.js";
|
||||||
import { BodyReference } from "./types.js";
|
import { BodyReference } from "./types.js";
|
||||||
import { ResidualFunctions } from "./ResidualFunctions.js";
|
import { ResidualFunctions } from "./ResidualFunctions.js";
|
||||||
@ -67,7 +67,7 @@ export class Emitter {
|
|||||||
residualFunctions: ResidualFunctions,
|
residualFunctions: ResidualFunctions,
|
||||||
referencedDeclaredValues: Map<Value, void | FunctionValue>,
|
referencedDeclaredValues: Map<Value, void | FunctionValue>,
|
||||||
conditionalFeasibility: Map<AbstractValue, { t: boolean, f: boolean }>,
|
conditionalFeasibility: Map<AbstractValue, { t: boolean, f: boolean }>,
|
||||||
derivedIds: Map<string, TemporalBuildNodeEntry>
|
derivedIds: Map<string, TemporalOperationEntry>
|
||||||
) {
|
) {
|
||||||
this._mainBody = { type: "MainGenerator", parentBody: undefined, entries: [], done: false };
|
this._mainBody = { type: "MainGenerator", parentBody: undefined, entries: [], done: false };
|
||||||
this._waitingForValues = new Map();
|
this._waitingForValues = new Map();
|
||||||
|
@ -29,7 +29,7 @@ import {
|
|||||||
hardModifyReactObjectPropertyBinding,
|
hardModifyReactObjectPropertyBinding,
|
||||||
} from "../react/utils.js";
|
} from "../react/utils.js";
|
||||||
import invariant from "../invariant.js";
|
import invariant from "../invariant.js";
|
||||||
import { TemporalBuildNodeEntry } from "../utils/generator.js";
|
import { TemporalOperationEntry } from "../utils/generator.js";
|
||||||
import { ReactEquivalenceSet } from "../react/ReactEquivalenceSet.js";
|
import { ReactEquivalenceSet } from "../react/ReactEquivalenceSet.js";
|
||||||
import { ReactElementSet } from "../react/ReactElementSet.js";
|
import { ReactElementSet } from "../react/ReactElementSet.js";
|
||||||
import { ReactPropsSet } from "../react/ReactPropsSet.js";
|
import { ReactPropsSet } from "../react/ReactPropsSet.js";
|
||||||
@ -165,7 +165,7 @@ export class ResidualReactElementVisitor {
|
|||||||
// temporal value was declared in one of the entries
|
// temporal value was declared in one of the entries
|
||||||
for (let i = 0; i < scope._entries.length; i++) {
|
for (let i = 0; i < scope._entries.length; i++) {
|
||||||
let entry = scope._entries[i];
|
let entry = scope._entries[i];
|
||||||
if (entry instanceof TemporalBuildNodeEntry) {
|
if (entry instanceof TemporalOperationEntry) {
|
||||||
if (entry.declared === temporalAlias) {
|
if (entry.declared === temporalAlias) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -58,99 +58,93 @@ import type {
|
|||||||
import { memberExpressionHelper } from "./babelhelpers.js";
|
import { memberExpressionHelper } from "./babelhelpers.js";
|
||||||
import { concretize, Utils } from "../singletons.js";
|
import { concretize, Utils } from "../singletons.js";
|
||||||
import type { SerializerOptions } from "../options.js";
|
import type { SerializerOptions } from "../options.js";
|
||||||
|
import type { ShapeInformationInterface } from "../types.js";
|
||||||
import * as t from "@babel/types";
|
import * as t from "@babel/types";
|
||||||
|
|
||||||
export type OperationDescriptorType =
|
export type OperationDescriptorType =
|
||||||
| "IDENTIFIER"
|
|
||||||
| "SINGLE_ARG"
|
|
||||||
| "REBUILT_OBJECT"
|
|
||||||
| "CONSOLE_LOG"
|
|
||||||
| "FOR_IN"
|
|
||||||
| "DO_WHILE"
|
|
||||||
| "CONCRETE_MODEL"
|
|
||||||
| "BINARY_EXPRESSION"
|
|
||||||
| "LOGICAL_EXPRESSION"
|
|
||||||
| "CONDITIONAL_EXPRESSION"
|
|
||||||
| "UNARY_EXPRESSION"
|
|
||||||
| "ABSTRACT_FROM_TEMPLATE"
|
| "ABSTRACT_FROM_TEMPLATE"
|
||||||
| "GLOBAL_ASSIGNMENT"
|
| "ABSTRACT_OBJECT_GET"
|
||||||
| "GLOBAL_DELETE"
|
|
||||||
| "EMIT_PROPERTY_ASSIGNMENT"
|
|
||||||
| "ABSTRACT_PROPERTY"
|
|
||||||
| "JOIN_GENERATORS"
|
|
||||||
| "APPEND_GENERATOR"
|
|
||||||
| "DEFINE_PROPERTY"
|
|
||||||
| "PROPERTY_DELETE"
|
|
||||||
| "THROW"
|
|
||||||
| "CONDITIONAL_THROW"
|
|
||||||
| "COERCE_TO_STRING"
|
|
||||||
| "ABSTRACT_FROM_TEMPLATE"
|
|
||||||
| "FOR_STATEMENT_FUNC"
|
|
||||||
| "NEW_EXPRESSION"
|
|
||||||
| "OBJECT_ASSIGN"
|
|
||||||
| "OBJECT_SET_PARTIAL"
|
|
||||||
| "OBJECT_GET_PARTIAL"
|
|
||||||
| "OBJECT_PROTO_HAS_OWN_PROPERTY"
|
|
||||||
| "OBJECT_PROTO_GET_OWN_PROPERTY_DESCRIPTOR"
|
|
||||||
| "ABSTRACT_OBJECT_SET_PARTIAL"
|
|
||||||
| "ABSTRACT_OBJECT_SET_PARTIAL_VALUE"
|
|
||||||
| "ABSTRACT_OBJECT_GET_PARTIAL"
|
| "ABSTRACT_OBJECT_GET_PARTIAL"
|
||||||
| "ABSTRACT_OBJECT_GET_PROTO_OF"
|
| "ABSTRACT_OBJECT_GET_PROTO_OF"
|
||||||
| "ABSTRACT_OBJECT_GET"
|
| "ABSTRACT_OBJECT_SET_PARTIAL"
|
||||||
| "DIRECT_CALL_WITH_ARG_LIST"
|
| "ABSTRACT_OBJECT_SET_PARTIAL_VALUE"
|
||||||
|
| "ABSTRACT_PROPERTY"
|
||||||
|
| "APPEND_GENERATOR"
|
||||||
|
| "ASSUME_CALL"
|
||||||
|
| "BABEL_HELPERS_OBJECT_WITHOUT_PROPERTIES"
|
||||||
|
| "BINARY_EXPRESSION"
|
||||||
| "CALL_ABSTRACT_FUNC"
|
| "CALL_ABSTRACT_FUNC"
|
||||||
| "CALL_ABSTRACT_FUNC_THIS"
|
| "CALL_ABSTRACT_FUNC_THIS"
|
||||||
| "CALL_BAILOUT"
|
| "CALL_BAILOUT"
|
||||||
|
| "CANNOT_BECOME_OBJECT"
|
||||||
|
| "COERCE_TO_STRING"
|
||||||
|
| "CONCRETE_MODEL"
|
||||||
|
| "CONDITIONAL_EXPRESSION"
|
||||||
|
| "CONDITIONAL_PROPERTY_ASSIGNMENT"
|
||||||
|
| "CONDITIONAL_THROW"
|
||||||
|
| "CONSOLE_LOG"
|
||||||
|
| "DEFINE_PROPERTY"
|
||||||
|
| "DERIVED_ABSTRACT_INVARIANT"
|
||||||
|
| "DIRECT_CALL_WITH_ARG_LIST"
|
||||||
|
| "DO_WHILE"
|
||||||
| "EMIT_CALL"
|
| "EMIT_CALL"
|
||||||
| "EMIT_CALL_AND_CAPTURE_RESULT"
|
| "EMIT_CALL_AND_CAPTURE_RESULT"
|
||||||
|
| "EMIT_PROPERTY_ASSIGNMENT"
|
||||||
|
| "FB_MOCKS_BOOTLOADER_LOAD_MODULES"
|
||||||
|
| "FB_MOCKS_MAGIC_GLOBAL_FUNCTION"
|
||||||
|
| "FOR_IN"
|
||||||
|
| "FOR_STATEMENT_FUNC"
|
||||||
|
| "FULL_INVARIANT"
|
||||||
|
| "FULL_INVARIANT_ABSTRACT"
|
||||||
|
| "FULL_INVARIANT_FUNCTION"
|
||||||
| "GET_BINDING"
|
| "GET_BINDING"
|
||||||
| "LOCAL_ASSIGNMENT"
|
| "GLOBAL_ASSIGNMENT"
|
||||||
| "LOGICAL_PROPERTY_ASSIGNMENT"
|
| "GLOBAL_DELETE"
|
||||||
| "CONDITIONAL_PROPERTY_ASSIGNMENT"
|
| "IDENTIFIER"
|
||||||
| "PROPERTY_ASSIGNMENT"
|
|
||||||
| "MODULES_REQUIRE"
|
|
||||||
| "RESIDUAL_CALL"
|
|
||||||
| "ASSUME_CALL"
|
|
||||||
| "CANNOT_BECOME_OBJECT"
|
|
||||||
| "UPDATE_INCREMENTOR"
|
|
||||||
| "WIDENED_IDENTIFIER"
|
|
||||||
| "WIDEN_PROPERTY"
|
|
||||||
| "WIDEN_ABSTRACT_PROPERTY"
|
|
||||||
| "WIDEN_PROPERTY_ASSIGNMENT"
|
|
||||||
| "WIDEN_ABSTRACT_PROPERTY_ASSIGNMENT"
|
|
||||||
| "INVARIANT"
|
| "INVARIANT"
|
||||||
| "INVARIANT_APPEND"
|
| "INVARIANT_APPEND"
|
||||||
| "DERIVED_ABSTRACT_INVARIANT"
|
| "JOIN_GENERATORS"
|
||||||
|
| "LOCAL_ASSIGNMENT"
|
||||||
|
| "LOGICAL_EXPRESSION"
|
||||||
|
| "LOGICAL_PROPERTY_ASSIGNMENT"
|
||||||
|
| "MODULES_REQUIRE"
|
||||||
|
| "NEW_EXPRESSION"
|
||||||
|
| "OBJECT_ASSIGN"
|
||||||
|
| "OBJECT_GET_PARTIAL"
|
||||||
|
| "OBJECT_PROTO_GET_OWN_PROPERTY_DESCRIPTOR"
|
||||||
|
| "OBJECT_PROTO_HAS_OWN_PROPERTY"
|
||||||
|
| "OBJECT_SET_PARTIAL"
|
||||||
|
| "PROPERTY_ASSIGNMENT"
|
||||||
|
| "PROPERTY_DELETE"
|
||||||
| "PROPERTY_INVARIANT"
|
| "PROPERTY_INVARIANT"
|
||||||
| "FULL_INVARIANT"
|
|
||||||
| "FULL_INVARIANT_FUNCTION"
|
|
||||||
| "FULL_INVARIANT_ABSTRACT"
|
|
||||||
| "UNKNOWN_ARRAY_METHOD_CALL"
|
|
||||||
| "UNKNOWN_ARRAY_METHOD_PROPERTY_CALL"
|
|
||||||
| "UNKNOWN_ARRAY_LENGTH"
|
|
||||||
| "UNKNOWN_ARRAY_GET_PARTIAL"
|
|
||||||
| "BABEL_HELPERS_OBJECT_WITHOUT_PROPERTIES"
|
|
||||||
| "REACT_DEFAULT_PROPS_HELPER"
|
|
||||||
| "REACT_TEMPORAL_FUNC"
|
|
||||||
| "REACT_CREATE_CONTEXT_PROVIDER"
|
| "REACT_CREATE_CONTEXT_PROVIDER"
|
||||||
| "REACT_SSR_REGEX_CONSTANT"
|
| "REACT_DEFAULT_PROPS_HELPER"
|
||||||
| "REACT_SSR_PREV_TEXT_NODE"
|
|
||||||
| "REACT_SSR_RENDER_VALUE_HELPER"
|
|
||||||
| "REACT_SSR_TEMPLATE_LITERAL"
|
|
||||||
| "REACT_NATIVE_STRING_LITERAL"
|
| "REACT_NATIVE_STRING_LITERAL"
|
||||||
| "REACT_RELAY_MOCK_CONTAINER"
|
| "REACT_RELAY_MOCK_CONTAINER"
|
||||||
| "FB_MOCKS_BOOTLOADER_LOAD_MODULES"
|
| "REACT_SSR_PREV_TEXT_NODE"
|
||||||
| "FB_MOCKS_MAGIC_GLOBAL_FUNCTION";
|
| "REACT_SSR_REGEX_CONSTANT"
|
||||||
|
| "REACT_SSR_RENDER_VALUE_HELPER"
|
||||||
export type DerivedExpressionBuildNodeFunction = (
|
| "REACT_SSR_TEMPLATE_LITERAL"
|
||||||
Array<BabelNodeExpression>,
|
| "REACT_TEMPORAL_FUNC"
|
||||||
SerializationContext,
|
| "REBUILT_OBJECT"
|
||||||
Set<AbstractValue | ObjectValue>
|
| "RESIDUAL_CALL"
|
||||||
) => BabelNodeExpression;
|
| "SINGLE_ARG"
|
||||||
|
| "THROW"
|
||||||
|
| "UNARY_EXPRESSION"
|
||||||
|
| "UNKNOWN_ARRAY_GET_PARTIAL"
|
||||||
|
| "UNKNOWN_ARRAY_LENGTH"
|
||||||
|
| "UNKNOWN_ARRAY_METHOD_CALL"
|
||||||
|
| "UNKNOWN_ARRAY_METHOD_PROPERTY_CALL"
|
||||||
|
| "UPDATE_INCREMENTOR"
|
||||||
|
| "WIDEN_ABSTRACT_PROPERTY"
|
||||||
|
| "WIDEN_ABSTRACT_PROPERTY_ASSIGNMENT"
|
||||||
|
| "WIDEN_PROPERTY"
|
||||||
|
| "WIDEN_PROPERTY_ASSIGNMENT"
|
||||||
|
| "WIDENED_IDENTIFIER";
|
||||||
|
|
||||||
export type OperationDescriptor = {
|
export type OperationDescriptor = {
|
||||||
data: OperationDescriptorData,
|
data: OperationDescriptorData,
|
||||||
kind: void | ResidualBuildKind,
|
kind: void | OperationDescriptorKind,
|
||||||
type: OperationDescriptorType,
|
type: OperationDescriptorType,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -185,12 +179,12 @@ export type OperationDescriptorData = {
|
|||||||
violationConditionOperationDescriptor?: OperationDescriptor,
|
violationConditionOperationDescriptor?: OperationDescriptor,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResidualBuildKind = "DERIVED" | "VOID";
|
export type OperationDescriptorKind = "DERIVED" | "VOID";
|
||||||
|
|
||||||
export function createOperationDescriptor(
|
export function createOperationDescriptor(
|
||||||
type: OperationDescriptorType,
|
type: OperationDescriptorType,
|
||||||
data?: OperationDescriptorData = {},
|
data?: OperationDescriptorData = {},
|
||||||
kind?: ResidualBuildKind
|
kind?: OperationDescriptorKind
|
||||||
): OperationDescriptor {
|
): OperationDescriptor {
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
@ -199,8 +193,6 @@ export function createOperationDescriptor(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
import type { ShapeInformationInterface } from "../types.js";
|
|
||||||
|
|
||||||
export type SerializationContext = {|
|
export type SerializationContext = {|
|
||||||
serializeOperationDescriptor: (
|
serializeOperationDescriptor: (
|
||||||
OperationDescriptor,
|
OperationDescriptor,
|
||||||
@ -242,10 +234,10 @@ export type VisitEntryCallbacks = {|
|
|||||||
|
|
||||||
export class GeneratorEntry {
|
export class GeneratorEntry {
|
||||||
constructor(realm: Realm) {
|
constructor(realm: Realm) {
|
||||||
// We increment the index of every TemporalBuildNodeEntry created.
|
// We increment the index of every TemporalOperationEntry created.
|
||||||
// This should match up as a form of timeline value due to the tree-like
|
// This should match up as a form of timeline value due to the tree-like
|
||||||
// structure we use to create entries during evaluation. For example,
|
// structure we use to create entries during evaluation. For example,
|
||||||
// if all AST nodes in a BlockStatement resulted in a temporal build node
|
// if all AST nodes in a BlockStatement resulted in a temporal operation
|
||||||
// for each AST node, then each would have a sequential index as to its
|
// for each AST node, then each would have a sequential index as to its
|
||||||
// position of how it was evaluated in the BlockSstatement.
|
// position of how it was evaluated in the BlockSstatement.
|
||||||
this.index = realm.temporalEntryCounter++;
|
this.index = realm.temporalEntryCounter++;
|
||||||
@ -274,7 +266,7 @@ export class GeneratorEntry {
|
|||||||
index: number;
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TemporalBuildNodeEntryArgs = {
|
export type TemporalOperationEntryArgs = {
|
||||||
declared?: AbstractValue | ObjectValue,
|
declared?: AbstractValue | ObjectValue,
|
||||||
args: Array<Value>,
|
args: Array<Value>,
|
||||||
// If we're just trying to add roots for the serializer to notice, we don't need an operationDescriptor.
|
// If we're just trying to add roots for the serializer to notice, we don't need an operationDescriptor.
|
||||||
@ -284,8 +276,8 @@ export type TemporalBuildNodeEntryArgs = {
|
|||||||
mutatesOnly?: Array<Value>,
|
mutatesOnly?: Array<Value>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class TemporalBuildNodeEntry extends GeneratorEntry {
|
export class TemporalOperationEntry extends GeneratorEntry {
|
||||||
constructor(realm: Realm, args: TemporalBuildNodeEntryArgs) {
|
constructor(realm: Realm, args: TemporalOperationEntryArgs) {
|
||||||
super(realm);
|
super(realm);
|
||||||
Object.assign(this, args);
|
Object.assign(this, args);
|
||||||
if (this.mutatesOnly !== undefined) {
|
if (this.mutatesOnly !== undefined) {
|
||||||
@ -305,8 +297,8 @@ export class TemporalBuildNodeEntry extends GeneratorEntry {
|
|||||||
mutatesOnly: void | Array<Value>;
|
mutatesOnly: void | Array<Value>;
|
||||||
|
|
||||||
toDisplayJson(depth: number): DisplayResult {
|
toDisplayJson(depth: number): DisplayResult {
|
||||||
if (depth <= 0) return `TemporalBuildNode${this.index}`;
|
if (depth <= 0) return `TemporalOperation${this.index}`;
|
||||||
let obj = { type: "TemporalBuildNode", ...this };
|
let obj = { type: "TemporalOperation", ...this };
|
||||||
delete obj.operationDescriptor;
|
delete obj.operationDescriptor;
|
||||||
return Utils.verboseToDisplayJson(obj, depth);
|
return Utils.verboseToDisplayJson(obj, depth);
|
||||||
}
|
}
|
||||||
@ -376,7 +368,7 @@ export class TemporalBuildNodeEntry extends GeneratorEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TemporalObjectAssignEntry extends TemporalBuildNodeEntry {
|
export class TemporalObjectAssignEntry extends TemporalOperationEntry {
|
||||||
visit(callbacks: VisitEntryCallbacks, containingGenerator: Generator): boolean {
|
visit(callbacks: VisitEntryCallbacks, containingGenerator: Generator): boolean {
|
||||||
let declared = this.declared;
|
let declared = this.declared;
|
||||||
if (!(declared instanceof AbstractObjectValue || declared instanceof ObjectValue)) {
|
if (!(declared instanceof AbstractObjectValue || declared instanceof ObjectValue)) {
|
||||||
@ -1141,20 +1133,20 @@ export class Generator {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
_addEntry(entryArgs: TemporalBuildNodeEntryArgs): TemporalBuildNodeEntry {
|
_addEntry(entryArgs: TemporalOperationEntryArgs): TemporalOperationEntry {
|
||||||
let entry;
|
let entry;
|
||||||
let operationDescriptor = entryArgs.operationDescriptor;
|
let operationDescriptor = entryArgs.operationDescriptor;
|
||||||
if (operationDescriptor && operationDescriptor.type === "OBJECT_ASSIGN") {
|
if (operationDescriptor && operationDescriptor.type === "OBJECT_ASSIGN") {
|
||||||
entry = new TemporalObjectAssignEntry(this.realm, entryArgs);
|
entry = new TemporalObjectAssignEntry(this.realm, entryArgs);
|
||||||
} else {
|
} else {
|
||||||
entry = new TemporalBuildNodeEntry(this.realm, entryArgs);
|
entry = new TemporalOperationEntry(this.realm, entryArgs);
|
||||||
}
|
}
|
||||||
this.realm.saveTemporalGeneratorEntryArgs(entry);
|
this.realm.saveTemporalGeneratorEntryArgs(entry);
|
||||||
this._entries.push(entry);
|
this._entries.push(entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
_addDerivedEntry(id: string, entryArgs: TemporalBuildNodeEntryArgs): void {
|
_addDerivedEntry(id: string, entryArgs: TemporalOperationEntryArgs): void {
|
||||||
let entry = this._addEntry(entryArgs);
|
let entry = this._addEntry(entryArgs);
|
||||||
this.realm.derivedIds.set(id, entry);
|
this.realm.derivedIds.set(id, entry);
|
||||||
}
|
}
|
||||||
@ -1317,7 +1309,7 @@ export class PreludeGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type TemporalBuildNodeEntryOptimizationStatus = "NO_OPTIMIZATION" | "POSSIBLE_OPTIMIZATION";
|
type TemporalOperationEntryOptimizationStatus = "NO_OPTIMIZATION" | "POSSIBLE_OPTIMIZATION";
|
||||||
|
|
||||||
// This function attempts to optimize Object.assign calls, by merging mulitple
|
// This function attempts to optimize Object.assign calls, by merging mulitple
|
||||||
// calls into one another where possible. For example:
|
// calls into one another where possible. For example:
|
||||||
@ -1331,9 +1323,9 @@ type TemporalBuildNodeEntryOptimizationStatus = "NO_OPTIMIZATION" | "POSSIBLE_OP
|
|||||||
export function attemptToMergeEquivalentObjectAssigns(
|
export function attemptToMergeEquivalentObjectAssigns(
|
||||||
realm: Realm,
|
realm: Realm,
|
||||||
callbacks: VisitEntryCallbacks,
|
callbacks: VisitEntryCallbacks,
|
||||||
temporalBuildNodeEntry: TemporalBuildNodeEntry
|
temporalOperationEntry: TemporalOperationEntry
|
||||||
): TemporalBuildNodeEntryOptimizationStatus | TemporalObjectAssignEntry {
|
): TemporalOperationEntryOptimizationStatus | TemporalObjectAssignEntry {
|
||||||
let args = temporalBuildNodeEntry.args;
|
let args = temporalOperationEntry.args;
|
||||||
// If we are Object.assigning 2 or more args
|
// If we are Object.assigning 2 or more args
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
return "NO_OPTIMIZATION";
|
return "NO_OPTIMIZATION";
|
||||||
@ -1353,11 +1345,11 @@ export function attemptToMergeEquivalentObjectAssigns(
|
|||||||
// Check if the "to" was definitely an Object.assign, it should
|
// Check if the "to" was definitely an Object.assign, it should
|
||||||
// be a snapshot AbstractObjectValue
|
// be a snapshot AbstractObjectValue
|
||||||
if (possibleOtherObjectAssignTo instanceof AbstractObjectValue) {
|
if (possibleOtherObjectAssignTo instanceof AbstractObjectValue) {
|
||||||
let otherTemporalBuildNodeEntry = realm.getTemporalBuildNodeEntryFromDerivedValue(possibleOtherObjectAssignTo);
|
let otherTemporalOperationEntry = realm.getTemporalOperationEntryFromDerivedValue(possibleOtherObjectAssignTo);
|
||||||
if (!(otherTemporalBuildNodeEntry instanceof TemporalObjectAssignEntry)) {
|
if (!(otherTemporalOperationEntry instanceof TemporalObjectAssignEntry)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let otherArgs = otherTemporalBuildNodeEntry.args;
|
let otherArgs = otherTemporalOperationEntry.args;
|
||||||
// Object.assign has at least 1 arg
|
// Object.assign has at least 1 arg
|
||||||
if (otherArgs.length < 1) {
|
if (otherArgs.length < 1) {
|
||||||
continue;
|
continue;
|
||||||
@ -1389,8 +1381,8 @@ export function attemptToMergeEquivalentObjectAssigns(
|
|||||||
// because another generator entry may have a dependency on the Object.assign
|
// because another generator entry may have a dependency on the Object.assign
|
||||||
// TemporalObjectAssignEntry we're trying to merge.
|
// TemporalObjectAssignEntry we're trying to merge.
|
||||||
if (
|
if (
|
||||||
temporalGeneratorEntry.notEqualToAndDoesNotHappenBefore(otherTemporalBuildNodeEntry) &&
|
temporalGeneratorEntry.notEqualToAndDoesNotHappenBefore(otherTemporalOperationEntry) &&
|
||||||
temporalGeneratorEntry.notEqualToAndDoesNotHappenAfter(temporalBuildNodeEntry)
|
temporalGeneratorEntry.notEqualToAndDoesNotHappenAfter(temporalOperationEntry)
|
||||||
) {
|
) {
|
||||||
continue loopThroughArgs;
|
continue loopThroughArgs;
|
||||||
}
|
}
|
||||||
@ -1414,7 +1406,7 @@ export function attemptToMergeEquivalentObjectAssigns(
|
|||||||
// been merged into a single entry. The previous Object.assign TemporalObjectAssignEntry
|
// been merged into a single entry. The previous Object.assign TemporalObjectAssignEntry
|
||||||
// should dead-code eliminate away once we replace the original TemporalObjectAssignEntry
|
// should dead-code eliminate away once we replace the original TemporalObjectAssignEntry
|
||||||
// we started with with the new merged on as they will no longer be referenced.
|
// we started with with the new merged on as they will no longer be referenced.
|
||||||
let newTemporalObjectAssignEntryArgs = Object.assign({}, temporalBuildNodeEntry, {
|
let newTemporalObjectAssignEntryArgs = Object.assign({}, temporalOperationEntry, {
|
||||||
args: newArgs,
|
args: newArgs,
|
||||||
});
|
});
|
||||||
return new TemporalObjectAssignEntry(realm, newTemporalObjectAssignEntryArgs);
|
return new TemporalObjectAssignEntry(realm, newTemporalObjectAssignEntryArgs);
|
||||||
|
@ -128,10 +128,6 @@ export default class AbstractValue extends Value {
|
|||||||
addSourceLocationsTo(locations: Array<BabelNodeSourceLocation>, seenValues?: Set<AbstractValue> = new Set()): void {
|
addSourceLocationsTo(locations: Array<BabelNodeSourceLocation>, seenValues?: Set<AbstractValue> = new Set()): void {
|
||||||
if (seenValues.has(this)) return;
|
if (seenValues.has(this)) return;
|
||||||
seenValues.add(this);
|
seenValues.add(this);
|
||||||
// TODO: make this work again?
|
|
||||||
// if (this._buildNode && !(this._buildNode instanceof Function)) {
|
|
||||||
// if (this._buildNode.loc) locations.push(this._buildNode.loc);
|
|
||||||
// }
|
|
||||||
for (let val of this.args) {
|
for (let val of this.args) {
|
||||||
if (val instanceof AbstractValue) val.addSourceLocationsTo(locations, seenValues);
|
if (val instanceof AbstractValue) val.addSourceLocationsTo(locations, seenValues);
|
||||||
}
|
}
|
||||||
@ -143,9 +139,9 @@ export default class AbstractValue extends Value {
|
|||||||
let realm = this.$Realm;
|
let realm = this.$Realm;
|
||||||
function add_intrinsic(name: string) {
|
function add_intrinsic(name: string) {
|
||||||
if (name.startsWith("_$")) {
|
if (name.startsWith("_$")) {
|
||||||
let temporalBuildNodeEntryArgs = realm.derivedIds.get(name);
|
let temporalOperationEntryArgs = realm.derivedIds.get(name);
|
||||||
invariant(temporalBuildNodeEntryArgs !== undefined);
|
invariant(temporalOperationEntryArgs !== undefined);
|
||||||
add_args(temporalBuildNodeEntryArgs.args);
|
add_args(temporalOperationEntryArgs.args);
|
||||||
} else if (names.indexOf(name) < 0) {
|
} else if (names.indexOf(name) < 0) {
|
||||||
names.push(name);
|
names.push(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user