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

Unified Diff: src/types.cc

Issue 1631583002: [for-in] Further refactorings and unification around for-in. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « src/types.h ('k') | test/mjsunit/for-in-opt.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/types.cc
diff --git a/src/types.cc b/src/types.cc
index f41697870501bd998d9e55d9f744948c12efdb5b..e1355209e3b2f99b5e68c98e353e44d2708c9bc5 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -174,6 +174,7 @@ TypeImpl<Config>::BitsetType::Lub(TypeImpl* type) {
if (type->IsContext()) return kInternal & kTaggedPointer;
if (type->IsArray()) return kOtherObject;
if (type->IsFunction()) return kFunction;
+ if (type->IsTuple()) return kInternal;
UNREACHABLE();
return kNone;
}
@@ -503,6 +504,18 @@ bool TypeImpl<Config>::SimplyEquals(TypeImpl* that) {
}
return true;
}
+ if (this->IsTuple()) {
Jarin 2016/01/25 10:00:26 There should be a comment somewhere (probably on t
Benedikt Meurer 2016/01/25 10:05:05 As discussed offline, not saying anything about th
+ if (!that->IsTuple()) return false;
+ TupleType* this_tuple = this->AsTuple();
+ TupleType* that_tuple = that->AsTuple();
+ if (this_tuple->Arity() != that_tuple->Arity()) {
+ return false;
+ }
+ for (int i = 0, n = this_tuple->Arity(); i < n; ++i) {
+ if (!this_tuple->Element(i)->Equals(that_tuple->Element(i))) return false;
+ }
+ return true;
+ }
UNREACHABLE();
return false;
}
@@ -1238,6 +1251,13 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert(
function->InitParameter(i, param);
}
return function;
+ } else if (type->IsTuple()) {
+ TupleHandle tuple = TupleType::New(type->AsTuple()->Arity(), region);
+ for (int i = 0; i < tuple->Arity(); ++i) {
+ tuple->InitElement(
+ i, Convert<OtherType>(type->AsTuple()->Element(i), region));
+ }
+ return tuple;
} else {
UNREACHABLE();
return None(region);
@@ -1355,6 +1375,14 @@ void TypeImpl<Config>::PrintTo(std::ostream& os, PrintDimension dim) {
}
os << ")->";
this->AsFunction()->Result()->PrintTo(os, dim);
+ } else if (this->IsTuple()) {
+ os << "<";
+ for (int i = 0, n = this->AsTuple()->Arity(); i < n; ++i) {
+ TypeHandle type_i = this->AsTuple()->Element(i);
+ if (i > 0) os << ", ";
+ type_i->PrintTo(os, dim);
+ }
+ os << ">";
} else {
UNREACHABLE();
}
« no previous file with comments | « src/types.h ('k') | test/mjsunit/for-in-opt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698