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

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

Issue 23923005: Change --print-ast output to be more regular. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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"
11 11
12 12
13 namespace dart { 13 namespace dart {
14 14
15 #define DEFINE_VISIT_FUNCTION(type, name) \ 15 #define DEFINE_VISIT_FUNCTION(BaseName) \
16 void type::Visit(AstNodeVisitor* visitor) { \ 16 void BaseName##Node::Visit(AstNodeVisitor* visitor) { \
17 visitor->Visit##type(this); \ 17 visitor->Visit##BaseName##Node(this); \
18 } 18 }
19 NODE_LIST(DEFINE_VISIT_FUNCTION) 19
20 FOR_EACH_NODE(DEFINE_VISIT_FUNCTION)
20 #undef DEFINE_VISIT_FUNCTION 21 #undef DEFINE_VISIT_FUNCTION
21 22
22 23
23 #define DEFINE_NAME_FUNCTION(type, name) \ 24 #define DEFINE_NAME_FUNCTION(BaseName) \
24 const char* type::PrettyName() const { \ 25 const char* BaseName##Node::PrettyName() const { \
25 return name; \ 26 return #BaseName; \
26 } 27 }
27 NODE_LIST(DEFINE_NAME_FUNCTION) 28
29 FOR_EACH_NODE(DEFINE_NAME_FUNCTION)
28 #undef DEFINE_NAME_FUNCTION 30 #undef DEFINE_NAME_FUNCTION
29 31
30 32
31 // A visitor class to collect all the nodes (including children) into an 33 // A visitor class to collect all the nodes (including children) into an
32 // array. 34 // array.
33 class AstNodeCollector : public AstNodeVisitor { 35 class AstNodeCollector : public AstNodeVisitor {
34 public: 36 public:
35 explicit AstNodeCollector(GrowableArray<AstNode*>* nodes) 37 explicit AstNodeCollector(GrowableArray<AstNode*>* nodes)
36 : nodes_(nodes) { } 38 : nodes_(nodes) { }
37 39
38 #define DEFINE_VISITOR_FUNCTION(type, name) \ 40 #define DEFINE_VISITOR_FUNCTION(BaseName) \
39 virtual void Visit##type(type* node) { \ 41 virtual void Visit##BaseName##Node(BaseName##Node* node) { \
40 nodes_->Add(node); \ 42 nodes_->Add(node); \
41 node->VisitChildren(this); \ 43 node->VisitChildren(this); \
42 } 44 }
43 NODE_LIST(DEFINE_VISITOR_FUNCTION) 45
46 FOR_EACH_NODE(DEFINE_VISITOR_FUNCTION)
44 #undef DEFINE_VISITOR_FUNCTION 47 #undef DEFINE_VISITOR_FUNCTION
45 48
46 private: 49 private:
47 GrowableArray<AstNode*>* nodes_; 50 GrowableArray<AstNode*>* nodes_;
48 DISALLOW_COPY_AND_ASSIGN(AstNodeCollector); 51 DISALLOW_COPY_AND_ASSIGN(AstNodeCollector);
49 }; 52 };
50 53
51 54
52 void SequenceNode::CollectAllNodes(GrowableArray<AstNode*>* nodes) { 55 void SequenceNode::CollectAllNodes(GrowableArray<AstNode*>* nodes) {
53 AstNodeCollector node_collector(nodes); 56 AstNodeCollector node_collector(nodes);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 147
145 bool ComparisonNode::IsKindValid() const { 148 bool ComparisonNode::IsKindValid() const {
146 return Token::IsRelationalOperator(kind_) 149 return Token::IsRelationalOperator(kind_)
147 || Token::IsEqualityOperator(kind_) 150 || Token::IsEqualityOperator(kind_)
148 || Token::IsTypeTestOperator(kind_) 151 || Token::IsTypeTestOperator(kind_)
149 || Token::IsTypeCastOperator(kind_); 152 || Token::IsTypeCastOperator(kind_);
150 } 153 }
151 154
152 155
153 const char* ComparisonNode::TokenName() const { 156 const char* ComparisonNode::TokenName() const {
154 return Token::Str(kind_); 157 return (kind_ == Token::kAS) ? "as" : Token::Str(kind_);
155 } 158 }
156 159
157 160
158 bool ComparisonNode::IsPotentiallyConst() const { 161 bool ComparisonNode::IsPotentiallyConst() const {
159 switch (kind_) { 162 switch (kind_) {
160 case Token::kLT: 163 case Token::kLT:
161 case Token::kGT: 164 case Token::kGT:
162 case Token::kLTE: 165 case Token::kLTE:
163 case Token::kGTE: 166 case Token::kGTE:
164 case Token::kEQ: 167 case Token::kEQ:
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 if (result.IsError() || result.IsNull()) { 553 if (result.IsError() || result.IsNull()) {
551 // TODO(turnidge): We could get better error messages by returning 554 // TODO(turnidge): We could get better error messages by returning
552 // the Error object directly to the parser. This will involve 555 // the Error object directly to the parser. This will involve
553 // replumbing all of the EvalConstExpr methods. 556 // replumbing all of the EvalConstExpr methods.
554 return NULL; 557 return NULL;
555 } 558 }
556 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 559 return &Instance::ZoneHandle(Instance::Cast(result).raw());
557 } 560 }
558 561
559 } // namespace dart 562 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/ast_printer.h » ('j') | runtime/vm/ast_printer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698