| 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.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Generates the code for all used classes in the program. Static fields (even | 8 * Generates the code for all used classes in the program. Static fields (even |
| 9 * in classes) are ignored, since they can be treated as non-class elements. | 9 * in classes) are ignored, since they can be treated as non-class elements. |
| 10 * | 10 * |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 return (isConstructor) ? 'new $suffix' : suffix; | 735 return (isConstructor) ? 'new $suffix' : suffix; |
| 736 } | 736 } |
| 737 Element element = elementOrSelector; | 737 Element element = elementOrSelector; |
| 738 if (element.isGenerativeConstructorBody()) { | 738 if (element.isGenerativeConstructorBody()) { |
| 739 return null; | 739 return null; |
| 740 } else if (element.isClass()) { | 740 } else if (element.isClass()) { |
| 741 ClassElement cls = element; | 741 ClassElement cls = element; |
| 742 if (cls.isUnnamedMixinApplication) return null; | 742 if (cls.isUnnamedMixinApplication) return null; |
| 743 return cls.name; | 743 return cls.name; |
| 744 } | 744 } |
| 745 throw compiler.internalErrorOnElement( | 745 throw compiler.internalError(element, |
| 746 element, 'Do not know how to reflect on this $element'); | 746 'Do not know how to reflect on this $element.'); |
| 747 } | 747 } |
| 748 | 748 |
| 749 String namedParametersAsReflectionNames(Selector selector) { | 749 String namedParametersAsReflectionNames(Selector selector) { |
| 750 if (selector.getOrderedNamedArguments().isEmpty) return ''; | 750 if (selector.getOrderedNamedArguments().isEmpty) return ''; |
| 751 String names = selector.getOrderedNamedArguments().join(':'); | 751 String names = selector.getOrderedNamedArguments().join(':'); |
| 752 return ':$names'; | 752 return ':$names'; |
| 753 } | 753 } |
| 754 | 754 |
| 755 jsAst.FunctionDeclaration buildPrecompiledFunction() { | 755 jsAst.FunctionDeclaration buildPrecompiledFunction() { |
| 756 // TODO(ahe): Compute a hash code. | 756 // TODO(ahe): Compute a hash code. |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 pendingStatics.forEach((element) => | 1414 pendingStatics.forEach((element) => |
| 1415 compiler.reportInfo( | 1415 compiler.reportInfo( |
| 1416 element, MessageKind.GENERIC, {'text': 'Pending statics.'})); | 1416 element, MessageKind.GENERIC, {'text': 'Pending statics.'})); |
| 1417 | 1417 |
| 1418 for (LibraryElement library in sortedElements.where((element) => | 1418 for (LibraryElement library in sortedElements.where((element) => |
| 1419 element.isLibrary())) { | 1419 element.isLibrary())) { |
| 1420 writeLibraryDescriptors(library); | 1420 writeLibraryDescriptors(library); |
| 1421 elementDescriptors[library] = const {}; | 1421 elementDescriptors[library] = const {}; |
| 1422 } | 1422 } |
| 1423 if (!pendingStatics.isEmpty) { | 1423 if (!pendingStatics.isEmpty) { |
| 1424 compiler.internalError('Pending statics (see above).'); | 1424 compiler.internalError(pendingStatics.first, |
| 1425 'Pending statics (see above).'); |
| 1425 } | 1426 } |
| 1426 mainBuffer.write('])$N'); | 1427 mainBuffer.write('])$N'); |
| 1427 | 1428 |
| 1428 emitFinishClassesInvocationIfNecessary(mainBuffer); | 1429 emitFinishClassesInvocationIfNecessary(mainBuffer); |
| 1429 classesCollector = oldClassesCollector; | 1430 classesCollector = oldClassesCollector; |
| 1430 } | 1431 } |
| 1431 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 1432 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 1432 typeTestEmitter.emitRuntimeTypeSupport(mainBuffer, mainOutputUnit); | 1433 typeTestEmitter.emitRuntimeTypeSupport(mainBuffer, mainOutputUnit); |
| 1433 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); | 1434 interceptorEmitter.emitGetInterceptorMethods(mainBuffer); |
| 1434 interceptorEmitter.emitOneShotInterceptors(mainBuffer); | 1435 interceptorEmitter.emitOneShotInterceptors(mainBuffer); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 // specific to the class. For now, not supported for native classes and | 1594 // specific to the class. For now, not supported for native classes and |
| 1594 // native elements. | 1595 // native elements. |
| 1595 ClassElement cls = | 1596 ClassElement cls = |
| 1596 element.getEnclosingClassOrCompilationUnit().declaration; | 1597 element.getEnclosingClassOrCompilationUnit().declaration; |
| 1597 if (compiler.codegenWorld.instantiatedClasses.contains(cls) | 1598 if (compiler.codegenWorld.instantiatedClasses.contains(cls) |
| 1598 && !cls.isNative()) { | 1599 && !cls.isNative()) { |
| 1599 owner = cls; | 1600 owner = cls; |
| 1600 } | 1601 } |
| 1601 } | 1602 } |
| 1602 if (owner == null) { | 1603 if (owner == null) { |
| 1603 compiler.internalErrorOnElement(element, 'Owner is null'); | 1604 compiler.internalError(element, 'Owner is null.'); |
| 1604 } | 1605 } |
| 1605 return getElementDescriptorForOutputUnit(owner, | 1606 return getElementDescriptorForOutputUnit(owner, |
| 1606 compiler.deferredLoadTask.outputUnitForElement(element)); | 1607 compiler.deferredLoadTask.outputUnitForElement(element)); |
| 1607 } | 1608 } |
| 1608 | 1609 |
| 1609 void emitDeferredCode() { | 1610 void emitDeferredCode() { |
| 1610 for (OutputUnit outputUnit in compiler.deferredLoadTask.allOutputUnits) { | 1611 for (OutputUnit outputUnit in compiler.deferredLoadTask.allOutputUnits) { |
| 1611 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) continue; | 1612 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) continue; |
| 1612 CodeBuffer outputBuffer = outputBuffers.putIfAbsent(outputUnit, | 1613 CodeBuffer outputBuffer = outputBuffers.putIfAbsent(outputUnit, |
| 1613 () => new CodeBuffer()); | 1614 () => new CodeBuffer()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 String sourceMap = sourceMapBuilder.build(compiledFile); | 1677 String sourceMap = sourceMapBuilder.build(compiledFile); |
| 1677 compiler.outputProvider(name, 'js.map') | 1678 compiler.outputProvider(name, 'js.map') |
| 1678 ..add(sourceMap) | 1679 ..add(sourceMap) |
| 1679 ..close(); | 1680 ..close(); |
| 1680 } | 1681 } |
| 1681 | 1682 |
| 1682 void registerReadTypeVariable(TypeVariableElement element) { | 1683 void registerReadTypeVariable(TypeVariableElement element) { |
| 1683 readTypeVariables.add(element); | 1684 readTypeVariables.add(element); |
| 1684 } | 1685 } |
| 1685 } | 1686 } |
| OLD | NEW |