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

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

Issue 14820028: Delay Class parsing until the class is actually used. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_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) 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 DISALLOW_COPY_AND_ASSIGN(TryBlocks); 254 DISALLOW_COPY_AND_ASSIGN(TryBlocks);
255 }; 255 };
256 256
257 257
258 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) { 258 void Parser::TryBlocks::AddNodeForFinallyInlining(AstNode* node) {
259 inlined_finally_nodes_.Add(node); 259 inlined_finally_nodes_.Add(node);
260 } 260 }
261 261
262 262
263 // For parsing a compilation unit. 263 // For parsing a compilation unit.
264 Parser::Parser(const Script& script, const Library& library) 264 Parser::Parser(const Script& script, const Library& library, intptr_t token_pos)
265 : script_(Script::Handle(script.raw())), 265 : script_(Script::Handle(script.raw())),
266 tokens_iterator_(TokenStream::Handle(script.tokens()), 0), 266 tokens_iterator_(TokenStream::Handle(script.tokens()), token_pos),
267 token_kind_(Token::kILLEGAL), 267 token_kind_(Token::kILLEGAL),
268 current_block_(NULL), 268 current_block_(NULL),
269 is_top_level_(false), 269 is_top_level_(false),
270 current_member_(NULL), 270 current_member_(NULL),
271 allow_function_literals_(true), 271 allow_function_literals_(true),
272 parsed_function_(NULL), 272 parsed_function_(NULL),
273 innermost_function_(Function::Handle()), 273 innermost_function_(Function::Handle()),
274 current_class_(Class::Handle()), 274 current_class_(Class::Handle()),
275 library_(Library::Handle(library.raw())), 275 library_(Library::Handle(library.raw())),
276 try_blocks_list_(NULL) { 276 try_blocks_list_(NULL) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 tokens_iterator_.SetCurrentPosition(position); 346 tokens_iterator_.SetCurrentPosition(position);
347 token_kind_ = Token::kILLEGAL; 347 token_kind_ = Token::kILLEGAL;
348 } 348 }
349 349
350 350
351 void Parser::ParseCompilationUnit(const Library& library, 351 void Parser::ParseCompilationUnit(const Library& library,
352 const Script& script) { 352 const Script& script) {
353 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); 353 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump());
354 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 354 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
355 Parser parser(script, library); 355 Parser parser(script, library, 0);
356 parser.ParseTopLevel(); 356 parser.ParseTopLevel();
357 } 357 }
358 358
359 359
360 Token::Kind Parser::CurrentToken() { 360 Token::Kind Parser::CurrentToken() {
361 if (token_kind_ == Token::kILLEGAL) { 361 if (token_kind_ == Token::kILLEGAL) {
362 token_kind_ = tokens_iterator_.CurrentTokenKind(); 362 token_kind_ = tokens_iterator_.CurrentTokenKind();
363 if (token_kind_ == Token::kERROR) { 363 if (token_kind_ == Token::kERROR) {
364 ErrorMsg(TokenPos(), "%s", CurrentLiteral()->ToCString()); 364 ErrorMsg(TokenPos(), "%s", CurrentLiteral()->ToCString());
365 } 365 }
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 return false; 730 return false;
731 } else if ((seq->length()) == 1 && 731 } else if ((seq->length()) == 1 &&
732 (seq->NodeAt(seq->length() - 1)->IsSequenceNode())) { 732 (seq->NodeAt(seq->length() - 1)->IsSequenceNode())) {
733 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode()); 733 return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode());
734 } else { 734 } else {
735 return seq->NodeAt(seq->length() - 1)->IsReturnNode(); 735 return seq->NodeAt(seq->length() - 1)->IsReturnNode();
736 } 736 }
737 } 737 }
738 738
739 739
740 void Parser::ParseClass(const Class& cls) {
741 if (!cls.is_synthesized_class()) {
742 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
743 Isolate* isolate = Isolate::Current();
744 ASSERT(isolate->long_jump_base()->IsSafeToJump());
745 const Script& script = Script::Handle(isolate, cls.script());
746 const Library& lib = Library::Handle(isolate, cls.library());
747 Parser parser(script, lib, cls.token_pos());
748 parser.ParseClassDefinition(cls);
749 }
750 }
751
752
740 void Parser::ParseFunction(ParsedFunction* parsed_function) { 753 void Parser::ParseFunction(ParsedFunction* parsed_function) {
741 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 754 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
742 Isolate* isolate = Isolate::Current(); 755 Isolate* isolate = Isolate::Current();
743 ASSERT(isolate->long_jump_base()->IsSafeToJump()); 756 ASSERT(isolate->long_jump_base()->IsSafeToJump());
744 ASSERT(parsed_function != NULL); 757 ASSERT(parsed_function != NULL);
745 const Function& func = parsed_function->function(); 758 const Function& func = parsed_function->function();
746 const Script& script = Script::Handle(isolate, func.script()); 759 const Script& script = Script::Handle(isolate, func.script());
747 Parser parser(script, parsed_function, func.token_pos()); 760 Parser parser(script, parsed_function, func.token_pos());
748 SequenceNode* node_sequence = NULL; 761 SequenceNode* node_sequence = NULL;
749 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); 762 Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null());
(...skipping 2444 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 } 3207 }
3195 ParseFieldDefinition(members, &member); 3208 ParseFieldDefinition(members, &member);
3196 } else { 3209 } else {
3197 UnexpectedToken(); 3210 UnexpectedToken();
3198 } 3211 }
3199 current_member_ = NULL; 3212 current_member_ = NULL;
3200 members->AddMember(member); 3213 members->AddMember(member);
3201 } 3214 }
3202 3215
3203 3216
3204 void Parser::ParseClassDefinition(const GrowableObjectArray& pending_classes) { 3217 void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes) {
3205 TRACE_PARSER("ParseClassDefinition"); 3218 TRACE_PARSER("ParseClassDeclaration");
3206 bool is_patch = false; 3219 bool is_patch = false;
3207 bool is_abstract = false; 3220 bool is_abstract = false;
3208 if (is_patch_source() && 3221 if (is_patch_source() &&
3209 (CurrentToken() == Token::kIDENT) && 3222 (CurrentToken() == Token::kIDENT) &&
3210 CurrentLiteral()->Equals("patch")) { 3223 CurrentLiteral()->Equals("patch")) {
3211 ConsumeToken(); 3224 ConsumeToken();
3212 is_patch = true; 3225 is_patch = true;
3213 } else if (CurrentToken() == Token::kABSTRACT) { 3226 } else if (CurrentToken() == Token::kABSTRACT) {
3214 is_abstract = true; 3227 is_abstract = true;
3215 ConsumeToken(); 3228 ConsumeToken();
3216 } 3229 }
3217 const intptr_t class_pos = TokenPos();
3218 ExpectToken(Token::kCLASS); 3230 ExpectToken(Token::kCLASS);
3219 const intptr_t classname_pos = TokenPos(); 3231 const intptr_t classname_pos = TokenPos();
3220 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); 3232 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected");
3221 if (FLAG_trace_parser) { 3233 if (FLAG_trace_parser) {
3222 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString()); 3234 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString());
3223 } 3235 }
3224 Class& cls = Class::Handle(); 3236 Class& cls = Class::Handle();
3225 TypeArguments& orig_type_parameters = TypeArguments::Handle(); 3237 TypeArguments& orig_type_parameters = TypeArguments::Handle();
3226 Object& obj = Object::Handle(library_.LookupLocalObject(class_name)); 3238 Object& obj = Object::Handle(library_.LookupLocalObject(class_name));
3227 if (obj.IsNull()) { 3239 if (obj.IsNull()) {
(...skipping 22 matching lines...) Expand all
3250 } else { 3262 } else {
3251 // Not patching a class, but it has been found. This must be one of the 3263 // Not patching a class, but it has been found. This must be one of the
3252 // pre-registered classes from object.cc or a duplicate definition. 3264 // pre-registered classes from object.cc or a duplicate definition.
3253 if (!(cls.is_prefinalized() || 3265 if (!(cls.is_prefinalized() ||
3254 RawObject::IsTypedDataViewClassId(cls.id()))) { 3266 RawObject::IsTypedDataViewClassId(cls.id()))) {
3255 ErrorMsg(classname_pos, "class '%s' is already defined", 3267 ErrorMsg(classname_pos, "class '%s' is already defined",
3256 class_name.ToCString()); 3268 class_name.ToCString());
3257 } 3269 }
3258 // Pre-registered classes need their scripts connected at this time. 3270 // Pre-registered classes need their scripts connected at this time.
3259 cls.set_script(script_); 3271 cls.set_script(script_);
3272 cls.set_token_pos(classname_pos);
3260 } 3273 }
3261 } 3274 }
3262 ASSERT(!cls.IsNull()); 3275 ASSERT(!cls.IsNull());
3263 ASSERT(cls.functions() == Object::empty_array().raw()); 3276 ASSERT(cls.functions() == Object::empty_array().raw());
3264 set_current_class(cls); 3277 set_current_class(cls);
3265 ParseTypeParameters(cls); 3278 ParseTypeParameters(cls);
3266 if (is_patch) { 3279 if (is_patch) {
3267 // Check that the new type parameters are identical to the original ones. 3280 // Check that the new type parameters are identical to the original ones.
3268 const TypeArguments& new_type_parameters = 3281 const TypeArguments& new_type_parameters =
3269 TypeArguments::Handle(cls.type_parameters()); 3282 TypeArguments::Handle(cls.type_parameters());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3321 // No extends clause: implicitly extend Object. 3334 // No extends clause: implicitly extend Object.
3322 super_type = Type::ObjectType(); 3335 super_type = Type::ObjectType();
3323 } 3336 }
3324 ASSERT(!super_type.IsNull()); 3337 ASSERT(!super_type.IsNull());
3325 cls.set_super_type(super_type); 3338 cls.set_super_type(super_type);
3326 3339
3327 if (CurrentToken() == Token::kIMPLEMENTS) { 3340 if (CurrentToken() == Token::kIMPLEMENTS) {
3328 ParseInterfaceList(cls); 3341 ParseInterfaceList(cls);
3329 } 3342 }
3330 3343
3344 if (is_abstract) {
3345 cls.set_is_abstract();
3346 }
3347 if (is_patch) {
3348 // Apply the changes to the patched class looked up above.
3349 ASSERT(obj.raw() == library_.LookupLocalObject(class_name));
3350 // The patched class must not be finalized yet.
3351 const Class& orig_class = Class::Cast(obj);
3352 ASSERT(!orig_class.is_finalized());
3353 orig_class.set_patch_class(cls);
3354 cls.set_is_patch();
3355 }
3356 pending_classes.Add(cls, Heap::kOld);
3357
3358 if (CurrentToken() != Token::kLBRACE) {
3359 ErrorMsg("{ expected");
3360 }
3361 SkipBlock();
3362 }
3363
3364
3365 void Parser::ParseClassDefinition(const Class& cls) {
3366 TRACE_PARSER("ParseClassDefinition");
3367 set_current_class(cls);
3368 is_top_level_ = true;
3369 String& class_name = String::Handle(cls.Name());
3370 const intptr_t class_pos = TokenPos();
3371 ClassDesc members(cls, class_name, false, class_pos);
3372 while (CurrentToken() != Token::kLBRACE) {
3373 ConsumeToken();
3374 }
3331 ExpectToken(Token::kLBRACE); 3375 ExpectToken(Token::kLBRACE);
3332 ClassDesc members(cls, class_name, false, class_pos);
3333 while (CurrentToken() != Token::kRBRACE) { 3376 while (CurrentToken() != Token::kRBRACE) {
3334 SkipMetadata(); 3377 SkipMetadata();
3335 ParseClassMemberDefinition(&members); 3378 ParseClassMemberDefinition(&members);
3336 } 3379 }
3337 ExpectToken(Token::kRBRACE); 3380 ExpectToken(Token::kRBRACE);
3338 3381
3339 if (is_abstract) {
3340 cls.set_is_abstract();
3341 }
3342
3343 CheckConstructors(&members); 3382 CheckConstructors(&members);
3344 3383
3345 // Need to compute this here since MakeArray() will clear the 3384 // Need to compute this here since MakeArray() will clear the
3346 // functions array in members. 3385 // functions array in members.
3347 const bool need_implicit_constructor = 3386 const bool need_implicit_constructor =
3348 !members.has_constructor() && !is_patch; 3387 !members.has_constructor() && !cls.is_patch();
3349 3388
3350 Array& array = Array::Handle(); 3389 Array& array = Array::Handle();
3351 array = Array::MakeArray(members.fields()); 3390 array = Array::MakeArray(members.fields());
3352 cls.SetFields(array); 3391 cls.SetFields(array);
3353 3392
3354 // Creating a new array for functions marks the class as parsed. 3393 // Creating a new array for functions marks the class as parsed.
3355 array = Array::MakeArray(members.functions()); 3394 array = Array::MakeArray(members.functions());
3356 cls.SetFunctions(array); 3395 cls.SetFunctions(array);
3357 3396
3358 // Add an implicit constructor if no explicit constructor is present. 3397 // Add an implicit constructor if no explicit constructor is present.
3359 // No implicit constructors are needed for patch classes. 3398 // No implicit constructors are needed for patch classes.
3360 if (need_implicit_constructor) { 3399 if (need_implicit_constructor) {
3361 AddImplicitConstructor(cls); 3400 AddImplicitConstructor(cls);
3362 } 3401 }
3363 3402
3364 if (!is_patch) { 3403 if (cls.is_patch()) {
3365 pending_classes.Add(cls, Heap::kOld);
3366 } else {
3367 // Apply the changes to the patched class looked up above. 3404 // Apply the changes to the patched class looked up above.
3368 ASSERT(obj.raw() == library_.LookupLocalObject(class_name)); 3405 Object& obj = Object::Handle(library_.LookupLocalObject(class_name));
3369 // The patched class must not be finalized yet. 3406 // The patched class must not be finalized yet.
3370 ASSERT(!Class::Cast(obj).is_finalized()); 3407 const Class& orig_class = Class::Cast(obj);
3371 const char* err_msg = Class::Cast(obj).ApplyPatch(cls); 3408 ASSERT(!orig_class.is_finalized());
3409 const char* err_msg = orig_class.ApplyPatch(cls);
3372 if (err_msg != NULL) { 3410 if (err_msg != NULL) {
3373 ErrorMsg(classname_pos, "applying patch failed with '%s'", err_msg); 3411 ErrorMsg(class_pos, "applying patch failed with '%s'", err_msg);
3374 } 3412 }
3375 } 3413 }
3376 } 3414 }
3377 3415
3378 3416
3379 // Add an implicit constructor to the given class. 3417 // Add an implicit constructor to the given class.
3380 void Parser::AddImplicitConstructor(const Class& cls) { 3418 void Parser::AddImplicitConstructor(const Class& cls) {
3381 // The implicit constructor is unnamed, has no explicit parameter. 3419 // The implicit constructor is unnamed, has no explicit parameter.
3382 String& ctor_name = String::ZoneHandle(cls.Name()); 3420 String& ctor_name = String::ZoneHandle(cls.Name());
3383 ctor_name = String::Concat(ctor_name, Symbols::Dot()); 3421 ctor_name = String::Concat(ctor_name, Symbols::Dot());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3488 } 3526 }
3489 3527
3490 if (CurrentToken() != Token::kWITH) { 3528 if (CurrentToken() != Token::kWITH) {
3491 ErrorMsg("mixin application 'with Type' expected"); 3529 ErrorMsg("mixin application 'with Type' expected");
3492 } 3530 }
3493 type = ParseMixins(type); 3531 type = ParseMixins(type);
3494 3532
3495 // TODO(hausner): treat the mixin application as an alias, not as a base 3533 // TODO(hausner): treat the mixin application as an alias, not as a base
3496 // class whose super class is the mixin application! 3534 // class whose super class is the mixin application!
3497 mixin_application.set_super_type(type); 3535 mixin_application.set_super_type(type);
3536 mixin_application.set_is_synthesized_class();
3498 3537
3499 AddImplicitConstructor(mixin_application); 3538 AddImplicitConstructor(mixin_application);
3500 if (CurrentToken() == Token::kIMPLEMENTS) { 3539 if (CurrentToken() == Token::kIMPLEMENTS) {
3501 ParseInterfaceList(mixin_application); 3540 ParseInterfaceList(mixin_application);
3502 } 3541 }
3503 ExpectSemicolon(); 3542 ExpectSemicolon();
3504 pending_classes.Add(mixin_application, Heap::kOld); 3543 pending_classes.Add(mixin_application, Heap::kOld);
3505 } 3544 }
3506 3545
3507 3546
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 mixin_app_name = mixin_super_type.ClassName(); 3935 mixin_app_name = mixin_super_type.ClassName();
3897 mixin_app_name = String::Concat(mixin_app_name, Symbols::Ampersand()); 3936 mixin_app_name = String::Concat(mixin_app_name, Symbols::Ampersand());
3898 mixin_app_name = String::Concat(mixin_app_name, 3937 mixin_app_name = String::Concat(mixin_app_name,
3899 String::Handle(mixin_type.ClassName())); 3938 String::Handle(mixin_type.ClassName()));
3900 mixin_app_name = Symbols::New(mixin_app_name); 3939 mixin_app_name = Symbols::New(mixin_app_name);
3901 3940
3902 mixin_application = Class::New(mixin_app_name, script_, mixin_pos); 3941 mixin_application = Class::New(mixin_app_name, script_, mixin_pos);
3903 mixin_application.set_super_type(mixin_super_type); 3942 mixin_application.set_super_type(mixin_super_type);
3904 mixin_application.set_mixin(Type::Cast(mixin_type)); 3943 mixin_application.set_mixin(Type::Cast(mixin_type));
3905 mixin_application.set_library(library_); 3944 mixin_application.set_library(library_);
3945 mixin_application.set_is_synthesized_class();
3906 AddImplicitConstructor(mixin_application); 3946 AddImplicitConstructor(mixin_application);
3907 // Add the mixin type to the interfaces that the mixin application 3947 // Add the mixin type to the interfaces that the mixin application
3908 // class implements. This is necessary so that type tests work. 3948 // class implements. This is necessary so that type tests work.
3909 mixin_application_interfaces = Array::New(1); 3949 mixin_application_interfaces = Array::New(1);
3910 mixin_application_interfaces.SetAt(0, mixin_type); 3950 mixin_application_interfaces.SetAt(0, mixin_type);
3911 mixin_application.set_interfaces(mixin_application_interfaces); 3951 mixin_application.set_interfaces(mixin_application_interfaces);
3912 3952
3913 // For the type arguments of the mixin application type, we need 3953 // For the type arguments of the mixin application type, we need
3914 // a copy of the type arguments to the mixin type. The simplest way 3954 // a copy of the type arguments to the mixin type. The simplest way
3915 // to get the copy is to rewind the parser, parse the mixin type 3955 // to get the copy is to rewind the parser, parse the mixin type
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
4480 if (is_library_source() || is_patch_source()) { 4520 if (is_library_source() || is_patch_source()) {
4481 ParseLibraryDefinition(); 4521 ParseLibraryDefinition();
4482 } else if (is_part_source()) { 4522 } else if (is_part_source()) {
4483 ParsePartHeader(); 4523 ParsePartHeader();
4484 } 4524 }
4485 4525
4486 while (true) { 4526 while (true) {
4487 set_current_class(Class::Handle()); // No current class. 4527 set_current_class(Class::Handle()); // No current class.
4488 SkipMetadata(); 4528 SkipMetadata();
4489 if (CurrentToken() == Token::kCLASS) { 4529 if (CurrentToken() == Token::kCLASS) {
4490 ParseClassDefinition(pending_classes); 4530 ParseClassDeclaration(pending_classes);
4491 } else if ((CurrentToken() == Token::kTYPEDEF) && 4531 } else if ((CurrentToken() == Token::kTYPEDEF) &&
4492 (LookaheadToken(1) != Token::kLPAREN)) { 4532 (LookaheadToken(1) != Token::kLPAREN)) {
4493 set_current_class(toplevel_class); 4533 set_current_class(toplevel_class);
4494 ParseTypedef(pending_classes); 4534 ParseTypedef(pending_classes);
4495 } else if ((CurrentToken() == Token::kABSTRACT) && 4535 } else if ((CurrentToken() == Token::kABSTRACT) &&
4496 (LookaheadToken(1) == Token::kCLASS)) { 4536 (LookaheadToken(1) == Token::kCLASS)) {
4497 ParseClassDefinition(pending_classes); 4537 ParseClassDeclaration(pending_classes);
4498 } else if (is_patch_source() && IsLiteral("patch") && 4538 } else if (is_patch_source() && IsLiteral("patch") &&
4499 (LookaheadToken(1) == Token::kCLASS)) { 4539 (LookaheadToken(1) == Token::kCLASS)) {
4500 ParseClassDefinition(pending_classes); 4540 ParseClassDeclaration(pending_classes);
4501 } else { 4541 } else {
4502 set_current_class(toplevel_class); 4542 set_current_class(toplevel_class);
4503 if (IsVariableDeclaration()) { 4543 if (IsVariableDeclaration()) {
4504 ParseTopLevelVariable(&top_level); 4544 ParseTopLevelVariable(&top_level);
4505 } else if (IsFunctionDeclaration()) { 4545 } else if (IsFunctionDeclaration()) {
4506 ParseTopLevelFunction(&top_level); 4546 ParseTopLevelFunction(&top_level);
4507 } else if (IsTopLevelAccessor()) { 4547 } else if (IsTopLevelAccessor()) {
4508 ParseTopLevelAccessor(&top_level); 4548 ParseTopLevelAccessor(&top_level);
4509 } else if (CurrentToken() == Token::kEOS) { 4549 } else if (CurrentToken() == Token::kEOS) {
4510 break; 4550 break;
(...skipping 3505 matching lines...) Expand 10 before | Expand all | Expand 10 after
8016 8056
8017 8057
8018 const Type* Parser::ReceiverType(intptr_t type_pos) const { 8058 const Type* Parser::ReceiverType(intptr_t type_pos) const {
8019 ASSERT(!current_class().IsNull()); 8059 ASSERT(!current_class().IsNull());
8020 TypeArguments& type_arguments = TypeArguments::Handle(); 8060 TypeArguments& type_arguments = TypeArguments::Handle();
8021 if (current_class().NumTypeParameters() > 0) { 8061 if (current_class().NumTypeParameters() > 0) {
8022 type_arguments = current_class().type_parameters(); 8062 type_arguments = current_class().type_parameters();
8023 } 8063 }
8024 Type& type = Type::ZoneHandle( 8064 Type& type = Type::ZoneHandle(
8025 Type::New(current_class(), type_arguments, type_pos)); 8065 Type::New(current_class(), type_arguments, type_pos));
8026 if (!is_top_level_) { 8066 if (!is_top_level_ || current_class().is_type_finalized()) {
8027 type ^= ClassFinalizer::FinalizeType( 8067 type ^= ClassFinalizer::FinalizeType(
8028 current_class(), type, ClassFinalizer::kCanonicalizeWellFormed); 8068 current_class(), type, ClassFinalizer::kCanonicalizeWellFormed);
8029 } 8069 }
8030 return &type; 8070 return &type;
8031 } 8071 }
8032 8072
8033 8073
8034 bool Parser::IsInstantiatorRequired() const { 8074 bool Parser::IsInstantiatorRequired() const {
8035 ASSERT(!current_function().IsNull()); 8075 ASSERT(!current_function().IsNull());
8036 if (current_function().is_static() && 8076 if (current_function().is_static() &&
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
9955 void Parser::SkipQualIdent() { 9995 void Parser::SkipQualIdent() {
9956 ASSERT(IsIdentifier()); 9996 ASSERT(IsIdentifier());
9957 ConsumeToken(); 9997 ConsumeToken();
9958 if (CurrentToken() == Token::kPERIOD) { 9998 if (CurrentToken() == Token::kPERIOD) {
9959 ConsumeToken(); // Consume the kPERIOD token. 9999 ConsumeToken(); // Consume the kPERIOD token.
9960 ExpectIdentifier("identifier expected after '.'"); 10000 ExpectIdentifier("identifier expected after '.'");
9961 } 10001 }
9962 } 10002 }
9963 10003
9964 } // namespace dart 10004 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698