refactor(ivy): split the `memory` instruction into `store` and `load` (#22268)

PR Close #22268
This commit is contained in:
Victor Berchet 2018-02-16 16:58:07 -08:00
parent 3ceee99e22
commit 5a14e2238f
19 changed files with 105 additions and 114 deletions

View File

@ -63,7 +63,7 @@ export class Identifiers {
static interpolation8: o.ExternalReference = {name: 'ɵi8', moduleName: CORE};
static interpolationV: o.ExternalReference = {name: 'ɵiV', moduleName: CORE};
static memory: o.ExternalReference = {name: 'ɵm', moduleName: CORE};
static load: o.ExternalReference = {name: 'ɵld', moduleName: CORE};
static projection: o.ExternalReference = {name: 'ɵP', moduleName: CORE};
static projectionDef: o.ExternalReference = {name: 'ɵpD', moduleName: CORE};

View File

@ -408,7 +408,7 @@ class TemplateDefinitionBuilder implements TemplateAstVisitor, LocalResolver {
// Generate the update temporary.
const variableName = this.bindingScope.freshReferenceName();
this._bindingMode.push(o.variable(variableName, o.INFERRED_TYPE)
.set(o.importExpr(R3.memory).callFn([o.literal(slot)]))
.set(o.importExpr(R3.load).callFn([o.literal(slot)]))
.toDeclStmt(o.INFERRED_TYPE, [o.StmtModifier.Final]));
this.bindingScope.set(reference.name, variableName);
return [reference.name, reference.originalValue];

View File

@ -293,7 +293,7 @@ describe('r3_view_compiler', () => {
$r3$.ɵC(2, $c2$, MyComponent_IfDirective_Template_2);
$r3$.ɵe();
}
const $foo$ = $r3$.ɵm(1);
const $foo$ = $r3$.ɵld(1);
IfDirective.ngDirectiveDef.h(3,2);
$r3$.ɵcR(2);
$r3$.ɵr(3,2);
@ -420,7 +420,7 @@ describe('r3_view_compiler', () => {
$r3$.ɵe();
$r3$.ɵT(2);
}
const $user$ = $r3$.ɵm(1);
const $user$ = $r3$.ɵld(1);
$r3$.ɵt(2, $r3$.ɵi1('Hello ', $user$.value, '!'));
}
});

View File

@ -65,7 +65,8 @@ export {
t as ɵt,
v as ɵv,
r as ɵr,
m as ɵm,
st as ɵst,
ld as ɵld,
Pp as ɵPp,
} from './render3/index';
// clang-format on

View File

@ -53,7 +53,8 @@ export {
elementStyle as s,
listener as L,
memory as m,
store as st,
load as ld,
projection as P,
projectionDef as pD,

View File

@ -1306,8 +1306,7 @@ export function projection(
const componentNode = findComponentHost(currentView);
// make sure that nodes to project were memorized
const nodesForSelector =
valueInData<LNode[][]>(componentNode.data !.data !, localIndex)[selectorIndex];
const nodesForSelector = componentNode.data !.data ![localIndex][selectorIndex];
// build the linked list of projected nodes:
for (let i = 0; i < nodesForSelector.length; i++) {
@ -1744,23 +1743,20 @@ export function interpolation8(
NO_CHANGE;
}
export function memory<T>(index: number, value?: T): T {
return valueInData<T>(data, index, value);
/** Store a value in the `data` at a given `index`. */
export function store<T>(index: number, value: T): void {
// We don't store any static data for local variables, so the first time
// we see the template, we should store as null to avoid a sparse array
if (index >= tData.length) {
tData[index] = null;
}
data[index] = value;
}
function valueInData<T>(data: any[], index: number, value?: T): T {
if (value === undefined) {
ngDevMode && assertDataInRange(index, data);
value = data[index];
} else {
// We don't store any static data for local variables, so the first time
// we see the template, we should store as null to avoid a sparse array
if (index >= tData.length) {
tData[index] = null;
}
data[index] = value;
}
return value !;
/** Retrieves a value from the `data`. */
export function load<T>(index: number): T {
ngDevMode && assertDataInRange(index, data);
return data[index];
}
export function getCurrentQueries(QueryType: {new (): LQueries}): LQueries {

View File

@ -17,7 +17,7 @@ import {getSymbolIterator} from '../util';
import {assertEqual, assertNotNull} from './assert';
import {ReadFromInjectorFn, getOrCreateNodeInjectorForNode} from './di';
import {assertPreviousIsParent, getCurrentQueries, memory} from './instructions';
import {assertPreviousIsParent, getCurrentQueries, store} from './instructions';
import {DirectiveDef, unusedValueExportToPlacateAjd as unused1} from './interfaces/definition';
import {LInjector, unusedValueExportToPlacateAjd as unused2} from './interfaces/injector';
import {LContainerNode, LElementNode, LNode, LNodeFlags, TNode, unusedValueExportToPlacateAjd as unused3} from './interfaces/node';
@ -389,7 +389,7 @@ export function query<T>(
queries.track(queryList, predicate, descend, read);
if (memoryIndex != null) {
memory(memoryIndex, queryList);
store(memoryIndex, queryList);
}
return queryList;
}

View File

@ -11,7 +11,6 @@ import {IterableDiffers} from '@angular/core';
import {defaultIterableDiffers} from '../../src/change_detection/change_detection';
import {DirectiveType, InjectFlags, NgOnChangesFeature, defineDirective, inject, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
import {memory} from '../../src/render3/instructions';
export const NgForOf: DirectiveType<NgForOfDef<any>> = NgForOfDef as any;

View File

@ -354,7 +354,7 @@ describe('compiler specification', () => {
$r3$.ɵC(2, $c1_dirs$, C1);
$r3$.ɵe();
}
let $foo$ = $r3$.ɵm<any>(1);
let $foo$ = $r3$.ɵld<any>(1);
$r3$.ɵcR(2);
$r3$.ɵr(3, 2);
$r3$.ɵcr();
@ -951,8 +951,8 @@ describe('compiler specification', () => {
$r3$.ɵe();
}
$r3$.ɵqR($tmp$ = $r3$.ɵm<QueryList<any>>(0)) && (ctx.someDir = $tmp$.first);
$r3$.ɵqR($tmp$ = $r3$.ɵm<QueryList<any>>(1)) &&
$r3$.ɵqR($tmp$ = $r3$.ɵld<QueryList<any>>(0)) && (ctx.someDir = $tmp$.first);
$r3$.ɵqR($tmp$ = $r3$.ɵld<QueryList<any>>(1)) &&
(ctx.someDirList = $tmp$ as QueryList<any>);
SomeDirective.ngDirectiveDef.h(3, 2);
$r3$.ɵr(3, 2);
@ -998,9 +998,9 @@ describe('compiler specification', () => {
hostBindings: function ContentQueryComponent_HostBindings(
dirIndex: $number$, elIndex: $number$) {
let $tmp$: any;
const $instance$ = $r3$.ɵm<any[]>(dirIndex)[0];
$r3$.ɵqR($tmp$ = $r3$.ɵm<any[]>(dirIndex)[1]) && ($instance$.someDir = $tmp$.first);
$r3$.ɵqR($tmp$ = $r3$.ɵm<any[]>(dirIndex)[2]) && ($instance$.someDirList = $tmp$);
const $instance$ = $r3$.ɵld<any[]>(dirIndex)[0];
$r3$.ɵqR($tmp$ = $r3$.ɵld<any[]>(dirIndex)[1]) && ($instance$.someDir = $tmp$.first);
$r3$.ɵqR($tmp$ = $r3$.ɵld<any[]>(dirIndex)[2]) && ($instance$.someDirList = $tmp$);
},
template: function ContentQueryComponent_Template(
ctx: $ContentQueryComponent$, cm: $boolean$) {
@ -1035,7 +1035,7 @@ describe('compiler specification', () => {
template: function MyApp_Template(ctx: $MyApp$, cm: $boolean$) {
if (cm) {
$r3$.ɵE(0, ContentQueryComponent);
contentQueryComp = $r3$.ɵm<any[]>(1)[0];
contentQueryComp = $r3$.ɵld<any[]>(1)[0];
$r3$.ɵE(2, 'div', $e2_attrs$, $e2_dirs$);
$r3$.ɵe();
$r3$.ɵe();
@ -1148,7 +1148,7 @@ describe('compiler specification', () => {
$r3$.ɵe();
$r3$.ɵT(2);
}
const l1_user = $r3$.ɵm<any>(1);
const l1_user = $r3$.ɵld<any>(1);
$r3$.ɵt(2, $r3$.ɵi1('Hello ', l1_user.value, '!'));
}
});

View File

@ -7,7 +7,7 @@
*/
import {detectChanges} from '../../src/render3/index';
import {componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, memory, projection, projectionDef, text} from '../../src/render3/instructions';
import {componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, load, projection, projectionDef, text} from '../../src/render3/instructions';
import {createComponent, renderComponent, toHtml} from './render_util';
@ -309,7 +309,7 @@ describe('content projection', () => {
if (cm) {
elementStart(0, Child);
{
childCmptInstance = memory(1);
childCmptInstance = load(1);
text(2, 'content');
}
elementEnd();
@ -362,7 +362,7 @@ describe('content projection', () => {
if (cm) {
elementStart(0, Child);
{
childCmptInstance = memory(1);
childCmptInstance = load(1);
text(2, 'content');
}
elementEnd();
@ -417,7 +417,7 @@ describe('content projection', () => {
if (cm) {
elementStart(0, Child);
{
childCmptInstance = memory(1);
childCmptInstance = load(1);
text(2, 'content');
}
elementEnd();
@ -512,7 +512,7 @@ describe('content projection', () => {
if (cm) {
elementStart(0, Child);
{
childCmptInstance = memory(1);
childCmptInstance = load(1);
text(2, 'content');
}
elementEnd();

View File

@ -11,7 +11,7 @@ import {ElementRef, TemplateRef, ViewContainerRef} from '@angular/core';
import {defineComponent} from '../../src/render3/definition';
import {InjectFlags, bloomAdd, bloomFindPossibleInjector, getOrCreateNodeInjector} from '../../src/render3/di';
import {PublicFeature, defineDirective, inject, injectElementRef, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
import {bind, container, containerRefreshEnd, containerRefreshStart, createLNode, createLView, createTView, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, enterView, interpolation2, leaveView, memory, text, textBinding} from '../../src/render3/instructions';
import {bind, container, containerRefreshEnd, containerRefreshStart, createLNode, createLView, createTView, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, enterView, interpolation2, leaveView, load, text, textBinding} from '../../src/render3/instructions';
import {LInjector} from '../../src/render3/interfaces/injector';
import {LNodeFlags} from '../../src/render3/interfaces/node';
@ -31,7 +31,7 @@ describe('di', () => {
{ text(2); }
elementEnd();
}
textBinding(2, bind(memory<Directive>(1).value));
textBinding(2, bind(load<Directive>(1).value));
}
expect(renderToHtml(Template, {})).toEqual('<div>Created</div>');
@ -71,7 +71,7 @@ describe('di', () => {
}
elementEnd();
}
textBinding(5, bind(memory<DirectiveC>(4).value));
textBinding(5, bind(load<DirectiveC>(4).value));
}
expect(renderToHtml(Template, {})).toEqual('<div><span>AB</span></div>');
@ -110,9 +110,8 @@ describe('di', () => {
elementEnd();
}
textBinding(
3,
interpolation2(
'', memory<Directive>(1).value, '-', memory<DirectiveSameInstance>(2).value, ''));
3, interpolation2(
'', load<Directive>(1).value, '-', load<DirectiveSameInstance>(2).value, ''));
}
expect(renderToHtml(Template, {})).toEqual('<div>ElementRef-true</div>');
@ -151,9 +150,8 @@ describe('di', () => {
text(3);
}
textBinding(
3,
interpolation2(
'', memory<Directive>(1).value, '-', memory<DirectiveSameInstance>(2).value, ''));
3, interpolation2(
'', load<Directive>(1).value, '-', load<DirectiveSameInstance>(2).value, ''));
}
expect(renderToHtml(Template, {})).toEqual('TemplateRef-true');
@ -192,9 +190,8 @@ describe('di', () => {
elementEnd();
}
textBinding(
3,
interpolation2(
'', memory<Directive>(1).value, '-', memory<DirectiveSameInstance>(2).value, ''));
3, interpolation2(
'', load<Directive>(1).value, '-', load<DirectiveSameInstance>(2).value, ''));
}
expect(renderToHtml(Template, {})).toEqual('<div>ViewContainerRef-true</div>');
@ -306,9 +303,8 @@ describe('di', () => {
elementEnd();
}
textBinding(
3,
interpolation2(
'', memory<ChildDirective>(1).value, '-', memory<Child2Directive>(2).value, ''));
3, interpolation2(
'', load<ChildDirective>(1).value, '-', load<Child2Directive>(2).value, ''));
embeddedViewEnd();
}
containerRefreshEnd();

View File

@ -7,7 +7,7 @@
*/
import {defineDirective} from '../../src/render3/index';
import {bind, componentRefresh, elementEnd, elementProperty, elementStart, memory} from '../../src/render3/instructions';
import {bind, componentRefresh, elementEnd, elementProperty, elementStart, load} from '../../src/render3/instructions';
import {renderToHtml} from './render_util';
@ -24,8 +24,7 @@ describe('directive', () => {
type: Directive,
factory: () => directiveInstance = new Directive,
hostBindings: (directiveIndex: number, elementIndex: number) => {
elementProperty(
elementIndex, 'className', bind(memory<Directive>(directiveIndex).klass));
elementProperty(elementIndex, 'className', bind(load<Directive>(directiveIndex).klass));
}
});
}

View File

@ -7,7 +7,7 @@
*/
import {defineComponent, defineDirective} from '../../src/render3/index';
import {bind, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, memory, text, textBinding} from '../../src/render3/instructions';
import {bind, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, load, text, textBinding} from '../../src/render3/instructions';
import {renderToHtml} from './render_util';
@ -37,7 +37,7 @@ describe('exports', () => {
elementEnd();
text(2);
}
textBinding(2, memory<MyComponent>(1).name);
textBinding(2, load<MyComponent>(1).name);
}
class MyComponent {
@ -83,7 +83,7 @@ describe('exports', () => {
elementStart(2, 'div', null, [MyDir]);
elementEnd();
}
elementProperty(2, 'myDir', bind(memory<MyComponent>(1)));
elementProperty(2, 'myDir', bind(load<MyComponent>(1)));
}
renderToHtml(Template, {});
@ -99,7 +99,7 @@ describe('exports', () => {
elementEnd();
text(2);
}
textBinding(2, memory<SomeDir>(1).name);
textBinding(2, load<SomeDir>(1).name);
}
class SomeDir {
@ -209,7 +209,7 @@ describe('exports', () => {
elementStart(2, MyComponent);
elementEnd();
}
elementProperty(0, 'myDir', bind(memory<MyComponent>(3)));
elementProperty(0, 'myDir', bind(load<MyComponent>(3)));
}
renderToHtml(Template, {});
@ -229,7 +229,7 @@ describe('exports', () => {
elementEnd();
}
let myInput = elementStart(4);
let myComp = memory(3) as MyComponent;
let myComp = load<MyComponent>(3);
textBinding(0, bind(myInput && (myInput as any).value));
textBinding(1, bind(myComp && myComp.name));
}

View File

@ -7,7 +7,7 @@
*/
import {defineComponent, defineDirective} from '../../src/render3/index';
import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, embeddedViewEnd, embeddedViewStart, interpolation1, interpolation2, interpolation3, interpolation4, interpolation5, interpolation6, interpolation7, interpolation8, interpolationV, memory, projection, projectionDef, text, textBinding} from '../../src/render3/instructions';
import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementAttribute, elementClass, elementEnd, elementProperty, elementStart, elementStyle, embeddedViewEnd, embeddedViewStart, interpolation1, interpolation2, interpolation3, interpolation4, interpolation5, interpolation6, interpolation7, interpolation8, interpolationV, load, projection, projectionDef, text, textBinding} from '../../src/render3/instructions';
import {containerEl, renderToHtml} from './render_util';
@ -300,8 +300,7 @@ describe('render3 integration test', () => {
hostBindings: function(directiveIndex: number, elementIndex: number): void {
// host bindings
elementProperty(
elementIndex, 'title',
bind(memory<TodoComponentHostBinding>(directiveIndex).title));
elementIndex, 'title', bind(load<TodoComponentHostBinding>(directiveIndex).title));
}
});
}

View File

@ -7,7 +7,7 @@
*/
import {ComponentTemplate, defineComponent, defineDirective} from '../../src/render3/index';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, listener, memory, projection, projectionDef, text} from '../../src/render3/instructions';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, listener, projection, projectionDef, store, text} from '../../src/render3/instructions';
import {containerEl, renderToHtml} from './render_util';

View File

@ -9,7 +9,7 @@
import {EventEmitter} from '@angular/core';
import {defineComponent, defineDirective} from '../../src/render3/index';
import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, interpolation1, listener, memory, text, textBinding} from '../../src/render3/instructions';
import {NO_CHANGE, bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, interpolation1, listener, load, text, textBinding} from '../../src/render3/instructions';
import {renderToHtml} from './render_util';
@ -479,7 +479,7 @@ describe('elementProperty', () => {
elementEnd();
text(2);
}
textBinding(2, bind(memory<MyDir>(1).role));
textBinding(2, bind(load<MyDir>(1).role));
},
factory: () => new Comp()
});

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {defineComponent} from '../../src/render3/index';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, memory} from '../../src/render3/instructions';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, elementEnd, elementProperty, elementStart, embeddedViewEnd, embeddedViewStart, load} from '../../src/render3/instructions';
import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunction5, pureFunction6, pureFunction7, pureFunction8, pureFunctionV} from '../../src/render3/pure_function';
import {renderToHtml} from '../../test/render3/render_util';
@ -124,7 +124,7 @@ describe('array literals', () => {
template: function(ctx: any, cm: boolean) {
if (cm) {
elementStart(0, MyComp);
myComps.push(memory(1));
myComps.push(load(1));
elementEnd();
}
elementProperty(0, 'names', bind(ctx.someFn(pureFunction1(e0_ff, ctx.customName))));
@ -223,22 +223,22 @@ describe('array literals', () => {
function Template(c: any, cm: boolean) {
if (cm) {
elementStart(0, MyComp);
f3Comp = memory(1);
f3Comp = load(1);
elementEnd();
elementStart(2, MyComp);
f4Comp = memory(3);
f4Comp = load(3);
elementEnd();
elementStart(4, MyComp);
f5Comp = memory(5);
f5Comp = load(5);
elementEnd();
elementStart(6, MyComp);
f6Comp = memory(7);
f6Comp = load(7);
elementEnd();
elementStart(8, MyComp);
f7Comp = memory(9);
f7Comp = load(9);
elementEnd();
elementStart(10, MyComp);
f8Comp = memory(11);
f8Comp = load(11);
elementEnd();
}
elementProperty(0, 'names', bind(pureFunction3(e0_ff, c[5], c[6], c[7])));
@ -444,7 +444,7 @@ describe('object literals', () => {
for (let i = 0; i < 2; i++) {
if (embeddedViewStart(0)) {
elementStart(0, ObjectComp);
objectComps.push(memory(1));
objectComps.push(load(1));
elementEnd();
}
elementProperty(

View File

@ -7,7 +7,7 @@
*/
import {QUERY_READ_CONTAINER_REF, QUERY_READ_ELEMENT_REF, QUERY_READ_FROM_NODE, QUERY_READ_TEMPLATE_REF} from '../../src/render3/di';
import {QueryList, detectChanges} from '../../src/render3/index';
import {container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, memory} from '../../src/render3/instructions';
import {container, containerRefreshEnd, containerRefreshStart, elementEnd, elementStart, embeddedViewEnd, embeddedViewStart, load} from '../../src/render3/instructions';
import {query, queryRefresh} from '../../src/render3/query';
import {createComponent, createDirective, renderComponent} from './render_util';
@ -64,15 +64,15 @@ describe('query', () => {
query(1, Child, true);
elementStart(2, Child);
{
child1 = memory(3);
child1 = load(3);
elementStart(4, Child);
{ child2 = memory(5); }
{ child2 = load(5); }
elementEnd();
}
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query0 = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(1)) && (ctx.query1 = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query0 = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(1)) && (ctx.query1 = tmp as QueryList<any>);
});
const parent = renderComponent(Cmp);
@ -98,7 +98,7 @@ describe('query', () => {
elToQuery = elementStart(1, 'div', null, [Child]);
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -124,10 +124,10 @@ describe('query', () => {
if (cm) {
query(0, Child, false, OtherChild);
elementStart(1, 'div', null, [Child, OtherChild]);
{ otherChildInstance = memory(3); }
{ otherChildInstance = load(3); }
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -152,7 +152,7 @@ describe('query', () => {
elementStart(1, 'div', null, [Child]);
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -182,7 +182,7 @@ describe('query', () => {
elementStart(2, 'div');
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -214,7 +214,7 @@ describe('query', () => {
el2ToQuery = elementStart(3, 'div', null, null, ['bar', '']);
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -243,7 +243,7 @@ describe('query', () => {
elementStart(2, 'div');
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -267,7 +267,7 @@ describe('query', () => {
elementStart(1, 'div', null, null, ['foo', '']);
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -289,7 +289,7 @@ describe('query', () => {
query(0, ['foo'], false, QUERY_READ_CONTAINER_REF);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -312,7 +312,7 @@ describe('query', () => {
query(0, ['foo'], false, QUERY_READ_ELEMENT_REF);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -335,7 +335,7 @@ describe('query', () => {
query(0, ['foo'], undefined, QUERY_READ_FROM_NODE);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -358,7 +358,7 @@ describe('query', () => {
query(0, ['foo'], false, QUERY_READ_TEMPLATE_REF);
container(1, undefined, undefined, undefined, undefined, ['foo', '']);
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -382,10 +382,10 @@ describe('query', () => {
if (cm) {
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
elementStart(1, Child, null, null, ['foo', '']);
{ childInstance = memory(2); }
{ childInstance = load(2); }
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -410,10 +410,10 @@ describe('query', () => {
if (cm) {
query(0, ['foo'], true, QUERY_READ_FROM_NODE);
elementStart(1, 'div', null, [Child], ['foo', 'child']);
childInstance = memory(2);
childInstance = load(2);
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -439,12 +439,12 @@ describe('query', () => {
query(0, ['foo', 'bar'], true, QUERY_READ_FROM_NODE);
elementStart(1, 'div', null, [Child1, Child2], ['foo', 'child1', 'bar', 'child2']);
{
child1Instance = memory(2);
child2Instance = memory(3);
child1Instance = load(2);
child2Instance = load(3);
}
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -471,7 +471,7 @@ describe('query', () => {
div = elementStart(1, 'div', null, [Child], ['foo', 'child']);
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -495,10 +495,10 @@ describe('query', () => {
if (cm) {
query(0, ['foo', 'bar'], undefined, QUERY_READ_FROM_NODE);
div = elementStart(1, 'div', null, [Child], ['foo', '', 'bar', 'child']);
{ childInstance = memory(2); }
{ childInstance = load(2); }
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -524,7 +524,7 @@ describe('query', () => {
elementStart(1, 'div', null, null, ['foo', '']);
elementEnd();
}
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -566,7 +566,7 @@ describe('query', () => {
}
}
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -620,7 +620,7 @@ describe('query', () => {
}
}
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -686,7 +686,7 @@ describe('query', () => {
}
}
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -753,7 +753,7 @@ describe('query', () => {
}
}
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.query = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);
@ -805,8 +805,8 @@ describe('query', () => {
}
}
containerRefreshEnd();
queryRefresh(tmp = memory<QueryList<any>>(0)) && (ctx.deep = tmp as QueryList<any>);
queryRefresh(tmp = memory<QueryList<any>>(1)) && (ctx.shallow = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(0)) && (ctx.deep = tmp as QueryList<any>);
queryRefresh(tmp = load<QueryList<any>>(1)) && (ctx.shallow = tmp as QueryList<any>);
});
const cmptInstance = renderComponent(Cmpt);

View File

@ -8,7 +8,7 @@
import {TemplateRef, ViewContainerRef} from '../../src/core';
import {defineComponent, defineDirective, injectTemplateRef, injectViewContainerRef} from '../../src/render3/index';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, memory, text, textBinding} from '../../src/render3/instructions';
import {bind, componentRefresh, container, containerRefreshEnd, containerRefreshStart, load, text, textBinding} from '../../src/render3/instructions';
import {renderComponent, toHtml} from './render_util';
@ -40,7 +40,7 @@ describe('ViewContainerRef', () => {
container(0, [TestDirective], subTemplate);
}
containerRefreshStart(0);
cmp.testDir = memory(1) as TestDirective;
cmp.testDir = load<TestDirective>(1);
TestDirective.ngDirectiveDef.h(1, 0);
componentRefresh(1, 0);
containerRefreshEnd();