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

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

Issue 23960003: Disentangle AstNode::Name and AstNode::ShortName. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. 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
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/ast_printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(type, name) \
16 void type::Visit(AstNodeVisitor* visitor) { \ 16 void type::Visit(AstNodeVisitor* visitor) { \
17 visitor->Visit##type(this); \ 17 visitor->Visit##type(this); \
18 } 18 }
19 NODE_LIST(DEFINE_VISIT_FUNCTION) 19 NODE_LIST(DEFINE_VISIT_FUNCTION)
20 #undef DEFINE_VISIT_FUNCTION 20 #undef DEFINE_VISIT_FUNCTION
21 21
22 22
23 #define DEFINE_NAME_FUNCTION(type, name) \ 23 #define DEFINE_NAME_FUNCTION(type, name) \
24 const char* type::ShortName() const { \ 24 const char* type::PrettyName() const { \
25 return name; \ 25 return name; \
26 } 26 }
27 NODE_LIST(DEFINE_NAME_FUNCTION) 27 NODE_LIST(DEFINE_NAME_FUNCTION)
28 #undef DEFINE_NAME_FUNCTION 28 #undef DEFINE_NAME_FUNCTION
29 29
30 30
31 // A visitor class to collect all the nodes (including children) into an 31 // A visitor class to collect all the nodes (including children) into an
32 // array. 32 // array.
33 class AstNodeCollector : public AstNodeVisitor { 33 class AstNodeCollector : public AstNodeVisitor {
34 public: 34 public:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 double new_value = (dbl.value() == 0.0) ? -0.0 : (0.0 - dbl.value()); 130 double new_value = (dbl.value() == 0.0) ? -0.0 : (0.0 - dbl.value());
131 const Double& double_instance = 131 const Double& double_instance =
132 Double::ZoneHandle(Double::NewCanonical(new_value)); 132 Double::ZoneHandle(Double::NewCanonical(new_value));
133 return new LiteralNode(this->token_pos(), double_instance); 133 return new LiteralNode(this->token_pos(), double_instance);
134 } 134 }
135 } 135 }
136 return NULL; 136 return NULL;
137 } 137 }
138 138
139 139
140 const char* TypeNode::Name() const { 140 const char* TypeNode::TypeName() const {
141 return String::Handle(type().UserVisibleName()).ToCString(); 141 return String::Handle(type().UserVisibleName()).ToCString();
142 } 142 }
143 143
144 144
145 bool ComparisonNode::IsKindValid() const { 145 bool ComparisonNode::IsKindValid() const {
146 return Token::IsRelationalOperator(kind_) 146 return Token::IsRelationalOperator(kind_)
147 || Token::IsEqualityOperator(kind_) 147 || Token::IsEqualityOperator(kind_)
148 || Token::IsTypeTestOperator(kind_) 148 || Token::IsTypeTestOperator(kind_)
149 || Token::IsTypeCastOperator(kind_); 149 || Token::IsTypeCastOperator(kind_);
150 } 150 }
151 151
152 152
153 const char* ComparisonNode::Name() const { 153 const char* ComparisonNode::TokenName() const {
154 return Token::Str(kind_); 154 return Token::Str(kind_);
155 } 155 }
156 156
157 157
158 bool ComparisonNode::IsPotentiallyConst() const { 158 bool ComparisonNode::IsPotentiallyConst() const {
159 switch (kind_) { 159 switch (kind_) {
160 case Token::kLT: 160 case Token::kLT:
161 case Token::kGT: 161 case Token::kGT:
162 case Token::kLTE: 162 case Token::kLTE:
163 case Token::kGTE: 163 case Token::kGTE:
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 case Token::kBIT_AND: 232 case Token::kBIT_AND:
233 case Token::kSHL: 233 case Token::kSHL:
234 case Token::kSHR: 234 case Token::kSHR:
235 return true; 235 return true;
236 default: 236 default:
237 return false; 237 return false;
238 } 238 }
239 } 239 }
240 240
241 241
242 const char* BinaryOpNode::Name() const { 242 const char* BinaryOpNode::TokenName() const {
243 return Token::Str(kind_); 243 return Token::Str(kind_);
244 } 244 }
245 245
246 246
247 const char* BinaryOpWithMask32Node::Name() const { 247 const char* BinaryOpWithMask32Node::TokenName() const {
248 return Token::Str(kind()); 248 return Token::Str(kind());
249 } 249 }
250 250
251 251
252 bool BinaryOpNode::IsPotentiallyConst() const { 252 bool BinaryOpNode::IsPotentiallyConst() const {
253 switch (kind_) { 253 switch (kind_) {
254 case Token::kADD: 254 case Token::kADD:
255 case Token::kSUB: 255 case Token::kSUB:
256 case Token::kMUL: 256 case Token::kMUL:
257 case Token::kDIV: 257 case Token::kDIV:
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 return new StaticSetterNode(token_pos(), 398 return new StaticSetterNode(token_pos(),
399 receiver(), 399 receiver(),
400 Class::ZoneHandle(function().Owner()), 400 Class::ZoneHandle(function().Owner()),
401 String::ZoneHandle(function().name()), 401 String::ZoneHandle(function().name()),
402 rhs); 402 rhs);
403 } 403 }
404 return NULL; 404 return NULL;
405 } 405 }
406 406
407 407
408 const char* UnaryOpNode::Name() const { 408 const char* UnaryOpNode::TokenName() const {
409 return Token::Str(kind_); 409 return Token::Str(kind_);
410 } 410 }
411 411
412 412
413 const char* JumpNode::Name() const { 413 const char* JumpNode::TokenName() const {
414 return Token::Str(kind_); 414 return Token::Str(kind_);
415 } 415 }
416 416
417 417
418 const char* LoadLocalNode::Name() const {
419 return local().name().ToCString();
420 }
421
422
423 bool LoadLocalNode::IsPotentiallyConst() const { 418 bool LoadLocalNode::IsPotentiallyConst() const {
424 // Parameters of const constructors are implicitly final and can be 419 // Parameters of const constructors are implicitly final and can be
425 // used in initializer expressions. 420 // used in initializer expressions.
426 // We can't check here whether the local variable is indeed a parameter, 421 // We can't check here whether the local variable is indeed a parameter,
427 // but this code is executed before any other local variables are 422 // but this code is executed before any other local variables are
428 // added to the scope. 423 // added to the scope.
429 return local().is_final(); 424 return local().is_final();
430 } 425 }
431 426
432 427
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 if (result.IsError() || result.IsNull()) { 550 if (result.IsError() || result.IsNull()) {
556 // TODO(turnidge): We could get better error messages by returning 551 // TODO(turnidge): We could get better error messages by returning
557 // the Error object directly to the parser. This will involve 552 // the Error object directly to the parser. This will involve
558 // replumbing all of the EvalConstExpr methods. 553 // replumbing all of the EvalConstExpr methods.
559 return NULL; 554 return NULL;
560 } 555 }
561 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 556 return &Instance::ZoneHandle(Instance::Cast(result).raw());
562 } 557 }
563 558
564 } // namespace dart 559 } // namespace dart
OLDNEW
« 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