(exp, interceptorFn, expensiveChecks)
| 16149 | return $parse; |
| 16150 | |
| 16151 | function $parse(exp, interceptorFn, expensiveChecks) { |
| 16152 | var parsedExpression, oneTime, cacheKey; |
| 16153 | |
| 16154 | expensiveChecks = expensiveChecks || runningChecksEnabled; |
| 16155 | |
| 16156 | switch (typeof exp) { |
| 16157 | case 'string': |
| 16158 | exp = exp.trim(); |
| 16159 | cacheKey = exp; |
| 16160 | |
| 16161 | var cache = (expensiveChecks ? cacheExpensive : cacheDefault); |
| 16162 | parsedExpression = cache[cacheKey]; |
| 16163 | |
| 16164 | if (!parsedExpression) { |
| 16165 | if (exp.charAt(0) === ':' && exp.charAt(1) === ':') { |
| 16166 | oneTime = true; |
| 16167 | exp = exp.substring(2); |
| 16168 | } |
| 16169 | var parseOptions = expensiveChecks ? $parseOptionsExpensive : $parseOptions; |
| 16170 | var lexer = new Lexer(parseOptions); |
| 16171 | var parser = new Parser(lexer, $filter, parseOptions); |
| 16172 | parsedExpression = parser.parse(exp); |
| 16173 | if (parsedExpression.constant) { |
| 16174 | parsedExpression.$$watchDelegate = constantWatchDelegate; |
| 16175 | } else if (oneTime) { |
| 16176 | parsedExpression.$$watchDelegate = parsedExpression.literal ? |
| 16177 | oneTimeLiteralWatchDelegate : oneTimeWatchDelegate; |
| 16178 | } else if (parsedExpression.inputs) { |
| 16179 | parsedExpression.$$watchDelegate = inputsWatchDelegate; |
| 16180 | } |
| 16181 | if (expensiveChecks) { |
| 16182 | parsedExpression = expensiveChecksInterceptor(parsedExpression); |
| 16183 | } |
| 16184 | cache[cacheKey] = parsedExpression; |
| 16185 | } |
| 16186 | return addInterceptor(parsedExpression, interceptorFn); |
| 16187 | |
| 16188 | case 'function': |
| 16189 | return addInterceptor(exp, interceptorFn); |
| 16190 | |
| 16191 | default: |
| 16192 | return addInterceptor(noop, interceptorFn); |
| 16193 | } |
| 16194 | } |
| 16195 | |
| 16196 | function expensiveChecksInterceptor(fn) { |
| 16197 | if (!fn) return fn; |
no test coverage detected