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

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

Issue 1566553003: More 0 => Scanner::kNoSourcePos. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « runtime/vm/object.cc ('k') | 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 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED 8 #ifndef DART_PRECOMPILED
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 has_final = false; 616 has_final = false;
617 has_const = false; 617 has_const = false;
618 has_static = false; 618 has_static = false;
619 has_var = false; 619 has_var = false;
620 has_factory = false; 620 has_factory = false;
621 has_operator = false; 621 has_operator = false;
622 has_native = false; 622 has_native = false;
623 metadata_pos = Scanner::kNoSourcePos; 623 metadata_pos = Scanner::kNoSourcePos;
624 operator_token = Token::kILLEGAL; 624 operator_token = Token::kILLEGAL;
625 type = NULL; 625 type = NULL;
626 name_pos = 0; 626 name_pos = Scanner::kNoSourcePos;
627 name = NULL; 627 name = NULL;
628 redirect_name = NULL; 628 redirect_name = NULL;
629 dict_name = NULL; 629 dict_name = NULL;
630 params.Clear(); 630 params.Clear();
631 kind = RawFunction::kRegularFunction; 631 kind = RawFunction::kRegularFunction;
632 field_ = NULL; 632 field_ = NULL;
633 } 633 }
634 634
635 bool IsConstructor() const { 635 bool IsConstructor() const {
636 return (kind == RawFunction::kConstructor) && !has_static; 636 return (kind == RawFunction::kConstructor) && !has_static;
(...skipping 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after
3476 func.set_is_debuggable(false); 3476 func.set_is_debuggable(false);
3477 generated_body_closure = OpenAsyncGeneratorFunction(func.token_pos()); 3477 generated_body_closure = OpenAsyncGeneratorFunction(func.token_pos());
3478 } else if (func.IsAsyncGenClosure()) { 3478 } else if (func.IsAsyncGenClosure()) {
3479 // The closure containing the body of an async* function is debuggable. 3479 // The closure containing the body of an async* function is debuggable.
3480 ASSERT(func.is_debuggable()); 3480 ASSERT(func.is_debuggable());
3481 OpenAsyncGeneratorClosure(); 3481 OpenAsyncGeneratorClosure();
3482 } 3482 }
3483 3483
3484 BoolScope allow_await(&this->await_is_keyword_, 3484 BoolScope allow_await(&this->await_is_keyword_,
3485 func.IsAsyncOrGenerator() || func.is_generated_body()); 3485 func.IsAsyncOrGenerator() || func.is_generated_body());
3486 intptr_t end_token_pos = 0; 3486 intptr_t end_token_pos = Scanner::kNoSourcePos;
3487 if (CurrentToken() == Token::kLBRACE) { 3487 if (CurrentToken() == Token::kLBRACE) {
3488 ConsumeToken(); 3488 ConsumeToken();
3489 if (String::Handle(Z, func.name()).Equals(Symbols::EqualOperator())) { 3489 if (String::Handle(Z, func.name()).Equals(Symbols::EqualOperator())) {
3490 const Class& owner = Class::Handle(Z, func.Owner()); 3490 const Class& owner = Class::Handle(Z, func.Owner());
3491 if (!owner.IsObjectClass()) { 3491 if (!owner.IsObjectClass()) {
3492 AddEqualityNullCheck(); 3492 AddEqualityNullCheck();
3493 } 3493 }
3494 } 3494 }
3495 ParseStatementSequence(); 3495 ParseStatementSequence();
3496 end_token_pos = TokenPos(); 3496 end_token_pos = TokenPos();
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 method->has_native, 3997 method->has_native,
3998 current_class(), 3998 current_class(),
3999 method->decl_begin_pos)); 3999 method->decl_begin_pos));
4000 func.set_result_type(*method->type); 4000 func.set_result_type(*method->type);
4001 func.set_end_token_pos(method_end_pos); 4001 func.set_end_token_pos(method_end_pos);
4002 func.set_is_redirecting(is_redirecting); 4002 func.set_is_redirecting(is_redirecting);
4003 func.set_modifier(async_modifier); 4003 func.set_modifier(async_modifier);
4004 if (library_.is_dart_scheme() && library_.IsPrivate(*method->name)) { 4004 if (library_.is_dart_scheme() && library_.IsPrivate(*method->name)) {
4005 func.set_is_reflectable(false); 4005 func.set_is_reflectable(false);
4006 } 4006 }
4007 if (FLAG_enable_mirrors && (method->metadata_pos > 0)) { 4007 if (FLAG_enable_mirrors && (method->metadata_pos >= 0)) {
4008 library_.AddFunctionMetadata(func, method->metadata_pos); 4008 library_.AddFunctionMetadata(func, method->metadata_pos);
4009 } 4009 }
4010 if (method->has_native) { 4010 if (method->has_native) {
4011 func.set_native_name(*native_name); 4011 func.set_native_name(*native_name);
4012 } 4012 }
4013 4013
4014 // If this method is a redirecting factory, set the redirection information. 4014 // If this method is a redirecting factory, set the redirection information.
4015 if (!redirection_type.IsNull()) { 4015 if (!redirection_type.IsNull()) {
4016 ASSERT(func.IsFactory()); 4016 ASSERT(func.IsFactory());
4017 func.SetRedirectionType(redirection_type); 4017 func.SetRedirectionType(redirection_type);
(...skipping 10 matching lines...) Expand all
4028 4028
4029 4029
4030 void Parser::ParseFieldDefinition(ClassDesc* members, MemberDesc* field) { 4030 void Parser::ParseFieldDefinition(ClassDesc* members, MemberDesc* field) {
4031 TRACE_PARSER("ParseFieldDefinition"); 4031 TRACE_PARSER("ParseFieldDefinition");
4032 // The parser has read the first field name and is now at the token 4032 // The parser has read the first field name and is now at the token
4033 // after the field name. 4033 // after the field name.
4034 ASSERT(CurrentToken() == Token::kSEMICOLON || 4034 ASSERT(CurrentToken() == Token::kSEMICOLON ||
4035 CurrentToken() == Token::kCOMMA || 4035 CurrentToken() == Token::kCOMMA ||
4036 CurrentToken() == Token::kASSIGN); 4036 CurrentToken() == Token::kASSIGN);
4037 ASSERT(field->type != NULL); 4037 ASSERT(field->type != NULL);
4038 ASSERT(field->name_pos > 0); 4038 ASSERT(field->name_pos >= 0);
4039 ASSERT(current_member_ == field); 4039 ASSERT(current_member_ == field);
4040 // All const fields are also final. 4040 // All const fields are also final.
4041 ASSERT(!field->has_const || field->has_final); 4041 ASSERT(!field->has_const || field->has_final);
4042 4042
4043 if (field->has_abstract) { 4043 if (field->has_abstract) {
4044 ReportError("keyword 'abstract' not allowed in field declaration"); 4044 ReportError("keyword 'abstract' not allowed in field declaration");
4045 } 4045 }
4046 if (field->has_external) { 4046 if (field->has_external) {
4047 ReportError("keyword 'external' not allowed in field declaration"); 4047 ReportError("keyword 'external' not allowed in field declaration");
4048 } 4048 }
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
4456 current_member_ = NULL; 4456 current_member_ = NULL;
4457 CheckMemberNameConflict(members, &member); 4457 CheckMemberNameConflict(members, &member);
4458 members->AddMember(member); 4458 members->AddMember(member);
4459 } 4459 }
4460 4460
4461 4461
4462 void Parser::ParseEnumDeclaration(const GrowableObjectArray& pending_classes, 4462 void Parser::ParseEnumDeclaration(const GrowableObjectArray& pending_classes,
4463 const Object& tl_owner, 4463 const Object& tl_owner,
4464 intptr_t metadata_pos) { 4464 intptr_t metadata_pos) {
4465 TRACE_PARSER("ParseEnumDeclaration"); 4465 TRACE_PARSER("ParseEnumDeclaration");
4466 const intptr_t declaration_pos = (metadata_pos > 0) ? metadata_pos 4466 const intptr_t declaration_pos = (metadata_pos >= 0) ? metadata_pos
4467 : TokenPos(); 4467 : TokenPos();
4468 ConsumeToken(); 4468 ConsumeToken();
4469 const intptr_t name_pos = TokenPos(); 4469 const intptr_t name_pos = TokenPos();
4470 String* enum_name = 4470 String* enum_name =
4471 ExpectUserDefinedTypeIdentifier("enum type name expected"); 4471 ExpectUserDefinedTypeIdentifier("enum type name expected");
4472 if (FLAG_trace_parser) { 4472 if (FLAG_trace_parser) {
4473 OS::Print("TopLevel parsing enum '%s'\n", enum_name->ToCString()); 4473 OS::Print("TopLevel parsing enum '%s'\n", enum_name->ToCString());
4474 } 4474 }
4475 ExpectToken(Token::kLBRACE); 4475 ExpectToken(Token::kLBRACE);
4476 if (!IsIdentifier()) { 4476 if (!IsIdentifier()) {
4477 ReportError("Enumeration must have at least one name"); 4477 ReportError("Enumeration must have at least one name");
(...skipping 30 matching lines...) Expand all
4508 pending_classes.Add(cls, Heap::kOld); 4508 pending_classes.Add(cls, Heap::kOld);
4509 } 4509 }
4510 4510
4511 4511
4512 void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes, 4512 void Parser::ParseClassDeclaration(const GrowableObjectArray& pending_classes,
4513 const Object& tl_owner, 4513 const Object& tl_owner,
4514 intptr_t metadata_pos) { 4514 intptr_t metadata_pos) {
4515 TRACE_PARSER("ParseClassDeclaration"); 4515 TRACE_PARSER("ParseClassDeclaration");
4516 bool is_patch = false; 4516 bool is_patch = false;
4517 bool is_abstract = false; 4517 bool is_abstract = false;
4518 intptr_t declaration_pos = (metadata_pos > 0) ? metadata_pos : TokenPos(); 4518 intptr_t declaration_pos = (metadata_pos >= 0) ? metadata_pos : TokenPos();
4519 if (is_patch_source() && 4519 if (is_patch_source() &&
4520 (CurrentToken() == Token::kIDENT) && 4520 (CurrentToken() == Token::kIDENT) &&
4521 CurrentLiteral()->Equals("patch")) { 4521 CurrentLiteral()->Equals("patch")) {
4522 ConsumeToken(); 4522 ConsumeToken();
4523 is_patch = true; 4523 is_patch = true;
4524 } else if (CurrentToken() == Token::kABSTRACT) { 4524 } else if (CurrentToken() == Token::kABSTRACT) {
4525 is_abstract = true; 4525 is_abstract = true;
4526 ConsumeToken(); 4526 ConsumeToken();
4527 } 4527 }
4528 ExpectToken(Token::kCLASS); 4528 ExpectToken(Token::kCLASS);
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
5100 } 5100 }
5101 SetPosition(saved_pos); 5101 SetPosition(saved_pos);
5102 return is_mixin_def; 5102 return is_mixin_def;
5103 } 5103 }
5104 5104
5105 5105
5106 void Parser::ParseTypedef(const GrowableObjectArray& pending_classes, 5106 void Parser::ParseTypedef(const GrowableObjectArray& pending_classes,
5107 const Object& tl_owner, 5107 const Object& tl_owner,
5108 intptr_t metadata_pos) { 5108 intptr_t metadata_pos) {
5109 TRACE_PARSER("ParseTypedef"); 5109 TRACE_PARSER("ParseTypedef");
5110 intptr_t declaration_pos = (metadata_pos > 0) ? metadata_pos : TokenPos(); 5110 intptr_t declaration_pos = (metadata_pos >= 0) ? metadata_pos : TokenPos();
5111 ExpectToken(Token::kTYPEDEF); 5111 ExpectToken(Token::kTYPEDEF);
5112 5112
5113 if (IsMixinAppAlias()) { 5113 if (IsMixinAppAlias()) {
5114 if (FLAG_warn_mixin_typedef) { 5114 if (FLAG_warn_mixin_typedef) {
5115 ReportWarning(TokenPos(), "deprecated mixin application typedef"); 5115 ReportWarning(TokenPos(), "deprecated mixin application typedef");
5116 } 5116 }
5117 ParseMixinAppAlias(pending_classes, tl_owner, metadata_pos); 5117 ParseMixinAppAlias(pending_classes, tl_owner, metadata_pos);
5118 return; 5118 return;
5119 } 5119 }
5120 5120
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
5241 } else if (token_kind_ == Token::kSHR) { 5241 } else if (token_kind_ == Token::kSHR) {
5242 token_kind_ = Token::kGT; 5242 token_kind_ = Token::kGT;
5243 } else { 5243 } else {
5244 UNREACHABLE(); 5244 UNREACHABLE();
5245 } 5245 }
5246 } 5246 }
5247 5247
5248 5248
5249 intptr_t Parser::SkipMetadata() { 5249 intptr_t Parser::SkipMetadata() {
5250 if (CurrentToken() != Token::kAT) { 5250 if (CurrentToken() != Token::kAT) {
5251 return -1; 5251 return Scanner::kNoSourcePos;
5252 } 5252 }
5253 intptr_t metadata_pos = TokenPos(); 5253 intptr_t metadata_pos = TokenPos();
5254 while (CurrentToken() == Token::kAT) { 5254 while (CurrentToken() == Token::kAT) {
5255 ConsumeToken(); 5255 ConsumeToken();
5256 ExpectIdentifier("identifier expected"); 5256 ExpectIdentifier("identifier expected");
5257 if (CurrentToken() == Token::kPERIOD) { 5257 if (CurrentToken() == Token::kPERIOD) {
5258 ConsumeToken(); 5258 ConsumeToken();
5259 ExpectIdentifier("identifier expected"); 5259 ExpectIdentifier("identifier expected");
5260 if (CurrentToken() == Token::kPERIOD) { 5260 if (CurrentToken() == Token::kPERIOD) {
5261 ConsumeToken(); 5261 ConsumeToken();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5309 GrowableArray<AbstractType*> type_parameters_array(Z, 2); 5309 GrowableArray<AbstractType*> type_parameters_array(Z, 2);
5310 intptr_t index = 0; 5310 intptr_t index = 0;
5311 TypeParameter& type_parameter = TypeParameter::Handle(Z); 5311 TypeParameter& type_parameter = TypeParameter::Handle(Z);
5312 TypeParameter& existing_type_parameter = TypeParameter::Handle(Z); 5312 TypeParameter& existing_type_parameter = TypeParameter::Handle(Z);
5313 String& existing_type_parameter_name = String::Handle(Z); 5313 String& existing_type_parameter_name = String::Handle(Z);
5314 AbstractType& type_parameter_bound = Type::Handle(Z); 5314 AbstractType& type_parameter_bound = Type::Handle(Z);
5315 do { 5315 do {
5316 ConsumeToken(); 5316 ConsumeToken();
5317 const intptr_t metadata_pos = SkipMetadata(); 5317 const intptr_t metadata_pos = SkipMetadata();
5318 const intptr_t type_parameter_pos = TokenPos(); 5318 const intptr_t type_parameter_pos = TokenPos();
5319 const intptr_t declaration_pos = (metadata_pos > 0) ? metadata_pos 5319 const intptr_t declaration_pos = (metadata_pos >= 0) ? metadata_pos
5320 : type_parameter_pos; 5320 : type_parameter_pos;
5321 String& type_parameter_name = 5321 String& type_parameter_name =
5322 *ExpectUserDefinedTypeIdentifier("type parameter expected"); 5322 *ExpectUserDefinedTypeIdentifier("type parameter expected");
5323 // Check for duplicate type parameters. 5323 // Check for duplicate type parameters.
5324 for (intptr_t i = 0; i < index; i++) { 5324 for (intptr_t i = 0; i < index; i++) {
5325 existing_type_parameter ^= type_parameters_array.At(i)->raw(); 5325 existing_type_parameter ^= type_parameters_array.At(i)->raw();
5326 existing_type_parameter_name = existing_type_parameter.name(); 5326 existing_type_parameter_name = existing_type_parameter.name();
5327 if (existing_type_parameter_name.Equals(type_parameter_name)) { 5327 if (existing_type_parameter_name.Equals(type_parameter_name)) {
5328 ReportError(type_parameter_pos, "duplicate type parameter '%s'", 5328 ReportError(type_parameter_pos, "duplicate type parameter '%s'",
5329 type_parameter_name.ToCString()); 5329 type_parameter_name.ToCString());
5330 } 5330 }
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
5953 if (url.Length() == 0) { 5953 if (url.Length() == 0) {
5954 ReportError("library url expected"); 5954 ReportError("library url expected");
5955 } 5955 }
5956 bool is_deferred_import = false; 5956 bool is_deferred_import = false;
5957 if (is_import && (IsSymbol(Symbols::Deferred()))) { 5957 if (is_import && (IsSymbol(Symbols::Deferred()))) {
5958 is_deferred_import = true; 5958 is_deferred_import = true;
5959 ConsumeToken(); 5959 ConsumeToken();
5960 CheckToken(Token::kAS, "'as' expected"); 5960 CheckToken(Token::kAS, "'as' expected");
5961 } 5961 }
5962 String& prefix = String::Handle(Z); 5962 String& prefix = String::Handle(Z);
5963 intptr_t prefix_pos = 0; 5963 intptr_t prefix_pos = Scanner::kNoSourcePos;
5964 if (is_import && (CurrentToken() == Token::kAS)) { 5964 if (is_import && (CurrentToken() == Token::kAS)) {
5965 ConsumeToken(); 5965 ConsumeToken();
5966 prefix_pos = TokenPos(); 5966 prefix_pos = TokenPos();
5967 prefix = ExpectIdentifier("prefix identifier expected")->raw(); 5967 prefix = ExpectIdentifier("prefix identifier expected")->raw();
5968 } 5968 }
5969 5969
5970 Array& show_names = Array::Handle(Z); 5970 Array& show_names = Array::Handle(Z);
5971 Array& hide_names = Array::Handle(Z); 5971 Array& hide_names = Array::Handle(Z);
5972 if (is_deferred_import || 5972 if (is_deferred_import ||
5973 IsSymbol(Symbols::Show()) || 5973 IsSymbol(Symbols::Show()) ||
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
7511 variable = new(Z) LocalVariable( 7511 variable = new(Z) LocalVariable(
7512 assign_pos, ident, type); 7512 assign_pos, ident, type);
7513 AstNode* null_expr = new(Z) LiteralNode(ident_pos, Object::null_instance()); 7513 AstNode* null_expr = new(Z) LiteralNode(ident_pos, Object::null_instance());
7514 initialization = new(Z) StoreLocalNode( 7514 initialization = new(Z) StoreLocalNode(
7515 ident_pos, variable, null_expr); 7515 ident_pos, variable, null_expr);
7516 } 7516 }
7517 7517
7518 ASSERT(current_block_ != NULL); 7518 ASSERT(current_block_ != NULL);
7519 const intptr_t previous_pos = 7519 const intptr_t previous_pos =
7520 current_block_->scope->PreviousReferencePos(ident); 7520 current_block_->scope->PreviousReferencePos(ident);
7521 if (previous_pos >= 0) { 7521 if (previous_pos != Scanner::kNoSourcePos) {
7522 ASSERT(!script_.IsNull()); 7522 ASSERT(!script_.IsNull());
7523 if (previous_pos > ident_pos) { 7523 if (previous_pos > ident_pos) {
7524 ReportError(ident_pos, 7524 ReportError(ident_pos,
7525 "initializer of '%s' may not refer to itself", 7525 "initializer of '%s' may not refer to itself",
7526 ident.ToCString()); 7526 ident.ToCString());
7527 7527
7528 } else { 7528 } else {
7529 intptr_t line_number; 7529 intptr_t line_number;
7530 script_.GetTokenLocation(previous_pos, &line_number, NULL); 7530 script_.GetTokenLocation(previous_pos, &line_number, NULL);
7531 ReportError(ident_pos, 7531 ReportError(ident_pos,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
7639 7639
7640 AstNode* Parser::ParseFunctionStatement(bool is_literal) { 7640 AstNode* Parser::ParseFunctionStatement(bool is_literal) {
7641 TRACE_PARSER("ParseFunctionStatement"); 7641 TRACE_PARSER("ParseFunctionStatement");
7642 AbstractType& result_type = AbstractType::Handle(Z); 7642 AbstractType& result_type = AbstractType::Handle(Z);
7643 const String* variable_name = NULL; 7643 const String* variable_name = NULL;
7644 const String* function_name = NULL; 7644 const String* function_name = NULL;
7645 7645
7646 result_type = Type::DynamicType(); 7646 result_type = Type::DynamicType();
7647 7647
7648 const intptr_t function_pos = TokenPos(); 7648 const intptr_t function_pos = TokenPos();
7649 intptr_t metadata_pos = -1; 7649 intptr_t metadata_pos = Scanner::kNoSourcePos;
7650 if (is_literal) { 7650 if (is_literal) {
7651 ASSERT(CurrentToken() == Token::kLPAREN); 7651 ASSERT(CurrentToken() == Token::kLPAREN);
7652 function_name = &Symbols::AnonymousClosure(); 7652 function_name = &Symbols::AnonymousClosure();
7653 } else { 7653 } else {
7654 metadata_pos = SkipMetadata(); 7654 metadata_pos = SkipMetadata();
7655 if (CurrentToken() == Token::kVOID) { 7655 if (CurrentToken() == Token::kVOID) {
7656 ConsumeToken(); 7656 ConsumeToken();
7657 result_type = Type::VoidType(); 7657 result_type = Type::VoidType();
7658 } else if ((CurrentToken() == Token::kIDENT) && 7658 } else if ((CurrentToken() == Token::kIDENT) &&
7659 (LookaheadToken(1) != Token::kLPAREN)) { 7659 (LookaheadToken(1) != Token::kLPAREN)) {
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
8949 8949
8950 8950
8951 AstNode* Parser::ParseForInStatement(intptr_t forin_pos, 8951 AstNode* Parser::ParseForInStatement(intptr_t forin_pos,
8952 SourceLabel* label) { 8952 SourceLabel* label) {
8953 TRACE_PARSER("ParseForInStatement"); 8953 TRACE_PARSER("ParseForInStatement");
8954 bool loop_var_is_final = (CurrentToken() == Token::kFINAL); 8954 bool loop_var_is_final = (CurrentToken() == Token::kFINAL);
8955 if (CurrentToken() == Token::kCONST) { 8955 if (CurrentToken() == Token::kCONST) {
8956 ReportError("Loop variable cannot be 'const'"); 8956 ReportError("Loop variable cannot be 'const'");
8957 } 8957 }
8958 const String* loop_var_name = NULL; 8958 const String* loop_var_name = NULL;
8959 intptr_t loop_var_pos = 0; 8959 intptr_t loop_var_pos = Scanner::kNoSourcePos;
8960 bool new_loop_var = false; 8960 bool new_loop_var = false;
8961 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z); 8961 AbstractType& loop_var_type = AbstractType::ZoneHandle(Z);
8962 if (LookaheadToken(1) == Token::kIN) { 8962 if (LookaheadToken(1) == Token::kIN) {
8963 loop_var_pos = TokenPos(); 8963 loop_var_pos = TokenPos();
8964 loop_var_name = ExpectIdentifier("variable name expected"); 8964 loop_var_name = ExpectIdentifier("variable name expected");
8965 } else { 8965 } else {
8966 // The case without a type is handled above, so require a type here. 8966 // The case without a type is handled above, so require a type here.
8967 // Delay creation of the local variable until we know its actual 8967 // Delay creation of the local variable until we know its actual
8968 // position, which is inside the loop body. 8968 // position, which is inside the loop body.
8969 new_loop_var = true; 8969 new_loop_var = true;
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
10060 ASSERT(outer_saved_try_ctx == NULL); 10060 ASSERT(outer_saved_try_ctx == NULL);
10061 } 10061 }
10062 } 10062 }
10063 return yield; 10063 return yield;
10064 } 10064 }
10065 10065
10066 10066
10067 AstNode* Parser::ParseStatement() { 10067 AstNode* Parser::ParseStatement() {
10068 TRACE_PARSER("ParseStatement"); 10068 TRACE_PARSER("ParseStatement");
10069 AstNode* statement = NULL; 10069 AstNode* statement = NULL;
10070 intptr_t label_pos = 0; 10070 intptr_t label_pos = Scanner::kNoSourcePos;
10071 String* label_name = NULL; 10071 String* label_name = NULL;
10072 if (IsIdentifier()) { 10072 if (IsIdentifier()) {
10073 if (LookaheadToken(1) == Token::kCOLON) { 10073 if (LookaheadToken(1) == Token::kCOLON) {
10074 // Statement starts with a label. 10074 // Statement starts with a label.
10075 label_name = CurrentLiteral(); 10075 label_name = CurrentLiteral();
10076 label_pos = TokenPos(); 10076 label_pos = TokenPos();
10077 ASSERT(label_pos > 0); 10077 ASSERT(label_pos >= 0);
10078 ConsumeToken(); // Consume identifier. 10078 ConsumeToken(); // Consume identifier.
10079 ConsumeToken(); // Consume colon. 10079 ConsumeToken(); // Consume colon.
10080 } 10080 }
10081 } 10081 }
10082 const intptr_t statement_pos = TokenPos(); 10082 const intptr_t statement_pos = TokenPos();
10083 const Token::Kind token = CurrentToken(); 10083 const Token::Kind token = CurrentToken();
10084 10084
10085 if (token == Token::kWHILE) { 10085 if (token == Token::kWHILE) {
10086 statement = ParseWhileStatement(label_name); 10086 statement = ParseWhileStatement(label_name);
10087 } else if (token == Token::kFOR) { 10087 } else if (token == Token::kFOR) {
(...skipping 4440 matching lines...) Expand 10 before | Expand all | Expand 10 after
14528 const ArgumentListNode& function_args, 14528 const ArgumentListNode& function_args,
14529 const LocalVariable* temp_for_last_arg, 14529 const LocalVariable* temp_for_last_arg,
14530 bool is_super_invocation) { 14530 bool is_super_invocation) {
14531 UNREACHABLE(); 14531 UNREACHABLE();
14532 return NULL; 14532 return NULL;
14533 } 14533 }
14534 14534
14535 } // namespace dart 14535 } // namespace dart
14536 14536
14537 #endif // DART_PRECOMPILED 14537 #endif // DART_PRECOMPILED
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698