| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * If true, print a warning for each method that was resolved, but not | 7 * If true, print a warning for each method that was resolved, but not |
| 8 * compiled. | 8 * compiled. |
| 9 */ | 9 */ |
| 10 final bool REPORT_EXCESS_RESOLUTION = false; | 10 final bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ClassElement listClass; | 97 ClassElement listClass; |
| 98 Element assertMethod; | 98 Element assertMethod; |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Interface used to determine if an object has the JavaScript | 101 * Interface used to determine if an object has the JavaScript |
| 102 * indexing behavior. The interface is only visible to specific | 102 * indexing behavior. The interface is only visible to specific |
| 103 * libraries. | 103 * libraries. |
| 104 */ | 104 */ |
| 105 ClassElement jsIndexingBehaviorInterface; | 105 ClassElement jsIndexingBehaviorInterface; |
| 106 | 106 |
| 107 Element get currentElement() => _currentElement; | 107 Element get currentElement => _currentElement; |
| 108 withCurrentElement(Element element, f()) { | 108 withCurrentElement(Element element, f()) { |
| 109 Element old = currentElement; | 109 Element old = currentElement; |
| 110 _currentElement = element; | 110 _currentElement = element; |
| 111 try { | 111 try { |
| 112 return f(); | 112 return f(); |
| 113 } catch (CompilerCancelledException ex) { | 113 } catch (CompilerCancelledException ex) { |
| 114 throw; | 114 throw; |
| 115 } catch (StackOverflowException ex) { | 115 } catch (StackOverflowException ex) { |
| 116 // We cannot report anything useful in this case, because we | 116 // We cannot report anything useful in this case, because we |
| 117 // do not have enough stack space. | 117 // do not have enough stack space. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 typesTask = new ti.TypesTask(this); | 185 typesTask = new ti.TypesTask(this); |
| 186 backend = emitJavascript ? | 186 backend = emitJavascript ? |
| 187 new js_backend.JavaScriptBackend(this, generateSourceMap) : | 187 new js_backend.JavaScriptBackend(this, generateSourceMap) : |
| 188 new dart_backend.DartBackend(this, validateUnparse); | 188 new dart_backend.DartBackend(this, validateUnparse); |
| 189 enqueuer = new EnqueueTask(this); | 189 enqueuer = new EnqueueTask(this); |
| 190 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper, | 190 tasks = [scanner, dietParser, parser, resolver, closureToClassMapper, |
| 191 checker, typesTask, constantHandler, enqueuer]; | 191 checker, typesTask, constantHandler, enqueuer]; |
| 192 tasks.addAll(backend.tasks); | 192 tasks.addAll(backend.tasks); |
| 193 } | 193 } |
| 194 | 194 |
| 195 Universe get resolverWorld() => enqueuer.resolution.universe; | 195 Universe get resolverWorld => enqueuer.resolution.universe; |
| 196 Universe get codegenWorld() => enqueuer.codegen.universe; | 196 Universe get codegenWorld => enqueuer.codegen.universe; |
| 197 | 197 |
| 198 int getNextFreeClassId() => nextFreeClassId++; | 198 int getNextFreeClassId() => nextFreeClassId++; |
| 199 | 199 |
| 200 void ensure(bool condition) { | 200 void ensure(bool condition) { |
| 201 if (!condition) cancel('failed assertion in leg'); | 201 if (!condition) cancel('failed assertion in leg'); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void unimplemented(String methodName, | 204 void unimplemented(String methodName, |
| 205 [Node node, Token token, HInstruction instruction, | 205 [Node node, Token token, HInstruction instruction, |
| 206 Element element]) { | 206 Element element]) { |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 Uri uri = element.getCompilationUnit().script.uri; | 819 Uri uri = element.getCompilationUnit().script.uri; |
| 820 return (position === null) | 820 return (position === null) |
| 821 ? new SourceSpan(uri, 0, 0) | 821 ? new SourceSpan(uri, 0, 0) |
| 822 : spanFromTokens(position, position, uri); | 822 : spanFromTokens(position, position, uri); |
| 823 } | 823 } |
| 824 | 824 |
| 825 Script readScript(Uri uri, [ScriptTag node]) { | 825 Script readScript(Uri uri, [ScriptTag node]) { |
| 826 unimplemented('Compiler.readScript'); | 826 unimplemented('Compiler.readScript'); |
| 827 } | 827 } |
| 828 | 828 |
| 829 String get legDirectory() { | 829 String get legDirectory { |
| 830 unimplemented('Compiler.legDirectory'); | 830 unimplemented('Compiler.legDirectory'); |
| 831 } | 831 } |
| 832 | 832 |
| 833 Element findHelper(SourceString name) | 833 Element findHelper(SourceString name) |
| 834 => jsHelperLibrary.findLocal(name); | 834 => jsHelperLibrary.findLocal(name); |
| 835 Element findInterceptor(SourceString name) | 835 Element findInterceptor(SourceString name) |
| 836 => interceptorsLibrary.findLocal(name); | 836 => interceptorsLibrary.findLocal(name); |
| 837 | 837 |
| 838 bool get isMockCompilation() => false; | 838 bool get isMockCompilation => false; |
| 839 } | 839 } |
| 840 | 840 |
| 841 class CompilerTask { | 841 class CompilerTask { |
| 842 final Compiler compiler; | 842 final Compiler compiler; |
| 843 final Stopwatch watch; | 843 final Stopwatch watch; |
| 844 | 844 |
| 845 CompilerTask(this.compiler) : watch = new Stopwatch(); | 845 CompilerTask(this.compiler) : watch = new Stopwatch(); |
| 846 | 846 |
| 847 String get name() => 'Unknown task'; | 847 String get name => 'Unknown task'; |
| 848 int get timing() => watch.elapsedInMs(); | 848 int get timing => watch.elapsedInMs(); |
| 849 | 849 |
| 850 measure(Function action) { | 850 measure(Function action) { |
| 851 // TODO(kasperl): Do we have to worry about exceptions here? | 851 // TODO(kasperl): Do we have to worry about exceptions here? |
| 852 CompilerTask previous = compiler.measuredTask; | 852 CompilerTask previous = compiler.measuredTask; |
| 853 compiler.measuredTask = this; | 853 compiler.measuredTask = this; |
| 854 if (previous !== null) previous.watch.stop(); | 854 if (previous !== null) previous.watch.stop(); |
| 855 watch.start(); | 855 watch.start(); |
| 856 var result = action(); | 856 var result = action(); |
| 857 watch.stop(); | 857 watch.stop(); |
| 858 if (previous !== null) previous.watch.start(); | 858 if (previous !== null) previous.watch.start(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 final endOffset = end.charOffset + end.slowCharCount; | 899 final endOffset = end.charOffset + end.slowCharCount; |
| 900 | 900 |
| 901 // [begin] and [end] might be the same for the same empty token. This | 901 // [begin] and [end] might be the same for the same empty token. This |
| 902 // happens for instance when scanning '$$'. | 902 // happens for instance when scanning '$$'. |
| 903 assert(endOffset >= beginOffset); | 903 assert(endOffset >= beginOffset); |
| 904 return f(beginOffset, endOffset); | 904 return f(beginOffset, endOffset); |
| 905 } | 905 } |
| 906 | 906 |
| 907 String toString() => 'SourceSpan($uri, $begin, $end)'; | 907 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 908 } | 908 } |
| OLD | NEW |