Chromium Code Reviews| Index: runtime/vm/parser.cc |
| =================================================================== |
| --- runtime/vm/parser.cc (revision 383) |
| +++ runtime/vm/parser.cc (working copy) |
| @@ -2105,9 +2105,12 @@ |
| // TODO(srdjan): Implement checks in class finalization when all types have |
| // been resolved. |
| if (member.has_factory && !member.name->Equals(members->class_name())) { |
| - const TypeArguments& arguments = TypeArguments::Handle(); |
| - member.type = &Type::ZoneHandle( |
| - Type::NewParameterizedType(*member.name, arguments)); |
| + const UnresolvedClass& type = |
| + UnresolvedClass::Handle(UnresolvedClass::New(member.name_pos, |
| + String::Handle(), |
| + *(member.name))); |
| + const TypeArguments& args = TypeArguments::Handle(); |
| + member.type = &Type::ZoneHandle(Type::NewParameterizedType(type, args)); |
| } |
| ConsumeToken(); |
| // We must be dealing with a constructor or named constructor. |
| @@ -3486,8 +3489,13 @@ |
| nesting_level -= 2; |
| } else if (CurrentToken() == Token::kSHR) { |
| nesting_level -= 3; |
| + } else if (CurrentToken() == Token::kIDENT) { |
| + // Check to see if it is a qualified identifier. |
| + if (LookaheadToken(1) == Token::kPERIOD) { |
| + // Consume the identifier, the period will be consumed below. |
| + ConsumeToken(); |
| + } |
| } else if (CurrentToken() != Token::kCOMMA && |
| - CurrentToken() != Token::kIDENT && |
| CurrentToken() != Token::kEXTENDS) { |
| // We are looking at something other than type parameters. |
| return false; |
| @@ -5570,13 +5578,15 @@ |
| ASSERT(type != NULL); |
| // Resolve class. |
| if (!type->HasResolvedTypeClass()) { |
| - const String& unresolved_type_class = |
| - String::Handle(type->unresolved_type_class()); |
| + const UnresolvedClass& unresolved_class = |
| + UnresolvedClass::Handle(type->unresolved_class()); |
| + const String& unresolved_class_name = |
| + String::Handle(unresolved_class.ident()); |
| // First check if the type is a type parameter of the given class. |
| const TypeParameter& type_parameter = TypeParameter::Handle( |
| - cls.LookupTypeParameter(unresolved_type_class)); |
| + cls.LookupTypeParameter(unresolved_class_name)); |
| if (!type_parameter.IsNull()) { |
| - CheckTypeParameterReference(type_pos, unresolved_type_class); |
| + CheckTypeParameterReference(type_pos, unresolved_class_name); |
| // A type parameter cannot be parameterized, so report an error if type |
| // arguments have previously been parsed. |
| if (type->arguments() != TypeArguments::null()) { |
| @@ -5588,13 +5598,13 @@ |
| return true; |
| } |
| const Class& resolved_type_class = |
| - Class::Handle(LookupClass(unresolved_type_class)); |
| + Class::Handle(LookupClass(unresolved_class_name)); |
| if (resolved_type_class.IsNull()) { |
| return false; |
| } |
| Object& type_class = Object::Handle(resolved_type_class.raw()); |
| ASSERT(type->IsParameterizedType()); |
| - // Replace unresolved type class with resolved type class. |
| + // Replace unresolved class with resolved type class. |
| ParameterizedType& parameterized_type = ParameterizedType::Handle(); |
| parameterized_type ^= type->raw(); |
| parameterized_type.set_type_class(type_class); |
| @@ -6016,12 +6026,12 @@ |
| type_name.ident->ToCString()); |
| } |
| Object& type_class = Object::Handle(); |
| + String& qualifier = String::Handle(); |
| + if (type_name.qualifier != NULL) { |
| + qualifier ^= type_name.qualifier->raw(); |
| + } |
| if (type_resolution == kDoNotResolve) { |
| - // TODO(5072252): Figure out what should be done in this case. |
| - if (type_name.qualifier != NULL) { |
| - Unimplemented("cannot handle qualified type names yet"); |
| - } |
| - type_class = type_name.ident->raw(); |
| + type_class = UnresolvedClass::New(type_pos, qualifier, *(type_name.ident)); |
| } else { |
| TypeParameter& type_parameter = TypeParameter::Handle(); |
| // Check if qualifier is a type parameter of the class we are parsing. |
| @@ -6047,12 +6057,20 @@ |
| } |
| // Try to resolve the type class. |
| type_class = LookupTypeClass(type_name, type_resolution); |
| + if (!type_class.IsClass()) { |
| + // We have an unresolved name, create an UnresolvedClass object |
| + // for this case. |
| + type_class = UnresolvedClass::New(type_pos, |
| + qualifier, |
| + *(type_name.ident)); |
| + } |
|
regis
2011/10/13 17:23:03
Why not move the creation of the unresolved class
siva
2011/10/13 20:06:39
Good idea, Done.
On 2011/10/13 17:23:03, regis wr
|
| } |
| TypeArguments& type_arguments = |
| TypeArguments::Handle(ParseTypeArguments(type_resolution)); |
| const Type& type = Type::Handle( |
| Type::NewParameterizedType(type_class, type_arguments)); |
| if (type_resolution == kMustResolve) { |
| + ASSERT(type_class.IsClass()); // Must be resolved. |
| const String& errmsg = String::Handle( |
| ClassFinalizer::FinalizeTypeWhileParsing(type)); |
| if (!errmsg.IsNull()) { |
| @@ -6427,10 +6445,10 @@ |
| } |
| if (!factory_type.HasResolvedTypeClass()) { |
| // This error can occur only with bootstrap classes. |
| - const String& missing_class_name = |
| - String::Handle(factory_type.unresolved_type_class()); |
| - ErrorMsg("Unresolved factory class '%s'", |
| - missing_class_name.ToCString()); |
| + const UnresolvedClass& unresolved = |
| + UnresolvedClass::Handle(factory_type.unresolved_class()); |
| + const String& missing_class_name = String::Handle(unresolved.ident()); |
| + ErrorMsg("Unresolved factory class '%s'", missing_class_name.ToCString()); |
| } |
| // Only change the class of the constructor to the factory class if the |