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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 CodeBuffer buffer = bufferForConstant(constant, eagerBuffer); | 902 CodeBuffer buffer = bufferForConstant(constant, eagerBuffer); |
903 jsAst.Expression init = js( | 903 jsAst.Expression init = js( |
904 '${namer.globalObjectForConstant(constant)}.$name = #', | 904 '${namer.globalObjectForConstant(constant)}.$name = #', |
905 constantInitializerExpression(constant)); | 905 constantInitializerExpression(constant)); |
906 buffer.write(jsAst.prettyPrint(init, compiler)); | 906 buffer.write(jsAst.prettyPrint(init, compiler)); |
907 buffer.write('$N'); | 907 buffer.write('$N'); |
908 } | 908 } |
909 } | 909 } |
910 | 910 |
911 bool isConstantInlinedOrAlreadyEmitted(Constant constant) { | 911 bool isConstantInlinedOrAlreadyEmitted(Constant constant) { |
912 if (constant.isFunction()) return true; // Already emitted. | 912 if (constant.isFunction()) return true; // Already emitted. |
913 if (constant.isPrimitive()) return true; // Inlined. | 913 if (constant.isPrimitive()) return true; // Inlined. |
914 if (constant.isDummyReceiver()) return true; // Inlined. | |
915 // The name is null when the constant is already a JS constant. | 914 // The name is null when the constant is already a JS constant. |
916 // TODO(floitsch): every constant should be registered, so that we can | 915 // TODO(floitsch): every constant should be registered, so that we can |
917 // share the ones that take up too much space (like some strings). | 916 // share the ones that take up too much space (like some strings). |
918 if (namer.constantName(constant) == null) return true; | 917 if (namer.constantName(constant) == null) return true; |
919 return false; | 918 return false; |
920 } | 919 } |
921 | 920 |
922 int compareConstants(Constant a, Constant b) { | 921 int compareConstants(Constant a, Constant b) { |
923 // Inlined constants don't affect the order and sometimes don't even have | 922 // Inlined constants don't affect the order and sometimes don't even have |
924 // names. | 923 // names. |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 } | 1597 } |
1599 | 1598 |
1600 bool get areAnyElementsDeferred { | 1599 bool get areAnyElementsDeferred { |
1601 return compiler.deferredLoadTask.areAnyElementsDeferred; | 1600 return compiler.deferredLoadTask.areAnyElementsDeferred; |
1602 } | 1601 } |
1603 | 1602 |
1604 void registerReadTypeVariable(TypeVariableElement element) { | 1603 void registerReadTypeVariable(TypeVariableElement element) { |
1605 readTypeVariables.add(element); | 1604 readTypeVariables.add(element); |
1606 } | 1605 } |
1607 } | 1606 } |
OLD | NEW |