| 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 library dart2js.constant_system.js; | 5 library dart2js.constant_system.js; |
| 6 | 6 |
| 7 import '../constant_system_dart.dart'; | 7 import '../constant_system_dart.dart'; |
| 8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../common_elements.dart' show CommonElements; | 10 import '../common_elements.dart' show CommonElements; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 352 } |
| 353 | 353 |
| 354 MapConstantValue createMap( | 354 MapConstantValue createMap( |
| 355 CommonElements commonElements, | 355 CommonElements commonElements, |
| 356 InterfaceType sourceType, | 356 InterfaceType sourceType, |
| 357 List<ConstantValue> keys, | 357 List<ConstantValue> keys, |
| 358 List<ConstantValue> values) { | 358 List<ConstantValue> values) { |
| 359 bool onlyStringKeys = true; | 359 bool onlyStringKeys = true; |
| 360 ConstantValue protoValue = null; | 360 ConstantValue protoValue = null; |
| 361 for (int i = 0; i < keys.length; i++) { | 361 for (int i = 0; i < keys.length; i++) { |
| 362 var key = keys[i]; | 362 dynamic key = keys[i]; |
| 363 if (key.isString) { | 363 if (key.isString) { |
| 364 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) { | 364 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) { |
| 365 protoValue = values[i]; | 365 protoValue = values[i]; |
| 366 } | 366 } |
| 367 } else { | 367 } else { |
| 368 onlyStringKeys = false; | 368 onlyStringKeys = false; |
| 369 // Don't handle __proto__ values specially in the general map case. | 369 // Don't handle __proto__ values specially in the general map case. |
| 370 protoValue = null; | 370 protoValue = null; |
| 371 break; | 371 break; |
| 372 } | 372 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 386 type, keysList, values, protoValue, onlyStringKeys); | 386 type, keysList, values, protoValue, onlyStringKeys); |
| 387 } | 387 } |
| 388 | 388 |
| 389 @override | 389 @override |
| 390 ConstantValue createSymbol(CommonElements commonElements, String text) { | 390 ConstantValue createSymbol(CommonElements commonElements, String text) { |
| 391 InterfaceType type = commonElements.symbolImplementationType; | 391 InterfaceType type = commonElements.symbolImplementationType; |
| 392 FieldEntity field = commonElements.symbolField; | 392 FieldEntity field = commonElements.symbolField; |
| 393 ConstantValue argument = createString(text); | 393 ConstantValue argument = createString(text); |
| 394 // TODO(johnniwinther): Use type arguments when all uses no longer expect | 394 // TODO(johnniwinther): Use type arguments when all uses no longer expect |
| 395 // a [FieldElement]. | 395 // a [FieldElement]. |
| 396 Map<FieldEntity, ConstantValue> fields = /*<FieldElement, ConstantValue>*/ { | 396 Map<FieldEntity, ConstantValue> fields = <dynamic, ConstantValue>{ |
| 397 field: argument | 397 field: argument |
| 398 }; | 398 }; |
| 399 return new ConstructedConstantValue(type, fields); | 399 return new ConstructedConstantValue(type, fields); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 class JavaScriptMapConstant extends MapConstantValue { | 403 class JavaScriptMapConstant extends MapConstantValue { |
| 404 /** | 404 /** |
| 405 * The [PROTO_PROPERTY] must not be used as normal property in any JavaScript | 405 * The [PROTO_PROPERTY] must not be used as normal property in any JavaScript |
| 406 * object. It would change the prototype chain. | 406 * object. It would change the prototype chain. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 434 result.add(keyList); | 434 result.add(keyList); |
| 435 } else { | 435 } else { |
| 436 // Add the keys individually to avoid generating an unused list constant | 436 // Add the keys individually to avoid generating an unused list constant |
| 437 // for the keys. | 437 // for the keys. |
| 438 result.addAll(keys); | 438 result.addAll(keys); |
| 439 } | 439 } |
| 440 result.addAll(values); | 440 result.addAll(values); |
| 441 return result; | 441 return result; |
| 442 } | 442 } |
| 443 } | 443 } |
| OLD | NEW |