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

Side by Side Diff: runtime/vm/parser.cc

Issue 15935005: Remove pseudo-node from LoadLocalNode and replace it with a proper AST node. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
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 "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 if (is_no_such_method) { 1510 if (is_no_such_method) {
1511 arguments = BuildNoSuchMethodArguments( 1511 arguments = BuildNoSuchMethodArguments(
1512 supercall_pos, function_name, *arguments); 1512 supercall_pos, function_name, *arguments);
1513 } 1513 }
1514 return new StaticCallNode(supercall_pos, super_function, arguments); 1514 return new StaticCallNode(supercall_pos, super_function, arguments);
1515 } 1515 }
1516 1516
1517 1517
1518 // Simple test if a node is side effect free. 1518 // Simple test if a node is side effect free.
1519 static bool IsSimpleLocalOrLiteralNode(AstNode* node) { 1519 static bool IsSimpleLocalOrLiteralNode(AstNode* node) {
1520 if (node->IsLiteralNode()) { 1520 return node->IsLiteralNode() || node->IsLoadLocalNode();
1521 return true;
1522 }
1523 if (node->IsLoadLocalNode() && !node->AsLoadLocalNode()->HasPseudo()) {
1524 return true;
1525 }
1526 return false;
1527 } 1521 }
1528 1522
1529 1523
1530 AstNode* Parser::BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super) { 1524 AstNode* Parser::BuildUnarySuperOperator(Token::Kind op, PrimaryNode* super) {
1531 ASSERT(super->IsSuper()); 1525 ASSERT(super->IsSuper());
1532 AstNode* super_op = NULL; 1526 AstNode* super_op = NULL;
1533 const intptr_t super_pos = super->token_pos(); 1527 const intptr_t super_pos = super->token_pos();
1534 if ((op == Token::kNEGATE) || 1528 if ((op == Token::kNEGATE) ||
1535 (op == Token::kBIT_NOT)) { 1529 (op == Token::kBIT_NOT)) {
1536 // Resolve the operator function in the superclass. 1530 // Resolve the operator function in the superclass.
(...skipping 3873 matching lines...) Expand 10 before | Expand all | Expand 10 after
5410 void Parser::ParseStatementSequence() { 5404 void Parser::ParseStatementSequence() {
5411 TRACE_PARSER("ParseStatementSequence"); 5405 TRACE_PARSER("ParseStatementSequence");
5412 const bool dead_code_allowed = true; 5406 const bool dead_code_allowed = true;
5413 bool abrupt_completing_seen = false; 5407 bool abrupt_completing_seen = false;
5414 while (CurrentToken() != Token::kRBRACE) { 5408 while (CurrentToken() != Token::kRBRACE) {
5415 const intptr_t statement_pos = TokenPos(); 5409 const intptr_t statement_pos = TokenPos();
5416 AstNode* statement = ParseStatement(); 5410 AstNode* statement = ParseStatement();
5417 // Do not add statements with no effect (e.g., LoadLocalNode). 5411 // Do not add statements with no effect (e.g., LoadLocalNode).
5418 if ((statement != NULL) && statement->IsLoadLocalNode()) { 5412 if ((statement != NULL) && statement->IsLoadLocalNode()) {
5419 // Skip load local. 5413 // Skip load local.
5420 statement = statement->AsLoadLocalNode()->pseudo(); 5414 continue;
5421 } 5415 }
5422 if (statement != NULL) { 5416 if (statement != NULL) {
5423 if (!dead_code_allowed && abrupt_completing_seen) { 5417 if (!dead_code_allowed && abrupt_completing_seen) {
5424 ErrorMsg(statement_pos, "dead code after abrupt completing statement"); 5418 ErrorMsg(statement_pos, "dead code after abrupt completing statement");
5425 } 5419 }
5426 current_block_->statements->Add(statement); 5420 current_block_->statements->Add(statement);
5427 abrupt_completing_seen |= IsAbruptCompleting(statement); 5421 abrupt_completing_seen |= IsAbruptCompleting(statement);
5428 } 5422 }
5429 } 5423 }
5430 } 5424 }
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
6876 op_pos, op_kind, left_operand, right_operand); 6870 op_pos, op_kind, left_operand, right_operand);
6877 } 6871 }
6878 } 6872 }
6879 current_preced--; 6873 current_preced--;
6880 } 6874 }
6881 return left_operand; 6875 return left_operand;
6882 } 6876 }
6883 6877
6884 6878
6885 bool Parser::IsAssignableExpr(AstNode* expr) { 6879 bool Parser::IsAssignableExpr(AstNode* expr) {
6886 return (expr->IsLoadLocalNode() && !expr->AsLoadLocalNode()->HasPseudo() 6880 return (expr->IsLoadLocalNode()
6887 && (!expr->AsLoadLocalNode()->local().is_final())) 6881 && (!expr->AsLoadLocalNode()->local().is_final()))
6888 || expr->IsLoadStaticFieldNode() 6882 || expr->IsLoadStaticFieldNode()
6889 || expr->IsStaticGetterNode() 6883 || expr->IsStaticGetterNode()
6890 || expr->IsInstanceGetterNode() 6884 || expr->IsInstanceGetterNode()
6891 || expr->IsLoadIndexedNode() 6885 || expr->IsLoadIndexedNode()
6892 || (expr->IsPrimaryNode() && !expr->AsPrimaryNode()->IsSuper()); 6886 || (expr->IsPrimaryNode() && !expr->AsPrimaryNode()->IsSuper());
6893 } 6887 }
6894 6888
6895 6889
6896 AstNode* Parser::ParseExprList() { 6890 AstNode* Parser::ParseExprList() {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
7169 ErrorMsg(assignment_pos, 7163 ErrorMsg(assignment_pos,
7170 "left hand side of '%s' is not assignable", 7164 "left hand side of '%s' is not assignable",
7171 Token::Str(assignment_op)); 7165 Token::Str(assignment_op));
7172 } 7166 }
7173 expr = assign_expr; 7167 expr = assign_expr;
7174 } 7168 }
7175 cascade->Add(expr); 7169 cascade->Add(expr);
7176 } 7170 }
7177 // The result is a pair of the (side effects of the) cascade sequence 7171 // The result is a pair of the (side effects of the) cascade sequence
7178 // followed by the (value of the) receiver temp variable load. 7172 // followed by the (value of the) receiver temp variable load.
7179 return new LoadLocalNode(cascade_pos, cascade_receiver_var, cascade); 7173 return new CommaNode(
7174 cascade_pos,
7175 cascade,
7176 new LoadLocalNode(cascade_pos, cascade_receiver_var));
7180 } 7177 }
7181 7178
7182 7179
7183 AstNode* Parser::ParseExpr(bool require_compiletime_const, 7180 AstNode* Parser::ParseExpr(bool require_compiletime_const,
7184 bool consume_cascades) { 7181 bool consume_cascades) {
7185 TRACE_PARSER("ParseExpr"); 7182 TRACE_PARSER("ParseExpr");
7186 const intptr_t expr_pos = TokenPos(); 7183 const intptr_t expr_pos = TokenPos();
7187 7184
7188 if (CurrentToken() == Token::kTHROW) { 7185 if (CurrentToken() == Token::kTHROW) {
7189 ConsumeToken(); 7186 ConsumeToken();
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
7780 Token::Kind binary_op = 7777 Token::Kind binary_op =
7781 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB; 7778 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB;
7782 BinaryOpNode* add = new BinaryOpNode( 7779 BinaryOpNode* add = new BinaryOpNode(
7783 postfix_expr_pos, 7780 postfix_expr_pos,
7784 binary_op, 7781 binary_op,
7785 save, 7782 save,
7786 new LiteralNode(postfix_expr_pos, Smi::ZoneHandle(Smi::New(1)))); 7783 new LiteralNode(postfix_expr_pos, Smi::ZoneHandle(Smi::New(1))));
7787 AstNode* store = CreateAssignmentNode(left_expr, add); 7784 AstNode* store = CreateAssignmentNode(left_expr, add);
7788 // The result is a pair of the (side effects of the) store followed by 7785 // The result is a pair of the (side effects of the) store followed by
7789 // the (value of the) initial value temp variable load. 7786 // the (value of the) initial value temp variable load.
7790 LoadLocalNode* load_res = 7787 return new CommaNode(
7791 new LoadLocalNode(postfix_expr_pos, temp, store); 7788 postfix_expr_pos,
7792 return load_res; 7789 store,
7790 new LoadLocalNode(postfix_expr_pos, temp));
7793 } 7791 }
7794 return postfix_expr; 7792 return postfix_expr;
7795 } 7793 }
7796 7794
7797 7795
7798 // Resolve the given type and its type arguments from the given scope class 7796 // Resolve the given type and its type arguments from the given scope class
7799 // according to the given type finalization mode. 7797 // according to the given type finalization mode.
7800 // If the given scope class is null, use the current library, but do not try to 7798 // If the given scope class is null, use the current library, but do not try to
7801 // resolve type parameters. 7799 // resolve type parameters.
7802 // Not all involved type classes may get resolved yet, but at least the type 7800 // Not all involved type classes may get resolved yet, but at least the type
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after
9990 void Parser::SkipQualIdent() { 9988 void Parser::SkipQualIdent() {
9991 ASSERT(IsIdentifier()); 9989 ASSERT(IsIdentifier());
9992 ConsumeToken(); 9990 ConsumeToken();
9993 if (CurrentToken() == Token::kPERIOD) { 9991 if (CurrentToken() == Token::kPERIOD) {
9994 ConsumeToken(); // Consume the kPERIOD token. 9992 ConsumeToken(); // Consume the kPERIOD token.
9995 ExpectIdentifier("identifier expected after '.'"); 9993 ExpectIdentifier("identifier expected after '.'");
9996 } 9994 }
9997 } 9995 }
9998 9996
9999 } // namespace dart 9997 } // namespace dart
OLDNEW
« runtime/vm/flow_graph_builder.cc ('K') | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698