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

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

Issue 1131793012: Ensure libraries always have at least one top-level class and therefore at least one script. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/lib/lib.status » ('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 "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 5952 matching lines...) Expand 10 before | Expand all | Expand 10 after
5963 ParseTopLevelFunction(&top_level, metadata_pos); 5963 ParseTopLevelFunction(&top_level, metadata_pos);
5964 } else if (IsTopLevelAccessor()) { 5964 } else if (IsTopLevelAccessor()) {
5965 ParseTopLevelAccessor(&top_level, metadata_pos); 5965 ParseTopLevelAccessor(&top_level, metadata_pos);
5966 } else if (CurrentToken() == Token::kEOS) { 5966 } else if (CurrentToken() == Token::kEOS) {
5967 break; 5967 break;
5968 } else { 5968 } else {
5969 UnexpectedToken(); 5969 UnexpectedToken();
5970 } 5970 }
5971 } 5971 }
5972 } 5972 }
5973 if ((top_level.fields.Length() > 0) || (top_level.functions.Length() > 0)) { 5973
5974 if ((library_.num_anonymous_classes() == 0) ||
5975 (top_level.fields.Length() > 0) || (top_level.functions.Length() > 0)) {
5974 toplevel_class.AddFields(top_level.fields); 5976 toplevel_class.AddFields(top_level.fields);
5975 5977
5976 const Array& array = Array::Handle(Z, 5978 const Array& array = Array::Handle(Z,
5977 Array::MakeArray(top_level.functions)); 5979 Array::MakeArray(top_level.functions));
5978 toplevel_class.SetFunctions(array); 5980 toplevel_class.SetFunctions(array);
5979 5981
5980 library_.AddAnonymousClass(toplevel_class); 5982 library_.AddAnonymousClass(toplevel_class);
5981 pending_classes.Add(toplevel_class, Heap::kOld); 5983 pending_classes.Add(toplevel_class, Heap::kOld);
5982 } 5984 }
5983 } 5985 }
(...skipping 7491 matching lines...) Expand 10 before | Expand all | Expand 10 after
13475 void Parser::SkipQualIdent() { 13477 void Parser::SkipQualIdent() {
13476 ASSERT(IsIdentifier()); 13478 ASSERT(IsIdentifier());
13477 ConsumeToken(); 13479 ConsumeToken();
13478 if (CurrentToken() == Token::kPERIOD) { 13480 if (CurrentToken() == Token::kPERIOD) {
13479 ConsumeToken(); // Consume the kPERIOD token. 13481 ConsumeToken(); // Consume the kPERIOD token.
13480 ExpectIdentifier("identifier expected after '.'"); 13482 ExpectIdentifier("identifier expected after '.'");
13481 } 13483 }
13482 } 13484 }
13483 13485
13484 } // namespace dart 13486 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698