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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 12327010: Infer types of final fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/builder.dart (revision 18819)
+++ sdk/lib/_internal/compiler/implementation/ssa/builder.dart (working copy)
@@ -294,7 +294,7 @@
builder.parameters[parameterElement] = parameter;
directLocals[parameterElement] = parameter;
parameter.instructionType =
- builder.getGuaranteedTypeOfElement(parameterElement);
+ new HType.inferredForElement(parameterElement, compiler);
});
}
@@ -2887,7 +2887,7 @@
native.NativeBehavior nativeBehavior =
compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node);
- HType ssaType = mapNativeBehaviorType(nativeBehavior);
+ HType ssaType = new HType.fromNativeBehavior(nativeBehavior, compiler);
if (code is StringNode) {
StringNode codeString = code;
if (!codeString.isInterpolation) {
@@ -3374,7 +3374,7 @@
}
HInvokeStatic instruction = new HInvokeStatic(inputs, HType.UNKNOWN);
- HType returnType = getGuaranteedTypeOfElement(element);
+ HType returnType = new HType.inferredForElement(element, compiler);
if (returnType.isUnknown()) {
// TODO(ngeoffray): Only do this if knowing the return type is
// useful.
@@ -3574,8 +3574,9 @@
inputs.addAll(arguments);
HInstruction invoke = new HInvokeDynamicMethod(
selector, inputs, isIntercepted);
- HType returnType = mapInferredType(
- compiler.typesTask.getGuaranteedTypeOfNode(currentElement, node));
+ HType returnType =
+ new HType.inferredForNode(currentElement, node, compiler);
+
if (returnType != null) {
invoke.instructionType = returnType;
}
@@ -4655,64 +4656,6 @@
visitTypeVariable(TypeVariable node) {
compiler.internalError('SsaBuilder.visitTypeVariable');
}
-
- HType mapBaseType(BaseType baseType) {
- if (!baseType.isClass()) return HType.UNKNOWN;
- ClassBaseType classBaseType = baseType;
- ClassElement cls = classBaseType.element;
- // Special case the list and map classes that are used as types
- // for literals in the type inferrer.
- if (cls == compiler.listClass) {
- return HType.READABLE_ARRAY;
- } else if (cls == compiler.mapClass) {
- // TODO(ngeoffray): get the actual implementation of a map
- // literal.
- return new HType.nonNullSubtype(
- compiler.mapLiteralClass.computeType(compiler), compiler);
- } else {
- return new HType.nonNullExactClass(
- cls.computeType(compiler), compiler);
- }
- }
-
- HType mapInferredType(ConcreteType concreteType) {
- if (concreteType == null) return HType.UNKNOWN;
- HType ssaType = HType.CONFLICTING;
- for (BaseType baseType in concreteType.baseTypes) {
- ssaType = ssaType.union(mapBaseType(baseType), compiler);
- }
- if (ssaType.isConflicting()) return HType.UNKNOWN;
- return ssaType;
- }
-
- HType getGuaranteedTypeOfElement(Element element) {
- return mapInferredType(
- compiler.typesTask.getGuaranteedTypeOfElement(element));
- }
-
- // [type] is either an instance of [DartType] or special objects
- // like [native.SpecialType.JsObject], or [native.SpecialType.JsArray].
- HType mapNativeType(type) {
- if (type == native.SpecialType.JsObject) {
- return new HType.nonNullExactClass(
- compiler.objectClass.computeType(compiler), compiler);
- } else if (type == native.SpecialType.JsArray) {
- return HType.READABLE_ARRAY;
- } else {
- return new HType.nonNullSubclass(type, compiler);
- }
- }
-
- HType mapNativeBehaviorType(native.NativeBehavior nativeBehavior) {
- if (nativeBehavior.typesInstantiated.isEmpty) return HType.UNKNOWN;
-
- HType ssaType = HType.CONFLICTING;
- for (final type in nativeBehavior.typesInstantiated) {
- ssaType = ssaType.union(mapNativeType(type), compiler);
- }
- assert(!ssaType.isConflicting());
- return ssaType;
- }
}
/**
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/enqueue.dart ('k') | sdk/lib/_internal/compiler/implementation/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698