* @param {string} expressionString * @param {!{[key: string]: !./bind-macro.BindMacro}} macros * @param {number=} opt_maxAstSize * @throws {Error} On malformed expressions.
(expressionString, macros, opt_maxAstSize)
| 205 | * @throws {Error} On malformed expressions. |
| 206 | */ |
| 207 | constructor(expressionString, macros, opt_maxAstSize) { |
| 208 | if (!FUNCTION_ALLOWLIST) { |
| 209 | FUNCTION_ALLOWLIST = generateFunctionAllowlist(); |
| 210 | } |
| 211 | |
| 212 | /** @const {string} */ |
| 213 | this.expressionString = expressionString; |
| 214 | |
| 215 | /** @private @const {!{[key: string]: !./bind-macro.BindMacro}} */ |
| 216 | this.macros_ = macros; |
| 217 | |
| 218 | /** @const @private {!./bind-expr-defines.AstNode} */ |
| 219 | this.ast_ = parser.parse(this.expressionString); |
| 220 | |
| 221 | /** @const {number} */ |
| 222 | this.expressionSize = this.numberOfNodesInAst_(this.ast_); |
| 223 | |
| 224 | // Check if this expression string is too large (for performance). |
| 225 | const maxSize = opt_maxAstSize || MAX_AST_SIZE; |
| 226 | const skipConstraint = getMode().localDev && !getMode().test; |
| 227 | if (this.expressionSize > maxSize && !skipConstraint) { |
| 228 | throw new Error( |
| 229 | `Expression size (${this.expressionSize}) exceeds max ` + |
| 230 | `(${maxSize}). Please reduce number of operands.` |
| 231 | ); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * Evaluates the expression given a scope. |
nothing calls this directly
no test coverage detected