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 10636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10647 bool require_const) { | 10647 bool require_const) { |
10648 TRACE_PARSER("ParseActualParameters"); | 10648 TRACE_PARSER("ParseActualParameters"); |
10649 ASSERT(CurrentToken() == Token::kLPAREN); | 10649 ASSERT(CurrentToken() == Token::kLPAREN); |
10650 const bool saved_mode = SetAllowFunctionLiterals(true); | 10650 const bool saved_mode = SetAllowFunctionLiterals(true); |
10651 ArgumentListNode* arguments; | 10651 ArgumentListNode* arguments; |
10652 if (implicit_arguments == NULL) { | 10652 if (implicit_arguments == NULL) { |
10653 arguments = new(Z) ArgumentListNode(TokenPos()); | 10653 arguments = new(Z) ArgumentListNode(TokenPos()); |
10654 } else { | 10654 } else { |
10655 arguments = implicit_arguments; | 10655 arguments = implicit_arguments; |
10656 } | 10656 } |
10657 const GrowableObjectArray& names = GrowableObjectArray::Handle(Z, | 10657 const GrowableObjectArray& names = |
10658 GrowableObjectArray::New(Heap::kOld)); | 10658 GrowableObjectArray::Handle(Z, GrowableObjectArray::New(Heap::kOld)); |
10659 bool named_argument_seen = false; | 10659 bool named_argument_seen = false; |
10660 if (LookaheadToken(1) != Token::kRPAREN) { | 10660 if (LookaheadToken(1) != Token::kRPAREN) { |
10661 String& arg_name = String::Handle(Z); | 10661 String& arg_name = String::Handle(Z); |
10662 do { | 10662 do { |
10663 ASSERT((CurrentToken() == Token::kLPAREN) || | 10663 ASSERT((CurrentToken() == Token::kLPAREN) || |
10664 (CurrentToken() == Token::kCOMMA)); | 10664 (CurrentToken() == Token::kCOMMA)); |
10665 ConsumeToken(); | 10665 ConsumeToken(); |
10666 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) { | 10666 if (IsIdentifier() && (LookaheadToken(1) == Token::kCOLON)) { |
10667 named_argument_seen = true; | 10667 named_argument_seen = true; |
10668 // The canonicalization of the arguments descriptor array built in | 10668 // The canonicalization of the arguments descriptor array built in |
10669 // the code generator requires that the names are symbols, i.e. | 10669 // the code generator requires that the names are symbols, i.e. |
10670 // canonicalized strings. | 10670 // canonicalized strings. |
10671 ASSERT(CurrentLiteral()->IsSymbol()); | 10671 ASSERT(CurrentLiteral()->IsSymbol()); |
10672 for (int i = 0; i < names.Length(); i++) { | 10672 for (int i = 0; i < names.Length(); i++) { |
10673 arg_name ^= names.At(i); | 10673 arg_name ^= names.At(i); |
10674 if (CurrentLiteral()->Equals(arg_name)) { | 10674 if (CurrentLiteral()->Equals(arg_name)) { |
10675 ReportError("duplicate named argument"); | 10675 ReportError("duplicate named argument"); |
10676 } | 10676 } |
10677 } | 10677 } |
10678 names.Add(*CurrentLiteral()); | 10678 names.Add(*CurrentLiteral(), Heap::kOld); |
10679 ConsumeToken(); // ident. | 10679 ConsumeToken(); // ident. |
10680 ConsumeToken(); // colon. | 10680 ConsumeToken(); // colon. |
10681 } else if (named_argument_seen) { | 10681 } else if (named_argument_seen) { |
10682 ReportError("named argument expected"); | 10682 ReportError("named argument expected"); |
10683 } | 10683 } |
10684 arguments->Add(ParseExpr(require_const, kConsumeCascades)); | 10684 arguments->Add(ParseExpr(require_const, kConsumeCascades)); |
10685 } while (CurrentToken() == Token::kCOMMA); | 10685 } while (CurrentToken() == Token::kCOMMA); |
10686 } else { | 10686 } else { |
10687 ConsumeToken(); | 10687 ConsumeToken(); |
10688 } | 10688 } |
(...skipping 2751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13440 void Parser::SkipQualIdent() { | 13440 void Parser::SkipQualIdent() { |
13441 ASSERT(IsIdentifier()); | 13441 ASSERT(IsIdentifier()); |
13442 ConsumeToken(); | 13442 ConsumeToken(); |
13443 if (CurrentToken() == Token::kPERIOD) { | 13443 if (CurrentToken() == Token::kPERIOD) { |
13444 ConsumeToken(); // Consume the kPERIOD token. | 13444 ConsumeToken(); // Consume the kPERIOD token. |
13445 ExpectIdentifier("identifier expected after '.'"); | 13445 ExpectIdentifier("identifier expected after '.'"); |
13446 } | 13446 } |
13447 } | 13447 } |
13448 | 13448 |
13449 } // namespace dart | 13449 } // namespace dart |
OLD | NEW |