@@ -37178,49 +37178,30 @@ function memoizeFbtAndMacroOperandsInSameScope(fn) {
3717837178 ...Array.from(FBT_TAGS).map((tag) => [tag, []]),
3717937179 ...((_a = fn.env.config.customMacros) !== null && _a !== void 0 ? _a : []),
3718037180 ]);
37181- const macroTagsCalls = new Set();
37182- const macroValues = new Map();
37181+ const fbtValues = new Set();
3718337182 const macroMethods = new Map();
37184- visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues);
37185- for (const root of macroValues.keys()) {
37186- const scope = root.scope;
37187- if (scope == null) {
37188- continue;
37189- }
37190- if (!macroTagsCalls.has(root.id)) {
37191- continue;
37183+ while (true) {
37184+ let vsize = fbtValues.size;
37185+ let msize = macroMethods.size;
37186+ visit$1(fn, fbtMacroTags, fbtValues, macroMethods);
37187+ if (vsize === fbtValues.size && msize === macroMethods.size) {
37188+ break;
3719237189 }
37193- mergeScopes(root, scope, macroValues, macroTagsCalls);
3719437190 }
37195- return macroTagsCalls ;
37191+ return fbtValues ;
3719637192}
3719737193const FBT_TAGS = new Set([
3719837194 'fbt',
3719937195 'fbt:param',
37200- 'fbt:enum',
37201- 'fbt:plural',
3720237196 'fbs',
3720337197 'fbs:param',
37204- 'fbs:enum',
37205- 'fbs:plural',
3720637198]);
3720737199const SINGLE_CHILD_FBT_TAGS = new Set([
3720837200 'fbt:param',
3720937201 'fbs:param',
3721037202]);
37211- function visit$1(fn, fbtMacroTags, macroTagsCalls , macroMethods, macroValues ) {
37203+ function visit$1(fn, fbtMacroTags, fbtValues , macroMethods) {
3721237204 for (const [, block] of fn.body.blocks) {
37213- for (const phi of block.phis) {
37214- const macroOperands = [];
37215- for (const operand of phi.operands.values()) {
37216- if (macroValues.has(operand.identifier)) {
37217- macroOperands.push(operand.identifier);
37218- }
37219- }
37220- if (macroOperands.length !== 0) {
37221- macroValues.set(phi.place.identifier, macroOperands);
37222- }
37223- }
3722437205 for (const instruction of block.instructions) {
3722537206 const { lvalue, value } = instruction;
3722637207 if (lvalue === null) {
@@ -37229,11 +37210,11 @@ function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
3722937210 if (value.kind === 'Primitive' &&
3723037211 typeof value.value === 'string' &&
3723137212 matchesExactTag(value.value, fbtMacroTags)) {
37232- macroTagsCalls .add(lvalue.identifier.id);
37213+ fbtValues .add(lvalue.identifier.id);
3723337214 }
3723437215 else if (value.kind === 'LoadGlobal' &&
3723537216 matchesExactTag(value.binding.name, fbtMacroTags)) {
37236- macroTagsCalls .add(lvalue.identifier.id);
37217+ fbtValues .add(lvalue.identifier.id);
3723737218 }
3723837219 else if (value.kind === 'LoadGlobal' &&
3723937220 matchTagRoot(value.binding.name, fbtMacroTags) !== null) {
@@ -37252,48 +37233,54 @@ function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
3725237233 newMethods.push(method.slice(1));
3725337234 }
3725437235 else {
37255- macroTagsCalls .add(lvalue.identifier.id);
37236+ fbtValues .add(lvalue.identifier.id);
3725637237 }
3725737238 }
3725837239 }
3725937240 if (newMethods.length > 0) {
3726037241 macroMethods.set(lvalue.identifier.id, newMethods);
3726137242 }
3726237243 }
37263- else if (value.kind === 'PropertyLoad' &&
37264- macroTagsCalls.has(value.object.identifier.id)) {
37265- macroTagsCalls.add(lvalue.identifier.id);
37244+ else if (isFbtCallExpression(fbtValues, value)) {
37245+ const fbtScope = lvalue.identifier.scope;
37246+ if (fbtScope === null) {
37247+ continue;
37248+ }
37249+ for (const operand of eachReactiveValueOperand(value)) {
37250+ operand.identifier.scope = fbtScope;
37251+ expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
37252+ fbtValues.add(operand.identifier.id);
37253+ }
3726637254 }
37267- else if (isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) ||
37268- isFbtJsxChild(macroTagsCalls, lvalue, value) ||
37269- isFbtCallExpression(macroTagsCalls, value)) {
37270- macroTagsCalls.add(lvalue.identifier.id);
37271- macroValues.set(lvalue.identifier, Array.from(eachInstructionValueOperand(value), operand => operand.identifier));
37255+ else if (isFbtJsxExpression(fbtMacroTags, fbtValues, value) ||
37256+ isFbtJsxChild(fbtValues, lvalue, value)) {
37257+ const fbtScope = lvalue.identifier.scope;
37258+ if (fbtScope === null) {
37259+ continue;
37260+ }
37261+ for (const operand of eachReactiveValueOperand(value)) {
37262+ operand.identifier.scope = fbtScope;
37263+ expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
37264+ fbtValues.add(operand.identifier.id);
37265+ }
3727237266 }
37273- else if (Iterable_some(eachInstructionValueOperand(value), operand => macroValues.has(operand.identifier))) {
37274- const macroOperands = [];
37275- for (const operand of eachInstructionValueOperand(value)) {
37276- if (macroValues.has(operand.identifier)) {
37277- macroOperands.push(operand.identifier);
37267+ else if (fbtValues.has(lvalue.identifier.id)) {
37268+ const fbtScope = lvalue.identifier.scope;
37269+ if (fbtScope === null) {
37270+ return;
37271+ }
37272+ for (const operand of eachReactiveValueOperand(value)) {
37273+ if (operand.identifier.name !== null &&
37274+ operand.identifier.name.kind === 'named') {
37275+ continue;
3727837276 }
37277+ operand.identifier.scope = fbtScope;
37278+ expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
3727937279 }
37280- macroValues.set(lvalue.identifier, macroOperands);
3728137280 }
3728237281 }
3728337282 }
3728437283}
37285- function mergeScopes(root, scope, macroValues, macroTagsCalls) {
37286- const operands = macroValues.get(root);
37287- if (operands == null) {
37288- return;
37289- }
37290- for (const operand of operands) {
37291- operand.scope = scope;
37292- expandFbtScopeRange(scope.range, operand.mutableRange);
37293- macroTagsCalls.add(operand.id);
37294- mergeScopes(operand, scope, macroValues, macroTagsCalls);
37295- }
37296- }
3729737284function matchesExactTag(s, tags) {
3729837285 return Array.from(tags).some(macro => typeof macro === 'string'
3729937286 ? s === macro
@@ -37317,23 +37304,22 @@ function matchTagRoot(s, tags) {
3731737304 return null;
3731837305 }
3731937306}
37320- function isFbtCallExpression(macroTagsCalls , value) {
37307+ function isFbtCallExpression(fbtValues , value) {
3732137308 return ((value.kind === 'CallExpression' &&
37322- macroTagsCalls.has(value.callee.identifier.id)) ||
37323- (value.kind === 'MethodCall' &&
37324- macroTagsCalls.has(value.property.identifier.id)));
37309+ fbtValues.has(value.callee.identifier.id)) ||
37310+ (value.kind === 'MethodCall' && fbtValues.has(value.property.identifier.id)));
3732537311}
37326- function isFbtJsxExpression(fbtMacroTags, macroTagsCalls , value) {
37312+ function isFbtJsxExpression(fbtMacroTags, fbtValues , value) {
3732737313 return (value.kind === 'JsxExpression' &&
3732837314 ((value.tag.kind === 'Identifier' &&
37329- macroTagsCalls .has(value.tag.identifier.id)) ||
37315+ fbtValues .has(value.tag.identifier.id)) ||
3733037316 (value.tag.kind === 'BuiltinTag' &&
3733137317 matchesExactTag(value.tag.name, fbtMacroTags))));
3733237318}
37333- function isFbtJsxChild(macroTagsCalls , lvalue, value) {
37319+ function isFbtJsxChild(fbtValues , lvalue, value) {
3733437320 return ((value.kind === 'JsxExpression' || value.kind === 'JsxFragment') &&
3733537321 lvalue !== null &&
37336- macroTagsCalls .has(lvalue.identifier.id));
37322+ fbtValues .has(lvalue.identifier.id));
3733737323}
3733837324function expandFbtScopeRange(fbtRange, extendWith) {
3733937325 if (extendWith.start !== 0) {
0 commit comments