| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 2856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2867 Type& super_type = Type::Handle(); | 2867 Type& super_type = Type::Handle(); |
| 2868 if (CurrentToken() == Token::kEXTENDS) { | 2868 if (CurrentToken() == Token::kEXTENDS) { |
| 2869 ConsumeToken(); | 2869 ConsumeToken(); |
| 2870 const intptr_t type_pos = TokenPos(); | 2870 const intptr_t type_pos = TokenPos(); |
| 2871 const AbstractType& type = AbstractType::Handle( | 2871 const AbstractType& type = AbstractType::Handle( |
| 2872 ParseType(ClassFinalizer::kTryResolve)); | 2872 ParseType(ClassFinalizer::kTryResolve)); |
| 2873 if (type.IsTypeParameter()) { | 2873 if (type.IsTypeParameter()) { |
| 2874 ErrorMsg(type_pos, | 2874 ErrorMsg(type_pos, |
| 2875 "class '%s' may not extend type parameter '%s'", | 2875 "class '%s' may not extend type parameter '%s'", |
| 2876 class_name.ToCString(), | 2876 class_name.ToCString(), |
| 2877 String::Handle(type.Name()).ToCString()); | 2877 String::Handle(type.UserVisibleName()).ToCString()); |
| 2878 } | 2878 } |
| 2879 super_type ^= type.raw(); | 2879 super_type ^= type.raw(); |
| 2880 if (super_type.IsInterfaceType()) { | 2880 if (super_type.IsInterfaceType()) { |
| 2881 ErrorMsg(type_pos, | 2881 ErrorMsg(type_pos, |
| 2882 "class '%s' may implement, but cannot extend interface '%s'", | 2882 "class '%s' may implement, but cannot extend interface '%s'", |
| 2883 class_name.ToCString(), | 2883 class_name.ToCString(), |
| 2884 String::Handle(super_type.Name()).ToCString()); | 2884 String::Handle(super_type.UserVisibleName()).ToCString()); |
| 2885 } | 2885 } |
| 2886 } else { | 2886 } else { |
| 2887 // No extends clause: Implicitly extend Object. | 2887 // No extends clause: Implicitly extend Object. |
| 2888 super_type = Type::ObjectType(); | 2888 super_type = Type::ObjectType(); |
| 2889 } | 2889 } |
| 2890 ASSERT(!super_type.IsNull()); | 2890 ASSERT(!super_type.IsNull()); |
| 2891 cls.set_super_type(super_type); | 2891 cls.set_super_type(super_type); |
| 2892 | 2892 |
| 2893 if (CurrentToken() == Token::kIMPLEMENTS) { | 2893 if (CurrentToken() == Token::kIMPLEMENTS) { |
| 2894 Array& interfaces = Array::Handle(); | 2894 Array& interfaces = Array::Handle(); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3277 do { | 3277 do { |
| 3278 ConsumeToken(); | 3278 ConsumeToken(); |
| 3279 if (CurrentToken() != Token::kIDENT) { | 3279 if (CurrentToken() != Token::kIDENT) { |
| 3280 ErrorMsg("type parameter name expected"); | 3280 ErrorMsg("type parameter name expected"); |
| 3281 } | 3281 } |
| 3282 String& type_parameter_name = *CurrentLiteral(); | 3282 String& type_parameter_name = *CurrentLiteral(); |
| 3283 const intptr_t type_parameter_pos = TokenPos(); | 3283 const intptr_t type_parameter_pos = TokenPos(); |
| 3284 // Check for duplicate type parameters. | 3284 // Check for duplicate type parameters. |
| 3285 for (intptr_t i = 0; i < index; i++) { | 3285 for (intptr_t i = 0; i < index; i++) { |
| 3286 existing_type_parameter ^= type_parameters_array.At(i); | 3286 existing_type_parameter ^= type_parameters_array.At(i); |
| 3287 existing_type_parameter_name = existing_type_parameter.Name(); | 3287 existing_type_parameter_name = existing_type_parameter.name(); |
| 3288 if (existing_type_parameter_name.Equals(type_parameter_name)) { | 3288 if (existing_type_parameter_name.Equals(type_parameter_name)) { |
| 3289 ErrorMsg("duplicate type parameter '%s'", | 3289 ErrorMsg("duplicate type parameter '%s'", |
| 3290 type_parameter_name.ToCString()); | 3290 type_parameter_name.ToCString()); |
| 3291 } | 3291 } |
| 3292 } | 3292 } |
| 3293 ConsumeToken(); | 3293 ConsumeToken(); |
| 3294 if (CurrentToken() == Token::kEXTENDS) { | 3294 if (CurrentToken() == Token::kEXTENDS) { |
| 3295 ConsumeToken(); | 3295 ConsumeToken(); |
| 3296 // A bound may refer to the owner of the type parameter it applies to, | 3296 // A bound may refer to the owner of the type parameter it applies to, |
| 3297 // i.e. to the class or interface currently being parsed. | 3297 // i.e. to the class or interface currently being parsed. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3375 ASSERT((CurrentToken() == Token::kIMPLEMENTS) || | 3375 ASSERT((CurrentToken() == Token::kIMPLEMENTS) || |
| 3376 (CurrentToken() == Token::kEXTENDS)); | 3376 (CurrentToken() == Token::kEXTENDS)); |
| 3377 const GrowableObjectArray& interfaces = | 3377 const GrowableObjectArray& interfaces = |
| 3378 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 3378 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
| 3379 String& interface_name = String::Handle(); | 3379 String& interface_name = String::Handle(); |
| 3380 AbstractType& interface = AbstractType::Handle(); | 3380 AbstractType& interface = AbstractType::Handle(); |
| 3381 String& other_name = String::Handle(); | 3381 String& other_name = String::Handle(); |
| 3382 AbstractType& other_interface = AbstractType::Handle(); | 3382 AbstractType& other_interface = AbstractType::Handle(); |
| 3383 do { | 3383 do { |
| 3384 ConsumeToken(); | 3384 ConsumeToken(); |
| 3385 intptr_t supertype_pos = TokenPos(); | 3385 intptr_t interface_pos = TokenPos(); |
| 3386 interface = ParseType(ClassFinalizer::kTryResolve); | 3386 interface = ParseType(ClassFinalizer::kTryResolve); |
| 3387 interface_name = interface.Name(); | 3387 interface_name = interface.UserVisibleName(); |
| 3388 for (int i = 0; i < interfaces.Length(); i++) { | 3388 for (int i = 0; i < interfaces.Length(); i++) { |
| 3389 other_interface ^= interfaces.At(i); | 3389 other_interface ^= interfaces.At(i); |
| 3390 other_name = other_interface.Name(); | 3390 other_name = other_interface.UserVisibleName(); |
| 3391 if (interface_name.Equals(other_name)) { | 3391 if (interface_name.Equals(other_name)) { |
| 3392 ErrorMsg(supertype_pos, "Duplicate supertype '%s'", | 3392 ErrorMsg(interface_pos, "duplicate interface '%s'", |
| 3393 interface_name.ToCString()); | 3393 interface_name.ToCString()); |
| 3394 } | 3394 } |
| 3395 } | 3395 } |
| 3396 interfaces.Add(interface); | 3396 interfaces.Add(interface); |
| 3397 } while (CurrentToken() == Token::kCOMMA); | 3397 } while (CurrentToken() == Token::kCOMMA); |
| 3398 return Array::MakeArray(interfaces); | 3398 return Array::MakeArray(interfaces); |
| 3399 } | 3399 } |
| 3400 | 3400 |
| 3401 | 3401 |
| 3402 void Parser::AddInterfaces(intptr_t interfaces_pos, | 3402 void Parser::AddInterfaces(intptr_t interfaces_pos, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3414 // Now add the new interfaces. | 3414 // Now add the new interfaces. |
| 3415 AbstractType& conflicting = AbstractType::Handle(); | 3415 AbstractType& conflicting = AbstractType::Handle(); |
| 3416 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 3416 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
| 3417 AbstractType& interface = AbstractType::ZoneHandle(); | 3417 AbstractType& interface = AbstractType::ZoneHandle(); |
| 3418 interface ^= interfaces.At(i); | 3418 interface ^= interfaces.At(i); |
| 3419 if (interface.IsTypeParameter()) { | 3419 if (interface.IsTypeParameter()) { |
| 3420 if (cls.is_interface()) { | 3420 if (cls.is_interface()) { |
| 3421 ErrorMsg(interfaces_pos, | 3421 ErrorMsg(interfaces_pos, |
| 3422 "interface '%s' may not extend type parameter '%s'", | 3422 "interface '%s' may not extend type parameter '%s'", |
| 3423 String::Handle(cls.Name()).ToCString(), | 3423 String::Handle(cls.Name()).ToCString(), |
| 3424 String::Handle(interface.Name()).ToCString()); | 3424 String::Handle(interface.UserVisibleName()).ToCString()); |
| 3425 } else { | 3425 } else { |
| 3426 ErrorMsg(interfaces_pos, | 3426 ErrorMsg(interfaces_pos, |
| 3427 "class '%s' may not implement type parameter '%s'", | 3427 "class '%s' may not implement type parameter '%s'", |
| 3428 String::Handle(cls.Name()).ToCString(), | 3428 String::Handle(cls.Name()).ToCString(), |
| 3429 String::Handle(interface.Name()).ToCString()); | 3429 String::Handle(interface.UserVisibleName()).ToCString()); |
| 3430 } | 3430 } |
| 3431 } | 3431 } |
| 3432 if (!ClassFinalizer::AddInterfaceIfUnique(all_interfaces, | 3432 if (!ClassFinalizer::AddInterfaceIfUnique(all_interfaces, |
| 3433 interface, | 3433 interface, |
| 3434 &conflicting)) { | 3434 &conflicting)) { |
| 3435 ASSERT(!conflicting.IsNull()); | 3435 ASSERT(!conflicting.IsNull()); |
| 3436 ErrorMsg(interfaces_pos, | 3436 ErrorMsg(interfaces_pos, |
| 3437 "interface '%s' conflicts with interface '%s'", | 3437 "interface '%s' conflicts with interface '%s'", |
| 3438 String::Handle(interface.Name()).ToCString(), | 3438 String::Handle(interface.UserVisibleName()).ToCString(), |
| 3439 String::Handle(conflicting.Name()).ToCString()); | 3439 String::Handle(conflicting.UserVisibleName()).ToCString()); |
| 3440 } | 3440 } |
| 3441 } | 3441 } |
| 3442 cls_interfaces = Array::MakeArray(all_interfaces); | 3442 cls_interfaces = Array::MakeArray(all_interfaces); |
| 3443 cls.set_interfaces(cls_interfaces); | 3443 cls.set_interfaces(cls_interfaces); |
| 3444 } | 3444 } |
| 3445 | 3445 |
| 3446 | 3446 |
| 3447 void Parser::ParseTopLevelVariable(TopLevel* top_level) { | 3447 void Parser::ParseTopLevelVariable(TopLevel* top_level) { |
| 3448 TRACE_PARSER("ParseTopLevelVariable"); | 3448 TRACE_PARSER("ParseTopLevelVariable"); |
| 3449 const bool is_final = (CurrentToken() == Token::kFINAL); | 3449 const bool is_final = (CurrentToken() == Token::kFINAL); |
| (...skipping 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6859 // First check if the type is a type parameter of the given scope class. | 6859 // First check if the type is a type parameter of the given scope class. |
| 6860 const TypeParameter& type_parameter = TypeParameter::Handle( | 6860 const TypeParameter& type_parameter = TypeParameter::Handle( |
| 6861 scope_class.LookupTypeParameter(unresolved_class_name, | 6861 scope_class.LookupTypeParameter(unresolved_class_name, |
| 6862 type->token_pos())); | 6862 type->token_pos())); |
| 6863 if (!type_parameter.IsNull()) { | 6863 if (!type_parameter.IsNull()) { |
| 6864 // A type parameter cannot be parameterized, so report an error if | 6864 // A type parameter cannot be parameterized, so report an error if |
| 6865 // type arguments have previously been parsed. | 6865 // type arguments have previously been parsed. |
| 6866 if (!AbstractTypeArguments::Handle(type->arguments()).IsNull()) { | 6866 if (!AbstractTypeArguments::Handle(type->arguments()).IsNull()) { |
| 6867 ErrorMsg(type_parameter.token_pos(), | 6867 ErrorMsg(type_parameter.token_pos(), |
| 6868 "type parameter '%s' cannot be parameterized", | 6868 "type parameter '%s' cannot be parameterized", |
| 6869 String::Handle(type_parameter.Name()).ToCString()); | 6869 String::Handle(type_parameter.name()).ToCString()); |
| 6870 } | 6870 } |
| 6871 *type = type_parameter.raw(); | 6871 *type = type_parameter.raw(); |
| 6872 return; | 6872 return; |
| 6873 } | 6873 } |
| 6874 } | 6874 } |
| 6875 // Global lookup in current library. | 6875 // Global lookup in current library. |
| 6876 resolved_type_class = library_.LookupClass(unresolved_class_name); | 6876 resolved_type_class = library_.LookupClass(unresolved_class_name); |
| 6877 } else { | 6877 } else { |
| 6878 LibraryPrefix& lib_prefix = | 6878 LibraryPrefix& lib_prefix = |
| 6879 LibraryPrefix::Handle(unresolved_class.library_prefix()); | 6879 LibraryPrefix::Handle(unresolved_class.library_prefix()); |
| 6880 // Local lookup in library prefix scope. | 6880 // Local lookup in library prefix scope. |
| 6881 resolved_type_class = lib_prefix.LookupLocalClass(unresolved_class_name); | 6881 resolved_type_class = lib_prefix.LookupLocalClass(unresolved_class_name); |
| 6882 } | 6882 } |
| 6883 // At this point, we can only have a parameterized_type. | 6883 // At this point, we can only have a parameterized_type. |
| 6884 Type& parameterized_type = Type::Handle(); | 6884 Type& parameterized_type = Type::Handle(); |
| 6885 parameterized_type ^= type->raw(); | 6885 parameterized_type ^= type->raw(); |
| 6886 if (!resolved_type_class.IsNull()) { | 6886 if (!resolved_type_class.IsNull()) { |
| 6887 // Replace unresolved class with resolved type class. | 6887 // Replace unresolved class with resolved type class. |
| 6888 parameterized_type.set_type_class(resolved_type_class); | 6888 parameterized_type.set_type_class(resolved_type_class); |
| 6889 } else if (finalization >= ClassFinalizer::kCanonicalize) { | 6889 } else if (finalization >= ClassFinalizer::kCanonicalize) { |
| 6890 // The type is malformed. | 6890 // The type is malformed. |
| 6891 ClassFinalizer::FinalizeMalformedType( | 6891 ClassFinalizer::FinalizeMalformedType( |
| 6892 Error::Handle(), // No previous error. | 6892 Error::Handle(), // No previous error. |
| 6893 current_class(), parameterized_type, finalization, | 6893 current_class(), parameterized_type, finalization, |
| 6894 "type '%s' is not loaded", | 6894 "type '%s' is not loaded", |
| 6895 String::Handle(parameterized_type.Name()).ToCString()); | 6895 String::Handle(parameterized_type.UserVisibleName()).ToCString()); |
| 6896 } | 6896 } |
| 6897 } | 6897 } |
| 6898 // Resolve type arguments, if any. | 6898 // Resolve type arguments, if any. |
| 6899 const AbstractTypeArguments& arguments = | 6899 const AbstractTypeArguments& arguments = |
| 6900 AbstractTypeArguments::Handle(type->arguments()); | 6900 AbstractTypeArguments::Handle(type->arguments()); |
| 6901 if (!arguments.IsNull()) { | 6901 if (!arguments.IsNull()) { |
| 6902 const intptr_t num_arguments = arguments.Length(); | 6902 const intptr_t num_arguments = arguments.Length(); |
| 6903 for (intptr_t i = 0; i < num_arguments; i++) { | 6903 for (intptr_t i = 0; i < num_arguments; i++) { |
| 6904 AbstractType& type_argument = AbstractType::Handle(arguments.TypeAt(i)); | 6904 AbstractType& type_argument = AbstractType::Handle(arguments.TypeAt(i)); |
| 6905 ResolveTypeFromClass(scope_class, finalization, &type_argument); | 6905 ResolveTypeFromClass(scope_class, finalization, &type_argument); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7315 AstNode* resolved = NULL; | 7315 AstNode* resolved = NULL; |
| 7316 ResolveIdentInLocalScope(ident_pos, ident, &resolved); | 7316 ResolveIdentInLocalScope(ident_pos, ident, &resolved); |
| 7317 if (resolved == NULL) { | 7317 if (resolved == NULL) { |
| 7318 // Check whether the identifier is a type parameter. Type parameters | 7318 // Check whether the identifier is a type parameter. Type parameters |
| 7319 // can never be used in primary expressions. | 7319 // can never be used in primary expressions. |
| 7320 const Class& scope_class = Class::Handle(TypeParametersScopeClass()); | 7320 const Class& scope_class = Class::Handle(TypeParametersScopeClass()); |
| 7321 if (!scope_class.IsNull()) { | 7321 if (!scope_class.IsNull()) { |
| 7322 TypeParameter& type_param = TypeParameter::Handle( | 7322 TypeParameter& type_param = TypeParameter::Handle( |
| 7323 scope_class.LookupTypeParameter(ident, ident_pos)); | 7323 scope_class.LookupTypeParameter(ident, ident_pos)); |
| 7324 if (!type_param.IsNull()) { | 7324 if (!type_param.IsNull()) { |
| 7325 String& type_param_name = String::Handle(type_param.Name()); | 7325 String& type_param_name = String::Handle(type_param.name()); |
| 7326 ErrorMsg(ident_pos, "illegal use of type parameter %s", | 7326 ErrorMsg(ident_pos, "illegal use of type parameter %s", |
| 7327 type_param_name.ToCString()); | 7327 type_param_name.ToCString()); |
| 7328 } | 7328 } |
| 7329 } | 7329 } |
| 7330 // Not found in the local scope, and the name is not a type parameter. | 7330 // Not found in the local scope, and the name is not a type parameter. |
| 7331 // Try finding the variable in the library scope (current library | 7331 // Try finding the variable in the library scope (current library |
| 7332 // and all libraries imported by it). | 7332 // and all libraries imported by it). |
| 7333 QualIdent qual_ident; | 7333 QualIdent qual_ident; |
| 7334 qual_ident.lib_prefix = NULL; | 7334 qual_ident.lib_prefix = NULL; |
| 7335 qual_ident.ident_pos = ident_pos; | 7335 qual_ident.ident_pos = ident_pos; |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7553 !elem->AsLiteralNode()->literal().IsInstanceOf( | 7553 !elem->AsLiteralNode()->literal().IsInstanceOf( |
| 7554 element_type, TypeArguments::Handle(), &malformed_error))) { | 7554 element_type, TypeArguments::Handle(), &malformed_error))) { |
| 7555 // If the failure is due to a malformed type error, display it instead. | 7555 // If the failure is due to a malformed type error, display it instead. |
| 7556 if (!malformed_error.IsNull()) { | 7556 if (!malformed_error.IsNull()) { |
| 7557 ErrorMsg(malformed_error); | 7557 ErrorMsg(malformed_error); |
| 7558 } else { | 7558 } else { |
| 7559 ErrorMsg(elem->AsLiteralNode()->token_pos(), | 7559 ErrorMsg(elem->AsLiteralNode()->token_pos(), |
| 7560 "list literal element at index %d must be " | 7560 "list literal element at index %d must be " |
| 7561 "a constant of type '%s'", | 7561 "a constant of type '%s'", |
| 7562 i, | 7562 i, |
| 7563 String::Handle(element_type.Name()).ToCString()); | 7563 String::Handle(element_type.UserVisibleName()).ToCString()); |
| 7564 } | 7564 } |
| 7565 } | 7565 } |
| 7566 const_list.SetAt(i, elem->AsLiteralNode()->literal()); | 7566 const_list.SetAt(i, elem->AsLiteralNode()->literal()); |
| 7567 } | 7567 } |
| 7568 const_list ^= const_list.Canonicalize(); | 7568 const_list ^= const_list.Canonicalize(); |
| 7569 const_list.MakeImmutable(); | 7569 const_list.MakeImmutable(); |
| 7570 return new LiteralNode(literal_pos, const_list); | 7570 return new LiteralNode(literal_pos, const_list); |
| 7571 } else { | 7571 } else { |
| 7572 // Factory call at runtime. | 7572 // Factory call at runtime. |
| 7573 String& list_literal_factory_class_name = String::Handle( | 7573 String& list_literal_factory_class_name = String::Handle( |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7752 !arg->AsLiteralNode()->literal().IsInstanceOf( | 7752 !arg->AsLiteralNode()->literal().IsInstanceOf( |
| 7753 value_type, TypeArguments::Handle(), &malformed_error))) { | 7753 value_type, TypeArguments::Handle(), &malformed_error))) { |
| 7754 // If the failure is due to a malformed type error, display it instead. | 7754 // If the failure is due to a malformed type error, display it instead. |
| 7755 if (!malformed_error.IsNull()) { | 7755 if (!malformed_error.IsNull()) { |
| 7756 ErrorMsg(malformed_error); | 7756 ErrorMsg(malformed_error); |
| 7757 } else { | 7757 } else { |
| 7758 ErrorMsg(arg->AsLiteralNode()->token_pos(), | 7758 ErrorMsg(arg->AsLiteralNode()->token_pos(), |
| 7759 "map literal value at index %d must be " | 7759 "map literal value at index %d must be " |
| 7760 "a constant of type '%s'", | 7760 "a constant of type '%s'", |
| 7761 i >> 1, | 7761 i >> 1, |
| 7762 String::Handle(value_type.Name()).ToCString()); | 7762 String::Handle(value_type.UserVisibleName()).ToCString()); |
| 7763 } | 7763 } |
| 7764 } | 7764 } |
| 7765 key_value_array.SetAt(i, arg->AsLiteralNode()->literal()); | 7765 key_value_array.SetAt(i, arg->AsLiteralNode()->literal()); |
| 7766 } | 7766 } |
| 7767 key_value_array ^= key_value_array.Canonicalize(); | 7767 key_value_array ^= key_value_array.Canonicalize(); |
| 7768 key_value_array.MakeImmutable(); | 7768 key_value_array.MakeImmutable(); |
| 7769 | 7769 |
| 7770 // Construct the map object. | 7770 // Construct the map object. |
| 7771 const String& immutable_map_class_name = | 7771 const String& immutable_map_class_name = |
| 7772 String::Handle(String::NewSymbol(kImmutableMapName)); | 7772 String::Handle(String::NewSymbol(kImmutableMapName)); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7878 intptr_t type_pos = TokenPos(); | 7878 intptr_t type_pos = TokenPos(); |
| 7879 const AbstractType& type = AbstractType::Handle( | 7879 const AbstractType& type = AbstractType::Handle( |
| 7880 ParseType(ClassFinalizer::kCanonicalizeWellFormed)); | 7880 ParseType(ClassFinalizer::kCanonicalizeWellFormed)); |
| 7881 // Malformed bounds never result in a compile time error, therefore, the | 7881 // Malformed bounds never result in a compile time error, therefore, the |
| 7882 // parsed type may be malformed although we requested kCanonicalizeWellFormed. | 7882 // parsed type may be malformed although we requested kCanonicalizeWellFormed. |
| 7883 // In that case, we throw a dynamic type error instead of calling the | 7883 // In that case, we throw a dynamic type error instead of calling the |
| 7884 // constructor. | 7884 // constructor. |
| 7885 if (type.IsTypeParameter()) { | 7885 if (type.IsTypeParameter()) { |
| 7886 ErrorMsg(type_pos, | 7886 ErrorMsg(type_pos, |
| 7887 "type parameter '%s' cannot be instantiated", | 7887 "type parameter '%s' cannot be instantiated", |
| 7888 String::Handle(type.Name()).ToCString()); | 7888 String::Handle(type.UserVisibleName()).ToCString()); |
| 7889 } | 7889 } |
| 7890 if (type.IsDynamicType()) { | 7890 if (type.IsDynamicType()) { |
| 7891 ErrorMsg(type_pos, "Dynamic cannot be instantiated"); | 7891 ErrorMsg(type_pos, "Dynamic cannot be instantiated"); |
| 7892 } | 7892 } |
| 7893 Class& type_class = Class::Handle(type.type_class()); | 7893 Class& type_class = Class::Handle(type.type_class()); |
| 7894 String& type_class_name = String::Handle(type_class.Name()); | 7894 String& type_class_name = String::Handle(type_class.Name()); |
| 7895 AbstractTypeArguments& type_arguments = | 7895 AbstractTypeArguments& type_arguments = |
| 7896 AbstractTypeArguments::ZoneHandle(type.arguments()); | 7896 AbstractTypeArguments::ZoneHandle(type.arguments()); |
| 7897 | 7897 |
| 7898 // The constructor class and its name are those of the parsed type, unless the | 7898 // The constructor class and its name are those of the parsed type, unless the |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8276 *qual_ident.ident, | 8276 *qual_ident.ident, |
| 8277 &primary)) { | 8277 &primary)) { |
| 8278 // Check whether the identifier is a type parameter. Type parameters | 8278 // Check whether the identifier is a type parameter. Type parameters |
| 8279 // can never be used as part of primary expressions. | 8279 // can never be used as part of primary expressions. |
| 8280 const Class& scope_class = Class::Handle(TypeParametersScopeClass()); | 8280 const Class& scope_class = Class::Handle(TypeParametersScopeClass()); |
| 8281 if (!scope_class.IsNull()) { | 8281 if (!scope_class.IsNull()) { |
| 8282 TypeParameter& type_param = TypeParameter::ZoneHandle( | 8282 TypeParameter& type_param = TypeParameter::ZoneHandle( |
| 8283 scope_class.LookupTypeParameter(*(qual_ident.ident), | 8283 scope_class.LookupTypeParameter(*(qual_ident.ident), |
| 8284 TokenPos())); | 8284 TokenPos())); |
| 8285 if (!type_param.IsNull()) { | 8285 if (!type_param.IsNull()) { |
| 8286 String& type_param_name = String::Handle(type_param.Name()); | 8286 const String& type_param_name = String::Handle(type_param.name()); |
| 8287 ErrorMsg(qual_ident.ident_pos, | 8287 ErrorMsg(qual_ident.ident_pos, |
| 8288 "illegal use of type parameter %s", | 8288 "illegal use of type parameter %s", |
| 8289 type_param_name.ToCString()); | 8289 type_param_name.ToCString()); |
| 8290 } | 8290 } |
| 8291 } | 8291 } |
| 8292 // This is a non-local unqualified identifier so resolve the | 8292 // This is a non-local unqualified identifier so resolve the |
| 8293 // identifier locally in the main app library and all libraries | 8293 // identifier locally in the main app library and all libraries |
| 8294 // imported by it. | 8294 // imported by it. |
| 8295 primary = ResolveIdentInLibraryScope(library_, | 8295 primary = ResolveIdentInLibraryScope(library_, |
| 8296 qual_ident, | 8296 qual_ident, |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8659 void Parser::SkipQualIdent() { | 8659 void Parser::SkipQualIdent() { |
| 8660 ASSERT(IsIdentifier()); | 8660 ASSERT(IsIdentifier()); |
| 8661 ConsumeToken(); | 8661 ConsumeToken(); |
| 8662 if (CurrentToken() == Token::kPERIOD) { | 8662 if (CurrentToken() == Token::kPERIOD) { |
| 8663 ConsumeToken(); // Consume the kPERIOD token. | 8663 ConsumeToken(); // Consume the kPERIOD token. |
| 8664 ExpectIdentifier("identifier expected after '.'"); | 8664 ExpectIdentifier("identifier expected after '.'"); |
| 8665 } | 8665 } |
| 8666 } | 8666 } |
| 8667 | 8667 |
| 8668 } // namespace dart | 8668 } // namespace dart |
| OLD | NEW |