Chromium Code Reviews| 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; | 5 part of dart2js; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The [ConstantHandler] keeps track of compile-time constants, | 8 * The [ConstantHandler] keeps track of compile-time constants, |
| 9 * initializations of global and static fields, and default values of | 9 * initializations of global and static fields, and default values of |
| 10 * optional parameters. | 10 * optional parameters. |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 bool hasProtoKey = (protoValue != null); | 328 bool hasProtoKey = (protoValue != null); |
| 329 List<Constant> values = map.values.toList(); | 329 List<Constant> values = map.values.toList(); |
| 330 InterfaceType sourceType = elements.getType(node); | 330 InterfaceType sourceType = elements.getType(node); |
| 331 DartType keysType; | 331 DartType keysType; |
| 332 if (sourceType.treatAsRaw) { | 332 if (sourceType.treatAsRaw) { |
| 333 keysType = compiler.listClass.rawType; | 333 keysType = compiler.listClass.rawType; |
| 334 } else { | 334 } else { |
| 335 Link<DartType> arguments = | 335 List<DartType> arguments = <DartType>[sourceType.typeArguments[0]]; |
|
Johnni Winther
2014/02/26 14:01:54
Why not use 'typeArguments.first' here?
karlklose
2014/02/27 09:31:41
Done.
| |
| 336 new Link<DartType>.fromList([sourceType.typeArguments.head]); | |
| 337 keysType = new InterfaceType(compiler.listClass, arguments); | 336 keysType = new InterfaceType(compiler.listClass, arguments); |
| 338 } | 337 } |
| 339 ListConstant keysList = new ListConstant(keysType, keys); | 338 ListConstant keysList = new ListConstant(keysType, keys); |
| 340 String className = onlyStringKeys | 339 String className = onlyStringKeys |
| 341 ? (hasProtoKey ? MapConstant.DART_PROTO_CLASS | 340 ? (hasProtoKey ? MapConstant.DART_PROTO_CLASS |
| 342 : MapConstant.DART_STRING_CLASS) | 341 : MapConstant.DART_STRING_CLASS) |
| 343 : MapConstant.DART_GENERAL_CLASS; | 342 : MapConstant.DART_GENERAL_CLASS; |
| 344 ClassElement classElement = compiler.jsHelperLibrary.find(className); | 343 ClassElement classElement = compiler.jsHelperLibrary.find(className); |
| 345 classElement.ensureResolved(compiler); | 344 classElement.ensureResolved(compiler); |
| 346 Link<DartType> typeArgument = sourceType.typeArguments; | 345 List<DartType> typeArgument = sourceType.typeArguments; |
| 347 InterfaceType type; | 346 InterfaceType type; |
| 348 if (sourceType.treatAsRaw) { | 347 if (sourceType.treatAsRaw) { |
| 349 type = classElement.rawType; | 348 type = classElement.rawType; |
| 350 } else { | 349 } else { |
| 351 type = new InterfaceType(classElement, typeArgument); | 350 type = new InterfaceType(classElement, typeArgument); |
| 352 } | 351 } |
| 353 return new MapConstant(type, keysList, values, protoValue, onlyStringKeys); | 352 return new MapConstant(type, keysList, values, protoValue, onlyStringKeys); |
| 354 } | 353 } |
| 355 | 354 |
| 356 Constant visitLiteralNull(LiteralNull node) { | 355 Constant visitLiteralNull(LiteralNull node) { |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 960 if (fieldValue == null) { | 959 if (fieldValue == null) { |
| 961 // Use the default value. | 960 // Use the default value. |
| 962 fieldValue = handler.compileConstant(field); | 961 fieldValue = handler.compileConstant(field); |
| 963 } | 962 } |
| 964 jsNewArguments.add(fieldValue); | 963 jsNewArguments.add(fieldValue); |
| 965 }, | 964 }, |
| 966 includeSuperAndInjectedMembers: true); | 965 includeSuperAndInjectedMembers: true); |
| 967 return jsNewArguments; | 966 return jsNewArguments; |
| 968 } | 967 } |
| 969 } | 968 } |
| OLD | NEW |