| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library dart2js.new_js_emitter.model_emitter; | 5 library dart2js.new_js_emitter.model_emitter; |
| 6 | 6 |
| 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; | 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; |
| 8 import '../../dart2jslib.dart' show Compiler; | 8 import '../../dart2jslib.dart' show Compiler; |
| 9 import '../../elements/elements.dart' show ClassElement, FunctionElement; | 9 import '../../elements/elements.dart' show ClassElement, FunctionElement; |
| 10 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (constant.isFunction) return true; // Already emitted. | 76 if (constant.isFunction) return true; // Already emitted. |
| 77 if (constant.isPrimitive) return true; // Inlined. | 77 if (constant.isPrimitive) return true; // Inlined. |
| 78 if (constant.isDummy) return true; // Inlined. | 78 if (constant.isDummy) return true; // Inlined. |
| 79 // The name is null when the constant is already a JS constant. | 79 // The name is null when the constant is already a JS constant. |
| 80 // TODO(floitsch): every constant should be registered, so that we can | 80 // TODO(floitsch): every constant should be registered, so that we can |
| 81 // share the ones that take up too much space (like some strings). | 81 // share the ones that take up too much space (like some strings). |
| 82 if (namer.constantName(constant) == null) return true; | 82 if (namer.constantName(constant) == null) return true; |
| 83 return false; | 83 return false; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // TODO(floitsch): copied from OldEmitter. Adjust or share. | 86 // TODO(floitsch): copied from full emitter. Adjust or share. |
| 87 int compareConstants(ConstantValue a, ConstantValue b) { | 87 int compareConstants(ConstantValue a, ConstantValue b) { |
| 88 // Inlined constants don't affect the order and sometimes don't even have | 88 // Inlined constants don't affect the order and sometimes don't even have |
| 89 // names. | 89 // names. |
| 90 int cmp1 = isConstantInlinedOrAlreadyEmitted(a) ? 0 : 1; | 90 int cmp1 = isConstantInlinedOrAlreadyEmitted(a) ? 0 : 1; |
| 91 int cmp2 = isConstantInlinedOrAlreadyEmitted(b) ? 0 : 1; | 91 int cmp2 = isConstantInlinedOrAlreadyEmitted(b) ? 0 : 1; |
| 92 if (cmp1 + cmp2 < 2) return cmp1 - cmp2; | 92 if (cmp1 + cmp2 < 2) return cmp1 - cmp2; |
| 93 | 93 |
| 94 // Emit constant interceptors first. Constant interceptors for primitives | 94 // Emit constant interceptors first. Constant interceptors for primitives |
| 95 // might be used by code that builds other constants. See Issue 18173. | 95 // might be used by code that builds other constants. See Issue 18173. |
| 96 if (a.isInterceptor != b.isInterceptor) { | 96 if (a.isInterceptor != b.isInterceptor) { |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 | 1238 |
| 1239 var end = Date.now(); | 1239 var end = Date.now(); |
| 1240 // print('Setup: ' + (end - start) + ' ms.'); | 1240 // print('Setup: ' + (end - start) + ' ms.'); |
| 1241 | 1241 |
| 1242 #invokeMain; // Start main. | 1242 #invokeMain; // Start main. |
| 1243 | 1243 |
| 1244 })(Date.now(), #code) | 1244 })(Date.now(), #code) |
| 1245 }"""; | 1245 }"""; |
| 1246 | 1246 |
| 1247 } | 1247 } |
| OLD | NEW |