Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1200)

Side by Side Diff: pkg/compiler/lib/src/constants/values.dart

Issue 2603263002: Prefix resolution_types with Resolution. (Closed)
Patch Set: Rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/constants/expressions.dart ('k') | pkg/compiler/lib/src/core_types.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.constants.values; 5 library dart2js.constants.values;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../core_types.dart'; 8 import '../core_types.dart';
9 import '../elements/elements.dart' show Entity; 9 import '../elements/elements.dart' show Entity;
10 import '../elements/entities.dart'; 10 import '../elements/entities.dart';
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 bool get isDummy => false; 75 bool get isDummy => false;
76 76
77 bool get isNaN => false; 77 bool get isNaN => false;
78 bool get isMinusZero => false; 78 bool get isMinusZero => false;
79 bool get isZero => false; 79 bool get isZero => false;
80 bool get isOne => false; 80 bool get isOne => false;
81 bool get isPositiveInfinity => false; 81 bool get isPositiveInfinity => false;
82 bool get isNegativeInfinity => false; 82 bool get isNegativeInfinity => false;
83 83
84 // TODO(johnniwinther): Replace with a 'type' getter. 84 // TODO(johnniwinther): Replace with a 'type' getter.
85 DartType getType(CommonElements types); 85 ResolutionDartType getType(CommonElements types);
86 86
87 List<ConstantValue> getDependencies(); 87 List<ConstantValue> getDependencies();
88 88
89 accept(ConstantValueVisitor visitor, arg); 89 accept(ConstantValueVisitor visitor, arg);
90 90
91 /// The value of this constant in Dart syntax, if possible. 91 /// The value of this constant in Dart syntax, if possible.
92 /// 92 ///
93 /// For [ConstructedConstantValue]s there is no way to create a valid const 93 /// For [ConstructedConstantValue]s there is no way to create a valid const
94 /// expression from the value so the unparse of these is best effort. 94 /// expression from the value so the unparse of these is best effort.
95 /// 95 ///
(...skipping 11 matching lines...) Expand all
107 assertDebugMode("Use ConstantValue.toDartText() or " 107 assertDebugMode("Use ConstantValue.toDartText() or "
108 "ConstantValue.toStructuredText() " 108 "ConstantValue.toStructuredText() "
109 "instead of ConstantValue.toString()."); 109 "instead of ConstantValue.toString().");
110 return toStructuredText(); 110 return toStructuredText();
111 } 111 }
112 } 112 }
113 113
114 class FunctionConstantValue extends ConstantValue { 114 class FunctionConstantValue extends ConstantValue {
115 final FunctionEntity element; 115 final FunctionEntity element;
116 // TODO(johnniwinther): Should the type be derived from [element]. 116 // TODO(johnniwinther): Should the type be derived from [element].
117 final FunctionType type; 117 final ResolutionFunctionType type;
118 118
119 FunctionConstantValue(this.element, this.type); 119 FunctionConstantValue(this.element, this.type);
120 120
121 bool get isFunction => true; 121 bool get isFunction => true;
122 122
123 bool operator ==(var other) { 123 bool operator ==(var other) {
124 if (other is! FunctionConstantValue) return false; 124 if (other is! FunctionConstantValue) return false;
125 return identical(other.element, element); 125 return identical(other.element, element);
126 } 126 }
127 127
128 List<ConstantValue> getDependencies() => const <ConstantValue>[]; 128 List<ConstantValue> getDependencies() => const <ConstantValue>[];
129 129
130 DartString toDartString() { 130 DartString toDartString() {
131 return new DartString.literal(element.name); 131 return new DartString.literal(element.name);
132 } 132 }
133 133
134 DartType getType(CommonElements types) => type; 134 ResolutionDartType getType(CommonElements types) => type;
135 135
136 int get hashCode => (17 * element.hashCode) & 0x7fffffff; 136 int get hashCode => (17 * element.hashCode) & 0x7fffffff;
137 137
138 accept(ConstantValueVisitor visitor, arg) => visitor.visitFunction(this, arg); 138 accept(ConstantValueVisitor visitor, arg) => visitor.visitFunction(this, arg);
139 139
140 ConstantValueKind get kind => ConstantValueKind.FUNCTION; 140 ConstantValueKind get kind => ConstantValueKind.FUNCTION;
141 141
142 String toDartText() { 142 String toDartText() {
143 if (element.enclosingClass != null) { 143 if (element.enclosingClass != null) {
144 return '${element.enclosingClass.name}.${element.name}'; 144 return '${element.enclosingClass.name}.${element.name}';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 static const String JsNull = "null"; 182 static const String JsNull = "null";
183 183
184 const factory NullConstantValue() = NullConstantValue._internal; 184 const factory NullConstantValue() = NullConstantValue._internal;
185 185
186 const NullConstantValue._internal(); 186 const NullConstantValue._internal();
187 187
188 bool get isNull => true; 188 bool get isNull => true;
189 189
190 get primitiveValue => null; 190 get primitiveValue => null;
191 191
192 DartType getType(CommonElements types) => types.nullType; 192 ResolutionDartType getType(CommonElements types) => types.nullType;
193 193
194 // The magic constant has no meaning. It is just a random value. 194 // The magic constant has no meaning. It is just a random value.
195 int get hashCode => 785965825; 195 int get hashCode => 785965825;
196 196
197 DartString toDartString() => const LiteralDartString("null"); 197 DartString toDartString() => const LiteralDartString("null");
198 198
199 accept(ConstantValueVisitor visitor, arg) => visitor.visitNull(this, arg); 199 accept(ConstantValueVisitor visitor, arg) => visitor.visitNull(this, arg);
200 200
201 ConstantValueKind get kind => ConstantValueKind.NULL; 201 ConstantValueKind get kind => ConstantValueKind.NULL;
202 202
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 bool isUInt31() => primitiveValue >= 0 && primitiveValue < (1 << 31); 254 bool isUInt31() => primitiveValue >= 0 && primitiveValue < (1 << 31);
255 255
256 bool isUInt32() => primitiveValue >= 0 && primitiveValue < (1 << 32); 256 bool isUInt32() => primitiveValue >= 0 && primitiveValue < (1 << 32);
257 257
258 bool isPositive() => primitiveValue >= 0; 258 bool isPositive() => primitiveValue >= 0;
259 259
260 bool get isZero => primitiveValue == 0; 260 bool get isZero => primitiveValue == 0;
261 261
262 bool get isOne => primitiveValue == 1; 262 bool get isOne => primitiveValue == 1;
263 263
264 DartType getType(CommonElements types) => types.intType; 264 ResolutionDartType getType(CommonElements types) => types.intType;
265 265
266 // We have to override the equality operator so that ints and doubles are 266 // We have to override the equality operator so that ints and doubles are
267 // treated as separate constants. 267 // treated as separate constants.
268 // The is [:!IntConstant:] check at the beginning of the function makes sure 268 // The is [:!IntConstant:] check at the beginning of the function makes sure
269 // that we compare only equal to integer constants. 269 // that we compare only equal to integer constants.
270 bool operator ==(var other) { 270 bool operator ==(var other) {
271 if (other is! IntConstantValue) return false; 271 if (other is! IntConstantValue) return false;
272 IntConstantValue otherInt = other; 272 IntConstantValue otherInt = other;
273 return primitiveValue == otherInt.primitiveValue; 273 return primitiveValue == otherInt.primitiveValue;
274 } 274 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 bool get isMinusZero => primitiveValue == 0.0 && primitiveValue.isNegative; 315 bool get isMinusZero => primitiveValue == 0.0 && primitiveValue.isNegative;
316 316
317 bool get isZero => primitiveValue == 0.0; 317 bool get isZero => primitiveValue == 0.0;
318 318
319 bool get isOne => primitiveValue == 1.0; 319 bool get isOne => primitiveValue == 1.0;
320 320
321 bool get isPositiveInfinity => primitiveValue == double.INFINITY; 321 bool get isPositiveInfinity => primitiveValue == double.INFINITY;
322 322
323 bool get isNegativeInfinity => primitiveValue == -double.INFINITY; 323 bool get isNegativeInfinity => primitiveValue == -double.INFINITY;
324 324
325 DartType getType(CommonElements types) => types.doubleType; 325 ResolutionDartType getType(CommonElements types) => types.doubleType;
326 326
327 bool operator ==(var other) { 327 bool operator ==(var other) {
328 if (other is! DoubleConstantValue) return false; 328 if (other is! DoubleConstantValue) return false;
329 DoubleConstantValue otherDouble = other; 329 DoubleConstantValue otherDouble = other;
330 double otherValue = otherDouble.primitiveValue; 330 double otherValue = otherDouble.primitiveValue;
331 if (primitiveValue == 0.0 && otherValue == 0.0) { 331 if (primitiveValue == 0.0 && otherValue == 0.0) {
332 return primitiveValue.isNegative == otherValue.isNegative; 332 return primitiveValue.isNegative == otherValue.isNegative;
333 } else if (primitiveValue.isNaN) { 333 } else if (primitiveValue.isNaN) {
334 return otherValue.isNaN; 334 return otherValue.isNaN;
335 } else { 335 } else {
(...skipping 16 matching lines...) Expand all
352 352
353 abstract class BoolConstantValue extends PrimitiveConstantValue { 353 abstract class BoolConstantValue extends PrimitiveConstantValue {
354 factory BoolConstantValue(value) { 354 factory BoolConstantValue(value) {
355 return value ? new TrueConstantValue() : new FalseConstantValue(); 355 return value ? new TrueConstantValue() : new FalseConstantValue();
356 } 356 }
357 357
358 const BoolConstantValue._internal(); 358 const BoolConstantValue._internal();
359 359
360 bool get isBool => true; 360 bool get isBool => true;
361 361
362 DartType getType(CommonElements types) => types.boolType; 362 ResolutionDartType getType(CommonElements types) => types.boolType;
363 363
364 BoolConstantValue negate(); 364 BoolConstantValue negate();
365 365
366 accept(ConstantValueVisitor visitor, arg) => visitor.visitBool(this, arg); 366 accept(ConstantValueVisitor visitor, arg) => visitor.visitBool(this, arg);
367 367
368 ConstantValueKind get kind => ConstantValueKind.BOOL; 368 ConstantValueKind get kind => ConstantValueKind.BOOL;
369 369
370 String toStructuredText() => 'BoolConstant(${toDartText()})'; 370 String toStructuredText() => 'BoolConstant(${toDartText()})';
371 } 371 }
372 372
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // DartString. 420 // DartString.
421 StringConstantValue(DartString value) 421 StringConstantValue(DartString value)
422 : this.primitiveValue = value, 422 : this.primitiveValue = value,
423 this.hashCode = value.slowToString().hashCode; 423 this.hashCode = value.slowToString().hashCode;
424 424
425 StringConstantValue.fromString(String value) 425 StringConstantValue.fromString(String value)
426 : this(new DartString.literal(value)); 426 : this(new DartString.literal(value));
427 427
428 bool get isString => true; 428 bool get isString => true;
429 429
430 DartType getType(CommonElements types) => types.stringType; 430 ResolutionDartType getType(CommonElements types) => types.stringType;
431 431
432 bool operator ==(var other) { 432 bool operator ==(var other) {
433 if (identical(this, other)) return true; 433 if (identical(this, other)) return true;
434 if (other is! StringConstantValue) return false; 434 if (other is! StringConstantValue) return false;
435 StringConstantValue otherString = other; 435 StringConstantValue otherString = other;
436 return hashCode == otherString.hashCode && 436 return hashCode == otherString.hashCode &&
437 primitiveValue == otherString.primitiveValue; 437 primitiveValue == otherString.primitiveValue;
438 } 438 }
439 439
440 DartString toDartString() => primitiveValue; 440 DartString toDartString() => primitiveValue;
441 441
442 int get length => primitiveValue.length; 442 int get length => primitiveValue.length;
443 443
444 accept(ConstantValueVisitor visitor, arg) => visitor.visitString(this, arg); 444 accept(ConstantValueVisitor visitor, arg) => visitor.visitString(this, arg);
445 445
446 ConstantValueKind get kind => ConstantValueKind.STRING; 446 ConstantValueKind get kind => ConstantValueKind.STRING;
447 447
448 // TODO(johnniwinther): Ensure correct escaping. 448 // TODO(johnniwinther): Ensure correct escaping.
449 String toDartText() => '"${primitiveValue.slowToString()}"'; 449 String toDartText() => '"${primitiveValue.slowToString()}"';
450 450
451 String toStructuredText() => 'StringConstant(${toDartText()})'; 451 String toStructuredText() => 'StringConstant(${toDartText()})';
452 } 452 }
453 453
454 abstract class ObjectConstantValue extends ConstantValue { 454 abstract class ObjectConstantValue extends ConstantValue {
455 final InterfaceType type; 455 final ResolutionInterfaceType type;
456 456
457 ObjectConstantValue(this.type); 457 ObjectConstantValue(this.type);
458 458
459 bool get isObject => true; 459 bool get isObject => true;
460 460
461 DartType getType(CommonElements types) => type; 461 ResolutionDartType getType(CommonElements types) => type;
462 462
463 void _unparseTypeArguments(StringBuffer sb) { 463 void _unparseTypeArguments(StringBuffer sb) {
464 if (!type.treatAsRaw) { 464 if (!type.treatAsRaw) {
465 sb.write('<'); 465 sb.write('<');
466 sb.write(type.typeArguments.join(', ')); 466 sb.write(type.typeArguments.join(', '));
467 sb.write('>'); 467 sb.write('>');
468 } 468 }
469 } 469 }
470 } 470 }
471 471
472 class TypeConstantValue extends ObjectConstantValue { 472 class TypeConstantValue extends ObjectConstantValue {
473 /// The user type that this constant represents. 473 /// The user type that this constant represents.
474 final DartType representedType; 474 final ResolutionDartType representedType;
475 475
476 TypeConstantValue(this.representedType, InterfaceType type) : super(type); 476 TypeConstantValue(this.representedType, ResolutionInterfaceType type)
477 : super(type);
477 478
478 bool get isType => true; 479 bool get isType => true;
479 480
480 bool operator ==(other) { 481 bool operator ==(other) {
481 return other is TypeConstantValue && 482 return other is TypeConstantValue &&
482 representedType == other.representedType; 483 representedType == other.representedType;
483 } 484 }
484 485
485 int get hashCode => representedType.hashCode * 13; 486 int get hashCode => representedType.hashCode * 13;
486 487
487 List<ConstantValue> getDependencies() => const <ConstantValue>[]; 488 List<ConstantValue> getDependencies() => const <ConstantValue>[];
488 489
489 accept(ConstantValueVisitor visitor, arg) => visitor.visitType(this, arg); 490 accept(ConstantValueVisitor visitor, arg) => visitor.visitType(this, arg);
490 491
491 ConstantValueKind get kind => ConstantValueKind.TYPE; 492 ConstantValueKind get kind => ConstantValueKind.TYPE;
492 493
493 String toDartText() => '$representedType'; 494 String toDartText() => '$representedType';
494 495
495 String toStructuredText() => 'TypeConstant(${representedType})'; 496 String toStructuredText() => 'TypeConstant(${representedType})';
496 } 497 }
497 498
498 class ListConstantValue extends ObjectConstantValue { 499 class ListConstantValue extends ObjectConstantValue {
499 final List<ConstantValue> entries; 500 final List<ConstantValue> entries;
500 final int hashCode; 501 final int hashCode;
501 502
502 ListConstantValue(InterfaceType type, List<ConstantValue> entries) 503 ListConstantValue(ResolutionInterfaceType type, List<ConstantValue> entries)
503 : this.entries = entries, 504 : this.entries = entries,
504 hashCode = Hashing.listHash(entries, Hashing.objectHash(type)), 505 hashCode = Hashing.listHash(entries, Hashing.objectHash(type)),
505 super(type); 506 super(type);
506 507
507 bool get isList => true; 508 bool get isList => true;
508 509
509 bool operator ==(var other) { 510 bool operator ==(var other) {
510 if (identical(this, other)) return true; 511 if (identical(this, other)) return true;
511 if (other is! ListConstantValue) return false; 512 if (other is! ListConstantValue) return false;
512 ListConstantValue otherList = other; 513 ListConstantValue otherList = other;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 return sb.toString(); 553 return sb.toString();
553 } 554 }
554 } 555 }
555 556
556 class MapConstantValue extends ObjectConstantValue { 557 class MapConstantValue extends ObjectConstantValue {
557 final List<ConstantValue> keys; 558 final List<ConstantValue> keys;
558 final List<ConstantValue> values; 559 final List<ConstantValue> values;
559 final int hashCode; 560 final int hashCode;
560 Map<ConstantValue, ConstantValue> _lookupMap; 561 Map<ConstantValue, ConstantValue> _lookupMap;
561 562
562 MapConstantValue( 563 MapConstantValue(ResolutionInterfaceType type, List<ConstantValue> keys,
563 InterfaceType type, List<ConstantValue> keys, List<ConstantValue> values) 564 List<ConstantValue> values)
564 : this.keys = keys, 565 : this.keys = keys,
565 this.values = values, 566 this.values = values,
566 this.hashCode = Hashing.listHash( 567 this.hashCode = Hashing.listHash(
567 values, Hashing.listHash(keys, Hashing.objectHash(type))), 568 values, Hashing.listHash(keys, Hashing.objectHash(type))),
568 super(type) { 569 super(type) {
569 assert(keys.length == values.length); 570 assert(keys.length == values.length);
570 } 571 }
571 572
572 bool get isMap => true; 573 bool get isMap => true;
573 574
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 sb.write(values[i].toStructuredText()); 631 sb.write(values[i].toStructuredText());
631 } 632 }
632 sb.write('})'); 633 sb.write('})');
633 return sb.toString(); 634 return sb.toString();
634 } 635 }
635 } 636 }
636 637
637 class InterceptorConstantValue extends ConstantValue { 638 class InterceptorConstantValue extends ConstantValue {
638 /// The type for which this interceptor holds the methods. The constant 639 /// The type for which this interceptor holds the methods. The constant
639 /// is a dispatch table for this type. 640 /// is a dispatch table for this type.
640 final DartType dispatchedType; 641 final ResolutionDartType dispatchedType;
641 642
642 InterceptorConstantValue(this.dispatchedType); 643 InterceptorConstantValue(this.dispatchedType);
643 644
644 bool get isInterceptor => true; 645 bool get isInterceptor => true;
645 646
646 bool operator ==(other) { 647 bool operator ==(other) {
647 return other is InterceptorConstantValue && 648 return other is InterceptorConstantValue &&
648 dispatchedType == other.dispatchedType; 649 dispatchedType == other.dispatchedType;
649 } 650 }
650 651
651 int get hashCode => dispatchedType.hashCode * 43; 652 int get hashCode => dispatchedType.hashCode * 43;
652 653
653 List<ConstantValue> getDependencies() => const <ConstantValue>[]; 654 List<ConstantValue> getDependencies() => const <ConstantValue>[];
654 655
655 accept(ConstantValueVisitor visitor, arg) { 656 accept(ConstantValueVisitor visitor, arg) {
656 return visitor.visitInterceptor(this, arg); 657 return visitor.visitInterceptor(this, arg);
657 } 658 }
658 659
659 DartType getType(CommonElements types) => const DynamicType(); 660 ResolutionDartType getType(CommonElements types) =>
661 const ResolutionDynamicType();
660 662
661 ConstantValueKind get kind => ConstantValueKind.INTERCEPTOR; 663 ConstantValueKind get kind => ConstantValueKind.INTERCEPTOR;
662 664
663 String toDartText() { 665 String toDartText() {
664 return 'interceptor($dispatchedType)'; 666 return 'interceptor($dispatchedType)';
665 } 667 }
666 668
667 String toStructuredText() { 669 String toStructuredText() {
668 return 'InterceptorConstant(${dispatchedType.getStringAsDeclared("o")})'; 670 return 'InterceptorConstant(${dispatchedType.getStringAsDeclared("o")})';
669 } 671 }
(...skipping 12 matching lines...) Expand all
682 } 684 }
683 685
684 get hashCode => payload.hashCode * 17 + valueKind.hashCode; 686 get hashCode => payload.hashCode * 17 + valueKind.hashCode;
685 687
686 List<ConstantValue> getDependencies() => const <ConstantValue>[]; 688 List<ConstantValue> getDependencies() => const <ConstantValue>[];
687 689
688 accept(ConstantValueVisitor visitor, arg) { 690 accept(ConstantValueVisitor visitor, arg) {
689 return visitor.visitSynthetic(this, arg); 691 return visitor.visitSynthetic(this, arg);
690 } 692 }
691 693
692 DartType getType(CommonElements types) => const DynamicType(); 694 ResolutionDartType getType(CommonElements types) =>
695 const ResolutionDynamicType();
693 696
694 ConstantValueKind get kind => ConstantValueKind.SYNTHETIC; 697 ConstantValueKind get kind => ConstantValueKind.SYNTHETIC;
695 698
696 String toDartText() => 'synthetic($valueKind, $payload)'; 699 String toDartText() => 'synthetic($valueKind, $payload)';
697 700
698 String toStructuredText() => 'SyntheticConstant($valueKind, $payload)'; 701 String toStructuredText() => 'SyntheticConstant($valueKind, $payload)';
699 } 702 }
700 703
701 class ConstructedConstantValue extends ObjectConstantValue { 704 class ConstructedConstantValue extends ObjectConstantValue {
702 // TODO(johnniwinther): Make [fields] private to avoid misuse of the map 705 // TODO(johnniwinther): Make [fields] private to avoid misuse of the map
703 // ordering and mutability. 706 // ordering and mutability.
704 final Map<FieldEntity, ConstantValue> fields; 707 final Map<FieldEntity, ConstantValue> fields;
705 final int hashCode; 708 final int hashCode;
706 709
707 ConstructedConstantValue( 710 ConstructedConstantValue(
708 InterfaceType type, Map<FieldEntity, ConstantValue> fields) 711 ResolutionInterfaceType type, Map<FieldEntity, ConstantValue> fields)
709 : this.fields = fields, 712 : this.fields = fields,
710 hashCode = Hashing.unorderedMapHash(fields, Hashing.objectHash(type)), 713 hashCode = Hashing.unorderedMapHash(fields, Hashing.objectHash(type)),
711 super(type) { 714 super(type) {
712 assert(type != null); 715 assert(type != null);
713 assert(!fields.containsValue(null)); 716 assert(!fields.containsValue(null));
714 } 717 }
715 718
716 bool get isConstructedObject => true; 719 bool get isConstructedObject => true;
717 720
718 bool operator ==(var otherVar) { 721 bool operator ==(var otherVar) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 referenced == other.referenced && 789 referenced == other.referenced &&
787 prefix == other.prefix; 790 prefix == other.prefix;
788 } 791 }
789 792
790 get hashCode => (referenced.hashCode * 17 + prefix.hashCode) & 0x3fffffff; 793 get hashCode => (referenced.hashCode * 17 + prefix.hashCode) & 0x3fffffff;
791 794
792 List<ConstantValue> getDependencies() => <ConstantValue>[referenced]; 795 List<ConstantValue> getDependencies() => <ConstantValue>[referenced];
793 796
794 accept(ConstantValueVisitor visitor, arg) => visitor.visitDeferred(this, arg); 797 accept(ConstantValueVisitor visitor, arg) => visitor.visitDeferred(this, arg);
795 798
796 DartType getType(CommonElements types) => referenced.getType(types); 799 ResolutionDartType getType(CommonElements types) => referenced.getType(types);
797 800
798 ConstantValueKind get kind => ConstantValueKind.DEFERRED; 801 ConstantValueKind get kind => ConstantValueKind.DEFERRED;
799 802
800 String toDartText() => 'deferred(${referenced.toDartText()})'; 803 String toDartText() => 'deferred(${referenced.toDartText()})';
801 804
802 String toStructuredText() { 805 String toStructuredText() {
803 return 'DeferredConstant(${referenced.toStructuredText()})'; 806 return 'DeferredConstant(${referenced.toStructuredText()})';
804 } 807 }
805 } 808 }
806 809
807 /// A constant value resulting from a non constant or erroneous constant 810 /// A constant value resulting from a non constant or erroneous constant
808 /// expression. 811 /// expression.
809 // TODO(johnniwinther): Expand this to contain the error kind. 812 // TODO(johnniwinther): Expand this to contain the error kind.
810 class NonConstantValue extends ConstantValue { 813 class NonConstantValue extends ConstantValue {
811 bool get isConstant => false; 814 bool get isConstant => false;
812 815
813 @override 816 @override
814 accept(ConstantValueVisitor visitor, arg) { 817 accept(ConstantValueVisitor visitor, arg) {
815 return visitor.visitNonConstant(this, arg); 818 return visitor.visitNonConstant(this, arg);
816 } 819 }
817 820
818 @override 821 @override
819 List<ConstantValue> getDependencies() => const <ConstantValue>[]; 822 List<ConstantValue> getDependencies() => const <ConstantValue>[];
820 823
821 @override 824 @override
822 DartType getType(CommonElements types) => const DynamicType(); 825 ResolutionDartType getType(CommonElements types) =>
826 const ResolutionDynamicType();
823 827
824 ConstantValueKind get kind => ConstantValueKind.NON_CONSTANT; 828 ConstantValueKind get kind => ConstantValueKind.NON_CONSTANT;
825 829
826 @override 830 @override
827 String toStructuredText() => 'NonConstant'; 831 String toStructuredText() => 'NonConstant';
828 832
829 @override 833 @override
830 String toDartText() => '>>non-constant<<'; 834 String toDartText() => '>>non-constant<<';
831 } 835 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constants/expressions.dart ('k') | pkg/compiler/lib/src/core_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698