mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-10-26 23:32:02 +03:00
Refine operationDescriptor "data" and remove some properties (#2308)
Summary: Release notes: none This refines the `operationDescriptor` `data` object and removes a bunch of properties, but mainly `propName`. Instead we now feed this around in args, mainly as a `StringValue` removing a bunch of confusing existing logic. Pull Request resolved: https://github.com/facebook/prepack/pull/2308 Differential Revision: D8959081 Pulled By: trueadm fbshipit-source-id: 6bb1e95735dcbe3a88800b94af71d6681692f432
This commit is contained in:
parent
5f3d54775f
commit
2735f970a9
@ -39,8 +39,8 @@ export default function(realm: Realm): NativeFunctionValue {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
StringValue,
|
StringValue,
|
||||||
[array],
|
[array, new StringValue(realm, "toString")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "toString" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
/* @flow strict-local */
|
/* @flow strict-local */
|
||||||
|
|
||||||
import type { Realm } from "../../realm.js";
|
import type { Realm } from "../../realm.js";
|
||||||
import { AbstractValue, ArrayValue, NativeFunctionValue, Value } from "../../values/index.js";
|
import { AbstractValue, ArrayValue, NativeFunctionValue, StringValue, Value } from "../../values/index.js";
|
||||||
import { Create, To } from "../../singletons.js";
|
import { Create, To } from "../../singletons.js";
|
||||||
import { createOperationDescriptor } from "../../utils/generator.js";
|
import { createOperationDescriptor } from "../../utils/generator.js";
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ export default function(realm: Realm): NativeFunctionValue {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
[O],
|
[O, new StringValue(realm, "values")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "values" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("concat") === undefined
|
O.$GetOwnProperty("concat") === undefined
|
||||||
) {
|
) {
|
||||||
let newArgs = [O, ...args];
|
let newArgs = [O, new StringValue(realm, "concat"), ...args];
|
||||||
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
||||||
realm,
|
realm,
|
||||||
newArgs,
|
newArgs,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "concat" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("copyWithin") === undefined
|
O.$GetOwnProperty("copyWithin") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, target];
|
let args = [O, new StringValue(realm, "copyWithin"), target];
|
||||||
if (start) {
|
if (start) {
|
||||||
args.push(start);
|
args.push(start);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
BooleanValue,
|
BooleanValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "copyWithin" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
return O;
|
return O;
|
||||||
}
|
}
|
||||||
@ -266,8 +266,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
[O],
|
[O, new StringValue(realm, "entries")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "entries" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("every") === undefined
|
O.$GetOwnProperty("every") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, callbackfn];
|
let args = [O, new StringValue(realm, "every"), callbackfn];
|
||||||
if (thisArg) {
|
if (thisArg) {
|
||||||
args.push(thisArg);
|
args.push(thisArg);
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
BooleanValue,
|
BooleanValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "every" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("fill") === undefined
|
O.$GetOwnProperty("fill") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, value];
|
let args = [O, new StringValue(realm, "fill"), value];
|
||||||
if (start) {
|
if (start) {
|
||||||
args.push(start);
|
args.push(start);
|
||||||
}
|
}
|
||||||
@ -366,7 +366,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "fill" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
return O;
|
return O;
|
||||||
}
|
}
|
||||||
@ -412,14 +412,14 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("filter") === undefined
|
O.$GetOwnProperty("filter") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, callbackfn];
|
let args = [O, new StringValue(realm, "filter"), callbackfn];
|
||||||
if (thisArg) {
|
if (thisArg) {
|
||||||
args.push(thisArg);
|
args.push(thisArg);
|
||||||
}
|
}
|
||||||
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
||||||
realm,
|
realm,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "filter" }),
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL"),
|
||||||
{ func: callbackfn, thisVal: thisArg }
|
{ func: callbackfn, thisVal: thisArg }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -491,7 +491,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("find") === undefined
|
O.$GetOwnProperty("find") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, predicate];
|
let args = [O, new StringValue(realm, "find"), predicate];
|
||||||
if (thisArg) {
|
if (thisArg) {
|
||||||
args.push(thisArg);
|
args.push(thisArg);
|
||||||
}
|
}
|
||||||
@ -499,7 +499,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "find" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +552,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("findIndex") === undefined
|
O.$GetOwnProperty("findIndex") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, predicate];
|
let args = [O, new StringValue(realm, "findIndex"), predicate];
|
||||||
if (thisArg) {
|
if (thisArg) {
|
||||||
args.push(thisArg);
|
args.push(thisArg);
|
||||||
}
|
}
|
||||||
@ -560,7 +560,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
NumberValue,
|
NumberValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "findIndex" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,7 +613,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("forEach") === undefined
|
O.$GetOwnProperty("forEach") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, callbackfn];
|
let args = [O, new StringValue(realm, "forEach"), callbackfn];
|
||||||
if (thisArg) {
|
if (thisArg) {
|
||||||
args.push(thisArg);
|
args.push(thisArg);
|
||||||
}
|
}
|
||||||
@ -621,7 +621,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
BooleanValue,
|
BooleanValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "forEach" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
return realm.intrinsics.undefined;
|
return realm.intrinsics.undefined;
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("includes") === undefined
|
O.$GetOwnProperty("includes") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, searchElement];
|
let args = [O, new StringValue(realm, "includes"), searchElement];
|
||||||
if (fromIndex) {
|
if (fromIndex) {
|
||||||
args.push(fromIndex);
|
args.push(fromIndex);
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
BooleanValue,
|
BooleanValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "includes" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,7 +742,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("indexOf") === undefined
|
O.$GetOwnProperty("indexOf") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, searchElement];
|
let args = [O, new StringValue(realm, "indexOf"), searchElement];
|
||||||
if (fromIndex) {
|
if (fromIndex) {
|
||||||
args.push(fromIndex);
|
args.push(fromIndex);
|
||||||
}
|
}
|
||||||
@ -750,7 +750,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
NumberValue,
|
NumberValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "indexOf" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,7 +818,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("join") === undefined
|
O.$GetOwnProperty("join") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O];
|
let args = [O, new StringValue(realm, "join")];
|
||||||
if (separator) {
|
if (separator) {
|
||||||
args.push(separator);
|
args.push(separator);
|
||||||
}
|
}
|
||||||
@ -826,7 +826,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
StringValue,
|
StringValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "join" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,8 +899,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
[O],
|
[O, new StringValue(realm, "keys")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "keys" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +921,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("lastIndexOf") === undefined
|
O.$GetOwnProperty("lastIndexOf") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, searchElement];
|
let args = [O, new StringValue(realm, "lastIndexOf"), searchElement];
|
||||||
if (fromIndex) {
|
if (fromIndex) {
|
||||||
args.push(fromIndex);
|
args.push(fromIndex);
|
||||||
}
|
}
|
||||||
@ -929,7 +929,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
NumberValue,
|
NumberValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "lastIndexOf" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,14 +988,14 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("map") === undefined
|
O.$GetOwnProperty("map") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, callbackfn];
|
let args = [O, new StringValue(realm, "map"), callbackfn];
|
||||||
if (thisArg) {
|
if (thisArg) {
|
||||||
args.push(thisArg);
|
args.push(thisArg);
|
||||||
}
|
}
|
||||||
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
||||||
realm,
|
realm,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "map" }),
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL"),
|
||||||
{ func: callbackfn, thisVal: thisArg }
|
{ func: callbackfn, thisVal: thisArg }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1084,8 +1084,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
[O],
|
[O, new StringValue(realm, "pop")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "pop" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,8 +1137,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
NumberValue,
|
NumberValue,
|
||||||
[O, ...args],
|
[O, new StringValue(realm, "push"), ...args],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "push" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1188,7 +1188,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("reduce") === undefined
|
O.$GetOwnProperty("reduce") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, callbackfn];
|
let args = [O, new StringValue(realm, "reduce"), callbackfn];
|
||||||
if (initialValue) {
|
if (initialValue) {
|
||||||
args.push(initialValue);
|
args.push(initialValue);
|
||||||
}
|
}
|
||||||
@ -1196,7 +1196,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "reduce" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1295,7 +1295,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("reduceRight") === undefined
|
O.$GetOwnProperty("reduceRight") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, callbackfn];
|
let args = [O, new StringValue(realm, "reduceRight"), callbackfn];
|
||||||
if (initialValue) {
|
if (initialValue) {
|
||||||
args.push(initialValue);
|
args.push(initialValue);
|
||||||
}
|
}
|
||||||
@ -1303,7 +1303,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "reduceRight" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1403,8 +1403,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
AbstractValue.createTemporalFromBuildFunction(
|
AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
ArrayValue,
|
ArrayValue,
|
||||||
[O],
|
[O, new StringValue(realm, "reverse")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "reverse" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
return O;
|
return O;
|
||||||
}
|
}
|
||||||
@ -1506,8 +1506,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
[O],
|
[O, new StringValue(realm, "shift")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "shift" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1577,11 +1577,11 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("slice") === undefined
|
O.$GetOwnProperty("slice") === undefined
|
||||||
) {
|
) {
|
||||||
let newArgs = [O, start, end];
|
let newArgs = [O, new StringValue(realm, "slice"), start, end];
|
||||||
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
return ArrayValue.createTemporalWithWidenedNumericProperty(
|
||||||
realm,
|
realm,
|
||||||
newArgs,
|
newArgs,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "slice" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1653,7 +1653,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("some") === undefined
|
O.$GetOwnProperty("some") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, callbackfn];
|
let args = [O, new StringValue(realm, "some"), callbackfn];
|
||||||
if (thisArg) {
|
if (thisArg) {
|
||||||
args.push(thisArg);
|
args.push(thisArg);
|
||||||
}
|
}
|
||||||
@ -1661,7 +1661,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
BooleanValue,
|
BooleanValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "some" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1723,12 +1723,12 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("sort") === undefined
|
O.$GetOwnProperty("sort") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, comparefn];
|
let args = [O, new StringValue(realm, "sort"), comparefn];
|
||||||
AbstractValue.createTemporalFromBuildFunction(
|
AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "sort" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
// context is returned instead of O at the end of this method
|
// context is returned instead of O at the end of this method
|
||||||
// so we do the same here
|
// so we do the same here
|
||||||
@ -1909,7 +1909,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm.isInPureScope() &&
|
realm.isInPureScope() &&
|
||||||
O.$GetOwnProperty("splice") === undefined
|
O.$GetOwnProperty("splice") === undefined
|
||||||
) {
|
) {
|
||||||
let args = [O, start];
|
let args = [O, new StringValue(realm, "splice"), start];
|
||||||
if (deleteCount) {
|
if (deleteCount) {
|
||||||
args.push(deleteCount);
|
args.push(deleteCount);
|
||||||
}
|
}
|
||||||
@ -1920,7 +1920,7 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
realm,
|
realm,
|
||||||
ArrayValue,
|
ArrayValue,
|
||||||
args,
|
args,
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "splice" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2120,8 +2120,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
StringValue,
|
StringValue,
|
||||||
[array],
|
[array, new StringValue(realm, "toLocaleString")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "toLocaleString" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2200,8 +2200,8 @@ export default function(realm: Realm, obj: ObjectValue): void {
|
|||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
NumberValue,
|
NumberValue,
|
||||||
[O],
|
[O, new StringValue(realm, "unshift")],
|
||||||
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL", { propName: "unshift" })
|
createOperationDescriptor("UNKNOWN_ARRAY_METHOD_PROPERTY_CALL")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +202,8 @@ function createMagicGlobalFunction(realm: Realm, global: ObjectValue | AbstractO
|
|||||||
let val = AbstractValue.createTemporalFromBuildFunction(
|
let val = AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
FunctionValue,
|
FunctionValue,
|
||||||
args,
|
[new StringValue(realm, functionName), ...args],
|
||||||
createOperationDescriptor("FB_MOCKS_MAGIC_GLOBAL_FUNCTION", { propName: functionName }),
|
createOperationDescriptor("FB_MOCKS_MAGIC_GLOBAL_FUNCTION"),
|
||||||
{ skipInvariant: true, isPure: true }
|
{ skipInvariant: true, isPure: true }
|
||||||
);
|
);
|
||||||
invariant(val instanceof AbstractValue);
|
invariant(val instanceof AbstractValue);
|
||||||
|
8
src/intrinsics/fb-www/react-native-mocks.js
vendored
8
src/intrinsics/fb-www/react-native-mocks.js
vendored
@ -1659,8 +1659,8 @@ export function createMockReactNative(realm: Realm, reactNativeRequireName: stri
|
|||||||
let RCTViewDerivedReference = AbstractValue.createTemporalFromBuildFunction(
|
let RCTViewDerivedReference = AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
StringValue,
|
StringValue,
|
||||||
[],
|
[new StringValue(realm, "RCTView")],
|
||||||
createOperationDescriptor("REACT_NATIVE_STRING_LITERAL", { propName: "RCTView" }),
|
createOperationDescriptor("REACT_NATIVE_STRING_LITERAL"),
|
||||||
{ skipInvariant: true, isPure: true }
|
{ skipInvariant: true, isPure: true }
|
||||||
);
|
);
|
||||||
invariant(RCTViewDerivedReference instanceof AbstractValue);
|
invariant(RCTViewDerivedReference instanceof AbstractValue);
|
||||||
@ -1669,8 +1669,8 @@ export function createMockReactNative(realm: Realm, reactNativeRequireName: stri
|
|||||||
let RCTTextDerivedReference = AbstractValue.createTemporalFromBuildFunction(
|
let RCTTextDerivedReference = AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
StringValue,
|
StringValue,
|
||||||
[],
|
[new StringValue(realm, "RCTText")],
|
||||||
createOperationDescriptor("REACT_NATIVE_STRING_LITERAL", { propName: "RCTText" }),
|
createOperationDescriptor("REACT_NATIVE_STRING_LITERAL"),
|
||||||
{ skipInvariant: true, isPure: true }
|
{ skipInvariant: true, isPure: true }
|
||||||
);
|
);
|
||||||
invariant(RCTTextDerivedReference instanceof AbstractValue);
|
invariant(RCTTextDerivedReference instanceof AbstractValue);
|
||||||
|
@ -10,7 +10,13 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
|
|
||||||
import type { Realm } from "../../realm.js";
|
import type { Realm } from "../../realm.js";
|
||||||
import { ObjectValue, FunctionValue, AbstractValue, ECMAScriptSourceFunctionValue } from "../../values/index.js";
|
import {
|
||||||
|
AbstractValue,
|
||||||
|
ECMAScriptSourceFunctionValue,
|
||||||
|
FunctionValue,
|
||||||
|
ObjectValue,
|
||||||
|
StringValue,
|
||||||
|
} from "../../values/index.js";
|
||||||
import { Create, Environment } from "../../singletons.js";
|
import { Create, Environment } from "../../singletons.js";
|
||||||
import { createAbstract } from "../prepack/utils.js";
|
import { createAbstract } from "../prepack/utils.js";
|
||||||
import { Get } from "../../methods/index.js";
|
import { Get } from "../../methods/index.js";
|
||||||
@ -112,8 +118,8 @@ function createReactRelayContainer(
|
|||||||
let value = AbstractValue.createTemporalFromBuildFunction(
|
let value = AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
FunctionValue,
|
FunctionValue,
|
||||||
[reactRelay, ...args],
|
[reactRelay, new StringValue(realm, containerName), ...args],
|
||||||
createOperationDescriptor("REACT_RELAY_MOCK_CONTAINER", { propName: containerName }),
|
createOperationDescriptor("REACT_RELAY_MOCK_CONTAINER"),
|
||||||
{ skipInvariant: true, isPure: true }
|
{ skipInvariant: true, isPure: true }
|
||||||
);
|
);
|
||||||
invariant(value instanceof AbstractValue);
|
invariant(value instanceof AbstractValue);
|
||||||
|
@ -1181,15 +1181,14 @@ export class PropertiesImplementation {
|
|||||||
|
|
||||||
invariant(realm.generator);
|
invariant(realm.generator);
|
||||||
let propName = P;
|
let propName = P;
|
||||||
if (P instanceof StringValue) {
|
if (typeof propName === "string") {
|
||||||
propName = P.value;
|
propName = new StringValue(realm, propName);
|
||||||
}
|
}
|
||||||
invariant(typeof propName === "string");
|
|
||||||
let absVal = AbstractValue.createTemporalFromBuildFunction(
|
let absVal = AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
[O._templateFor || O],
|
[O._templateFor || O, propName],
|
||||||
createOperationDescriptor("ABSTRACT_PROPERTY", { propName }),
|
createOperationDescriptor("ABSTRACT_PROPERTY"),
|
||||||
{ isPure: true }
|
{ isPure: true }
|
||||||
);
|
);
|
||||||
// TODO: We can't be sure what the descriptor will be, but the value will be abstract.
|
// TODO: We can't be sure what the descriptor will be, but the value will be abstract.
|
||||||
@ -1216,16 +1215,16 @@ export class PropertiesImplementation {
|
|||||||
return AbstractValue.createFromBuildFunction(
|
return AbstractValue.createFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
type,
|
type,
|
||||||
[O._templateFor || O],
|
[O._templateFor || O, new StringValue(realm, P)],
|
||||||
createOperationDescriptor("ABSTRACT_PROPERTY", { propName: P }),
|
createOperationDescriptor("ABSTRACT_PROPERTY"),
|
||||||
{ kind: AbstractValue.makeKind("property", P) }
|
{ kind: AbstractValue.makeKind("property", P) }
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return AbstractValue.createTemporalFromBuildFunction(
|
return AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
type,
|
type,
|
||||||
[O._templateFor || O],
|
[O._templateFor || O, new StringValue(realm, P)],
|
||||||
createOperationDescriptor("ABSTRACT_PROPERTY", { propName: P }),
|
createOperationDescriptor("ABSTRACT_PROPERTY"),
|
||||||
{ skipInvariant: true, isPure: true }
|
{ skipInvariant: true, isPure: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import { AbruptCompletion, PossiblyNormalCompletion, SimpleNormalCompletion } fr
|
|||||||
import { Reference } from "../environment.js";
|
import { Reference } from "../environment.js";
|
||||||
import { cloneDescriptor, equalDescriptors, IsDataDescriptor, StrictEqualityComparison } from "./index.js";
|
import { cloneDescriptor, equalDescriptors, IsDataDescriptor, StrictEqualityComparison } from "./index.js";
|
||||||
import { Generator, createOperationDescriptor } from "../utils/generator.js";
|
import { Generator, createOperationDescriptor } from "../utils/generator.js";
|
||||||
import { AbstractValue, ArrayValue, EmptyValue, Value } from "../values/index.js";
|
import { AbstractValue, ArrayValue, EmptyValue, Value, StringValue } from "../values/index.js";
|
||||||
|
|
||||||
import invariant from "../invariant.js";
|
import invariant from "../invariant.js";
|
||||||
|
|
||||||
@ -265,8 +265,8 @@ export class WidenImplementation {
|
|||||||
pathNode = AbstractValue.createFromWidenedProperty(
|
pathNode = AbstractValue.createFromWidenedProperty(
|
||||||
realm,
|
realm,
|
||||||
rval,
|
rval,
|
||||||
[b.object],
|
[b.object, new StringValue(realm, key)],
|
||||||
createOperationDescriptor("WIDEN_PROPERTY", { propName: key })
|
createOperationDescriptor("WIDEN_PROPERTY")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
invariant(key instanceof AbstractValue);
|
invariant(key instanceof AbstractValue);
|
||||||
@ -274,7 +274,7 @@ export class WidenImplementation {
|
|||||||
realm,
|
realm,
|
||||||
rval,
|
rval,
|
||||||
[b.object, key],
|
[b.object, key],
|
||||||
createOperationDescriptor("WIDEN_ABSTRACT_PROPERTY")
|
createOperationDescriptor("WIDEN_PROPERTY")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// The value of the property at the start of the loop needs to be written to the property
|
// The value of the property at the start of the loop needs to be written to the property
|
||||||
@ -290,8 +290,8 @@ export class WidenImplementation {
|
|||||||
generator.emitVoidExpression(
|
generator.emitVoidExpression(
|
||||||
rval.types,
|
rval.types,
|
||||||
rval.values,
|
rval.values,
|
||||||
[b.object, initVal],
|
[b.object, new StringValue(realm, key), initVal],
|
||||||
createOperationDescriptor("WIDEN_PROPERTY_ASSIGNMENT", { propName: key })
|
createOperationDescriptor("WIDEN_PROPERTY_ASSIGNMENT")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
invariant(key instanceof AbstractValue);
|
invariant(key instanceof AbstractValue);
|
||||||
@ -299,7 +299,7 @@ export class WidenImplementation {
|
|||||||
rval.types,
|
rval.types,
|
||||||
rval.values,
|
rval.values,
|
||||||
[b.object, key, initVal],
|
[b.object, key, initVal],
|
||||||
createOperationDescriptor("WIDEN_ABSTRACT_PROPERTY_ASSIGNMENT")
|
createOperationDescriptor("WIDEN_PROPERTY_ASSIGNMENT")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1196,8 +1196,8 @@ export class Realm {
|
|||||||
if (typeof keyKey === "string") {
|
if (typeof keyKey === "string") {
|
||||||
if (path !== undefined) {
|
if (path !== undefined) {
|
||||||
gen.emitStatement(
|
gen.emitStatement(
|
||||||
[key.object, tval || value, this.intrinsics.empty],
|
[key.object, tval || value, this.intrinsics.empty, new StringValue(this, keyKey)],
|
||||||
createOperationDescriptor("CONDITIONAL_PROPERTY_ASSIGNMENT", { binding: key, path, value })
|
createOperationDescriptor("CONDITIONAL_PROPERTY_ASSIGNMENT", { path, value })
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// RH value was not widened, so it must have been a constant. We don't need to assign that inside the loop.
|
// RH value was not widened, so it must have been a constant. We don't need to assign that inside the loop.
|
||||||
@ -1686,8 +1686,8 @@ export class Realm {
|
|||||||
if (!propertyValue.isIntrinsic()) {
|
if (!propertyValue.isIntrinsic()) {
|
||||||
propertyValue.intrinsicName = `${path}.${key}`;
|
propertyValue.intrinsicName = `${path}.${key}`;
|
||||||
propertyValue.kind = "rebuiltProperty";
|
propertyValue.kind = "rebuiltProperty";
|
||||||
propertyValue.args = [object];
|
propertyValue.args = [object, new StringValue(this, key)];
|
||||||
propertyValue.operationDescriptor = createOperationDescriptor("REBUILT_OBJECT", { propName: key });
|
propertyValue.operationDescriptor = createOperationDescriptor("REBUILT_OBJECT");
|
||||||
let intrinsicName = propertyValue.intrinsicName;
|
let intrinsicName = propertyValue.intrinsicName;
|
||||||
invariant(intrinsicName !== undefined);
|
invariant(intrinsicName !== undefined);
|
||||||
this.rebuildNestedProperties(propertyValue, intrinsicName);
|
this.rebuildNestedProperties(propertyValue, intrinsicName);
|
||||||
|
@ -28,7 +28,12 @@ import invariant from "../invariant.js";
|
|||||||
import { type Binding } from "../environment.js";
|
import { type Binding } from "../environment.js";
|
||||||
import * as t from "@babel/types";
|
import * as t from "@babel/types";
|
||||||
import { AbstractValue, EmptyValue, ObjectValue, Value } from "../values/index.js";
|
import { AbstractValue, EmptyValue, ObjectValue, Value } from "../values/index.js";
|
||||||
import type { BabelNodeBlockStatement, BabelNodeExpression, BabelNodeSpreadElement } from "@babel/types";
|
import type {
|
||||||
|
BabelNodeBlockStatement,
|
||||||
|
BabelNodeExpression,
|
||||||
|
BabelNodeSpreadElement,
|
||||||
|
BabelNodeStringLiteral,
|
||||||
|
} from "@babel/types";
|
||||||
import { Utils } from "../singletons.js";
|
import { Utils } from "../singletons.js";
|
||||||
import type { PropertyBinding } from "../types.js";
|
import type { PropertyBinding } from "../types.js";
|
||||||
|
|
||||||
@ -90,7 +95,7 @@ export class ResidualOperationSerializer {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "IDENTIFIER":
|
case "IDENTIFIER":
|
||||||
babelNode = this._serializeIdentifier(data);
|
babelNode = this._serializeIdentifier(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "REBUILT_OBJECT":
|
case "REBUILT_OBJECT":
|
||||||
babelNode = this._serializeRebuiltObject(data, nodes);
|
babelNode = this._serializeRebuiltObject(data, nodes);
|
||||||
@ -129,7 +134,7 @@ export class ResidualOperationSerializer {
|
|||||||
babelNode = this._serializeGlobalAssignment(data, nodes);
|
babelNode = this._serializeGlobalAssignment(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "GLOBAL_DELETE":
|
case "GLOBAL_DELETE":
|
||||||
babelNode = this._serializeGlobalDelete(data);
|
babelNode = this._serializeGlobalDelete(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "EMIT_PROPERTY_ASSIGNMENT":
|
case "EMIT_PROPERTY_ASSIGNMENT":
|
||||||
babelNode = this._serializeEmitPropertyAssignment(data, nodes, context);
|
babelNode = this._serializeEmitPropertyAssignment(data, nodes, context);
|
||||||
@ -197,9 +202,6 @@ export class ResidualOperationSerializer {
|
|||||||
case "ABSTRACT_OBJECT_SET_PARTIAL":
|
case "ABSTRACT_OBJECT_SET_PARTIAL":
|
||||||
babelNode = this._serializeAbstractObjectSetPartial(data, nodes);
|
babelNode = this._serializeAbstractObjectSetPartial(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "ABSTRACT_OBJECT_SET_PARTIAL_VALUE":
|
|
||||||
babelNode = this._serializeAbstractObjectSetPartialValue(data, nodes);
|
|
||||||
break;
|
|
||||||
case "ABSTRACT_OBJECT_GET_PROTO_OF":
|
case "ABSTRACT_OBJECT_GET_PROTO_OF":
|
||||||
babelNode = this._serializeAbstractObjectGetProtoOf(data, nodes);
|
babelNode = this._serializeAbstractObjectGetProtoOf(data, nodes);
|
||||||
break;
|
break;
|
||||||
@ -243,7 +245,7 @@ export class ResidualOperationSerializer {
|
|||||||
babelNode = this._serializeConsoleLog(data, nodes);
|
babelNode = this._serializeConsoleLog(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "MODULES_REQUIRE":
|
case "MODULES_REQUIRE":
|
||||||
babelNode = this._serializeModulesRequires(data);
|
babelNode = this._serializeModulesRequires(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "RESIDUAL_CALL":
|
case "RESIDUAL_CALL":
|
||||||
babelNode = this._serializeResidualCall(data, nodes);
|
babelNode = this._serializeResidualCall(data, nodes);
|
||||||
@ -255,20 +257,14 @@ export class ResidualOperationSerializer {
|
|||||||
babelNode = this._serializeCannotBecomeObject(data, nodes);
|
babelNode = this._serializeCannotBecomeObject(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "WIDENED_IDENTIFIER":
|
case "WIDENED_IDENTIFIER":
|
||||||
babelNode = this._serializeIdentifier(data);
|
babelNode = this._serializeIdentifier(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "WIDEN_PROPERTY":
|
case "WIDEN_PROPERTY":
|
||||||
babelNode = this._serializeWidenProperty(data, nodes);
|
babelNode = this._serializeWidenProperty(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "WIDEN_ABSTRACT_PROPERTY":
|
|
||||||
babelNode = this._serializeWidenAbstractProperty(data, nodes);
|
|
||||||
break;
|
|
||||||
case "WIDEN_PROPERTY_ASSIGNMENT":
|
case "WIDEN_PROPERTY_ASSIGNMENT":
|
||||||
babelNode = this._serializeWidenPropertyAssignment(data, nodes);
|
babelNode = this._serializeWidenPropertyAssignment(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "WIDEN_ABSTRACT_PROPERTY_ASSIGNMENT":
|
|
||||||
babelNode = this._serializeWidenAbstractPropertyAssignment(data, nodes);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Invariants
|
// Invariants
|
||||||
case "INVARIANT":
|
case "INVARIANT":
|
||||||
@ -318,7 +314,7 @@ export class ResidualOperationSerializer {
|
|||||||
babelNode = this._serializeReactCreateContextProvider(data, nodes);
|
babelNode = this._serializeReactCreateContextProvider(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "REACT_NATIVE_STRING_LITERAL":
|
case "REACT_NATIVE_STRING_LITERAL":
|
||||||
babelNode = this._serializeReactNativeStringLiteral(data);
|
babelNode = this._serializeReactNativeStringLiteral(data, nodes);
|
||||||
break;
|
break;
|
||||||
case "REACT_RELAY_MOCK_CONTAINER":
|
case "REACT_RELAY_MOCK_CONTAINER":
|
||||||
babelNode = this._serializeReactRelayMockContainer(data, nodes);
|
babelNode = this._serializeReactRelayMockContainer(data, nodes);
|
||||||
@ -349,15 +345,15 @@ export class ResidualOperationSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serializeAppendGenerator(
|
_serializeAppendGenerator(
|
||||||
{ generator, propName: leadingComment }: OperationDescriptorData,
|
{ generator }: OperationDescriptorData,
|
||||||
node: Array<BabelNodeExpression>,
|
[leadingCommentNode]: Array<BabelNodeExpression>,
|
||||||
context?: SerializationContext,
|
context?: SerializationContext,
|
||||||
valuesToProcess?: Set<AbstractValue | ObjectValue>
|
valuesToProcess?: Set<AbstractValue | ObjectValue>
|
||||||
) {
|
) {
|
||||||
invariant(context !== undefined);
|
invariant(context !== undefined);
|
||||||
invariant(generator !== undefined);
|
invariant(generator !== undefined);
|
||||||
invariant(leadingComment !== undefined);
|
|
||||||
invariant(valuesToProcess !== undefined);
|
invariant(valuesToProcess !== undefined);
|
||||||
|
let leadingComment = ((leadingCommentNode: any): BabelNodeStringLiteral).value;
|
||||||
let statements = context.serializeGenerator(generator, valuesToProcess);
|
let statements = context.serializeGenerator(generator, valuesToProcess);
|
||||||
if (statements.length === 1) {
|
if (statements.length === 1) {
|
||||||
let statement = statements[0];
|
let statement = statements[0];
|
||||||
@ -380,12 +376,7 @@ export class ResidualOperationSerializer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeWidenAbstractPropertyAssignment(data: OperationDescriptorData, [o, p, v]: Array<BabelNodeExpression>) {
|
_serializeWidenPropertyAssignment(data: OperationDescriptorData, [o, propName, v]: Array<BabelNodeExpression>) {
|
||||||
return t.assignmentExpression("=", memberExpressionHelper(o, p), v);
|
|
||||||
}
|
|
||||||
|
|
||||||
_serializeWidenPropertyAssignment({ propName }: OperationDescriptorData, [o, v]: Array<BabelNodeExpression>) {
|
|
||||||
invariant(typeof propName === "string");
|
|
||||||
return t.assignmentExpression("=", memberExpressionHelper(o, propName), v);
|
return t.assignmentExpression("=", memberExpressionHelper(o, propName), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,21 +384,13 @@ export class ResidualOperationSerializer {
|
|||||||
return memberExpressionHelper(o, p);
|
return memberExpressionHelper(o, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeWidenProperty({ propName }: OperationDescriptorData, [o]: Array<BabelNodeExpression>) {
|
_serializeWidenProperty(data: OperationDescriptorData, [o, propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
|
||||||
return memberExpressionHelper(o, propName);
|
return memberExpressionHelper(o, propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeAbstractObjectGet(
|
_serializeAbstractObjectGet({ propertyGetter }: OperationDescriptorData, [o, P]: Array<BabelNodeExpression>) {
|
||||||
{ propertyGetter, propName: P }: OperationDescriptorData,
|
|
||||||
[o]: Array<BabelNodeExpression>
|
|
||||||
) {
|
|
||||||
invariant(typeof P === "string");
|
|
||||||
return propertyGetter !== undefined
|
return propertyGetter !== undefined
|
||||||
? t.callExpression(t.memberExpression(t.identifier("global"), t.identifier("__prop_" + propertyGetter)), [
|
? t.callExpression(t.memberExpression(t.identifier("global"), t.identifier("__prop_" + propertyGetter)), [o, P])
|
||||||
o,
|
|
||||||
t.stringLiteral(P),
|
|
||||||
])
|
|
||||||
: memberExpressionHelper(o, P);
|
: memberExpressionHelper(o, P);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,22 +411,21 @@ export class ResidualOperationSerializer {
|
|||||||
return t.callExpression(nodes[0], ((nodes.slice(1): any): Array<BabelNodeExpression | BabelNodeSpreadElement>));
|
return t.callExpression(nodes[0], ((nodes.slice(1): any): Array<BabelNodeExpression | BabelNodeSpreadElement>));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeModulesRequires({ propName }: OperationDescriptorData) {
|
_serializeModulesRequires(data: OperationDescriptorData, [propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(propName !== undefined);
|
return t.callExpression(t.identifier("require"), [propName]);
|
||||||
return t.callExpression(t.identifier("require"), [t.valueToNode(propName)]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeConcreteModel({ propName }: OperationDescriptorData, [valueNode]: Array<BabelNodeExpression>) {
|
_serializeConcreteModel(data: OperationDescriptorData, [valueNode, propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(propName !== undefined);
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.expressionStatement(
|
return t.expressionStatement(
|
||||||
t.assignmentExpression("=", this.preludeGenerator.globalReference(propName, false), valueNode)
|
t.assignmentExpression("=", this.preludeGenerator.globalReference(propString, false), valueNode)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeConsoleLog({ propName }: OperationDescriptorData, nodes: Array<BabelNodeExpression>) {
|
_serializeConsoleLog(data: OperationDescriptorData, [propName, ...nodes]: Array<BabelNodeExpression>) {
|
||||||
invariant(propName !== undefined);
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.expressionStatement(
|
return t.expressionStatement(
|
||||||
t.callExpression(t.memberExpression(t.identifier("console"), t.identifier(propName)), [...nodes])
|
t.callExpression(t.memberExpression(t.identifier("console"), t.identifier(propString)), [...nodes])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,13 +460,14 @@ export class ResidualOperationSerializer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeFullInvariant({ propName }: OperationDescriptorData, [objectNode, valueNode]: Array<BabelNodeExpression>) {
|
_serializeFullInvariant(
|
||||||
invariant(propName !== undefined);
|
data: OperationDescriptorData,
|
||||||
|
[propName, objectNode, valueNode]: Array<BabelNodeExpression>
|
||||||
|
) {
|
||||||
return t.binaryExpression("!==", memberExpressionHelper(objectNode, propName), valueNode);
|
return t.binaryExpression("!==", memberExpressionHelper(objectNode, propName), valueNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeFullInvariantFunction({ propName }: OperationDescriptorData, [objectNode]: Array<BabelNodeExpression>) {
|
_serializeFullInvariantFunction(data: OperationDescriptorData, [propName, objectNode]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
|
||||||
return t.binaryExpression(
|
return t.binaryExpression(
|
||||||
"!==",
|
"!==",
|
||||||
t.unaryExpression("typeof", memberExpressionHelper(objectNode, propName), true),
|
t.unaryExpression("typeof", memberExpressionHelper(objectNode, propName), true),
|
||||||
@ -494,7 +477,7 @@ export class ResidualOperationSerializer {
|
|||||||
|
|
||||||
_serializeFullInvariantAbstract(
|
_serializeFullInvariantAbstract(
|
||||||
{ concreteComparisons, typeComparisons }: OperationDescriptorData,
|
{ concreteComparisons, typeComparisons }: OperationDescriptorData,
|
||||||
[valueNode]: Array<BabelNodeExpression>
|
[propName, valueNode]: Array<BabelNodeExpression>
|
||||||
) {
|
) {
|
||||||
invariant(concreteComparisons !== undefined);
|
invariant(concreteComparisons !== undefined);
|
||||||
invariant(typeComparisons !== undefined);
|
invariant(typeComparisons !== undefined);
|
||||||
@ -513,20 +496,18 @@ export class ResidualOperationSerializer {
|
|||||||
return checks.reduce((expr, newCondition) => t.logicalExpression("&&", expr, newCondition));
|
return checks.reduce((expr, newCondition) => t.logicalExpression("&&", expr, newCondition));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeInvariantAppend({ propName }: OperationDescriptorData, [objectNode]: Array<BabelNodeExpression>) {
|
_serializeInvariantAppend(data: OperationDescriptorData, [propName, objectNode]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
|
||||||
return memberExpressionHelper(objectNode, propName);
|
return memberExpressionHelper(objectNode, propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializePropertyInvariant({ propName, state }: OperationDescriptorData, [objectNode]: Array<BabelNodeExpression>) {
|
_serializePropertyInvariant({ state }: OperationDescriptorData, [propName, objectNode]: Array<BabelNodeExpression>) {
|
||||||
invariant(state !== undefined);
|
invariant(state !== undefined);
|
||||||
invariant(typeof propName === "string");
|
|
||||||
let n = t.callExpression(
|
let n = t.callExpression(
|
||||||
t.memberExpression(
|
t.memberExpression(
|
||||||
this.preludeGenerator.memoizeReference("Object.prototype.hasOwnProperty"),
|
this.preludeGenerator.memoizeReference("Object.prototype.hasOwnProperty"),
|
||||||
t.identifier("call")
|
t.identifier("call")
|
||||||
),
|
),
|
||||||
[objectNode, t.stringLiteral(propName)]
|
[objectNode, propName]
|
||||||
);
|
);
|
||||||
if (state !== "MISSING") {
|
if (state !== "MISSING") {
|
||||||
n = t.unaryExpression("!", n, true);
|
n = t.unaryExpression("!", n, true);
|
||||||
@ -545,16 +526,19 @@ export class ResidualOperationSerializer {
|
|||||||
return t.binaryExpression(op, oldValNode, t.numericLiteral(1));
|
return t.binaryExpression(op, oldValNode, t.numericLiteral(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeDerivedAbstractInvariant({ typeofString }: OperationDescriptorData, nodes: Array<BabelNodeExpression>) {
|
_serializeDerivedAbstractInvariant(
|
||||||
invariant(typeofString !== undefined);
|
data: OperationDescriptorData,
|
||||||
let condition = t.binaryExpression("!==", t.unaryExpression("typeof", nodes[0]), t.stringLiteral(typeofString));
|
[typeOfStringNode, typeofNode]: Array<BabelNodeExpression>
|
||||||
|
) {
|
||||||
|
let typeofString = ((typeOfStringNode: any): BabelNodeStringLiteral).value;
|
||||||
|
let condition = t.binaryExpression("!==", t.unaryExpression("typeof", typeofNode), t.stringLiteral(typeofString));
|
||||||
if (typeofString === "object") {
|
if (typeofString === "object") {
|
||||||
condition = t.logicalExpression(
|
condition = t.logicalExpression(
|
||||||
"&&",
|
"&&",
|
||||||
condition,
|
condition,
|
||||||
t.binaryExpression("!==", t.unaryExpression("typeof", nodes[0]), t.stringLiteral("function"))
|
t.binaryExpression("!==", t.unaryExpression("typeof", typeofNode), t.stringLiteral("function"))
|
||||||
);
|
);
|
||||||
condition = t.logicalExpression("||", condition, t.binaryExpression("===", nodes[0], nullExpression));
|
condition = t.logicalExpression("||", condition, t.binaryExpression("===", typeofNode, nullExpression));
|
||||||
}
|
}
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
@ -569,9 +553,10 @@ export class ResidualOperationSerializer {
|
|||||||
t.numericLiteral(this.preludeGenerator.nextInvariantId++),
|
t.numericLiteral(this.preludeGenerator.nextInvariantId++),
|
||||||
];
|
];
|
||||||
if (appendLastToInvariantOperationDescriptor) {
|
if (appendLastToInvariantOperationDescriptor) {
|
||||||
|
let propName = nodes[0];
|
||||||
let last = nodes.pop();
|
let last = nodes.pop();
|
||||||
messageComponents.push(t.stringLiteral("): "));
|
messageComponents.push(t.stringLiteral("): "));
|
||||||
messageComponents.push(this.serialize(appendLastToInvariantOperationDescriptor, [last]));
|
messageComponents.push(this.serialize(appendLastToInvariantOperationDescriptor, [propName, last]));
|
||||||
} else {
|
} else {
|
||||||
messageComponents.push(t.stringLiteral(")"));
|
messageComponents.push(t.stringLiteral(")"));
|
||||||
}
|
}
|
||||||
@ -584,12 +569,12 @@ export class ResidualOperationSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serializeReactRelayMockContainer(
|
_serializeReactRelayMockContainer(
|
||||||
{ propName }: OperationDescriptorData,
|
data: OperationDescriptorData,
|
||||||
[reactRelayIdent, ...otherArgs]: Array<BabelNodeExpression>
|
[reactRelayIdent, propName, ...otherArgs]: Array<BabelNodeExpression>
|
||||||
) {
|
) {
|
||||||
invariant(typeof propName === "string");
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.callExpression(
|
return t.callExpression(
|
||||||
t.memberExpression(reactRelayIdent, t.identifier(propName)),
|
t.memberExpression(reactRelayIdent, t.identifier(propString)),
|
||||||
((otherArgs: any): Array<any>)
|
((otherArgs: any): Array<any>)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -607,28 +592,23 @@ export class ResidualOperationSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serializeConditionalPropertyAssignment(
|
_serializeConditionalPropertyAssignment(
|
||||||
{ binding: _binding, path, value }: OperationDescriptorData,
|
{ path, value }: OperationDescriptorData,
|
||||||
[o, v, e]: Array<BabelNodeExpression>,
|
[o, v, e, keyKey]: Array<BabelNodeExpression>,
|
||||||
context?: SerializationContext,
|
context?: SerializationContext,
|
||||||
valuesToProcess?: Set<AbstractValue | ObjectValue>
|
valuesToProcess?: Set<AbstractValue | ObjectValue>
|
||||||
) {
|
) {
|
||||||
invariant(value instanceof AbstractValue);
|
invariant(value instanceof AbstractValue);
|
||||||
invariant(path instanceof AbstractValue);
|
invariant(path instanceof AbstractValue);
|
||||||
invariant(_binding !== undefined);
|
|
||||||
let binding = ((_binding: any): PropertyBinding);
|
|
||||||
invariant(value !== undefined);
|
|
||||||
let keyKey = binding.key;
|
|
||||||
invariant(typeof keyKey === "string");
|
|
||||||
let mightHaveBeenDeleted = value.mightHaveBeenDeleted();
|
let mightHaveBeenDeleted = value.mightHaveBeenDeleted();
|
||||||
let mightBeUndefined = value.mightBeUndefined();
|
let mightBeUndefined = value.mightBeUndefined();
|
||||||
invariant(path.operationDescriptor !== undefined);
|
invariant(path.operationDescriptor !== undefined);
|
||||||
let lh = this.serialize(path.operationDescriptor, [o, t.identifier(keyKey)], context, valuesToProcess);
|
let lh = this.serialize(path.operationDescriptor, [o, keyKey], context, valuesToProcess);
|
||||||
let r = t.expressionStatement(t.assignmentExpression("=", (lh: any), v));
|
let r = t.expressionStatement(t.assignmentExpression("=", (lh: any), v));
|
||||||
if (mightHaveBeenDeleted) {
|
if (mightHaveBeenDeleted) {
|
||||||
// If v === __empty || (v === undefined && !(key.key in o)) then delete it
|
// If v === __empty || (v === undefined && !(key.key in o)) then delete it
|
||||||
let emptyTest = t.binaryExpression("===", v, e);
|
let emptyTest = t.binaryExpression("===", v, e);
|
||||||
let undefinedTest = t.binaryExpression("===", v, voidExpression);
|
let undefinedTest = t.binaryExpression("===", v, voidExpression);
|
||||||
let inTest = t.unaryExpression("!", t.binaryExpression("in", t.stringLiteral(keyKey), o));
|
let inTest = t.unaryExpression("!", t.binaryExpression("in", keyKey, o));
|
||||||
let guard = t.logicalExpression("||", emptyTest, t.logicalExpression("&&", undefinedTest, inTest));
|
let guard = t.logicalExpression("||", emptyTest, t.logicalExpression("&&", undefinedTest, inTest));
|
||||||
let deleteIt = t.expressionStatement(t.unaryExpression("delete", (lh: any)));
|
let deleteIt = t.expressionStatement(t.unaryExpression("delete", (lh: any)));
|
||||||
return t.ifStatement(mightBeUndefined ? emptyTest : guard, deleteIt, r);
|
return t.ifStatement(mightBeUndefined ? emptyTest : guard, deleteIt, r);
|
||||||
@ -663,9 +643,8 @@ export class ResidualOperationSerializer {
|
|||||||
return t.expressionStatement(t.assignmentExpression("=", (id: any), v));
|
return t.expressionStatement(t.assignmentExpression("=", (id: any), v));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeReactNativeStringLiteral({ propName }: OperationDescriptorData) {
|
_serializeReactNativeStringLiteral(data: OperationDescriptorData, [propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
return propName;
|
||||||
return t.stringLiteral(propName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeReactCreateContextProvider(data: OperationDescriptorData, [consumerNode]: Array<BabelNodeExpression>) {
|
_serializeReactCreateContextProvider(data: OperationDescriptorData, [consumerNode]: Array<BabelNodeExpression>) {
|
||||||
@ -698,33 +677,33 @@ export class ResidualOperationSerializer {
|
|||||||
return t.callExpression(t.memberExpression(methodNode, t.identifier("call")), [objectNode, nameNode]);
|
return t.callExpression(t.memberExpression(methodNode, t.identifier("call")), [objectNode, nameNode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeRebuiltObject({ propName }: OperationDescriptorData, [node]: Array<BabelNodeExpression>) {
|
_serializeRebuiltObject(data: OperationDescriptorData, [node, propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.isValidIdentifier(propName)
|
return t.isValidIdentifier(propString)
|
||||||
? t.memberExpression(node, t.identifier(propName), false)
|
? t.memberExpression(node, t.identifier(propString), false)
|
||||||
: t.memberExpression(node, t.stringLiteral(propName), true);
|
: t.memberExpression(node, propName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeGlobalDelete({ propName }: OperationDescriptorData) {
|
_serializeGlobalDelete(data: OperationDescriptorData, [propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.expressionStatement(t.unaryExpression("delete", this.preludeGenerator.globalReference(propName, false)));
|
return t.expressionStatement(t.unaryExpression("delete", this.preludeGenerator.globalReference(propString, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeDefineProperty(
|
_serializeDefineProperty(
|
||||||
{ object, propName, desc }: OperationDescriptorData,
|
{ object, desc }: OperationDescriptorData,
|
||||||
args: Array<BabelNodeExpression>,
|
[propName]: Array<BabelNodeExpression>,
|
||||||
context?: SerializationContext
|
context?: SerializationContext
|
||||||
) {
|
) {
|
||||||
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
invariant(object !== undefined);
|
invariant(object !== undefined);
|
||||||
invariant(propName !== undefined);
|
|
||||||
invariant(desc !== undefined);
|
invariant(desc !== undefined);
|
||||||
invariant(context !== undefined);
|
invariant(context !== undefined);
|
||||||
return context.emitDefinePropertyBody(object, propName, desc);
|
return context.emitDefinePropertyBody(object, propString, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeFBMocksMagicGlobalFunction({ propName }: OperationDescriptorData, args: Array<BabelNodeExpression>) {
|
_serializeFBMocksMagicGlobalFunction(data: OperationDescriptorData, [propName, ...args]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.callExpression(t.identifier(propName), ((args: any): Array<any>));
|
return t.callExpression(t.identifier(propString), ((args: any): Array<any>));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeFBMocksBootloaderLoadModules(data: OperationDescriptorData, args: Array<BabelNodeExpression>) {
|
_serializeFBMocksBootloaderLoadModules(data: OperationDescriptorData, args: Array<BabelNodeExpression>) {
|
||||||
@ -735,14 +714,6 @@ export class ResidualOperationSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serializeAbstractObjectSetPartial(
|
_serializeAbstractObjectSetPartial(
|
||||||
{ propName }: OperationDescriptorData,
|
|
||||||
[objectNode, valueNode]: Array<BabelNodeExpression>
|
|
||||||
) {
|
|
||||||
invariant(typeof propName === "string");
|
|
||||||
return t.expressionStatement(t.assignmentExpression("=", memberExpressionHelper(objectNode, propName), valueNode));
|
|
||||||
}
|
|
||||||
|
|
||||||
_serializeAbstractObjectSetPartialValue(
|
|
||||||
data: OperationDescriptorData,
|
data: OperationDescriptorData,
|
||||||
[objectNode, keyNode, valueNode]: Array<BabelNodeExpression>
|
[objectNode, keyNode, valueNode]: Array<BabelNodeExpression>
|
||||||
) {
|
) {
|
||||||
@ -768,7 +739,7 @@ export class ResidualOperationSerializer {
|
|||||||
return t.expressionStatement(t.assignmentExpression("=", memberExpressionHelper(objectNode, keyNode), valueNode));
|
return t.expressionStatement(t.assignmentExpression("=", memberExpressionHelper(objectNode, keyNode), valueNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeIdentifier(data: OperationDescriptorData) {
|
_serializeIdentifier(data: OperationDescriptorData, nodes: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof data.id === "string");
|
invariant(typeof data.id === "string");
|
||||||
return t.identifier(data.id);
|
return t.identifier(data.id);
|
||||||
}
|
}
|
||||||
@ -797,11 +768,11 @@ export class ResidualOperationSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serializeUnknownArrayMethodPropertyCall(
|
_serializeUnknownArrayMethodPropertyCall(
|
||||||
{ propName }: OperationDescriptorData,
|
data: OperationDescriptorData,
|
||||||
[objNode, ..._args]: Array<BabelNodeExpression>
|
[objNode, propName, ..._args]: Array<BabelNodeExpression>
|
||||||
) {
|
) {
|
||||||
invariant(typeof propName === "string");
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.callExpression(t.memberExpression(objNode, t.identifier(propName)), ((_args: any): Array<any>));
|
return t.callExpression(t.memberExpression(objNode, t.identifier(propString)), ((_args: any): Array<any>));
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeThrow(data: OperationDescriptorData, [argument]: Array<BabelNodeExpression>) {
|
_serializeThrow(data: OperationDescriptorData, [argument]: Array<BabelNodeExpression>) {
|
||||||
@ -841,8 +812,7 @@ export class ResidualOperationSerializer {
|
|||||||
return t.callExpression(helperNode, [valueNode]);
|
return t.callExpression(helperNode, [valueNode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializePropertyDelete({ propName }: OperationDescriptorData, [objectNode]: Array<BabelNodeExpression>) {
|
_serializePropertyDelete(data: OperationDescriptorData, [objectNode, propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(propName !== undefined);
|
|
||||||
return t.expressionStatement(t.unaryExpression("delete", memberExpressionHelper(objectNode, propName)));
|
return t.expressionStatement(t.unaryExpression("delete", memberExpressionHelper(objectNode, propName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,13 +892,12 @@ export class ResidualOperationSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_serializeEmitPropertyAssignment(
|
_serializeEmitPropertyAssignment(
|
||||||
{ propName, value }: OperationDescriptorData,
|
{ value }: OperationDescriptorData,
|
||||||
[objectNode, valueNode]: Array<BabelNodeExpression>,
|
[objectNode, valueNode, propName]: Array<BabelNodeExpression>,
|
||||||
context?: SerializationContext
|
context?: SerializationContext
|
||||||
) {
|
) {
|
||||||
invariant(context !== undefined);
|
invariant(context !== undefined);
|
||||||
invariant(value instanceof Value);
|
invariant(value instanceof Value);
|
||||||
invariant(typeof propName === "string");
|
|
||||||
return context.getPropertyAssignmentStatement(
|
return context.getPropertyAssignmentStatement(
|
||||||
memberExpressionHelper(objectNode, propName),
|
memberExpressionHelper(objectNode, propName),
|
||||||
value,
|
value,
|
||||||
@ -937,10 +906,10 @@ export class ResidualOperationSerializer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeGlobalAssignment({ propName }: OperationDescriptorData, [valueNode]: Array<BabelNodeExpression>) {
|
_serializeGlobalAssignment(data: OperationDescriptorData, [valueNode, propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(typeof propName === "string");
|
let propString = ((propName: any): BabelNodeStringLiteral).value;
|
||||||
return t.expressionStatement(
|
return t.expressionStatement(
|
||||||
t.assignmentExpression("=", this.preludeGenerator.globalReference(propName, false), valueNode)
|
t.assignmentExpression("=", this.preludeGenerator.globalReference(propString, false), valueNode)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -948,8 +917,7 @@ export class ResidualOperationSerializer {
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
_serializeAbstractProperty({ propName }: OperationDescriptorData, [o]: Array<BabelNodeExpression>) {
|
_serializeAbstractProperty(data: OperationDescriptorData, [o, propName]: Array<BabelNodeExpression>) {
|
||||||
invariant(propName !== undefined);
|
|
||||||
return memberExpressionHelper(o, propName);
|
return memberExpressionHelper(o, propName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ export type OperationDescriptorType =
|
|||||||
| "ABSTRACT_OBJECT_GET_PARTIAL"
|
| "ABSTRACT_OBJECT_GET_PARTIAL"
|
||||||
| "ABSTRACT_OBJECT_GET_PROTO_OF"
|
| "ABSTRACT_OBJECT_GET_PROTO_OF"
|
||||||
| "ABSTRACT_OBJECT_SET_PARTIAL"
|
| "ABSTRACT_OBJECT_SET_PARTIAL"
|
||||||
| "ABSTRACT_OBJECT_SET_PARTIAL_VALUE"
|
|
||||||
| "ABSTRACT_PROPERTY"
|
| "ABSTRACT_PROPERTY"
|
||||||
| "APPEND_GENERATOR"
|
| "APPEND_GENERATOR"
|
||||||
| "ASSUME_CALL"
|
| "ASSUME_CALL"
|
||||||
@ -136,8 +135,6 @@ export type OperationDescriptorType =
|
|||||||
| "UNKNOWN_ARRAY_METHOD_CALL"
|
| "UNKNOWN_ARRAY_METHOD_CALL"
|
||||||
| "UNKNOWN_ARRAY_METHOD_PROPERTY_CALL"
|
| "UNKNOWN_ARRAY_METHOD_PROPERTY_CALL"
|
||||||
| "UPDATE_INCREMENTOR"
|
| "UPDATE_INCREMENTOR"
|
||||||
| "WIDEN_ABSTRACT_PROPERTY"
|
|
||||||
| "WIDEN_ABSTRACT_PROPERTY_ASSIGNMENT"
|
|
||||||
| "WIDEN_PROPERTY"
|
| "WIDEN_PROPERTY"
|
||||||
| "WIDEN_PROPERTY_ASSIGNMENT"
|
| "WIDEN_PROPERTY_ASSIGNMENT"
|
||||||
| "WIDENED_IDENTIFIER";
|
| "WIDENED_IDENTIFIER";
|
||||||
@ -165,7 +162,6 @@ export type OperationDescriptorData = {
|
|||||||
prefix?: boolean,
|
prefix?: boolean,
|
||||||
path?: Value,
|
path?: Value,
|
||||||
propertyGetter?: SupportedGraphQLGetters,
|
propertyGetter?: SupportedGraphQLGetters,
|
||||||
propName?: string,
|
|
||||||
propRef?: ReferenceName | AbstractValue,
|
propRef?: ReferenceName | AbstractValue,
|
||||||
object?: ObjectValue,
|
object?: ObjectValue,
|
||||||
quasis?: Array<any>,
|
quasis?: Array<any>,
|
||||||
@ -173,7 +169,6 @@ export type OperationDescriptorData = {
|
|||||||
thisArg?: BaseValue | Value,
|
thisArg?: BaseValue | Value,
|
||||||
template?: PreludeGenerator => ({}) => BabelNodeExpression,
|
template?: PreludeGenerator => ({}) => BabelNodeExpression,
|
||||||
typeComparisons?: Set<typeof Value>,
|
typeComparisons?: Set<typeof Value>,
|
||||||
typeofString?: string,
|
|
||||||
usesThis?: boolean,
|
usesThis?: boolean,
|
||||||
value?: Value,
|
value?: Value,
|
||||||
violationConditionOperationDescriptor?: OperationDescriptor,
|
violationConditionOperationDescriptor?: OperationDescriptor,
|
||||||
@ -757,22 +752,22 @@ export class Generator {
|
|||||||
|
|
||||||
emitGlobalAssignment(key: string, value: Value): void {
|
emitGlobalAssignment(key: string, value: Value): void {
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: [value],
|
args: [value, new StringValue(this.realm, key)],
|
||||||
operationDescriptor: createOperationDescriptor("GLOBAL_ASSIGNMENT", { propName: key }),
|
operationDescriptor: createOperationDescriptor("GLOBAL_ASSIGNMENT"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
emitConcreteModel(key: string, value: Value): void {
|
emitConcreteModel(key: string, value: Value): void {
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: [concretize(this.realm, value)],
|
args: [concretize(this.realm, value), new StringValue(this.realm, key)],
|
||||||
operationDescriptor: createOperationDescriptor("CONCRETE_MODEL", { propName: key }),
|
operationDescriptor: createOperationDescriptor("CONCRETE_MODEL"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
emitGlobalDelete(key: string): void {
|
emitGlobalDelete(key: string): void {
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: [],
|
args: [new StringValue(this.realm, key)],
|
||||||
operationDescriptor: createOperationDescriptor("GLOBAL_DELETE", { propName: key }),
|
operationDescriptor: createOperationDescriptor("GLOBAL_DELETE"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,8 +778,8 @@ export class Generator {
|
|||||||
emitPropertyAssignment(object: ObjectValue, key: string, value: Value): void {
|
emitPropertyAssignment(object: ObjectValue, key: string, value: Value): void {
|
||||||
if (object.refuseSerialization) return;
|
if (object.refuseSerialization) return;
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: [object, value],
|
args: [object, value, new StringValue(this.realm, key)],
|
||||||
operationDescriptor: createOperationDescriptor("EMIT_PROPERTY_ASSIGNMENT", { propName: key, value }),
|
operationDescriptor: createOperationDescriptor("EMIT_PROPERTY_ASSIGNMENT", { value }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,12 +795,13 @@ export class Generator {
|
|||||||
invariant(descValue instanceof Value);
|
invariant(descValue instanceof Value);
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: [
|
args: [
|
||||||
|
new StringValue(this.realm, key),
|
||||||
object,
|
object,
|
||||||
descValue,
|
descValue,
|
||||||
desc.get || object.$Realm.intrinsics.undefined,
|
desc.get || object.$Realm.intrinsics.undefined,
|
||||||
desc.set || object.$Realm.intrinsics.undefined,
|
desc.set || object.$Realm.intrinsics.undefined,
|
||||||
],
|
],
|
||||||
operationDescriptor: createOperationDescriptor("DEFINE_PROPERTY", { object, propName: key, desc }),
|
operationDescriptor: createOperationDescriptor("DEFINE_PROPERTY", { object, desc }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -813,8 +809,8 @@ export class Generator {
|
|||||||
emitPropertyDelete(object: ObjectValue, key: string): void {
|
emitPropertyDelete(object: ObjectValue, key: string): void {
|
||||||
if (object.refuseSerialization) return;
|
if (object.refuseSerialization) return;
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: [object],
|
args: [object, new StringValue(this.realm, key)],
|
||||||
operationDescriptor: createOperationDescriptor("PROPERTY_DELETE", { propName: key }),
|
operationDescriptor: createOperationDescriptor("PROPERTY_DELETE"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,8 +823,11 @@ export class Generator {
|
|||||||
|
|
||||||
emitConsoleLog(method: ConsoleMethodTypes, args: Array<string | ConcreteValue>): void {
|
emitConsoleLog(method: ConsoleMethodTypes, args: Array<string | ConcreteValue>): void {
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: args.map(v => (typeof v === "string" ? new StringValue(this.realm, v) : v)),
|
args: [
|
||||||
operationDescriptor: createOperationDescriptor("CONSOLE_LOG", { propName: method }),
|
new StringValue(this.realm, method),
|
||||||
|
...args.map(v => (typeof v === "string" ? new StringValue(this.realm, v) : v)),
|
||||||
|
],
|
||||||
|
operationDescriptor: createOperationDescriptor("CONSOLE_LOG"),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,9 +902,9 @@ export class Generator {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
this._emitInvariant(
|
this._emitInvariant(
|
||||||
[value, value],
|
[new StringValue(this.realm, key), value, value],
|
||||||
createOperationDescriptor("FULL_INVARIANT_ABSTRACT", { concreteComparisons, typeComparisons }),
|
createOperationDescriptor("FULL_INVARIANT_ABSTRACT", { concreteComparisons, typeComparisons }),
|
||||||
createOperationDescriptor("INVARIANT_APPEND", { propName: key })
|
createOperationDescriptor("INVARIANT_APPEND")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (value instanceof FunctionValue) {
|
} else if (value instanceof FunctionValue) {
|
||||||
@ -913,15 +912,15 @@ export class Generator {
|
|||||||
// as we like to use concrete functions in the model to model abstract behaviors.
|
// as we like to use concrete functions in the model to model abstract behaviors.
|
||||||
// These concrete functions do not have the right identity.
|
// These concrete functions do not have the right identity.
|
||||||
this._emitInvariant(
|
this._emitInvariant(
|
||||||
[object, value, object],
|
[new StringValue(this.realm, key), object, value, object],
|
||||||
createOperationDescriptor("FULL_INVARIANT_FUNCTION", { propName: key }),
|
createOperationDescriptor("FULL_INVARIANT_FUNCTION"),
|
||||||
createOperationDescriptor("INVARIANT_APPEND", { propName: key })
|
createOperationDescriptor("INVARIANT_APPEND")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this._emitInvariant(
|
this._emitInvariant(
|
||||||
[object, value, object],
|
[new StringValue(this.realm, key), object, value, object],
|
||||||
createOperationDescriptor("FULL_INVARIANT", { propName: key }),
|
createOperationDescriptor("FULL_INVARIANT"),
|
||||||
createOperationDescriptor("INVARIANT_APPEND", { propName: key })
|
createOperationDescriptor("INVARIANT_APPEND")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -933,9 +932,9 @@ export class Generator {
|
|||||||
): void {
|
): void {
|
||||||
if (object.refuseSerialization) return;
|
if (object.refuseSerialization) return;
|
||||||
this._emitInvariant(
|
this._emitInvariant(
|
||||||
[object, object],
|
[new StringValue(this.realm, key), object, object],
|
||||||
createOperationDescriptor("PROPERTY_INVARIANT", { state, propName: key }),
|
createOperationDescriptor("PROPERTY_INVARIANT", { state }),
|
||||||
createOperationDescriptor("INVARIANT_APPEND", { propName: key })
|
createOperationDescriptor("INVARIANT_APPEND")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1089,8 +1088,8 @@ export class Generator {
|
|||||||
// Verify that the types are as expected, a failure of this invariant
|
// Verify that the types are as expected, a failure of this invariant
|
||||||
// should mean the model is wrong.
|
// should mean the model is wrong.
|
||||||
this._emitInvariant(
|
this._emitInvariant(
|
||||||
[res, res],
|
[new StringValue(this.realm, typeofString), res, res],
|
||||||
createOperationDescriptor("DERIVED_ABSTRACT_INVARIANT", { typeofString }),
|
createOperationDescriptor("DERIVED_ABSTRACT_INVARIANT"),
|
||||||
createOperationDescriptor("SINGLE_ARG")
|
createOperationDescriptor("SINGLE_ARG")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1161,10 +1160,9 @@ export class Generator {
|
|||||||
this._entries.push(...other._entries);
|
this._entries.push(...other._entries);
|
||||||
} else {
|
} else {
|
||||||
this._addEntry({
|
this._addEntry({
|
||||||
args: [],
|
args: [new StringValue(this.realm, leadingComment)],
|
||||||
operationDescriptor: createOperationDescriptor("APPEND_GENERATOR", {
|
operationDescriptor: createOperationDescriptor("APPEND_GENERATOR", {
|
||||||
generator: other,
|
generator: other,
|
||||||
propName: leadingComment,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -249,8 +249,8 @@ export class ModuleTracer extends Tracer {
|
|||||||
result = AbstractValue.createTemporalFromBuildFunction(
|
result = AbstractValue.createTemporalFromBuildFunction(
|
||||||
realm,
|
realm,
|
||||||
Value,
|
Value,
|
||||||
[],
|
[new StringValue(realm, propName)],
|
||||||
createOperationDescriptor("MODULES_REQUIRE", { propName })
|
createOperationDescriptor("MODULES_REQUIRE")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
result = effects.result;
|
result = effects.result;
|
||||||
|
@ -518,8 +518,8 @@ export default class AbstractObjectValue extends AbstractValue {
|
|||||||
let propAbsVal = AbstractValue.createTemporalFromBuildFunction(
|
let propAbsVal = AbstractValue.createTemporalFromBuildFunction(
|
||||||
this.$Realm,
|
this.$Realm,
|
||||||
type,
|
type,
|
||||||
[ob],
|
[ob, new StringValue(this.$Realm, P)],
|
||||||
createOperationDescriptor("ABSTRACT_OBJECT_GET", { propertyGetter, propName: P }),
|
createOperationDescriptor("ABSTRACT_OBJECT_GET", { propertyGetter }),
|
||||||
{
|
{
|
||||||
skipInvariant: true,
|
skipInvariant: true,
|
||||||
isPure: true,
|
isPure: true,
|
||||||
@ -766,18 +766,15 @@ export default class AbstractObjectValue extends AbstractValue {
|
|||||||
let generator = this.$Realm.generator;
|
let generator = this.$Realm.generator;
|
||||||
invariant(generator);
|
invariant(generator);
|
||||||
|
|
||||||
if (P instanceof StringValue) {
|
|
||||||
P = P.value;
|
|
||||||
}
|
|
||||||
if (typeof P === "string") {
|
if (typeof P === "string") {
|
||||||
generator.emitStatement(
|
generator.emitStatement(
|
||||||
[Receiver, V],
|
[Receiver, new StringValue(this.$Realm, P), V],
|
||||||
createOperationDescriptor("ABSTRACT_OBJECT_SET_PARTIAL", { propName: P })
|
createOperationDescriptor("ABSTRACT_OBJECT_SET_PARTIAL")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Coercion can only have effects on anything reachable from the key.
|
// Coercion can only have effects on anything reachable from the key.
|
||||||
Havoc.value(this.$Realm, P);
|
Havoc.value(this.$Realm, P);
|
||||||
generator.emitStatement([Receiver, P, V], createOperationDescriptor("ABSTRACT_OBJECT_SET_PARTIAL_VALUE"));
|
generator.emitStatement([Receiver, P, V], createOperationDescriptor("ABSTRACT_OBJECT_SET_PARTIAL"));
|
||||||
}
|
}
|
||||||
return this.$Realm.intrinsics.undefined;
|
return this.$Realm.intrinsics.undefined;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user