1 | import * as o from '../output/output_ast';
|
---|
2 | import { Identifiers as R3 } from '../render3/r3_identifiers';
|
---|
3 | import { typeWithParameters } from './util';
|
---|
4 | export var R3FactoryDelegateType;
|
---|
5 | (function (R3FactoryDelegateType) {
|
---|
6 | R3FactoryDelegateType[R3FactoryDelegateType["Class"] = 0] = "Class";
|
---|
7 | R3FactoryDelegateType[R3FactoryDelegateType["Function"] = 1] = "Function";
|
---|
8 | })(R3FactoryDelegateType || (R3FactoryDelegateType = {}));
|
---|
9 | export var FactoryTarget;
|
---|
10 | (function (FactoryTarget) {
|
---|
11 | FactoryTarget[FactoryTarget["Directive"] = 0] = "Directive";
|
---|
12 | FactoryTarget[FactoryTarget["Component"] = 1] = "Component";
|
---|
13 | FactoryTarget[FactoryTarget["Injectable"] = 2] = "Injectable";
|
---|
14 | FactoryTarget[FactoryTarget["Pipe"] = 3] = "Pipe";
|
---|
15 | FactoryTarget[FactoryTarget["NgModule"] = 4] = "NgModule";
|
---|
16 | })(FactoryTarget || (FactoryTarget = {}));
|
---|
17 | /**
|
---|
18 | * Construct a factory function expression for the given `R3FactoryMetadata`.
|
---|
19 | */
|
---|
20 | export function compileFactoryFunction(meta) {
|
---|
21 | const t = o.variable('t');
|
---|
22 | let baseFactoryVar = null;
|
---|
23 | // The type to instantiate via constructor invocation. If there is no delegated factory, meaning
|
---|
24 | // this type is always created by constructor invocation, then this is the type-to-create
|
---|
25 | // parameter provided by the user (t) if specified, or the current type if not. If there is a
|
---|
26 | // delegated factory (which is used to create the current type) then this is only the type-to-
|
---|
27 | // create parameter (t).
|
---|
28 | const typeForCtor = !isDelegatedFactoryMetadata(meta) ?
|
---|
29 | new o.BinaryOperatorExpr(o.BinaryOperator.Or, t, meta.internalType) :
|
---|
30 | t;
|
---|
31 | let ctorExpr = null;
|
---|
32 | if (meta.deps !== null) {
|
---|
33 | // There is a constructor (either explicitly or implicitly defined).
|
---|
34 | if (meta.deps !== 'invalid') {
|
---|
35 | ctorExpr = new o.InstantiateExpr(typeForCtor, injectDependencies(meta.deps, meta.target));
|
---|
36 | }
|
---|
37 | }
|
---|
38 | else {
|
---|
39 | // There is no constructor, use the base class' factory to construct typeForCtor.
|
---|
40 | baseFactoryVar = o.variable(`ɵ${meta.name}_BaseFactory`);
|
---|
41 | ctorExpr = baseFactoryVar.callFn([typeForCtor]);
|
---|
42 | }
|
---|
43 | const body = [];
|
---|
44 | let retExpr = null;
|
---|
45 | function makeConditionalFactory(nonCtorExpr) {
|
---|
46 | const r = o.variable('r');
|
---|
47 | body.push(r.set(o.NULL_EXPR).toDeclStmt());
|
---|
48 | const ctorStmt = ctorExpr !== null ? r.set(ctorExpr).toStmt() :
|
---|
49 | o.importExpr(R3.invalidFactory).callFn([]).toStmt();
|
---|
50 | body.push(o.ifStmt(t, [ctorStmt], [r.set(nonCtorExpr).toStmt()]));
|
---|
51 | return r;
|
---|
52 | }
|
---|
53 | if (isDelegatedFactoryMetadata(meta)) {
|
---|
54 | // This type is created with a delegated factory. If a type parameter is not specified, call
|
---|
55 | // the factory instead.
|
---|
56 | const delegateArgs = injectDependencies(meta.delegateDeps, meta.target);
|
---|
57 | // Either call `new delegate(...)` or `delegate(...)` depending on meta.delegateType.
|
---|
58 | const factoryExpr = new (meta.delegateType === R3FactoryDelegateType.Class ?
|
---|
59 | o.InstantiateExpr :
|
---|
60 | o.InvokeFunctionExpr)(meta.delegate, delegateArgs);
|
---|
61 | retExpr = makeConditionalFactory(factoryExpr);
|
---|
62 | }
|
---|
63 | else if (isExpressionFactoryMetadata(meta)) {
|
---|
64 | // TODO(alxhub): decide whether to lower the value here or in the caller
|
---|
65 | retExpr = makeConditionalFactory(meta.expression);
|
---|
66 | }
|
---|
67 | else {
|
---|
68 | retExpr = ctorExpr;
|
---|
69 | }
|
---|
70 | if (retExpr === null) {
|
---|
71 | // The expression cannot be formed so render an `ɵɵinvalidFactory()` call.
|
---|
72 | body.push(o.importExpr(R3.invalidFactory).callFn([]).toStmt());
|
---|
73 | }
|
---|
74 | else if (baseFactoryVar !== null) {
|
---|
75 | // This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.
|
---|
76 | const getInheritedFactoryCall = o.importExpr(R3.getInheritedFactory).callFn([meta.internalType]);
|
---|
77 | // Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`
|
---|
78 | const baseFactory = new o.BinaryOperatorExpr(o.BinaryOperator.Or, baseFactoryVar, baseFactoryVar.set(getInheritedFactoryCall));
|
---|
79 | body.push(new o.ReturnStatement(baseFactory.callFn([typeForCtor])));
|
---|
80 | }
|
---|
81 | else {
|
---|
82 | // This is straightforward factory, just return it.
|
---|
83 | body.push(new o.ReturnStatement(retExpr));
|
---|
84 | }
|
---|
85 | let factoryFn = o.fn([new o.FnParam('t', o.DYNAMIC_TYPE)], body, o.INFERRED_TYPE, undefined, `${meta.name}_Factory`);
|
---|
86 | if (baseFactoryVar !== null) {
|
---|
87 | // There is a base factory variable so wrap its declaration along with the factory function into
|
---|
88 | // an IIFE.
|
---|
89 | factoryFn = o.fn([], [
|
---|
90 | new o.DeclareVarStmt(baseFactoryVar.name), new o.ReturnStatement(factoryFn)
|
---|
91 | ]).callFn([], /* sourceSpan */ undefined, /* pure */ true);
|
---|
92 | }
|
---|
93 | return {
|
---|
94 | expression: factoryFn,
|
---|
95 | statements: [],
|
---|
96 | type: createFactoryType(meta),
|
---|
97 | };
|
---|
98 | }
|
---|
99 | export function createFactoryType(meta) {
|
---|
100 | const ctorDepsType = meta.deps !== null && meta.deps !== 'invalid' ? createCtorDepsType(meta.deps) : o.NONE_TYPE;
|
---|
101 | return o.expressionType(o.importExpr(R3.FactoryDeclaration, [typeWithParameters(meta.type.type, meta.typeArgumentCount), ctorDepsType]));
|
---|
102 | }
|
---|
103 | function injectDependencies(deps, target) {
|
---|
104 | return deps.map((dep, index) => compileInjectDependency(dep, target, index));
|
---|
105 | }
|
---|
106 | function compileInjectDependency(dep, target, index) {
|
---|
107 | // Interpret the dependency according to its resolved type.
|
---|
108 | if (dep.token === null) {
|
---|
109 | return o.importExpr(R3.invalidFactoryDep).callFn([o.literal(index)]);
|
---|
110 | }
|
---|
111 | else if (dep.attributeNameType === null) {
|
---|
112 | // Build up the injection flags according to the metadata.
|
---|
113 | const flags = 0 /* Default */ | (dep.self ? 2 /* Self */ : 0) |
|
---|
114 | (dep.skipSelf ? 4 /* SkipSelf */ : 0) | (dep.host ? 1 /* Host */ : 0) |
|
---|
115 | (dep.optional ? 8 /* Optional */ : 0) |
|
---|
116 | (target === FactoryTarget.Pipe ? 16 /* ForPipe */ : 0);
|
---|
117 | // If this dependency is optional or otherwise has non-default flags, then additional
|
---|
118 | // parameters describing how to inject the dependency must be passed to the inject function
|
---|
119 | // that's being used.
|
---|
120 | let flagsParam = (flags !== 0 /* Default */ || dep.optional) ? o.literal(flags) : null;
|
---|
121 | // Build up the arguments to the injectFn call.
|
---|
122 | const injectArgs = [dep.token];
|
---|
123 | if (flagsParam) {
|
---|
124 | injectArgs.push(flagsParam);
|
---|
125 | }
|
---|
126 | const injectFn = getInjectFn(target);
|
---|
127 | return o.importExpr(injectFn).callFn(injectArgs);
|
---|
128 | }
|
---|
129 | else {
|
---|
130 | // The `dep.attributeTypeName` value is defined, which indicates that this is an `@Attribute()`
|
---|
131 | // type dependency. For the generated JS we still want to use the `dep.token` value in case the
|
---|
132 | // name given for the attribute is not a string literal. For example given `@Attribute(foo())`,
|
---|
133 | // we want to generate `ɵɵinjectAttribute(foo())`.
|
---|
134 | //
|
---|
135 | // The `dep.attributeTypeName` is only actually used (in `createCtorDepType()`) to generate
|
---|
136 | // typings.
|
---|
137 | return o.importExpr(R3.injectAttribute).callFn([dep.token]);
|
---|
138 | }
|
---|
139 | }
|
---|
140 | function createCtorDepsType(deps) {
|
---|
141 | let hasTypes = false;
|
---|
142 | const attributeTypes = deps.map(dep => {
|
---|
143 | const type = createCtorDepType(dep);
|
---|
144 | if (type !== null) {
|
---|
145 | hasTypes = true;
|
---|
146 | return type;
|
---|
147 | }
|
---|
148 | else {
|
---|
149 | return o.literal(null);
|
---|
150 | }
|
---|
151 | });
|
---|
152 | if (hasTypes) {
|
---|
153 | return o.expressionType(o.literalArr(attributeTypes));
|
---|
154 | }
|
---|
155 | else {
|
---|
156 | return o.NONE_TYPE;
|
---|
157 | }
|
---|
158 | }
|
---|
159 | function createCtorDepType(dep) {
|
---|
160 | const entries = [];
|
---|
161 | if (dep.attributeNameType !== null) {
|
---|
162 | entries.push({ key: 'attribute', value: dep.attributeNameType, quoted: false });
|
---|
163 | }
|
---|
164 | if (dep.optional) {
|
---|
165 | entries.push({ key: 'optional', value: o.literal(true), quoted: false });
|
---|
166 | }
|
---|
167 | if (dep.host) {
|
---|
168 | entries.push({ key: 'host', value: o.literal(true), quoted: false });
|
---|
169 | }
|
---|
170 | if (dep.self) {
|
---|
171 | entries.push({ key: 'self', value: o.literal(true), quoted: false });
|
---|
172 | }
|
---|
173 | if (dep.skipSelf) {
|
---|
174 | entries.push({ key: 'skipSelf', value: o.literal(true), quoted: false });
|
---|
175 | }
|
---|
176 | return entries.length > 0 ? o.literalMap(entries) : null;
|
---|
177 | }
|
---|
178 | export function isDelegatedFactoryMetadata(meta) {
|
---|
179 | return meta.delegateType !== undefined;
|
---|
180 | }
|
---|
181 | export function isExpressionFactoryMetadata(meta) {
|
---|
182 | return meta.expression !== undefined;
|
---|
183 | }
|
---|
184 | function getInjectFn(target) {
|
---|
185 | switch (target) {
|
---|
186 | case FactoryTarget.Component:
|
---|
187 | case FactoryTarget.Directive:
|
---|
188 | case FactoryTarget.Pipe:
|
---|
189 | return R3.directiveInject;
|
---|
190 | case FactoryTarget.NgModule:
|
---|
191 | case FactoryTarget.Injectable:
|
---|
192 | default:
|
---|
193 | return R3.inject;
|
---|
194 | }
|
---|
195 | }
|
---|
196 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicjNfZmFjdG9yeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzI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