Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: vm/parser.cc

Issue 10808064: Rename some of the enum definitions inside classes to avoid conflict with the ObjectKind enum. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/parser.h ('k') | vm/parser_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 has_final = false; 473 has_final = false;
474 has_const = false; 474 has_const = false;
475 has_static = false; 475 has_static = false;
476 has_var = false; 476 has_var = false;
477 has_factory = false; 477 has_factory = false;
478 type = NULL; 478 type = NULL;
479 name_pos = 0; 479 name_pos = 0;
480 name = NULL; 480 name = NULL;
481 redirect_name = NULL; 481 redirect_name = NULL;
482 params.Clear(); 482 params.Clear();
483 kind = RawFunction::kFunction; 483 kind = RawFunction::kRegularFunction;
484 } 484 }
485 bool IsConstructor() const { 485 bool IsConstructor() const {
486 return (kind == RawFunction::kConstructor) && !has_static; 486 return (kind == RawFunction::kConstructor) && !has_static;
487 } 487 }
488 bool IsFactory() const { 488 bool IsFactory() const {
489 return (kind == RawFunction::kConstructor) && has_static; 489 return (kind == RawFunction::kConstructor) && has_static;
490 } 490 }
491 bool IsFactoryOrConstructor() const { 491 bool IsFactoryOrConstructor() const {
492 return (kind == RawFunction::kConstructor); 492 return (kind == RawFunction::kConstructor);
493 } 493 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 const intptr_t prev_ast_node_id = isolate->ast_node_id(); 683 const intptr_t prev_ast_node_id = isolate->ast_node_id();
684 isolate->set_ast_node_id(0); 684 isolate->set_ast_node_id(0);
685 ASSERT(parsed_function != NULL); 685 ASSERT(parsed_function != NULL);
686 const Function& func = parsed_function->function(); 686 const Function& func = parsed_function->function();
687 const Class& cls = Class::Handle(isolate, func.owner()); 687 const Class& cls = Class::Handle(isolate, func.owner());
688 const Script& script = Script::Handle(isolate, cls.script()); 688 const Script& script = Script::Handle(isolate, cls.script());
689 Parser parser(script, func, func.token_pos()); 689 Parser parser(script, func, func.token_pos());
690 SequenceNode* node_sequence = NULL; 690 SequenceNode* node_sequence = NULL;
691 Array& default_parameter_values = Array::Handle(isolate, Array::null()); 691 Array& default_parameter_values = Array::Handle(isolate, Array::null());
692 switch (func.kind()) { 692 switch (func.kind()) {
693 case RawFunction::kFunction: 693 case RawFunction::kRegularFunction:
694 case RawFunction::kClosureFunction: 694 case RawFunction::kClosureFunction:
695 case RawFunction::kGetterFunction: 695 case RawFunction::kGetterFunction:
696 case RawFunction::kSetterFunction: 696 case RawFunction::kSetterFunction:
697 case RawFunction::kConstructor: 697 case RawFunction::kConstructor:
698 node_sequence = parser.ParseFunc(func, default_parameter_values); 698 node_sequence = parser.ParseFunc(func, default_parameter_values);
699 break; 699 break;
700 case RawFunction::kImplicitGetter: 700 case RawFunction::kImplicitGetter:
701 ASSERT(!func.is_static()); 701 ASSERT(!func.is_static());
702 node_sequence = parser.ParseInstanceGetter(func); 702 node_sequence = parser.ParseInstanceGetter(func);
703 break; 703 break;
(...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
2462 RawFunction::Kind function_kind; 2462 RawFunction::Kind function_kind;
2463 if (method->IsFactoryOrConstructor()) { 2463 if (method->IsFactoryOrConstructor()) {
2464 function_kind = RawFunction::kConstructor; 2464 function_kind = RawFunction::kConstructor;
2465 } else if (method->has_abstract) { 2465 } else if (method->has_abstract) {
2466 function_kind = RawFunction::kAbstract; 2466 function_kind = RawFunction::kAbstract;
2467 } else if (method->IsGetter()) { 2467 } else if (method->IsGetter()) {
2468 function_kind = RawFunction::kGetterFunction; 2468 function_kind = RawFunction::kGetterFunction;
2469 } else if (method->IsSetter()) { 2469 } else if (method->IsSetter()) {
2470 function_kind = RawFunction::kSetterFunction; 2470 function_kind = RawFunction::kSetterFunction;
2471 } else { 2471 } else {
2472 function_kind = RawFunction::kFunction; 2472 function_kind = RawFunction::kRegularFunction;
2473 } 2473 }
2474 Function& func = Function::Handle( 2474 Function& func = Function::Handle(
2475 Function::New(*method->name, 2475 Function::New(*method->name,
2476 function_kind, 2476 function_kind,
2477 method->has_static, 2477 method->has_static,
2478 method->has_const, 2478 method->has_const,
2479 method_pos)); 2479 method_pos));
2480 func.set_result_type(*method->type); 2480 func.set_result_type(*method->type);
2481 func.set_end_token_pos(method_end_pos); 2481 func.set_end_token_pos(method_end_pos);
2482 2482
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 (LookaheadToken(1) != Token::kCOMMA) && 2772 (LookaheadToken(1) != Token::kCOMMA) &&
2773 (LookaheadToken(1) != Token::kSEMICOLON)) { 2773 (LookaheadToken(1) != Token::kSEMICOLON)) {
2774 ConsumeToken(); 2774 ConsumeToken();
2775 if (!Token::CanBeOverloaded(CurrentToken())) { 2775 if (!Token::CanBeOverloaded(CurrentToken())) {
2776 ErrorMsg("invalid operator overloading"); 2776 ErrorMsg("invalid operator overloading");
2777 } 2777 }
2778 if (member.has_static) { 2778 if (member.has_static) {
2779 ErrorMsg("operator overloading functions cannot be static"); 2779 ErrorMsg("operator overloading functions cannot be static");
2780 } 2780 }
2781 operator_token = CurrentToken(); 2781 operator_token = CurrentToken();
2782 member.kind = RawFunction::kFunction; 2782 member.kind = RawFunction::kRegularFunction;
2783 member.name_pos = this->TokenPos(); 2783 member.name_pos = this->TokenPos();
2784 member.name = 2784 member.name =
2785 &String::ZoneHandle(String::NewSymbol(Token::Str(operator_token))); 2785 &String::ZoneHandle(String::NewSymbol(Token::Str(operator_token)));
2786 ConsumeToken(); 2786 ConsumeToken();
2787 } else if (IsIdentifier()) { 2787 } else if (IsIdentifier()) {
2788 member.name = CurrentLiteral(); 2788 member.name = CurrentLiteral();
2789 member.name_pos = TokenPos(); 2789 member.name_pos = TokenPos();
2790 ConsumeToken(); 2790 ConsumeToken();
2791 } else { 2791 } else {
2792 ErrorMsg("identifier expected"); 2792 ErrorMsg("identifier expected");
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 ConsumeToken(); 3549 ConsumeToken();
3550 SkipExpr(); 3550 SkipExpr();
3551 ExpectSemicolon(); 3551 ExpectSemicolon();
3552 function_end_pos = TokenPos(); 3552 function_end_pos = TokenPos();
3553 } else if (IsLiteral("native")) { 3553 } else if (IsLiteral("native")) {
3554 ParseNativeDeclaration(); 3554 ParseNativeDeclaration();
3555 } else { 3555 } else {
3556 ErrorMsg("function block expected"); 3556 ErrorMsg("function block expected");
3557 } 3557 }
3558 Function& func = Function::Handle( 3558 Function& func = Function::Handle(
3559 Function::New(func_name, RawFunction::kFunction, 3559 Function::New(func_name, RawFunction::kRegularFunction,
3560 is_static, false, function_pos)); 3560 is_static, false, function_pos));
3561 func.set_result_type(result_type); 3561 func.set_result_type(result_type);
3562 func.set_end_token_pos(function_end_pos); 3562 func.set_end_token_pos(function_end_pos);
3563 AddFormalParamsToFunction(&params, func); 3563 AddFormalParamsToFunction(&params, func);
3564 top_level->functions.Add(func); 3564 top_level->functions.Add(func);
3565 library_.AddObject(func, func_name); 3565 library_.AddObject(func, func_name);
3566 } 3566 }
3567 3567
3568 3568
3569 void Parser::ParseTopLevelAccessor(TopLevel* top_level) { 3569 void Parser::ParseTopLevelAccessor(TopLevel* top_level) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 is_static, false, accessor_pos)); 3642 is_static, false, accessor_pos));
3643 func.set_result_type(result_type); 3643 func.set_result_type(result_type);
3644 AddFormalParamsToFunction(&params, func); 3644 AddFormalParamsToFunction(&params, func);
3645 top_level->functions.Add(func); 3645 top_level->functions.Add(func);
3646 library_.AddObject(func, accessor_name); 3646 library_.AddObject(func, accessor_name);
3647 } 3647 }
3648 3648
3649 3649
3650 void Parser::ParseLibraryName() { 3650 void Parser::ParseLibraryName() {
3651 TRACE_PARSER("ParseLibraryName"); 3651 TRACE_PARSER("ParseLibraryName");
3652 if ((script_.kind() == RawScript::kLibrary) && 3652 if ((script_.kind() == RawScript::kLibraryTag) &&
3653 (CurrentToken() != Token::kLIBRARY)) { 3653 (CurrentToken() != Token::kLIBRARY)) {
3654 // Handle error case early to get consistent error message. 3654 // Handle error case early to get consistent error message.
3655 ExpectToken(Token::kLIBRARY); 3655 ExpectToken(Token::kLIBRARY);
3656 } 3656 }
3657 if (CurrentToken() == Token::kLIBRARY) { 3657 if (CurrentToken() == Token::kLIBRARY) {
3658 ConsumeToken(); 3658 ConsumeToken();
3659 ExpectToken(Token::kLPAREN); 3659 ExpectToken(Token::kLPAREN);
3660 if (CurrentToken() != Token::kSTRING) { 3660 if (CurrentToken() != Token::kSTRING) {
3661 ErrorMsg("library name expected"); 3661 ErrorMsg("library name expected");
3662 } 3662 }
(...skipping 5003 matching lines...) Expand 10 before | Expand all | Expand 10 after
8666 void Parser::SkipQualIdent() { 8666 void Parser::SkipQualIdent() {
8667 ASSERT(IsIdentifier()); 8667 ASSERT(IsIdentifier());
8668 ConsumeToken(); 8668 ConsumeToken();
8669 if (CurrentToken() == Token::kPERIOD) { 8669 if (CurrentToken() == Token::kPERIOD) {
8670 ConsumeToken(); // Consume the kPERIOD token. 8670 ConsumeToken(); // Consume the kPERIOD token.
8671 ExpectIdentifier("identifier expected after '.'"); 8671 ExpectIdentifier("identifier expected after '.'");
8672 } 8672 }
8673 } 8673 }
8674 8674
8675 } // namespace dart 8675 } // namespace dart
OLDNEW
« no previous file with comments | « vm/parser.h ('k') | vm/parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698