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

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

Issue 11265047: Implement const expressions for local variables (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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/object.h » ('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"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 const char* UnaryOpNode::Name() const { 296 const char* UnaryOpNode::Name() const {
297 return Token::Str(kind_); 297 return Token::Str(kind_);
298 } 298 }
299 299
300 300
301 const char* JumpNode::Name() const { 301 const char* JumpNode::Name() const {
302 return Token::Str(kind_); 302 return Token::Str(kind_);
303 } 303 }
304 304
305 305
306 const Instance* LoadLocalNode::EvalConstExpr() const {
307 if (local().IsConst()) {
308 return local().ConstValue();
309 }
310 return NULL;
311 }
312
313
306 AstNode* LoadLocalNode::MakeAssignmentNode(AstNode* rhs) { 314 AstNode* LoadLocalNode::MakeAssignmentNode(AstNode* rhs) {
307 if (local().is_final()) { 315 if (local().is_final()) {
308 return NULL; 316 return NULL;
309 } 317 }
310 if (HasPseudo()) { 318 if (HasPseudo()) {
311 return NULL; 319 return NULL;
312 } 320 }
313 return new StoreLocalNode(token_pos(), &local(), rhs); 321 return new StoreLocalNode(token_pos(), &local(), rhs);
314 } 322 }
315 323
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 if (result.IsError() || result.IsNull()) { 435 if (result.IsError() || result.IsNull()) {
428 // TODO(turnidge): We could get better error messages by returning 436 // TODO(turnidge): We could get better error messages by returning
429 // the Error object directly to the parser. This will involve 437 // the Error object directly to the parser. This will involve
430 // replumbing all of the EvalConstExpr methods. 438 // replumbing all of the EvalConstExpr methods.
431 return NULL; 439 return NULL;
432 } 440 }
433 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 441 return &Instance::ZoneHandle(Instance::Cast(result).raw());
434 } 442 }
435 443
436 } // namespace dart 444 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/ast.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698