Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Generalized adjacent join generator merge #2636

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"eslint-plugin-flowtype": "^2.40.0",
"eslint-plugin-header": "^1.0.0",
"eslint-plugin-prettier": "^2.1.2",
"flow-bin": "^0.83.0",
"flow-typed": "^2.3.0",
"graceful-fs": "^4.1.11",
"invariant": "^2.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/adapter/DebugAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { DebuggerError } from "./../common/DebuggerError.js";

/* An implementation of an debugger adapter adhering to the VSCode Debug protocol
* The adapter is responsible for communication between the UI and Prepack
*/
*/
class PrepackDebugSession extends DebugSession {
/**
* Creates a new debug adapter that is used for one debug session.
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/mock-ui/UISession.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const TWO_CRLF = "\r\n\r\n";
/* Represents one debugging session in the CLI.
* Read in user input from the command line, parses the input into commands,
* sends the commands to the adapter and process any responses
*/
*/
export class UISession {
constructor(proc: Process, args: DebuggerCLIArguments) {
this._proc = proc;
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/mock-ui/debugger-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { UISession } from "./UISession.js";
import type { DebuggerCLIArguments } from "./UISession.js";
/* The entry point to start up the debugger CLI
* Reads in command line arguments and starts up a UISession
*/
*/

function run(process, console) {
let args = readCLIArguments(process, console);
Expand Down
4 changes: 2 additions & 2 deletions src/methods/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ export function OrdinaryGet(
let descValue = !desc
? realm.intrinsics.undefined
: desc.value === undefined
? realm.intrinsics.undefined
: desc.value;
? realm.intrinsics.undefined
: desc.value;
invariant(descValue instanceof Value);

// 3. If desc is undefined, then
Expand Down
4 changes: 3 additions & 1 deletion src/methods/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export function hashUnary(op: BabelUnaryOperator, x: Hashable): number {
return (hashString(op) * 13) ^ x.getHash();
}

interface Equatable { equals(x: any): boolean }
interface Equatable {
equals(x: any): boolean;
}

export class HashSet<T: Equatable & Hashable> {
constructor(expectedEntries?: number = 32 * 1024) {
Expand Down
4 changes: 2 additions & 2 deletions src/methods/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ export class PropertiesImplementation {
let existingDescValue = !existingDescriptor
? realm.intrinsics.undefined
: existingDescriptor.value === undefined
? realm.intrinsics.undefined
: existingDescriptor.value;
? realm.intrinsics.undefined
: existingDescriptor.value;
invariant(existingDescValue instanceof Value);

// d. If existingDescriptor is not undefined, then
Expand Down
4 changes: 2 additions & 2 deletions src/react/reconcilation.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class Reconciler {
let effects;
try {
this.realm.react.activeReconciler = this;
effects = this.realm.wrapInGlobalEnv(
() => (this.realm.isInPureScope() ? funcCall() : this.realm.evaluateWithPureScope(funcCall))
effects = this.realm.wrapInGlobalEnv(() =>
this.realm.isInPureScope() ? funcCall() : this.realm.evaluateWithPureScope(funcCall)
);
} catch (e) {
this._handleComponentTreeRootFailure(e, evaluatedRootNode);
Expand Down
2 changes: 1 addition & 1 deletion src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export type PathType = {
export class PathConditions {
add(c: AbstractValue): void {}

equals(x: PathConditions): boolean {
equates(x: PathConditions): boolean {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,8 +1218,8 @@ export class Generator {
let [entryGenerator1, entryGenerator2] = operationDescriptor.data.generators;
let [thisLastEntryGenerator1, thisLastEntryGenerator2] = thisLastEntryOperationDescriptor.data.generators;
if (
entryGenerator1.pathConditions.equals(thisLastEntryGenerator1.pathConditions) &&
entryGenerator2.pathConditions.equals(thisLastEntryGenerator2.pathConditions)
entryGenerator1.pathConditions.equates(thisLastEntryGenerator1.pathConditions) &&
entryGenerator2.pathConditions.equates(thisLastEntryGenerator2.pathConditions)
) {
if (!entryGenerator1.empty())
entryGenerator1._entries.forEach(e => thisLastEntryGenerator1._entries.push(e));
Expand Down
6 changes: 3 additions & 3 deletions src/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export class Logger {
let message = object.properties.get("message");
console.error(
message &&
message.descriptor &&
message.descriptor instanceof PropertyDescriptor &&
message.descriptor.value instanceof StringValue
message.descriptor &&
message.descriptor instanceof PropertyDescriptor &&
message.descriptor.value instanceof StringValue
? message.descriptor.value.value
: "(no message available)"
);
Expand Down
37 changes: 14 additions & 23 deletions src/utils/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,21 @@ export class PathConditionsImplementation extends PathConditions {
this._failedNegativeImplications = undefined;
}

// It makes the strong assumption that, in order for 2 path conditions to be equal,
// the number of values must be the same, as well as their order.
// This might not always be the case, yielding false negatives?!
equals(x: PathConditions): boolean {
// this <=> x
equates(x: PathConditions): boolean {
invariant(x instanceof PathConditionsImplementation);
let conditionsAreEqual = () => {
if (this._assumedConditions.size !== x._assumedConditions.size) return false;
let thisConditions = Array.from(this._assumedConditions);
let xConditions = Array.from(x._assumedConditions);
let thisLength = thisConditions.length;
for (let i = 0; i < thisLength; i++) {
let thisCondition = thisConditions[i];
let xCondition = xConditions[i];
if (!thisCondition.equals(xCondition)) return false;
}
return true;
};
let baseConditionsAreEqual = () => {
if (this._baseConditions && !x._baseConditions) return false;
if (!this._baseConditions && x._baseConditions) return false;
if (this._baseConditions && x._baseConditions) return this._baseConditions.equals(x._baseConditions);
return true;
};
return this === x || (conditionsAreEqual() && baseConditionsAreEqual());
if (this === x) return true;
function* assumedConditionsDeep(pc: PathConditionsImplementation) {
for (let condition of pc._assumedConditions) yield condition;
if (pc._baseConditions !== undefined) yield* assumedConditionsDeep(pc._baseConditions);
}
for (let xCondition of assumedConditionsDeep(x)) {
if (!this.implies(xCondition)) return false;
}
for (let thisCondition of assumedConditionsDeep(this)) {
if (!x.implies(thisCondition)) return false;
}
return true;
}

isReadOnly(): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/values/AbstractObjectValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ export default class AbstractObjectValue extends AbstractValue {
Desc.configurable !== undefined
? Desc.configurable
: firstExistingDesc
? firstExistingDesc.configurable
: false,
? firstExistingDesc.configurable
: false,
});
let newVal = desc.value;
if (this.kind === "conditional") {
Expand Down
3 changes: 2 additions & 1 deletion test/react/FBMocks/fb8.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = this.__evaluatePureFunction(() => {
function App() {
return (
<span>
This contains a ReactRelay container:<WrappedApp />
This contains a ReactRelay container:
<WrappedApp />
</span>
);
}
Expand Down
4 changes: 3 additions & 1 deletion test/react/FBMocks/hacker-news.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ module.exports = this.__evaluatePureFunction(() => {
<tbody>
{// we use Array.from to tell the compiler that this
// is definitely an array object
Array.from(stories).map((story, i) => <Story story={story} rank={++i} key={story.id} />)}
Array.from(stories).map((story, i) => (
<Story story={story} rank={++i} key={story.id} />
))}
</tbody>
</table>
</td>
Expand Down
8 changes: 7 additions & 1 deletion test/react/FBMocks/repl-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ function Foo(props: { href: string }) {
{ href: props.href, name: "Third Item" },
];

return <div>{collection.map(item => <Bar {...item} />)}</div>;
return (
<div>
{collection.map(item => (
<Bar {...item} />
))}
</div>
);
}

// this is a special Prepack function hook
Expand Down
4 changes: 3 additions & 1 deletion test/react/FirstRenderOnly/get-derived-state-from-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Child2 extends React.Component {
render() {
return (
<React.Fragment>
{Array.from(this.props.items).map(item => <Child3 data={item} key={item.id} />)}
{Array.from(this.props.items).map(item => (
<Child3 data={item} key={item.id} />
))}
<span>{this.randomVar.text}</span>
</React.Fragment>
);
Expand Down
4 changes: 3 additions & 1 deletion test/react/FirstRenderOnly/get-derived-state-from-props2.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Child2 extends React.Component {
render() {
return (
<React.Fragment>
{Array.from(this.props.items).map(item => <Child3 data={item} key={item.id} />)}
{Array.from(this.props.items).map(item => (
<Child3 data={item} key={item.id} />
))}
<span>{this.randomVar.text}</span>
</React.Fragment>
);
Expand Down
4 changes: 3 additions & 1 deletion test/react/FirstRenderOnly/get-derived-state-from-props3.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Child2 extends React.Component {
render() {
return (
<React.Fragment>
{Array.from(this.props.items).map(item => <Child3 data={item} key={item.id} />)}
{Array.from(this.props.items).map(item => (
<Child3 data={item} key={item.id} />
))}
<span>{this.randomVar.text}</span>
</React.Fragment>
);
Expand Down
4 changes: 3 additions & 1 deletion test/react/FirstRenderOnly/get-derived-state-from-props4.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Child2 extends React.Component {
render() {
return (
<React.Fragment>
{Array.from(this.props.items).map(item => <Child3 data={item} key={item.id} />)}
{Array.from(this.props.items).map(item => (
<Child3 data={item} key={item.id} />
))}
<span>{this.randomVar.text}</span>
</React.Fragment>
);
Expand Down
4 changes: 3 additions & 1 deletion test/react/FirstRenderOnly/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Child2 extends React.Component {
render() {
return (
<React.Fragment>
{Array.from(this.props.items).map(item => <Child3 data={item} key={item.id} />)}
{Array.from(this.props.items).map(item => (
<Child3 data={item} key={item.id} />
))}
<span>{this.randomVar.text}</span>
</React.Fragment>
);
Expand Down
4 changes: 3 additions & 1 deletion test/react/FirstRenderOnly/will-mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Child2 extends React.Component {
render() {
return (
<React.Fragment>
{Array.from(this.props.items).map(item => <Child3 data={item} key={item.id} />)}
{Array.from(this.props.items).map(item => (
<Child3 data={item} key={item.id} />
))}
<span>{this.randomVar.text}</span>
</React.Fragment>
);
Expand Down
8 changes: 7 additions & 1 deletion test/react/FunctionalComponents/array-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ function A(props) {
}

function App(props) {
return <div>{Array.from(props.items).map(item => <A title={item.title} key={item.id} />)}</div>;
return (
<div>
{Array.from(props.items).map(item => (
<A title={item.title} key={item.id} />
))}
</div>
);
}

App.getTrials = function(renderer, Root) {
Expand Down
8 changes: 7 additions & 1 deletion test/react/FunctionalComponents/array-map2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ function A(props) {
}

function App(props) {
return <div>{Array.from(props.items, item => <A title={item.title} key={item.id} />)}</div>;
return (
<div>
{Array.from(props.items, item => (
<A title={item.title} key={item.id} />
))}
</div>
);
}

App.getTrials = function(renderer, Root) {
Expand Down
4 changes: 3 additions & 1 deletion test/react/ServerRendering/hacker-news.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ function StoryList({ stories }) {
<tbody>
{// we use Array.from to tell the compiler that this
// is definitely an array object
Array.from(stories).map((story, i) => <Story story={story} rank={++i} key={story.id} />)}
Array.from(stories).map((story, i) => (
<Story story={story} rank={++i} key={story.id} />
))}
</tbody>
</table>
</td>
Expand Down
12 changes: 7 additions & 5 deletions test/serializer/abstract/ListOperationsCommentBubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ function createAttributedComment(props) {
let ranges;

if (body && body.ranges) {
_ranges = body.ranges.filter(r => r.entity.__typename).map(r => ({
location: Number(r.offset),
length: Number(r.length),
decorationLine: r.entity.__typename.includes("User") ? "none" : "underline",
}));
_ranges = body.ranges
.filter(r => r.entity.__typename)
.map(r => ({
location: Number(r.offset),
length: Number(r.length),
decorationLine: r.entity.__typename.includes("User") ? "none" : "underline",
}));
} else {
_ranges = [];
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4172,6 +4172,11 @@ flat-cache@^1.2.1:
graceful-fs "^4.1.2"
write "^0.2.1"

flow-bin@^0.83.0:
version "0.83.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.83.0.tgz#fd26f5f95758d7701264b3f9a1e1a3d4cbcab1a9"
integrity sha512-1K83EL/U9Gh0BaXPKkZe6TRizSmNSKx9Wuws1c8gh7DJEwiburtCxYT+4o7in1+GnNEm3CZWnbnVV8n9HMpiDA==

flow-typed@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/flow-typed/-/flow-typed-2.3.0.tgz#0f8604faab60691b885024e16ec0e3256e3b680e"
Expand Down