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