(exp, interceptorFn, expensiveChecks)
| 14571 | return $parse; |
| 14572 | |
| 14573 | function $parse(exp, interceptorFn, expensiveChecks) { |
| 14574 | var parsedExpression, oneTime, cacheKey; |
| 14575 | |
| 14576 | expensiveChecks = expensiveChecks || runningChecksEnabled; |
| 14577 | |
| 14578 | switch (typeof exp) { |
| 14579 | case 'string': |
| 14580 | exp = exp.trim(); |
| 14581 | cacheKey = exp; |
| 14582 | |
| 14583 | var cache = (expensiveChecks ? cacheExpensive : cacheDefault); |
| 14584 | parsedExpression = cache[cacheKey]; |
| 14585 | |
| 14586 | if (!parsedExpression) { |
| 14587 | if (exp.charAt(0) === ':' && exp.charAt(1) === ':') { |
| 14588 | oneTime = true; |
| 14589 | exp = exp.substring(2); |
| 14590 | } |
| 14591 | var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions; |
| 14592 | var lexer = new Lexer(parseOptions); |
| 14593 | var parser = new Parser(lexer, $filter, parseOptions); |
| 14594 | parsedExpression = parser.parse(exp); |
| 14595 | if (parsedExpression.constant) { |
| 14596 | parsedExpression.$$watchDelegate = constantWatchDelegate; |
| 14597 | } else if (oneTime) { |
| 14598 | parsedExpression.$$watchDelegate = parsedExpression.literal ? |
| 14599 | oneTimeLiteralWatchDelegate : oneTimeWatchDelegate; |
| 14600 | } else if (parsedExpression.inputs) { |
| 14601 | parsedExpression.$$watchDelegate = inputsWatchDelegate; |
| 14602 | } |
| 14603 | if (expensiveChecks) { |
| 14604 | parsedExpression = expensiveChecksInterceptor(parsedExpression); |
| 14605 | } |
| 14606 | cache[cacheKey] = parsedExpression; |
| 14607 | } |
| 14608 | return addInterceptor(parsedExpression, interceptorFn); |
| 14609 | |
| 14610 | case 'function': |
| 14611 | return addInterceptor(exp, interceptorFn); |
| 14612 | |
| 14613 | default: |
| 14614 | return addInterceptor(noop, interceptorFn); |
| 14615 | } |
| 14616 | } |
| 14617 | |
| 14618 | function expensiveChecksInterceptor(fn) { |
| 14619 | if (!fn) return fn; |
no test coverage detected