* Rewrite an expression, prefixing all path accessors with * `scope.` and generate getter/setter functions. * * @param {String} exp * @return {Function}
(exp)
| 2897 | */ |
| 2898 | |
| 2899 | function compileGetter(exp) { |
| 2900 | if (improperKeywordsRE.test(exp)) { |
| 2901 | 'development' !== 'production' && warn('Avoid using reserved keywords in expression: ' + exp); |
| 2902 | } |
| 2903 | // reset state |
| 2904 | saved.length = 0; |
| 2905 | // save strings and object literal keys |
| 2906 | var body = exp.replace(saveRE, save).replace(wsRE, ''); |
| 2907 | // rewrite all paths |
| 2908 | // pad 1 space here because the regex matches 1 extra char |
| 2909 | body = (' ' + body).replace(identRE, rewrite).replace(restoreRE, restore); |
| 2910 | return makeGetterFn(body); |
| 2911 | } |
| 2912 | |
| 2913 | /** |
| 2914 | * Build a getter function. Requires eval. |
no test coverage detected