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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 if (constant.isList()) emitMakeConstantListIfNotEmitted(buffer); | 919 if (constant.isList()) emitMakeConstantListIfNotEmitted(buffer); |
920 jsAst.Expression init = js( | 920 jsAst.Expression init = js( |
921 '${namer.globalObjectForConstant(constant)}.$name = #', | 921 '${namer.globalObjectForConstant(constant)}.$name = #', |
922 constantInitializerExpression(constant)); | 922 constantInitializerExpression(constant)); |
923 buffer.write(jsAst.prettyPrint(init, compiler)); | 923 buffer.write(jsAst.prettyPrint(init, compiler)); |
924 buffer.write('$N'); | 924 buffer.write('$N'); |
925 } | 925 } |
926 } | 926 } |
927 | 927 |
928 bool isConstantInlinedOrAlreadyEmitted(Constant constant) { | 928 bool isConstantInlinedOrAlreadyEmitted(Constant constant) { |
929 if (constant.isFunction()) return true; // Already emitted. | 929 if (constant.isFunction()) return true; // Already emitted. |
930 if (constant.isPrimitive()) return true; // Inlined. | 930 if (constant.isPrimitive()) return true; // Inlined. |
931 if (constant.isDummyReceiver()) return true; // Inlined. | 931 if (constant.isDummy()) return true; // Inlined. |
932 // The name is null when the constant is already a JS constant. | 932 // The name is null when the constant is already a JS constant. |
933 // TODO(floitsch): every constant should be registered, so that we can | 933 // TODO(floitsch): every constant should be registered, so that we can |
934 // share the ones that take up too much space (like some strings). | 934 // share the ones that take up too much space (like some strings). |
935 if (namer.constantName(constant) == null) return true; | 935 if (namer.constantName(constant) == null) return true; |
936 return false; | 936 return false; |
937 } | 937 } |
938 | 938 |
939 int compareConstants(Constant a, Constant b) { | 939 int compareConstants(Constant a, Constant b) { |
940 // Inlined constants don't affect the order and sometimes don't even have | 940 // Inlined constants don't affect the order and sometimes don't even have |
941 // names. | 941 // names. |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 String sourceMap = buildSourceMap(mainBuffer, compiledFile); | 1644 String sourceMap = buildSourceMap(mainBuffer, compiledFile); |
1645 compiler.outputProvider(name, 'js.map') | 1645 compiler.outputProvider(name, 'js.map') |
1646 ..add(sourceMap) | 1646 ..add(sourceMap) |
1647 ..close(); | 1647 ..close(); |
1648 } | 1648 } |
1649 | 1649 |
1650 void registerReadTypeVariable(TypeVariableElement element) { | 1650 void registerReadTypeVariable(TypeVariableElement element) { |
1651 readTypeVariables.add(element); | 1651 readTypeVariables.add(element); |
1652 } | 1652 } |
1653 } | 1653 } |
OLD | NEW |