| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/ast_transformer.h" | 9 #include "vm/ast_transformer.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2390 // constructor name to the respective named constructor if necessary. | 2390 // constructor name to the respective named constructor if necessary. |
| 2391 if (forwarding_args != NULL) { | 2391 if (forwarding_args != NULL) { |
| 2392 for (int i = 0; i < forwarding_args->length(); i++) { | 2392 for (int i = 0; i < forwarding_args->length(); i++) { |
| 2393 arguments->Add(forwarding_args->NodeAt(i)); | 2393 arguments->Add(forwarding_args->NodeAt(i)); |
| 2394 } | 2394 } |
| 2395 String& ctor_name = String::Handle(Z, current_function().name()); | 2395 String& ctor_name = String::Handle(Z, current_function().name()); |
| 2396 String& class_name = String::Handle(Z, cls.Name()); | 2396 String& class_name = String::Handle(Z, cls.Name()); |
| 2397 if (ctor_name.Length() > class_name.Length() + 1) { | 2397 if (ctor_name.Length() > class_name.Length() + 1) { |
| 2398 // Generating a forwarding call to a named constructor 'C.n'. | 2398 // Generating a forwarding call to a named constructor 'C.n'. |
| 2399 // Add the constructor name 'n' to the super constructor. | 2399 // Add the constructor name 'n' to the super constructor. |
| 2400 ctor_name = String::SubString(ctor_name, class_name.Length() + 1); | 2400 const intptr_t kLen = class_name.Length() + 1; |
| 2401 super_ctor_name = String::Concat(super_ctor_name, ctor_name); | 2401 ctor_name = Symbols::New(ctor_name, kLen, ctor_name.Length() - kLen); |
| 2402 super_ctor_name = Symbols::FromConcat(super_ctor_name, ctor_name); |
| 2402 } | 2403 } |
| 2403 } | 2404 } |
| 2404 | 2405 |
| 2405 // Resolve super constructor function and check arguments. | 2406 // Resolve super constructor function and check arguments. |
| 2406 const Function& super_ctor = Function::ZoneHandle(Z, | 2407 const Function& super_ctor = Function::ZoneHandle(Z, |
| 2407 super_class.LookupConstructor(super_ctor_name)); | 2408 super_class.LookupConstructor(super_ctor_name)); |
| 2408 if (super_ctor.IsNull()) { | 2409 if (super_ctor.IsNull()) { |
| 2409 ReportError(supercall_pos, | 2410 ReportError(supercall_pos, |
| 2410 "unresolved implicit call to super constructor '%s()'", | 2411 "unresolved implicit call to super constructor '%s()'", |
| 2411 String::Handle(Z, super_class.Name()).ToCString()); | 2412 String::Handle(Z, super_class.Name()).ToCString()); |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3684 if (method->IsGetter() || method->IsSetter()) { | 3685 if (method->IsGetter() || method->IsSetter()) { |
| 3685 int expected_num_parameters = 0; | 3686 int expected_num_parameters = 0; |
| 3686 if (method->IsGetter()) { | 3687 if (method->IsGetter()) { |
| 3687 expected_num_parameters = (method->has_static) ? 0 : 1; | 3688 expected_num_parameters = (method->has_static) ? 0 : 1; |
| 3688 method->dict_name = method->name; | 3689 method->dict_name = method->name; |
| 3689 method->name = &String::ZoneHandle(Z, Field::GetterSymbol(*method->name)); | 3690 method->name = &String::ZoneHandle(Z, Field::GetterSymbol(*method->name)); |
| 3690 } else { | 3691 } else { |
| 3691 ASSERT(method->IsSetter()); | 3692 ASSERT(method->IsSetter()); |
| 3692 expected_num_parameters = (method->has_static) ? 1 : 2; | 3693 expected_num_parameters = (method->has_static) ? 1 : 2; |
| 3693 method->dict_name = &String::ZoneHandle(Z, | 3694 method->dict_name = &String::ZoneHandle(Z, |
| 3694 String::Concat(*method->name, Symbols::Equals())); | 3695 Symbols::FromConcat(*method->name, Symbols::Equals())); |
| 3695 method->name = &String::ZoneHandle(Z, Field::SetterSymbol(*method->name)); | 3696 method->name = &String::ZoneHandle(Z, Field::SetterSymbol(*method->name)); |
| 3696 } | 3697 } |
| 3697 if ((method->params.num_fixed_parameters != expected_num_parameters) || | 3698 if ((method->params.num_fixed_parameters != expected_num_parameters) || |
| 3698 (method->params.num_optional_parameters != 0)) { | 3699 (method->params.num_optional_parameters != 0)) { |
| 3699 ReportError(method->name_pos, "illegal %s parameters", | 3700 ReportError(method->name_pos, "illegal %s parameters", |
| 3700 method->IsGetter() ? "getter" : "setter"); | 3701 method->IsGetter() ? "getter" : "setter"); |
| 3701 } | 3702 } |
| 3702 } | 3703 } |
| 3703 | 3704 |
| 3704 // Parse redirecting factory constructor. | 3705 // Parse redirecting factory constructor. |
| (...skipping 10597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14302 void Parser::SkipQualIdent() { | 14303 void Parser::SkipQualIdent() { |
| 14303 ASSERT(IsIdentifier()); | 14304 ASSERT(IsIdentifier()); |
| 14304 ConsumeToken(); | 14305 ConsumeToken(); |
| 14305 if (CurrentToken() == Token::kPERIOD) { | 14306 if (CurrentToken() == Token::kPERIOD) { |
| 14306 ConsumeToken(); // Consume the kPERIOD token. | 14307 ConsumeToken(); // Consume the kPERIOD token. |
| 14307 ExpectIdentifier("identifier expected after '.'"); | 14308 ExpectIdentifier("identifier expected after '.'"); |
| 14308 } | 14309 } |
| 14309 } | 14310 } |
| 14310 | 14311 |
| 14311 } // namespace dart | 14312 } // namespace dart |
| OLD | NEW |