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