Chromium Code Reviews| 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 AbstractType& type = AbstractType::Handle(ParseType(kCanResolve)); |
| 2516 if (type.IsTypeParameter()) { | |
| 2517 ErrorMsg("class '%s' may not extend type parameter '%s'", | |
|
hausner
2012/01/09 18:54:49
I would print the error at the actual text positio
regis
2012/01/09 19:19:30
Done here and on line 2523 below.
| |
| 2518 class_name.ToCString(), | |
| 2519 String::Handle(type.Name()).ToCString()); | |
| 2520 } | |
| 2521 super_type ^= type.raw(); | |
| 2516 if (super_type.IsInterfaceType()) { | 2522 if (super_type.IsInterfaceType()) { |
| 2517 ErrorMsg("class '%s' may implement, but cannot extend interface '%s'", | 2523 ErrorMsg("class '%s' may implement, but cannot extend interface '%s'", |
| 2518 class_name.ToCString(), | 2524 class_name.ToCString(), |
| 2519 String::Handle(super_type.Name()).ToCString()); | 2525 String::Handle(super_type.Name()).ToCString()); |
| 2520 } | 2526 } |
| 2521 } else { | 2527 } else { |
| 2522 // No extends clause: Implicitly extend Object. | 2528 // No extends clause: Implicitly extend Object. |
| 2523 super_type = Type::ObjectType(); | 2529 super_type = Type::ObjectType(); |
| 2524 } | 2530 } |
| 2525 ASSERT(!super_type.IsNull()); | 2531 ASSERT(!super_type.IsNull()); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2997 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) { | 3003 for (intptr_t i = 0; i < cls_interfaces.Length(); i++) { |
| 2998 AbstractType& interface = AbstractType::ZoneHandle(); | 3004 AbstractType& interface = AbstractType::ZoneHandle(); |
| 2999 interface ^= cls_interfaces.At(i); | 3005 interface ^= cls_interfaces.At(i); |
| 3000 all_interfaces.Add(&interface); | 3006 all_interfaces.Add(&interface); |
| 3001 } | 3007 } |
| 3002 // Now add the new interfaces. | 3008 // Now add the new interfaces. |
| 3003 AbstractType& conflicting = AbstractType::Handle(); | 3009 AbstractType& conflicting = AbstractType::Handle(); |
| 3004 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 3010 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
| 3005 AbstractType& interface = AbstractType::ZoneHandle(); | 3011 AbstractType& interface = AbstractType::ZoneHandle(); |
| 3006 interface ^= interfaces.At(i); | 3012 interface ^= interfaces.At(i); |
| 3013 if (interface.IsTypeParameter()) { | |
| 3014 if (cls.is_interface()) { | |
| 3015 ErrorMsg("interface '%s' may not extend type parameter '%s'", | |
|
hausner
2012/01/09 18:54:49
Would be nice if these error messages were pointin
regis
2012/01/09 19:19:30
We should definitely store the position in each ty
| |
| 3016 String::Handle(cls.Name()).ToCString(), | |
| 3017 String::Handle(interface.Name()).ToCString()); | |
| 3018 } else { | |
| 3019 ErrorMsg("class '%s' may not implement type parameter '%s'", | |
| 3020 String::Handle(cls.Name()).ToCString(), | |
| 3021 String::Handle(interface.Name()).ToCString()); | |
| 3022 } | |
| 3023 } | |
| 3007 if (!ClassFinalizer::AddInterfaceIfUnique(&all_interfaces, | 3024 if (!ClassFinalizer::AddInterfaceIfUnique(&all_interfaces, |
| 3008 &interface, | 3025 &interface, |
| 3009 &conflicting)) { | 3026 &conflicting)) { |
| 3010 ASSERT(!conflicting.IsNull()); | 3027 ASSERT(!conflicting.IsNull()); |
| 3011 ErrorMsg(interfaces_pos, | 3028 ErrorMsg(interfaces_pos, |
| 3012 "interface '%s' conflicts with interface '%s'", | 3029 "interface '%s' conflicts with interface '%s'", |
| 3013 String::Handle(interface.Name()).ToCString(), | 3030 String::Handle(interface.Name()).ToCString(), |
| 3014 String::Handle(conflicting.Name()).ToCString()); | 3031 String::Handle(conflicting.Name()).ToCString()); |
| 3015 } | 3032 } |
| 3016 } | 3033 } |
| (...skipping 4687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7704 } | 7721 } |
| 7705 | 7722 |
| 7706 | 7723 |
| 7707 void Parser::SkipNestedExpr() { | 7724 void Parser::SkipNestedExpr() { |
| 7708 const bool saved_mode = SetAllowFunctionLiterals(true); | 7725 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 7709 SkipExpr(); | 7726 SkipExpr(); |
| 7710 SetAllowFunctionLiterals(saved_mode); | 7727 SetAllowFunctionLiterals(saved_mode); |
| 7711 } | 7728 } |
| 7712 | 7729 |
| 7713 } // namespace dart | 7730 } // namespace dart |
| OLD | NEW |