feat(ivy): support pipe compilation from local metadata (#24703)

This updates the r3_pipe_compiler to not depend on global analysis,
and to produce ngPipeDef instructions in the same way that the other
compilers do. It's a precursor to JIT and AOT implementations of
@Pipe compilation.

PR Close #24703
This commit is contained in:
Alex Rickabaugh
2018-06-26 10:43:06 -07:00
committed by Miško Hevery
parent ffbacdf4ac
commit dbdcfed2bd
11 changed files with 78 additions and 43 deletions

View File

@ -9,7 +9,7 @@
import {PipeTransform} from '../change_detection/pipe_transform';
import {getTView, load, store} from './instructions';
import {PipeDef, PipeDefList} from './interfaces/definition';
import {PipeDefInternal, PipeDefList} from './interfaces/definition';
import {HEADER_OFFSET} from './interfaces/view';
import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunctionV} from './pure_function';
@ -22,7 +22,7 @@ import {pureFunction1, pureFunction2, pureFunction3, pureFunction4, pureFunction
*/
export function pipe(index: number, pipeName: string): any {
const tView = getTView();
let pipeDef: PipeDef<any>;
let pipeDef: PipeDefInternal<any>;
const adjustedIndex = index + HEADER_OFFSET;
if (tView.firstTemplatePass) {
@ -33,7 +33,7 @@ export function pipe(index: number, pipeName: string): any {
])).push(adjustedIndex, pipeDef.onDestroy);
}
} else {
pipeDef = tView.data[adjustedIndex] as PipeDef<any>;
pipeDef = tView.data[adjustedIndex] as PipeDefInternal<any>;
}
const pipeInstance = pipeDef.factory();
@ -49,7 +49,7 @@ export function pipe(index: number, pipeName: string): any {
* @param registry Full list of available pipes
* @returns Matching PipeDef
*/
function getPipeDef(name: string, registry: PipeDefList | null): PipeDef<any> {
function getPipeDef(name: string, registry: PipeDefList | null): PipeDefInternal<any> {
if (registry) {
for (let i = 0; i < registry.length; i++) {
const pipeDef = registry[i];
@ -151,5 +151,5 @@ export function pipeBindV(index: number, slotOffset: number, values: any[]): any
}
function isPure(index: number): boolean {
return (<PipeDef<any>>getTView().data[index + HEADER_OFFSET]).pure;
return (<PipeDefInternal<any>>getTView().data[index + HEADER_OFFSET]).pure;
}