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

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

Issue 11363012: Prevent mutation of final 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 | « pkg/pkg.status ('k') | runtime/vm/parser.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"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return NULL; 308 return NULL;
309 } 309 }
310 if (HasPseudo()) { 310 if (HasPseudo()) {
311 return NULL; 311 return NULL;
312 } 312 }
313 return new StoreLocalNode(token_pos(), &local(), rhs); 313 return new StoreLocalNode(token_pos(), &local(), rhs);
314 } 314 }
315 315
316 316
317 AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) { 317 AstNode* LoadStaticFieldNode::MakeAssignmentNode(AstNode* rhs) {
318 if (field().is_final()) {
319 return NULL;
320 }
318 return new StoreStaticFieldNode(token_pos(), field(), rhs); 321 return new StoreStaticFieldNode(token_pos(), field(), rhs);
319 } 322 }
320 323
321 324
322 AstNode* InstanceGetterNode::MakeAssignmentNode(AstNode* rhs) { 325 AstNode* InstanceGetterNode::MakeAssignmentNode(AstNode* rhs) {
323 return new InstanceSetterNode(token_pos(), receiver(), field_name(), rhs); 326 return new InstanceSetterNode(token_pos(), receiver(), field_name(), rhs);
324 } 327 }
325 328
326 329
327 AstNode* LoadIndexedNode::MakeAssignmentNode(AstNode* rhs) { 330 AstNode* LoadIndexedNode::MakeAssignmentNode(AstNode* rhs) {
(...skipping 27 matching lines...) Expand all
355 if (!setter.IsNull()) { 358 if (!setter.IsNull()) {
356 return new StaticSetterNode(token_pos(), NULL, cls(), field_name(), rhs); 359 return new StaticSetterNode(token_pos(), NULL, cls(), field_name(), rhs);
357 } 360 }
358 // Could not find a static setter. Look for a field. 361 // Could not find a static setter. Look for a field.
359 // Access to a lazily initialized static field that has not yet been 362 // Access to a lazily initialized static field that has not yet been
360 // initialized is compiled to a static implicit getter. 363 // initialized is compiled to a static implicit getter.
361 // A setter may not exist for such a field. 364 // A setter may not exist for such a field.
362 const Field& field = 365 const Field& field =
363 Field::ZoneHandle(cls().LookupStaticField(field_name())); 366 Field::ZoneHandle(cls().LookupStaticField(field_name()));
364 if (!field.IsNull()) { 367 if (!field.IsNull()) {
368 if (field.is_final()) {
369 return NULL;
370 }
365 #if defined(DEBUG) 371 #if defined(DEBUG)
366 const String& getter_name = 372 const String& getter_name =
367 String::Handle(Field::GetterName(field_name())); 373 String::Handle(Field::GetterName(field_name()));
368 const Function& getter = 374 const Function& getter =
369 Function::ZoneHandle(cls().LookupStaticFunction(getter_name)); 375 Function::ZoneHandle(cls().LookupStaticFunction(getter_name));
370 ASSERT(!getter.IsNull() && 376 ASSERT(!getter.IsNull() &&
371 (getter.kind() == RawFunction::kConstImplicitGetter)); 377 (getter.kind() == RawFunction::kConstImplicitGetter));
372 #endif 378 #endif
373 return new StoreStaticFieldNode(token_pos(), field, rhs); 379 return new StoreStaticFieldNode(token_pos(), field, rhs);
374 } 380 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 if (result.IsError() || result.IsNull()) { 427 if (result.IsError() || result.IsNull()) {
422 // TODO(turnidge): We could get better error messages by returning 428 // TODO(turnidge): We could get better error messages by returning
423 // the Error object directly to the parser. This will involve 429 // the Error object directly to the parser. This will involve
424 // replumbing all of the EvalConstExpr methods. 430 // replumbing all of the EvalConstExpr methods.
425 return NULL; 431 return NULL;
426 } 432 }
427 return &Instance::ZoneHandle(Instance::Cast(result).raw()); 433 return &Instance::ZoneHandle(Instance::Cast(result).raw());
428 } 434 }
429 435
430 } // namespace dart 436 } // namespace dart
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698