mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(compiler): add ConstantPool to template pipeline compilations (#50118)
This commit adds the `ConstantPool` to `ComponentCompilation`, making it available to all phases of the template pipeline. Constant extraction is a common operation in pipeline phases. PR Close #50118
This commit is contained in:
parent
11469b58c3
commit
1928cd82d9
3 changed files with 7 additions and 4 deletions
|
|
@ -234,7 +234,7 @@ export function compileComponentFromMetadata(
|
|||
} else {
|
||||
// This path compiles the template using the prototype template pipeline. First the template is
|
||||
// ingested into IR:
|
||||
const tpl = ingest(meta.name, meta.template.nodes);
|
||||
const tpl = ingest(meta.name, meta.template.nodes, constantPool);
|
||||
|
||||
// Then the IR is transformed to prepare it for cod egeneration.
|
||||
transformTemplate(tpl);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ConstantPool} from '../../../constant_pool';
|
||||
import * as o from '../../../output/output_ast';
|
||||
import * as ir from '../ir';
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ export class ComponentCompilation {
|
|||
*/
|
||||
readonly root: ViewCompilation;
|
||||
|
||||
constructor(readonly componentName: string) {
|
||||
constructor(readonly componentName: string, readonly pool: ConstantPool) {
|
||||
// Allocate the root view.
|
||||
const root = new ViewCompilation(this, this.allocateXrefId(), null);
|
||||
this.views.set(root.xref, root);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ConstantPool} from '../../../constant_pool';
|
||||
import * as e from '../../../expression_parser/ast';
|
||||
import * as o from '../../../output/output_ast';
|
||||
import * as t from '../../../render3/r3_ast';
|
||||
|
|
@ -18,8 +19,9 @@ import {BINARY_OPERATORS} from './conversion';
|
|||
* Process a template AST and convert it into a `ComponentCompilation` in the intermediate
|
||||
* representation.
|
||||
*/
|
||||
export function ingest(componentName: string, template: t.Node[]): ComponentCompilation {
|
||||
const cpl = new ComponentCompilation(componentName);
|
||||
export function ingest(
|
||||
componentName: string, template: t.Node[], constantPool: ConstantPool): ComponentCompilation {
|
||||
const cpl = new ComponentCompilation(componentName, constantPool);
|
||||
ingestNodes(cpl.root, template);
|
||||
return cpl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue