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

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

Issue 16835002: One more premature load-static node generation solved. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 7507 matching lines...) Expand 10 before | Expand all | Expand 10 after
7518 // The field is not yet initialized and could not be initialized at compile 7518 // The field is not yet initialized and could not be initialized at compile
7519 // time. The getter will initialize the field. 7519 // time. The getter will initialize the field.
7520 return initializing_getter; 7520 return initializing_getter;
7521 } 7521 }
7522 // The field is initialized. 7522 // The field is initialized.
7523 if (field.is_const()) { 7523 if (field.is_const()) {
7524 ASSERT(field.value() != Object::sentinel().raw()); 7524 ASSERT(field.value() != Object::sentinel().raw());
7525 ASSERT(field.value() != Object::transition_sentinel().raw()); 7525 ASSERT(field.value() != Object::transition_sentinel().raw());
7526 return new LiteralNode(ident_pos, Instance::ZoneHandle(field.value())); 7526 return new LiteralNode(ident_pos, Instance::ZoneHandle(field.value()));
7527 } 7527 }
7528 // Access the field directly. 7528 ASSERT(field.is_static());
7529 return new LoadStaticFieldNode(ident_pos, Field::ZoneHandle(field.raw())); 7529 const Class& field_owner = Class::ZoneHandle(field.owner());
7530 const String& field_name = String::ZoneHandle(field.name());
7531 const String& getter_name = String::Handle(Field::GetterName(field_name));
7532 const Function& getter =
7533 Function::Handle(field_owner.LookupStaticFunction(getter_name));
7534 // Never load field directly if there is a getter (deterministic AST).
7535 if (getter.IsNull()) {
7536 return new LoadStaticFieldNode(ident_pos, Field::ZoneHandle(field.raw()));
7537 } else {
7538 ASSERT(getter.kind() == RawFunction::kConstImplicitGetter);
7539 return new StaticGetterNode(ident_pos,
7540 NULL, // Receiver.
7541 false, // is_super_getter.
7542 field_owner,
7543 field_name);
7544 }
7530 } 7545 }
7531 7546
7532 7547
7533 AstNode* Parser::ParseStaticFieldAccess(const Class& cls, 7548 AstNode* Parser::ParseStaticFieldAccess(const Class& cls,
7534 const String& field_name, 7549 const String& field_name,
7535 intptr_t ident_pos, 7550 intptr_t ident_pos,
7536 bool consume_cascades) { 7551 bool consume_cascades) {
7537 TRACE_PARSER("ParseStaticFieldAccess"); 7552 TRACE_PARSER("ParseStaticFieldAccess");
7538 AstNode* access = NULL; 7553 AstNode* access = NULL;
7539 const intptr_t call_pos = TokenPos(); 7554 const intptr_t call_pos = TokenPos();
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
8165 ErrorMsg("circular dependency while initializing static field '%s'", 8180 ErrorMsg("circular dependency while initializing static field '%s'",
8166 field_name.ToCString()); 8181 field_name.ToCString());
8167 } else { 8182 } else {
8168 // The implicit static getter will throw the exception if necessary. 8183 // The implicit static getter will throw the exception if necessary.
8169 return new StaticGetterNode(TokenPos(), 8184 return new StaticGetterNode(TokenPos(),
8170 NULL, 8185 NULL,
8171 false, 8186 false,
8172 field_owner, 8187 field_owner,
8173 field_name); 8188 field_name);
8174 } 8189 }
8175 } else if (value.raw() == Object::sentinel().raw()) { 8190 }
hausner 2013/06/12 20:43:39 Why get rid of the else? I prefer it since it is e
srdjan 2013/06/12 21:32:08 Restored.
8191 if (value.raw() == Object::sentinel().raw()) {
8176 // This field has not been referenced yet and thus the value has 8192 // This field has not been referenced yet and thus the value has
8177 // not been evaluated. If the field is const, call the static getter method 8193 // not been evaluated. If the field is const, call the static getter method
8178 // to evaluate the expression and canonicalize the value. 8194 // to evaluate the expression and canonicalize the value.
8179 if (field.is_const()) { 8195 if (field.is_const()) {
8180 field.set_value(Object::transition_sentinel()); 8196 field.set_value(Object::transition_sentinel());
8181 const int kNumArguments = 0; // no arguments. 8197 const int kNumArguments = 0; // no arguments.
8182 const Function& func = 8198 const Function& func =
8183 Function::Handle(Resolver::ResolveStatic(field_owner, 8199 Function::Handle(Resolver::ResolveStatic(field_owner,
8184 getter_name, 8200 getter_name,
8185 kNumArguments, 8201 kNumArguments,
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
10079 void Parser::SkipQualIdent() { 10095 void Parser::SkipQualIdent() {
10080 ASSERT(IsIdentifier()); 10096 ASSERT(IsIdentifier());
10081 ConsumeToken(); 10097 ConsumeToken();
10082 if (CurrentToken() == Token::kPERIOD) { 10098 if (CurrentToken() == Token::kPERIOD) {
10083 ConsumeToken(); // Consume the kPERIOD token. 10099 ConsumeToken(); // Consume the kPERIOD token.
10084 ExpectIdentifier("identifier expected after '.'"); 10100 ExpectIdentifier("identifier expected after '.'");
10085 } 10101 }
10086 } 10102 }
10087 10103
10088 } // namespace dart 10104 } // 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