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

Side by Side Diff: lib/src/checker/rules.dart

Issue 1100633006: Generate static calls for Object fields and methods (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Better static dispatch check Created 5 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 dev_compiler.src.checker.rules; 5 library dev_compiler.src.checker.rules;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/resolver.dart'; 9 import 'package:analyzer/src/generated/resolver.dart';
10 10
11 import 'package:dev_compiler/src/info.dart'; 11 import 'package:dev_compiler/src/info.dart';
12 import 'package:dev_compiler/src/options.dart'; 12 import 'package:dev_compiler/src/options.dart';
13 import 'package:dev_compiler/src/utils.dart' as utils; 13 import 'package:dev_compiler/src/utils.dart' as utils;
14 14
15 abstract class TypeRules { 15 abstract class TypeRules {
16 final TypeProvider provider; 16 final TypeProvider provider;
17 LibraryInfo currentLibraryInfo = null; 17 LibraryInfo currentLibraryInfo = null;
18 18
19 TypeRules(TypeProvider this.provider); 19 /// Map of fields / properties / methods on Object.
20 Map<String, DartType> _objectMembers;
21
22 TypeRules(TypeProvider this.provider) {
Jennifer Messerly 2015/04/23 21:09:30 minor suggestion: final Map<String, DartType> obj
vsm 2015/04/23 21:23:32 Done.
23 _objectMembers = utils.getObjectMemberMap(provider);
24 }
20 25
21 MissingTypeReporter reportMissingType; 26 MissingTypeReporter reportMissingType;
22 27
23 bool isSubTypeOf(DartType t1, DartType t2); 28 bool isSubTypeOf(DartType t1, DartType t2);
24 bool isAssignable(DartType t1, DartType t2); 29 bool isAssignable(DartType t1, DartType t2);
25 30
26 bool isGroundType(DartType t) => true; 31 bool isGroundType(DartType t) => true;
27 // TODO(vsm): The default implementation is not ignoring the return type, 32 // TODO(vsm): The default implementation is not ignoring the return type,
28 // only the restricted override is. 33 // only the restricted override is.
29 bool isFunctionSubTypeOf(FunctionType f1, FunctionType f2, 34 bool isFunctionSubTypeOf(FunctionType f1, FunctionType f2,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 71 }
67 if (t is FunctionType) return t; 72 if (t is FunctionType) return t;
68 return null; 73 return null;
69 } 74 }
70 75
71 DartType elementType(Element e); 76 DartType elementType(Element e);
72 77
73 bool isDynamic(DartType t); 78 bool isDynamic(DartType t);
74 bool isDynamicTarget(Expression expr); 79 bool isDynamicTarget(Expression expr);
75 bool isDynamicCall(Expression call); 80 bool isDynamicCall(Expression call);
81
82 Map<String, DartType> get objectMembers => _objectMembers;
76 } 83 }
77 84
78 class DartRules extends TypeRules { 85 class DartRules extends TypeRules {
79 DartRules(TypeProvider provider) : super(provider); 86 DartRules(TypeProvider provider) : super(provider);
80 87
81 MissingTypeReporter reportMissingType = null; 88 MissingTypeReporter reportMissingType = null;
82 89
83 bool isSubTypeOf(DartType t1, DartType t2) { 90 bool isSubTypeOf(DartType t1, DartType t2) {
84 return t1.isSubtypeOf(t2); 91 return t1.isSubtypeOf(t2);
85 } 92 }
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 var entries = e.entries; 846 var entries = e.entries;
840 bool inferEntry(MapLiteralEntry entry) { 847 bool inferEntry(MapLiteralEntry entry) {
841 return _inferExpression(entry.key, kType, errors) && 848 return _inferExpression(entry.key, kType, errors) &&
842 _inferExpression(entry.value, vType, errors); 849 _inferExpression(entry.value, vType, errors);
843 } 850 }
844 var b = entries.every(inferEntry); 851 var b = entries.every(inferEntry);
845 if (b) annotateMapLiteral(e, targs); 852 if (b) annotateMapLiteral(e, targs);
846 return b; 853 return b;
847 } 854 }
848 } 855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698