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

Side by Side Diff: lib/compiler/implementation/typechecker.dart

Issue 11191078: Make hashCode a getter and not a method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status file with co19 issue number. Created 8 years, 2 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 | Annotate | Revision Log
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 class TypeCheckerTask extends CompilerTask { 5 class TypeCheckerTask extends CompilerTask {
6 TypeCheckerTask(Compiler compiler) : super(compiler); 6 TypeCheckerTask(Compiler compiler) : super(compiler);
7 String get name => "Type checker"; 7 String get name => "Type checker";
8 8
9 static const bool LOG_FAILURES = false; 9 static const bool LOG_FAILURES = false;
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 class TypeVariableType implements DartType { 56 class TypeVariableType implements DartType {
57 final TypeVariableElement element; 57 final TypeVariableElement element;
58 58
59 TypeVariableType(this.element); 59 TypeVariableType(this.element);
60 60
61 SourceString get name => element.name; 61 SourceString get name => element.name;
62 62
63 DartType unalias(Compiler compiler) => this; 63 DartType unalias(Compiler compiler) => this;
64 64
65 int hashCode() => 17 * element.hashCode(); 65 int get hashCode => 17 * element.hashCode;
66 66
67 bool operator ==(other) { 67 bool operator ==(other) {
68 if (other is !TypeVariableType) return false; 68 if (other is !TypeVariableType) return false;
69 return identical(other.element, element); 69 return identical(other.element, element);
70 } 70 }
71 71
72 String toString() => name.slowToString(); 72 String toString() => name.slowToString();
73 } 73 }
74 74
75 /** 75 /**
(...skipping 11 matching lines...) Expand all
87 static const NOT_RETURNING = const StatementType('<not returning>'); 87 static const NOT_RETURNING = const StatementType('<not returning>');
88 static const MAYBE_RETURNING = const StatementType('<maybe returning>'); 88 static const MAYBE_RETURNING = const StatementType('<maybe returning>');
89 89
90 /** Combine the information about two control-flow edges that are joined. */ 90 /** Combine the information about two control-flow edges that are joined. */
91 StatementType join(StatementType other) { 91 StatementType join(StatementType other) {
92 return (identical(this, other)) ? this : MAYBE_RETURNING; 92 return (identical(this, other)) ? this : MAYBE_RETURNING;
93 } 93 }
94 94
95 DartType unalias(Compiler compiler) => this; 95 DartType unalias(Compiler compiler) => this;
96 96
97 int hashCode() => 17 * stringName.hashCode(); 97 int get hashCode => 17 * stringName.hashCode;
98 98
99 bool operator ==(other) { 99 bool operator ==(other) {
100 if (other is !StatementType) return false; 100 if (other is !StatementType) return false;
101 return other.stringName == stringName; 101 return other.stringName == stringName;
102 } 102 }
103 103
104 String toString() => stringName; 104 String toString() => stringName;
105 } 105 }
106 106
107 class VoidType implements DartType { 107 class VoidType implements DartType {
108 const VoidType(this.element); 108 const VoidType(this.element);
109 SourceString get name => element.name; 109 SourceString get name => element.name;
110 final VoidElement element; 110 final VoidElement element;
111 111
112 DartType unalias(Compiler compiler) => this; 112 DartType unalias(Compiler compiler) => this;
113 113
114 int hashCode() => 1729; 114 int get hashCode => 1729;
115 115
116 bool operator ==(other) => other is VoidType; 116 bool operator ==(other) => other is VoidType;
117 117
118 String toString() => name.slowToString(); 118 String toString() => name.slowToString();
119 } 119 }
120 120
121 class InterfaceType implements DartType { 121 class InterfaceType implements DartType {
122 final Element element; 122 final Element element;
123 final Link<DartType> arguments; 123 final Link<DartType> arguments;
124 124
125 const InterfaceType(this.element, 125 const InterfaceType(this.element,
126 [this.arguments = const Link<DartType>()]); 126 [this.arguments = const Link<DartType>()]);
127 127
128 SourceString get name => element.name; 128 SourceString get name => element.name;
129 129
130 DartType unalias(Compiler compiler) => this; 130 DartType unalias(Compiler compiler) => this;
131 131
132 String toString() { 132 String toString() {
133 StringBuffer sb = new StringBuffer(); 133 StringBuffer sb = new StringBuffer();
134 sb.add(name.slowToString()); 134 sb.add(name.slowToString());
135 if (!arguments.isEmpty()) { 135 if (!arguments.isEmpty()) {
136 sb.add('<'); 136 sb.add('<');
137 arguments.printOn(sb, ', '); 137 arguments.printOn(sb, ', ');
138 sb.add('>'); 138 sb.add('>');
139 } 139 }
140 return sb.toString(); 140 return sb.toString();
141 } 141 }
142 142
143 int hashCode() { 143 int get hashCode {
144 int hash = element.hashCode(); 144 int hash = element.hashCode;
145 for (Link<DartType> arguments = this.arguments; 145 for (Link<DartType> arguments = this.arguments;
146 !arguments.isEmpty(); 146 !arguments.isEmpty();
147 arguments = arguments.tail) { 147 arguments = arguments.tail) {
148 int argumentHash = arguments.head != null ? arguments.head.hashCode() : 0; 148 int argumentHash = arguments.head != null ? arguments.head.hashCode : 0;
149 hash = 17 * hash + 3 * argumentHash; 149 hash = 17 * hash + 3 * argumentHash;
150 } 150 }
151 return hash; 151 return hash;
152 } 152 }
153 153
154 bool operator ==(other) { 154 bool operator ==(other) {
155 if (other is !InterfaceType) return false; 155 if (other is !InterfaceType) return false;
156 if (!identical(element, other.element)) return false; 156 if (!identical(element, other.element)) return false;
157 return arguments == other.arguments; 157 return arguments == other.arguments;
158 } 158 }
(...skipping 28 matching lines...) Expand all
187 return arity; 187 return arity;
188 } 188 }
189 189
190 void initializeFrom(FunctionType other) { 190 void initializeFrom(FunctionType other) {
191 assert(returnType == null); 191 assert(returnType == null);
192 assert(parameterTypes == null); 192 assert(parameterTypes == null);
193 returnType = other.returnType; 193 returnType = other.returnType;
194 parameterTypes = other.parameterTypes; 194 parameterTypes = other.parameterTypes;
195 } 195 }
196 196
197 int hashCode() { 197 int get hashCode {
198 int hash = 17 * element.hashCode() + 3 * returnType.hashCode(); 198 int hash = 17 * element.hashCode + 3 * returnType.hashCode;
199 for (Link<DartType> parameters = parameterTypes; 199 for (Link<DartType> parameters = parameterTypes;
200 !parameters.isEmpty(); 200 !parameters.isEmpty();
201 parameters = parameters.tail) { 201 parameters = parameters.tail) {
202 hash = 17 * hash + 3 * parameters.head.hashCode(); 202 hash = 17 * hash + 3 * parameters.head.hashCode;
203 } 203 }
204 return hash; 204 return hash;
205 } 205 }
206 206
207 bool operator ==(other) { 207 bool operator ==(other) {
208 if (other is !FunctionType) return false; 208 if (other is !FunctionType) return false;
209 return returnType == other.returnType 209 return returnType == other.returnType
210 && parameterTypes == other.parameterTypes; 210 && parameterTypes == other.parameterTypes;
211 } 211 }
212 } 212 }
(...skipping 17 matching lines...) Expand all
230 StringBuffer sb = new StringBuffer(); 230 StringBuffer sb = new StringBuffer();
231 sb.add(name.slowToString()); 231 sb.add(name.slowToString());
232 if (!typeArguments.isEmpty()) { 232 if (!typeArguments.isEmpty()) {
233 sb.add('<'); 233 sb.add('<');
234 typeArguments.printOn(sb, ', '); 234 typeArguments.printOn(sb, ', ');
235 sb.add('>'); 235 sb.add('>');
236 } 236 }
237 return sb.toString(); 237 return sb.toString();
238 } 238 }
239 239
240 int hashCode() => 17 * element.hashCode(); 240 int get hashCode => 17 * element.hashCode;
241 241
242 bool operator ==(other) { 242 bool operator ==(other) {
243 if (other is !TypedefType) return false; 243 if (other is !TypedefType) return false;
244 if (!identical(element, other.element)) return false; 244 if (!identical(element, other.element)) return false;
245 return typeArguments == other.typeArguments; 245 return typeArguments == other.typeArguments;
246 } 246 }
247 } 247 }
248 248
249 class Types { 249 class Types {
250 final Compiler compiler; 250 final Compiler compiler;
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 } 983 }
984 984
985 DartType visitStatement(Statement node) { 985 DartType visitStatement(Statement node) {
986 compiler.unimplemented('visitNode', node: node); 986 compiler.unimplemented('visitNode', node: node);
987 } 987 }
988 988
989 DartType visitStringNode(StringNode node) { 989 DartType visitStringNode(StringNode node) {
990 compiler.unimplemented('visitNode', node: node); 990 compiler.unimplemented('visitNode', node: node);
991 } 991 }
992 } 992 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698