(exp, interceptorFn, expensiveChecks)
| 15445 | return $parse; |
| 15446 | |
| 15447 | function $parse(exp, interceptorFn, expensiveChecks) { |
| 15448 | var parsedExpression, oneTime, cacheKey; |
| 15449 | |
| 15450 | expensiveChecks = expensiveChecks || runningChecksEnabled; |
| 15451 | |
| 15452 | switch (typeof exp) { |
| 15453 | case 'string': |
| 15454 | exp = exp.trim(); |
| 15455 | cacheKey = exp; |
| 15456 | |
| 15457 | var cache = (expensiveChecks ? cacheExpensive : cacheDefault); |
| 15458 | parsedExpression = cache[cacheKey]; |
| 15459 | |
| 15460 | if (!parsedExpression) { |
| 15461 | if (exp.charAt(0) === ':' && exp.charAt(1) === ':') { |
| 15462 | oneTime = true; |
| 15463 | exp = exp.substring(2); |
| 15464 | } |
| 15465 | var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions; |
| 15466 | var lexer = new Lexer(parseOptions); |
| 15467 | var parser = new Parser(lexer, $filter, parseOptions); |
| 15468 | parsedExpression = parser.parse(exp); |
| 15469 | if (parsedExpression.constant) { |
| 15470 | parsedExpression.$$watchDelegate = constantWatchDelegate; |
| 15471 | } else if (oneTime) { |
| 15472 | parsedExpression.$$watchDelegate = parsedExpression.literal |
| 15473 | ? oneTimeLiteralWatchDelegate |
| 15474 | : oneTimeWatchDelegate; |
| 15475 | } else if (parsedExpression.inputs) { |
| 15476 | parsedExpression.$$watchDelegate = inputsWatchDelegate; |
| 15477 | } |
| 15478 | if (expensiveChecks) { |
| 15479 | parsedExpression = expensiveChecksInterceptor(parsedExpression); |
| 15480 | } |
| 15481 | cache[cacheKey] = parsedExpression; |
| 15482 | } |
| 15483 | return addInterceptor(parsedExpression, interceptorFn); |
| 15484 | |
| 15485 | case 'function': |
| 15486 | return addInterceptor(exp, interceptorFn); |
| 15487 | |
| 15488 | default: |
| 15489 | return addInterceptor(noop, interceptorFn); |
| 15490 | } |
| 15491 | } |
| 15492 | |
| 15493 | function expensiveChecksInterceptor(fn) { |
| 15494 | if (!fn) return fn; |
no test coverage detected