(exp, interceptorFn, expensiveChecks)
| 15012 | return $parse; |
| 15013 | |
| 15014 | function $parse(exp, interceptorFn, expensiveChecks) { |
| 15015 | var parsedExpression, oneTime, cacheKey; |
| 15016 | |
| 15017 | expensiveChecks = expensiveChecks || runningChecksEnabled; |
| 15018 | |
| 15019 | switch (typeof exp) { |
| 15020 | case 'string': |
| 15021 | exp = exp.trim(); |
| 15022 | cacheKey = exp; |
| 15023 | |
| 15024 | var cache = (expensiveChecks ? cacheExpensive : cacheDefault); |
| 15025 | parsedExpression = cache[cacheKey]; |
| 15026 | |
| 15027 | if (!parsedExpression) { |
| 15028 | if (exp.charAt(0) === ':' && exp.charAt(1) === ':') { |
| 15029 | oneTime = true; |
| 15030 | exp = exp.substring(2); |
| 15031 | } |
| 15032 | var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions; |
| 15033 | var lexer = new Lexer(parseOptions); |
| 15034 | var parser = new Parser(lexer, $filter, parseOptions); |
| 15035 | parsedExpression = parser.parse(exp); |
| 15036 | if (parsedExpression.constant) { |
| 15037 | parsedExpression.$$watchDelegate = constantWatchDelegate; |
| 15038 | } else if (oneTime) { |
| 15039 | parsedExpression.$$watchDelegate = parsedExpression.literal ? |
| 15040 | oneTimeLiteralWatchDelegate : oneTimeWatchDelegate; |
| 15041 | } else if (parsedExpression.inputs) { |
| 15042 | parsedExpression.$$watchDelegate = inputsWatchDelegate; |
| 15043 | } |
| 15044 | if (expensiveChecks) { |
| 15045 | parsedExpression = expensiveChecksInterceptor(parsedExpression); |
| 15046 | } |
| 15047 | cache[cacheKey] = parsedExpression; |
| 15048 | } |
| 15049 | return addInterceptor(parsedExpression, interceptorFn); |
| 15050 | |
| 15051 | case 'function': |
| 15052 | return addInterceptor(exp, interceptorFn); |
| 15053 | |
| 15054 | default: |
| 15055 | return addInterceptor(noop, interceptorFn); |
| 15056 | } |
| 15057 | } |
| 15058 | |
| 15059 | function expensiveChecksInterceptor(fn) { |
| 15060 | if (!fn) return fn; |
no test coverage detected