babel-plugin-react-compiler 19.0.0-beta-63b359f-20241101 → 19.0.0-beta-0dec889-20241115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1081 -2210
- package/package.json +3 -2
- package/dist/tsconfig.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
@@ -125654,6 +125654,12 @@ function makeTemporaryIdentifier(id, loc) {
|
|
125654
125654
|
loc: loc,
|
125655
125655
|
};
|
125656
125656
|
}
|
125657
|
+
function forkTemporaryIdentifier(id, source) {
|
125658
|
+
return Object.assign(Object.assign({}, source), {
|
125659
|
+
mutableRange: {start: makeInstructionId(0), end: makeInstructionId(0)},
|
125660
|
+
id: id,
|
125661
|
+
});
|
125662
|
+
}
|
125657
125663
|
function makeIdentifierName(name) {
|
125658
125664
|
CompilerError.invariant(t__namespace.isValidIdentifier(name), {
|
125659
125665
|
reason: `Expected a valid identifier name`,
|
@@ -132800,7 +132806,7 @@ function lowerJsxElementName(builder, exprPath) {
|
|
132800
132806
|
}
|
132801
132807
|
}
|
132802
132808
|
function lowerJsxMemberExpression(builder, exprPath) {
|
132803
|
-
var _a, _b;
|
132809
|
+
var _a, _b, _c;
|
132804
132810
|
const loc =
|
132805
132811
|
(_a = exprPath.node.loc) !== null && _a !== void 0 ? _a : GeneratedSource;
|
132806
132812
|
const object = exprPath.get('object');
|
@@ -132814,7 +132820,15 @@ function lowerJsxMemberExpression(builder, exprPath) {
|
|
132814
132820
|
loc: (_b = object.node.loc) !== null && _b !== void 0 ? _b : null,
|
132815
132821
|
suggestions: null,
|
132816
132822
|
});
|
132817
|
-
|
132823
|
+
const kind = getLoadKind(builder, object);
|
132824
|
+
objectPlace = lowerValueToTemporary(builder, {
|
132825
|
+
kind: kind,
|
132826
|
+
place: lowerIdentifier(builder, object),
|
132827
|
+
loc:
|
132828
|
+
(_c = exprPath.node.loc) !== null && _c !== void 0
|
132829
|
+
? _c
|
132830
|
+
: GeneratedSource,
|
132831
|
+
});
|
132818
132832
|
}
|
132819
132833
|
const property = exprPath.get('property').node.name;
|
132820
132834
|
return lowerValueToTemporary(builder, {
|
@@ -136618,6 +136632,7 @@ const ReactElementSymbolSchema = z.object({
|
|
136618
136632
|
z.literal('react.element'),
|
136619
136633
|
z.literal('react.transitional.element'),
|
136620
136634
|
]),
|
136635
|
+
globalDevVar: z.string(),
|
136621
136636
|
});
|
136622
136637
|
const ExternalFunctionSchema = z.object({
|
136623
136638
|
source: z.string(),
|
@@ -136626,8 +136641,8 @@ const ExternalFunctionSchema = z.object({
|
|
136626
136641
|
const InstrumentationSchema = z
|
136627
136642
|
.object({
|
136628
136643
|
fn: ExternalFunctionSchema,
|
136629
|
-
gating: ExternalFunctionSchema.
|
136630
|
-
globalGating: z.string().
|
136644
|
+
gating: ExternalFunctionSchema.nullable(),
|
136645
|
+
globalGating: z.string().nullable(),
|
136631
136646
|
})
|
136632
136647
|
.refine(
|
136633
136648
|
opts => opts.gating != null || opts.globalGating != null,
|
@@ -136648,7 +136663,7 @@ const HookSchema = z.object({
|
|
136648
136663
|
transitiveMixedData: z.boolean().default(false),
|
136649
136664
|
});
|
136650
136665
|
const EnvironmentConfigSchema = z.object({
|
136651
|
-
customHooks: z.map(z.string(), HookSchema).
|
136666
|
+
customHooks: z.map(z.string(), HookSchema).default(new Map()),
|
136652
136667
|
moduleTypeProvider: z.nullable(z.function().args(z.string())).default(null),
|
136653
136668
|
customMacros: z.nullable(z.array(MacroSchema)).default(null),
|
136654
136669
|
enableResetCacheOnSourceFileChanges: z.boolean().default(false),
|
@@ -136657,9 +136672,8 @@ const EnvironmentConfigSchema = z.object({
|
|
136657
136672
|
enablePreserveExistingManualUseMemo: z.boolean().default(false),
|
136658
136673
|
enableForest: z.boolean().default(false),
|
136659
136674
|
enableUseTypeAnnotations: z.boolean().default(false),
|
136660
|
-
|
136661
|
-
|
136662
|
-
inlineJsxTransform: ReactElementSymbolSchema.nullish(),
|
136675
|
+
enableFunctionDependencyRewrite: z.boolean().default(true),
|
136676
|
+
inlineJsxTransform: ReactElementSymbolSchema.nullable().default(null),
|
136663
136677
|
validateHooksUsage: z.boolean().default(true),
|
136664
136678
|
validateRefAccessDuringRender: z.boolean().default(true),
|
136665
136679
|
validateNoSetStateInRender: z.boolean().default(true),
|
@@ -136670,26 +136684,60 @@ const EnvironmentConfigSchema = z.object({
|
|
136670
136684
|
validateBlocklistedImports: z.nullable(z.array(z.string())).default(null),
|
136671
136685
|
enableAssumeHooksFollowRulesOfReact: z.boolean().default(true),
|
136672
136686
|
enableTransitivelyFreezeFunctionExpressions: z.boolean().default(true),
|
136673
|
-
enableEmitFreeze: ExternalFunctionSchema.
|
136674
|
-
enableEmitHookGuards: ExternalFunctionSchema.
|
136687
|
+
enableEmitFreeze: ExternalFunctionSchema.nullable().default(null),
|
136688
|
+
enableEmitHookGuards: ExternalFunctionSchema.nullable().default(null),
|
136675
136689
|
enableInstructionReordering: z.boolean().default(false),
|
136676
136690
|
enableFunctionOutlining: z.boolean().default(true),
|
136677
136691
|
enableJsxOutlining: z.boolean().default(false),
|
136678
|
-
enableEmitInstrumentForget: InstrumentationSchema.
|
136692
|
+
enableEmitInstrumentForget: InstrumentationSchema.nullable().default(null),
|
136679
136693
|
assertValidMutableRanges: z.boolean().default(false),
|
136680
136694
|
enableChangeVariableCodegen: z.boolean().default(false),
|
136681
136695
|
enableMemoizationComments: z.boolean().default(false),
|
136682
136696
|
throwUnknownException__testonly: z.boolean().default(false),
|
136683
|
-
enableSharedRuntime__testonly: z.boolean().default(false),
|
136684
136697
|
enableTreatFunctionDepsAsConditional: z.boolean().default(false),
|
136685
136698
|
disableMemoizationForDebugging: z.boolean().default(false),
|
136686
|
-
enableChangeDetectionForDebugging:
|
136699
|
+
enableChangeDetectionForDebugging:
|
136700
|
+
ExternalFunctionSchema.nullable().default(null),
|
136687
136701
|
enableCustomTypeDefinitionForReanimated: z.boolean().default(false),
|
136688
136702
|
hookPattern: z.string().nullable().default(null),
|
136689
|
-
enableTreatRefLikeIdentifiersAsRefs: z.boolean().
|
136690
|
-
lowerContextAccess: ExternalFunctionSchema.
|
136703
|
+
enableTreatRefLikeIdentifiersAsRefs: z.boolean().default(false),
|
136704
|
+
lowerContextAccess: ExternalFunctionSchema.nullable().default(null),
|
136691
136705
|
});
|
136692
|
-
|
136706
|
+
const testComplexConfigDefaults = {
|
136707
|
+
validateNoCapitalizedCalls: [],
|
136708
|
+
enableChangeDetectionForDebugging: {
|
136709
|
+
source: 'react-compiler-runtime',
|
136710
|
+
importSpecifierName: '$structuralCheck',
|
136711
|
+
},
|
136712
|
+
enableEmitFreeze: {
|
136713
|
+
source: 'react-compiler-runtime',
|
136714
|
+
importSpecifierName: 'makeReadOnly',
|
136715
|
+
},
|
136716
|
+
enableEmitInstrumentForget: {
|
136717
|
+
fn: {
|
136718
|
+
source: 'react-compiler-runtime',
|
136719
|
+
importSpecifierName: 'useRenderCounter',
|
136720
|
+
},
|
136721
|
+
gating: {
|
136722
|
+
source: 'react-compiler-runtime',
|
136723
|
+
importSpecifierName: 'shouldInstrument',
|
136724
|
+
},
|
136725
|
+
globalGating: '__DEV__',
|
136726
|
+
},
|
136727
|
+
enableEmitHookGuards: {
|
136728
|
+
source: 'react-compiler-runtime',
|
136729
|
+
importSpecifierName: '$dispatcherGuard',
|
136730
|
+
},
|
136731
|
+
inlineJsxTransform: {
|
136732
|
+
elementSymbol: 'react.transitional.element',
|
136733
|
+
globalDevVar: 'DEV',
|
136734
|
+
},
|
136735
|
+
lowerContextAccess: {
|
136736
|
+
source: 'react-compiler-runtime',
|
136737
|
+
importSpecifierName: 'useContext_withSelector',
|
136738
|
+
},
|
136739
|
+
};
|
136740
|
+
function parseConfigPragmaForTests(pragma) {
|
136693
136741
|
const maybeConfig = {};
|
136694
136742
|
const defaultConfig = EnvironmentConfigSchema.parse({});
|
136695
136743
|
for (const token of pragma.split(' ')) {
|
@@ -136697,19 +136745,10 @@ function parseConfigPragma(pragma) {
|
|
136697
136745
|
continue;
|
136698
136746
|
}
|
136699
136747
|
const keyVal = token.slice(1);
|
136700
|
-
let [key, val] = keyVal.split(':');
|
136701
|
-
|
136702
|
-
|
136703
|
-
|
136704
|
-
}
|
136705
|
-
if (
|
136706
|
-
key === 'enableChangeDetectionForDebugging' &&
|
136707
|
-
(val === undefined || val === 'true')
|
136708
|
-
) {
|
136709
|
-
maybeConfig[key] = {
|
136710
|
-
source: 'react-compiler-runtime',
|
136711
|
-
importSpecifierName: '$structuralCheck',
|
136712
|
-
};
|
136748
|
+
let [key, val = undefined] = keyVal.split(':');
|
136749
|
+
const isSet = val === undefined || val === 'true';
|
136750
|
+
if (isSet && key in testComplexConfigDefaults) {
|
136751
|
+
maybeConfig[key] = testComplexConfigDefaults[key];
|
136713
136752
|
continue;
|
136714
136753
|
}
|
136715
136754
|
if (key === 'customMacros' && val) {
|
@@ -136723,15 +136762,6 @@ function parseConfigPragma(pragma) {
|
|
136723
136762
|
props.push({type: 'name', name: elt});
|
136724
136763
|
}
|
136725
136764
|
}
|
136726
|
-
console.log([
|
136727
|
-
valSplit[0],
|
136728
|
-
props
|
136729
|
-
.map(x => {
|
136730
|
-
var _a;
|
136731
|
-
return (_a = x.name) !== null && _a !== void 0 ? _a : '*';
|
136732
|
-
})
|
136733
|
-
.join('.'),
|
136734
|
-
]);
|
136735
136765
|
maybeConfig[key] = [[valSplit[0], props]];
|
136736
136766
|
}
|
136737
136767
|
continue;
|
@@ -136740,11 +136770,10 @@ function parseConfigPragma(pragma) {
|
|
136740
136770
|
continue;
|
136741
136771
|
}
|
136742
136772
|
if (val === undefined || val === 'true') {
|
136743
|
-
|
136773
|
+
maybeConfig[key] = true;
|
136744
136774
|
} else {
|
136745
|
-
|
136775
|
+
maybeConfig[key] = false;
|
136746
136776
|
}
|
136747
|
-
maybeConfig[key] = val;
|
136748
136777
|
}
|
136749
136778
|
const config = EnvironmentConfigSchema.safeParse(maybeConfig);
|
136750
136779
|
if (config.success) {
|
@@ -139834,7 +139863,7 @@ function findContextIdentifiers(func) {
|
|
139834
139863
|
const currentFn =
|
139835
139864
|
(_a = state.currentFn.at(-1)) !== null && _a !== void 0 ? _a : null;
|
139836
139865
|
if (path.isReferencedIdentifier()) {
|
139837
|
-
handleIdentifier(currentFn, state.identifiers, path);
|
139866
|
+
handleIdentifier$1(currentFn, state.identifiers, path);
|
139838
139867
|
}
|
139839
139868
|
},
|
139840
139869
|
},
|
@@ -139850,7 +139879,7 @@ function findContextIdentifiers(func) {
|
|
139850
139879
|
}
|
139851
139880
|
return result;
|
139852
139881
|
}
|
139853
|
-
function handleIdentifier(currentFn, identifiers, path) {
|
139882
|
+
function handleIdentifier$1(currentFn, identifiers, path) {
|
139854
139883
|
const name = path.node.name;
|
139855
139884
|
const binding = path.scope.getBinding(name);
|
139856
139885
|
if (binding == null) {
|
@@ -140863,6 +140892,9 @@ function deadCodeElimination(fn) {
|
|
140863
140892
|
}
|
140864
140893
|
}
|
140865
140894
|
}
|
140895
|
+
retainWhere(fn.context, contextVar =>
|
140896
|
+
state.isIdOrNameUsed(contextVar.identifier)
|
140897
|
+
);
|
140866
140898
|
}
|
140867
140899
|
let State$2 = class State {
|
140868
140900
|
constructor() {
|
@@ -141181,6 +141213,313 @@ function instructionMayThrow(instr) {
|
|
141181
141213
|
}
|
141182
141214
|
}
|
141183
141215
|
}
|
141216
|
+
function inlineJsxTransform(fn, inlineJsxTransformConfig) {
|
141217
|
+
var _a;
|
141218
|
+
const inlinedJsxDeclarations = new Map();
|
141219
|
+
for (const [_, currentBlock] of [...fn.body.blocks]) {
|
141220
|
+
let fallthroughBlockInstructions = null;
|
141221
|
+
const instructionCount = currentBlock.instructions.length;
|
141222
|
+
for (let i = 0; i < instructionCount; i++) {
|
141223
|
+
const instr = currentBlock.instructions[i];
|
141224
|
+
if (currentBlock.kind === 'value') {
|
141225
|
+
(_a = fn.env.logger) === null || _a === void 0
|
141226
|
+
? void 0
|
141227
|
+
: _a.logEvent(fn.env.filename, {
|
141228
|
+
kind: 'CompileDiagnostic',
|
141229
|
+
fnLoc: null,
|
141230
|
+
detail: {
|
141231
|
+
reason: 'JSX Inlining is not supported on value blocks',
|
141232
|
+
loc: instr.loc,
|
141233
|
+
},
|
141234
|
+
});
|
141235
|
+
continue;
|
141236
|
+
}
|
141237
|
+
switch (instr.value.kind) {
|
141238
|
+
case 'JsxExpression':
|
141239
|
+
case 'JsxFragment': {
|
141240
|
+
const currentBlockInstructions = currentBlock.instructions.slice(
|
141241
|
+
0,
|
141242
|
+
i
|
141243
|
+
);
|
141244
|
+
const thenBlockInstructions = currentBlock.instructions.slice(
|
141245
|
+
i,
|
141246
|
+
i + 1
|
141247
|
+
);
|
141248
|
+
const elseBlockInstructions = [];
|
141249
|
+
fallthroughBlockInstructions !== null &&
|
141250
|
+
fallthroughBlockInstructions !== void 0
|
141251
|
+
? fallthroughBlockInstructions
|
141252
|
+
: (fallthroughBlockInstructions = currentBlock.instructions.slice(
|
141253
|
+
i + 1
|
141254
|
+
));
|
141255
|
+
const fallthroughBlockId = fn.env.nextBlockId;
|
141256
|
+
const fallthroughBlock = {
|
141257
|
+
kind: currentBlock.kind,
|
141258
|
+
id: fallthroughBlockId,
|
141259
|
+
instructions: fallthroughBlockInstructions,
|
141260
|
+
terminal: currentBlock.terminal,
|
141261
|
+
preds: new Set(),
|
141262
|
+
phis: new Set(),
|
141263
|
+
};
|
141264
|
+
const varPlace = createTemporaryPlace(fn.env, instr.value.loc);
|
141265
|
+
promoteTemporary(varPlace.identifier);
|
141266
|
+
const varLValuePlace = createTemporaryPlace(fn.env, instr.value.loc);
|
141267
|
+
const thenVarPlace = Object.assign(Object.assign({}, varPlace), {
|
141268
|
+
identifier: forkTemporaryIdentifier(
|
141269
|
+
fn.env.nextIdentifierId,
|
141270
|
+
varPlace.identifier
|
141271
|
+
),
|
141272
|
+
});
|
141273
|
+
const elseVarPlace = Object.assign(Object.assign({}, varPlace), {
|
141274
|
+
identifier: forkTemporaryIdentifier(
|
141275
|
+
fn.env.nextIdentifierId,
|
141276
|
+
varPlace.identifier
|
141277
|
+
),
|
141278
|
+
});
|
141279
|
+
const varInstruction = {
|
141280
|
+
id: makeInstructionId(0),
|
141281
|
+
lvalue: Object.assign({}, varLValuePlace),
|
141282
|
+
value: {
|
141283
|
+
kind: 'DeclareLocal',
|
141284
|
+
lvalue: {
|
141285
|
+
place: Object.assign({}, varPlace),
|
141286
|
+
kind: InstructionKind.Let,
|
141287
|
+
},
|
141288
|
+
type: null,
|
141289
|
+
loc: instr.value.loc,
|
141290
|
+
},
|
141291
|
+
loc: instr.loc,
|
141292
|
+
};
|
141293
|
+
currentBlockInstructions.push(varInstruction);
|
141294
|
+
const devGlobalPlace = createTemporaryPlace(fn.env, instr.value.loc);
|
141295
|
+
const devGlobalInstruction = {
|
141296
|
+
id: makeInstructionId(0),
|
141297
|
+
lvalue: Object.assign(Object.assign({}, devGlobalPlace), {
|
141298
|
+
effect: exports.Effect.Mutate,
|
141299
|
+
}),
|
141300
|
+
value: {
|
141301
|
+
kind: 'LoadGlobal',
|
141302
|
+
binding: {
|
141303
|
+
kind: 'Global',
|
141304
|
+
name: inlineJsxTransformConfig.globalDevVar,
|
141305
|
+
},
|
141306
|
+
loc: instr.value.loc,
|
141307
|
+
},
|
141308
|
+
loc: instr.loc,
|
141309
|
+
};
|
141310
|
+
currentBlockInstructions.push(devGlobalInstruction);
|
141311
|
+
const thenBlockId = fn.env.nextBlockId;
|
141312
|
+
const elseBlockId = fn.env.nextBlockId;
|
141313
|
+
const ifTerminal = {
|
141314
|
+
kind: 'if',
|
141315
|
+
test: Object.assign(Object.assign({}, devGlobalPlace), {
|
141316
|
+
effect: exports.Effect.Read,
|
141317
|
+
}),
|
141318
|
+
consequent: thenBlockId,
|
141319
|
+
alternate: elseBlockId,
|
141320
|
+
fallthrough: fallthroughBlockId,
|
141321
|
+
loc: instr.loc,
|
141322
|
+
id: makeInstructionId(0),
|
141323
|
+
};
|
141324
|
+
currentBlock.instructions = currentBlockInstructions;
|
141325
|
+
currentBlock.terminal = ifTerminal;
|
141326
|
+
const thenBlock = {
|
141327
|
+
id: thenBlockId,
|
141328
|
+
instructions: thenBlockInstructions,
|
141329
|
+
kind: 'block',
|
141330
|
+
phis: new Set(),
|
141331
|
+
preds: new Set(),
|
141332
|
+
terminal: {
|
141333
|
+
kind: 'goto',
|
141334
|
+
block: fallthroughBlockId,
|
141335
|
+
variant: GotoVariant.Break,
|
141336
|
+
id: makeInstructionId(0),
|
141337
|
+
loc: instr.loc,
|
141338
|
+
},
|
141339
|
+
};
|
141340
|
+
fn.body.blocks.set(thenBlockId, thenBlock);
|
141341
|
+
const resassignElsePlace = createTemporaryPlace(
|
141342
|
+
fn.env,
|
141343
|
+
instr.value.loc
|
141344
|
+
);
|
141345
|
+
const reassignElseInstruction = {
|
141346
|
+
id: makeInstructionId(0),
|
141347
|
+
lvalue: Object.assign({}, resassignElsePlace),
|
141348
|
+
value: {
|
141349
|
+
kind: 'StoreLocal',
|
141350
|
+
lvalue: {place: elseVarPlace, kind: InstructionKind.Reassign},
|
141351
|
+
value: Object.assign({}, instr.lvalue),
|
141352
|
+
type: null,
|
141353
|
+
loc: instr.value.loc,
|
141354
|
+
},
|
141355
|
+
loc: instr.loc,
|
141356
|
+
};
|
141357
|
+
thenBlockInstructions.push(reassignElseInstruction);
|
141358
|
+
const elseBlockTerminal = {
|
141359
|
+
kind: 'goto',
|
141360
|
+
block: fallthroughBlockId,
|
141361
|
+
variant: GotoVariant.Break,
|
141362
|
+
id: makeInstructionId(0),
|
141363
|
+
loc: instr.loc,
|
141364
|
+
};
|
141365
|
+
const elseBlock = {
|
141366
|
+
id: elseBlockId,
|
141367
|
+
instructions: elseBlockInstructions,
|
141368
|
+
kind: 'block',
|
141369
|
+
phis: new Set(),
|
141370
|
+
preds: new Set(),
|
141371
|
+
terminal: elseBlockTerminal,
|
141372
|
+
};
|
141373
|
+
fn.body.blocks.set(elseBlockId, elseBlock);
|
141374
|
+
const {
|
141375
|
+
refProperty: refProperty,
|
141376
|
+
keyProperty: keyProperty,
|
141377
|
+
propsProperty: propsProperty,
|
141378
|
+
} = createPropsProperties(
|
141379
|
+
fn,
|
141380
|
+
instr,
|
141381
|
+
elseBlockInstructions,
|
141382
|
+
instr.value.kind === 'JsxExpression' ? instr.value.props : [],
|
141383
|
+
instr.value.children
|
141384
|
+
);
|
141385
|
+
const reactElementInstructionPlace = createTemporaryPlace(
|
141386
|
+
fn.env,
|
141387
|
+
instr.value.loc
|
141388
|
+
);
|
141389
|
+
const reactElementInstruction = {
|
141390
|
+
id: makeInstructionId(0),
|
141391
|
+
lvalue: Object.assign(
|
141392
|
+
Object.assign({}, reactElementInstructionPlace),
|
141393
|
+
{effect: exports.Effect.Store}
|
141394
|
+
),
|
141395
|
+
value: {
|
141396
|
+
kind: 'ObjectExpression',
|
141397
|
+
properties: [
|
141398
|
+
createSymbolProperty(
|
141399
|
+
fn,
|
141400
|
+
instr,
|
141401
|
+
elseBlockInstructions,
|
141402
|
+
'$$typeof',
|
141403
|
+
inlineJsxTransformConfig.elementSymbol
|
141404
|
+
),
|
141405
|
+
instr.value.kind === 'JsxExpression'
|
141406
|
+
? createTagProperty(
|
141407
|
+
fn,
|
141408
|
+
instr,
|
141409
|
+
elseBlockInstructions,
|
141410
|
+
instr.value.tag
|
141411
|
+
)
|
141412
|
+
: createSymbolProperty(
|
141413
|
+
fn,
|
141414
|
+
instr,
|
141415
|
+
elseBlockInstructions,
|
141416
|
+
'type',
|
141417
|
+
'react.fragment'
|
141418
|
+
),
|
141419
|
+
refProperty,
|
141420
|
+
keyProperty,
|
141421
|
+
propsProperty,
|
141422
|
+
],
|
141423
|
+
loc: instr.value.loc,
|
141424
|
+
},
|
141425
|
+
loc: instr.loc,
|
141426
|
+
};
|
141427
|
+
elseBlockInstructions.push(reactElementInstruction);
|
141428
|
+
const reassignConditionalInstruction = {
|
141429
|
+
id: makeInstructionId(0),
|
141430
|
+
lvalue: Object.assign(
|
141431
|
+
{},
|
141432
|
+
createTemporaryPlace(fn.env, instr.value.loc)
|
141433
|
+
),
|
141434
|
+
value: {
|
141435
|
+
kind: 'StoreLocal',
|
141436
|
+
lvalue: {
|
141437
|
+
place: Object.assign({}, elseVarPlace),
|
141438
|
+
kind: InstructionKind.Reassign,
|
141439
|
+
},
|
141440
|
+
value: Object.assign({}, reactElementInstruction.lvalue),
|
141441
|
+
type: null,
|
141442
|
+
loc: instr.value.loc,
|
141443
|
+
},
|
141444
|
+
loc: instr.loc,
|
141445
|
+
};
|
141446
|
+
elseBlockInstructions.push(reassignConditionalInstruction);
|
141447
|
+
const operands = new Map();
|
141448
|
+
operands.set(thenBlockId, Object.assign({}, elseVarPlace));
|
141449
|
+
operands.set(elseBlockId, Object.assign({}, thenVarPlace));
|
141450
|
+
const phiIdentifier = forkTemporaryIdentifier(
|
141451
|
+
fn.env.nextIdentifierId,
|
141452
|
+
varPlace.identifier
|
141453
|
+
);
|
141454
|
+
const phiPlace = Object.assign(
|
141455
|
+
Object.assign({}, createTemporaryPlace(fn.env, instr.value.loc)),
|
141456
|
+
{identifier: phiIdentifier}
|
141457
|
+
);
|
141458
|
+
const phis = new Set([
|
141459
|
+
{kind: 'Phi', operands: operands, place: phiPlace},
|
141460
|
+
]);
|
141461
|
+
fallthroughBlock.phis = phis;
|
141462
|
+
fn.body.blocks.set(fallthroughBlockId, fallthroughBlock);
|
141463
|
+
inlinedJsxDeclarations.set(instr.lvalue.identifier.declarationId, {
|
141464
|
+
identifier: phiIdentifier,
|
141465
|
+
blockIdsToIgnore: new Set([thenBlockId, elseBlockId]),
|
141466
|
+
});
|
141467
|
+
break;
|
141468
|
+
}
|
141469
|
+
case 'FunctionExpression':
|
141470
|
+
case 'ObjectMethod': {
|
141471
|
+
inlineJsxTransform(
|
141472
|
+
instr.value.loweredFunc.func,
|
141473
|
+
inlineJsxTransformConfig
|
141474
|
+
);
|
141475
|
+
break;
|
141476
|
+
}
|
141477
|
+
}
|
141478
|
+
}
|
141479
|
+
}
|
141480
|
+
for (const [blockId, block] of fn.body.blocks) {
|
141481
|
+
for (const instr of block.instructions) {
|
141482
|
+
mapInstructionOperands(instr, place =>
|
141483
|
+
handlePlace(place, blockId, inlinedJsxDeclarations)
|
141484
|
+
);
|
141485
|
+
mapInstructionLValues(instr, lvalue =>
|
141486
|
+
handlelValue(lvalue, blockId, inlinedJsxDeclarations)
|
141487
|
+
);
|
141488
|
+
mapInstructionValueOperands(instr.value, place =>
|
141489
|
+
handlePlace(place, blockId, inlinedJsxDeclarations)
|
141490
|
+
);
|
141491
|
+
}
|
141492
|
+
mapTerminalOperands(block.terminal, place =>
|
141493
|
+
handlePlace(place, blockId, inlinedJsxDeclarations)
|
141494
|
+
);
|
141495
|
+
if (block.terminal.kind === 'scope') {
|
141496
|
+
const scope = block.terminal.scope;
|
141497
|
+
for (const dep of scope.dependencies) {
|
141498
|
+
dep.identifier = handleIdentifier(
|
141499
|
+
dep.identifier,
|
141500
|
+
inlinedJsxDeclarations
|
141501
|
+
);
|
141502
|
+
}
|
141503
|
+
for (const [origId, decl] of [...scope.declarations]) {
|
141504
|
+
const newDecl = handleIdentifier(
|
141505
|
+
decl.identifier,
|
141506
|
+
inlinedJsxDeclarations
|
141507
|
+
);
|
141508
|
+
if (newDecl.id !== origId) {
|
141509
|
+
scope.declarations.delete(origId);
|
141510
|
+
scope.declarations.set(decl.identifier.id, {
|
141511
|
+
identifier: newDecl,
|
141512
|
+
scope: decl.scope,
|
141513
|
+
});
|
141514
|
+
}
|
141515
|
+
}
|
141516
|
+
}
|
141517
|
+
}
|
141518
|
+
reversePostorderBlocks(fn.body);
|
141519
|
+
markPredecessors(fn.body);
|
141520
|
+
markInstructionIds(fn.body);
|
141521
|
+
fixScopeAndIdentifierRanges(fn.body);
|
141522
|
+
}
|
141184
141523
|
function createSymbolProperty(
|
141185
141524
|
fn,
|
141186
141525
|
instr,
|
@@ -141473,152 +141812,65 @@ function createPropsProperties(
|
|
141473
141812
|
propsProperty: propsProperty,
|
141474
141813
|
};
|
141475
141814
|
}
|
141476
|
-
function
|
141477
|
-
|
141478
|
-
|
141479
|
-
|
141480
|
-
|
141481
|
-
|
141482
|
-
|
141483
|
-
|
141484
|
-
|
141485
|
-
|
141486
|
-
|
141487
|
-
|
141488
|
-
|
141489
|
-
|
141490
|
-
|
141491
|
-
|
141492
|
-
|
141493
|
-
|
141494
|
-
|
141495
|
-
|
141496
|
-
|
141497
|
-
|
141498
|
-
|
141499
|
-
|
141500
|
-
|
141501
|
-
|
141502
|
-
|
141503
|
-
|
141504
|
-
|
141505
|
-
|
141506
|
-
|
141507
|
-
|
141508
|
-
|
141509
|
-
|
141510
|
-
|
141511
|
-
|
141512
|
-
|
141513
|
-
|
141514
|
-
|
141515
|
-
|
141516
|
-
|
141517
|
-
|
141518
|
-
|
141519
|
-
|
141520
|
-
|
141521
|
-
|
141522
|
-
|
141523
|
-
|
141524
|
-
|
141525
|
-
|
141526
|
-
|
141527
|
-
|
141528
|
-
|
141529
|
-
|
141530
|
-
|
141531
|
-
|
141532
|
-
|
141533
|
-
|
141534
|
-
|
141535
|
-
nextInstructions,
|
141536
|
-
[],
|
141537
|
-
instr.value.children
|
141538
|
-
);
|
141539
|
-
const reactElementInstruction = {
|
141540
|
-
id: makeInstructionId(0),
|
141541
|
-
lvalue: Object.assign(Object.assign({}, instr.lvalue), {
|
141542
|
-
effect: exports.Effect.Store,
|
141543
|
-
}),
|
141544
|
-
value: {
|
141545
|
-
kind: 'ObjectExpression',
|
141546
|
-
properties: [
|
141547
|
-
createSymbolProperty(
|
141548
|
-
fn,
|
141549
|
-
instr,
|
141550
|
-
nextInstructions,
|
141551
|
-
'$$typeof',
|
141552
|
-
inlineJsxTransformConfig.elementSymbol
|
141553
|
-
),
|
141554
|
-
createSymbolProperty(
|
141555
|
-
fn,
|
141556
|
-
instr,
|
141557
|
-
nextInstructions,
|
141558
|
-
'type',
|
141559
|
-
'react.fragment'
|
141560
|
-
),
|
141561
|
-
refProperty,
|
141562
|
-
keyProperty,
|
141563
|
-
propsProperty,
|
141564
|
-
],
|
141565
|
-
loc: instr.value.loc,
|
141566
|
-
},
|
141567
|
-
loc: instr.loc,
|
141568
|
-
};
|
141569
|
-
nextInstructions.push(reactElementInstruction);
|
141570
|
-
break;
|
141571
|
-
}
|
141572
|
-
case 'FunctionExpression':
|
141573
|
-
case 'ObjectMethod': {
|
141574
|
-
inlineJsxTransform(
|
141575
|
-
instr.value.loweredFunc.func,
|
141576
|
-
inlineJsxTransformConfig
|
141577
|
-
);
|
141578
|
-
if (nextInstructions !== null) {
|
141579
|
-
nextInstructions.push(instr);
|
141580
|
-
}
|
141581
|
-
break;
|
141582
|
-
}
|
141583
|
-
default: {
|
141584
|
-
if (nextInstructions !== null) {
|
141585
|
-
nextInstructions.push(instr);
|
141586
|
-
}
|
141587
|
-
}
|
141588
|
-
}
|
141589
|
-
}
|
141590
|
-
if (nextInstructions !== null) {
|
141591
|
-
block.instructions = nextInstructions;
|
141592
|
-
}
|
141593
|
-
}
|
141594
|
-
reversePostorderBlocks(fn.body);
|
141595
|
-
markPredecessors(fn.body);
|
141596
|
-
markInstructionIds(fn.body);
|
141597
|
-
fixScopeAndIdentifierRanges(fn.body);
|
141598
|
-
}
|
141599
|
-
function findScopesToMerge(fn) {
|
141600
|
-
const objectMethodDecls = new Set();
|
141601
|
-
const mergeScopesBuilder = new DisjointSet();
|
141602
|
-
for (const [_, block] of fn.body.blocks) {
|
141603
|
-
for (const {lvalue: lvalue, value: value} of block.instructions) {
|
141604
|
-
if (value.kind === 'ObjectMethod') {
|
141605
|
-
objectMethodDecls.add(lvalue.identifier);
|
141606
|
-
} else if (value.kind === 'ObjectExpression') {
|
141607
|
-
for (const operand of eachInstructionValueOperand(value)) {
|
141608
|
-
if (objectMethodDecls.has(operand.identifier)) {
|
141609
|
-
const operandScope = operand.identifier.scope;
|
141610
|
-
const lvalueScope = lvalue.identifier.scope;
|
141611
|
-
CompilerError.invariant(
|
141612
|
-
operandScope != null && lvalueScope != null,
|
141613
|
-
{
|
141614
|
-
reason:
|
141615
|
-
'Internal error: Expected all ObjectExpressions and ObjectMethods to have non-null scope.',
|
141616
|
-
suggestions: null,
|
141617
|
-
loc: GeneratedSource,
|
141618
|
-
}
|
141619
|
-
);
|
141620
|
-
mergeScopesBuilder.union([operandScope, lvalueScope]);
|
141621
|
-
}
|
141815
|
+
function handlePlace(place, blockId, inlinedJsxDeclarations) {
|
141816
|
+
const inlinedJsxDeclaration = inlinedJsxDeclarations.get(
|
141817
|
+
place.identifier.declarationId
|
141818
|
+
);
|
141819
|
+
if (
|
141820
|
+
inlinedJsxDeclaration == null ||
|
141821
|
+
inlinedJsxDeclaration.blockIdsToIgnore.has(blockId)
|
141822
|
+
) {
|
141823
|
+
return place;
|
141824
|
+
}
|
141825
|
+
return Object.assign(Object.assign({}, place), {
|
141826
|
+
identifier: inlinedJsxDeclaration.identifier,
|
141827
|
+
});
|
141828
|
+
}
|
141829
|
+
function handlelValue(lvalue, blockId, inlinedJsxDeclarations) {
|
141830
|
+
const inlinedJsxDeclaration = inlinedJsxDeclarations.get(
|
141831
|
+
lvalue.identifier.declarationId
|
141832
|
+
);
|
141833
|
+
if (
|
141834
|
+
inlinedJsxDeclaration == null ||
|
141835
|
+
inlinedJsxDeclaration.blockIdsToIgnore.has(blockId)
|
141836
|
+
) {
|
141837
|
+
return lvalue;
|
141838
|
+
}
|
141839
|
+
return Object.assign(Object.assign({}, lvalue), {
|
141840
|
+
identifier: inlinedJsxDeclaration.identifier,
|
141841
|
+
});
|
141842
|
+
}
|
141843
|
+
function handleIdentifier(identifier, inlinedJsxDeclarations) {
|
141844
|
+
const inlinedJsxDeclaration = inlinedJsxDeclarations.get(
|
141845
|
+
identifier.declarationId
|
141846
|
+
);
|
141847
|
+
return inlinedJsxDeclaration == null
|
141848
|
+
? identifier
|
141849
|
+
: inlinedJsxDeclaration.identifier;
|
141850
|
+
}
|
141851
|
+
function findScopesToMerge(fn) {
|
141852
|
+
const objectMethodDecls = new Set();
|
141853
|
+
const mergeScopesBuilder = new DisjointSet();
|
141854
|
+
for (const [_, block] of fn.body.blocks) {
|
141855
|
+
for (const {lvalue: lvalue, value: value} of block.instructions) {
|
141856
|
+
if (value.kind === 'ObjectMethod') {
|
141857
|
+
objectMethodDecls.add(lvalue.identifier);
|
141858
|
+
} else if (value.kind === 'ObjectExpression') {
|
141859
|
+
for (const operand of eachInstructionValueOperand(value)) {
|
141860
|
+
if (objectMethodDecls.has(operand.identifier)) {
|
141861
|
+
const operandScope = operand.identifier.scope;
|
141862
|
+
const lvalueScope = lvalue.identifier.scope;
|
141863
|
+
CompilerError.invariant(
|
141864
|
+
operandScope != null && lvalueScope != null,
|
141865
|
+
{
|
141866
|
+
reason:
|
141867
|
+
'Internal error: Expected all ObjectExpressions and ObjectMethods to have non-null scope.',
|
141868
|
+
suggestions: null,
|
141869
|
+
loc: GeneratedSource,
|
141870
|
+
}
|
141871
|
+
);
|
141872
|
+
mergeScopesBuilder.union([operandScope, lvalueScope]);
|
141873
|
+
}
|
141622
141874
|
}
|
141623
141875
|
}
|
141624
141876
|
}
|
@@ -142254,7 +142506,7 @@ var _Context_nextScheduleId,
|
|
142254
142506
|
_Context_catchHandlers,
|
142255
142507
|
_Context_controlFlowStack;
|
142256
142508
|
function buildReactiveFunction(fn) {
|
142257
|
-
const cx = new Context$
|
142509
|
+
const cx = new Context$2(fn.body);
|
142258
142510
|
const driver = new Driver(cx);
|
142259
142511
|
const body = driver.traverseBlock(cx.block(fn.body.entry));
|
142260
142512
|
return {
|
@@ -143302,7 +143554,7 @@ class Driver {
|
|
143302
143554
|
};
|
143303
143555
|
}
|
143304
143556
|
}
|
143305
|
-
let Context$
|
143557
|
+
let Context$2 = class Context {
|
143306
143558
|
constructor(ir) {
|
143307
143559
|
_Context_nextScheduleId.set(this, 0);
|
143308
143560
|
this.emitted = new Set();
|
@@ -143682,7 +143934,7 @@ function expandFbtScopeRange(fbtRange, extendWith) {
|
|
143682
143934
|
);
|
143683
143935
|
}
|
143684
143936
|
}
|
143685
|
-
var _Context_nextCacheIndex, _Context_declarations$
|
143937
|
+
var _Context_nextCacheIndex, _Context_declarations$1;
|
143686
143938
|
const MEMO_CACHE_SENTINEL = 'react.memo_cache_sentinel';
|
143687
143939
|
const EARLY_RETURN_SENTINEL = 'react.early_return_sentinel';
|
143688
143940
|
function codegenFunction(
|
@@ -143690,7 +143942,7 @@ function codegenFunction(
|
|
143690
143942
|
{uniqueIdentifiers: uniqueIdentifiers, fbtOperands: fbtOperands}
|
143691
143943
|
) {
|
143692
143944
|
var _a, _b, _c;
|
143693
|
-
const cx = new Context$
|
143945
|
+
const cx = new Context$1(
|
143694
143946
|
fn.env,
|
143695
143947
|
(_a = fn.id) !== null && _a !== void 0 ? _a : '[[ anonymous ]]',
|
143696
143948
|
uniqueIdentifiers,
|
@@ -143855,7 +144107,7 @@ function codegenFunction(
|
|
143855
144107
|
pruneHoistedContexts(reactiveFunction);
|
143856
144108
|
const identifiers = renameVariables(reactiveFunction);
|
143857
144109
|
const codegen = codegenReactiveFunction(
|
143858
|
-
new Context$
|
144110
|
+
new Context$1(
|
143859
144111
|
cx.env,
|
143860
144112
|
(_c = reactiveFunction.id) !== null && _c !== void 0
|
143861
144113
|
? _c
|
@@ -143942,10 +144194,10 @@ function convertParameter(param) {
|
|
143942
144194
|
return t__namespace.restElement(convertIdentifier(param.place.identifier));
|
143943
144195
|
}
|
143944
144196
|
}
|
143945
|
-
let Context$
|
144197
|
+
let Context$1 = class Context {
|
143946
144198
|
constructor(env, fnName, uniqueIdentifiers, fbtOperands, temporaries = null) {
|
143947
144199
|
_Context_nextCacheIndex.set(this, 0);
|
143948
|
-
_Context_declarations$
|
144200
|
+
_Context_declarations$1.set(this, new Set());
|
143949
144201
|
this.errors = new CompilerError();
|
143950
144202
|
this.objectMethods = new Map();
|
143951
144203
|
this.synthesizedNames = new Map();
|
@@ -143970,12 +144222,12 @@ let Context$2 = class Context {
|
|
143970
144222
|
);
|
143971
144223
|
}
|
143972
144224
|
declare(identifier) {
|
143973
|
-
__classPrivateFieldGet(this, _Context_declarations$
|
144225
|
+
__classPrivateFieldGet(this, _Context_declarations$1, 'f').add(
|
143974
144226
|
identifier.declarationId
|
143975
144227
|
);
|
143976
144228
|
}
|
143977
144229
|
hasDeclared(identifier) {
|
143978
|
-
return __classPrivateFieldGet(this, _Context_declarations$
|
144230
|
+
return __classPrivateFieldGet(this, _Context_declarations$1, 'f').has(
|
143979
144231
|
identifier.declarationId
|
143980
144232
|
);
|
143981
144233
|
}
|
@@ -143995,7 +144247,7 @@ let Context$2 = class Context {
|
|
143995
144247
|
}
|
143996
144248
|
};
|
143997
144249
|
(_Context_nextCacheIndex = new WeakMap()),
|
143998
|
-
(_Context_declarations$
|
144250
|
+
(_Context_declarations$1 = new WeakMap());
|
143999
144251
|
function codegenBlock(cx, block) {
|
144000
144252
|
const temp = new Map(cx.temp);
|
144001
144253
|
const result = codegenBlockNoReset(cx, block);
|
@@ -144088,7 +144340,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
144088
144340
|
const changeExpressions = [];
|
144089
144341
|
const changeExpressionComments = [];
|
144090
144342
|
const outputComments = [];
|
144091
|
-
for (const dep of scope.dependencies) {
|
144343
|
+
for (const dep of [...scope.dependencies].sort(compareScopeDependency)) {
|
144092
144344
|
const index = cx.nextCacheIndex;
|
144093
144345
|
changeExpressionComments.push(printDependencyComment(dep));
|
144094
144346
|
const comparison = t__namespace.binaryExpression(
|
@@ -144128,7 +144380,9 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
144128
144380
|
);
|
144129
144381
|
}
|
144130
144382
|
let firstOutputIndex = null;
|
144131
|
-
for (const [, {identifier: identifier}] of scope.declarations
|
144383
|
+
for (const [, {identifier: identifier}] of [...scope.declarations].sort(
|
144384
|
+
([, a], [, b]) => compareScopeDeclaration(a, b)
|
144385
|
+
)) {
|
144132
144386
|
const index = cx.nextCacheIndex;
|
144133
144387
|
if (firstOutputIndex === null) {
|
144134
144388
|
firstOutputIndex = index;
|
@@ -145271,7 +145525,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
145271
145525
|
pruneUnusedLabels(reactiveFunction);
|
145272
145526
|
pruneUnusedLValues(reactiveFunction);
|
145273
145527
|
const fn = codegenReactiveFunction(
|
145274
|
-
new Context$
|
145528
|
+
new Context$1(
|
145275
145529
|
cx.env,
|
145276
145530
|
(_e = reactiveFunction.id) !== null && _e !== void 0
|
145277
145531
|
? _e
|
@@ -145470,7 +145724,7 @@ function codegenInstructionValue(cx, instrValue) {
|
|
145470
145724
|
pruneUnusedLValues(reactiveFunction);
|
145471
145725
|
pruneHoistedContexts(reactiveFunction);
|
145472
145726
|
const fn = codegenReactiveFunction(
|
145473
|
-
new Context$
|
145727
|
+
new Context$1(
|
145474
145728
|
cx.env,
|
145475
145729
|
(_g = reactiveFunction.id) !== null && _g !== void 0
|
145476
145730
|
? _g
|
@@ -145939,6 +146193,50 @@ function convertIdentifier(identifier) {
|
|
145939
146193
|
);
|
145940
146194
|
return t__namespace.identifier(identifier.name.value);
|
145941
146195
|
}
|
146196
|
+
function compareScopeDependency(a, b) {
|
146197
|
+
var _a, _b;
|
146198
|
+
CompilerError.invariant(
|
146199
|
+
((_a = a.identifier.name) === null || _a === void 0 ? void 0 : _a.kind) ===
|
146200
|
+
'named' &&
|
146201
|
+
((_b = b.identifier.name) === null || _b === void 0
|
146202
|
+
? void 0
|
146203
|
+
: _b.kind) === 'named',
|
146204
|
+
{
|
146205
|
+
reason: '[Codegen] Expected named identifier for dependency',
|
146206
|
+
loc: a.identifier.loc,
|
146207
|
+
}
|
146208
|
+
);
|
146209
|
+
const aName = [
|
146210
|
+
a.identifier.name.value,
|
146211
|
+
...a.path.map(entry => `${entry.optional ? '?' : ''}${entry.property}`),
|
146212
|
+
].join('.');
|
146213
|
+
const bName = [
|
146214
|
+
b.identifier.name.value,
|
146215
|
+
...b.path.map(entry => `${entry.optional ? '?' : ''}${entry.property}`),
|
146216
|
+
].join('.');
|
146217
|
+
if (aName < bName) return -1;
|
146218
|
+
else if (aName > bName) return 1;
|
146219
|
+
else return 0;
|
146220
|
+
}
|
146221
|
+
function compareScopeDeclaration(a, b) {
|
146222
|
+
var _a, _b;
|
146223
|
+
CompilerError.invariant(
|
146224
|
+
((_a = a.identifier.name) === null || _a === void 0 ? void 0 : _a.kind) ===
|
146225
|
+
'named' &&
|
146226
|
+
((_b = b.identifier.name) === null || _b === void 0
|
146227
|
+
? void 0
|
146228
|
+
: _b.kind) === 'named',
|
146229
|
+
{
|
146230
|
+
reason: '[Codegen] Expected named identifier for declaration',
|
146231
|
+
loc: a.identifier.loc,
|
146232
|
+
}
|
146233
|
+
);
|
146234
|
+
const aName = a.identifier.name.value;
|
146235
|
+
const bName = b.identifier.name.value;
|
146236
|
+
if (aName < bName) return -1;
|
146237
|
+
else if (aName > bName) return 1;
|
146238
|
+
else return 0;
|
146239
|
+
}
|
145942
146240
|
function extractScopeDeclarationsFromDestructuring(fn) {
|
145943
146241
|
const state = new State$1(fn.env);
|
145944
146242
|
visitReactiveFunction(fn, new Visitor$9(), state);
|
@@ -146935,1651 +147233,42 @@ let Transform$3 = class Transform extends ReactiveFunctionTransform {
|
|
146935
147233
|
return {kind: 'keep'};
|
146936
147234
|
}
|
146937
147235
|
};
|
146938
|
-
|
146939
|
-
|
146940
|
-
|
146941
|
-
}
|
146942
|
-
class Node {
|
146943
|
-
constructor(value, next = EMPTY) {
|
146944
|
-
_Node_value.set(this, void 0);
|
146945
|
-
_Node_next.set(this, void 0);
|
146946
|
-
__classPrivateFieldSet(this, _Node_value, value, 'f');
|
146947
|
-
__classPrivateFieldSet(this, _Node_next, next, 'f');
|
146948
|
-
}
|
146949
|
-
push(value) {
|
146950
|
-
return new Node(value, this);
|
146951
|
-
}
|
146952
|
-
pop() {
|
146953
|
-
return __classPrivateFieldGet(this, _Node_next, 'f');
|
146954
|
-
}
|
146955
|
-
find(fn) {
|
146956
|
-
return fn(__classPrivateFieldGet(this, _Node_value, 'f'))
|
146957
|
-
? true
|
146958
|
-
: __classPrivateFieldGet(this, _Node_next, 'f').find(fn);
|
146959
|
-
}
|
146960
|
-
contains(value) {
|
146961
|
-
return (
|
146962
|
-
value === __classPrivateFieldGet(this, _Node_value, 'f') ||
|
146963
|
-
(__classPrivateFieldGet(this, _Node_next, 'f') !== null &&
|
146964
|
-
__classPrivateFieldGet(this, _Node_next, 'f').contains(value))
|
146965
|
-
);
|
146966
|
-
}
|
146967
|
-
each(fn) {
|
146968
|
-
fn(__classPrivateFieldGet(this, _Node_value, 'f'));
|
146969
|
-
__classPrivateFieldGet(this, _Node_next, 'f').each(fn);
|
146970
|
-
}
|
146971
|
-
get value() {
|
146972
|
-
return __classPrivateFieldGet(this, _Node_value, 'f');
|
146973
|
-
}
|
146974
|
-
print(fn) {
|
146975
|
-
return (
|
146976
|
-
fn(__classPrivateFieldGet(this, _Node_value, 'f')) +
|
146977
|
-
__classPrivateFieldGet(this, _Node_next, 'f').print(fn)
|
146978
|
-
);
|
146979
|
-
}
|
146980
|
-
}
|
146981
|
-
(_Node_value = new WeakMap()), (_Node_next = new WeakMap());
|
146982
|
-
class Empty {
|
146983
|
-
push(value) {
|
146984
|
-
return new Node(value, this);
|
146985
|
-
}
|
146986
|
-
pop() {
|
146987
|
-
return this;
|
146988
|
-
}
|
146989
|
-
find(_fn) {
|
146990
|
-
return false;
|
146991
|
-
}
|
146992
|
-
contains(_value) {
|
146993
|
-
return false;
|
146994
|
-
}
|
146995
|
-
each(_fn) {
|
146996
|
-
return;
|
146997
|
-
}
|
146998
|
-
get value() {
|
146999
|
-
return null;
|
147000
|
-
}
|
147001
|
-
print(_) {
|
147002
|
-
return '';
|
147003
|
-
}
|
147236
|
+
function pruneHoistedContexts(fn) {
|
147237
|
+
const hoistedIdentifiers = new Map();
|
147238
|
+
visitReactiveFunction(fn, new Visitor$8(), hoistedIdentifiers);
|
147004
147239
|
}
|
147005
|
-
|
147006
|
-
|
147007
|
-
|
147008
|
-
|
147009
|
-
|
147010
|
-
|
147011
|
-
|
147012
|
-
|
147013
|
-
|
147014
|
-
|
147015
|
-
add(dep, inConditional) {
|
147016
|
-
const {path: path} = dep;
|
147017
|
-
let currNode = __classPrivateFieldGet(
|
147018
|
-
this,
|
147019
|
-
_ReactiveScopeDependencyTree_instances,
|
147020
|
-
'm',
|
147021
|
-
_ReactiveScopeDependencyTree_getOrCreateRoot
|
147022
|
-
).call(this, dep.identifier);
|
147023
|
-
for (const item of path) {
|
147024
|
-
let currChild = getOrMakeProperty(currNode, item.property);
|
147025
|
-
const accessType = inConditional
|
147026
|
-
? PropertyAccessType$1.ConditionalAccess
|
147027
|
-
: item.optional
|
147028
|
-
? PropertyAccessType$1.OptionalAccess
|
147029
|
-
: PropertyAccessType$1.UnconditionalAccess;
|
147030
|
-
currChild.accessType = merge$1(currChild.accessType, accessType);
|
147031
|
-
currNode = currChild;
|
147032
|
-
}
|
147033
|
-
const depType = inConditional
|
147034
|
-
? PropertyAccessType$1.ConditionalDependency
|
147035
|
-
: isOptional$1(currNode.accessType)
|
147036
|
-
? PropertyAccessType$1.OptionalDependency
|
147037
|
-
: PropertyAccessType$1.UnconditionalDependency;
|
147038
|
-
currNode.accessType = merge$1(currNode.accessType, depType);
|
147039
|
-
}
|
147040
|
-
deriveMinimalDependencies() {
|
147041
|
-
const results = new Set();
|
147042
|
-
for (const [rootId, rootNode] of __classPrivateFieldGet(
|
147043
|
-
this,
|
147044
|
-
_ReactiveScopeDependencyTree_roots,
|
147045
|
-
'f'
|
147046
|
-
).entries()) {
|
147047
|
-
const deps = deriveMinimalDependenciesInSubtree(rootNode, null);
|
147048
|
-
CompilerError.invariant(
|
147049
|
-
deps.every(
|
147050
|
-
dep =>
|
147051
|
-
dep.accessType === PropertyAccessType$1.UnconditionalDependency ||
|
147052
|
-
dep.accessType == PropertyAccessType$1.OptionalDependency
|
147053
|
-
),
|
147054
|
-
{
|
147055
|
-
reason:
|
147056
|
-
'[PropagateScopeDependencies] All dependencies must be reduced to unconditional dependencies.',
|
147057
|
-
description: null,
|
147058
|
-
loc: null,
|
147059
|
-
suggestions: null,
|
147060
|
-
}
|
147240
|
+
let Visitor$8 = class Visitor extends ReactiveFunctionTransform {
|
147241
|
+
transformInstruction(instruction, state) {
|
147242
|
+
this.visitInstruction(instruction, state);
|
147243
|
+
if (
|
147244
|
+
instruction.value.kind === 'DeclareContext' &&
|
147245
|
+
instruction.value.lvalue.kind === 'HoistedConst'
|
147246
|
+
) {
|
147247
|
+
state.set(
|
147248
|
+
instruction.value.lvalue.place.identifier.declarationId,
|
147249
|
+
InstructionKind.Const
|
147061
147250
|
);
|
147062
|
-
|
147063
|
-
results.add({identifier: rootId, path: dep.relativePath});
|
147064
|
-
}
|
147065
|
-
}
|
147066
|
-
return results;
|
147067
|
-
}
|
147068
|
-
addDepsFromInnerScope(
|
147069
|
-
depsFromInnerScope,
|
147070
|
-
innerScopeInConditionalWithinParent,
|
147071
|
-
checkValidDepIdFn
|
147072
|
-
) {
|
147073
|
-
for (const [id, otherRoot] of __classPrivateFieldGet(
|
147074
|
-
depsFromInnerScope,
|
147075
|
-
_ReactiveScopeDependencyTree_roots,
|
147076
|
-
'f'
|
147077
|
-
)) {
|
147078
|
-
if (!checkValidDepIdFn({identifier: id, path: []})) {
|
147079
|
-
continue;
|
147080
|
-
}
|
147081
|
-
let currRoot = __classPrivateFieldGet(
|
147082
|
-
this,
|
147083
|
-
_ReactiveScopeDependencyTree_instances,
|
147084
|
-
'm',
|
147085
|
-
_ReactiveScopeDependencyTree_getOrCreateRoot
|
147086
|
-
).call(this, id);
|
147087
|
-
addSubtree(currRoot, otherRoot, innerScopeInConditionalWithinParent);
|
147088
|
-
if (!isUnconditional(currRoot.accessType)) {
|
147089
|
-
currRoot.accessType = isDependency$1(currRoot.accessType)
|
147090
|
-
? PropertyAccessType$1.UnconditionalDependency
|
147091
|
-
: PropertyAccessType$1.UnconditionalAccess;
|
147092
|
-
}
|
147251
|
+
return {kind: 'remove'};
|
147093
147252
|
}
|
147094
|
-
|
147095
|
-
|
147096
|
-
|
147097
|
-
|
147098
|
-
|
147099
|
-
|
147100
|
-
|
147101
|
-
|
147102
|
-
|
147103
|
-
this,
|
147104
|
-
_ReactiveScopeDependencyTree_roots,
|
147105
|
-
'f'
|
147106
|
-
)) {
|
147107
|
-
const nodesForRootId = mapNonNull(trees, tree => {
|
147108
|
-
const node = __classPrivateFieldGet(
|
147109
|
-
tree,
|
147110
|
-
_ReactiveScopeDependencyTree_roots,
|
147111
|
-
'f'
|
147112
|
-
).get(id);
|
147113
|
-
if (node != null && isUnconditional(node.accessType)) {
|
147114
|
-
return node;
|
147115
|
-
} else {
|
147116
|
-
return null;
|
147117
|
-
}
|
147118
|
-
});
|
147119
|
-
if (nodesForRootId) {
|
147120
|
-
addSubtreeIntersection(
|
147121
|
-
root.properties,
|
147122
|
-
nodesForRootId.map(root => root.properties)
|
147123
|
-
);
|
147124
|
-
}
|
147253
|
+
if (
|
147254
|
+
instruction.value.kind === 'DeclareContext' &&
|
147255
|
+
instruction.value.lvalue.kind === 'HoistedLet'
|
147256
|
+
) {
|
147257
|
+
state.set(
|
147258
|
+
instruction.value.lvalue.place.identifier.declarationId,
|
147259
|
+
InstructionKind.Let
|
147260
|
+
);
|
147261
|
+
return {kind: 'remove'};
|
147125
147262
|
}
|
147126
|
-
|
147127
|
-
|
147128
|
-
|
147129
|
-
|
147130
|
-
|
147131
|
-
|
147132
|
-
|
147133
|
-
).entries()) {
|
147134
|
-
const rootResults = printSubtree$1(rootNode, includeAccesses).map(
|
147135
|
-
result => `${printIdentifier(rootId)}.${result}`
|
147263
|
+
if (
|
147264
|
+
instruction.value.kind === 'DeclareContext' &&
|
147265
|
+
instruction.value.lvalue.kind === 'HoistedFunction'
|
147266
|
+
) {
|
147267
|
+
state.set(
|
147268
|
+
instruction.value.lvalue.place.identifier.declarationId,
|
147269
|
+
InstructionKind.Function
|
147136
147270
|
);
|
147137
|
-
|
147138
|
-
}
|
147139
|
-
return res.flat().join('\n');
|
147140
|
-
}
|
147141
|
-
debug() {
|
147142
|
-
const buf = [`tree() [`];
|
147143
|
-
for (const [rootId, rootNode] of __classPrivateFieldGet(
|
147144
|
-
this,
|
147145
|
-
_ReactiveScopeDependencyTree_roots,
|
147146
|
-
'f'
|
147147
|
-
)) {
|
147148
|
-
buf.push(`${printIdentifier(rootId)} (${rootNode.accessType}):`);
|
147149
|
-
__classPrivateFieldGet(
|
147150
|
-
this,
|
147151
|
-
_ReactiveScopeDependencyTree_instances,
|
147152
|
-
'm',
|
147153
|
-
_ReactiveScopeDependencyTree_debugImpl
|
147154
|
-
).call(this, buf, rootNode, 1);
|
147155
|
-
}
|
147156
|
-
buf.push(']');
|
147157
|
-
return buf.length > 2 ? buf.join('\n') : buf.join('');
|
147158
|
-
}
|
147159
|
-
}
|
147160
|
-
(_ReactiveScopeDependencyTree_roots = new WeakMap()),
|
147161
|
-
(_ReactiveScopeDependencyTree_instances = new WeakSet()),
|
147162
|
-
(_ReactiveScopeDependencyTree_getOrCreateRoot =
|
147163
|
-
function _ReactiveScopeDependencyTree_getOrCreateRoot(identifier) {
|
147164
|
-
let rootNode = __classPrivateFieldGet(
|
147165
|
-
this,
|
147166
|
-
_ReactiveScopeDependencyTree_roots,
|
147167
|
-
'f'
|
147168
|
-
).get(identifier);
|
147169
|
-
if (rootNode === undefined) {
|
147170
|
-
rootNode = {
|
147171
|
-
properties: new Map(),
|
147172
|
-
accessType: PropertyAccessType$1.UnconditionalAccess,
|
147173
|
-
};
|
147174
|
-
__classPrivateFieldGet(
|
147175
|
-
this,
|
147176
|
-
_ReactiveScopeDependencyTree_roots,
|
147177
|
-
'f'
|
147178
|
-
).set(identifier, rootNode);
|
147179
|
-
}
|
147180
|
-
return rootNode;
|
147181
|
-
}),
|
147182
|
-
(_ReactiveScopeDependencyTree_debugImpl =
|
147183
|
-
function _ReactiveScopeDependencyTree_debugImpl(buf, node, depth = 0) {
|
147184
|
-
for (const [property, childNode] of node.properties) {
|
147185
|
-
buf.push(
|
147186
|
-
`${' '.repeat(depth)}.${property} (${childNode.accessType}):`
|
147187
|
-
);
|
147188
|
-
__classPrivateFieldGet(
|
147189
|
-
this,
|
147190
|
-
_ReactiveScopeDependencyTree_instances,
|
147191
|
-
'm',
|
147192
|
-
_ReactiveScopeDependencyTree_debugImpl
|
147193
|
-
).call(this, buf, childNode, depth + 1);
|
147194
|
-
}
|
147195
|
-
});
|
147196
|
-
var PropertyAccessType$1;
|
147197
|
-
(function (PropertyAccessType) {
|
147198
|
-
PropertyAccessType['ConditionalAccess'] = 'ConditionalAccess';
|
147199
|
-
PropertyAccessType['OptionalAccess'] = 'OptionalAccess';
|
147200
|
-
PropertyAccessType['UnconditionalAccess'] = 'UnconditionalAccess';
|
147201
|
-
PropertyAccessType['ConditionalDependency'] = 'ConditionalDependency';
|
147202
|
-
PropertyAccessType['OptionalDependency'] = 'OptionalDependency';
|
147203
|
-
PropertyAccessType['UnconditionalDependency'] = 'UnconditionalDependency';
|
147204
|
-
})(PropertyAccessType$1 || (PropertyAccessType$1 = {}));
|
147205
|
-
const MIN_ACCESS_TYPE = PropertyAccessType$1.ConditionalAccess;
|
147206
|
-
function isUnconditional(access) {
|
147207
|
-
return (
|
147208
|
-
access === PropertyAccessType$1.UnconditionalAccess ||
|
147209
|
-
access === PropertyAccessType$1.UnconditionalDependency
|
147210
|
-
);
|
147211
|
-
}
|
147212
|
-
function isDependency$1(access) {
|
147213
|
-
return (
|
147214
|
-
access === PropertyAccessType$1.ConditionalDependency ||
|
147215
|
-
access === PropertyAccessType$1.OptionalDependency ||
|
147216
|
-
access === PropertyAccessType$1.UnconditionalDependency
|
147217
|
-
);
|
147218
|
-
}
|
147219
|
-
function isOptional$1(access) {
|
147220
|
-
return (
|
147221
|
-
access === PropertyAccessType$1.OptionalAccess ||
|
147222
|
-
access === PropertyAccessType$1.OptionalDependency
|
147223
|
-
);
|
147224
|
-
}
|
147225
|
-
function merge$1(access1, access2) {
|
147226
|
-
const resultIsUnconditional =
|
147227
|
-
isUnconditional(access1) || isUnconditional(access2);
|
147228
|
-
const resultIsDependency = isDependency$1(access1) || isDependency$1(access2);
|
147229
|
-
const resultIsOptional = isOptional$1(access1) || isOptional$1(access2);
|
147230
|
-
if (resultIsUnconditional) {
|
147231
|
-
if (resultIsDependency) {
|
147232
|
-
return PropertyAccessType$1.UnconditionalDependency;
|
147233
|
-
} else {
|
147234
|
-
return PropertyAccessType$1.UnconditionalAccess;
|
147235
|
-
}
|
147236
|
-
} else if (resultIsOptional) {
|
147237
|
-
if (resultIsDependency) {
|
147238
|
-
return PropertyAccessType$1.OptionalDependency;
|
147239
|
-
} else {
|
147240
|
-
return PropertyAccessType$1.OptionalAccess;
|
147241
|
-
}
|
147242
|
-
} else {
|
147243
|
-
if (resultIsDependency) {
|
147244
|
-
return PropertyAccessType$1.ConditionalDependency;
|
147245
|
-
} else {
|
147246
|
-
return PropertyAccessType$1.ConditionalAccess;
|
147247
|
-
}
|
147248
|
-
}
|
147249
|
-
}
|
147250
|
-
function promoteResult(accessType, path) {
|
147251
|
-
const result = {relativePath: [], accessType: accessType};
|
147252
|
-
if (path !== null) {
|
147253
|
-
result.relativePath.push(path);
|
147254
|
-
}
|
147255
|
-
return [result];
|
147256
|
-
}
|
147257
|
-
function prependPath(results, path) {
|
147258
|
-
if (path === null) {
|
147259
|
-
return results;
|
147260
|
-
}
|
147261
|
-
return results.map(result => ({
|
147262
|
-
accessType: result.accessType,
|
147263
|
-
relativePath: [path, ...result.relativePath],
|
147264
|
-
}));
|
147265
|
-
}
|
147266
|
-
function deriveMinimalDependenciesInSubtree(dep, property) {
|
147267
|
-
const results = [];
|
147268
|
-
for (const [childName, childNode] of dep.properties) {
|
147269
|
-
const childResult = deriveMinimalDependenciesInSubtree(
|
147270
|
-
childNode,
|
147271
|
-
childName
|
147272
|
-
);
|
147273
|
-
results.push(...childResult);
|
147274
|
-
}
|
147275
|
-
switch (dep.accessType) {
|
147276
|
-
case PropertyAccessType$1.UnconditionalDependency: {
|
147277
|
-
return promoteResult(
|
147278
|
-
PropertyAccessType$1.UnconditionalDependency,
|
147279
|
-
property !== null ? {property: property, optional: false} : null
|
147280
|
-
);
|
147281
|
-
}
|
147282
|
-
case PropertyAccessType$1.UnconditionalAccess: {
|
147283
|
-
if (
|
147284
|
-
results.every(
|
147285
|
-
({accessType: accessType}) =>
|
147286
|
-
accessType === PropertyAccessType$1.UnconditionalDependency ||
|
147287
|
-
accessType === PropertyAccessType$1.OptionalDependency
|
147288
|
-
)
|
147289
|
-
) {
|
147290
|
-
return prependPath(
|
147291
|
-
results,
|
147292
|
-
property !== null ? {property: property, optional: false} : null
|
147293
|
-
);
|
147294
|
-
} else {
|
147295
|
-
return promoteResult(
|
147296
|
-
PropertyAccessType$1.UnconditionalDependency,
|
147297
|
-
property !== null ? {property: property, optional: false} : null
|
147298
|
-
);
|
147299
|
-
}
|
147300
|
-
}
|
147301
|
-
case PropertyAccessType$1.OptionalDependency: {
|
147302
|
-
return promoteResult(
|
147303
|
-
PropertyAccessType$1.OptionalDependency,
|
147304
|
-
property !== null ? {property: property, optional: true} : null
|
147305
|
-
);
|
147306
|
-
}
|
147307
|
-
case PropertyAccessType$1.OptionalAccess: {
|
147308
|
-
if (
|
147309
|
-
results.every(
|
147310
|
-
({accessType: accessType}) =>
|
147311
|
-
accessType === PropertyAccessType$1.UnconditionalDependency ||
|
147312
|
-
accessType === PropertyAccessType$1.OptionalDependency
|
147313
|
-
)
|
147314
|
-
) {
|
147315
|
-
return prependPath(
|
147316
|
-
results,
|
147317
|
-
property !== null ? {property: property, optional: true} : null
|
147318
|
-
);
|
147319
|
-
} else {
|
147320
|
-
return promoteResult(
|
147321
|
-
PropertyAccessType$1.OptionalDependency,
|
147322
|
-
property !== null ? {property: property, optional: true} : null
|
147323
|
-
);
|
147324
|
-
}
|
147325
|
-
}
|
147326
|
-
case PropertyAccessType$1.ConditionalAccess:
|
147327
|
-
case PropertyAccessType$1.ConditionalDependency: {
|
147328
|
-
if (
|
147329
|
-
results.every(
|
147330
|
-
({accessType: accessType}) =>
|
147331
|
-
accessType === PropertyAccessType$1.ConditionalDependency
|
147332
|
-
)
|
147333
|
-
) {
|
147334
|
-
return promoteResult(
|
147335
|
-
PropertyAccessType$1.ConditionalDependency,
|
147336
|
-
property !== null ? {property: property, optional: true} : null
|
147337
|
-
);
|
147338
|
-
} else {
|
147339
|
-
return promoteResult(
|
147340
|
-
PropertyAccessType$1.UnconditionalDependency,
|
147341
|
-
property !== null ? {property: property, optional: true} : null
|
147342
|
-
);
|
147343
|
-
}
|
147344
|
-
}
|
147345
|
-
default: {
|
147346
|
-
assertExhaustive(
|
147347
|
-
dep.accessType,
|
147348
|
-
'[PropgateScopeDependencies] Unhandled access type!'
|
147349
|
-
);
|
147350
|
-
}
|
147351
|
-
}
|
147352
|
-
}
|
147353
|
-
function demoteSubtreeToConditional(subtree) {
|
147354
|
-
const stack = [subtree];
|
147355
|
-
let node;
|
147356
|
-
while ((node = stack.pop()) !== undefined) {
|
147357
|
-
const {accessType: accessType, properties: properties} = node;
|
147358
|
-
if (!isUnconditional(accessType)) {
|
147359
|
-
continue;
|
147360
|
-
}
|
147361
|
-
node.accessType = isDependency$1(accessType)
|
147362
|
-
? PropertyAccessType$1.ConditionalDependency
|
147363
|
-
: PropertyAccessType$1.ConditionalAccess;
|
147364
|
-
for (const childNode of properties.values()) {
|
147365
|
-
if (isUnconditional(accessType)) {
|
147366
|
-
stack.push(childNode);
|
147367
|
-
}
|
147368
|
-
}
|
147369
|
-
}
|
147370
|
-
}
|
147371
|
-
function addSubtree(currNode, otherNode, demoteOtherNode) {
|
147372
|
-
let otherType = otherNode.accessType;
|
147373
|
-
if (demoteOtherNode) {
|
147374
|
-
otherType = isDependency$1(otherType)
|
147375
|
-
? PropertyAccessType$1.ConditionalDependency
|
147376
|
-
: PropertyAccessType$1.ConditionalAccess;
|
147377
|
-
}
|
147378
|
-
currNode.accessType = merge$1(currNode.accessType, otherType);
|
147379
|
-
for (const [propertyName, otherChild] of otherNode.properties) {
|
147380
|
-
const currChild = currNode.properties.get(propertyName);
|
147381
|
-
if (currChild) {
|
147382
|
-
addSubtree(currChild, otherChild, demoteOtherNode);
|
147383
|
-
} else {
|
147384
|
-
if (demoteOtherNode) {
|
147385
|
-
demoteSubtreeToConditional(otherChild);
|
147386
|
-
}
|
147387
|
-
currNode.properties.set(propertyName, otherChild);
|
147388
|
-
}
|
147389
|
-
}
|
147390
|
-
}
|
147391
|
-
function addSubtreeIntersection(currProperties, otherProperties) {
|
147392
|
-
CompilerError.invariant(otherProperties.length > 1, {
|
147393
|
-
reason:
|
147394
|
-
'[DeriveMinimalDependencies] Expected otherProperties to be at least 2 elements long.',
|
147395
|
-
description: null,
|
147396
|
-
loc: null,
|
147397
|
-
suggestions: null,
|
147398
|
-
});
|
147399
|
-
for (const [propertyName, currNode] of currProperties) {
|
147400
|
-
const otherNodes = mapNonNull(otherProperties, properties => {
|
147401
|
-
const node = properties.get(propertyName);
|
147402
|
-
if (node != null && isUnconditional(node.accessType)) {
|
147403
|
-
return node;
|
147404
|
-
} else {
|
147405
|
-
return null;
|
147406
|
-
}
|
147407
|
-
});
|
147408
|
-
if (otherNodes) {
|
147409
|
-
addSubtreeIntersection(
|
147410
|
-
currNode.properties,
|
147411
|
-
otherNodes.map(node => node.properties)
|
147412
|
-
);
|
147413
|
-
const isDep = otherNodes.some(tree => isDependency$1(tree.accessType));
|
147414
|
-
const externalAccessType = isDep
|
147415
|
-
? PropertyAccessType$1.UnconditionalDependency
|
147416
|
-
: PropertyAccessType$1.UnconditionalAccess;
|
147417
|
-
currNode.accessType = merge$1(externalAccessType, currNode.accessType);
|
147418
|
-
}
|
147419
|
-
}
|
147420
|
-
}
|
147421
|
-
function printSubtree$1(node, includeAccesses) {
|
147422
|
-
const results = [];
|
147423
|
-
for (const [propertyName, propertyNode] of node.properties) {
|
147424
|
-
if (includeAccesses || isDependency$1(propertyNode.accessType)) {
|
147425
|
-
results.push(`${propertyName} (${propertyNode.accessType})`);
|
147426
|
-
}
|
147427
|
-
const propertyResults = printSubtree$1(propertyNode, includeAccesses);
|
147428
|
-
results.push(...propertyResults.map(result => `${propertyName}.${result}`));
|
147429
|
-
}
|
147430
|
-
return results;
|
147431
|
-
}
|
147432
|
-
function getOrMakeProperty(node, property) {
|
147433
|
-
let child = node.properties.get(property);
|
147434
|
-
if (child == null) {
|
147435
|
-
child = {properties: new Map(), accessType: MIN_ACCESS_TYPE};
|
147436
|
-
node.properties.set(property, child);
|
147437
|
-
}
|
147438
|
-
return child;
|
147439
|
-
}
|
147440
|
-
function mapNonNull(arr, fn) {
|
147441
|
-
const result = [];
|
147442
|
-
for (let i = 0; i < arr.length; i++) {
|
147443
|
-
const element = fn(arr[i]);
|
147444
|
-
if (element) {
|
147445
|
-
result.push(element);
|
147446
|
-
} else {
|
147447
|
-
return null;
|
147448
|
-
}
|
147449
|
-
}
|
147450
|
-
return result;
|
147451
|
-
}
|
147452
|
-
var _PoisonState_instances,
|
147453
|
-
_PoisonState_invalidate,
|
147454
|
-
_Context_instances$1,
|
147455
|
-
_Context_temporariesUsedOutsideScope$1,
|
147456
|
-
_Context_declarations$1,
|
147457
|
-
_Context_reassignments$1,
|
147458
|
-
_Context_dependencies$1,
|
147459
|
-
_Context_properties,
|
147460
|
-
_Context_temporaries$1,
|
147461
|
-
_Context_inConditionalWithinScope,
|
147462
|
-
_Context_depsInCurrentConditional,
|
147463
|
-
_Context_scopes$1,
|
147464
|
-
_Context_getProperty,
|
147465
|
-
_Context_checkValidDependency$1,
|
147466
|
-
_Context_isScopeActive$1;
|
147467
|
-
function propagateScopeDependencies(fn) {
|
147468
|
-
const escapingTemporaries = {
|
147469
|
-
declarations: new Map(),
|
147470
|
-
usedOutsideDeclaringScope: new Set(),
|
147471
|
-
};
|
147472
|
-
visitReactiveFunction(fn, new FindPromotedTemporaries(), escapingTemporaries);
|
147473
|
-
const context = new Context$1(escapingTemporaries.usedOutsideDeclaringScope);
|
147474
|
-
for (const param of fn.params) {
|
147475
|
-
if (param.kind === 'Identifier') {
|
147476
|
-
context.declare(param.identifier, {
|
147477
|
-
id: makeInstructionId(0),
|
147478
|
-
scope: empty(),
|
147479
|
-
});
|
147480
|
-
} else {
|
147481
|
-
context.declare(param.place.identifier, {
|
147482
|
-
id: makeInstructionId(0),
|
147483
|
-
scope: empty(),
|
147484
|
-
});
|
147485
|
-
}
|
147486
|
-
}
|
147487
|
-
visitReactiveFunction(fn, new PropagationVisitor(fn.env), context);
|
147488
|
-
}
|
147489
|
-
class FindPromotedTemporaries extends ReactiveFunctionVisitor {
|
147490
|
-
constructor() {
|
147491
|
-
super(...arguments);
|
147492
|
-
this.scopes = [];
|
147493
|
-
}
|
147494
|
-
visitScope(scope, state) {
|
147495
|
-
this.scopes.push(scope.scope.id);
|
147496
|
-
this.traverseScope(scope, state);
|
147497
|
-
this.scopes.pop();
|
147498
|
-
}
|
147499
|
-
visitInstruction(instruction, state) {
|
147500
|
-
this.traverseInstruction(instruction, state);
|
147501
|
-
const scope = this.scopes.at(-1);
|
147502
|
-
if (instruction.lvalue === null || scope === undefined) {
|
147503
|
-
return;
|
147504
|
-
}
|
147505
|
-
switch (instruction.value.kind) {
|
147506
|
-
case 'LoadLocal':
|
147507
|
-
case 'LoadContext':
|
147508
|
-
case 'PropertyLoad': {
|
147509
|
-
state.declarations.set(
|
147510
|
-
instruction.lvalue.identifier.declarationId,
|
147511
|
-
scope
|
147512
|
-
);
|
147513
|
-
break;
|
147514
|
-
}
|
147515
|
-
}
|
147516
|
-
}
|
147517
|
-
visitPlace(_id, place, state) {
|
147518
|
-
const declaringScope = state.declarations.get(
|
147519
|
-
place.identifier.declarationId
|
147520
|
-
);
|
147521
|
-
if (declaringScope === undefined) {
|
147522
|
-
return;
|
147523
|
-
}
|
147524
|
-
if (this.scopes.indexOf(declaringScope) === -1) {
|
147525
|
-
state.usedOutsideDeclaringScope.add(place.identifier.declarationId);
|
147526
|
-
}
|
147527
|
-
}
|
147528
|
-
}
|
147529
|
-
class PoisonState {
|
147530
|
-
constructor(poisonedBlocks, poisonedScopes, isPoisoned) {
|
147531
|
-
_PoisonState_instances.add(this);
|
147532
|
-
this.poisonedBlocks = new Set();
|
147533
|
-
this.poisonedScopes = new Set();
|
147534
|
-
this.isPoisoned = false;
|
147535
|
-
this.poisonedBlocks = poisonedBlocks;
|
147536
|
-
this.poisonedScopes = poisonedScopes;
|
147537
|
-
this.isPoisoned = isPoisoned;
|
147538
|
-
}
|
147539
|
-
clone() {
|
147540
|
-
return new PoisonState(
|
147541
|
-
new Set(this.poisonedBlocks),
|
147542
|
-
new Set(this.poisonedScopes),
|
147543
|
-
this.isPoisoned
|
147544
|
-
);
|
147545
|
-
}
|
147546
|
-
take(other) {
|
147547
|
-
const copy = new PoisonState(
|
147548
|
-
this.poisonedBlocks,
|
147549
|
-
this.poisonedScopes,
|
147550
|
-
this.isPoisoned
|
147551
|
-
);
|
147552
|
-
this.poisonedBlocks = other.poisonedBlocks;
|
147553
|
-
this.poisonedScopes = other.poisonedScopes;
|
147554
|
-
this.isPoisoned = other.isPoisoned;
|
147555
|
-
return copy;
|
147556
|
-
}
|
147557
|
-
merge(others, currentScope) {
|
147558
|
-
for (const other of others) {
|
147559
|
-
for (const id of other.poisonedBlocks) {
|
147560
|
-
this.poisonedBlocks.add(id);
|
147561
|
-
}
|
147562
|
-
for (const id of other.poisonedScopes) {
|
147563
|
-
this.poisonedScopes.add(id);
|
147564
|
-
}
|
147565
|
-
}
|
147566
|
-
__classPrivateFieldGet(
|
147567
|
-
this,
|
147568
|
-
_PoisonState_instances,
|
147569
|
-
'm',
|
147570
|
-
_PoisonState_invalidate
|
147571
|
-
).call(this, currentScope);
|
147572
|
-
}
|
147573
|
-
addPoisonTarget(target, activeScopes) {
|
147574
|
-
const currentScope = activeScopes.value;
|
147575
|
-
if (target == null && currentScope != null) {
|
147576
|
-
let cursor = activeScopes;
|
147577
|
-
while (true) {
|
147578
|
-
const next = cursor.pop();
|
147579
|
-
if (next.value == null) {
|
147580
|
-
const poisonedScope = cursor.value.value.id;
|
147581
|
-
this.poisonedScopes.add(poisonedScope);
|
147582
|
-
if (
|
147583
|
-
poisonedScope ===
|
147584
|
-
(currentScope === null || currentScope === void 0
|
147585
|
-
? void 0
|
147586
|
-
: currentScope.value.id)
|
147587
|
-
) {
|
147588
|
-
this.isPoisoned = true;
|
147589
|
-
}
|
147590
|
-
break;
|
147591
|
-
} else {
|
147592
|
-
cursor = next;
|
147593
|
-
}
|
147594
|
-
}
|
147595
|
-
} else if (target != null) {
|
147596
|
-
this.poisonedBlocks.add(target);
|
147597
|
-
if (
|
147598
|
-
!this.isPoisoned &&
|
147599
|
-
(currentScope === null || currentScope === void 0
|
147600
|
-
? void 0
|
147601
|
-
: currentScope.ownBlocks.find(blockId => blockId === target))
|
147602
|
-
) {
|
147603
|
-
this.isPoisoned = true;
|
147604
|
-
}
|
147605
|
-
}
|
147606
|
-
}
|
147607
|
-
removeMaybePoisonedScope(id, currentScope) {
|
147608
|
-
this.poisonedScopes.delete(id);
|
147609
|
-
__classPrivateFieldGet(
|
147610
|
-
this,
|
147611
|
-
_PoisonState_instances,
|
147612
|
-
'm',
|
147613
|
-
_PoisonState_invalidate
|
147614
|
-
).call(this, currentScope);
|
147615
|
-
}
|
147616
|
-
removeMaybePoisonedBlock(id, currentScope) {
|
147617
|
-
this.poisonedBlocks.delete(id);
|
147618
|
-
__classPrivateFieldGet(
|
147619
|
-
this,
|
147620
|
-
_PoisonState_instances,
|
147621
|
-
'm',
|
147622
|
-
_PoisonState_invalidate
|
147623
|
-
).call(this, currentScope);
|
147624
|
-
}
|
147625
|
-
}
|
147626
|
-
(_PoisonState_instances = new WeakSet()),
|
147627
|
-
(_PoisonState_invalidate = function _PoisonState_invalidate(currentScope) {
|
147628
|
-
if (currentScope != null) {
|
147629
|
-
if (this.poisonedScopes.has(currentScope.value.id)) {
|
147630
|
-
this.isPoisoned = true;
|
147631
|
-
return;
|
147632
|
-
} else if (
|
147633
|
-
currentScope.ownBlocks.find(blockId => this.poisonedBlocks.has(blockId))
|
147634
|
-
) {
|
147635
|
-
this.isPoisoned = true;
|
147636
|
-
return;
|
147637
|
-
}
|
147638
|
-
}
|
147639
|
-
this.isPoisoned = false;
|
147640
|
-
});
|
147641
|
-
let Context$1 = class Context {
|
147642
|
-
constructor(temporariesUsedOutsideScope) {
|
147643
|
-
_Context_instances$1.add(this);
|
147644
|
-
_Context_temporariesUsedOutsideScope$1.set(this, void 0);
|
147645
|
-
_Context_declarations$1.set(this, new Map());
|
147646
|
-
_Context_reassignments$1.set(this, new Map());
|
147647
|
-
_Context_dependencies$1.set(this, new ReactiveScopeDependencyTree());
|
147648
|
-
_Context_properties.set(this, new Map());
|
147649
|
-
_Context_temporaries$1.set(this, new Map());
|
147650
|
-
_Context_inConditionalWithinScope.set(this, false);
|
147651
|
-
_Context_depsInCurrentConditional.set(
|
147652
|
-
this,
|
147653
|
-
new ReactiveScopeDependencyTree()
|
147654
|
-
);
|
147655
|
-
_Context_scopes$1.set(this, empty());
|
147656
|
-
this.poisonState = new PoisonState(new Set(), new Set(), false);
|
147657
|
-
__classPrivateFieldSet(
|
147658
|
-
this,
|
147659
|
-
_Context_temporariesUsedOutsideScope$1,
|
147660
|
-
temporariesUsedOutsideScope,
|
147661
|
-
'f'
|
147662
|
-
);
|
147663
|
-
}
|
147664
|
-
enter(scope, fn) {
|
147665
|
-
const prevInConditional = __classPrivateFieldGet(
|
147666
|
-
this,
|
147667
|
-
_Context_inConditionalWithinScope,
|
147668
|
-
'f'
|
147669
|
-
);
|
147670
|
-
const previousDependencies = __classPrivateFieldGet(
|
147671
|
-
this,
|
147672
|
-
_Context_dependencies$1,
|
147673
|
-
'f'
|
147674
|
-
);
|
147675
|
-
const prevDepsInConditional = this.isPoisoned
|
147676
|
-
? __classPrivateFieldGet(this, _Context_depsInCurrentConditional, 'f')
|
147677
|
-
: null;
|
147678
|
-
if (prevDepsInConditional != null) {
|
147679
|
-
__classPrivateFieldSet(
|
147680
|
-
this,
|
147681
|
-
_Context_depsInCurrentConditional,
|
147682
|
-
new ReactiveScopeDependencyTree(),
|
147683
|
-
'f'
|
147684
|
-
);
|
147685
|
-
}
|
147686
|
-
const scopedDependencies = new ReactiveScopeDependencyTree();
|
147687
|
-
__classPrivateFieldSet(this, _Context_inConditionalWithinScope, false, 'f');
|
147688
|
-
__classPrivateFieldSet(
|
147689
|
-
this,
|
147690
|
-
_Context_dependencies$1,
|
147691
|
-
scopedDependencies,
|
147692
|
-
'f'
|
147693
|
-
);
|
147694
|
-
__classPrivateFieldSet(
|
147695
|
-
this,
|
147696
|
-
_Context_scopes$1,
|
147697
|
-
__classPrivateFieldGet(this, _Context_scopes$1, 'f').push({
|
147698
|
-
value: scope,
|
147699
|
-
ownBlocks: empty(),
|
147700
|
-
}),
|
147701
|
-
'f'
|
147702
|
-
);
|
147703
|
-
this.poisonState.isPoisoned = false;
|
147704
|
-
fn();
|
147705
|
-
__classPrivateFieldSet(
|
147706
|
-
this,
|
147707
|
-
_Context_scopes$1,
|
147708
|
-
__classPrivateFieldGet(this, _Context_scopes$1, 'f').pop(),
|
147709
|
-
'f'
|
147710
|
-
);
|
147711
|
-
this.poisonState.removeMaybePoisonedScope(
|
147712
|
-
scope.id,
|
147713
|
-
__classPrivateFieldGet(this, _Context_scopes$1, 'f').value
|
147714
|
-
);
|
147715
|
-
__classPrivateFieldSet(
|
147716
|
-
this,
|
147717
|
-
_Context_dependencies$1,
|
147718
|
-
previousDependencies,
|
147719
|
-
'f'
|
147720
|
-
);
|
147721
|
-
__classPrivateFieldSet(
|
147722
|
-
this,
|
147723
|
-
_Context_inConditionalWithinScope,
|
147724
|
-
prevInConditional,
|
147725
|
-
'f'
|
147726
|
-
);
|
147727
|
-
const minInnerScopeDependencies =
|
147728
|
-
scopedDependencies.deriveMinimalDependencies();
|
147729
|
-
__classPrivateFieldGet(
|
147730
|
-
this,
|
147731
|
-
_Context_dependencies$1,
|
147732
|
-
'f'
|
147733
|
-
).addDepsFromInnerScope(
|
147734
|
-
scopedDependencies,
|
147735
|
-
__classPrivateFieldGet(this, _Context_inConditionalWithinScope, 'f') ||
|
147736
|
-
this.isPoisoned,
|
147737
|
-
__classPrivateFieldGet(
|
147738
|
-
this,
|
147739
|
-
_Context_instances$1,
|
147740
|
-
'm',
|
147741
|
-
_Context_checkValidDependency$1
|
147742
|
-
).bind(this)
|
147743
|
-
);
|
147744
|
-
if (prevDepsInConditional != null) {
|
147745
|
-
prevDepsInConditional.addDepsFromInnerScope(
|
147746
|
-
__classPrivateFieldGet(this, _Context_depsInCurrentConditional, 'f'),
|
147747
|
-
true,
|
147748
|
-
__classPrivateFieldGet(
|
147749
|
-
this,
|
147750
|
-
_Context_instances$1,
|
147751
|
-
'm',
|
147752
|
-
_Context_checkValidDependency$1
|
147753
|
-
).bind(this)
|
147754
|
-
);
|
147755
|
-
__classPrivateFieldSet(
|
147756
|
-
this,
|
147757
|
-
_Context_depsInCurrentConditional,
|
147758
|
-
prevDepsInConditional,
|
147759
|
-
'f'
|
147760
|
-
);
|
147761
|
-
}
|
147762
|
-
return minInnerScopeDependencies;
|
147763
|
-
}
|
147764
|
-
isUsedOutsideDeclaringScope(place) {
|
147765
|
-
return __classPrivateFieldGet(
|
147766
|
-
this,
|
147767
|
-
_Context_temporariesUsedOutsideScope$1,
|
147768
|
-
'f'
|
147769
|
-
).has(place.identifier.declarationId);
|
147770
|
-
}
|
147771
|
-
printDeps(includeAccesses = false) {
|
147772
|
-
return __classPrivateFieldGet(this, _Context_dependencies$1, 'f').printDeps(
|
147773
|
-
includeAccesses
|
147774
|
-
);
|
147775
|
-
}
|
147776
|
-
enterConditional(fn) {
|
147777
|
-
const prevInConditional = __classPrivateFieldGet(
|
147778
|
-
this,
|
147779
|
-
_Context_inConditionalWithinScope,
|
147780
|
-
'f'
|
147781
|
-
);
|
147782
|
-
const prevUncondAccessed = __classPrivateFieldGet(
|
147783
|
-
this,
|
147784
|
-
_Context_depsInCurrentConditional,
|
147785
|
-
'f'
|
147786
|
-
);
|
147787
|
-
__classPrivateFieldSet(this, _Context_inConditionalWithinScope, true, 'f');
|
147788
|
-
__classPrivateFieldSet(
|
147789
|
-
this,
|
147790
|
-
_Context_depsInCurrentConditional,
|
147791
|
-
new ReactiveScopeDependencyTree(),
|
147792
|
-
'f'
|
147793
|
-
);
|
147794
|
-
fn();
|
147795
|
-
const result = __classPrivateFieldGet(
|
147796
|
-
this,
|
147797
|
-
_Context_depsInCurrentConditional,
|
147798
|
-
'f'
|
147799
|
-
);
|
147800
|
-
__classPrivateFieldSet(
|
147801
|
-
this,
|
147802
|
-
_Context_inConditionalWithinScope,
|
147803
|
-
prevInConditional,
|
147804
|
-
'f'
|
147805
|
-
);
|
147806
|
-
__classPrivateFieldSet(
|
147807
|
-
this,
|
147808
|
-
_Context_depsInCurrentConditional,
|
147809
|
-
prevUncondAccessed,
|
147810
|
-
'f'
|
147811
|
-
);
|
147812
|
-
return result;
|
147813
|
-
}
|
147814
|
-
promoteDepsFromExhaustiveConditionals(depsInConditionals) {
|
147815
|
-
__classPrivateFieldGet(
|
147816
|
-
this,
|
147817
|
-
_Context_dependencies$1,
|
147818
|
-
'f'
|
147819
|
-
).promoteDepsFromExhaustiveConditionals(depsInConditionals);
|
147820
|
-
__classPrivateFieldGet(
|
147821
|
-
this,
|
147822
|
-
_Context_depsInCurrentConditional,
|
147823
|
-
'f'
|
147824
|
-
).promoteDepsFromExhaustiveConditionals(depsInConditionals);
|
147825
|
-
}
|
147826
|
-
declare(identifier, decl) {
|
147827
|
-
if (
|
147828
|
-
!__classPrivateFieldGet(this, _Context_declarations$1, 'f').has(
|
147829
|
-
identifier.declarationId
|
147830
|
-
)
|
147831
|
-
) {
|
147832
|
-
__classPrivateFieldGet(this, _Context_declarations$1, 'f').set(
|
147833
|
-
identifier.declarationId,
|
147834
|
-
decl
|
147835
|
-
);
|
147836
|
-
}
|
147837
|
-
__classPrivateFieldGet(this, _Context_reassignments$1, 'f').set(
|
147838
|
-
identifier,
|
147839
|
-
decl
|
147840
|
-
);
|
147841
|
-
}
|
147842
|
-
declareTemporary(lvalue, place) {
|
147843
|
-
__classPrivateFieldGet(this, _Context_temporaries$1, 'f').set(
|
147844
|
-
lvalue.identifier,
|
147845
|
-
place
|
147846
|
-
);
|
147847
|
-
}
|
147848
|
-
resolveTemporary(place) {
|
147849
|
-
var _a;
|
147850
|
-
return (_a = __classPrivateFieldGet(this, _Context_temporaries$1, 'f').get(
|
147851
|
-
place.identifier
|
147852
|
-
)) !== null && _a !== void 0
|
147853
|
-
? _a
|
147854
|
-
: place;
|
147855
|
-
}
|
147856
|
-
declareProperty(lvalue, object, property, optional) {
|
147857
|
-
const nextDependency = __classPrivateFieldGet(
|
147858
|
-
this,
|
147859
|
-
_Context_instances$1,
|
147860
|
-
'm',
|
147861
|
-
_Context_getProperty
|
147862
|
-
).call(this, object, property, optional);
|
147863
|
-
__classPrivateFieldGet(this, _Context_properties, 'f').set(
|
147864
|
-
lvalue.identifier,
|
147865
|
-
nextDependency
|
147866
|
-
);
|
147867
|
-
}
|
147868
|
-
get currentScope() {
|
147869
|
-
return __classPrivateFieldGet(this, _Context_scopes$1, 'f');
|
147870
|
-
}
|
147871
|
-
get isPoisoned() {
|
147872
|
-
return this.poisonState.isPoisoned;
|
147873
|
-
}
|
147874
|
-
visitOperand(place) {
|
147875
|
-
const resolved = this.resolveTemporary(place);
|
147876
|
-
let dependency = {identifier: resolved.identifier, path: []};
|
147877
|
-
if (resolved.identifier.name === null) {
|
147878
|
-
const propertyDependency = __classPrivateFieldGet(
|
147879
|
-
this,
|
147880
|
-
_Context_properties,
|
147881
|
-
'f'
|
147882
|
-
).get(resolved.identifier);
|
147883
|
-
if (propertyDependency !== undefined) {
|
147884
|
-
dependency = Object.assign({}, propertyDependency);
|
147885
|
-
}
|
147886
|
-
}
|
147887
|
-
this.visitDependency(dependency);
|
147888
|
-
}
|
147889
|
-
visitProperty(object, property, optional) {
|
147890
|
-
const nextDependency = __classPrivateFieldGet(
|
147891
|
-
this,
|
147892
|
-
_Context_instances$1,
|
147893
|
-
'm',
|
147894
|
-
_Context_getProperty
|
147895
|
-
).call(this, object, property, optional);
|
147896
|
-
this.visitDependency(nextDependency);
|
147897
|
-
}
|
147898
|
-
visitDependency(maybeDependency) {
|
147899
|
-
const originalDeclaration = __classPrivateFieldGet(
|
147900
|
-
this,
|
147901
|
-
_Context_declarations$1,
|
147902
|
-
'f'
|
147903
|
-
).get(maybeDependency.identifier.declarationId);
|
147904
|
-
if (
|
147905
|
-
originalDeclaration !== undefined &&
|
147906
|
-
originalDeclaration.scope.value !== null
|
147907
|
-
) {
|
147908
|
-
originalDeclaration.scope.each(scope => {
|
147909
|
-
if (
|
147910
|
-
!__classPrivateFieldGet(
|
147911
|
-
this,
|
147912
|
-
_Context_instances$1,
|
147913
|
-
'm',
|
147914
|
-
_Context_isScopeActive$1
|
147915
|
-
).call(this, scope.value) &&
|
147916
|
-
!Iterable_some(
|
147917
|
-
scope.value.declarations.values(),
|
147918
|
-
decl =>
|
147919
|
-
decl.identifier.declarationId ===
|
147920
|
-
maybeDependency.identifier.declarationId
|
147921
|
-
)
|
147922
|
-
) {
|
147923
|
-
scope.value.declarations.set(maybeDependency.identifier.id, {
|
147924
|
-
identifier: maybeDependency.identifier,
|
147925
|
-
scope: originalDeclaration.scope.value.value,
|
147926
|
-
});
|
147927
|
-
}
|
147928
|
-
});
|
147929
|
-
}
|
147930
|
-
if (
|
147931
|
-
__classPrivateFieldGet(
|
147932
|
-
this,
|
147933
|
-
_Context_instances$1,
|
147934
|
-
'm',
|
147935
|
-
_Context_checkValidDependency$1
|
147936
|
-
).call(this, maybeDependency)
|
147937
|
-
) {
|
147938
|
-
const isPoisoned = this.isPoisoned;
|
147939
|
-
__classPrivateFieldGet(this, _Context_depsInCurrentConditional, 'f').add(
|
147940
|
-
maybeDependency,
|
147941
|
-
isPoisoned
|
147942
|
-
);
|
147943
|
-
__classPrivateFieldGet(this, _Context_dependencies$1, 'f').add(
|
147944
|
-
maybeDependency,
|
147945
|
-
__classPrivateFieldGet(this, _Context_inConditionalWithinScope, 'f') ||
|
147946
|
-
isPoisoned
|
147947
|
-
);
|
147948
|
-
}
|
147949
|
-
}
|
147950
|
-
visitReassignment(place) {
|
147951
|
-
var _a;
|
147952
|
-
const currentScope =
|
147953
|
-
(_a = this.currentScope.value) === null || _a === void 0
|
147954
|
-
? void 0
|
147955
|
-
: _a.value;
|
147956
|
-
if (
|
147957
|
-
currentScope != null &&
|
147958
|
-
!Iterable_some(
|
147959
|
-
currentScope.reassignments,
|
147960
|
-
identifier =>
|
147961
|
-
identifier.declarationId === place.identifier.declarationId
|
147962
|
-
) &&
|
147963
|
-
__classPrivateFieldGet(
|
147964
|
-
this,
|
147965
|
-
_Context_instances$1,
|
147966
|
-
'm',
|
147967
|
-
_Context_checkValidDependency$1
|
147968
|
-
).call(this, {identifier: place.identifier, path: []})
|
147969
|
-
) {
|
147970
|
-
currentScope.reassignments.add(place.identifier);
|
147971
|
-
}
|
147972
|
-
}
|
147973
|
-
pushLabeledBlock(id) {
|
147974
|
-
const currentScope = __classPrivateFieldGet(
|
147975
|
-
this,
|
147976
|
-
_Context_scopes$1,
|
147977
|
-
'f'
|
147978
|
-
).value;
|
147979
|
-
if (currentScope != null) {
|
147980
|
-
currentScope.ownBlocks = currentScope.ownBlocks.push(id);
|
147981
|
-
}
|
147982
|
-
}
|
147983
|
-
popLabeledBlock(id) {
|
147984
|
-
const currentScope = __classPrivateFieldGet(
|
147985
|
-
this,
|
147986
|
-
_Context_scopes$1,
|
147987
|
-
'f'
|
147988
|
-
).value;
|
147989
|
-
if (currentScope != null) {
|
147990
|
-
const last = currentScope.ownBlocks.value;
|
147991
|
-
currentScope.ownBlocks = currentScope.ownBlocks.pop();
|
147992
|
-
CompilerError.invariant(last != null && last === id, {
|
147993
|
-
reason: '[PropagateScopeDependencies] Misformed block stack',
|
147994
|
-
loc: GeneratedSource,
|
147995
|
-
});
|
147996
|
-
}
|
147997
|
-
this.poisonState.removeMaybePoisonedBlock(id, currentScope);
|
147998
|
-
}
|
147999
|
-
};
|
148000
|
-
(_Context_temporariesUsedOutsideScope$1 = new WeakMap()),
|
148001
|
-
(_Context_declarations$1 = new WeakMap()),
|
148002
|
-
(_Context_reassignments$1 = new WeakMap()),
|
148003
|
-
(_Context_dependencies$1 = new WeakMap()),
|
148004
|
-
(_Context_properties = new WeakMap()),
|
148005
|
-
(_Context_temporaries$1 = new WeakMap()),
|
148006
|
-
(_Context_inConditionalWithinScope = new WeakMap()),
|
148007
|
-
(_Context_depsInCurrentConditional = new WeakMap()),
|
148008
|
-
(_Context_scopes$1 = new WeakMap()),
|
148009
|
-
(_Context_instances$1 = new WeakSet()),
|
148010
|
-
(_Context_getProperty = function _Context_getProperty(
|
148011
|
-
object,
|
148012
|
-
property,
|
148013
|
-
optional
|
148014
|
-
) {
|
148015
|
-
const resolvedObject = this.resolveTemporary(object);
|
148016
|
-
const resolvedDependency = __classPrivateFieldGet(
|
148017
|
-
this,
|
148018
|
-
_Context_properties,
|
148019
|
-
'f'
|
148020
|
-
).get(resolvedObject.identifier);
|
148021
|
-
let objectDependency;
|
148022
|
-
if (resolvedDependency === undefined) {
|
148023
|
-
objectDependency = {identifier: resolvedObject.identifier, path: []};
|
148024
|
-
} else {
|
148025
|
-
objectDependency = {
|
148026
|
-
identifier: resolvedDependency.identifier,
|
148027
|
-
path: [...resolvedDependency.path],
|
148028
|
-
};
|
148029
|
-
}
|
148030
|
-
objectDependency.path.push({property: property, optional: optional});
|
148031
|
-
return objectDependency;
|
148032
|
-
}),
|
148033
|
-
(_Context_checkValidDependency$1 = function _Context_checkValidDependency(
|
148034
|
-
maybeDependency
|
148035
|
-
) {
|
148036
|
-
var _a, _b, _c, _d;
|
148037
|
-
if (
|
148038
|
-
isUseRefType(maybeDependency.identifier) &&
|
148039
|
-
((_a = maybeDependency.path.at(0)) === null || _a === void 0
|
148040
|
-
? void 0
|
148041
|
-
: _a.property) === 'current'
|
148042
|
-
) {
|
148043
|
-
return false;
|
148044
|
-
}
|
148045
|
-
if (isRefValueType(maybeDependency.identifier)) {
|
148046
|
-
return false;
|
148047
|
-
}
|
148048
|
-
if (isObjectMethodType(maybeDependency.identifier)) {
|
148049
|
-
return false;
|
148050
|
-
}
|
148051
|
-
const identifier = maybeDependency.identifier;
|
148052
|
-
const currentDeclaration =
|
148053
|
-
(_b = __classPrivateFieldGet(this, _Context_reassignments$1, 'f').get(
|
148054
|
-
identifier
|
148055
|
-
)) !== null && _b !== void 0
|
148056
|
-
? _b
|
148057
|
-
: __classPrivateFieldGet(this, _Context_declarations$1, 'f').get(
|
148058
|
-
identifier.declarationId
|
148059
|
-
);
|
148060
|
-
const currentScope =
|
148061
|
-
(_c = this.currentScope.value) === null || _c === void 0
|
148062
|
-
? void 0
|
148063
|
-
: _c.value;
|
148064
|
-
return (
|
148065
|
-
currentScope != null &&
|
148066
|
-
currentDeclaration !== undefined &&
|
148067
|
-
currentDeclaration.id < currentScope.range.start &&
|
148068
|
-
(currentDeclaration.scope == null ||
|
148069
|
-
((_d = currentDeclaration.scope.value) === null || _d === void 0
|
148070
|
-
? void 0
|
148071
|
-
: _d.value) !== currentScope)
|
148072
|
-
);
|
148073
|
-
}),
|
148074
|
-
(_Context_isScopeActive$1 = function _Context_isScopeActive(scope) {
|
148075
|
-
if (__classPrivateFieldGet(this, _Context_scopes$1, 'f') === null) {
|
148076
|
-
return false;
|
148077
|
-
}
|
148078
|
-
return __classPrivateFieldGet(this, _Context_scopes$1, 'f').find(
|
148079
|
-
state => state.value === scope
|
148080
|
-
);
|
148081
|
-
});
|
148082
|
-
class PropagationVisitor extends ReactiveFunctionVisitor {
|
148083
|
-
constructor(env) {
|
148084
|
-
super();
|
148085
|
-
this.env = env;
|
148086
|
-
}
|
148087
|
-
visitScope(scope, context) {
|
148088
|
-
const scopeDependencies = context.enter(scope.scope, () => {
|
148089
|
-
this.visitBlock(scope.instructions, context);
|
148090
|
-
});
|
148091
|
-
for (const candidateDep of scopeDependencies) {
|
148092
|
-
if (
|
148093
|
-
!Iterable_some(
|
148094
|
-
scope.scope.dependencies,
|
148095
|
-
existingDep =>
|
148096
|
-
existingDep.identifier.declarationId ===
|
148097
|
-
candidateDep.identifier.declarationId &&
|
148098
|
-
areEqualPaths(existingDep.path, candidateDep.path)
|
148099
|
-
)
|
148100
|
-
) {
|
148101
|
-
scope.scope.dependencies.add(candidateDep);
|
148102
|
-
}
|
148103
|
-
}
|
148104
|
-
}
|
148105
|
-
visitPrunedScope(scopeBlock, context) {
|
148106
|
-
context.enter(scopeBlock.scope, () => {
|
148107
|
-
this.visitBlock(scopeBlock.instructions, context);
|
148108
|
-
});
|
148109
|
-
}
|
148110
|
-
visitInstruction(instruction, context) {
|
148111
|
-
const {id: id, value: value, lvalue: lvalue} = instruction;
|
148112
|
-
this.visitInstructionValue(context, id, value, lvalue);
|
148113
|
-
if (lvalue == null) {
|
148114
|
-
return;
|
148115
|
-
}
|
148116
|
-
context.declare(lvalue.identifier, {id: id, scope: context.currentScope});
|
148117
|
-
}
|
148118
|
-
extractOptionalProperty(context, optionalValue, lvalue) {
|
148119
|
-
const sequence = optionalValue.value;
|
148120
|
-
CompilerError.invariant(sequence.kind === 'SequenceExpression', {
|
148121
|
-
reason: 'Expected OptionalExpression value to be a SequenceExpression',
|
148122
|
-
description: `Found a \`${sequence.kind}\``,
|
148123
|
-
loc: sequence.loc,
|
148124
|
-
});
|
148125
|
-
if (
|
148126
|
-
sequence.instructions.length === 1 &&
|
148127
|
-
sequence.instructions[0].lvalue !== null &&
|
148128
|
-
sequence.instructions[0].value.kind === 'LoadLocal' &&
|
148129
|
-
sequence.instructions[0].value.place.identifier.name !== null &&
|
148130
|
-
!context.isUsedOutsideDeclaringScope(sequence.instructions[0].lvalue) &&
|
148131
|
-
sequence.value.kind === 'SequenceExpression' &&
|
148132
|
-
sequence.value.instructions.length === 1 &&
|
148133
|
-
sequence.value.instructions[0].value.kind === 'PropertyLoad' &&
|
148134
|
-
sequence.value.instructions[0].value.object.identifier.id ===
|
148135
|
-
sequence.instructions[0].lvalue.identifier.id &&
|
148136
|
-
sequence.value.instructions[0].lvalue !== null &&
|
148137
|
-
sequence.value.value.kind === 'LoadLocal' &&
|
148138
|
-
sequence.value.value.place.identifier.id ===
|
148139
|
-
sequence.value.instructions[0].lvalue.identifier.id
|
148140
|
-
) {
|
148141
|
-
context.declareTemporary(
|
148142
|
-
sequence.instructions[0].lvalue,
|
148143
|
-
sequence.instructions[0].value.place
|
148144
|
-
);
|
148145
|
-
const propertyLoad = sequence.value.instructions[0].value;
|
148146
|
-
return {
|
148147
|
-
lvalue: lvalue,
|
148148
|
-
object: propertyLoad.object,
|
148149
|
-
property: propertyLoad.property,
|
148150
|
-
optional: optionalValue.optional,
|
148151
|
-
};
|
148152
|
-
}
|
148153
|
-
if (
|
148154
|
-
sequence.instructions.length === 1 &&
|
148155
|
-
sequence.instructions[0].lvalue !== null &&
|
148156
|
-
sequence.instructions[0].value.kind === 'SequenceExpression' &&
|
148157
|
-
sequence.instructions[0].value.instructions.length === 1 &&
|
148158
|
-
sequence.instructions[0].value.instructions[0].lvalue !== null &&
|
148159
|
-
sequence.instructions[0].value.instructions[0].value.kind ===
|
148160
|
-
'LoadLocal' &&
|
148161
|
-
sequence.instructions[0].value.instructions[0].value.place.identifier
|
148162
|
-
.name !== null &&
|
148163
|
-
!context.isUsedOutsideDeclaringScope(
|
148164
|
-
sequence.instructions[0].value.instructions[0].lvalue
|
148165
|
-
) &&
|
148166
|
-
sequence.instructions[0].value.value.kind === 'PropertyLoad' &&
|
148167
|
-
sequence.instructions[0].value.value.object.identifier.id ===
|
148168
|
-
sequence.instructions[0].value.instructions[0].lvalue.identifier.id &&
|
148169
|
-
sequence.value.kind === 'SequenceExpression' &&
|
148170
|
-
sequence.value.instructions.length === 1 &&
|
148171
|
-
sequence.value.instructions[0].lvalue !== null &&
|
148172
|
-
sequence.value.instructions[0].value.kind === 'PropertyLoad' &&
|
148173
|
-
sequence.value.instructions[0].value.object.identifier.id ===
|
148174
|
-
sequence.instructions[0].lvalue.identifier.id &&
|
148175
|
-
sequence.value.value.kind === 'LoadLocal' &&
|
148176
|
-
sequence.value.value.place.identifier.id ===
|
148177
|
-
sequence.value.instructions[0].lvalue.identifier.id
|
148178
|
-
) {
|
148179
|
-
context.declareTemporary(
|
148180
|
-
sequence.instructions[0].value.instructions[0].lvalue,
|
148181
|
-
sequence.instructions[0].value.instructions[0].value.place
|
148182
|
-
);
|
148183
|
-
context.declareProperty(
|
148184
|
-
sequence.instructions[0].lvalue,
|
148185
|
-
sequence.instructions[0].value.value.object,
|
148186
|
-
sequence.instructions[0].value.value.property,
|
148187
|
-
false
|
148188
|
-
);
|
148189
|
-
const propertyLoad = sequence.value.instructions[0].value;
|
148190
|
-
return {
|
148191
|
-
lvalue: lvalue,
|
148192
|
-
object: propertyLoad.object,
|
148193
|
-
property: propertyLoad.property,
|
148194
|
-
optional: optionalValue.optional,
|
148195
|
-
};
|
148196
|
-
}
|
148197
|
-
if (
|
148198
|
-
sequence.instructions.length === 1 &&
|
148199
|
-
sequence.instructions[0].value.kind === 'SequenceExpression' &&
|
148200
|
-
sequence.instructions[0].value.instructions.length === 1 &&
|
148201
|
-
sequence.instructions[0].value.instructions[0].lvalue !== null &&
|
148202
|
-
sequence.instructions[0].value.instructions[0].value.kind ===
|
148203
|
-
'OptionalExpression' &&
|
148204
|
-
sequence.instructions[0].value.value.kind === 'LoadLocal' &&
|
148205
|
-
sequence.instructions[0].value.value.place.identifier.id ===
|
148206
|
-
sequence.instructions[0].value.instructions[0].lvalue.identifier.id &&
|
148207
|
-
sequence.value.kind === 'SequenceExpression' &&
|
148208
|
-
sequence.value.instructions.length === 1 &&
|
148209
|
-
sequence.value.instructions[0].lvalue !== null &&
|
148210
|
-
sequence.value.instructions[0].value.kind === 'PropertyLoad' &&
|
148211
|
-
sequence.value.instructions[0].value.object.identifier.id ===
|
148212
|
-
sequence.instructions[0].value.value.place.identifier.id &&
|
148213
|
-
sequence.value.value.kind === 'LoadLocal' &&
|
148214
|
-
sequence.value.value.place.identifier.id ===
|
148215
|
-
sequence.value.instructions[0].lvalue.identifier.id
|
148216
|
-
) {
|
148217
|
-
const {lvalue: innerLvalue, value: innerOptional} =
|
148218
|
-
sequence.instructions[0].value.instructions[0];
|
148219
|
-
const innerProperty = this.extractOptionalProperty(
|
148220
|
-
context,
|
148221
|
-
innerOptional,
|
148222
|
-
innerLvalue
|
148223
|
-
);
|
148224
|
-
if (innerProperty === null) {
|
148225
|
-
return null;
|
148226
|
-
}
|
148227
|
-
context.declareProperty(
|
148228
|
-
innerProperty.lvalue,
|
148229
|
-
innerProperty.object,
|
148230
|
-
innerProperty.property,
|
148231
|
-
innerProperty.optional
|
148232
|
-
);
|
148233
|
-
const propertyLoad = sequence.value.instructions[0].value;
|
148234
|
-
return {
|
148235
|
-
lvalue: lvalue,
|
148236
|
-
object: propertyLoad.object,
|
148237
|
-
property: propertyLoad.property,
|
148238
|
-
optional: optionalValue.optional,
|
148239
|
-
};
|
148240
|
-
}
|
148241
|
-
return null;
|
148242
|
-
}
|
148243
|
-
visitOptionalExpression(context, id, value, lvalue) {
|
148244
|
-
if (
|
148245
|
-
lvalue !== null &&
|
148246
|
-
value.optional &&
|
148247
|
-
this.env.config.enableOptionalDependencies
|
148248
|
-
) {
|
148249
|
-
const inner = this.extractOptionalProperty(context, value, lvalue);
|
148250
|
-
if (inner !== null) {
|
148251
|
-
context.visitProperty(inner.object, inner.property, inner.optional);
|
148252
|
-
return;
|
148253
|
-
}
|
148254
|
-
}
|
148255
|
-
const inner = value.value;
|
148256
|
-
CompilerError.invariant(inner.kind === 'SequenceExpression', {
|
148257
|
-
reason: 'Expected OptionalExpression value to be a SequenceExpression',
|
148258
|
-
description: `Found a \`${value.kind}\``,
|
148259
|
-
loc: value.loc,
|
148260
|
-
suggestions: null,
|
148261
|
-
});
|
148262
|
-
for (const instr of inner.instructions) {
|
148263
|
-
this.visitInstruction(instr, context);
|
148264
|
-
}
|
148265
|
-
context.enterConditional(() => {
|
148266
|
-
this.visitReactiveValue(context, id, inner.value, null);
|
148267
|
-
});
|
148268
|
-
}
|
148269
|
-
visitReactiveValue(context, id, value, lvalue) {
|
148270
|
-
switch (value.kind) {
|
148271
|
-
case 'OptionalExpression': {
|
148272
|
-
this.visitOptionalExpression(context, id, value, lvalue);
|
148273
|
-
break;
|
148274
|
-
}
|
148275
|
-
case 'LogicalExpression': {
|
148276
|
-
this.visitReactiveValue(context, id, value.left, null);
|
148277
|
-
context.enterConditional(() => {
|
148278
|
-
this.visitReactiveValue(context, id, value.right, null);
|
148279
|
-
});
|
148280
|
-
break;
|
148281
|
-
}
|
148282
|
-
case 'ConditionalExpression': {
|
148283
|
-
this.visitReactiveValue(context, id, value.test, null);
|
148284
|
-
const consequentDeps = context.enterConditional(() => {
|
148285
|
-
this.visitReactiveValue(context, id, value.consequent, null);
|
148286
|
-
});
|
148287
|
-
const alternateDeps = context.enterConditional(() => {
|
148288
|
-
this.visitReactiveValue(context, id, value.alternate, null);
|
148289
|
-
});
|
148290
|
-
context.promoteDepsFromExhaustiveConditionals([
|
148291
|
-
consequentDeps,
|
148292
|
-
alternateDeps,
|
148293
|
-
]);
|
148294
|
-
break;
|
148295
|
-
}
|
148296
|
-
case 'SequenceExpression': {
|
148297
|
-
for (const instr of value.instructions) {
|
148298
|
-
this.visitInstruction(instr, context);
|
148299
|
-
}
|
148300
|
-
this.visitInstructionValue(context, id, value.value, null);
|
148301
|
-
break;
|
148302
|
-
}
|
148303
|
-
case 'FunctionExpression': {
|
148304
|
-
if (this.env.config.enableTreatFunctionDepsAsConditional) {
|
148305
|
-
context.enterConditional(() => {
|
148306
|
-
for (const operand of eachInstructionValueOperand(value)) {
|
148307
|
-
context.visitOperand(operand);
|
148308
|
-
}
|
148309
|
-
});
|
148310
|
-
} else {
|
148311
|
-
for (const operand of eachInstructionValueOperand(value)) {
|
148312
|
-
context.visitOperand(operand);
|
148313
|
-
}
|
148314
|
-
}
|
148315
|
-
break;
|
148316
|
-
}
|
148317
|
-
case 'ReactiveFunctionValue': {
|
148318
|
-
CompilerError.invariant(false, {
|
148319
|
-
reason: `Unexpected ReactiveFunctionValue`,
|
148320
|
-
loc: value.loc,
|
148321
|
-
description: null,
|
148322
|
-
suggestions: null,
|
148323
|
-
});
|
148324
|
-
}
|
148325
|
-
default: {
|
148326
|
-
for (const operand of eachInstructionValueOperand(value)) {
|
148327
|
-
context.visitOperand(operand);
|
148328
|
-
}
|
148329
|
-
}
|
148330
|
-
}
|
148331
|
-
}
|
148332
|
-
visitInstructionValue(context, id, value, lvalue) {
|
148333
|
-
if (value.kind === 'LoadLocal' && lvalue !== null) {
|
148334
|
-
if (
|
148335
|
-
value.place.identifier.name !== null &&
|
148336
|
-
lvalue.identifier.name === null &&
|
148337
|
-
!context.isUsedOutsideDeclaringScope(lvalue)
|
148338
|
-
) {
|
148339
|
-
context.declareTemporary(lvalue, value.place);
|
148340
|
-
} else {
|
148341
|
-
context.visitOperand(value.place);
|
148342
|
-
}
|
148343
|
-
} else if (value.kind === 'PropertyLoad') {
|
148344
|
-
if (lvalue !== null && !context.isUsedOutsideDeclaringScope(lvalue)) {
|
148345
|
-
context.declareProperty(lvalue, value.object, value.property, false);
|
148346
|
-
} else {
|
148347
|
-
context.visitProperty(value.object, value.property, false);
|
148348
|
-
}
|
148349
|
-
} else if (value.kind === 'StoreLocal') {
|
148350
|
-
context.visitOperand(value.value);
|
148351
|
-
if (value.lvalue.kind === InstructionKind.Reassign) {
|
148352
|
-
context.visitReassignment(value.lvalue.place);
|
148353
|
-
}
|
148354
|
-
context.declare(value.lvalue.place.identifier, {
|
148355
|
-
id: id,
|
148356
|
-
scope: context.currentScope,
|
148357
|
-
});
|
148358
|
-
} else if (
|
148359
|
-
value.kind === 'DeclareLocal' ||
|
148360
|
-
value.kind === 'DeclareContext'
|
148361
|
-
) {
|
148362
|
-
context.declare(value.lvalue.place.identifier, {
|
148363
|
-
id: id,
|
148364
|
-
scope: context.currentScope,
|
148365
|
-
});
|
148366
|
-
} else if (value.kind === 'Destructure') {
|
148367
|
-
context.visitOperand(value.value);
|
148368
|
-
for (const place of eachPatternOperand(value.lvalue.pattern)) {
|
148369
|
-
if (value.lvalue.kind === InstructionKind.Reassign) {
|
148370
|
-
context.visitReassignment(place);
|
148371
|
-
}
|
148372
|
-
context.declare(place.identifier, {
|
148373
|
-
id: id,
|
148374
|
-
scope: context.currentScope,
|
148375
|
-
});
|
148376
|
-
}
|
148377
|
-
} else {
|
148378
|
-
this.visitReactiveValue(context, id, value, lvalue);
|
148379
|
-
}
|
148380
|
-
}
|
148381
|
-
enterTerminal(stmt, context) {
|
148382
|
-
if (stmt.label != null) {
|
148383
|
-
context.pushLabeledBlock(stmt.label.id);
|
148384
|
-
}
|
148385
|
-
const terminal = stmt.terminal;
|
148386
|
-
switch (terminal.kind) {
|
148387
|
-
case 'continue':
|
148388
|
-
case 'break': {
|
148389
|
-
context.poisonState.addPoisonTarget(
|
148390
|
-
terminal.target,
|
148391
|
-
context.currentScope
|
148392
|
-
);
|
148393
|
-
break;
|
148394
|
-
}
|
148395
|
-
case 'throw':
|
148396
|
-
case 'return': {
|
148397
|
-
context.poisonState.addPoisonTarget(null, context.currentScope);
|
148398
|
-
break;
|
148399
|
-
}
|
148400
|
-
}
|
148401
|
-
}
|
148402
|
-
exitTerminal(stmt, context) {
|
148403
|
-
if (stmt.label != null) {
|
148404
|
-
context.popLabeledBlock(stmt.label.id);
|
148405
|
-
}
|
148406
|
-
}
|
148407
|
-
visitTerminal(stmt, context) {
|
148408
|
-
this.enterTerminal(stmt, context);
|
148409
|
-
const terminal = stmt.terminal;
|
148410
|
-
switch (terminal.kind) {
|
148411
|
-
case 'break':
|
148412
|
-
case 'continue': {
|
148413
|
-
break;
|
148414
|
-
}
|
148415
|
-
case 'return': {
|
148416
|
-
context.visitOperand(terminal.value);
|
148417
|
-
break;
|
148418
|
-
}
|
148419
|
-
case 'throw': {
|
148420
|
-
context.visitOperand(terminal.value);
|
148421
|
-
break;
|
148422
|
-
}
|
148423
|
-
case 'for': {
|
148424
|
-
this.visitReactiveValue(context, terminal.id, terminal.init, null);
|
148425
|
-
this.visitReactiveValue(context, terminal.id, terminal.test, null);
|
148426
|
-
context.enterConditional(() => {
|
148427
|
-
this.visitBlock(terminal.loop, context);
|
148428
|
-
if (terminal.update !== null) {
|
148429
|
-
this.visitReactiveValue(
|
148430
|
-
context,
|
148431
|
-
terminal.id,
|
148432
|
-
terminal.update,
|
148433
|
-
null
|
148434
|
-
);
|
148435
|
-
}
|
148436
|
-
});
|
148437
|
-
break;
|
148438
|
-
}
|
148439
|
-
case 'for-of': {
|
148440
|
-
this.visitReactiveValue(context, terminal.id, terminal.init, null);
|
148441
|
-
context.enterConditional(() => {
|
148442
|
-
this.visitBlock(terminal.loop, context);
|
148443
|
-
});
|
148444
|
-
break;
|
148445
|
-
}
|
148446
|
-
case 'for-in': {
|
148447
|
-
this.visitReactiveValue(context, terminal.id, terminal.init, null);
|
148448
|
-
context.enterConditional(() => {
|
148449
|
-
this.visitBlock(terminal.loop, context);
|
148450
|
-
});
|
148451
|
-
break;
|
148452
|
-
}
|
148453
|
-
case 'do-while': {
|
148454
|
-
this.visitBlock(terminal.loop, context);
|
148455
|
-
context.enterConditional(() => {
|
148456
|
-
this.visitReactiveValue(context, terminal.id, terminal.test, null);
|
148457
|
-
});
|
148458
|
-
break;
|
148459
|
-
}
|
148460
|
-
case 'while': {
|
148461
|
-
this.visitReactiveValue(context, terminal.id, terminal.test, null);
|
148462
|
-
context.enterConditional(() => {
|
148463
|
-
this.visitBlock(terminal.loop, context);
|
148464
|
-
});
|
148465
|
-
break;
|
148466
|
-
}
|
148467
|
-
case 'if': {
|
148468
|
-
context.visitOperand(terminal.test);
|
148469
|
-
const {consequent: consequent, alternate: alternate} = terminal;
|
148470
|
-
const prevPoisonState = context.poisonState.clone();
|
148471
|
-
const depsInIf = context.enterConditional(() => {
|
148472
|
-
this.visitBlock(consequent, context);
|
148473
|
-
});
|
148474
|
-
if (alternate !== null) {
|
148475
|
-
const ifPoisonState = context.poisonState.take(prevPoisonState);
|
148476
|
-
const depsInElse = context.enterConditional(() => {
|
148477
|
-
this.visitBlock(alternate, context);
|
148478
|
-
});
|
148479
|
-
context.poisonState.merge(
|
148480
|
-
[ifPoisonState],
|
148481
|
-
context.currentScope.value
|
148482
|
-
);
|
148483
|
-
context.promoteDepsFromExhaustiveConditionals([depsInIf, depsInElse]);
|
148484
|
-
}
|
148485
|
-
break;
|
148486
|
-
}
|
148487
|
-
case 'switch': {
|
148488
|
-
context.visitOperand(terminal.test);
|
148489
|
-
const isDefaultOnly =
|
148490
|
-
terminal.cases.length === 1 && terminal.cases[0].test == null;
|
148491
|
-
if (isDefaultOnly) {
|
148492
|
-
const case_ = terminal.cases[0];
|
148493
|
-
if (case_.block != null) {
|
148494
|
-
this.visitBlock(case_.block, context);
|
148495
|
-
break;
|
148496
|
-
}
|
148497
|
-
}
|
148498
|
-
const depsInCases = [];
|
148499
|
-
let foundDefault = false;
|
148500
|
-
const prevPoisonState = context.poisonState.clone();
|
148501
|
-
const mutExPoisonStates = [];
|
148502
|
-
for (const {test: test, block: block} of terminal.cases) {
|
148503
|
-
if (test !== null) {
|
148504
|
-
context.visitOperand(test);
|
148505
|
-
} else {
|
148506
|
-
foundDefault = true;
|
148507
|
-
}
|
148508
|
-
if (block !== undefined) {
|
148509
|
-
mutExPoisonStates.push(
|
148510
|
-
context.poisonState.take(prevPoisonState.clone())
|
148511
|
-
);
|
148512
|
-
depsInCases.push(
|
148513
|
-
context.enterConditional(() => {
|
148514
|
-
this.visitBlock(block, context);
|
148515
|
-
})
|
148516
|
-
);
|
148517
|
-
}
|
148518
|
-
}
|
148519
|
-
if (foundDefault) {
|
148520
|
-
context.promoteDepsFromExhaustiveConditionals(depsInCases);
|
148521
|
-
}
|
148522
|
-
context.poisonState.merge(
|
148523
|
-
mutExPoisonStates,
|
148524
|
-
context.currentScope.value
|
148525
|
-
);
|
148526
|
-
break;
|
148527
|
-
}
|
148528
|
-
case 'label': {
|
148529
|
-
this.visitBlock(terminal.block, context);
|
148530
|
-
break;
|
148531
|
-
}
|
148532
|
-
case 'try': {
|
148533
|
-
this.visitBlock(terminal.block, context);
|
148534
|
-
this.visitBlock(terminal.handler, context);
|
148535
|
-
break;
|
148536
|
-
}
|
148537
|
-
default: {
|
148538
|
-
assertExhaustive(
|
148539
|
-
terminal,
|
148540
|
-
`Unexpected terminal kind \`${terminal.kind}\``
|
148541
|
-
);
|
148542
|
-
}
|
148543
|
-
}
|
148544
|
-
this.exitTerminal(stmt, context);
|
148545
|
-
}
|
148546
|
-
}
|
148547
|
-
function pruneHoistedContexts(fn) {
|
148548
|
-
const hoistedIdentifiers = new Map();
|
148549
|
-
visitReactiveFunction(fn, new Visitor$8(), hoistedIdentifiers);
|
148550
|
-
}
|
148551
|
-
let Visitor$8 = class Visitor extends ReactiveFunctionTransform {
|
148552
|
-
transformInstruction(instruction, state) {
|
148553
|
-
this.visitInstruction(instruction, state);
|
148554
|
-
if (
|
148555
|
-
instruction.value.kind === 'DeclareContext' &&
|
148556
|
-
instruction.value.lvalue.kind === 'HoistedConst'
|
148557
|
-
) {
|
148558
|
-
state.set(
|
148559
|
-
instruction.value.lvalue.place.identifier.declarationId,
|
148560
|
-
InstructionKind.Const
|
148561
|
-
);
|
148562
|
-
return {kind: 'remove'};
|
148563
|
-
}
|
148564
|
-
if (
|
148565
|
-
instruction.value.kind === 'DeclareContext' &&
|
148566
|
-
instruction.value.lvalue.kind === 'HoistedLet'
|
148567
|
-
) {
|
148568
|
-
state.set(
|
148569
|
-
instruction.value.lvalue.place.identifier.declarationId,
|
148570
|
-
InstructionKind.Let
|
148571
|
-
);
|
148572
|
-
return {kind: 'remove'};
|
148573
|
-
}
|
148574
|
-
if (
|
148575
|
-
instruction.value.kind === 'DeclareContext' &&
|
148576
|
-
instruction.value.lvalue.kind === 'HoistedFunction'
|
148577
|
-
) {
|
148578
|
-
state.set(
|
148579
|
-
instruction.value.lvalue.place.identifier.declarationId,
|
148580
|
-
InstructionKind.Function
|
148581
|
-
);
|
148582
|
-
return {kind: 'remove'};
|
147271
|
+
return {kind: 'remove'};
|
148583
147272
|
}
|
148584
147273
|
if (
|
148585
147274
|
instruction.value.kind === 'StoreContext' &&
|
@@ -151195,12 +149884,18 @@ let Visitor$7 = class Visitor extends ReactiveFunctionVisitor {
|
|
151195
149884
|
visitPrunedScope(scopeBlock, state) {
|
151196
149885
|
this.traversePrunedScope(scopeBlock, state);
|
151197
149886
|
for (const [id, decl] of scopeBlock.scope.declarations) {
|
151198
|
-
if (
|
149887
|
+
if (
|
149888
|
+
!isPrimitiveType(decl.identifier) &&
|
149889
|
+
!isStableRefType(decl.identifier, state)
|
149890
|
+
) {
|
151199
149891
|
state.add(id);
|
151200
149892
|
}
|
151201
149893
|
}
|
151202
149894
|
}
|
151203
149895
|
};
|
149896
|
+
function isStableRefType(identifier, reactiveIdentifiers) {
|
149897
|
+
return isUseRefType(identifier) && !reactiveIdentifiers.has(identifier.id);
|
149898
|
+
}
|
151204
149899
|
function collectReactiveIdentifiers(fn) {
|
151205
149900
|
const visitor = new Visitor$7();
|
151206
149901
|
const state = new Set();
|
@@ -156452,210 +155147,19 @@ function validateNoJSXInTryStatement(fn) {
|
|
156452
155147
|
}
|
156453
155148
|
}
|
156454
155149
|
if (block.terminal.kind === 'try') {
|
156455
|
-
activeTryBlocks.push(block.terminal.handler);
|
156456
|
-
}
|
156457
|
-
}
|
156458
|
-
if (errors.hasErrors()) {
|
156459
|
-
throw errors;
|
156460
|
-
}
|
156461
|
-
}
|
156462
|
-
function collectOptionalChainSidemap(fn) {
|
156463
|
-
const context = {
|
156464
|
-
blocks: fn.body.blocks,
|
156465
|
-
seenOptionals: new Set(),
|
156466
|
-
processedInstrsInOptional: new Set(),
|
156467
|
-
temporariesReadInOptional: new Map(),
|
156468
|
-
hoistableObjects: new Map(),
|
156469
|
-
};
|
156470
|
-
for (const [_, block] of fn.body.blocks) {
|
156471
|
-
if (
|
156472
|
-
block.terminal.kind === 'optional' &&
|
156473
|
-
!context.seenOptionals.has(block.id)
|
156474
|
-
) {
|
156475
|
-
traverseOptionalBlock(block, context, null);
|
156476
|
-
}
|
156477
|
-
}
|
156478
|
-
return {
|
156479
|
-
temporariesReadInOptional: context.temporariesReadInOptional,
|
156480
|
-
processedInstrsInOptional: context.processedInstrsInOptional,
|
156481
|
-
hoistableObjects: context.hoistableObjects,
|
156482
|
-
};
|
156483
|
-
}
|
156484
|
-
function matchOptionalTestBlock(terminal, blocks) {
|
156485
|
-
const consequentBlock = assertNonNull(blocks.get(terminal.consequent));
|
156486
|
-
if (
|
156487
|
-
consequentBlock.instructions.length === 2 &&
|
156488
|
-
consequentBlock.instructions[0].value.kind === 'PropertyLoad' &&
|
156489
|
-
consequentBlock.instructions[1].value.kind === 'StoreLocal'
|
156490
|
-
) {
|
156491
|
-
const propertyLoad = consequentBlock.instructions[0];
|
156492
|
-
const storeLocal = consequentBlock.instructions[1].value;
|
156493
|
-
const storeLocalInstrId = consequentBlock.instructions[1].id;
|
156494
|
-
CompilerError.invariant(
|
156495
|
-
propertyLoad.value.object.identifier.id === terminal.test.identifier.id,
|
156496
|
-
{
|
156497
|
-
reason:
|
156498
|
-
'[OptionalChainDeps] Inconsistent optional chaining property load',
|
156499
|
-
description: `Test=${printIdentifier(terminal.test.identifier)} PropertyLoad base=${printIdentifier(propertyLoad.value.object.identifier)}`,
|
156500
|
-
loc: propertyLoad.loc,
|
156501
|
-
}
|
156502
|
-
);
|
156503
|
-
CompilerError.invariant(
|
156504
|
-
storeLocal.value.identifier.id === propertyLoad.lvalue.identifier.id,
|
156505
|
-
{
|
156506
|
-
reason: '[OptionalChainDeps] Unexpected storeLocal',
|
156507
|
-
loc: propertyLoad.loc,
|
156508
|
-
}
|
156509
|
-
);
|
156510
|
-
if (
|
156511
|
-
consequentBlock.terminal.kind !== 'goto' ||
|
156512
|
-
consequentBlock.terminal.variant !== GotoVariant.Break
|
156513
|
-
) {
|
156514
|
-
return null;
|
156515
|
-
}
|
156516
|
-
const alternate = assertNonNull(blocks.get(terminal.alternate));
|
156517
|
-
CompilerError.invariant(
|
156518
|
-
alternate.instructions.length === 2 &&
|
156519
|
-
alternate.instructions[0].value.kind === 'Primitive' &&
|
156520
|
-
alternate.instructions[1].value.kind === 'StoreLocal',
|
156521
|
-
{reason: 'Unexpected alternate structure', loc: terminal.loc}
|
156522
|
-
);
|
156523
|
-
return {
|
156524
|
-
consequentId: storeLocal.lvalue.place.identifier.id,
|
156525
|
-
property: propertyLoad.value.property,
|
156526
|
-
propertyId: propertyLoad.lvalue.identifier.id,
|
156527
|
-
storeLocalInstrId: storeLocalInstrId,
|
156528
|
-
consequentGoto: consequentBlock.terminal.block,
|
156529
|
-
};
|
156530
|
-
}
|
156531
|
-
return null;
|
156532
|
-
}
|
156533
|
-
function traverseOptionalBlock(optional, context, outerAlternate) {
|
156534
|
-
context.seenOptionals.add(optional.id);
|
156535
|
-
const maybeTest = context.blocks.get(optional.terminal.test);
|
156536
|
-
let test;
|
156537
|
-
let baseObject;
|
156538
|
-
if (maybeTest.terminal.kind === 'branch') {
|
156539
|
-
CompilerError.invariant(optional.terminal.optional, {
|
156540
|
-
reason: '[OptionalChainDeps] Expect base case to be always optional',
|
156541
|
-
loc: optional.terminal.loc,
|
156542
|
-
});
|
156543
|
-
if (
|
156544
|
-
maybeTest.instructions.length === 0 ||
|
156545
|
-
maybeTest.instructions[0].value.kind !== 'LoadLocal'
|
156546
|
-
) {
|
156547
|
-
return null;
|
156548
|
-
}
|
156549
|
-
const path = [];
|
156550
|
-
for (let i = 1; i < maybeTest.instructions.length; i++) {
|
156551
|
-
const instrVal = maybeTest.instructions[i].value;
|
156552
|
-
const prevInstr = maybeTest.instructions[i - 1];
|
156553
|
-
if (
|
156554
|
-
instrVal.kind === 'PropertyLoad' &&
|
156555
|
-
instrVal.object.identifier.id === prevInstr.lvalue.identifier.id
|
156556
|
-
) {
|
156557
|
-
path.push({property: instrVal.property, optional: false});
|
156558
|
-
} else {
|
156559
|
-
return null;
|
156560
|
-
}
|
156561
|
-
}
|
156562
|
-
CompilerError.invariant(
|
156563
|
-
maybeTest.terminal.test.identifier.id ===
|
156564
|
-
maybeTest.instructions.at(-1).lvalue.identifier.id,
|
156565
|
-
{
|
156566
|
-
reason: '[OptionalChainDeps] Unexpected test expression',
|
156567
|
-
loc: maybeTest.terminal.loc,
|
156568
|
-
}
|
156569
|
-
);
|
156570
|
-
baseObject = {
|
156571
|
-
identifier: maybeTest.instructions[0].value.place.identifier,
|
156572
|
-
path: path,
|
156573
|
-
};
|
156574
|
-
test = maybeTest.terminal;
|
156575
|
-
} else if (maybeTest.terminal.kind === 'optional') {
|
156576
|
-
const testBlock = context.blocks.get(maybeTest.terminal.fallthrough);
|
156577
|
-
if (testBlock.terminal.kind !== 'branch') {
|
156578
|
-
CompilerError.throwTodo({
|
156579
|
-
reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for optional fallthrough block`,
|
156580
|
-
loc: maybeTest.terminal.loc,
|
156581
|
-
});
|
156582
|
-
}
|
156583
|
-
const innerOptional = traverseOptionalBlock(
|
156584
|
-
maybeTest,
|
156585
|
-
context,
|
156586
|
-
testBlock.terminal.alternate
|
156587
|
-
);
|
156588
|
-
if (innerOptional == null) {
|
156589
|
-
return null;
|
156590
|
-
}
|
156591
|
-
if (testBlock.terminal.test.identifier.id !== innerOptional) {
|
156592
|
-
return null;
|
156593
|
-
}
|
156594
|
-
if (!optional.terminal.optional) {
|
156595
|
-
context.hoistableObjects.set(
|
156596
|
-
optional.id,
|
156597
|
-
assertNonNull(context.temporariesReadInOptional.get(innerOptional))
|
156598
|
-
);
|
156599
|
-
}
|
156600
|
-
baseObject = assertNonNull(
|
156601
|
-
context.temporariesReadInOptional.get(innerOptional)
|
156602
|
-
);
|
156603
|
-
test = testBlock.terminal;
|
156604
|
-
} else {
|
156605
|
-
return null;
|
156606
|
-
}
|
156607
|
-
if (test.alternate === outerAlternate) {
|
156608
|
-
CompilerError.invariant(optional.instructions.length === 0, {
|
156609
|
-
reason:
|
156610
|
-
'[OptionalChainDeps] Unexpected instructions an inner optional block. ' +
|
156611
|
-
'This indicates that the compiler may be incorrectly concatenating two unrelated optional chains',
|
156612
|
-
loc: optional.terminal.loc,
|
156613
|
-
});
|
156614
|
-
}
|
156615
|
-
const matchConsequentResult = matchOptionalTestBlock(test, context.blocks);
|
156616
|
-
if (!matchConsequentResult) {
|
156617
|
-
return null;
|
156618
|
-
}
|
156619
|
-
CompilerError.invariant(
|
156620
|
-
matchConsequentResult.consequentGoto === optional.terminal.fallthrough,
|
156621
|
-
{
|
156622
|
-
reason: '[OptionalChainDeps] Unexpected optional goto-fallthrough',
|
156623
|
-
description: `${matchConsequentResult.consequentGoto} != ${optional.terminal.fallthrough}`,
|
156624
|
-
loc: optional.terminal.loc,
|
155150
|
+
activeTryBlocks.push(block.terminal.handler);
|
156625
155151
|
}
|
156626
|
-
|
156627
|
-
|
156628
|
-
|
156629
|
-
|
156630
|
-
...baseObject.path,
|
156631
|
-
{
|
156632
|
-
property: matchConsequentResult.property,
|
156633
|
-
optional: optional.terminal.optional,
|
156634
|
-
},
|
156635
|
-
],
|
156636
|
-
};
|
156637
|
-
context.processedInstrsInOptional.add(
|
156638
|
-
matchConsequentResult.storeLocalInstrId
|
156639
|
-
);
|
156640
|
-
context.processedInstrsInOptional.add(test.id);
|
156641
|
-
context.temporariesReadInOptional.set(
|
156642
|
-
matchConsequentResult.consequentId,
|
156643
|
-
load
|
156644
|
-
);
|
156645
|
-
context.temporariesReadInOptional.set(matchConsequentResult.propertyId, load);
|
156646
|
-
return matchConsequentResult.consequentId;
|
155152
|
+
}
|
155153
|
+
if (errors.hasErrors()) {
|
155154
|
+
throw errors;
|
155155
|
+
}
|
156647
155156
|
}
|
156648
155157
|
function collectHoistablePropertyLoads(
|
156649
155158
|
fn,
|
156650
155159
|
temporaries,
|
156651
|
-
hoistableFromOptionals
|
156652
|
-
nestedFnImmutableContext
|
155160
|
+
hoistableFromOptionals
|
156653
155161
|
) {
|
156654
155162
|
const registry = new PropertyPathRegistry();
|
156655
|
-
const functionExpressionLoads = collectFunctionExpressionFakeLoads(fn);
|
156656
|
-
const actuallyEvaluatedTemporaries = new Map(
|
156657
|
-
[...temporaries].filter(([id]) => !functionExpressionLoads.has(id))
|
156658
|
-
);
|
156659
155163
|
const knownImmutableIdentifiers = new Set();
|
156660
155164
|
if (fn.fnType === 'Component' || fn.fnType === 'Hook') {
|
156661
155165
|
for (const p of fn.params) {
|
@@ -156664,14 +155168,26 @@ function collectHoistablePropertyLoads(
|
|
156664
155168
|
}
|
156665
155169
|
}
|
156666
155170
|
}
|
156667
|
-
|
156668
|
-
temporaries:
|
155171
|
+
return collectHoistablePropertyLoadsImpl(fn, {
|
155172
|
+
temporaries: temporaries,
|
156669
155173
|
knownImmutableIdentifiers: knownImmutableIdentifiers,
|
156670
155174
|
hoistableFromOptionals: hoistableFromOptionals,
|
156671
155175
|
registry: registry,
|
156672
|
-
nestedFnImmutableContext:
|
155176
|
+
nestedFnImmutableContext: null,
|
156673
155177
|
});
|
156674
|
-
|
155178
|
+
}
|
155179
|
+
function collectHoistablePropertyLoadsImpl(fn, context) {
|
155180
|
+
const functionExpressionLoads = collectFunctionExpressionFakeLoads(fn);
|
155181
|
+
const actuallyEvaluatedTemporaries = new Map(
|
155182
|
+
[...context.temporaries].filter(([id]) => !functionExpressionLoads.has(id))
|
155183
|
+
);
|
155184
|
+
const nodes = collectNonNullsInBlocks(
|
155185
|
+
fn,
|
155186
|
+
Object.assign(Object.assign({}, context), {
|
155187
|
+
temporaries: actuallyEvaluatedTemporaries,
|
155188
|
+
})
|
155189
|
+
);
|
155190
|
+
propagateNonNull(fn, nodes, context.registry);
|
156675
155191
|
return nodes;
|
156676
155192
|
}
|
156677
155193
|
function keyByScopeId(fn, source) {
|
@@ -156808,28 +155324,25 @@ function collectNonNullsInBlocks(fn, context) {
|
|
156808
155324
|
assumedNonNullObjects.add(maybeNonNull);
|
156809
155325
|
}
|
156810
155326
|
if (
|
156811
|
-
instr.value.kind === 'FunctionExpression'
|
155327
|
+
(instr.value.kind === 'FunctionExpression' ||
|
155328
|
+
instr.value.kind === 'ObjectMethod') &&
|
156812
155329
|
!fn.env.config.enableTreatFunctionDepsAsConditional
|
156813
155330
|
) {
|
156814
155331
|
const innerFn = instr.value.loweredFunc;
|
156815
|
-
const
|
156816
|
-
innerFn.func,
|
156817
|
-
new Set()
|
156818
|
-
);
|
156819
|
-
const innerOptionals = collectOptionalChainSidemap(innerFn.func);
|
156820
|
-
const innerHoistableMap = collectHoistablePropertyLoads(
|
155332
|
+
const innerHoistableMap = collectHoistablePropertyLoadsImpl(
|
156821
155333
|
innerFn.func,
|
156822
|
-
|
156823
|
-
|
156824
|
-
|
156825
|
-
|
156826
|
-
|
156827
|
-
|
156828
|
-
|
156829
|
-
|
156830
|
-
|
156831
|
-
|
156832
|
-
|
155334
|
+
Object.assign(Object.assign({}, context), {
|
155335
|
+
nestedFnImmutableContext:
|
155336
|
+
(_a = context.nestedFnImmutableContext) !== null && _a !== void 0
|
155337
|
+
? _a
|
155338
|
+
: new Set(
|
155339
|
+
innerFn.func.context
|
155340
|
+
.filter(place =>
|
155341
|
+
isImmutableAtInstr(place.identifier, instr.id, context)
|
155342
|
+
)
|
155343
|
+
.map(place => place.identifier.id)
|
155344
|
+
),
|
155345
|
+
})
|
156833
155346
|
);
|
156834
155347
|
const innerHoistables = assertNonNull(
|
156835
155348
|
innerHoistableMap.get(innerFn.func.body.entry)
|
@@ -156978,7 +155491,10 @@ function collectFunctionExpressionFakeLoads(fn) {
|
|
156978
155491
|
const functionExpressionReferences = new Set();
|
156979
155492
|
for (const [_, block] of fn.body.blocks) {
|
156980
155493
|
for (const {lvalue: lvalue, value: value} of block.instructions) {
|
156981
|
-
if (
|
155494
|
+
if (
|
155495
|
+
value.kind === 'FunctionExpression' ||
|
155496
|
+
value.kind === 'ObjectMethod'
|
155497
|
+
) {
|
156982
155498
|
for (const reference of value.loweredFunc.dependencies) {
|
156983
155499
|
let curr = reference.identifier.id;
|
156984
155500
|
while (curr != null) {
|
@@ -156993,6 +155509,74 @@ function collectFunctionExpressionFakeLoads(fn) {
|
|
156993
155509
|
}
|
156994
155510
|
return functionExpressionReferences;
|
156995
155511
|
}
|
155512
|
+
var _Node_value, _Node_next;
|
155513
|
+
function empty() {
|
155514
|
+
return EMPTY;
|
155515
|
+
}
|
155516
|
+
class Node {
|
155517
|
+
constructor(value, next = EMPTY) {
|
155518
|
+
_Node_value.set(this, void 0);
|
155519
|
+
_Node_next.set(this, void 0);
|
155520
|
+
__classPrivateFieldSet(this, _Node_value, value, 'f');
|
155521
|
+
__classPrivateFieldSet(this, _Node_next, next, 'f');
|
155522
|
+
}
|
155523
|
+
push(value) {
|
155524
|
+
return new Node(value, this);
|
155525
|
+
}
|
155526
|
+
pop() {
|
155527
|
+
return __classPrivateFieldGet(this, _Node_next, 'f');
|
155528
|
+
}
|
155529
|
+
find(fn) {
|
155530
|
+
return fn(__classPrivateFieldGet(this, _Node_value, 'f'))
|
155531
|
+
? true
|
155532
|
+
: __classPrivateFieldGet(this, _Node_next, 'f').find(fn);
|
155533
|
+
}
|
155534
|
+
contains(value) {
|
155535
|
+
return (
|
155536
|
+
value === __classPrivateFieldGet(this, _Node_value, 'f') ||
|
155537
|
+
(__classPrivateFieldGet(this, _Node_next, 'f') !== null &&
|
155538
|
+
__classPrivateFieldGet(this, _Node_next, 'f').contains(value))
|
155539
|
+
);
|
155540
|
+
}
|
155541
|
+
each(fn) {
|
155542
|
+
fn(__classPrivateFieldGet(this, _Node_value, 'f'));
|
155543
|
+
__classPrivateFieldGet(this, _Node_next, 'f').each(fn);
|
155544
|
+
}
|
155545
|
+
get value() {
|
155546
|
+
return __classPrivateFieldGet(this, _Node_value, 'f');
|
155547
|
+
}
|
155548
|
+
print(fn) {
|
155549
|
+
return (
|
155550
|
+
fn(__classPrivateFieldGet(this, _Node_value, 'f')) +
|
155551
|
+
__classPrivateFieldGet(this, _Node_next, 'f').print(fn)
|
155552
|
+
);
|
155553
|
+
}
|
155554
|
+
}
|
155555
|
+
(_Node_value = new WeakMap()), (_Node_next = new WeakMap());
|
155556
|
+
class Empty {
|
155557
|
+
push(value) {
|
155558
|
+
return new Node(value, this);
|
155559
|
+
}
|
155560
|
+
pop() {
|
155561
|
+
return this;
|
155562
|
+
}
|
155563
|
+
find(_fn) {
|
155564
|
+
return false;
|
155565
|
+
}
|
155566
|
+
contains(_value) {
|
155567
|
+
return false;
|
155568
|
+
}
|
155569
|
+
each(_fn) {
|
155570
|
+
return;
|
155571
|
+
}
|
155572
|
+
get value() {
|
155573
|
+
return null;
|
155574
|
+
}
|
155575
|
+
print(_) {
|
155576
|
+
return '';
|
155577
|
+
}
|
155578
|
+
}
|
155579
|
+
const EMPTY = new Empty();
|
156996
155580
|
var _a,
|
156997
155581
|
_ReactiveScopeDependencyTreeHIR_hoistableObjects,
|
156998
155582
|
_ReactiveScopeDependencyTreeHIR_deps,
|
@@ -157201,56 +155785,258 @@ function merge(access1, access2) {
|
|
157201
155785
|
} else {
|
157202
155786
|
return PropertyAccessType.UnconditionalAccess;
|
157203
155787
|
}
|
157204
|
-
} else {
|
157205
|
-
if (resultIsDependency) {
|
157206
|
-
return PropertyAccessType.OptionalDependency;
|
157207
|
-
} else {
|
157208
|
-
return PropertyAccessType.OptionalAccess;
|
155788
|
+
} else {
|
155789
|
+
if (resultIsDependency) {
|
155790
|
+
return PropertyAccessType.OptionalDependency;
|
155791
|
+
} else {
|
155792
|
+
return PropertyAccessType.OptionalAccess;
|
155793
|
+
}
|
155794
|
+
}
|
155795
|
+
}
|
155796
|
+
function collectMinimalDependenciesInSubtree(
|
155797
|
+
node,
|
155798
|
+
rootIdentifier,
|
155799
|
+
path,
|
155800
|
+
results
|
155801
|
+
) {
|
155802
|
+
if (isDependency(node.accessType)) {
|
155803
|
+
results.add({identifier: rootIdentifier, path: path});
|
155804
|
+
} else {
|
155805
|
+
for (const [childName, childNode] of node.properties) {
|
155806
|
+
collectMinimalDependenciesInSubtree(
|
155807
|
+
childNode,
|
155808
|
+
rootIdentifier,
|
155809
|
+
[
|
155810
|
+
...path,
|
155811
|
+
{property: childName, optional: isOptional(childNode.accessType)},
|
155812
|
+
],
|
155813
|
+
results
|
155814
|
+
);
|
155815
|
+
}
|
155816
|
+
}
|
155817
|
+
}
|
155818
|
+
function printSubtree(node, includeAccesses) {
|
155819
|
+
const results = [];
|
155820
|
+
for (const [propertyName, propertyNode] of node.properties) {
|
155821
|
+
if (includeAccesses || isDependency(propertyNode.accessType)) {
|
155822
|
+
results.push(`${propertyName} (${propertyNode.accessType})`);
|
155823
|
+
}
|
155824
|
+
const propertyResults = printSubtree(propertyNode, includeAccesses);
|
155825
|
+
results.push(...propertyResults.map(result => `${propertyName}.${result}`));
|
155826
|
+
}
|
155827
|
+
return results;
|
155828
|
+
}
|
155829
|
+
function makeOrMergeProperty(node, property, accessType) {
|
155830
|
+
let child = node.properties.get(property);
|
155831
|
+
if (child == null) {
|
155832
|
+
child = {properties: new Map(), accessType: accessType};
|
155833
|
+
node.properties.set(property, child);
|
155834
|
+
} else {
|
155835
|
+
child.accessType = merge(child.accessType, accessType);
|
155836
|
+
}
|
155837
|
+
return child;
|
155838
|
+
}
|
155839
|
+
function collectOptionalChainSidemap(fn) {
|
155840
|
+
const context = {
|
155841
|
+
currFn: fn,
|
155842
|
+
blocks: fn.body.blocks,
|
155843
|
+
seenOptionals: new Set(),
|
155844
|
+
processedInstrsInOptional: new Set(),
|
155845
|
+
temporariesReadInOptional: new Map(),
|
155846
|
+
hoistableObjects: new Map(),
|
155847
|
+
};
|
155848
|
+
traverseFunction(fn, context);
|
155849
|
+
return {
|
155850
|
+
temporariesReadInOptional: context.temporariesReadInOptional,
|
155851
|
+
processedInstrsInOptional: context.processedInstrsInOptional,
|
155852
|
+
hoistableObjects: context.hoistableObjects,
|
155853
|
+
};
|
155854
|
+
}
|
155855
|
+
function traverseFunction(fn, context) {
|
155856
|
+
for (const [_, block] of fn.body.blocks) {
|
155857
|
+
for (const instr of block.instructions) {
|
155858
|
+
if (
|
155859
|
+
instr.value.kind === 'FunctionExpression' ||
|
155860
|
+
instr.value.kind === 'ObjectMethod'
|
155861
|
+
) {
|
155862
|
+
traverseFunction(
|
155863
|
+
instr.value.loweredFunc.func,
|
155864
|
+
Object.assign(Object.assign({}, context), {
|
155865
|
+
currFn: instr.value.loweredFunc.func,
|
155866
|
+
blocks: instr.value.loweredFunc.func.body.blocks,
|
155867
|
+
})
|
155868
|
+
);
|
155869
|
+
}
|
155870
|
+
}
|
155871
|
+
if (
|
155872
|
+
block.terminal.kind === 'optional' &&
|
155873
|
+
!context.seenOptionals.has(block.id)
|
155874
|
+
) {
|
155875
|
+
traverseOptionalBlock(block, context, null);
|
155876
|
+
}
|
155877
|
+
}
|
155878
|
+
}
|
155879
|
+
function matchOptionalTestBlock(terminal, blocks) {
|
155880
|
+
const consequentBlock = assertNonNull(blocks.get(terminal.consequent));
|
155881
|
+
if (
|
155882
|
+
consequentBlock.instructions.length === 2 &&
|
155883
|
+
consequentBlock.instructions[0].value.kind === 'PropertyLoad' &&
|
155884
|
+
consequentBlock.instructions[1].value.kind === 'StoreLocal'
|
155885
|
+
) {
|
155886
|
+
const propertyLoad = consequentBlock.instructions[0];
|
155887
|
+
const storeLocal = consequentBlock.instructions[1].value;
|
155888
|
+
const storeLocalInstr = consequentBlock.instructions[1];
|
155889
|
+
CompilerError.invariant(
|
155890
|
+
propertyLoad.value.object.identifier.id === terminal.test.identifier.id,
|
155891
|
+
{
|
155892
|
+
reason:
|
155893
|
+
'[OptionalChainDeps] Inconsistent optional chaining property load',
|
155894
|
+
description: `Test=${printIdentifier(terminal.test.identifier)} PropertyLoad base=${printIdentifier(propertyLoad.value.object.identifier)}`,
|
155895
|
+
loc: propertyLoad.loc,
|
155896
|
+
}
|
155897
|
+
);
|
155898
|
+
CompilerError.invariant(
|
155899
|
+
storeLocal.value.identifier.id === propertyLoad.lvalue.identifier.id,
|
155900
|
+
{
|
155901
|
+
reason: '[OptionalChainDeps] Unexpected storeLocal',
|
155902
|
+
loc: propertyLoad.loc,
|
155903
|
+
}
|
155904
|
+
);
|
155905
|
+
if (
|
155906
|
+
consequentBlock.terminal.kind !== 'goto' ||
|
155907
|
+
consequentBlock.terminal.variant !== GotoVariant.Break
|
155908
|
+
) {
|
155909
|
+
return null;
|
155910
|
+
}
|
155911
|
+
const alternate = assertNonNull(blocks.get(terminal.alternate));
|
155912
|
+
CompilerError.invariant(
|
155913
|
+
alternate.instructions.length === 2 &&
|
155914
|
+
alternate.instructions[0].value.kind === 'Primitive' &&
|
155915
|
+
alternate.instructions[1].value.kind === 'StoreLocal',
|
155916
|
+
{reason: 'Unexpected alternate structure', loc: terminal.loc}
|
155917
|
+
);
|
155918
|
+
return {
|
155919
|
+
consequentId: storeLocal.lvalue.place.identifier.id,
|
155920
|
+
property: propertyLoad.value.property,
|
155921
|
+
propertyId: propertyLoad.lvalue.identifier.id,
|
155922
|
+
storeLocalInstr: storeLocalInstr,
|
155923
|
+
consequentGoto: consequentBlock.terminal.block,
|
155924
|
+
};
|
155925
|
+
}
|
155926
|
+
return null;
|
155927
|
+
}
|
155928
|
+
function traverseOptionalBlock(optional, context, outerAlternate) {
|
155929
|
+
context.seenOptionals.add(optional.id);
|
155930
|
+
const maybeTest = context.blocks.get(optional.terminal.test);
|
155931
|
+
let test;
|
155932
|
+
let baseObject;
|
155933
|
+
if (maybeTest.terminal.kind === 'branch') {
|
155934
|
+
CompilerError.invariant(optional.terminal.optional, {
|
155935
|
+
reason: '[OptionalChainDeps] Expect base case to be always optional',
|
155936
|
+
loc: optional.terminal.loc,
|
155937
|
+
});
|
155938
|
+
if (
|
155939
|
+
maybeTest.instructions.length === 0 ||
|
155940
|
+
maybeTest.instructions[0].value.kind !== 'LoadLocal'
|
155941
|
+
) {
|
155942
|
+
return null;
|
155943
|
+
}
|
155944
|
+
const path = [];
|
155945
|
+
for (let i = 1; i < maybeTest.instructions.length; i++) {
|
155946
|
+
const instrVal = maybeTest.instructions[i].value;
|
155947
|
+
const prevInstr = maybeTest.instructions[i - 1];
|
155948
|
+
if (
|
155949
|
+
instrVal.kind === 'PropertyLoad' &&
|
155950
|
+
instrVal.object.identifier.id === prevInstr.lvalue.identifier.id
|
155951
|
+
) {
|
155952
|
+
path.push({property: instrVal.property, optional: false});
|
155953
|
+
} else {
|
155954
|
+
return null;
|
155955
|
+
}
|
157209
155956
|
}
|
157210
|
-
|
157211
|
-
|
157212
|
-
|
157213
|
-
|
157214
|
-
|
157215
|
-
|
157216
|
-
|
157217
|
-
)
|
157218
|
-
|
157219
|
-
|
157220
|
-
|
157221
|
-
|
157222
|
-
|
157223
|
-
|
157224
|
-
|
157225
|
-
|
157226
|
-
|
157227
|
-
|
157228
|
-
|
157229
|
-
|
155957
|
+
CompilerError.invariant(
|
155958
|
+
maybeTest.terminal.test.identifier.id ===
|
155959
|
+
maybeTest.instructions.at(-1).lvalue.identifier.id,
|
155960
|
+
{
|
155961
|
+
reason: '[OptionalChainDeps] Unexpected test expression',
|
155962
|
+
loc: maybeTest.terminal.loc,
|
155963
|
+
}
|
155964
|
+
);
|
155965
|
+
baseObject = {
|
155966
|
+
identifier: maybeTest.instructions[0].value.place.identifier,
|
155967
|
+
path: path,
|
155968
|
+
};
|
155969
|
+
test = maybeTest.terminal;
|
155970
|
+
} else if (maybeTest.terminal.kind === 'optional') {
|
155971
|
+
const testBlock = context.blocks.get(maybeTest.terminal.fallthrough);
|
155972
|
+
if (testBlock.terminal.kind !== 'branch') {
|
155973
|
+
CompilerError.throwTodo({
|
155974
|
+
reason: `Unexpected terminal kind \`${testBlock.terminal.kind}\` for optional fallthrough block`,
|
155975
|
+
loc: maybeTest.terminal.loc,
|
155976
|
+
});
|
155977
|
+
}
|
155978
|
+
const innerOptional = traverseOptionalBlock(
|
155979
|
+
maybeTest,
|
155980
|
+
context,
|
155981
|
+
testBlock.terminal.alternate
|
155982
|
+
);
|
155983
|
+
if (innerOptional == null) {
|
155984
|
+
return null;
|
155985
|
+
}
|
155986
|
+
if (testBlock.terminal.test.identifier.id !== innerOptional) {
|
155987
|
+
return null;
|
155988
|
+
}
|
155989
|
+
if (!optional.terminal.optional) {
|
155990
|
+
context.hoistableObjects.set(
|
155991
|
+
optional.id,
|
155992
|
+
assertNonNull(context.temporariesReadInOptional.get(innerOptional))
|
157230
155993
|
);
|
157231
155994
|
}
|
155995
|
+
baseObject = assertNonNull(
|
155996
|
+
context.temporariesReadInOptional.get(innerOptional)
|
155997
|
+
);
|
155998
|
+
test = testBlock.terminal;
|
155999
|
+
} else {
|
156000
|
+
return null;
|
157232
156001
|
}
|
157233
|
-
|
157234
|
-
|
157235
|
-
|
157236
|
-
|
157237
|
-
|
157238
|
-
|
157239
|
-
}
|
157240
|
-
const propertyResults = printSubtree(propertyNode, includeAccesses);
|
157241
|
-
results.push(...propertyResults.map(result => `${propertyName}.${result}`));
|
156002
|
+
if (test.alternate === outerAlternate) {
|
156003
|
+
CompilerError.invariant(optional.instructions.length === 0, {
|
156004
|
+
reason:
|
156005
|
+
'[OptionalChainDeps] Unexpected instructions an inner optional block. ' +
|
156006
|
+
'This indicates that the compiler may be incorrectly concatenating two unrelated optional chains',
|
156007
|
+
loc: optional.terminal.loc,
|
156008
|
+
});
|
157242
156009
|
}
|
157243
|
-
|
157244
|
-
|
157245
|
-
|
157246
|
-
let child = node.properties.get(property);
|
157247
|
-
if (child == null) {
|
157248
|
-
child = {properties: new Map(), accessType: accessType};
|
157249
|
-
node.properties.set(property, child);
|
157250
|
-
} else {
|
157251
|
-
child.accessType = merge(child.accessType, accessType);
|
156010
|
+
const matchConsequentResult = matchOptionalTestBlock(test, context.blocks);
|
156011
|
+
if (!matchConsequentResult) {
|
156012
|
+
return null;
|
157252
156013
|
}
|
157253
|
-
|
156014
|
+
CompilerError.invariant(
|
156015
|
+
matchConsequentResult.consequentGoto === optional.terminal.fallthrough,
|
156016
|
+
{
|
156017
|
+
reason: '[OptionalChainDeps] Unexpected optional goto-fallthrough',
|
156018
|
+
description: `${matchConsequentResult.consequentGoto} != ${optional.terminal.fallthrough}`,
|
156019
|
+
loc: optional.terminal.loc,
|
156020
|
+
}
|
156021
|
+
);
|
156022
|
+
const load = {
|
156023
|
+
identifier: baseObject.identifier,
|
156024
|
+
path: [
|
156025
|
+
...baseObject.path,
|
156026
|
+
{
|
156027
|
+
property: matchConsequentResult.property,
|
156028
|
+
optional: optional.terminal.optional,
|
156029
|
+
},
|
156030
|
+
],
|
156031
|
+
};
|
156032
|
+
context.processedInstrsInOptional.add(matchConsequentResult.storeLocalInstr);
|
156033
|
+
context.processedInstrsInOptional.add(test);
|
156034
|
+
context.temporariesReadInOptional.set(
|
156035
|
+
matchConsequentResult.consequentId,
|
156036
|
+
load
|
156037
|
+
);
|
156038
|
+
context.temporariesReadInOptional.set(matchConsequentResult.propertyId, load);
|
156039
|
+
return matchConsequentResult.consequentId;
|
157254
156040
|
}
|
157255
156041
|
var _Context_instances,
|
157256
156042
|
_Context_declarations,
|
@@ -157272,7 +156058,7 @@ function propagateScopeDependenciesHIR(fn) {
|
|
157272
156058
|
} = collectOptionalChainSidemap(fn);
|
157273
156059
|
const hoistablePropertyLoads = keyByScopeId(
|
157274
156060
|
fn,
|
157275
|
-
collectHoistablePropertyLoads(fn, temporaries, hoistableObjects
|
156061
|
+
collectHoistablePropertyLoads(fn, temporaries, hoistableObjects)
|
157276
156062
|
);
|
157277
156063
|
const scopeDeps = collectDependencies(
|
157278
156064
|
fn,
|
@@ -157364,6 +156150,20 @@ function findTemporariesUsedOutsideDeclaringScope(fn) {
|
|
157364
156150
|
}
|
157365
156151
|
function collectTemporariesSidemap(fn, usedOutsideDeclaringScope) {
|
157366
156152
|
const temporaries = new Map();
|
156153
|
+
collectTemporariesSidemapImpl(
|
156154
|
+
fn,
|
156155
|
+
usedOutsideDeclaringScope,
|
156156
|
+
temporaries,
|
156157
|
+
false
|
156158
|
+
);
|
156159
|
+
return temporaries;
|
156160
|
+
}
|
156161
|
+
function collectTemporariesSidemapImpl(
|
156162
|
+
fn,
|
156163
|
+
usedOutsideDeclaringScope,
|
156164
|
+
temporaries,
|
156165
|
+
isInnerFn
|
156166
|
+
) {
|
157367
156167
|
for (const [_, block] of fn.body.blocks) {
|
157368
156168
|
for (const instr of block.instructions) {
|
157369
156169
|
const {value: value, lvalue: lvalue} = instr;
|
@@ -157371,27 +156171,45 @@ function collectTemporariesSidemap(fn, usedOutsideDeclaringScope) {
|
|
157371
156171
|
lvalue.identifier.declarationId
|
157372
156172
|
);
|
157373
156173
|
if (value.kind === 'PropertyLoad' && !usedOutside) {
|
157374
|
-
|
157375
|
-
|
157376
|
-
|
157377
|
-
|
157378
|
-
|
157379
|
-
|
157380
|
-
|
156174
|
+
if (!isInnerFn || temporaries.has(value.object.identifier.id)) {
|
156175
|
+
const property = getProperty(
|
156176
|
+
value.object,
|
156177
|
+
value.property,
|
156178
|
+
false,
|
156179
|
+
temporaries
|
156180
|
+
);
|
156181
|
+
temporaries.set(lvalue.identifier.id, property);
|
156182
|
+
}
|
157381
156183
|
} else if (
|
157382
156184
|
value.kind === 'LoadLocal' &&
|
157383
156185
|
lvalue.identifier.name == null &&
|
157384
156186
|
value.place.identifier.name !== null &&
|
157385
156187
|
!usedOutside
|
157386
156188
|
) {
|
157387
|
-
|
157388
|
-
|
157389
|
-
|
157390
|
-
|
156189
|
+
if (
|
156190
|
+
!isInnerFn ||
|
156191
|
+
fn.context.some(
|
156192
|
+
context => context.identifier.id === value.place.identifier.id
|
156193
|
+
)
|
156194
|
+
) {
|
156195
|
+
temporaries.set(lvalue.identifier.id, {
|
156196
|
+
identifier: value.place.identifier,
|
156197
|
+
path: [],
|
156198
|
+
});
|
156199
|
+
}
|
156200
|
+
} else if (
|
156201
|
+
value.kind === 'FunctionExpression' ||
|
156202
|
+
value.kind === 'ObjectMethod'
|
156203
|
+
) {
|
156204
|
+
collectTemporariesSidemapImpl(
|
156205
|
+
value.loweredFunc.func,
|
156206
|
+
usedOutsideDeclaringScope,
|
156207
|
+
temporaries,
|
156208
|
+
true
|
156209
|
+
);
|
157391
156210
|
}
|
157392
156211
|
}
|
157393
156212
|
}
|
157394
|
-
return temporaries;
|
157395
156213
|
}
|
157396
156214
|
function getProperty(object, propertyName, optional, temporaries) {
|
157397
156215
|
const resolvedDependency = temporaries.get(object.identifier.id);
|
@@ -157422,6 +156240,7 @@ class Context {
|
|
157422
156240
|
this.deps = new Map();
|
157423
156241
|
_Context_temporaries.set(this, void 0);
|
157424
156242
|
_Context_temporariesUsedOutsideScope.set(this, void 0);
|
156243
|
+
this.inInnerFn = false;
|
157425
156244
|
__classPrivateFieldSet(
|
157426
156245
|
this,
|
157427
156246
|
_Context_temporariesUsedOutsideScope,
|
@@ -157497,6 +156316,7 @@ class Context {
|
|
157497
156316
|
).has(place.identifier.declarationId);
|
157498
156317
|
}
|
157499
156318
|
declare(identifier, decl) {
|
156319
|
+
if (this.inInnerFn) return;
|
157500
156320
|
if (
|
157501
156321
|
!__classPrivateFieldGet(this, _Context_declarations, 'f').has(
|
157502
156322
|
identifier.declarationId
|
@@ -157535,6 +156355,7 @@ class Context {
|
|
157535
156355
|
this.visitDependency(nextDependency);
|
157536
156356
|
}
|
157537
156357
|
visitDependency(maybeDependency) {
|
156358
|
+
var _a;
|
157538
156359
|
const originalDeclaration = __classPrivateFieldGet(
|
157539
156360
|
this,
|
157540
156361
|
_Context_declarations,
|
@@ -157566,6 +156387,14 @@ class Context {
|
|
157566
156387
|
}
|
157567
156388
|
});
|
157568
156389
|
}
|
156390
|
+
if (
|
156391
|
+
isUseRefType(maybeDependency.identifier) &&
|
156392
|
+
((_a = maybeDependency.path.at(0)) === null || _a === void 0
|
156393
|
+
? void 0
|
156394
|
+
: _a.property) === 'current'
|
156395
|
+
) {
|
156396
|
+
maybeDependency = {identifier: maybeDependency.identifier, path: []};
|
156397
|
+
}
|
157569
156398
|
if (
|
157570
156399
|
__classPrivateFieldGet(
|
157571
156400
|
this,
|
@@ -157609,15 +156438,7 @@ class Context {
|
|
157609
156438
|
(_Context_checkValidDependency = function _Context_checkValidDependency(
|
157610
156439
|
maybeDependency
|
157611
156440
|
) {
|
157612
|
-
var _a
|
157613
|
-
if (
|
157614
|
-
isUseRefType(maybeDependency.identifier) &&
|
157615
|
-
((_a = maybeDependency.path.at(0)) === null || _a === void 0
|
157616
|
-
? void 0
|
157617
|
-
: _a.property) === 'current'
|
157618
|
-
) {
|
157619
|
-
return false;
|
157620
|
-
}
|
156441
|
+
var _a;
|
157621
156442
|
if (isRefValueType(maybeDependency.identifier)) {
|
157622
156443
|
return false;
|
157623
156444
|
}
|
@@ -157626,10 +156447,10 @@ class Context {
|
|
157626
156447
|
}
|
157627
156448
|
const identifier = maybeDependency.identifier;
|
157628
156449
|
const currentDeclaration =
|
157629
|
-
(
|
156450
|
+
(_a = __classPrivateFieldGet(this, _Context_reassignments, 'f').get(
|
157630
156451
|
identifier
|
157631
|
-
)) !== null &&
|
157632
|
-
?
|
156452
|
+
)) !== null && _a !== void 0
|
156453
|
+
? _a
|
157633
156454
|
: __classPrivateFieldGet(this, _Context_declarations, 'f').get(
|
157634
156455
|
identifier.declarationId
|
157635
156456
|
);
|
@@ -157712,46 +156533,57 @@ function collectDependencies(
|
|
157712
156533
|
}
|
157713
156534
|
}
|
157714
156535
|
const scopeTraversal = new ScopeBlockTraversal();
|
157715
|
-
|
157716
|
-
|
157717
|
-
|
157718
|
-
|
157719
|
-
(
|
157720
|
-
|
157721
|
-
: scopeBlockInfo.kind) === 'begin'
|
157722
|
-
) {
|
157723
|
-
context.enterScope(scopeBlockInfo.scope);
|
157724
|
-
} else if (
|
157725
|
-
(scopeBlockInfo === null || scopeBlockInfo === void 0
|
157726
|
-
? void 0
|
157727
|
-
: scopeBlockInfo.kind) === 'end'
|
157728
|
-
) {
|
157729
|
-
context.exitScope(
|
157730
|
-
scopeBlockInfo.scope,
|
157731
|
-
scopeBlockInfo === null || scopeBlockInfo === void 0
|
156536
|
+
const handleFunction = fn => {
|
156537
|
+
for (const [blockId, block] of fn.body.blocks) {
|
156538
|
+
scopeTraversal.recordScopes(block);
|
156539
|
+
const scopeBlockInfo = scopeTraversal.blockInfos.get(blockId);
|
156540
|
+
if (
|
156541
|
+
(scopeBlockInfo === null || scopeBlockInfo === void 0
|
157732
156542
|
? void 0
|
157733
|
-
: scopeBlockInfo.
|
157734
|
-
)
|
157735
|
-
|
157736
|
-
|
157737
|
-
|
157738
|
-
|
157739
|
-
|
157740
|
-
|
156543
|
+
: scopeBlockInfo.kind) === 'begin'
|
156544
|
+
) {
|
156545
|
+
context.enterScope(scopeBlockInfo.scope);
|
156546
|
+
} else if (
|
156547
|
+
(scopeBlockInfo === null || scopeBlockInfo === void 0
|
156548
|
+
? void 0
|
156549
|
+
: scopeBlockInfo.kind) === 'end'
|
156550
|
+
) {
|
156551
|
+
context.exitScope(scopeBlockInfo.scope, scopeBlockInfo.pruned);
|
156552
|
+
}
|
156553
|
+
for (const phi of block.phis) {
|
156554
|
+
for (const operand of phi.operands) {
|
156555
|
+
const maybeOptionalChain = temporaries.get(operand[1].identifier.id);
|
156556
|
+
if (maybeOptionalChain) {
|
156557
|
+
context.visitDependency(maybeOptionalChain);
|
156558
|
+
}
|
157741
156559
|
}
|
157742
156560
|
}
|
157743
|
-
|
157744
|
-
|
157745
|
-
|
157746
|
-
|
156561
|
+
for (const instr of block.instructions) {
|
156562
|
+
if (
|
156563
|
+
fn.env.config.enableFunctionDependencyRewrite &&
|
156564
|
+
(instr.value.kind === 'FunctionExpression' ||
|
156565
|
+
instr.value.kind === 'ObjectMethod')
|
156566
|
+
) {
|
156567
|
+
context.declare(instr.lvalue.identifier, {
|
156568
|
+
id: instr.id,
|
156569
|
+
scope: context.currentScope,
|
156570
|
+
});
|
156571
|
+
const wasInInnerFn = context.inInnerFn;
|
156572
|
+
context.inInnerFn = true;
|
156573
|
+
handleFunction(instr.value.loweredFunc.func);
|
156574
|
+
context.inInnerFn = wasInInnerFn;
|
156575
|
+
} else if (!processedInstrsInOptional.has(instr)) {
|
156576
|
+
handleInstruction(instr, context);
|
156577
|
+
}
|
157747
156578
|
}
|
157748
|
-
|
157749
|
-
|
157750
|
-
|
157751
|
-
|
156579
|
+
if (!processedInstrsInOptional.has(block.terminal)) {
|
156580
|
+
for (const place of eachTerminalOperand(block.terminal)) {
|
156581
|
+
context.visitOperand(place);
|
156582
|
+
}
|
157752
156583
|
}
|
157753
156584
|
}
|
157754
|
-
}
|
156585
|
+
};
|
156586
|
+
handleFunction(fn);
|
157755
156587
|
return context.deps;
|
157756
156588
|
}
|
157757
156589
|
function outlineJSX(fn) {
|
@@ -157884,6 +156716,15 @@ function process$1(fn, jsx, globals) {
|
|
157884
156716
|
return {instrs: newInstrs, fn: outlinedFn};
|
157885
156717
|
}
|
157886
156718
|
function collectProps(instructions) {
|
156719
|
+
let id = 1;
|
156720
|
+
function generateName(oldName) {
|
156721
|
+
let newName = oldName;
|
156722
|
+
while (seen.has(newName)) {
|
156723
|
+
newName = `${oldName}${id++}`;
|
156724
|
+
}
|
156725
|
+
seen.add(newName);
|
156726
|
+
return newName;
|
156727
|
+
}
|
157887
156728
|
const attributes = [];
|
157888
156729
|
const jsxIds = new Set(instructions.map(i => i.lvalue.identifier.id));
|
157889
156730
|
const seen = new Set();
|
@@ -157893,24 +156734,38 @@ function collectProps(instructions) {
|
|
157893
156734
|
if (at.kind === 'JsxSpreadAttribute') {
|
157894
156735
|
return null;
|
157895
156736
|
}
|
157896
|
-
if (seen.has(at.name)) {
|
157897
|
-
return null;
|
157898
|
-
}
|
157899
156737
|
if (at.kind === 'JsxAttribute') {
|
157900
|
-
|
157901
|
-
attributes.push(
|
156738
|
+
const newName = generateName(at.name);
|
156739
|
+
attributes.push({
|
156740
|
+
originalName: at.name,
|
156741
|
+
newName: newName,
|
156742
|
+
place: at.place,
|
156743
|
+
});
|
157902
156744
|
}
|
157903
156745
|
}
|
157904
|
-
if (
|
157905
|
-
value.children
|
157906
|
-
|
157907
|
-
|
157908
|
-
|
156746
|
+
if (value.children) {
|
156747
|
+
for (const child of value.children) {
|
156748
|
+
if (jsxIds.has(child.identifier.id)) {
|
156749
|
+
continue;
|
156750
|
+
}
|
156751
|
+
promoteTemporary(child.identifier);
|
156752
|
+
const newName = generateName('t');
|
156753
|
+
attributes.push({
|
156754
|
+
originalName: child.identifier.name.value,
|
156755
|
+
newName: newName,
|
156756
|
+
place: child,
|
156757
|
+
});
|
156758
|
+
}
|
157909
156759
|
}
|
157910
156760
|
}
|
157911
156761
|
return attributes;
|
157912
156762
|
}
|
157913
|
-
function emitOutlinedJsx(env, instructions,
|
156763
|
+
function emitOutlinedJsx(env, instructions, outlinedProps, outlinedTag) {
|
156764
|
+
const props = outlinedProps.map(p => ({
|
156765
|
+
kind: 'JsxAttribute',
|
156766
|
+
name: p.newName,
|
156767
|
+
place: p.place,
|
156768
|
+
}));
|
157914
156769
|
const loadJsx = {
|
157915
156770
|
id: makeInstructionId(0),
|
157916
156771
|
loc: GeneratedSource,
|
@@ -157943,9 +156798,11 @@ function emitOutlinedFn(env, jsx, oldProps, globals) {
|
|
157943
156798
|
const oldToNewProps = createOldToNewPropsMapping(env, oldProps);
|
157944
156799
|
const propsObj = createTemporaryPlace(env, GeneratedSource);
|
157945
156800
|
promoteTemporary(propsObj.identifier);
|
157946
|
-
const destructurePropsInstr = emitDestructureProps(
|
157947
|
-
|
157948
|
-
|
156801
|
+
const destructurePropsInstr = emitDestructureProps(
|
156802
|
+
env,
|
156803
|
+
propsObj,
|
156804
|
+
oldToNewProps
|
156805
|
+
);
|
157949
156806
|
instructions.push(destructurePropsInstr);
|
157950
156807
|
const updatedJsxInstructions = emitUpdatedJsx(jsx, oldToNewProps);
|
157951
156808
|
const loadGlobalInstrs = emitLoadGlobals(jsx, globals);
|
@@ -157999,6 +156856,7 @@ function emitLoadGlobals(jsx, globals) {
|
|
157999
156856
|
}
|
158000
156857
|
function emitUpdatedJsx(jsx, oldToNewProps) {
|
158001
156858
|
const newInstrs = [];
|
156859
|
+
const jsxIds = new Set(jsx.map(i => i.lvalue.identifier.id));
|
158002
156860
|
for (const instr of jsx) {
|
158003
156861
|
const {value: value} = instr;
|
158004
156862
|
const newProps = [];
|
@@ -158015,13 +156873,34 @@ function emitUpdatedJsx(jsx, oldToNewProps) {
|
|
158015
156873
|
newProp !== undefined,
|
158016
156874
|
`Expected a new property for ${printIdentifier(prop.place.identifier)}`
|
158017
156875
|
);
|
158018
|
-
newProps.push(
|
158019
|
-
|
158020
|
-
|
156876
|
+
newProps.push({
|
156877
|
+
kind: 'JsxAttribute',
|
156878
|
+
name: newProp.originalName,
|
156879
|
+
place: newProp.place,
|
156880
|
+
});
|
156881
|
+
}
|
156882
|
+
let newChildren = null;
|
156883
|
+
if (value.children) {
|
156884
|
+
newChildren = [];
|
156885
|
+
for (const child of value.children) {
|
156886
|
+
if (jsxIds.has(child.identifier.id)) {
|
156887
|
+
newChildren.push(Object.assign({}, child));
|
156888
|
+
continue;
|
156889
|
+
}
|
156890
|
+
const newChild = oldToNewProps.get(child.identifier.id);
|
156891
|
+
invariant$1(
|
156892
|
+
newChild !== undefined,
|
156893
|
+
`Expected a new prop for ${printIdentifier(child.identifier)}`
|
156894
|
+
);
|
156895
|
+
newChildren.push(Object.assign({}, newChild.place));
|
156896
|
+
}
|
158021
156897
|
}
|
158022
156898
|
newInstrs.push(
|
158023
156899
|
Object.assign(Object.assign({}, instr), {
|
158024
|
-
value: Object.assign(Object.assign({}, value), {
|
156900
|
+
value: Object.assign(Object.assign({}, value), {
|
156901
|
+
props: newProps,
|
156902
|
+
children: newChildren,
|
156903
|
+
}),
|
158025
156904
|
})
|
158026
156905
|
);
|
158027
156906
|
}
|
@@ -158030,25 +156909,27 @@ function emitUpdatedJsx(jsx, oldToNewProps) {
|
|
158030
156909
|
function createOldToNewPropsMapping(env, oldProps) {
|
158031
156910
|
const oldToNewProps = new Map();
|
158032
156911
|
for (const oldProp of oldProps) {
|
158033
|
-
|
158034
|
-
oldProp.kind === 'JsxAttribute',
|
158035
|
-
`Expected only attributes but found ${oldProp.kind}`
|
158036
|
-
);
|
158037
|
-
if (oldProp.name === 'key') {
|
156912
|
+
if (oldProp.originalName === 'key') {
|
158038
156913
|
continue;
|
158039
156914
|
}
|
158040
|
-
const newProp = {
|
158041
|
-
kind: 'ObjectProperty',
|
158042
|
-
key: {kind: 'string', name: oldProp.name},
|
158043
|
-
type: 'property',
|
156915
|
+
const newProp = Object.assign(Object.assign({}, oldProp), {
|
158044
156916
|
place: createTemporaryPlace(env, GeneratedSource),
|
158045
|
-
};
|
158046
|
-
newProp.place.identifier.name = makeIdentifierName(oldProp.
|
156917
|
+
});
|
156918
|
+
newProp.place.identifier.name = makeIdentifierName(oldProp.newName);
|
158047
156919
|
oldToNewProps.set(oldProp.place.identifier.id, newProp);
|
158048
156920
|
}
|
158049
156921
|
return oldToNewProps;
|
158050
156922
|
}
|
158051
|
-
function emitDestructureProps(env, propsObj,
|
156923
|
+
function emitDestructureProps(env, propsObj, oldToNewProps) {
|
156924
|
+
const properties = [];
|
156925
|
+
for (const [_, prop] of oldToNewProps) {
|
156926
|
+
properties.push({
|
156927
|
+
kind: 'ObjectProperty',
|
156928
|
+
key: {kind: 'string', name: prop.newName},
|
156929
|
+
type: 'property',
|
156930
|
+
place: prop.place,
|
156931
|
+
});
|
156932
|
+
}
|
158052
156933
|
const destructurePropsInstr = {
|
158053
156934
|
id: makeInstructionId(0),
|
158054
156935
|
lvalue: createTemporaryPlace(env, GeneratedSource),
|
@@ -158219,10 +157100,8 @@ function* runWithEnvironment(func, env) {
|
|
158219
157100
|
yield log({kind: 'hir', name: 'FlattenScopesWithHooksOrUseHIR', value: hir});
|
158220
157101
|
assertTerminalSuccessorsExist(hir);
|
158221
157102
|
assertTerminalPredsExist(hir);
|
158222
|
-
|
158223
|
-
|
158224
|
-
yield log({kind: 'hir', name: 'PropagateScopeDependenciesHIR', value: hir});
|
158225
|
-
}
|
157103
|
+
propagateScopeDependenciesHIR(hir);
|
157104
|
+
yield log({kind: 'hir', name: 'PropagateScopeDependenciesHIR', value: hir});
|
158226
157105
|
if (env.config.inlineJsxTransform) {
|
158227
157106
|
inlineJsxTransform(hir, env.config.inlineJsxTransform);
|
158228
157107
|
yield log({kind: 'hir', name: 'inlineJsxTransform', value: hir});
|
@@ -158241,14 +157120,6 @@ function* runWithEnvironment(func, env) {
|
|
158241
157120
|
value: reactiveFunction,
|
158242
157121
|
});
|
158243
157122
|
assertScopeInstructionsWithinScopes(reactiveFunction);
|
158244
|
-
if (!env.config.enablePropagateDepsInHIR) {
|
158245
|
-
propagateScopeDependencies(reactiveFunction);
|
158246
|
-
yield log({
|
158247
|
-
kind: 'reactive',
|
158248
|
-
name: 'PropagateScopeDependencies',
|
158249
|
-
value: reactiveFunction,
|
158250
|
-
});
|
158251
|
-
}
|
158252
157123
|
pruneNonEscapingScopes(reactiveFunction);
|
158253
157124
|
yield log({
|
158254
157125
|
kind: 'reactive',
|
@@ -159479,7 +158350,7 @@ exports.OPT_OUT_DIRECTIVES = OPT_OUT_DIRECTIVES;
|
|
159479
158350
|
exports.compile = compileFn;
|
159480
158351
|
exports.compileProgram = compileProgram;
|
159481
158352
|
exports.default = BabelPluginReactCompiler;
|
159482
|
-
exports.
|
158353
|
+
exports.parseConfigPragmaForTests = parseConfigPragmaForTests;
|
159483
158354
|
exports.parsePluginOptions = parsePluginOptions;
|
159484
158355
|
exports.printHIR = printHIR;
|
159485
158356
|
exports.printReactiveFunction = printReactiveFunction;
|