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

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

Issue 12095011: Properly register types on the JS foreign instruction. (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/types.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/types.dart (revision 18037)
+++ sdk/lib/_internal/compiler/implementation/ssa/types.dart (working copy)
@@ -15,30 +15,32 @@
Compiler compiler,
[bool canBeNull = false]) {
Element element = type.element;
- if (identical(element.kind, ElementKind.TYPE_VARIABLE)) {
+ if (element.kind == ElementKind.TYPE_VARIABLE) {
// TODO(ngeoffray): Replace object type with [type].
return new HBoundedPotentialPrimitiveType(
compiler.objectClass.computeType(compiler), canBeNull, true);
}
- if (identical(element, compiler.intClass)) {
+ if (element == compiler.intClass) {
return canBeNull ? HType.INTEGER_OR_NULL : HType.INTEGER;
- } else if (identical(element, compiler.numClass)) {
+ } else if (element == compiler.numClass) {
return canBeNull ? HType.NUMBER_OR_NULL : HType.NUMBER;
- } else if (identical(element, compiler.doubleClass)) {
+ } else if (element == compiler.doubleClass) {
return canBeNull ? HType.DOUBLE_OR_NULL : HType.DOUBLE;
- } else if (identical(element, compiler.stringClass)) {
+ } else if (element == compiler.stringClass) {
return canBeNull ? HType.STRING_OR_NULL : HType.STRING;
- } else if (identical(element, compiler.boolClass)) {
+ } else if (element == compiler.boolClass) {
return canBeNull ? HType.BOOLEAN_OR_NULL : HType.BOOLEAN;
- } else if (identical(element, compiler.listClass)
+ } else if (element == compiler.nullClass) {
+ return HType.NULL;
+ } else if (element == compiler.listClass
|| Elements.isListSupertype(element, compiler)) {
return new HBoundedPotentialPrimitiveArray(type, canBeNull);
} else if (Elements.isNumberOrStringSupertype(element, compiler)) {
return new HBoundedPotentialPrimitiveNumberOrString(type, canBeNull);
} else if (Elements.isStringOnlySupertype(element, compiler)) {
return new HBoundedPotentialPrimitiveString(type, canBeNull);
- } else if (identical(element, compiler.objectClass)) {
+ } else if (element == compiler.objectClass) {
return new HBoundedPotentialPrimitiveType(
compiler.objectClass.computeType(compiler), canBeNull, true);
} else {
@@ -170,7 +172,9 @@
bool isNull() => true;
String toString() => 'null';
- DartType computeType(Compiler compiler) => null;
+ DartType computeType(Compiler compiler) {
+ return compiler.nullClass.computeType(compiler);
+ }
HType union(HType other, Compiler compiler) {
if (other.isConflicting()) return HType.NULL;
@@ -180,6 +184,8 @@
if (other.isDouble()) return HType.DOUBLE_OR_NULL;
if (other.isNumber()) return HType.NUMBER_OR_NULL;
if (other.isBoolean()) return HType.BOOLEAN_OR_NULL;
+ // TODO(ngeoffray): Deal with the type of null more generally.
+ if (other.isReadableArray()) return other.union(this, compiler);
if (!other.canBeNull()) return HType.UNKNOWN;
return other;
}
@@ -597,6 +603,11 @@
if (other.isReadableArray()) return HType.READABLE_ARRAY;
if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE;
if (other is HBoundedPotentialPrimitiveArray) return other;
+ if (other.isNull()) {
+ // TODO(ngeoffray): This should be readable array or null.
+ return new HBoundedPotentialPrimitiveArray(
+ compiler.listClass.computeType(compiler), true);
+ }
return HType.UNKNOWN;
}
@@ -623,6 +634,11 @@
if (other.isReadableArray()) return HType.READABLE_ARRAY;
if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE;
if (other is HBoundedPotentialPrimitiveArray) return other;
+ if (other.isNull()) {
+ // TODO(ngeoffray): This should be mutable array or null.
+ return new HBoundedPotentialPrimitiveArray(
+ compiler.listClass.computeType(compiler), true);
+ }
return HType.UNKNOWN;
}
@@ -650,6 +666,11 @@
if (other.isReadableArray()) return HType.READABLE_ARRAY;
if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE;
if (other is HBoundedPotentialPrimitiveArray) return other;
+ if (other.isNull()) {
+ // TODO(ngeoffray): This should be fixed array or null.
+ return new HBoundedPotentialPrimitiveArray(
+ compiler.listClass.computeType(compiler), true);
+ }
return HType.UNKNOWN;
}
@@ -678,6 +699,11 @@
if (other.isReadableArray()) return HType.READABLE_ARRAY;
if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE;
if (other is HBoundedPotentialPrimitiveArray) return other;
+ if (other.isNull()) {
+ // TODO(ngeoffray): This should be extendable array or null.
+ return new HBoundedPotentialPrimitiveArray(
+ compiler.listClass.computeType(compiler), true);
+ }
return HType.UNKNOWN;
}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/nodes.dart ('k') | tests/compiler/dart2js/call_site_type_inferer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698