| 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 8694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8705 expr = new(I) ConditionalExprNode(expr_pos, expr, expr1, expr2); | 8705 expr = new(I) ConditionalExprNode(expr_pos, expr, expr1, expr2); |
| 8706 } | 8706 } |
| 8707 return expr; | 8707 return expr; |
| 8708 } | 8708 } |
| 8709 | 8709 |
| 8710 | 8710 |
| 8711 AstNode* Parser::ParseUnaryExpr() { | 8711 AstNode* Parser::ParseUnaryExpr() { |
| 8712 TRACE_PARSER("ParseUnaryExpr"); | 8712 TRACE_PARSER("ParseUnaryExpr"); |
| 8713 AstNode* expr = NULL; | 8713 AstNode* expr = NULL; |
| 8714 const intptr_t op_pos = TokenPos(); | 8714 const intptr_t op_pos = TokenPos(); |
| 8715 if (IsPrefixOperator(CurrentToken())) { | 8715 if (IsAwaitAsKeyword()) { |
| 8716 TRACE_PARSER("ParseAwaitExpr"); |
| 8717 ConsumeToken(); |
| 8718 parsed_function()->record_await(); |
| 8719 expr = new (I) AwaitNode(TokenPos(), ParseUnaryExpr()); |
| 8720 } else if (IsPrefixOperator(CurrentToken())) { |
| 8716 Token::Kind unary_op = CurrentToken(); | 8721 Token::Kind unary_op = CurrentToken(); |
| 8717 if (unary_op == Token::kSUB) { | 8722 if (unary_op == Token::kSUB) { |
| 8718 unary_op = Token::kNEGATE; | 8723 unary_op = Token::kNEGATE; |
| 8719 } | 8724 } |
| 8720 ConsumeToken(); | 8725 ConsumeToken(); |
| 8721 expr = ParseUnaryExpr(); | 8726 expr = ParseUnaryExpr(); |
| 8722 if (expr->IsPrimaryNode() && (expr->AsPrimaryNode()->IsSuper())) { | 8727 if (expr->IsPrimaryNode() && (expr->AsPrimaryNode()->IsSuper())) { |
| 8723 expr = BuildUnarySuperOperator(unary_op, expr->AsPrimaryNode()); | 8728 expr = BuildUnarySuperOperator(unary_op, expr->AsPrimaryNode()); |
| 8724 } else { | 8729 } else { |
| 8725 expr = UnaryOpNode::UnaryOpOrLiteral(op_pos, unary_op, expr); | 8730 expr = UnaryOpNode::UnaryOpOrLiteral(op_pos, unary_op, expr); |
| (...skipping 2265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10991 TRACE_PARSER("ParsePrimary"); | 10996 TRACE_PARSER("ParsePrimary"); |
| 10992 ASSERT(!is_top_level_); | 10997 ASSERT(!is_top_level_); |
| 10993 AstNode* primary = NULL; | 10998 AstNode* primary = NULL; |
| 10994 const Token::Kind token = CurrentToken(); | 10999 const Token::Kind token = CurrentToken(); |
| 10995 if (IsFunctionLiteral()) { | 11000 if (IsFunctionLiteral()) { |
| 10996 // The name of a literal function is visible from inside the function, but | 11001 // The name of a literal function is visible from inside the function, but |
| 10997 // must not collide with names in the scope declaring the literal. | 11002 // must not collide with names in the scope declaring the literal. |
| 10998 OpenBlock(); | 11003 OpenBlock(); |
| 10999 primary = ParseFunctionStatement(true); | 11004 primary = ParseFunctionStatement(true); |
| 11000 CloseBlock(); | 11005 CloseBlock(); |
| 11001 } else if (IsAwaitAsKeyword()) { | |
| 11002 // The body of an async function is parsed multiple times. The first time | |
| 11003 // when setting up an AsyncFunction() for generating relevant scope | |
| 11004 // information. The second time the body is parsed for actually generating | |
| 11005 // code. | |
| 11006 TRACE_PARSER("ParseAwaitExpr"); | |
| 11007 ConsumeToken(); | |
| 11008 parsed_function()->record_await(); | |
| 11009 primary = new(I) AwaitNode( | |
| 11010 TokenPos(), ParseExpr(kAllowConst, kConsumeCascades)); | |
| 11011 } else if (IsIdentifier()) { | 11006 } else if (IsIdentifier()) { |
| 11012 intptr_t qual_ident_pos = TokenPos(); | 11007 intptr_t qual_ident_pos = TokenPos(); |
| 11013 const LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(I, ParsePrefix()); | 11008 const LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(I, ParsePrefix()); |
| 11014 String& ident = *CurrentLiteral(); | 11009 String& ident = *CurrentLiteral(); |
| 11015 ConsumeToken(); | 11010 ConsumeToken(); |
| 11016 if (prefix.IsNull()) { | 11011 if (prefix.IsNull()) { |
| 11017 if (!ResolveIdentInLocalScope(qual_ident_pos, ident, &primary)) { | 11012 if (!ResolveIdentInLocalScope(qual_ident_pos, ident, &primary)) { |
| 11018 // Check whether the identifier is a type parameter. | 11013 // Check whether the identifier is a type parameter. |
| 11019 if (!current_class().IsNull()) { | 11014 if (!current_class().IsNull()) { |
| 11020 TypeParameter& type_param = TypeParameter::ZoneHandle(I, | 11015 TypeParameter& type_param = TypeParameter::ZoneHandle(I, |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11540 void Parser::SkipQualIdent() { | 11535 void Parser::SkipQualIdent() { |
| 11541 ASSERT(IsIdentifier()); | 11536 ASSERT(IsIdentifier()); |
| 11542 ConsumeToken(); | 11537 ConsumeToken(); |
| 11543 if (CurrentToken() == Token::kPERIOD) { | 11538 if (CurrentToken() == Token::kPERIOD) { |
| 11544 ConsumeToken(); // Consume the kPERIOD token. | 11539 ConsumeToken(); // Consume the kPERIOD token. |
| 11545 ExpectIdentifier("identifier expected after '.'"); | 11540 ExpectIdentifier("identifier expected after '.'"); |
| 11546 } | 11541 } |
| 11547 } | 11542 } |
| 11548 | 11543 |
| 11549 } // namespace dart | 11544 } // namespace dart |
| OLD | NEW |