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

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

Issue 227863002: Add const static field optimization that got lost in last checkin (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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 | « no previous file | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 10540 matching lines...) Expand 10 before | Expand all | Expand 10 after
10551 10551
10552 10552
10553 // Evaluate expression in expr and return the value. The expression must 10553 // Evaluate expression in expr and return the value. The expression must
10554 // be a compile time constant. 10554 // be a compile time constant.
10555 const Instance& Parser::EvaluateConstExpr(intptr_t expr_pos, AstNode* expr) { 10555 const Instance& Parser::EvaluateConstExpr(intptr_t expr_pos, AstNode* expr) {
10556 if (expr->IsLiteralNode()) { 10556 if (expr->IsLiteralNode()) {
10557 return expr->AsLiteralNode()->literal(); 10557 return expr->AsLiteralNode()->literal();
10558 } else if (expr->IsLoadLocalNode() && 10558 } else if (expr->IsLoadLocalNode() &&
10559 expr->AsLoadLocalNode()->local().IsConst()) { 10559 expr->AsLoadLocalNode()->local().IsConst()) {
10560 return *expr->AsLoadLocalNode()->local().ConstValue(); 10560 return *expr->AsLoadLocalNode()->local().ConstValue();
10561 } else if (expr->IsLoadStaticFieldNode()) {
10562 const Field& field = expr->AsLoadStaticFieldNode()->field();
10563 // We already checked that this field is const and has been
10564 // initialized.
10565 ASSERT(field.is_const());
10566 ASSERT(field.value() != Object::sentinel().raw());
10567 ASSERT(field.value() != Object::transition_sentinel().raw());
10568 return Instance::ZoneHandle(field.value());
10561 } else { 10569 } else {
10562 ASSERT(expr->EvalConstExpr() != NULL); 10570 ASSERT(expr->EvalConstExpr() != NULL);
10563 ReturnNode* ret = new ReturnNode(expr->token_pos(), expr); 10571 ReturnNode* ret = new ReturnNode(expr->token_pos(), expr);
10564 // Compile time constant expressions cannot reference anything from a 10572 // Compile time constant expressions cannot reference anything from a
10565 // local scope. 10573 // local scope.
10566 LocalScope* empty_scope = new LocalScope(NULL, 0, 0); 10574 LocalScope* empty_scope = new LocalScope(NULL, 0, 0);
10567 SequenceNode* seq = new SequenceNode(expr->token_pos(), empty_scope); 10575 SequenceNode* seq = new SequenceNode(expr->token_pos(), empty_scope);
10568 seq->Add(ret); 10576 seq->Add(ret);
10569 10577
10570 Object& result = Object::Handle(Compiler::ExecuteOnce(seq)); 10578 Object& result = Object::Handle(Compiler::ExecuteOnce(seq));
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
10905 void Parser::SkipQualIdent() { 10913 void Parser::SkipQualIdent() {
10906 ASSERT(IsIdentifier()); 10914 ASSERT(IsIdentifier());
10907 ConsumeToken(); 10915 ConsumeToken();
10908 if (CurrentToken() == Token::kPERIOD) { 10916 if (CurrentToken() == Token::kPERIOD) {
10909 ConsumeToken(); // Consume the kPERIOD token. 10917 ConsumeToken(); // Consume the kPERIOD token.
10910 ExpectIdentifier("identifier expected after '.'"); 10918 ExpectIdentifier("identifier expected after '.'");
10911 } 10919 }
10912 } 10920 }
10913 10921
10914 } // namespace dart 10922 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698