| 2847 | function createInternalInjector(cache, factory) { |
| 2848 | |
| 2849 | function getService(serviceName) { |
| 2850 | if (typeof serviceName !== 'string') { |
| 2851 | throw Error('Service name expected'); |
| 2852 | } |
| 2853 | if (cache.hasOwnProperty(serviceName)) { |
| 2854 | if (cache[serviceName] === INSTANTIATING) { |
| 2855 | throw Error('Circular dependency: ' + path.join(' <- ')); |
| 2856 | } |
| 2857 | return cache[serviceName]; |
| 2858 | } else { |
| 2859 | try { |
| 2860 | path.unshift(serviceName); |
| 2861 | cache[serviceName] = INSTANTIATING; |
| 2862 | return cache[serviceName] = factory(serviceName); |
| 2863 | } finally { |
| 2864 | path.shift(); |
| 2865 | } |
| 2866 | } |
| 2867 | } |
| 2868 | |
| 2869 | function invoke(fn, self, locals){ |
| 2870 | var args = [], |