| Index: runtime/vm/object.cc
|
| ===================================================================
|
| --- runtime/vm/object.cc (revision 1474)
|
| +++ runtime/vm/object.cc (working copy)
|
| @@ -239,6 +239,7 @@
|
|
|
| // Allocate and initialize the null class.
|
| cls = Class::New<Instance>();
|
| + cls.set_is_finalized();
|
| null_class_ = cls.raw();
|
|
|
| // Complete initialization of null_ instance, i.e. initialize its class_
|
| @@ -264,6 +265,7 @@
|
| // see GetSingletonClassIndex) and its array fields cannot be set to the empty
|
| // array, but remain null.
|
| cls = Class::New<Instance>();
|
| + cls.set_is_finalized();
|
| cls.set_is_interface();
|
| dynamic_class_ = cls.raw();
|
|
|
| @@ -272,6 +274,7 @@
|
| unresolved_class_class_ = cls.raw();
|
|
|
| cls = Class::New<Instance>();
|
| + cls.set_is_finalized();
|
| void_class_ = cls.raw();
|
|
|
| cls = Class::New<ParameterizedType>();
|
| @@ -335,13 +338,33 @@
|
| }
|
|
|
|
|
| +RawClass* Object::CreateAndRegisterInterface(const char* cname,
|
| + const Script& script,
|
| + const Library& lib) {
|
| + const String& name = String::Handle(String::NewSymbol(cname));
|
| + const Class& cls = Class::Handle(Class::NewInterface(name, script));
|
| + lib.AddClass(cls);
|
| + return cls.raw();
|
| +}
|
| +
|
| +
|
| +void Object::RegisterClass(const Class& cls,
|
| + const char* cname,
|
| + const Script& script,
|
| + const Library& lib) {
|
| + const String& name = String::Handle(String::NewSymbol(cname));
|
| + cls.set_name(name);
|
| + cls.set_script(script);
|
| + lib.AddClass(cls);
|
| +}
|
| +
|
| +
|
| void Object::Init(Isolate* isolate) {
|
| TIMERSCOPE(time_bootstrap);
|
| ObjectStore* object_store = isolate->object_store();
|
|
|
| Class& cls = Class::Handle();
|
| Type& type = Type::Handle();
|
| - String& name = String::Handle();
|
| Array& array = Array::Handle();
|
|
|
| // All RawArray fields will be initialized to an empty array, therefore
|
| @@ -363,52 +386,6 @@
|
| // has been created.
|
| cls.InitEmptyFields();
|
|
|
| - cls = Class::New<ImmutableArray>();
|
| - object_store->set_immutable_array_class(cls);
|
| - cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset());
|
| -
|
| - // Allocate and initialize the object class and type.
|
| - cls = Class::New<Instance>();
|
| - object_store->set_object_class(cls);
|
| - type = Type::NewNonParameterizedType(cls);
|
| - object_store->set_object_type(type);
|
| -
|
| - cls = Class::New<Smi>();
|
| - object_store->set_smi_class(cls);
|
| -
|
| - cls = Class::New<Mint>();
|
| - object_store->set_mint_class(cls);
|
| -
|
| - cls = Class::New<Bigint>();
|
| - object_store->set_bigint_class(cls);
|
| -
|
| - cls = Class::New<Double>();
|
| - object_store->set_double_class(cls);
|
| -
|
| - cls = Class::New<OneByteString>();
|
| - object_store->set_one_byte_string_class(cls);
|
| -
|
| - cls = Class::New<TwoByteString>();
|
| - object_store->set_two_byte_string_class(cls);
|
| -
|
| - cls = Class::New<FourByteString>();
|
| - object_store->set_four_byte_string_class(cls);
|
| -
|
| - cls = Class::New<Bool>();
|
| - object_store->set_bool_class(cls);
|
| -
|
| - cls = Class::New<UnhandledException>();
|
| - object_store->set_unhandled_exception_class(cls);
|
| -
|
| - cls = Class::New<Stacktrace>();
|
| - object_store->set_stacktrace_class(cls);
|
| - // Set the super type so that the 'toString' method is implemented.
|
| - type = object_store->object_type();
|
| - cls.set_super_type(type);
|
| -
|
| - cls = Class::New<JSRegExp>();
|
| - object_store->set_jsregexp_class(cls);
|
| -
|
| // Setup the symbol table used within the String class.
|
| const int kInitialSymbolTableSize = 16;
|
| array = Array::New(kInitialSymbolTableSize + 1);
|
| @@ -416,156 +393,145 @@
|
| array.SetAt(kInitialSymbolTableSize, Smi::Handle(Smi::New(0)));
|
| object_store->set_symbol_table(array);
|
|
|
| + // Pre-allocate the OneByteString class needed by the symbol table.
|
| + cls = Class::New<OneByteString>();
|
| + object_store->set_one_byte_string_class(cls);
|
| +
|
| // Basic infrastructure has been setup, initialize the class dictionary.
|
| Library::InitCoreLibrary(isolate);
|
| - Library& core_lib = Library::Handle(isolate->object_store()->core_library());
|
| + Library& core_lib = Library::Handle(Library::CoreLibrary());
|
| ASSERT(!core_lib.IsNull());
|
| Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
|
| ASSERT(!core_impl_lib.IsNull());
|
|
|
| - // Allocate pre-initialized values.
|
| - Bool& bool_value = Bool::Handle();
|
| - bool_value = Bool::New(true);
|
| - object_store->set_true_value(bool_value);
|
| - bool_value = Bool::New(false);
|
| - object_store->set_false_value(bool_value);
|
| -
|
| object_store->set_pending_classes(Array::Handle(Array::Empty()));
|
|
|
| Context& context = Context::Handle(Context::New(0));
|
| object_store->set_empty_context(context);
|
|
|
| - // Now that the String class is initialized and the dictionary has been setup,
|
| - // add the names to preallocated classes and register them in the dictionary.
|
| + // Now that the symbol table is initialized and that the core dictionary as
|
| + // well as the core implementation dictionary have been setup, preallocate
|
| + // remaining classes and register them by name in the dictionaries.
|
| const Script& impl_script = Script::Handle(Bootstrap::LoadImplScript());
|
| + GrowableArray<const Class*> pending_classes;
|
|
|
| - name = String::NewSymbol("Smi");
|
| - cls = object_store->smi_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<Smi>();
|
| + object_store->set_smi_class(cls);
|
| + RegisterClass(cls, "Smi", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("OneByteString");
|
| - cls = object_store->one_byte_string_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<Mint>();
|
| + object_store->set_mint_class(cls);
|
| + RegisterClass(cls, "Mint", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("TwoByteString");
|
| - cls = object_store->two_byte_string_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<Bigint>();
|
| + object_store->set_bigint_class(cls);
|
| + RegisterClass(cls, "Bigint", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("FourByteString");
|
| - cls = object_store->four_byte_string_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<Double>();
|
| + object_store->set_double_class(cls);
|
| + RegisterClass(cls, "Double", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("Mint");
|
| - cls = object_store->mint_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<Bool>();
|
| + object_store->set_bool_class(cls);
|
| + RegisterClass(cls, "Bool", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("Bigint");
|
| - cls = object_store->bigint_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = object_store->array_class(); // Was allocated above.
|
| + RegisterClass(cls, "ObjectArray", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("Double");
|
| - cls = object_store->double_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<ImmutableArray>();
|
| + object_store->set_immutable_array_class(cls);
|
| + cls.set_type_arguments_instance_field_offset(Array::type_arguments_offset());
|
| + ASSERT(object_store->immutable_array_class() != object_store->array_class());
|
| + RegisterClass(cls, "ImmutableArray", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("Bool");
|
| - cls = object_store->bool_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = object_store->one_byte_string_class(); // Was allocated above.
|
| + RegisterClass(cls, "OneByteString", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("ObjectArray");
|
| - cls = object_store->array_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<TwoByteString>();
|
| + object_store->set_two_byte_string_class(cls);
|
| + RegisterClass(cls, "TwoByteString", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("ImmutableArray");
|
| - cls = object_store->immutable_array_class();
|
| - ASSERT(object_store->immutable_array_class() != object_store->array_class());
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<FourByteString>();
|
| + object_store->set_four_byte_string_class(cls);
|
| + RegisterClass(cls, "FourByteString", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("UnhandledException");
|
| - cls = object_store->unhandled_exception_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<UnhandledException>();
|
| + object_store->set_unhandled_exception_class(cls);
|
| + RegisterClass(cls, "UnhandledException", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| - name = String::NewSymbol("Stacktrace");
|
| - cls = object_store->stacktrace_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<Stacktrace>();
|
| + object_store->set_stacktrace_class(cls);
|
| + RegisterClass(cls, "Stacktrace", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| + // Super type set below, after Object is allocated.
|
|
|
| - name = String::NewSymbol("JSSyntaxRegExp");
|
| - cls = object_store->jsregexp_class();
|
| - cls.set_name(name);
|
| - cls.set_script(impl_script);
|
| - core_impl_lib.AddClass(cls);
|
| + cls = Class::New<JSRegExp>();
|
| + object_store->set_jsregexp_class(cls);
|
| + RegisterClass(cls, "JSSyntaxRegExp", impl_script, core_impl_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
|
|
| // Initialize the base interfaces used by the core VM classes.
|
| const Script& script = Script::Handle(Bootstrap::LoadScript());
|
|
|
| - name = String::NewSymbol("Object");
|
| - cls = object_store->object_class();
|
| - cls.set_name(name);
|
| + // Allocate and initialize the Object class and type.
|
| + // Object class is the only pre-allocated non-interface in the core library.
|
| + cls = Class::New<Instance>();
|
| + object_store->set_object_class(cls);
|
| + cls.set_name(String::Handle(String::NewSymbol("Object")));
|
| cls.set_script(script);
|
| core_lib.AddClass(cls);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| + type = Type::NewNonParameterizedType(cls);
|
| + object_store->set_object_type(type);
|
|
|
| - name = String::NewSymbol("Function");
|
| - cls = Class::NewInterface(name, script);
|
| - core_lib.AddClass(cls);
|
| + // Set the super type of class Stacktrace to Object type so that the
|
| + // 'toString' method is implemented.
|
| + cls = object_store->stacktrace_class();
|
| + cls.set_super_type(type);
|
| +
|
| + cls = CreateAndRegisterInterface("Function", script, core_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| type = Type::NewNonParameterizedType(cls);
|
| object_store->set_function_interface(type);
|
|
|
| - name = String::NewSymbol("num");
|
| - cls = Class::NewInterface(name, script);
|
| - core_lib.AddClass(cls);
|
| + cls = CreateAndRegisterInterface("num", script, core_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| type = Type::NewNonParameterizedType(cls);
|
| object_store->set_number_interface(type);
|
|
|
| - name = String::NewSymbol("int");
|
| - cls = Class::NewInterface(name, script);
|
| - core_lib.AddClass(cls);
|
| + cls = CreateAndRegisterInterface("int", script, core_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| type = Type::NewNonParameterizedType(cls);
|
| object_store->set_int_interface(type);
|
|
|
| - name = String::NewSymbol("double");
|
| - cls = Class::NewInterface(name, script);
|
| - core_lib.AddClass(cls);
|
| + cls = CreateAndRegisterInterface("double", script, core_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| type = Type::NewNonParameterizedType(cls);
|
| object_store->set_double_interface(type);
|
|
|
| - name = String::NewSymbol("String");
|
| - cls = Class::NewInterface(name, script);
|
| - core_lib.AddClass(cls);
|
| + cls = CreateAndRegisterInterface("String", script, core_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| type = Type::NewNonParameterizedType(cls);
|
| object_store->set_string_interface(type);
|
|
|
| - name = String::NewSymbol("bool");
|
| - cls = Class::NewInterface(name, script);
|
| - core_lib.AddClass(cls);
|
| + cls = CreateAndRegisterInterface("bool", script, core_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| type = Type::NewNonParameterizedType(cls);
|
| object_store->set_bool_interface(type);
|
|
|
| - name = String::NewSymbol("List");
|
| - cls = Class::NewInterface(name, script);
|
| - core_lib.AddClass(cls);
|
| + cls = CreateAndRegisterInterface("List", script, core_lib);
|
| + pending_classes.Add(&Class::ZoneHandle(cls.raw()));
|
| type = Type::NewNonParameterizedType(cls);
|
| object_store->set_list_interface(type);
|
|
|
| @@ -590,11 +556,21 @@
|
| object_store->set_dynamic_type(type);
|
| core_lib.AddClass(cls);
|
|
|
| - // Finish the initialization by compiling the bootstrap script containing the
|
| - // implementation of the internal classes.
|
| - Bootstrap::Compile(Library::Handle(Library::CoreLibrary()), script);
|
| - Bootstrap::Compile(Library::Handle(Library::CoreImplLibrary()), impl_script);
|
| + // Add the preallocated classes to the list of classes to be finalized.
|
| + ClassFinalizer::AddPendingClasses(pending_classes);
|
|
|
| + // Allocate pre-initialized values.
|
| + Bool& bool_value = Bool::Handle();
|
| + bool_value = Bool::New(true);
|
| + object_store->set_true_value(bool_value);
|
| + bool_value = Bool::New(false);
|
| + object_store->set_false_value(bool_value);
|
| +
|
| + // Finish the initialization by compiling the bootstrap scripts containing the
|
| + // base interfaces and the implementation of the internal classes.
|
| + Bootstrap::Compile(core_lib, script);
|
| + Bootstrap::Compile(core_impl_lib, impl_script);
|
| +
|
| Bootstrap::SetupNativeResolver();
|
|
|
| // Remove the Object superclass cycle by setting the super type to null (not
|
| @@ -713,25 +689,26 @@
|
|
|
|
|
| RawType* Class::SignatureType() const {
|
| - // Return the only canonical signature type if already computed.
|
| + // Return the first canonical signature type if already computed.
|
| const Array& signature_types = Array::Handle(canonical_types());
|
| if (signature_types.Length() > 0) {
|
| Type& signature_type = Type::Handle();
|
| signature_type ^= signature_types.At(0);
|
| if (!signature_type.IsNull()) {
|
| - // A signature class has a unique canonical signature type.
|
| - ASSERT((signature_types.Length() == 1) ||
|
| - signature_types.At(1) == Object::null());
|
| return signature_type.raw();
|
| }
|
| }
|
| ASSERT(IsSignatureClass());
|
| TypeArguments& signature_type_arguments = TypeArguments::Handle();
|
| const intptr_t num_type_params = NumTypeParameters();
|
| - // If the signature class extends a parameterized class, the type arguments of
|
| - // the super class will be prepended to the type argument vector during type
|
| - // finalization. We only need to provide the type parameters of the signature
|
| - // class here.
|
| + // A signature class extends class Instance and is parameterized in the same
|
| + // way as the owner class of its non-static signature function.
|
| + // It is not type parameterized if its signature function is static.
|
| + // See Class::NewSignatureClass() for the setup of its type parameters.
|
| + // During type finalization, the type arguments of the super class of the
|
| + // owner class of its signature function will be prepended to the type
|
| + // argument vector. Therefore, we only need to set the type arguments
|
| + // matching the type parameters here.
|
| if (num_type_params > 0) {
|
| const Array& type_params = Array::Handle(type_parameters());
|
| signature_type_arguments = TypeArguments::NewTypeArray(num_type_params);
|
| @@ -858,8 +835,16 @@
|
| intptr_t Class::NumTypeArguments() const {
|
| // To work properly, this call requires the super class of this class to be
|
| // resolved, which is checked by the SuperClass() call.
|
| + Class& cls = Class::Handle(raw());
|
| + if (IsSignatureClass()) {
|
| + const Function& signature_fun = Function::Handle(signature_function());
|
| + if (!signature_fun.is_static() &&
|
| + !signature_fun.HasInstantiatedSignature()) {
|
| + cls = signature_fun.owner();
|
| + }
|
| + }
|
| intptr_t num_type_args = NumTypeParameters();
|
| - const Class& superclass = Class::Handle(SuperClass());
|
| + const Class& superclass = Class::Handle(cls.SuperClass());
|
| // Object is its own super class during bootstrap.
|
| if (!superclass.IsNull() && (superclass.raw() != raw())) {
|
| num_type_args += superclass.NumTypeArguments();
|
| @@ -868,6 +853,17 @@
|
| }
|
|
|
|
|
| +bool Class::HasTypeArguments() const {
|
| + if (!IsSignatureClass() && (is_finalized() || is_prefinalized())) {
|
| + // More efficient than calling NumTypeArguments().
|
| + return type_arguments_instance_field_offset() != kNoTypeArguments;
|
| + } else {
|
| + // No need to check NumTypeArguments() if class has type parameters.
|
| + return (NumTypeParameters() > 0) || (NumTypeArguments() > 0);
|
| + }
|
| +}
|
| +
|
| +
|
| RawClass* Class::SuperClass() const {
|
| const Type& sup_type = Type::Handle(super_type());
|
| if (sup_type.IsNull()) {
|
| @@ -1033,42 +1029,49 @@
|
| const Function& signature_function,
|
| const Script& script) {
|
| ASSERT(!signature_function.IsNull());
|
| - Type& super_type = Type::Handle(Type::ObjectType());
|
| const Class& owner_class = Class::Handle(signature_function.owner());
|
| ASSERT(!owner_class.IsNull());
|
| Array& type_parameters = Array::Handle();
|
| TypeArray& type_parameter_extends = TypeArray::Handle();
|
| + // A signature class extends class Instance and is parameterized in the same
|
| + // way as the owner class of its non-static signature function.
|
| + // It is not type parameterized if its signature function is static.
|
| if (!signature_function.is_static()) {
|
| if ((owner_class.NumTypeParameters() > 0) &&
|
| !signature_function.HasInstantiatedSignature()) {
|
| - // Share the function owner super class as the super class of the
|
| - // signature class, so that the type argument vector of the closure at
|
| - // run time matches the type argument vector of the closure instantiator.
|
| type_parameters = owner_class.type_parameters();
|
| type_parameter_extends = owner_class.type_parameter_extends();
|
| - if (!owner_class.is_interface()) {
|
| - super_type = owner_class.super_type();
|
| - }
|
| }
|
| }
|
| Class& result = Class::Handle(New<Closure>(name, script));
|
| + const Type& super_type = Type::Handle(Type::ObjectType());
|
| + ASSERT(!super_type.IsNull());
|
| result.set_super_type(super_type);
|
| result.set_signature_function(signature_function);
|
| result.set_type_parameters(type_parameters);
|
| result.set_type_parameter_extends(type_parameter_extends);
|
| result.SetFields(Array::Handle(Array::Empty()));
|
| result.SetFunctions(Array::Handle(Array::Empty()));
|
| - // Implements interface Function.
|
| + // Implements interface "Function".
|
| const Type& function_interface = Type::Handle(Type::FunctionInterface());
|
| const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld));
|
| interfaces.SetAt(0, function_interface);
|
| result.set_interfaces(interfaces);
|
| // Unless the signature function already has a signature class, create a
|
| - // canonical signature class by having the signature function pointing back to
|
| + // canonical signature class by having the signature function point back to
|
| // the signature class.
|
| if (signature_function.signature_class() == Object::null()) {
|
| signature_function.set_signature_class(result);
|
| }
|
| + result.set_is_finalized();
|
| + // Instances of a signature class can only be closures.
|
| + ASSERT(result.instance_size() == Closure::InstanceSize());
|
| + // Cache the signature type as the first canonicalized type in result.
|
| + const Type& signature_type = Type::Handle(result.SignatureType());
|
| + ASSERT(!signature_type.IsFinalized());
|
| + const Array& new_canonical_types = Array::Handle(Array::New(1, Heap::kOld));
|
| + new_canonical_types.SetAt(0, signature_type);
|
| + result.set_canonical_types(new_canonical_types);
|
| return result.raw();
|
| }
|
|
|
| @@ -1336,6 +1339,8 @@
|
| const TypeArguments& type_arguments,
|
| const Class& other,
|
| const TypeArguments& other_type_arguments) const {
|
| + ASSERT(is_finalized() || !ClassFinalizer::AllClassesFinalized());
|
| + ASSERT(other.is_finalized() || !ClassFinalizer::AllClassesFinalized());
|
| if (test == kIsAssignableTo) {
|
| // The spec states that "a type T is assignable to a type S if T is a
|
| // subtype of S or S is a subtype of T". This is from the perspective of a
|
| @@ -1691,7 +1696,7 @@
|
| num_type_params = cls.NumTypeParameters(); // Do not print the full vector.
|
| if (num_type_params > num_args) {
|
| first_type_param_index = 0;
|
| - if (IsBeingFinalized()) {
|
| + if (!IsFinalized() || IsBeingFinalized()) {
|
| // Most probably an illformed type. Do not fill up with "Dynamic".
|
| num_type_params = num_args;
|
| } else {
|
| @@ -1704,7 +1709,7 @@
|
| if (cls.IsSignatureClass()) {
|
| // We may be reporting an error about an illformed function type. In that
|
| // case, avoid instantiating the signature, since it may lead to cycles.
|
| - if (IsBeingFinalized()) {
|
| + if (!IsFinalized() || IsBeingFinalized()) {
|
| return class_name.raw();
|
| }
|
| const Function& signature_function = Function::Handle(
|
| @@ -2007,13 +2012,11 @@
|
| intptr_t offset) const {
|
| ASSERT(IsFinalized());
|
| ASSERT(!IsInstantiated());
|
| - TypeArguments& type_arguments = TypeArguments::Handle();
|
| - if (!instantiator_type_arguments.IsNull()) {
|
| - type_arguments = arguments();
|
| - type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments,
|
| - offset);
|
| - }
|
| + TypeArguments& type_arguments = TypeArguments::Handle(arguments());
|
| + type_arguments = type_arguments.InstantiateFrom(instantiator_type_arguments,
|
| + offset);
|
| const Class& cls = Class::Handle(type_class());
|
| + ASSERT(cls.is_finalized());
|
| ParameterizedType& instantiated_type = ParameterizedType::Handle(
|
| ParameterizedType::New(cls, type_arguments));
|
| ASSERT(type_arguments.IsNull() ||
|
| @@ -2042,6 +2045,7 @@
|
|
|
|
|
| RawType* ParameterizedType::Canonicalize() const {
|
| + ASSERT(IsFinalized());
|
| const Class& cls = Class::Handle(type_class());
|
| Array& canonical_types = Array::Handle(cls.canonical_types());
|
| if (canonical_types.IsNull()) {
|
| @@ -2061,6 +2065,11 @@
|
| if (type.IsNull()) {
|
| break;
|
| }
|
| + if (!type.IsFinalized()) {
|
| + ASSERT((index == 0) && cls.IsSignatureClass());
|
| + index++;
|
| + continue;
|
| + }
|
| if (this->Equals(type)) {
|
| return type.raw();
|
| }
|
| @@ -2444,9 +2453,6 @@
|
| const TypeArguments& instantiator_type_arguments,
|
| intptr_t offset) const {
|
| ASSERT(!IsInstantiated());
|
| - if (instantiator_type_arguments.IsNull()) {
|
| - return TypeArguments::null();
|
| - }
|
| if ((offset == 0) &&
|
| !instantiator_type_arguments.IsNull() &&
|
| IsUninstantiatedIdentity() &&
|
| @@ -3136,6 +3142,12 @@
|
| } else {
|
| closure_function.set_signature_class(signature_class);
|
| }
|
| + const Type& signature_type = Type::Handle(signature_class.SignatureType());
|
| + if (!signature_type.IsFinalized()) {
|
| + String& errmsg = String::Handle();
|
| + ClassFinalizer::FinalizeAndCanonicalizeType(signature_type, &errmsg);
|
| + ASSERT(errmsg.IsNull());
|
| + }
|
| ASSERT(closure_function.signature_class() == signature_class.raw());
|
| set_implicit_closure_function(closure_function);
|
| ASSERT(closure_function.IsImplicitClosureFunction());
|
| @@ -4862,7 +4874,10 @@
|
| if (cls.HasTypeArguments()) {
|
| type_arguments = GetTypeArguments();
|
| }
|
| - return Type::NewParameterizedType(cls, type_arguments);
|
| + const ParameterizedType& type = ParameterizedType::Handle(
|
| + ParameterizedType::New(cls, type_arguments));
|
| + type.set_is_finalized();
|
| + return type.raw();
|
| }
|
|
|
|
|
|
|