| 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 | 5 |
| 6 /** | 6 /** |
| 7 * If true, print a warning for each method that was resolved, but not | 7 * If true, print a warning for each method that was resolved, but not |
| 8 * compiled. | 8 * compiled. |
| 9 */ | 9 */ |
| 10 final bool REPORT_EXCESS_RESOLUTION = false; | 10 final bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 HType type = fieldInitializers[field.enclosingElement][field]; | 186 HType type = fieldInitializers[field.enclosingElement][field]; |
| 187 return type == null ? HType.UNKNOWN : type; | 187 return type == null ? HType.UNKNOWN : type; |
| 188 } else { | 188 } else { |
| 189 return HType.UNKNOWN; | 189 return HType.UNKNOWN; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 void updateFieldSetters(Element field, HType type) { | 193 void updateFieldSetters(Element field, HType type) { |
| 194 assert(field.isField()); | 194 assert(field.isField()); |
| 195 assert(field.enclosingElement.isClass()); | 195 assert(field.enclosingElement.isClass()); |
| 196 Map<Element, bool> fields = | 196 Map<Element, HType> fields = |
| 197 fieldSettersType.putIfAbsent( | 197 fieldSettersType.putIfAbsent( |
| 198 field.enclosingElement, () => new Map<Element, HType>()); | 198 field.enclosingElement, () => new Map<Element, HType>()); |
| 199 if (!fields.containsKey(field)) { | 199 if (!fields.containsKey(field)) { |
| 200 fields[field] = type; | 200 fields[field] = type; |
| 201 } else { | 201 } else { |
| 202 fields[field] = fields[field].union(type); | 202 fields[field] = fields[field].union(type); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 // Returns whether nothing but setters setting the field to an integer have | 206 // Returns whether nothing but setters setting the field to an integer have |
| 207 // been seen during compilation so far. | 207 // been seen during compilation so far. |
| 208 HType fieldSettersTypeSoFar(Element field) { | 208 HType fieldSettersTypeSoFar(Element field) { |
| 209 assert(field.isField()); | 209 assert(field.isField()); |
| 210 assert(field.enclosingElement.isClass()); | 210 assert(field.enclosingElement.isClass()); |
| 211 if (!fieldSettersType.containsKey(field.enclosingElement)) { | 211 if (!fieldSettersType.containsKey(field.enclosingElement)) { |
| 212 return HType.UNKNOWN; | 212 return HType.UNKNOWN; |
| 213 } | 213 } |
| 214 Map<Element, Htype> fields = fieldSettersType[field.enclosingElement]; | 214 Map<Element, HType> fields = fieldSettersType[field.enclosingElement]; |
| 215 if (!fields.containsKey(field)) return HType.UNKNOWN; | 215 if (!fields.containsKey(field)) return HType.UNKNOWN; |
| 216 return fields[field]; | 216 return fields[field]; |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 class Compiler implements DiagnosticListener { | 220 class Compiler implements DiagnosticListener { |
| 221 final Map<String, LibraryElement> libraries; | 221 final Map<String, LibraryElement> libraries; |
| 222 int nextFreeClassId = 0; | 222 int nextFreeClassId = 0; |
| 223 World world; | 223 World world; |
| 224 String assembledCode; | 224 String assembledCode; |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 f(int beginOffset, int endOffset)) { | 994 f(int beginOffset, int endOffset)) { |
| 995 final beginOffset = begin.charOffset; | 995 final beginOffset = begin.charOffset; |
| 996 final endOffset = end.charOffset + end.slowCharCount; | 996 final endOffset = end.charOffset + end.slowCharCount; |
| 997 | 997 |
| 998 // [begin] and [end] might be the same for the same empty token. This | 998 // [begin] and [end] might be the same for the same empty token. This |
| 999 // happens for instance when scanning '$$'. | 999 // happens for instance when scanning '$$'. |
| 1000 assert(endOffset >= beginOffset); | 1000 assert(endOffset >= beginOffset); |
| 1001 return f(beginOffset, endOffset); | 1001 return f(beginOffset, endOffset); |
| 1002 } | 1002 } |
| 1003 } | 1003 } |
| OLD | NEW |