| 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 '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
| 8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../constant_system_dart.dart'; | 10 import '../constant_system_dart.dart'; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 @override | 257 @override |
| 258 ListConstantValue createList(InterfaceType type, | 258 ListConstantValue createList(InterfaceType type, |
| 259 List<ConstantValue> values) { | 259 List<ConstantValue> values) { |
| 260 return new ListConstantValue(type, values); | 260 return new ListConstantValue(type, values); |
| 261 } | 261 } |
| 262 | 262 |
| 263 @override | 263 @override |
| 264 ConstantValue createType(Compiler compiler, DartType type) { | 264 ConstantValue createType(Compiler compiler, DartType type) { |
| 265 return new TypeConstantValue( | 265 return new TypeConstantValue( |
| 266 type, compiler.backend.typeImplementation.computeType(compiler)); | 266 type, |
| 267 compiler.backend.typeImplementation.computeType(compiler.resolution)); |
| 267 } | 268 } |
| 268 | 269 |
| 269 // Integer checks don't verify that the number is not -0.0. | 270 // Integer checks don't verify that the number is not -0.0. |
| 270 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; | 271 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; |
| 271 bool isDouble(ConstantValue constant) | 272 bool isDouble(ConstantValue constant) |
| 272 => constant.isDouble && !constant.isMinusZero; | 273 => constant.isDouble && !constant.isMinusZero; |
| 273 bool isString(ConstantValue constant) => constant.isString; | 274 bool isString(ConstantValue constant) => constant.isString; |
| 274 bool isBool(ConstantValue constant) => constant.isBool; | 275 bool isBool(ConstantValue constant) => constant.isBool; |
| 275 bool isNull(ConstantValue constant) => constant.isNull; | 276 bool isNull(ConstantValue constant) => constant.isNull; |
| 276 | 277 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } else { | 315 } else { |
| 315 List<DartType> arguments = <DartType>[sourceType.typeArguments.first]; | 316 List<DartType> arguments = <DartType>[sourceType.typeArguments.first]; |
| 316 keysType = new InterfaceType(compiler.listClass, arguments); | 317 keysType = new InterfaceType(compiler.listClass, arguments); |
| 317 } | 318 } |
| 318 ListConstantValue keysList = new ListConstantValue(keysType, keys); | 319 ListConstantValue keysList = new ListConstantValue(keysType, keys); |
| 319 String className = onlyStringKeys | 320 String className = onlyStringKeys |
| 320 ? (hasProtoKey ? JavaScriptMapConstant.DART_PROTO_CLASS | 321 ? (hasProtoKey ? JavaScriptMapConstant.DART_PROTO_CLASS |
| 321 : JavaScriptMapConstant.DART_STRING_CLASS) | 322 : JavaScriptMapConstant.DART_STRING_CLASS) |
| 322 : JavaScriptMapConstant.DART_GENERAL_CLASS; | 323 : JavaScriptMapConstant.DART_GENERAL_CLASS; |
| 323 ClassElement classElement = backend.jsHelperLibrary.find(className); | 324 ClassElement classElement = backend.jsHelperLibrary.find(className); |
| 324 classElement.ensureResolved(compiler); | 325 classElement.ensureResolved(compiler.resolution); |
| 325 List<DartType> typeArgument = sourceType.typeArguments; | 326 List<DartType> typeArgument = sourceType.typeArguments; |
| 326 InterfaceType type; | 327 InterfaceType type; |
| 327 if (sourceType.treatAsRaw) { | 328 if (sourceType.treatAsRaw) { |
| 328 type = classElement.rawType; | 329 type = classElement.rawType; |
| 329 } else { | 330 } else { |
| 330 type = new InterfaceType(classElement, typeArgument); | 331 type = new InterfaceType(classElement, typeArgument); |
| 331 } | 332 } |
| 332 return new JavaScriptMapConstant( | 333 return new JavaScriptMapConstant( |
| 333 type, keysList, values, protoValue, onlyStringKeys); | 334 type, keysList, values, protoValue, onlyStringKeys); |
| 334 | 335 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 result.add(keyList); | 374 result.add(keyList); |
| 374 } else { | 375 } else { |
| 375 // Add the keys individually to avoid generating an unused list constant | 376 // Add the keys individually to avoid generating an unused list constant |
| 376 // for the keys. | 377 // for the keys. |
| 377 result.addAll(keys); | 378 result.addAll(keys); |
| 378 } | 379 } |
| 379 result.addAll(values); | 380 result.addAll(values); |
| 380 return result; | 381 return result; |
| 381 } | 382 } |
| 382 } | 383 } |
| OLD | NEW |