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

Unified Diff: src/types.cc

Issue 145083007: Type representation converter (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/cctest/test-types.cc » ('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 bbaf7a93fe29d67cf07066ebcb45de1efc770101..7867899d71de99fe0e9d41df81f4bc234b21e855 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -540,6 +540,30 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect(
}
+template<class Config>
+template<class OtherType>
+typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Convert(
+ typename OtherType::TypeHandle type, Region* region) {
+ if (type->IsBitset()) {
+ return Config::from_bitset(type->AsBitset(), region);
+ } else if (type->IsClass()) {
+ return Config::from_class(type->AsClass(), region);
+ } else if (type->IsConstant()) {
+ return Config::from_constant(type->AsConstant(), region);
+ } else {
+ ASSERT(type->IsUnion());
+ typename OtherType::UnionedHandle unioned = type->AsUnion();
+ int length = OtherType::UnionLength(unioned);
+ UnionedHandle new_unioned = Config::union_create(length, region);
+ for (int i = 0; i < length; ++i) {
+ Config::union_set(new_unioned, i,
+ Convert<OtherType>(OtherType::UnionGet(unioned, i), region));
+ }
+ return Config::from_union(new_unioned);
+ }
+}
+
+
// TODO(rossberg): this does not belong here.
Representation Representation::FromType(Type* type) {
if (type->Is(Type::None())) return Representation::None();
@@ -620,5 +644,12 @@ template class TypeImpl<HeapTypeConfig>;
template class TypeImpl<HeapTypeConfig>::Iterator<i::Map>;
template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>;
+template TypeImpl<ZoneTypeConfig>::TypeHandle
+ TypeImpl<ZoneTypeConfig>::Convert<HeapType>(
+ TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*);
+template TypeImpl<HeapTypeConfig>::TypeHandle
+ TypeImpl<HeapTypeConfig>::Convert<Type>(
+ TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*);
+
} } // namespace v8::internal
« no previous file with comments | « src/types.h ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698