Chromium Code Reviews| 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 Function run; | 8 Function run; |
| 9 Map<int, BailoutInfo> bailouts = null; | 9 Map<int, BailoutInfo> bailouts = null; |
| 10 bool allowSpeculativeOptimization = true; | 10 bool allowSpeculativeOptimization = true; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 | 48 |
| 49 CompilerTask measuredTask; | 49 CompilerTask measuredTask; |
| 50 Element _currentElement; | 50 Element _currentElement; |
| 51 LibraryElement coreLibrary; | 51 LibraryElement coreLibrary; |
| 52 LibraryElement coreImplLibrary; | 52 LibraryElement coreImplLibrary; |
| 53 LibraryElement isolateLibrary; | 53 LibraryElement isolateLibrary; |
| 54 LibraryElement jsHelperLibrary; | 54 LibraryElement jsHelperLibrary; |
| 55 LibraryElement mainApp; | 55 LibraryElement mainApp; |
| 56 ClassElement objectClass; | 56 ClassElement objectClass; |
| 57 ClassElement closureClass; | 57 ClassElement closureClass; |
| 58 ClassElement dynamicClass; | |
| 59 ClassElement boolClass; | |
| 60 ClassElement numClass; | |
| 61 ClassElement intClass; | |
| 62 ClassElement doubleClass; | |
| 63 ClassElement stringClass; | |
| 64 ClassElement functionClass; | |
| 58 | 65 |
| 59 Element get currentElement() => _currentElement; | 66 Element get currentElement() => _currentElement; |
| 60 withCurrentElement(Element element, f()) { | 67 withCurrentElement(Element element, f()) { |
| 61 Element old = currentElement; | 68 Element old = currentElement; |
| 62 _currentElement = element; | 69 _currentElement = element; |
| 63 try { | 70 try { |
| 64 return f(); | 71 return f(); |
| 65 } finally { | 72 } finally { |
| 66 _currentElement = old; | 73 _currentElement = old; |
| 67 } | 74 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 79 SsaCodeGeneratorTask generator; | 86 SsaCodeGeneratorTask generator; |
| 80 CodeEmitterTask emitter; | 87 CodeEmitterTask emitter; |
| 81 ConstantHandler constantHandler; | 88 ConstantHandler constantHandler; |
| 82 EnqueueTask enqueuer; | 89 EnqueueTask enqueuer; |
| 83 | 90 |
| 84 static final SourceString MAIN = const SourceString('main'); | 91 static final SourceString MAIN = const SourceString('main'); |
| 85 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 92 static final SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
| 86 static final SourceString NO_SUCH_METHOD_EXCEPTION = | 93 static final SourceString NO_SUCH_METHOD_EXCEPTION = |
| 87 const SourceString('NoSuchMethodException'); | 94 const SourceString('NoSuchMethodException'); |
| 88 static final SourceString OBJECT = const SourceString('Object'); | 95 static final SourceString OBJECT = const SourceString('Object'); |
| 96 static final SourceString DYNAMIC = const SourceString('Dynamic'); | |
|
ahe
2012/03/19 10:51:57
I think these constants are superfluous. I'll try
ahe
2012/03/19 15:31:09
Done.
| |
| 89 static final SourceString START_ROOT_ISOLATE = | 97 static final SourceString START_ROOT_ISOLATE = |
| 90 const SourceString('startRootIsolate'); | 98 const SourceString('startRootIsolate'); |
| 91 static final SourceString CLOSURE = const SourceString('Closure'); | 99 static final SourceString CLOSURE = const SourceString('Closure'); |
| 92 bool enabledNoSuchMethod = false; | 100 bool enabledNoSuchMethod = false; |
| 93 | 101 |
| 94 Compiler.withCurrentDirectory(String this.currentDirectory, | 102 Compiler.withCurrentDirectory(String this.currentDirectory, |
| 95 [this.tracer = const Tracer()]) | 103 [this.tracer = const Tracer()]) |
| 96 : types = new Types(), | 104 : types = new Types(), |
| 97 universe = new Universe(), | 105 universe = new Universe(), |
| 98 worklist = new Queue<WorkItem>() { | 106 worklist = new Queue<WorkItem>() { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 | 188 |
| 181 void enableIsolateSupport(LibraryElement element) { | 189 void enableIsolateSupport(LibraryElement element) { |
| 182 isolateLibrary = element; | 190 isolateLibrary = element; |
| 183 addToWorkList(element.find(START_ROOT_ISOLATE)); | 191 addToWorkList(element.find(START_ROOT_ISOLATE)); |
| 184 } | 192 } |
| 185 | 193 |
| 186 void onLibraryLoaded(LibraryElement library, Uri uri) { | 194 void onLibraryLoaded(LibraryElement library, Uri uri) { |
| 187 if (uri.toString() == 'dart:isolate') { | 195 if (uri.toString() == 'dart:isolate') { |
| 188 enableIsolateSupport(library); | 196 enableIsolateSupport(library); |
| 189 } | 197 } |
| 198 if (dynamicClass !== null) { | |
|
ahe
2012/03/19 10:51:57
dynamicClass is null while loading the built-in li
ahe
2012/03/19 15:31:09
Done.
| |
| 199 withCurrentElement(library, () { | |
| 200 library.define(dynamicClass, this); | |
| 201 }); | |
| 202 } | |
| 190 } | 203 } |
| 191 | 204 |
| 192 abstract LibraryElement scanBuiltinLibrary(String filename); | 205 abstract LibraryElement scanBuiltinLibrary(String filename); |
| 193 | 206 |
| 194 void scanBuiltinLibraries() { | 207 void scanBuiltinLibraries() { |
| 195 coreImplLibrary = scanBuiltinLibrary('coreimpl.dart'); | 208 coreImplLibrary = scanBuiltinLibrary('coreimpl.dart'); |
| 196 jsHelperLibrary = scanBuiltinLibrary('js_helper.dart'); | 209 jsHelperLibrary = scanBuiltinLibrary('js_helper.dart'); |
| 197 coreLibrary = scanBuiltinLibrary('core.dart'); | 210 coreLibrary = scanBuiltinLibrary('core.dart'); |
| 198 objectClass = coreLibrary.find(OBJECT); | 211 objectClass = coreLibrary.find(OBJECT); |
| 212 boolClass = coreLibrary.find(const SourceString('bool')); | |
| 213 numClass = coreLibrary.find(const SourceString('num')); | |
| 214 intClass = coreLibrary.find(const SourceString('int')); | |
| 215 doubleClass = coreLibrary.find(const SourceString('double')); | |
| 216 stringClass = coreLibrary.find(const SourceString('String')); | |
| 217 functionClass = coreLibrary.find(const SourceString('Function')); | |
| 218 | |
| 199 closureClass = jsHelperLibrary.find(CLOSURE); | 219 closureClass = jsHelperLibrary.find(CLOSURE); |
| 220 dynamicClass = new ClassElement(DYNAMIC, coreLibrary); | |
|
ngeoffray
2012/03/19 11:48:01
Wy don't we have a 'class Dynamic' in the core lib
ahe
2012/03/19 15:31:09
Done.
| |
| 221 dynamicClass.isResolved = true; | |
| 200 // Since coreLibrary import the libraries "coreimpl", and | 222 // Since coreLibrary import the libraries "coreimpl", and |
| 201 // "js_helper", coreLibrary is null when they are being built. So | 223 // "js_helper", coreLibrary is null when they are being built. So |
| 202 // we add the implicit import of coreLibrary now. This can be | 224 // we add the implicit import of coreLibrary now. This can be |
| 203 // cleaned up when we have proper support for "dart:core" and | 225 // cleaned up when we have proper support for "dart:core" and |
| 204 // don't need to access it through the field "coreLibrary". | 226 // don't need to access it through the field "coreLibrary". |
| 205 // TODO(ahe): Clean this up as described above. | 227 // TODO(ahe): Clean this up as described above. |
| 206 scanner.importLibrary(coreImplLibrary, coreLibrary, null); | 228 scanner.importLibrary(coreImplLibrary, coreLibrary, null); |
| 207 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); | 229 scanner.importLibrary(jsHelperLibrary, coreLibrary, null); |
| 208 addForeignFunctions(jsHelperLibrary); | 230 addForeignFunctions(jsHelperLibrary); |
| 209 | 231 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 } | 496 } |
| 475 } | 497 } |
| 476 | 498 |
| 477 class SourceSpan { | 499 class SourceSpan { |
| 478 final Uri uri; | 500 final Uri uri; |
| 479 final int begin; | 501 final int begin; |
| 480 final int end; | 502 final int end; |
| 481 | 503 |
| 482 const SourceSpan(this.uri, this.begin, this.end); | 504 const SourceSpan(this.uri, this.begin, this.end); |
| 483 } | 505 } |
| OLD | NEW |