| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) | 76 LetNode::LetNode(intptr_t token_pos) |
| 77 : AstNode(token_pos), | 77 : AstNode(token_pos), |
| 78 vars_(1), | 78 vars_(1), |
| 79 initializers_(1), | 79 initializers_(1), |
| 80 body_(NULL) { } | 80 nodes_(1) { } |
| 81 | 81 |
| 82 | 82 |
| 83 LocalVariable* LetNode::AddInitializer(AstNode* node) { | 83 LocalVariable* LetNode::AddInitializer(AstNode* node) { |
| 84 initializers_.Add(node); | 84 initializers_.Add(node); |
| 85 char name[64]; | 85 char name[64]; |
| 86 OS::SNPrint(name, sizeof(name), ":lt%"Pd"_%d", token_pos(), vars_.length()); | 86 OS::SNPrint(name, sizeof(name), ":lt%"Pd"_%d", token_pos(), vars_.length()); |
| 87 LocalVariable* temp_var = | 87 LocalVariable* temp_var = |
| 88 new LocalVariable(token_pos(), | 88 new LocalVariable(token_pos(), |
| 89 String::ZoneHandle(Symbols::New(name)), | 89 String::ZoneHandle(Symbols::New(name)), |
| 90 Type::ZoneHandle(Type::DynamicType())); | 90 Type::ZoneHandle(Type::DynamicType())); |
| 91 vars_.Add(temp_var); | 91 vars_.Add(temp_var); |
| 92 return temp_var; | 92 return temp_var; |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 void LetNode::VisitChildren(AstNodeVisitor* visitor) const { | 96 void LetNode::VisitChildren(AstNodeVisitor* visitor) const { |
| 97 for (intptr_t i = 0; i < num_temps(); ++i) { | 97 for (intptr_t i = 0; i < num_temps(); ++i) { |
| 98 initializers_[i]->Visit(visitor); | 98 initializers_[i]->Visit(visitor); |
| 99 } | 99 } |
| 100 body_->Visit(visitor); | 100 for (intptr_t i = 0; i < nodes_.length(); ++i) { |
| 101 nodes_[i]->Visit(visitor); |
| 102 } |
| 101 } | 103 } |
| 102 | 104 |
| 103 | 105 |
| 104 void ArrayNode::VisitChildren(AstNodeVisitor* visitor) const { | 106 void ArrayNode::VisitChildren(AstNodeVisitor* visitor) const { |
| 105 for (intptr_t i = 0; i < this->length(); i++) { | 107 for (intptr_t i = 0; i < this->length(); i++) { |
| 106 ElementAt(i)->Visit(visitor); | 108 ElementAt(i)->Visit(visitor); |
| 107 } | 109 } |
| 108 } | 110 } |
| 109 | 111 |
| 110 | 112 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 if (result.IsError() || result.IsNull()) { | 460 if (result.IsError() || result.IsNull()) { |
| 459 // TODO(turnidge): We could get better error messages by returning | 461 // TODO(turnidge): We could get better error messages by returning |
| 460 // the Error object directly to the parser. This will involve | 462 // the Error object directly to the parser. This will involve |
| 461 // replumbing all of the EvalConstExpr methods. | 463 // replumbing all of the EvalConstExpr methods. |
| 462 return NULL; | 464 return NULL; |
| 463 } | 465 } |
| 464 return &Instance::ZoneHandle(Instance::Cast(result).raw()); | 466 return &Instance::ZoneHandle(Instance::Cast(result).raw()); |
| 465 } | 467 } |
| 466 | 468 |
| 467 } // namespace dart | 469 } // namespace dart |
| OLD | NEW |