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

Side by Side Diff: pkg/compiler/lib/src/types/value_type_mask.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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 part of types; 5 part of types;
6 6
7 class ValueTypeMask extends ForwardingTypeMask { 7 class ValueTypeMask extends ForwardingTypeMask {
8 final TypeMask forwardTo; 8 final TypeMask forwardTo;
9 final PrimitiveConstantValue value; 9 final PrimitiveConstantValue value;
10 10
11 ValueTypeMask(this.forwardTo, this.value); 11 ValueTypeMask(this.forwardTo, this.value);
12 12
13 TypeMask nullable() { 13 TypeMask nullable() {
14 return isNullable 14 return isNullable ? this : new ValueTypeMask(forwardTo.nullable(), value);
15 ? this
16 : new ValueTypeMask(forwardTo.nullable(), value);
17 } 15 }
18 16
19 TypeMask nonNullable() { 17 TypeMask nonNullable() {
20 return isNullable 18 return isNullable
21 ? new ValueTypeMask(forwardTo.nonNullable(), value) 19 ? new ValueTypeMask(forwardTo.nonNullable(), value)
22 : this; 20 : this;
23 } 21 }
24 22
25 bool get isValue => true; 23 bool get isValue => true;
26 24
27 bool equalsDisregardNull(other) { 25 bool equalsDisregardNull(other) {
28 if (other is! ValueTypeMask) return false; 26 if (other is! ValueTypeMask) return false;
29 return super.equalsDisregardNull(other) && value == other.value; 27 return super.equalsDisregardNull(other) && value == other.value;
30 } 28 }
31 29
32 TypeMask intersection(TypeMask other, ClassWorld classWorld) { 30 TypeMask intersection(TypeMask other, ClassWorld classWorld) {
33 TypeMask forwardIntersection = forwardTo.intersection(other, classWorld); 31 TypeMask forwardIntersection = forwardTo.intersection(other, classWorld);
34 if (forwardIntersection.isEmptyOrNull) return forwardIntersection; 32 if (forwardIntersection.isEmptyOrNull) return forwardIntersection;
35 return forwardIntersection.isNullable 33 return forwardIntersection.isNullable ? nullable() : nonNullable();
36 ? nullable()
37 : nonNullable();
38 } 34 }
39 35
40 bool operator==(other) => super == other; 36 bool operator ==(other) => super == other;
41 37
42 int get hashCode { 38 int get hashCode {
43 return computeHashCode(value, isNullable, forwardTo); 39 return computeHashCode(value, isNullable, forwardTo);
44 } 40 }
45 41
46 String toString() { 42 String toString() {
47 return 'Value mask: [${value.unparse()}] type: $forwardTo'; 43 return 'Value mask: [${value.unparse()}] type: $forwardTo';
48 } 44 }
49 } 45 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/types/union_type_mask.dart ('k') | pkg/compiler/lib/src/universe/call_structure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698