| 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. |