feat(ivy): add ɵɵtextInterpolateX instructions (#30011)
- `ɵɵtextBinding(..., ɵɵinterpolationX())` instructions will now just be `ɵɵtextInterpolate(...)` instructions PR Close #30011
This commit is contained in:
@ -56,7 +56,7 @@ export class JitEvaluator {
|
||||
evaluateCode(
|
||||
sourceUrl: string, ctx: EmitterVisitorContext, vars: {[key: string]: any},
|
||||
createSourceMap: boolean): any {
|
||||
let fnBody = `${ctx.toSource()}\n//# sourceURL=${sourceUrl}`;
|
||||
let fnBody = `"use strict";${ctx.toSource()}\n//# sourceURL=${sourceUrl}`;
|
||||
const fnArgNames: string[] = [];
|
||||
const fnArgValues: any[] = [];
|
||||
for (const argName in vars) {
|
||||
|
@ -102,6 +102,17 @@ export class Identifiers {
|
||||
|
||||
static getCurrentView: o.ExternalReference = {name: 'ɵɵgetCurrentView', moduleName: CORE};
|
||||
|
||||
static textInterpolate: o.ExternalReference = {name: 'ɵɵtextInterpolate', moduleName: CORE};
|
||||
static textInterpolate1: o.ExternalReference = {name: 'ɵɵtextInterpolate1', moduleName: CORE};
|
||||
static textInterpolate2: o.ExternalReference = {name: 'ɵɵtextInterpolate2', moduleName: CORE};
|
||||
static textInterpolate3: o.ExternalReference = {name: 'ɵɵtextInterpolate3', moduleName: CORE};
|
||||
static textInterpolate4: o.ExternalReference = {name: 'ɵɵtextInterpolate4', moduleName: CORE};
|
||||
static textInterpolate5: o.ExternalReference = {name: 'ɵɵtextInterpolate5', moduleName: CORE};
|
||||
static textInterpolate6: o.ExternalReference = {name: 'ɵɵtextInterpolate6', moduleName: CORE};
|
||||
static textInterpolate7: o.ExternalReference = {name: 'ɵɵtextInterpolate7', moduleName: CORE};
|
||||
static textInterpolate8: o.ExternalReference = {name: 'ɵɵtextInterpolate8', moduleName: CORE};
|
||||
static textInterpolateV: o.ExternalReference = {name: 'ɵɵtextInterpolateV', moduleName: CORE};
|
||||
|
||||
static restoreView: o.ExternalReference = {name: 'ɵɵrestoreView', moduleName: CORE};
|
||||
|
||||
static interpolation1: o.ExternalReference = {name: 'ɵɵinterpolation1', moduleName: CORE};
|
||||
|
@ -941,9 +941,17 @@ export class TemplateDefinitionBuilder implements t.Visitor<void>, LocalResolver
|
||||
|
||||
const value = text.value.visit(this._valueConverter);
|
||||
this.allocateBindingSlots(value);
|
||||
this.updateInstruction(
|
||||
nodeIndex, text.sourceSpan, R3.textBinding,
|
||||
() => [o.literal(nodeIndex), this.convertPropertyBinding(o.variable(CONTEXT_NAME), value)]);
|
||||
|
||||
if (value instanceof Interpolation) {
|
||||
this.updateInstruction(
|
||||
nodeIndex, text.sourceSpan, getTextInterpolationExpression(value),
|
||||
() => this.getUpdateInstructionArguments(o.variable(CONTEXT_NAME), value));
|
||||
} else {
|
||||
this.updateInstruction(
|
||||
nodeIndex, text.sourceSpan, R3.textBinding,
|
||||
() =>
|
||||
[o.literal(nodeIndex), this.convertPropertyBinding(o.variable(CONTEXT_NAME), value)]);
|
||||
}
|
||||
}
|
||||
|
||||
visitText(text: t.Text) {
|
||||
@ -1736,6 +1744,35 @@ function getAttributeInterpolationExpression(interpolation: Interpolation) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instruction to generate for interpolated text.
|
||||
* @param interpolation An Interpolation AST
|
||||
*/
|
||||
function getTextInterpolationExpression(interpolation: Interpolation): o.ExternalReference {
|
||||
switch (getInterpolationArgsLength(interpolation)) {
|
||||
case 1:
|
||||
return R3.textInterpolate;
|
||||
case 3:
|
||||
return R3.textInterpolate1;
|
||||
case 5:
|
||||
return R3.textInterpolate2;
|
||||
case 7:
|
||||
return R3.textInterpolate3;
|
||||
case 9:
|
||||
return R3.textInterpolate4;
|
||||
case 11:
|
||||
return R3.textInterpolate5;
|
||||
case 13:
|
||||
return R3.textInterpolate6;
|
||||
case 15:
|
||||
return R3.textInterpolate7;
|
||||
case 17:
|
||||
return R3.textInterpolate8;
|
||||
default:
|
||||
return R3.textInterpolateV;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of arguments expected to be passed to a generated instruction in the case of
|
||||
* interpolation instructions.
|
||||
|
Reference in New Issue
Block a user