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

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

Issue 269253005: Put metadata fields in their owner class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
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 4029 matching lines...) Expand 10 before | Expand all | Expand 10 after
4040 } 4040 }
4041 ExpectToken(Token::kRBRACE); 4041 ExpectToken(Token::kRBRACE);
4042 4042
4043 CheckConstructors(&members); 4043 CheckConstructors(&members);
4044 4044
4045 // Need to compute this here since MakeArray() will clear the 4045 // Need to compute this here since MakeArray() will clear the
4046 // functions array in members. 4046 // functions array in members.
4047 const bool need_implicit_constructor = 4047 const bool need_implicit_constructor =
4048 !members.has_constructor() && !cls.is_patch(); 4048 !members.has_constructor() && !cls.is_patch();
4049 4049
4050 Array& array = Array::Handle(); 4050 cls.AddFields(members.fields());
4051 array = Array::MakeArray(members.fields());
4052 cls.SetFields(array);
4053 4051
4054 // Creating a new array for functions marks the class as parsed. 4052 // Creating a new array for functions marks the class as parsed.
4055 array = Array::MakeArray(members.functions()); 4053 const Array& array = Array::Handle(Array::MakeArray(members.functions()));
4056 cls.SetFunctions(array); 4054 cls.SetFunctions(array);
4057 4055
4058 // Add an implicit constructor if no explicit constructor is present. 4056 // Add an implicit constructor if no explicit constructor is present.
4059 // No implicit constructors are needed for patch classes. 4057 // No implicit constructors are needed for patch classes.
4060 if (need_implicit_constructor) { 4058 if (need_implicit_constructor) {
4061 AddImplicitConstructor(cls); 4059 AddImplicitConstructor(cls);
4062 } 4060 }
4063 4061
4064 if (cls.is_patch()) { 4062 if (cls.is_patch()) {
4065 // Apply the changes to the patched class looked up above. 4063 // Apply the changes to the patched class looked up above.
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
5253 } else if (IsTopLevelAccessor()) { 5251 } else if (IsTopLevelAccessor()) {
5254 ParseTopLevelAccessor(&top_level, metadata_pos); 5252 ParseTopLevelAccessor(&top_level, metadata_pos);
5255 } else if (CurrentToken() == Token::kEOS) { 5253 } else if (CurrentToken() == Token::kEOS) {
5256 break; 5254 break;
5257 } else { 5255 } else {
5258 UnexpectedToken(); 5256 UnexpectedToken();
5259 } 5257 }
5260 } 5258 }
5261 } 5259 }
5262 if ((top_level.fields.Length() > 0) || (top_level.functions.Length() > 0)) { 5260 if ((top_level.fields.Length() > 0) || (top_level.functions.Length() > 0)) {
5263 Array& array = Array::Handle(); 5261 toplevel_class.AddFields(top_level.fields);
5264 5262
5265 array = Array::MakeArray(top_level.fields); 5263 const Array& array = Array::Handle(Array::MakeArray(top_level.functions));
5266 toplevel_class.SetFields(array);
5267
5268 array = Array::MakeArray(top_level.functions);
5269 toplevel_class.SetFunctions(array); 5264 toplevel_class.SetFunctions(array);
5270 5265
5271 library_.AddAnonymousClass(toplevel_class); 5266 library_.AddAnonymousClass(toplevel_class);
5272 pending_classes.Add(toplevel_class, Heap::kOld); 5267 pending_classes.Add(toplevel_class, Heap::kOld);
5273 } 5268 }
5274 } 5269 }
5275 5270
5276 5271
5277 void Parser::ChainNewBlock(LocalScope* outer_scope) { 5272 void Parser::ChainNewBlock(LocalScope* outer_scope) {
5278 Block* block = new Block(current_block_, 5273 Block* block = new Block(current_block_,
(...skipping 5675 matching lines...) Expand 10 before | Expand all | Expand 10 after
10954 void Parser::SkipQualIdent() { 10949 void Parser::SkipQualIdent() {
10955 ASSERT(IsIdentifier()); 10950 ASSERT(IsIdentifier());
10956 ConsumeToken(); 10951 ConsumeToken();
10957 if (CurrentToken() == Token::kPERIOD) { 10952 if (CurrentToken() == Token::kPERIOD) {
10958 ConsumeToken(); // Consume the kPERIOD token. 10953 ConsumeToken(); // Consume the kPERIOD token.
10959 ExpectIdentifier("identifier expected after '.'"); 10954 ExpectIdentifier("identifier expected after '.'");
10960 } 10955 }
10961 } 10956 }
10962 10957
10963 } // namespace dart 10958 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698