| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
| 9 * compiled. | 9 * compiled. |
| 10 */ | 10 */ |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 // The backend determines the native resolution enqueuer, with a no-op | 267 // The backend determines the native resolution enqueuer, with a no-op |
| 268 // default, so tools like dart2dart can ignore the native classes. | 268 // default, so tools like dart2dart can ignore the native classes. |
| 269 native.NativeEnqueuer nativeResolutionEnqueuer(world) { | 269 native.NativeEnqueuer nativeResolutionEnqueuer(world) { |
| 270 return new native.NativeEnqueuer(); | 270 return new native.NativeEnqueuer(); |
| 271 } | 271 } |
| 272 native.NativeEnqueuer nativeCodegenEnqueuer(world) { | 272 native.NativeEnqueuer nativeCodegenEnqueuer(world) { |
| 273 return new native.NativeEnqueuer(); | 273 return new native.NativeEnqueuer(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 /// Generates the output and returns the total size of the generated code. | 276 void assembleProgram(); |
| 277 int assembleProgram(); | |
| 278 | |
| 279 List<CompilerTask> get tasks; | 277 List<CompilerTask> get tasks; |
| 280 | 278 |
| 281 void onResolutionComplete() {} | 279 void onResolutionComplete() {} |
| 282 | 280 |
| 283 ItemCompilationContext createItemCompilationContext() { | 281 ItemCompilationContext createItemCompilationContext() { |
| 284 return new ItemCompilationContext(); | 282 return new ItemCompilationContext(); |
| 285 } | 283 } |
| 286 | 284 |
| 287 bool classNeedsRti(ClassElement cls); | 285 bool classNeedsRti(ClassElement cls); |
| 288 bool methodNeedsRti(FunctionElement function); | 286 bool methodNeedsRti(FunctionElement function); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 static final Uri DART_CORE = new Uri(scheme: 'dart', path: 'core'); | 620 static final Uri DART_CORE = new Uri(scheme: 'dart', path: 'core'); |
| 623 static final Uri DART_MIRRORS = new Uri(scheme: 'dart', path: 'mirrors'); | 621 static final Uri DART_MIRRORS = new Uri(scheme: 'dart', path: 'mirrors'); |
| 624 static final Uri DART_NATIVE_TYPED_DATA = | 622 static final Uri DART_NATIVE_TYPED_DATA = |
| 625 new Uri(scheme: 'dart', path: '_native_typed_data'); | 623 new Uri(scheme: 'dart', path: '_native_typed_data'); |
| 626 static final Uri DART_INTERNAL = new Uri(scheme: 'dart', path: '_internal'); | 624 static final Uri DART_INTERNAL = new Uri(scheme: 'dart', path: '_internal'); |
| 627 static final Uri DART_ASYNC = new Uri(scheme: 'dart', path: 'async'); | 625 static final Uri DART_ASYNC = new Uri(scheme: 'dart', path: 'async'); |
| 628 | 626 |
| 629 final Stopwatch totalCompileTime = new Stopwatch(); | 627 final Stopwatch totalCompileTime = new Stopwatch(); |
| 630 int nextFreeClassId = 0; | 628 int nextFreeClassId = 0; |
| 631 World world; | 629 World world; |
| 630 String assembledCode; |
| 632 Types types; | 631 Types types; |
| 633 _CompilerCoreTypes _coreTypes; | 632 _CompilerCoreTypes _coreTypes; |
| 634 | 633 |
| 635 final CacheStrategy cacheStrategy; | 634 final CacheStrategy cacheStrategy; |
| 636 | 635 |
| 637 /** | 636 /** |
| 638 * Map from token to the first preceeding comment token. | 637 * Map from token to the first preceeding comment token. |
| 639 */ | 638 */ |
| 640 final TokenMap commentMap = new TokenMap(); | 639 final TokenMap commentMap = new TokenMap(); |
| 641 | 640 |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 | 1072 |
| 1074 bool get disableTypeInference => disableTypeInferenceFlag; | 1073 bool get disableTypeInference => disableTypeInferenceFlag; |
| 1075 | 1074 |
| 1076 int getNextFreeClassId() => nextFreeClassId++; | 1075 int getNextFreeClassId() => nextFreeClassId++; |
| 1077 | 1076 |
| 1078 void unimplemented(Spannable spannable, String methodName) { | 1077 void unimplemented(Spannable spannable, String methodName) { |
| 1079 internalError(spannable, "$methodName not implemented."); | 1078 internalError(spannable, "$methodName not implemented."); |
| 1080 } | 1079 } |
| 1081 | 1080 |
| 1082 void internalError(Spannable node, reason) { | 1081 void internalError(Spannable node, reason) { |
| 1082 assembledCode = null; // Compilation failed. Make sure that we |
| 1083 // don't return a bogus result. |
| 1083 String message = tryToString(reason); | 1084 String message = tryToString(reason); |
| 1084 reportDiagnosticInternal( | 1085 reportDiagnosticInternal( |
| 1085 node, MessageKind.GENERIC, {'text': message}, api.Diagnostic.CRASH); | 1086 node, MessageKind.GENERIC, {'text': message}, api.Diagnostic.CRASH); |
| 1086 throw 'Internal Error: $message'; | 1087 throw 'Internal Error: $message'; |
| 1087 } | 1088 } |
| 1088 | 1089 |
| 1089 void unhandledExceptionOnElement(Element element) { | 1090 void unhandledExceptionOnElement(Element element) { |
| 1090 if (hasCrashed) return; | 1091 if (hasCrashed) return; |
| 1091 hasCrashed = true; | 1092 hasCrashed = true; |
| 1092 reportDiagnostic(element, | 1093 reportDiagnostic(element, |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 if (compileAll) { | 1608 if (compileAll) { |
| 1608 libraryLoader.libraries.forEach((LibraryElement library) { | 1609 libraryLoader.libraries.forEach((LibraryElement library) { |
| 1609 fullyEnqueueLibrary(library, enqueuer.codegen); | 1610 fullyEnqueueLibrary(library, enqueuer.codegen); |
| 1610 }); | 1611 }); |
| 1611 } | 1612 } |
| 1612 processQueue(enqueuer.codegen, mainFunction); | 1613 processQueue(enqueuer.codegen, mainFunction); |
| 1613 enqueuer.codegen.logSummary(log); | 1614 enqueuer.codegen.logSummary(log); |
| 1614 | 1615 |
| 1615 if (compilationFailed) return; | 1616 if (compilationFailed) return; |
| 1616 | 1617 |
| 1617 int programSize = backend.assembleProgram(); | 1618 backend.assembleProgram(); |
| 1618 | 1619 |
| 1619 if (dumpInfo) { | 1620 if (dumpInfo) { |
| 1620 dumpInfoTask.reportSize(programSize); | |
| 1621 dumpInfoTask.dumpInfo(); | 1621 dumpInfoTask.dumpInfo(); |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 checkQueues(); | 1624 checkQueues(); |
| 1625 |
| 1626 if (compilationFailed) { |
| 1627 assembledCode = null; // Signals failure. |
| 1628 } |
| 1625 } | 1629 } |
| 1626 | 1630 |
| 1627 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { | 1631 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { |
| 1628 void enqueueAll(Element element) { | 1632 void enqueueAll(Element element) { |
| 1629 fullyEnqueueTopLevelElement(element, world); | 1633 fullyEnqueueTopLevelElement(element, world); |
| 1630 } | 1634 } |
| 1631 library.implementation.forEachLocalMember(enqueueAll); | 1635 library.implementation.forEachLocalMember(enqueueAll); |
| 1632 } | 1636 } |
| 1633 | 1637 |
| 1634 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { | 1638 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2404 InterfaceType get nullType => nullClass.computeType(compiler); | 2408 InterfaceType get nullType => nullClass.computeType(compiler); |
| 2405 | 2409 |
| 2406 @override | 2410 @override |
| 2407 InterfaceType get numType => numClass.computeType(compiler); | 2411 InterfaceType get numType => numClass.computeType(compiler); |
| 2408 | 2412 |
| 2409 @override | 2413 @override |
| 2410 InterfaceType get stringType => stringClass.computeType(compiler); | 2414 InterfaceType get stringType => stringClass.computeType(compiler); |
| 2411 } | 2415 } |
| 2412 | 2416 |
| 2413 typedef void InternalErrorFunction(Spannable location, String message); | 2417 typedef void InternalErrorFunction(Spannable location, String message); |
| OLD | NEW |