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.constants.expressions; | 5 library dart2js.constants.expressions; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 keys[index]._createStructuredText(sb); | 475 keys[index]._createStructuredText(sb); |
476 sb.write('->'); | 476 sb.write('->'); |
477 values[index]._createStructuredText(sb); | 477 values[index]._createStructuredText(sb); |
478 } | 478 } |
479 sb.write('])'); | 479 sb.write('])'); |
480 } | 480 } |
481 | 481 |
482 @override | 482 @override |
483 ConstantValue evaluate( | 483 ConstantValue evaluate( |
484 Environment environment, ConstantSystem constantSystem) { | 484 Environment environment, ConstantSystem constantSystem) { |
| 485 Map<ConstantValue, ConstantValue> valueMap = |
| 486 <ConstantValue, ConstantValue>{}; |
| 487 for (int index = 0; index < keys.length; index++) { |
| 488 ConstantValue key = |
| 489 keys[index].evaluate(environment, constantSystem); |
| 490 ConstantValue value = |
| 491 values[index].evaluate(environment, constantSystem); |
| 492 valueMap[key] = value; |
| 493 } |
485 return constantSystem.createMap( | 494 return constantSystem.createMap( |
486 environment.compiler, | 495 environment.compiler, |
487 type, | 496 type, |
488 keys.map((k) => k.evaluate(environment, constantSystem)).toList(), | 497 valueMap.keys.toList(), |
489 values.map((v) => v.evaluate(environment, constantSystem)).toList()); | 498 valueMap.values.toList()); |
490 } | 499 } |
491 | 500 |
492 ConstantExpression apply(NormalizedArguments arguments) { | 501 ConstantExpression apply(NormalizedArguments arguments) { |
493 return new MapConstantExpression( | 502 return new MapConstantExpression( |
494 type, | 503 type, |
495 keys.map((k) => k.apply(arguments)).toList(), | 504 keys.map((k) => k.apply(arguments)).toList(), |
496 values.map((v) => v.apply(arguments)).toList()); | 505 values.map((v) => v.apply(arguments)).toList()); |
497 } | 506 } |
498 | 507 |
499 @override | 508 @override |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 visit(exp.name); | 1891 visit(exp.name); |
1883 if (exp.defaultValue != null) { | 1892 if (exp.defaultValue != null) { |
1884 sb.write(', defaultValue: '); | 1893 sb.write(', defaultValue: '); |
1885 visit(exp.defaultValue); | 1894 visit(exp.defaultValue); |
1886 } | 1895 } |
1887 sb.write(')'); | 1896 sb.write(')'); |
1888 } | 1897 } |
1889 | 1898 |
1890 String toString() => sb.toString(); | 1899 String toString() => sb.toString(); |
1891 } | 1900 } |
OLD | NEW |