| 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 class Constant implements Hashable { | 5 class Constant implements Hashable { |
| 6 const Constant(); | 6 const Constant(); |
| 7 | 7 |
| 8 bool isNull() => false; | 8 bool isNull() => false; |
| 9 bool isBool() => false; | 9 bool isBool() => false; |
| 10 bool isTrue() => false; | 10 bool isTrue() => false; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool operator ==(var other) { | 242 bool operator ==(var other) { |
| 243 if (other is !StringConstant) return false; | 243 if (other is !StringConstant) return false; |
| 244 StringConstant otherString = other; | 244 StringConstant otherString = other; |
| 245 return (_hashCode == otherString._hashCode) && (value == otherString.value); | 245 return (_hashCode == otherString._hashCode) && (value == otherString.value); |
| 246 } | 246 } |
| 247 | 247 |
| 248 int hashCode() => _hashCode; | 248 int hashCode() => _hashCode; |
| 249 DartString toDartString() => value; | 249 DartString toDartString() => value; |
| 250 int get length() => value.length; |
| 250 } | 251 } |
| 251 | 252 |
| 252 class ObjectConstant extends Constant { | 253 class ObjectConstant extends Constant { |
| 253 final Type type; | 254 final Type type; |
| 254 | 255 |
| 255 ObjectConstant(this.type); | 256 ObjectConstant(this.type); |
| 256 bool isObject() => true; | 257 bool isObject() => true; |
| 257 | 258 |
| 258 // TODO(1603): The class should be marked as abstract, but the VM doesn't | 259 // TODO(1603): The class should be marked as abstract, but the VM doesn't |
| 259 // currently allow this. | 260 // currently allow this. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 if (entries.length != otherList.entries.length) return false; | 301 if (entries.length != otherList.entries.length) return false; |
| 301 for (int i = 0; i < entries.length; i++) { | 302 for (int i = 0; i < entries.length; i++) { |
| 302 if (entries[i] != otherList.entries[i]) return false; | 303 if (entries[i] != otherList.entries[i]) return false; |
| 303 } | 304 } |
| 304 return true; | 305 return true; |
| 305 } | 306 } |
| 306 | 307 |
| 307 int hashCode() => _hashCode; | 308 int hashCode() => _hashCode; |
| 308 | 309 |
| 309 List<Constant> getDependencies() => entries; | 310 List<Constant> getDependencies() => entries; |
| 311 |
| 312 int get length() => entries.length; |
| 310 } | 313 } |
| 311 | 314 |
| 312 class MapConstant extends ObjectConstant { | 315 class MapConstant extends ObjectConstant { |
| 313 /** | 316 /** |
| 314 * The [PROTO_PROPERTY] must not be used as normal property in any JavaScript | 317 * The [PROTO_PROPERTY] must not be used as normal property in any JavaScript |
| 315 * object. It would change the prototype chain. | 318 * object. It would change the prototype chain. |
| 316 */ | 319 */ |
| 317 static final String PROTO_PROPERTY = "__proto__"; | 320 static final String PROTO_PROPERTY = "__proto__"; |
| 318 | 321 |
| 319 /** The dart class implementing constant map literals. */ | 322 /** The dart class implementing constant map literals. */ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 return true; | 414 return true; |
| 412 } | 415 } |
| 413 | 416 |
| 414 int hashCode() => _hashCode; | 417 int hashCode() => _hashCode; |
| 415 | 418 |
| 416 List<Constant> getDependencies() { | 419 List<Constant> getDependencies() { |
| 417 List<Constant> result = <Constant>[keys]; | 420 List<Constant> result = <Constant>[keys]; |
| 418 result.addAll(values); | 421 result.addAll(values); |
| 419 return result; | 422 return result; |
| 420 } | 423 } |
| 424 |
| 425 int get length() => keys.length; |
| 421 } | 426 } |
| 422 | 427 |
| 423 class ConstructedConstant extends ObjectConstant { | 428 class ConstructedConstant extends ObjectConstant { |
| 424 final List<Constant> fields; | 429 final List<Constant> fields; |
| 425 int _hashCode; | 430 int _hashCode; |
| 426 | 431 |
| 427 ConstructedConstant(Type type, this.fields) : super(type) { | 432 ConstructedConstant(Type type, this.fields) : super(type) { |
| 428 assert(type !== null); | 433 assert(type !== null); |
| 429 // TODO(floitsch): create a better hash. | 434 // TODO(floitsch): create a better hash. |
| 430 int hash = 0; | 435 int hash = 0; |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 Constant fieldValue = fieldValues[field]; | 1142 Constant fieldValue = fieldValues[field]; |
| 1138 if (fieldValue === null) { | 1143 if (fieldValue === null) { |
| 1139 // Use the default value. | 1144 // Use the default value. |
| 1140 fieldValue = compiler.compileVariable(field); | 1145 fieldValue = compiler.compileVariable(field); |
| 1141 } | 1146 } |
| 1142 jsNewArguments.add(fieldValue); | 1147 jsNewArguments.add(fieldValue); |
| 1143 }); | 1148 }); |
| 1144 return jsNewArguments; | 1149 return jsNewArguments; |
| 1145 } | 1150 } |
| 1146 } | 1151 } |
| OLD | NEW |