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

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

Issue 189293002: Revert "Access to imports in the VM's runtime mirrors. Extend test coverage of the source mirrors." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 "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 4907 matching lines...) Expand 10 before | Expand all | Expand 10 after
4918 names->Add(*CurrentLiteral()); 4918 names->Add(*CurrentLiteral());
4919 ConsumeToken(); // Identifier. 4919 ConsumeToken(); // Identifier.
4920 if (CurrentToken() != Token::kCOMMA) { 4920 if (CurrentToken() != Token::kCOMMA) {
4921 return; 4921 return;
4922 } 4922 }
4923 ConsumeToken(); // Comma. 4923 ConsumeToken(); // Comma.
4924 } 4924 }
4925 } 4925 }
4926 4926
4927 4927
4928 void Parser::ParseLibraryImportExport(intptr_t metadata_pos) { 4928 void Parser::ParseLibraryImportExport() {
4929 bool is_import = (CurrentToken() == Token::kIMPORT); 4929 bool is_import = (CurrentToken() == Token::kIMPORT);
4930 bool is_export = (CurrentToken() == Token::kEXPORT); 4930 bool is_export = (CurrentToken() == Token::kEXPORT);
4931 ASSERT(is_import || is_export); 4931 ASSERT(is_import || is_export);
4932 const intptr_t import_pos = TokenPos(); 4932 const intptr_t import_pos = TokenPos();
4933 ConsumeToken(); 4933 ConsumeToken();
4934 CheckToken(Token::kSTRING, "library url expected"); 4934 CheckToken(Token::kSTRING, "library url expected");
4935 AstNode* url_literal = ParseStringLiteral(false); 4935 AstNode* url_literal = ParseStringLiteral(false);
4936 ASSERT(url_literal->IsLiteralNode()); 4936 ASSERT(url_literal->IsLiteralNode());
4937 ASSERT(url_literal->AsLiteralNode()->literal().IsString()); 4937 ASSERT(url_literal->AsLiteralNode()->literal().IsString());
4938 const String& url = String::Cast(url_literal->AsLiteralNode()->literal()); 4938 const String& url = String::Cast(url_literal->AsLiteralNode()->literal());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4981 // Call the library tag handler to load the library. 4981 // Call the library tag handler to load the library.
4982 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); 4982 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url);
4983 // If the library tag handler succeded without registering the 4983 // If the library tag handler succeded without registering the
4984 // library we create an empty library to import. 4984 // library we create an empty library to import.
4985 library = Library::LookupLibrary(canon_url); 4985 library = Library::LookupLibrary(canon_url);
4986 if (library.IsNull()) { 4986 if (library.IsNull()) {
4987 library = Library::New(canon_url); 4987 library = Library::New(canon_url);
4988 library.Register(); 4988 library.Register();
4989 } 4989 }
4990 } 4990 }
4991 4991 const Namespace& ns =
4992 Namespace& ns = 4992 Namespace::Handle(Namespace::New(library, show_names, hide_names));
4993 Namespace::Handle(Namespace::New(library, show_names, hide_names));
4994 if (metadata_pos >= 0) {
4995 ns.AddMetadata(metadata_pos, current_class());
4996 }
4997
4998 if (is_import) { 4993 if (is_import) {
4999 // Ensure that private dart:_ libraries are only imported into dart: 4994 // Ensure that private dart:_ libraries are only imported into dart:
5000 // libraries. 4995 // libraries.
5001 const String& lib_url = String::Handle(library_.url()); 4996 const String& lib_url = String::Handle(library_.url());
5002 if (canon_url.StartsWith(Symbols::DartSchemePrivate()) && 4997 if (canon_url.StartsWith(Symbols::DartSchemePrivate()) &&
5003 !lib_url.StartsWith(Symbols::DartScheme())) { 4998 !lib_url.StartsWith(Symbols::DartScheme())) {
5004 ErrorMsg(import_pos, "private library is not accessible"); 4999 ErrorMsg(import_pos, "private library is not accessible");
5005 } 5000 }
5006 if (prefix.IsNull() || (prefix.Length() == 0)) { 5001 if (prefix.IsNull() || (prefix.Length() == 0)) {
5007 library_.AddImport(ns); 5002 library_.AddImport(ns);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5060 } 5055 }
5061 ParseLibraryName(); 5056 ParseLibraryName();
5062 if (metadata_pos >= 0) { 5057 if (metadata_pos >= 0) {
5063 library_.AddLibraryMetadata(current_class(), metadata_pos); 5058 library_.AddLibraryMetadata(current_class(), metadata_pos);
5064 } 5059 }
5065 rewind_pos = TokenPos(); 5060 rewind_pos = TokenPos();
5066 metadata_pos = SkipMetadata(); 5061 metadata_pos = SkipMetadata();
5067 } 5062 }
5068 while ((CurrentToken() == Token::kIMPORT) || 5063 while ((CurrentToken() == Token::kIMPORT) ||
5069 (CurrentToken() == Token::kEXPORT)) { 5064 (CurrentToken() == Token::kEXPORT)) {
5070 ParseLibraryImportExport(metadata_pos); 5065 ParseLibraryImportExport();
5071 rewind_pos = TokenPos(); 5066 rewind_pos = TokenPos();
5072 metadata_pos = SkipMetadata(); 5067 metadata_pos = SkipMetadata();
5073 } 5068 }
5074 // Core lib has not been explicitly imported, so we implicitly 5069 // Core lib has not been explicitly imported, so we implicitly
5075 // import it here. 5070 // import it here.
5076 if (!library_.ImportsCorelib()) { 5071 if (!library_.ImportsCorelib()) {
5077 Library& core_lib = Library::Handle(Library::CoreLibrary()); 5072 Library& core_lib = Library::Handle(Library::CoreLibrary());
5078 ASSERT(!core_lib.IsNull()); 5073 ASSERT(!core_lib.IsNull());
5079 const Namespace& core_ns = Namespace::Handle( 5074 const Namespace& core_ns = Namespace::Handle(
5080 Namespace::New(core_lib, Object::null_array(), Object::null_array())); 5075 Namespace::New(core_lib, Object::null_array(), Object::null_array()));
(...skipping 5698 matching lines...) Expand 10 before | Expand all | Expand 10 after
10779 void Parser::SkipQualIdent() { 10774 void Parser::SkipQualIdent() {
10780 ASSERT(IsIdentifier()); 10775 ASSERT(IsIdentifier());
10781 ConsumeToken(); 10776 ConsumeToken();
10782 if (CurrentToken() == Token::kPERIOD) { 10777 if (CurrentToken() == Token::kPERIOD) {
10783 ConsumeToken(); // Consume the kPERIOD token. 10778 ConsumeToken(); // Consume the kPERIOD token.
10784 ExpectIdentifier("identifier expected after '.'"); 10779 ExpectIdentifier("identifier expected after '.'");
10785 } 10780 }
10786 } 10781 }
10787 10782
10788 } // namespace dart 10783 } // 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