| 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/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 8331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8342 } | 8342 } |
| 8343 | 8343 |
| 8344 | 8344 |
| 8345 AstNode* Parser::ParseSelectors(AstNode* primary, bool is_cascade) { | 8345 AstNode* Parser::ParseSelectors(AstNode* primary, bool is_cascade) { |
| 8346 AstNode* left = primary; | 8346 AstNode* left = primary; |
| 8347 while (true) { | 8347 while (true) { |
| 8348 AstNode* selector = NULL; | 8348 AstNode* selector = NULL; |
| 8349 if (CurrentToken() == Token::kPERIOD) { | 8349 if (CurrentToken() == Token::kPERIOD) { |
| 8350 ConsumeToken(); | 8350 ConsumeToken(); |
| 8351 if (left->IsPrimaryNode()) { | 8351 if (left->IsPrimaryNode()) { |
| 8352 if (left->AsPrimaryNode()->primary().IsFunction()) { | 8352 PrimaryNode* primary_node = left->AsPrimaryNode(); |
| 8353 left = LoadClosure(left->AsPrimaryNode()); | 8353 const intptr_t primary_pos = primary_node->token_pos(); |
| 8354 } else if (left->AsPrimaryNode()->primary().IsTypeParameter()) { | 8354 if (primary_node->primary().IsFunction()) { |
| 8355 left = LoadClosure(primary_node); |
| 8356 } else if (primary_node->primary().IsTypeParameter()) { |
| 8357 if (current_function().is_static()) { |
| 8358 const String& name = String::ZoneHandle( |
| 8359 TypeParameter::Cast(primary_node->primary()).name()); |
| 8360 ErrorMsg(primary_pos, |
| 8361 "cannot access type parameter '%s' from static function", |
| 8362 name.ToCString()); |
| 8363 } |
| 8355 if (current_block_->scope->function_level() > 0) { | 8364 if (current_block_->scope->function_level() > 0) { |
| 8356 // Make sure that the instantiator is captured. | 8365 // Make sure that the instantiator is captured. |
| 8357 CaptureInstantiator(); | 8366 CaptureInstantiator(); |
| 8358 } | 8367 } |
| 8359 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); | 8368 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); |
| 8360 type_parameter ^= ClassFinalizer::FinalizeType( | 8369 type_parameter ^= ClassFinalizer::FinalizeType( |
| 8361 current_class(), | 8370 current_class(), |
| 8362 TypeParameter::Cast(left->AsPrimaryNode()->primary()), | 8371 TypeParameter::Cast(primary_node->primary()), |
| 8363 ClassFinalizer::kCanonicalize); | 8372 ClassFinalizer::kCanonicalize); |
| 8364 ASSERT(!type_parameter.IsMalformed()); | 8373 ASSERT(!type_parameter.IsMalformed()); |
| 8365 left = new TypeNode(primary->token_pos(), type_parameter); | 8374 left = new TypeNode(primary->token_pos(), type_parameter); |
| 8366 } else { | 8375 } else { |
| 8367 // Super field access handled in ParseSuperFieldAccess(), | 8376 // Super field access handled in ParseSuperFieldAccess(), |
| 8368 // super calls handled in ParseSuperCall(). | 8377 // super calls handled in ParseSuperCall(). |
| 8369 ASSERT(!left->AsPrimaryNode()->IsSuper()); | 8378 ASSERT(!primary_node->IsSuper()); |
| 8370 left = LoadFieldIfUnresolved(left); | 8379 left = LoadFieldIfUnresolved(left); |
| 8371 } | 8380 } |
| 8372 } | 8381 } |
| 8373 const intptr_t ident_pos = TokenPos(); | 8382 const intptr_t ident_pos = TokenPos(); |
| 8374 String* ident = ExpectIdentifier("identifier expected"); | 8383 String* ident = ExpectIdentifier("identifier expected"); |
| 8375 if (CurrentToken() == Token::kLPAREN) { | 8384 if (CurrentToken() == Token::kLPAREN) { |
| 8376 // Identifier followed by a opening paren: method call. | 8385 // Identifier followed by a opening paren: method call. |
| 8377 if (left->IsPrimaryNode() && | 8386 if (left->IsPrimaryNode() && |
| 8378 left->AsPrimaryNode()->primary().IsClass()) { | 8387 left->AsPrimaryNode()->primary().IsClass()) { |
| 8379 // Static method call prefixed with class name. | 8388 // Static method call prefixed with class name. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 8408 | 8417 |
| 8409 const intptr_t bracket_pos = TokenPos(); | 8418 const intptr_t bracket_pos = TokenPos(); |
| 8410 ConsumeToken(); | 8419 ConsumeToken(); |
| 8411 left = LoadFieldIfUnresolved(left); | 8420 left = LoadFieldIfUnresolved(left); |
| 8412 const bool saved_mode = SetAllowFunctionLiterals(true); | 8421 const bool saved_mode = SetAllowFunctionLiterals(true); |
| 8413 AstNode* index = ParseExpr(kAllowConst, kConsumeCascades); | 8422 AstNode* index = ParseExpr(kAllowConst, kConsumeCascades); |
| 8414 SetAllowFunctionLiterals(saved_mode); | 8423 SetAllowFunctionLiterals(saved_mode); |
| 8415 ExpectToken(Token::kRBRACK); | 8424 ExpectToken(Token::kRBRACK); |
| 8416 AstNode* array = left; | 8425 AstNode* array = left; |
| 8417 if (left->IsPrimaryNode()) { | 8426 if (left->IsPrimaryNode()) { |
| 8418 PrimaryNode* primary = left->AsPrimaryNode(); | 8427 PrimaryNode* primary_node = left->AsPrimaryNode(); |
| 8419 if (primary->primary().IsFunction()) { | 8428 const intptr_t primary_pos = primary_node->token_pos(); |
| 8420 array = LoadClosure(primary); | 8429 if (primary_node->primary().IsFunction()) { |
| 8421 } else if (primary->primary().IsClass()) { | 8430 array = LoadClosure(primary_node); |
| 8422 const Class& type_class = Class::Cast(primary->primary()); | 8431 } else if (primary_node->primary().IsClass()) { |
| 8432 const Class& type_class = Class::Cast(primary_node->primary()); |
| 8423 AbstractType& type = Type::ZoneHandle( | 8433 AbstractType& type = Type::ZoneHandle( |
| 8424 Type::New(type_class, TypeArguments::Handle(), | 8434 Type::New(type_class, TypeArguments::Handle(), |
| 8425 primary->token_pos(), Heap::kOld)); | 8435 primary_pos, Heap::kOld)); |
| 8426 type ^= ClassFinalizer::FinalizeType( | 8436 type ^= ClassFinalizer::FinalizeType( |
| 8427 current_class(), type, ClassFinalizer::kCanonicalize); | 8437 current_class(), type, ClassFinalizer::kCanonicalize); |
| 8428 // Type may be malbounded, but not malformed. | 8438 // Type may be malbounded, but not malformed. |
| 8429 ASSERT(!type.IsMalformed()); | 8439 ASSERT(!type.IsMalformed()); |
| 8430 array = new TypeNode(primary->token_pos(), type); | 8440 array = new TypeNode(primary_pos, type); |
| 8431 } else if (primary->primary().IsTypeParameter()) { | 8441 } else if (primary_node->primary().IsTypeParameter()) { |
| 8442 if (current_function().is_static()) { |
| 8443 const String& name = String::ZoneHandle( |
| 8444 TypeParameter::Cast(primary_node->primary()).name()); |
| 8445 ErrorMsg(primary_pos, |
| 8446 "cannot access type parameter '%s' from static function", |
| 8447 name.ToCString()); |
| 8448 } |
| 8432 if (current_block_->scope->function_level() > 0) { | 8449 if (current_block_->scope->function_level() > 0) { |
| 8433 // Make sure that the instantiator is captured. | 8450 // Make sure that the instantiator is captured. |
| 8434 CaptureInstantiator(); | 8451 CaptureInstantiator(); |
| 8435 } | 8452 } |
| 8436 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); | 8453 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); |
| 8437 type_parameter ^= ClassFinalizer::FinalizeType( | 8454 type_parameter ^= ClassFinalizer::FinalizeType( |
| 8438 current_class(), | 8455 current_class(), |
| 8439 TypeParameter::Cast(primary->primary()), | 8456 TypeParameter::Cast(primary_node->primary()), |
| 8440 ClassFinalizer::kCanonicalize); | 8457 ClassFinalizer::kCanonicalize); |
| 8441 ASSERT(!type_parameter.IsMalformed()); | 8458 ASSERT(!type_parameter.IsMalformed()); |
| 8442 array = new TypeNode(primary->token_pos(), type_parameter); | 8459 array = new TypeNode(primary_pos, type_parameter); |
| 8443 } else { | 8460 } else { |
| 8444 UNREACHABLE(); // Internal parser error. | 8461 UNREACHABLE(); // Internal parser error. |
| 8445 } | 8462 } |
| 8446 } | 8463 } |
| 8447 selector = new LoadIndexedNode(bracket_pos, | 8464 selector = new LoadIndexedNode(bracket_pos, |
| 8448 array, | 8465 array, |
| 8449 index, | 8466 index, |
| 8450 Class::ZoneHandle()); | 8467 Class::ZoneHandle()); |
| 8451 } else if (CurrentToken() == Token::kLPAREN) { | 8468 } else if (CurrentToken() == Token::kLPAREN) { |
| 8452 if (left->IsPrimaryNode()) { | 8469 if (left->IsPrimaryNode()) { |
| 8453 PrimaryNode* primary = left->AsPrimaryNode(); | 8470 PrimaryNode* primary_node = left->AsPrimaryNode(); |
| 8454 const intptr_t primary_pos = primary->token_pos(); | 8471 const intptr_t primary_pos = primary_node->token_pos(); |
| 8455 if (primary->primary().IsFunction()) { | 8472 if (primary_node->primary().IsFunction()) { |
| 8456 const Function& func = Function::Cast(primary->primary()); | 8473 const Function& func = Function::Cast(primary_node->primary()); |
| 8457 const String& func_name = String::ZoneHandle(func.name()); | 8474 const String& func_name = String::ZoneHandle(func.name()); |
| 8458 if (func.is_static()) { | 8475 if (func.is_static()) { |
| 8459 // Parse static function call. | 8476 // Parse static function call. |
| 8460 Class& cls = Class::Handle(func.Owner()); | 8477 Class& cls = Class::Handle(func.Owner()); |
| 8461 selector = ParseStaticCall(cls, func_name, primary_pos); | 8478 selector = ParseStaticCall(cls, func_name, primary_pos); |
| 8462 } else { | 8479 } else { |
| 8463 // Dynamic function call on implicit "this" parameter. | 8480 // Dynamic function call on implicit "this" parameter. |
| 8464 if (current_function().is_static()) { | 8481 if (current_function().is_static()) { |
| 8465 ErrorMsg(primary_pos, | 8482 ErrorMsg(primary_pos, |
| 8466 "cannot access instance method '%s' " | 8483 "cannot access instance method '%s' " |
| 8467 "from static function", | 8484 "from static function", |
| 8468 func_name.ToCString()); | 8485 func_name.ToCString()); |
| 8469 } | 8486 } |
| 8470 selector = ParseInstanceCall(LoadReceiver(primary_pos), func_name); | 8487 selector = ParseInstanceCall(LoadReceiver(primary_pos), func_name); |
| 8471 } | 8488 } |
| 8472 } else if (primary->primary().IsString()) { | 8489 } else if (primary_node->primary().IsString()) { |
| 8473 // Primary is an unresolved name. | 8490 // Primary is an unresolved name. |
| 8474 if (primary->IsSuper()) { | 8491 if (primary_node->IsSuper()) { |
| 8475 ErrorMsg(primary->token_pos(), "illegal use of super"); | 8492 ErrorMsg(primary_pos, "illegal use of super"); |
| 8476 } | 8493 } |
| 8477 String& name = String::CheckedZoneHandle(primary->primary().raw()); | 8494 String& name = String::CheckedZoneHandle( |
| 8495 primary_node->primary().raw()); |
| 8478 if (current_function().is_static()) { | 8496 if (current_function().is_static()) { |
| 8479 selector = ThrowNoSuchMethodError(primary->token_pos(), | 8497 selector = ThrowNoSuchMethodError(primary_pos, |
| 8480 current_class(), | 8498 current_class(), |
| 8481 name, | 8499 name, |
| 8482 NULL, // No arguments. | 8500 NULL, // No arguments. |
| 8483 InvocationMirror::kStatic, | 8501 InvocationMirror::kStatic, |
| 8484 InvocationMirror::kMethod, | 8502 InvocationMirror::kMethod, |
| 8485 NULL); // No existing function. | 8503 NULL); // No existing function. |
| 8486 } else { | 8504 } else { |
| 8487 // Treat as call to unresolved (instance) method. | 8505 // Treat as call to unresolved (instance) method. |
| 8488 AstNode* receiver = LoadReceiver(primary->token_pos()); | 8506 selector = ParseInstanceCall(LoadReceiver(primary_pos), name); |
| 8489 selector = ParseInstanceCall(receiver, name); | |
| 8490 } | 8507 } |
| 8491 } else if (primary->primary().IsTypeParameter()) { | 8508 } else if (primary_node->primary().IsTypeParameter()) { |
| 8492 // TODO(regis): Issue 13134. Make sure the error message is the | |
| 8493 // one we want here and add a test covering this code. | |
| 8494 const String& name = String::ZoneHandle( | 8509 const String& name = String::ZoneHandle( |
| 8495 TypeParameter::Cast(primary->primary()).name()); | 8510 TypeParameter::Cast(primary_node->primary()).name()); |
| 8496 selector = ThrowNoSuchMethodError(primary->token_pos(), | 8511 if (current_function().is_static()) { |
| 8497 current_class(), | 8512 // Treat as this.T(), because T is in scope. |
| 8498 name, | 8513 ErrorMsg(primary_pos, |
| 8499 NULL, // No arguments. | 8514 "cannot access type parameter '%s' from static function", |
| 8500 InvocationMirror::kStatic, | 8515 name.ToCString()); |
| 8501 InvocationMirror::kMethod, | 8516 } else { |
| 8502 NULL); // No existing function. | 8517 // Treat as call to unresolved (instance) method. |
| 8503 } else if (primary->primary().IsClass()) { | 8518 selector = ParseInstanceCall(LoadReceiver(primary_pos), name); |
| 8504 const Class& type_class = Class::Cast(primary->primary()); | 8519 } |
| 8520 } else if (primary_node->primary().IsClass()) { |
| 8521 const Class& type_class = Class::Cast(primary_node->primary()); |
| 8505 AbstractType& type = Type::ZoneHandle(Type::New( | 8522 AbstractType& type = Type::ZoneHandle(Type::New( |
| 8506 type_class, TypeArguments::Handle(), primary->token_pos())); | 8523 type_class, TypeArguments::Handle(), primary_pos)); |
| 8507 type ^= ClassFinalizer::FinalizeType( | 8524 type ^= ClassFinalizer::FinalizeType( |
| 8508 current_class(), type, ClassFinalizer::kCanonicalize); | 8525 current_class(), type, ClassFinalizer::kCanonicalize); |
| 8509 // Type may be malbounded, but not malformed. | 8526 // Type may be malbounded, but not malformed. |
| 8510 ASSERT(!type.IsMalformed()); | 8527 ASSERT(!type.IsMalformed()); |
| 8511 selector = new TypeNode(primary->token_pos(), type); | 8528 selector = new TypeNode(primary_pos, type); |
| 8512 } else { | 8529 } else { |
| 8513 UNREACHABLE(); // Internal parser error. | 8530 UNREACHABLE(); // Internal parser error. |
| 8514 } | 8531 } |
| 8515 } else { | 8532 } else { |
| 8516 // Left is not a primary node; this must be a closure call. | 8533 // Left is not a primary node; this must be a closure call. |
| 8517 AstNode* closure = left; | 8534 AstNode* closure = left; |
| 8518 selector = ParseClosureCall(closure); | 8535 selector = ParseClosureCall(closure); |
| 8519 } | 8536 } |
| 8520 } else { | 8537 } else { |
| 8521 // No (more) selectors to parse. | 8538 // No (more) selectors to parse. |
| 8522 left = LoadFieldIfUnresolved(left); | 8539 left = LoadFieldIfUnresolved(left); |
| 8523 if (left->IsPrimaryNode()) { | 8540 if (left->IsPrimaryNode()) { |
| 8524 PrimaryNode* primary = left->AsPrimaryNode(); | 8541 PrimaryNode* primary_node = left->AsPrimaryNode(); |
| 8525 if (primary->primary().IsFunction()) { | 8542 const intptr_t primary_pos = primary->token_pos(); |
| 8543 if (primary_node->primary().IsFunction()) { |
| 8526 // Treat as implicit closure. | 8544 // Treat as implicit closure. |
| 8527 left = LoadClosure(primary); | 8545 left = LoadClosure(primary_node); |
| 8528 } else if (primary->primary().IsClass()) { | 8546 } else if (primary_node->primary().IsClass()) { |
| 8529 const Class& type_class = Class::Cast(primary->primary()); | 8547 const Class& type_class = Class::Cast(primary_node->primary()); |
| 8530 AbstractType& type = Type::ZoneHandle(Type::New( | 8548 AbstractType& type = Type::ZoneHandle(Type::New( |
| 8531 type_class, TypeArguments::Handle(), primary->token_pos())); | 8549 type_class, TypeArguments::Handle(), primary_pos)); |
| 8532 type = ClassFinalizer::FinalizeType( | 8550 type = ClassFinalizer::FinalizeType( |
| 8533 current_class(), type, ClassFinalizer::kCanonicalize); | 8551 current_class(), type, ClassFinalizer::kCanonicalize); |
| 8534 // Type may be malbounded, but not malformed. | 8552 // Type may be malbounded, but not malformed. |
| 8535 ASSERT(!type.IsMalformed()); | 8553 ASSERT(!type.IsMalformed()); |
| 8536 left = new TypeNode(primary->token_pos(), type); | 8554 left = new TypeNode(primary_pos, type); |
| 8537 } else if (primary->primary().IsTypeParameter()) { | 8555 } else if (primary_node->primary().IsTypeParameter()) { |
| 8556 if (current_function().is_static()) { |
| 8557 const String& name = String::ZoneHandle( |
| 8558 TypeParameter::Cast(primary_node->primary()).name()); |
| 8559 ErrorMsg(primary_pos, |
| 8560 "cannot access type parameter '%s' from static function", |
| 8561 name.ToCString()); |
| 8562 } |
| 8538 if (current_block_->scope->function_level() > 0) { | 8563 if (current_block_->scope->function_level() > 0) { |
| 8539 // Make sure that the instantiator is captured. | 8564 // Make sure that the instantiator is captured. |
| 8540 CaptureInstantiator(); | 8565 CaptureInstantiator(); |
| 8541 } | 8566 } |
| 8542 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); | 8567 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); |
| 8543 type_parameter ^= ClassFinalizer::FinalizeType( | 8568 type_parameter ^= ClassFinalizer::FinalizeType( |
| 8544 current_class(), | 8569 current_class(), |
| 8545 TypeParameter::Cast(primary->primary()), | 8570 TypeParameter::Cast(primary_node->primary()), |
| 8546 ClassFinalizer::kCanonicalize); | 8571 ClassFinalizer::kCanonicalize); |
| 8547 ASSERT(!type_parameter.IsMalformed()); | 8572 ASSERT(!type_parameter.IsMalformed()); |
| 8548 left = new TypeNode(primary->token_pos(), type_parameter); | 8573 left = new TypeNode(primary_pos, type_parameter); |
| 8549 } else if (primary->IsSuper()) { | 8574 } else if (primary_node->IsSuper()) { |
| 8550 // Return "super" to handle unary super operator calls, | 8575 // Return "super" to handle unary super operator calls, |
| 8551 // or to report illegal use of "super" otherwise. | 8576 // or to report illegal use of "super" otherwise. |
| 8552 left = primary; | 8577 left = primary_node; |
| 8553 } else { | 8578 } else { |
| 8554 UNREACHABLE(); // Internal parser error. | 8579 UNREACHABLE(); // Internal parser error. |
| 8555 } | 8580 } |
| 8556 } | 8581 } |
| 8557 // Done parsing selectors. | 8582 // Done parsing selectors. |
| 8558 return left; | 8583 return left; |
| 8559 } | 8584 } |
| 8560 ASSERT(selector != NULL); | 8585 ASSERT(selector != NULL); |
| 8561 left = selector; | 8586 left = selector; |
| 8562 } | 8587 } |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9222 return new TypeNode(ident_pos, type_parameter); | 9247 return new TypeNode(ident_pos, type_parameter); |
| 9223 } | 9248 } |
| 9224 } | 9249 } |
| 9225 // Not found in the local scope, and the name is not a type parameter. | 9250 // Not found in the local scope, and the name is not a type parameter. |
| 9226 // Try finding the variable in the library scope (current library | 9251 // Try finding the variable in the library scope (current library |
| 9227 // and all libraries imported by it without a library prefix). | 9252 // and all libraries imported by it without a library prefix). |
| 9228 resolved = ResolveIdentInCurrentLibraryScope(ident_pos, ident); | 9253 resolved = ResolveIdentInCurrentLibraryScope(ident_pos, ident); |
| 9229 } | 9254 } |
| 9230 if (resolved->IsPrimaryNode()) { | 9255 if (resolved->IsPrimaryNode()) { |
| 9231 PrimaryNode* primary = resolved->AsPrimaryNode(); | 9256 PrimaryNode* primary = resolved->AsPrimaryNode(); |
| 9257 const intptr_t primary_pos = primary->token_pos(); |
| 9232 if (primary->primary().IsString()) { | 9258 if (primary->primary().IsString()) { |
| 9233 // We got an unresolved name. If we are compiling a static | 9259 // We got an unresolved name. If we are compiling a static |
| 9234 // method, evaluation of an unresolved identifier causes a | 9260 // method, evaluation of an unresolved identifier causes a |
| 9235 // NoSuchMethodError to be thrown. In an instance method, we convert | 9261 // NoSuchMethodError to be thrown. In an instance method, we convert |
| 9236 // the unresolved name to an instance field access, since a | 9262 // the unresolved name to an instance field access, since a |
| 9237 // subclass might define a field with this name. | 9263 // subclass might define a field with this name. |
| 9238 if (current_function().is_static()) { | 9264 if (current_function().is_static()) { |
| 9239 resolved = ThrowNoSuchMethodError(ident_pos, | 9265 resolved = ThrowNoSuchMethodError(ident_pos, |
| 9240 current_class(), | 9266 current_class(), |
| 9241 ident, | 9267 ident, |
| 9242 NULL, // No arguments. | 9268 NULL, // No arguments. |
| 9243 InvocationMirror::kStatic, | 9269 InvocationMirror::kStatic, |
| 9244 InvocationMirror::kField, | 9270 InvocationMirror::kField, |
| 9245 NULL); // No existing function. | 9271 NULL); // No existing function. |
| 9246 } else { | 9272 } else { |
| 9247 // Treat as call to unresolved instance field. | 9273 // Treat as call to unresolved instance field. |
| 9248 resolved = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); | 9274 resolved = CallGetter(ident_pos, LoadReceiver(ident_pos), ident); |
| 9249 } | 9275 } |
| 9250 } else if (primary->primary().IsFunction()) { | 9276 } else if (primary->primary().IsFunction()) { |
| 9251 if (allow_closure_names) { | 9277 if (allow_closure_names) { |
| 9252 resolved = LoadClosure(primary); | 9278 resolved = LoadClosure(primary); |
| 9253 } else { | 9279 } else { |
| 9254 ErrorMsg(ident_pos, "illegal reference to method '%s'", | 9280 ErrorMsg(ident_pos, "illegal reference to method '%s'", |
| 9255 ident.ToCString()); | 9281 ident.ToCString()); |
| 9256 } | 9282 } |
| 9257 } else if (primary->primary().IsClass()) { | 9283 } else if (primary->primary().IsClass()) { |
| 9258 const Class& type_class = Class::Cast(primary->primary()); | 9284 const Class& type_class = Class::Cast(primary->primary()); |
| 9259 AbstractType& type = Type::ZoneHandle( | 9285 AbstractType& type = Type::ZoneHandle( |
| 9260 Type::New(type_class, TypeArguments::Handle(), primary->token_pos())); | 9286 Type::New(type_class, TypeArguments::Handle(), primary_pos)); |
| 9261 type ^= ClassFinalizer::FinalizeType( | 9287 type ^= ClassFinalizer::FinalizeType( |
| 9262 current_class(), type, ClassFinalizer::kCanonicalize); | 9288 current_class(), type, ClassFinalizer::kCanonicalize); |
| 9263 // Type may be malbounded, but not malformed. | 9289 // Type may be malbounded, but not malformed. |
| 9264 ASSERT(!type.IsMalformed()); | 9290 ASSERT(!type.IsMalformed()); |
| 9265 resolved = new TypeNode(primary->token_pos(), type); | 9291 resolved = new TypeNode(primary_pos, type); |
| 9266 } | 9292 } |
| 9267 } | 9293 } |
| 9268 return resolved; | 9294 return resolved; |
| 9269 } | 9295 } |
| 9270 | 9296 |
| 9271 | 9297 |
| 9272 // Parses type = [ident "."] ident ["<" type { "," type } ">"], then resolve and | 9298 // Parses type = [ident "."] ident ["<" type { "," type } ">"], then resolve and |
| 9273 // finalize it according to the given type finalization mode. | 9299 // finalize it according to the given type finalization mode. |
| 9274 RawAbstractType* Parser::ParseType( | 9300 RawAbstractType* Parser::ParseType( |
| 9275 ClassFinalizer::FinalizationKind finalization) { | 9301 ClassFinalizer::FinalizationKind finalization) { |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10750 void Parser::SkipQualIdent() { | 10776 void Parser::SkipQualIdent() { |
| 10751 ASSERT(IsIdentifier()); | 10777 ASSERT(IsIdentifier()); |
| 10752 ConsumeToken(); | 10778 ConsumeToken(); |
| 10753 if (CurrentToken() == Token::kPERIOD) { | 10779 if (CurrentToken() == Token::kPERIOD) { |
| 10754 ConsumeToken(); // Consume the kPERIOD token. | 10780 ConsumeToken(); // Consume the kPERIOD token. |
| 10755 ExpectIdentifier("identifier expected after '.'"); | 10781 ExpectIdentifier("identifier expected after '.'"); |
| 10756 } | 10782 } |
| 10757 } | 10783 } |
| 10758 | 10784 |
| 10759 } // namespace dart | 10785 } // namespace dart |
| OLD | NEW |