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

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

Issue 14942010: Eliminate temporary locals for some expressions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: cleaned up 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) 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 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 68
69 void ArgumentListNode::VisitChildren(AstNodeVisitor* visitor) const { 69 void ArgumentListNode::VisitChildren(AstNodeVisitor* visitor) const {
70 for (intptr_t i = 0; i < this->length(); i++) { 70 for (intptr_t i = 0; i < this->length(); i++) {
71 NodeAt(i)->Visit(visitor); 71 NodeAt(i)->Visit(visitor);
72 } 72 }
73 } 73 }
74 74
75 75
76 LetNode::LetNode(intptr_t token_pos, intptr_t num_temps)
77 : AstNode(token_pos),
78 vars_(num_temps),
79 temp_expressions_(num_temps),
80 body_(NULL) {
81 for (intptr_t i = 0; i < num_temps; ++i) {
82 char name[64];
83 OS::SNPrint(name, 64, ":lt%"Pd"_%"Pd, token_pos, i);
hausner 2013/05/28 17:00:47 64 -> sizeof name For our own debugging purposes,
Florian Schneider 2013/05/30 09:29:31 Done.
84 vars_.Add(
85 new LocalVariable(token_pos,
86 String::ZoneHandle(Symbols::New(name)),
87 Type::ZoneHandle(Type::DynamicType())));
88 temp_expressions_.Add(NULL);
89 }
90 }
91
92
93 void LetNode::VisitChildren(AstNodeVisitor* visitor) const {
94 for (intptr_t i = 0; i < num_temps(); ++i) {
95 temp_expressions_[i]->Visit(visitor);
96 }
97 body_->Visit(visitor);
98 }
99
100
76 void ArrayNode::VisitChildren(AstNodeVisitor* visitor) const { 101 void ArrayNode::VisitChildren(AstNodeVisitor* visitor) const {
77 for (intptr_t i = 0; i < this->length(); i++) { 102 for (intptr_t i = 0; i < this->length(); i++) {
78 ElementAt(i)->Visit(visitor); 103 ElementAt(i)->Visit(visitor);
79 } 104 }
80 } 105 }
81 106
82 107
83 // TODO(srdjan): Add code for logical negation. 108 // TODO(srdjan): Add code for logical negation.
84 AstNode* LiteralNode::ApplyUnaryOp(Token::Kind unary_op_kind) { 109 AstNode* LiteralNode::ApplyUnaryOp(Token::Kind unary_op_kind) {
85 if (unary_op_kind == Token::kNEGATE) { 110 if (unary_op_kind == Token::kNEGATE) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (result.IsError() || result.IsNull()) { 455 if (result.IsError() || result.IsNull()) {
431 // TODO(turnidge): We could get better error messages by returning 456 // TODO(turnidge): We could get better error messages by returning
432 // the Error object directly to the parser. This will involve 457 // the Error object directly to the parser. This will involve
433 // replumbing all of the EvalConstExpr methods. 458 // replumbing all of the EvalConstExpr methods.
434 return NULL; 459 return NULL;
435 } 460 }
436 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 461 return &Instance::ZoneHandle(Instance::Cast(result).raw());
437 } 462 }
438 463
439 } // namespace dart 464 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698