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

Side by Side Diff: lib/analyzer/ast_from_analyzer.dart

Issue 2439043002: Introduce Substitution class and Supertype class. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | lib/analyzer/loader.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.analyzer.ast_from_analyzer; 4 library kernel.analyzer.ast_from_analyzer;
5 5
6 import '../ast.dart' as ast; 6 import '../ast.dart' as ast;
7 import '../frontend/accessors.dart'; 7 import '../frontend/accessors.dart';
8 import '../frontend/super_initializers.dart'; 8 import '../frontend/super_initializers.dart';
9 import '../log.dart'; 9 import '../log.dart';
10 import '../type_algebra.dart'; 10 import '../type_algebra.dart';
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 var typeParameter = getTypeParameterReference(element); 313 var typeParameter = getTypeParameterReference(element);
314 assert(bound != null); 314 assert(bound != null);
315 typeParameter.bound = bound; 315 typeParameter.bound = bound;
316 return typeParameter; 316 return typeParameter;
317 } 317 }
318 318
319 ast.DartType buildType(DartType type) { 319 ast.DartType buildType(DartType type) {
320 return new TypeAnnotationBuilder(this).buildFromDartType(type); 320 return new TypeAnnotationBuilder(this).buildFromDartType(type);
321 } 321 }
322 322
323 ast.Supertype buildSupertype(DartType type) {
324 if (type is InterfaceType) {
325 var classElement = type.element;
326 if (classElement == null) return getRootClassReference().asRawSupertype;
327 var classNode = getClassReference(classElement);
328 if (classNode.typeParameters.isEmpty ||
329 classNode.typeParameters.length != type.typeArguments.length) {
330 return classNode.asRawSupertype;
331 } else {
332 return new ast.Supertype(classNode,
333 type.typeArguments.map(buildType).toList(growable: false));
334 }
335 }
336 return getRootClassReference().asRawSupertype;
337 }
338
323 ast.DartType buildTypeAnnotation(AstNode node) { 339 ast.DartType buildTypeAnnotation(AstNode node) {
324 return new TypeAnnotationBuilder(this).build(node); 340 return new TypeAnnotationBuilder(this).build(node);
325 } 341 }
326 342
327 ast.DartType buildOptionalTypeAnnotation(AstNode node) { 343 ast.DartType buildOptionalTypeAnnotation(AstNode node) {
328 return node == null ? null : new TypeAnnotationBuilder(this).build(node); 344 return node == null ? null : new TypeAnnotationBuilder(this).build(node);
329 } 345 }
330 346
331 ast.DartType getInferredType(Expression node) { 347 ast.DartType getInferredType(Expression node) {
332 if (!strongMode) return const ast.DynamicType(); 348 if (!strongMode) return const ast.DynamicType();
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 return; 2283 return;
2268 } 2284 }
2269 node.accept(this); 2285 node.accept(this);
2270 } 2286 }
2271 2287
2272 /// Builds an empty class for broken classes that have no AST. 2288 /// Builds an empty class for broken classes that have no AST.
2273 /// 2289 ///
2274 /// This should only be used to recover from a compile-time error. 2290 /// This should only be used to recover from a compile-time error.
2275 void buildBrokenClass() { 2291 void buildBrokenClass() {
2276 currentClass.name = element.name; 2292 currentClass.name = element.name;
2277 currentClass.supertype = scope.getRootClassReference().rawType; 2293 currentClass.supertype = scope.getRootClassReference().asRawSupertype;
2278 currentClass.constructors.add( 2294 currentClass.constructors.add(
2279 new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement()))); 2295 new ast.Constructor(new ast.FunctionNode(new ast.InvalidStatement())));
2280 } 2296 }
2281 2297
2282 void addAnnotations(List<Annotation> annotations) { 2298 void addAnnotations(List<Annotation> annotations) {
2283 // Class type parameters are not in scope in the annotation list. 2299 // Class type parameters are not in scope in the annotation list.
2284 for (var annotation in annotations) { 2300 for (var annotation in annotations) {
2285 currentClass.addAnnotation(annotationScope.buildAnnotation(annotation)); 2301 currentClass.addAnnotation(annotationScope.buildAnnotation(annotation));
2286 } 2302 }
2287 } 2303 }
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 if (element is FieldElement) return element.getter; 2772 if (element is FieldElement) return element.getter;
2757 return element; 2773 return element;
2758 } 2774 }
2759 2775
2760 Element desynthesizeSetter(Element element) { 2776 Element desynthesizeSetter(Element element) {
2761 if (element == null || !element.isSynthetic) return element; 2777 if (element == null || !element.isSynthetic) return element;
2762 if (element is PropertyAccessorElement) return element.variable; 2778 if (element is PropertyAccessorElement) return element.variable;
2763 if (element is FieldElement) return element.setter; 2779 if (element is FieldElement) return element.setter;
2764 return element; 2780 return element;
2765 } 2781 }
OLDNEW
« no previous file with comments | « no previous file | lib/analyzer/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698