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

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

Issue 9592031: Eliminate IncrOpStaticFieldNode, replace a set of nodes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | 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 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 // The temporary variables are necessary so that the argument 1692 // The temporary variables are necessary so that the argument
1693 // expressions are not evaluated twice. 1693 // expressions are not evaluated twice.
1694 ArgumentListNode* ctor_args = super_call->arguments(); 1694 ArgumentListNode* ctor_args = super_call->arguments();
1695 // The super initializer call has at least 2 arguments: the 1695 // The super initializer call has at least 2 arguments: the
1696 // implicit receiver, and the hidden construction phase. 1696 // implicit receiver, and the hidden construction phase.
1697 ASSERT(ctor_args->length() >= 2); 1697 ASSERT(ctor_args->length() >= 2);
1698 for (int i = 2; i < ctor_args->length(); i++) { 1698 for (int i = 2; i < ctor_args->length(); i++) {
1699 AstNode* arg = ctor_args->NodeAt(i); 1699 AstNode* arg = ctor_args->NodeAt(i);
1700 if (!arg->IsLoadLocalNode() && !arg->IsLiteralNode()) { 1700 if (!arg->IsLoadLocalNode() && !arg->IsLiteralNode()) {
1701 LocalVariable* temp = 1701 LocalVariable* temp =
1702 CreateTempConstVariable(arg->token_index(), arg->id(), "sca"); 1702 CreateTempConstVariable(arg->token_index(), arg->id(), "sca");
1703 AstNode* save_temp = 1703 AstNode* save_temp =
1704 new StoreLocalNode(arg->token_index(), *temp, arg); 1704 new StoreLocalNode(arg->token_index(), *temp, arg);
1705 ctor_args->SetNodeAt(i, save_temp); 1705 ctor_args->SetNodeAt(i, save_temp);
1706 } 1706 }
1707 } 1707 }
1708 } 1708 }
1709 OpenBlock(); // Block to collect constructor body nodes. 1709 OpenBlock(); // Block to collect constructor body nodes.
1710 1710
1711 // Insert the implicit super call to the super constructor body. 1711 // Insert the implicit super call to the super constructor body.
1712 if (super_call != NULL) { 1712 if (super_call != NULL) {
1713 ArgumentListNode* initializer_args = super_call->arguments(); 1713 ArgumentListNode* initializer_args = super_call->arguments();
1714 const Function& super_ctor = super_call->function(); 1714 const Function& super_ctor = super_call->function();
(...skipping 2459 matching lines...) Expand 10 before | Expand all | Expand 10 after
4174 } 4174 }
4175 4175
4176 4176
4177 void Parser::ParseStatementSequence() { 4177 void Parser::ParseStatementSequence() {
4178 TRACE_PARSER("ParseStatementSequence"); 4178 TRACE_PARSER("ParseStatementSequence");
4179 const bool dead_code_allowed = true; 4179 const bool dead_code_allowed = true;
4180 bool abrupt_completing_seen = false; 4180 bool abrupt_completing_seen = false;
4181 while (CurrentToken() != Token::kRBRACE) { 4181 while (CurrentToken() != Token::kRBRACE) {
4182 const intptr_t statement_pos = token_index_; 4182 const intptr_t statement_pos = token_index_;
4183 AstNode* statement = ParseStatement(); 4183 AstNode* statement = ParseStatement();
4184 if (statement != NULL) { 4184 // Do not add statements with no effect (e.g., LoadLocalNode).
4185 if (statement != NULL && !statement->IsLoadLocalNode()) {
4185 if (!dead_code_allowed && abrupt_completing_seen) { 4186 if (!dead_code_allowed && abrupt_completing_seen) {
4186 ErrorMsg(statement_pos, "dead code after abrupt completing statement"); 4187 ErrorMsg(statement_pos, "dead code after abrupt completing statement");
4187 } 4188 }
4188 current_block_->statements->Add(statement); 4189 current_block_->statements->Add(statement);
4189 abrupt_completing_seen |= IsAbruptCompleting(statement); 4190 abrupt_completing_seen |= IsAbruptCompleting(statement);
4190 } 4191 }
4191 } 4192 }
4192 } 4193 }
4193 4194
4194 4195
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
5847 } else { 5848 } else {
5848 expr = UnaryOpNode::UnaryOpOrLiteral(op_pos, unary_op, expr); 5849 expr = UnaryOpNode::UnaryOpOrLiteral(op_pos, unary_op, expr);
5849 } 5850 }
5850 } else if (IsIncrementOperator(CurrentToken())) { 5851 } else if (IsIncrementOperator(CurrentToken())) {
5851 Token::Kind incr_op = CurrentToken(); 5852 Token::Kind incr_op = CurrentToken();
5852 ConsumeToken(); 5853 ConsumeToken();
5853 expr = ParseUnaryExpr(); 5854 expr = ParseUnaryExpr();
5854 if (!IsAssignableExpr(expr)) { 5855 if (!IsAssignableExpr(expr)) {
5855 ErrorMsg("expression is not assignable"); 5856 ErrorMsg("expression is not assignable");
5856 } 5857 }
5857 // is_prefix. 5858 // TODO(srdjan): Implement transformation for all.
5858 AstNode* incr_op_node = expr->MakeIncrOpNode(op_pos, incr_op, true); 5859 if (expr->IsLoadStaticFieldNode() || expr->IsStaticGetterNode()) {
5859 if (incr_op_node == NULL) { 5860 Token::Kind binary_op =
5860 Unimplemented("incr operation not implemented"); 5861 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB;
5862 BinaryOpNode* add = new BinaryOpNode(
5863 op_pos,
5864 binary_op,
5865 expr,
5866 new LiteralNode(op_pos, Smi::ZoneHandle(Smi::New(1))));
5867 AstNode* store = expr->MakeAssignmentNode(add);
5868 expr = store;
5869 } else {
5870 // is_prefix.
5871 AstNode* incr_op_node = expr->MakeIncrOpNode(op_pos, incr_op, true);
5872 if (incr_op_node == NULL) {
5873 Unimplemented("incr operation not implemented");
5874 }
5875 expr = incr_op_node;
5861 } 5876 }
5862 expr = incr_op_node;
5863 } else { 5877 } else {
5864 expr = ParsePostfixExpr(); 5878 expr = ParsePostfixExpr();
5865 } 5879 }
5866 return expr; 5880 return expr;
5867 } 5881 }
5868 5882
5869 5883
5870 ArgumentListNode* Parser::ParseActualParameters( 5884 ArgumentListNode* Parser::ParseActualParameters(
5871 ArgumentListNode* implicit_arguments, 5885 ArgumentListNode* implicit_arguments,
5872 bool require_const) { 5886 bool require_const) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
6317 postfix_expr = selector; 6331 postfix_expr = selector;
6318 } 6332 }
6319 if (IsIncrementOperator(CurrentToken())) { 6333 if (IsIncrementOperator(CurrentToken())) {
6320 TRACE_PARSER("IncrementOperator"); 6334 TRACE_PARSER("IncrementOperator");
6321 Token::Kind incr_op = CurrentToken(); 6335 Token::Kind incr_op = CurrentToken();
6322 if (!IsAssignableExpr(postfix_expr)) { 6336 if (!IsAssignableExpr(postfix_expr)) {
6323 ErrorMsg("expression is not assignable"); 6337 ErrorMsg("expression is not assignable");
6324 } 6338 }
6325 ConsumeToken(); 6339 ConsumeToken();
6326 // Not prefix. 6340 // Not prefix.
6327 AstNode* incr_op_node = 6341 if (postfix_expr->IsLoadStaticFieldNode() ||
6328 postfix_expr->MakeIncrOpNode(postfix_expr_pos, incr_op, false); 6342 postfix_expr->IsStaticGetterNode()) {
6329 if (incr_op_node == NULL) { 6343 LocalVariable* temp = CreateTempConstVariable(
6330 Unimplemented("incr op not implemented"); 6344 postfix_expr_pos, postfix_expr->id(), "incoplix");
6345 AstNode* save =
6346 new StoreLocalNode(postfix_expr_pos, *temp, postfix_expr);
6347 current_block_->statements->Add(save);
6348 LoadLocalNode* load = new LoadLocalNode(postfix_expr_pos, *temp);
6349 Token::Kind binary_op =
6350 (incr_op == Token::kINCR) ? Token::kADD : Token::kSUB;
6351 BinaryOpNode* add = new BinaryOpNode(
6352 postfix_expr_pos,
6353 binary_op,
6354 load,
6355 new LiteralNode(postfix_expr_pos, Smi::ZoneHandle(Smi::New(1))));
6356 AstNode* store = postfix_expr->MakeAssignmentNode(add);
6357 current_block_->statements->Add(store);
6358 LoadLocalNode* load_res = new LoadLocalNode(postfix_expr_pos, *temp);
6359 return load_res;
6360 } else {
6361 AstNode* incr_op_node =
6362 postfix_expr->MakeIncrOpNode(postfix_expr_pos, incr_op, false);
6363 if (incr_op_node == NULL) {
6364 Unimplemented("incr op not implemented");
6365 }
6366 postfix_expr = incr_op_node;
6331 } 6367 }
6332 postfix_expr = incr_op_node;
6333 } 6368 }
6334 return postfix_expr; 6369 return postfix_expr;
6335 } 6370 }
6336 6371
6337 6372
6338 // Resolve the given type and its type arguments from the given scope class 6373 // Resolve the given type and its type arguments from the given scope class
6339 // according to the given type finalization mode. 6374 // according to the given type finalization mode.
6340 // If the given scope class is null, use the current library, but do not try to 6375 // If the given scope class is null, use the current library, but do not try to
6341 // resolve type parameters. 6376 // resolve type parameters.
6342 // Not all involved type classes may get resolved yet, but at least the type 6377 // Not all involved type classes may get resolved yet, but at least the type
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
8054 void Parser::SkipQualIdent() { 8089 void Parser::SkipQualIdent() {
8055 ASSERT(IsIdentifier()); 8090 ASSERT(IsIdentifier());
8056 ConsumeToken(); 8091 ConsumeToken();
8057 if (CurrentToken() == Token::kPERIOD) { 8092 if (CurrentToken() == Token::kPERIOD) {
8058 ConsumeToken(); // Consume the kPERIOD token. 8093 ConsumeToken(); // Consume the kPERIOD token.
8059 ExpectIdentifier("identifier expected after '.'"); 8094 ExpectIdentifier("identifier expected after '.'");
8060 } 8095 }
8061 } 8096 }
8062 8097
8063 } // namespace dart 8098 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698