MCPcopy Create free account
hub / github.com/angular/angular / getSharedConstant

Method getSharedConstant

packages/compiler/src/constant_pool.ts:158–166  ·  view source on GitHub ↗
(def: SharedConstantDefinition, expr: o.Expression)

Source from the content-addressed store, hash-verified

156 }
157
158 getSharedConstant(def: SharedConstantDefinition, expr: o.Expression): o.Expression {
159 const key = def.keyOf(expr);
160 if (!this.sharedConstants.has(key)) {
161 const id = this.freshName();
162 this.sharedConstants.set(key, o.variable(id));
163 this.statements.push(def.toSharedConstantDeclaration(id, expr));
164 }
165 return this.sharedConstants.get(key)!;
166 }
167
168 // TODO: useUniqueName(false) is necessary for naming compatibility with
169 // TemplateDefinitionBuilder, but should be removed once Template Pipeline is the default.

Callers 2

extractPureFunctionsFunction · 0.80

Calls 7

freshNameMethod · 0.95
keyOfMethod · 0.65
hasMethod · 0.65
setMethod · 0.65
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected