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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 8372041: Canonicalize types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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 | « runtime/vm/class_finalizer.h ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 1042)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -449,9 +449,11 @@
}
}
}
- const Type& super_type = Type::Handle(cls.super_type());
+ Type& super_type = Type::Handle(cls.super_type());
if (!super_type.IsNull()) {
FinalizeType(super_type);
+ super_type = super_type.Canonicalize();
+ cls.set_super_type(super_type);
const Class& super_class = Class::Handle(super_type.type_class());
const TypeArguments& super_type_args =
TypeArguments::Handle(super_type.arguments());
@@ -465,6 +467,7 @@
if (!super_type_arg.IsInstantiated()) {
super_type_arg = super_type_arg.InstantiateFrom(arguments, offset);
}
+ super_type_arg = super_type_arg.Canonicalize();
arguments.SetTypeAt(super_offset + i, super_type_arg);
}
FinalizeTypeArguments(super_class, arguments);
@@ -499,6 +502,8 @@
for (intptr_t i = 0; i < num_arguments; i++) {
Type& type_argument = Type::Handle(arguments.TypeAt(i));
FinalizeType(type_argument);
+ type_argument = type_argument.Canonicalize();
+ arguments.SetTypeAt(i, type_argument);
}
}
@@ -553,7 +558,8 @@
}
-RawString* ClassFinalizer::FinalizeTypeWhileParsing(const Type& type) {
+RawType* ClassFinalizer::FinalizeAndCanonicalizeType(const Type& type,
+ String* errmsg) {
Isolate* isolate = Isolate::Current();
ASSERT(isolate != NULL);
LongJump* base = isolate->long_jump_base();
@@ -562,14 +568,16 @@
if (setjmp(*jump.Set()) == 0) {
FinalizeType(type);
isolate->set_long_jump_base(base);
- return String::null();
+ *errmsg = String::null();
+ return type.Canonicalize();
} else {
// Error occured: Get the error message.
isolate->set_long_jump_base(base);
- return isolate->object_store()->sticky_error();
+ *errmsg = isolate->object_store()->sticky_error();
+ return type.raw();
}
UNREACHABLE();
- return String::null();
+ return Type::null();
}
@@ -585,6 +593,8 @@
type = ResolveType(cls, type);
function.set_result_type(type);
FinalizeType(type);
+ type = type.Canonicalize();
+ function.set_result_type(type);
// Resolve formal parameter types.
const intptr_t num_parameters = function.NumberOfParameters();
for (intptr_t i = 0; i < num_parameters; i++) {
@@ -592,6 +602,8 @@
type = ResolveType(cls, type);
function.SetParameterTypeAt(i, type);
FinalizeType(type);
+ type = type.Canonicalize();
+ function.SetParameterTypeAt(i, type);
}
}
@@ -660,6 +672,8 @@
type = ResolveType(cls, type);
field.set_type(type);
FinalizeType(type);
+ type = type.Canonicalize();
+ field.set_type(type);
name = field.name();
super_class = FindSuperOwnerOfInstanceMember(cls, name);
if (!super_class.IsNull()) {
@@ -771,6 +785,7 @@
if (cls.IsSignatureClass()) {
const Type& signature_type = Type::Handle(cls.SignatureType());
FinalizeType(signature_type);
+ // Signature types are canonicalized by default.
}
}
@@ -789,15 +804,17 @@
}
GrowableArray<const Class*> visited;
ResolveInterfaces(cls, &visited);
- const Type& super_type = Type::Handle(cls.super_type());
+ Type& super_type = Type::Handle(cls.super_type());
if (!super_type.IsNull()) {
const Class& super_class = Class::Handle(super_type.type_class());
// Finalize super class and super type.
FinalizeClass(super_class);
FinalizeType(super_type);
+ super_type = super_type.Canonicalize();
+ cls.set_super_type(super_type);
}
if (cls.is_interface()) {
- const Type& factory_type = Type::Handle(cls.factory_type());
+ Type& factory_type = Type::Handle(cls.factory_type());
if (!factory_type.IsNull()) {
const Class& factory_class = Class::Handle(factory_type.type_class());
// Finalize factory class and factory type.
@@ -809,6 +826,8 @@
}
}
FinalizeType(factory_type);
+ factory_type = factory_type.Canonicalize();
+ cls.set_factory_type(factory_type);
}
}
// Finalize interface types (but not necessarily interface classes).
@@ -817,6 +836,8 @@
for (intptr_t i = 0; i < interface_types.Length(); i++) {
interface_type ^= interface_types.At(i);
FinalizeType(interface_type);
+ interface_type = interface_type.Canonicalize();
+ interface_types.SetAt(i, interface_type);
}
// Mark as finalized before resolving member types in order to break cycles.
cls.Finalize();
« no previous file with comments | « runtime/vm/class_finalizer.h ('k') | runtime/vm/code_generator_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698