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

Unified Diff: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart

Issue 2999723002: Add stub versions of KernelInferrerEngine and friends (Closed)
Patch Set: Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
index cb0c6182cf1da65a81595901a158a98d1aa40259..153b70323f51d958cb5b4b0cd0f3caa7afa9bb53 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
@@ -50,13 +50,15 @@ class WorkQueue {
int get length => queue.length;
}
-class TypeGraphInferrer implements TypesInferrer {
- InferrerEngine inferrer;
- final Compiler compiler;
+abstract class TypeGraphInferrer<T> implements TypesInferrer<T> {
+ InferrerEngine<T> inferrer;
+ final bool _disableTypeInference;
final ClosedWorld closedWorld;
final ClosedWorldRefiner closedWorldRefiner;
- TypeGraphInferrer(this.compiler, this.closedWorld, this.closedWorldRefiner);
+ TypeGraphInferrer(this.closedWorld, this.closedWorldRefiner,
+ {bool disableTypeInference: false})
+ : this._disableTypeInference = disableTypeInference;
String get name => 'Graph inferrer';
@@ -65,51 +67,52 @@ class TypeGraphInferrer implements TypesInferrer {
TypeMask get _dynamicType => commonMasks.dynamicType;
void analyzeMain(FunctionEntity main) {
- inferrer =
- new AstInferrerEngine(compiler, closedWorld, closedWorldRefiner, main);
+ inferrer = createInferrerEngineFor(main);
inferrer.runOverAllElements();
}
- TypeMask getReturnTypeOfMember(MemberElement element) {
- if (compiler.disableTypeInference) return _dynamicType;
+ InferrerEngine<T> createInferrerEngineFor(FunctionEntity main);
+
+ TypeMask getReturnTypeOfMember(MemberEntity element) {
+ if (_disableTypeInference) return _dynamicType;
// Currently, closure calls return dynamic.
- if (element is! MethodElement) return _dynamicType;
+ if (element is! FunctionElement) return _dynamicType;
return inferrer.types.getInferredTypeOfMember(element).type;
}
- TypeMask getReturnTypeOfParameter(ParameterElement element) {
- if (compiler.disableTypeInference) return _dynamicType;
+ TypeMask getReturnTypeOfParameter(Local element) {
+ if (_disableTypeInference) return _dynamicType;
return _dynamicType;
}
- TypeMask getTypeOfMember(MemberElement element) {
- if (compiler.disableTypeInference) return _dynamicType;
+ TypeMask getTypeOfMember(MemberEntity element) {
+ if (_disableTypeInference) return _dynamicType;
// The inferrer stores the return type for a function, so we have to
// be careful to not return it here.
- if (element is MethodElement) return commonMasks.functionType;
+ if (element is FunctionEntity) return commonMasks.functionType;
return inferrer.types.getInferredTypeOfMember(element).type;
}
- TypeMask getTypeOfParameter(ParameterElement element) {
- if (compiler.disableTypeInference) return _dynamicType;
+ TypeMask getTypeOfParameter(Local element) {
+ if (_disableTypeInference) return _dynamicType;
// The inferrer stores the return type for a function, so we have to
// be careful to not return it here.
return inferrer.types.getInferredTypeOfParameter(element).type;
}
- TypeMask getTypeForNewList(ast.Node node) {
- if (compiler.disableTypeInference) return _dynamicType;
+ TypeMask getTypeForNewList(T node) {
+ if (_disableTypeInference) return _dynamicType;
return inferrer.types.allocatedLists[node].type;
}
- bool isFixedArrayCheckedForGrowable(ast.Node node) {
- if (compiler.disableTypeInference) return true;
+ bool isFixedArrayCheckedForGrowable(T node) {
+ if (_disableTypeInference) return true;
ListTypeInformation info = inferrer.types.allocatedLists[node];
return info.checksGrowable;
}
TypeMask getTypeOfSelector(Selector selector, TypeMask mask) {
- if (compiler.disableTypeInference) return _dynamicType;
+ if (_disableTypeInference) return _dynamicType;
// Bailout for closure calls. We're not tracking types of
// closures.
if (selector.isClosureCall) return _dynamicType;
@@ -137,16 +140,16 @@ class TypeGraphInferrer implements TypesInferrer {
return result;
}
- Iterable<MemberEntity> getCallersOf(MemberElement element) {
- if (compiler.disableTypeInference) {
+ Iterable<MemberEntity> getCallersOf(MemberEntity element) {
+ if (_disableTypeInference) {
throw new UnsupportedError(
"Cannot query the type inferrer when type inference is disabled.");
}
return inferrer.getCallersOf(element);
}
- bool isMemberCalledOnce(MemberElement element) {
- if (compiler.disableTypeInference) return false;
+ bool isMemberCalledOnce(MemberEntity element) {
+ if (_disableTypeInference) return false;
MemberTypeInformation info =
inferrer.types.getInferredTypeOfMember(element);
return info.isCalledOnce();
@@ -156,3 +159,18 @@ class TypeGraphInferrer implements TypesInferrer {
inferrer.clear();
}
}
+
+class AstTypeGraphInferrer extends TypeGraphInferrer<ast.Node> {
+ final Compiler _compiler;
+
+ AstTypeGraphInferrer(
+ this._compiler, ClosedWorld closedWorld, closedWorldRefiner,
+ {bool disableTypeInference: false})
+ : super(closedWorld, closedWorldRefiner,
+ disableTypeInference: disableTypeInference);
+
+ InferrerEngine<ast.Node> createInferrerEngineFor(FunctionEntity main) {
+ return new AstInferrerEngine(
+ _compiler, closedWorld, closedWorldRefiner, main);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698