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

Unified 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: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/ast_printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.cc
===================================================================
--- runtime/vm/ast.cc (revision 23243)
+++ runtime/vm/ast.cc (working copy)
@@ -73,6 +73,34 @@
}
+LetNode::LetNode(intptr_t token_pos)
+ : AstNode(token_pos),
+ vars_(1),
+ initializers_(1),
+ body_(NULL) { }
+
+
+LocalVariable* LetNode::AddInitializer(AstNode* node) {
+ initializers_.Add(node);
+ char name[64];
+ OS::SNPrint(name, sizeof(name), ":lt%"Pd"_%d", token_pos(), vars_.length());
+ LocalVariable* temp_var =
+ new LocalVariable(token_pos(),
+ String::ZoneHandle(Symbols::New(name)),
+ Type::ZoneHandle(Type::DynamicType()));
+ vars_.Add(temp_var);
+ return temp_var;
+}
+
+
+void LetNode::VisitChildren(AstNodeVisitor* visitor) const {
+ for (intptr_t i = 0; i < num_temps(); ++i) {
+ initializers_[i]->Visit(visitor);
+ }
+ body_->Visit(visitor);
+}
+
+
void ArrayNode::VisitChildren(AstNodeVisitor* visitor) const {
for (intptr_t i = 0; i < this->length(); i++) {
ElementAt(i)->Visit(visitor);
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/ast_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698