| 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 class WorkItem { | 5 class WorkItem { |
| 6 final Element element; | 6 final Element element; |
| 7 TreeElements resolutionTree; | 7 TreeElements resolutionTree; |
| 8 bool allowSpeculativeOptimization = true; | 8 bool allowSpeculativeOptimization = true; |
| 9 List<HTypeGuard> guards = const <HTypeGuard>[]; | 9 List<HTypeGuard> guards = const <HTypeGuard>[]; |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 class Compiler implements DiagnosticListener { | 74 class Compiler implements DiagnosticListener { |
| 75 final Map<String, LibraryElement> libraries; | 75 final Map<String, LibraryElement> libraries; |
| 76 int nextFreeClassId = 0; | 76 int nextFreeClassId = 0; |
| 77 World world; | 77 World world; |
| 78 String assembledCode; | 78 String assembledCode; |
| 79 Namer namer; | 79 Namer namer; |
| 80 Types types; | 80 Types types; |
| 81 final bool enableTypeAssertions; | 81 final bool enableTypeAssertions; |
| 82 final bool enableUserAssertions; |
| 82 | 83 |
| 83 final Tracer tracer; | 84 final Tracer tracer; |
| 84 | 85 |
| 85 CompilerTask measuredTask; | 86 CompilerTask measuredTask; |
| 86 Element _currentElement; | 87 Element _currentElement; |
| 87 LibraryElement coreLibrary; | 88 LibraryElement coreLibrary; |
| 88 LibraryElement coreImplLibrary; | 89 LibraryElement coreImplLibrary; |
| 89 LibraryElement isolateLibrary; | 90 LibraryElement isolateLibrary; |
| 90 LibraryElement jsHelperLibrary; | 91 LibraryElement jsHelperLibrary; |
| 91 LibraryElement interceptorsLibrary; | 92 LibraryElement interceptorsLibrary; |
| 92 LibraryElement mainApp; | 93 LibraryElement mainApp; |
| 93 | 94 |
| 94 ClassElement objectClass; | 95 ClassElement objectClass; |
| 95 ClassElement closureClass; | 96 ClassElement closureClass; |
| 96 ClassElement dynamicClass; | 97 ClassElement dynamicClass; |
| 97 ClassElement boolClass; | 98 ClassElement boolClass; |
| 98 ClassElement numClass; | 99 ClassElement numClass; |
| 99 ClassElement intClass; | 100 ClassElement intClass; |
| 100 ClassElement doubleClass; | 101 ClassElement doubleClass; |
| 101 ClassElement stringClass; | 102 ClassElement stringClass; |
| 102 ClassElement functionClass; | 103 ClassElement functionClass; |
| 103 ClassElement nullClass; | 104 ClassElement nullClass; |
| 104 ClassElement listClass; | 105 ClassElement listClass; |
| 106 Element assertMethod; |
| 105 | 107 |
| 106 Element get currentElement() => _currentElement; | 108 Element get currentElement() => _currentElement; |
| 107 withCurrentElement(Element element, f()) { | 109 withCurrentElement(Element element, f()) { |
| 108 Element old = currentElement; | 110 Element old = currentElement; |
| 109 _currentElement = element; | 111 _currentElement = element; |
| 110 try { | 112 try { |
| 111 return f(); | 113 return f(); |
| 112 } catch (CompilerCancelledException ex) { | 114 } catch (CompilerCancelledException ex) { |
| 113 throw; | 115 throw; |
| 114 } catch (var ex) { | 116 } catch (var ex) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 136 static final SourceString NO_SUCH_METHOD_EXCEPTION = | 138 static final SourceString NO_SUCH_METHOD_EXCEPTION = |
| 137 const SourceString('NoSuchMethodException'); | 139 const SourceString('NoSuchMethodException'); |
| 138 static final SourceString START_ROOT_ISOLATE = | 140 static final SourceString START_ROOT_ISOLATE = |
| 139 const SourceString('startRootIsolate'); | 141 const SourceString('startRootIsolate'); |
| 140 bool enabledNoSuchMethod = false; | 142 bool enabledNoSuchMethod = false; |
| 141 | 143 |
| 142 Stopwatch codegenProgress; | 144 Stopwatch codegenProgress; |
| 143 | 145 |
| 144 Compiler([this.tracer = const Tracer(), | 146 Compiler([this.tracer = const Tracer(), |
| 145 this.enableTypeAssertions = false, | 147 this.enableTypeAssertions = false, |
| 148 this.enableUserAssertions = false, |
| 146 bool emitJavascript = true, | 149 bool emitJavascript = true, |
| 147 validateUnparse = false]) | 150 validateUnparse = false]) |
| 148 : libraries = new Map<String, LibraryElement>(), | 151 : libraries = new Map<String, LibraryElement>(), |
| 149 world = new World(), | 152 world = new World(), |
| 150 codegenProgress = new Stopwatch.start() { | 153 codegenProgress = new Stopwatch.start() { |
| 151 namer = new Namer(this); | 154 namer = new Namer(this); |
| 152 constantHandler = new ConstantHandler(this); | 155 constantHandler = new ConstantHandler(this); |
| 153 scanner = new ScannerTask(this); | 156 scanner = new ScannerTask(this); |
| 154 dietParser = new DietParserTask(this); | 157 dietParser = new DietParserTask(this); |
| 155 parser = new ParserTask(this); | 158 parser = new ParserTask(this); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // TODO(ahe): Clean this up as described above. | 319 // TODO(ahe): Clean this up as described above. |
| 317 scanner.importLibrary(coreImplLibrary, coreLibrary, null); | 320 scanner.importLibrary(coreImplLibrary, coreLibrary, null); |
| 318 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); | 321 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); |
| 319 scanner.importLibrary(interceptorsLibrary, coreLibrary, null); | 322 scanner.importLibrary(interceptorsLibrary, coreLibrary, null); |
| 320 addForeignFunctions(jsHelperLibrary); | 323 addForeignFunctions(jsHelperLibrary); |
| 321 addForeignFunctions(interceptorsLibrary); | 324 addForeignFunctions(interceptorsLibrary); |
| 322 | 325 |
| 323 libraries['dart:core'] = coreLibrary; | 326 libraries['dart:core'] = coreLibrary; |
| 324 libraries['dart:coreimpl'] = coreImplLibrary; | 327 libraries['dart:coreimpl'] = coreImplLibrary; |
| 325 | 328 |
| 329 assertMethod = coreLibrary.find(const SourceString('assert')); |
| 330 |
| 326 initializeSpecialClasses(); | 331 initializeSpecialClasses(); |
| 327 } | 332 } |
| 328 | 333 |
| 329 /** Define the JS helper functions in the given library. */ | 334 /** Define the JS helper functions in the given library. */ |
| 330 void addForeignFunctions(LibraryElement library) { | 335 void addForeignFunctions(LibraryElement library) { |
| 331 library.define(new ForeignElement( | 336 library.define(new ForeignElement( |
| 332 const SourceString('JS'), library), this); | 337 const SourceString('JS'), library), this); |
| 333 library.define(new ForeignElement( | 338 library.define(new ForeignElement( |
| 334 const SourceString('UNINTERCEPTED'), library), this); | 339 const SourceString('UNINTERCEPTED'), library), this); |
| 335 library.define(new ForeignElement( | 340 library.define(new ForeignElement( |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 // invariant that endOffset > beginOffset, but for EOF the | 595 // invariant that endOffset > beginOffset, but for EOF the |
| 591 // charoffset of the next token may be [beginOffset]. This can | 596 // charoffset of the next token may be [beginOffset]. This can |
| 592 // also happen for synthetized tokens that are produced during | 597 // also happen for synthetized tokens that are produced during |
| 593 // error handling. | 598 // error handling. |
| 594 final endOffset = | 599 final endOffset = |
| 595 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1); | 600 Math.max((end.next !== null) ? end.next.charOffset : 0, beginOffset + 1); |
| 596 assert(endOffset > beginOffset); | 601 assert(endOffset > beginOffset); |
| 597 return f(beginOffset, endOffset); | 602 return f(beginOffset, endOffset); |
| 598 } | 603 } |
| 599 } | 604 } |
| OLD | NEW |