| OLD | NEW |
| 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 "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
| (...skipping 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 SetAllowFunctionLiterals(false); | 1897 SetAllowFunctionLiterals(false); |
| 1898 SkipExpr(); | 1898 SkipExpr(); |
| 1899 SetAllowFunctionLiterals(true); | 1899 SetAllowFunctionLiterals(true); |
| 1900 } | 1900 } |
| 1901 } while (CurrentToken() == Token::kCOMMA); | 1901 } while (CurrentToken() == Token::kCOMMA); |
| 1902 } | 1902 } |
| 1903 | 1903 |
| 1904 | 1904 |
| 1905 void Parser::ParseQualIdent(QualIdent* qual_ident) { | 1905 void Parser::ParseQualIdent(QualIdent* qual_ident) { |
| 1906 ASSERT(IsIdentifier()); | 1906 ASSERT(IsIdentifier()); |
| 1907 ASSERT(!current_class().IsNull()); |
| 1907 qual_ident->ident_pos = token_index_; | 1908 qual_ident->ident_pos = token_index_; |
| 1908 qual_ident->ident = CurrentLiteral(); | 1909 qual_ident->ident = CurrentLiteral(); |
| 1909 qual_ident->lib_prefix = NULL; | 1910 qual_ident->lib_prefix = NULL; |
| 1910 ConsumeToken(); | 1911 ConsumeToken(); |
| 1911 if (CurrentToken() == Token::kPERIOD) { | 1912 if (CurrentToken() == Token::kPERIOD) { |
| 1912 // An identifier cannot be resolved in a local scope when top level parsing. | 1913 // An identifier cannot be resolved in a local scope when top level parsing. |
| 1913 if (is_top_level_ || | 1914 if (is_top_level_ || |
| 1914 !ResolveIdentInLocalScope(qual_ident->ident_pos, | 1915 !ResolveIdentInLocalScope(qual_ident->ident_pos, |
| 1915 *(qual_ident->ident), | 1916 *(qual_ident->ident), |
| 1916 NULL)) { | 1917 NULL)) { |
| (...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3356 | 3357 |
| 3357 while (true) { | 3358 while (true) { |
| 3358 set_current_class(Class::Handle()); // No current class. | 3359 set_current_class(Class::Handle()); // No current class. |
| 3359 if (CurrentToken() == Token::kCLASS) { | 3360 if (CurrentToken() == Token::kCLASS) { |
| 3360 ParseClassDefinition(&classes); | 3361 ParseClassDefinition(&classes); |
| 3361 } else if ((CurrentToken() == Token::kTYPEDEF) && | 3362 } else if ((CurrentToken() == Token::kTYPEDEF) && |
| 3362 (LookaheadToken(1) != Token::kLPAREN)) { | 3363 (LookaheadToken(1) != Token::kLPAREN)) { |
| 3363 ParseFunctionTypeAlias(&classes); | 3364 ParseFunctionTypeAlias(&classes); |
| 3364 } else if (CurrentToken() == Token::kINTERFACE) { | 3365 } else if (CurrentToken() == Token::kINTERFACE) { |
| 3365 ParseInterfaceDefinition(&classes); | 3366 ParseInterfaceDefinition(&classes); |
| 3366 } else if (IsVariableDeclaration()) { | 3367 } else { |
| 3367 set_current_class(toplevel_class); | 3368 set_current_class(toplevel_class); |
| 3368 ParseTopLevelVariable(&top_level); | 3369 if (IsVariableDeclaration()) { |
| 3369 } else if (IsTopLevelFunction()) { | 3370 ParseTopLevelVariable(&top_level); |
| 3370 set_current_class(toplevel_class); | 3371 } else if (IsTopLevelFunction()) { |
| 3371 ParseTopLevelFunction(&top_level); | 3372 ParseTopLevelFunction(&top_level); |
| 3372 } else if (IsTopLevelAccessor()) { | 3373 } else if (IsTopLevelAccessor()) { |
| 3373 set_current_class(toplevel_class); | 3374 ParseTopLevelAccessor(&top_level); |
| 3374 ParseTopLevelAccessor(&top_level); | 3375 } else if (CurrentToken() == Token::kEOS) { |
| 3375 } else if (CurrentToken() == Token::kEOS) { | 3376 break; |
| 3376 break; | 3377 } else { |
| 3377 } else { | 3378 UnexpectedToken(); |
| 3378 UnexpectedToken(); | 3379 } |
| 3379 } | 3380 } |
| 3380 } | 3381 } |
| 3381 if ((top_level.fields.length() > 0) || (top_level.functions.length() > 0)) { | 3382 if ((top_level.fields.length() > 0) || (top_level.functions.length() > 0)) { |
| 3382 toplevel_class.SetFields( | 3383 toplevel_class.SetFields( |
| 3383 Array::Handle(NewArray<Field>(top_level.fields))); | 3384 Array::Handle(NewArray<Field>(top_level.fields))); |
| 3384 toplevel_class.SetFunctions( | 3385 toplevel_class.SetFunctions( |
| 3385 Array::Handle(NewArray<Function>(top_level.functions))); | 3386 Array::Handle(NewArray<Function>(top_level.functions))); |
| 3386 library_.AddAnonymousClass(toplevel_class); | 3387 library_.AddAnonymousClass(toplevel_class); |
| 3387 classes.Add(&toplevel_class); | 3388 classes.Add(&toplevel_class); |
| 3388 } | 3389 } |
| (...skipping 4327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7716 void Parser::SkipQualIdent() { | 7717 void Parser::SkipQualIdent() { |
| 7717 ASSERT(IsIdentifier()); | 7718 ASSERT(IsIdentifier()); |
| 7718 ConsumeToken(); | 7719 ConsumeToken(); |
| 7719 if (CurrentToken() == Token::kPERIOD) { | 7720 if (CurrentToken() == Token::kPERIOD) { |
| 7720 ConsumeToken(); // Consume the kPERIOD token. | 7721 ConsumeToken(); // Consume the kPERIOD token. |
| 7721 ExpectIdentifier("identifier expected after '.'"); | 7722 ExpectIdentifier("identifier expected after '.'"); |
| 7722 } | 7723 } |
| 7723 } | 7724 } |
| 7724 | 7725 |
| 7725 } // namespace dart | 7726 } // namespace dart |
| OLD | NEW |