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

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

Issue 10350003: Step toward eliminating increment nodes, starting with increment local. Fix a bug in evaluating sid… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/ast.h" 5 #include "vm/ast.h"
6 #include "vm/compiler.h" 6 #include "vm/compiler.h"
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 10
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return NULL; 291 return NULL;
292 } 292 }
293 } 293 }
294 294
295 295
296 const char* UnaryOpNode::Name() const { 296 const char* UnaryOpNode::Name() const {
297 return Token::Str(kind_); 297 return Token::Str(kind_);
298 } 298 }
299 299
300 300
301 const char* IncrOpLocalNode::Name() const {
302 switch (kind_) {
303 case Token::kINCR:
304 return prefix_ ? "local_pre_++" : "local_post_++";
305 case Token::kDECR:
306 return prefix_ ? "local_pre_--" : "local_post_--";
307 default:
308 UNREACHABLE();
309 return NULL;
310 }
311 }
312
313
314 const char* IncrOpInstanceFieldNode::Name() const { 301 const char* IncrOpInstanceFieldNode::Name() const {
315 switch (kind_) { 302 switch (kind_) {
316 case Token::kINCR: 303 case Token::kINCR:
317 return prefix_ ? "instance_field_pre_++" : "instance_field_post_++"; 304 return prefix_ ? "instance_field_pre_++" : "instance_field_post_++";
318 case Token::kDECR: 305 case Token::kDECR:
319 return prefix_ ? "instance_field_pre_--" : "instance_field_post_--"; 306 return prefix_ ? "instance_field_pre_--" : "instance_field_post_--";
320 default: 307 default:
321 UNREACHABLE(); 308 UNREACHABLE();
322 return NULL; 309 return NULL;
323 } 310 }
(...skipping 15 matching lines...) Expand all
339 UNREACHABLE(); 326 UNREACHABLE();
340 return NULL; 327 return NULL;
341 } 328 }
342 } 329 }
343 330
344 331
345 AstNode* LoadLocalNode::MakeAssignmentNode(AstNode* rhs) { 332 AstNode* LoadLocalNode::MakeAssignmentNode(AstNode* rhs) {
346 if (local().is_final()) { 333 if (local().is_final()) {
347 return NULL; 334 return NULL;
348 } 335 }
336 if (HasPseudo()) {
337 return NULL;
338 }
349 return new StoreLocalNode(token_index(), local(), rhs); 339 return new StoreLocalNode(token_index(), local(), rhs);
350 } 340 }
351 341
352 342
353 AstNode* LoadLocalNode::MakeIncrOpNode(intptr_t token_index, 343 AstNode* LoadLocalNode::MakeIncrOpNode(intptr_t token_index,
354 Token::Kind kind, 344 Token::Kind kind,
355 bool is_prefix) { 345 bool is_prefix) {
356 if (local().is_final()) { 346 if (local().is_final()) {
357 return NULL; 347 return NULL;
358 } 348 }
359 return new IncrOpLocalNode(token_index, kind, is_prefix, local()); 349 if (is_prefix) {
350 const Instance& literal = Instance::ZoneHandle(Smi::New(1));
351 AstNode* lhs = this;
352 LiteralNode* rhs = new LiteralNode(token_index, literal);
353 Token::Kind binop_kind = (kind == Token::kINCR) ? Token::kADD : Token::kSUB;
354 BinaryOpNode* result = new BinaryOpNode(token_index, binop_kind, lhs, rhs);
355 StoreLocalNode* store = new StoreLocalNode(token_index, local(), result);
356 return store;
357 }
358 UNIMPLEMENTED();
359 return NULL;
360 } 360 }
361 361
362 362
363 AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) { 363 AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) {
364 return new StoreStaticFieldNode(token_index(), field(), rhs); 364 return new StoreStaticFieldNode(token_index(), field(), rhs);
365 } 365 }
366 366
367 367
368 AstNode* LoadStaticFieldNode::MakeIncrOpNode(intptr_t token_index, 368 AstNode* LoadStaticFieldNode::MakeIncrOpNode(intptr_t token_index,
369 Token::Kind kind, 369 Token::Kind kind,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // the Error object directly to the parser. This will involve 458 // the Error object directly to the parser. This will involve
459 // replumbing all of the EvalConstExpr methods. 459 // replumbing all of the EvalConstExpr methods.
460 return NULL; 460 return NULL;
461 } 461 }
462 Instance& field_value = Instance::ZoneHandle(); 462 Instance& field_value = Instance::ZoneHandle();
463 field_value ^= result.raw(); 463 field_value ^= result.raw();
464 return &field_value; 464 return &field_value;
465 } 465 }
466 466
467 } // namespace dart 467 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/ast_printer.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698