| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2505 class_name.ToCString()); | 2505 class_name.ToCString()); |
| 2506 } | 2506 } |
| 2507 } | 2507 } |
| 2508 ASSERT(!cls.IsNull()); | 2508 ASSERT(!cls.IsNull()); |
| 2509 ASSERT(cls.functions() == Array::Empty()); | 2509 ASSERT(cls.functions() == Array::Empty()); |
| 2510 set_current_class(cls); | 2510 set_current_class(cls); |
| 2511 ParseTypeParameters(cls); | 2511 ParseTypeParameters(cls); |
| 2512 Type& super_type = Type::Handle(); | 2512 Type& super_type = Type::Handle(); |
| 2513 if (CurrentToken() == Token::kEXTENDS) { | 2513 if (CurrentToken() == Token::kEXTENDS) { |
| 2514 ConsumeToken(); | 2514 ConsumeToken(); |
| 2515 super_type ^= ParseType(kCanResolve); | 2515 const intptr_t type_pos = token_index_; |
| 2516 const AbstractType& type = AbstractType::Handle(ParseType(kCanResolve)); |
| 2517 if (type.IsTypeParameter()) { |
| 2518 ErrorMsg(type_pos, |
| 2519 "class '%s' may not extend type parameter '%s'", |
| 2520 class_name.ToCString(), |
| 2521 String::Handle(type.Name()).ToCString()); |
| 2522 } |
| 2523 super_type ^= type.raw(); |
| 2516 if (super_type.IsInterfaceType()) { | 2524 if (super_type.IsInterfaceType()) { |
| 2517 ErrorMsg("class '%s' may implement, but cannot extend interface '%s'", | 2525 ErrorMsg(type_pos, |
| 2526 "class '%s' may implement, but cannot extend interface '%s'", |
| 2518 class_name.ToCString(), | 2527 class_name.ToCString(), |
| 2519 String::Handle(super_type.Name()).ToCString()); | 2528 String::Handle(super_type.Name()).ToCString()); |
| 2520 } | 2529 } |
| 2521 } else { | 2530 } else { |
| 2522 // No extends clause: Implicitly extend Object. | 2531 // No extends clause: Implicitly extend Object. |
| 2523 super_type = Type::ObjectType(); | 2532 super_type = Type::ObjectType(); |
| 2524 } | 2533 } |
| 2525 ASSERT(!super_type.IsNull()); | 2534 ASSERT(!super_type.IsNull()); |
| 2526 cls.set_super_type(super_type); | 2535 cls.set_super_type(super_type); |
| 2527 | 2536 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2997 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) { | 3006 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) { |
| 2998 AbstractType& interface = AbstractType::ZoneHandle(); | 3007 AbstractType& interface = AbstractType::ZoneHandle(); |
| 2999 interface ^= cls_interfaces.At(i); | 3008 interface ^= cls_interfaces.At(i); |
| 3000 all_interfaces.Add(&interface); | 3009 all_interfaces.Add(&interface); |
| 3001 } | 3010 } |
| 3002 // Now add the new interfaces. | 3011 // Now add the new interfaces. |
| 3003 AbstractType& conflicting = AbstractType::Handle(); | 3012 AbstractType& conflicting = AbstractType::Handle(); |
| 3004 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 3013 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
| 3005 AbstractType& interface = AbstractType::ZoneHandle(); | 3014 AbstractType& interface = AbstractType::ZoneHandle(); |
| 3006 interface ^= interfaces.At(i); | 3015 interface ^= interfaces.At(i); |
| 3016 if (interface.IsTypeParameter()) { |
| 3017 if (cls.is_interface()) { |
| 3018 ErrorMsg(interfaces_pos, |
| 3019 "interface '%s' may not extend type parameter '%s'", |
| 3020 String::Handle(cls.Name()).ToCString(), |
| 3021 String::Handle(interface.Name()).ToCString()); |
| 3022 } else { |
| 3023 ErrorMsg(interfaces_pos, |
| 3024 "class '%s' may not implement type parameter '%s'", |
| 3025 String::Handle(cls.Name()).ToCString(), |
| 3026 String::Handle(interface.Name()).ToCString()); |
| 3027 } |
| 3028 } |
| 3007 if (!ClassFinalizer::AddInterfaceIfUnique(&all_interfaces, | 3029 if (!ClassFinalizer::AddInterfaceIfUnique(&all_interfaces, |
| 3008 &interface, | 3030 &interface, |
| 3009 &conflicting)) { | 3031 &conflicting)) { |
| 3010 ASSERT(!conflicting.IsNull()); | 3032 ASSERT(!conflicting.IsNull()); |
| 3011 ErrorMsg(interfaces_pos, | 3033 ErrorMsg(interfaces_pos, |
| 3012 "interface '%s' conflicts with interface '%s'", | 3034 "interface '%s' conflicts with interface '%s'", |
| 3013 String::Handle(interface.Name()).ToCString(), | 3035 String::Handle(interface.Name()).ToCString(), |
| 3014 String::Handle(conflicting.Name()).ToCString()); | 3036 String::Handle(conflicting.Name()).ToCString()); |
| 3015 } | 3037 } |
| 3016 } | 3038 } |
| (...skipping 4687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7704 } | 7726 } |
| 7705 | 7727 |
| 7706 | 7728 |
| 7707 void Parser::SkipNestedExpr() { | 7729 void Parser::SkipNestedExpr() { |
| 7708 const bool saved_mode = SetAllowFunctionLiterals(true); | 7730 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 7709 SkipExpr(); | 7731 SkipExpr(); |
| 7710 SetAllowFunctionLiterals(saved_mode); | 7732 SetAllowFunctionLiterals(saved_mode); |
| 7711 } | 7733 } |
| 7712 | 7734 |
| 7713 } // namespace dart | 7735 } // namespace dart |
| OLD | NEW |