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

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

Issue 154733003: 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: sync 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 4921 matching lines...) Expand 10 before | Expand all | Expand 10 after
4932 names->Add(*CurrentLiteral()); 4932 names->Add(*CurrentLiteral());
4933 ConsumeToken(); // Identifier. 4933 ConsumeToken(); // Identifier.
4934 if (CurrentToken() != Token::kCOMMA) { 4934 if (CurrentToken() != Token::kCOMMA) {
4935 return; 4935 return;
4936 } 4936 }
4937 ConsumeToken(); // Comma. 4937 ConsumeToken(); // Comma.
4938 } 4938 }
4939 } 4939 }
4940 4940
4941 4941
4942 void Parser::ParseLibraryImportExport() { 4942 void Parser::ParseLibraryImportExport(intptr_t metadata_pos) {
4943 bool is_import = (CurrentToken() == Token::kIMPORT); 4943 bool is_import = (CurrentToken() == Token::kIMPORT);
4944 bool is_export = (CurrentToken() == Token::kEXPORT); 4944 bool is_export = (CurrentToken() == Token::kEXPORT);
4945 ASSERT(is_import || is_export); 4945 ASSERT(is_import || is_export);
4946 const intptr_t import_pos = TokenPos(); 4946 const intptr_t import_pos = TokenPos();
4947 ConsumeToken(); 4947 ConsumeToken();
4948 CheckToken(Token::kSTRING, "library url expected"); 4948 CheckToken(Token::kSTRING, "library url expected");
4949 AstNode* url_literal = ParseStringLiteral(false); 4949 AstNode* url_literal = ParseStringLiteral(false);
4950 ASSERT(url_literal->IsLiteralNode()); 4950 ASSERT(url_literal->IsLiteralNode());
4951 ASSERT(url_literal->AsLiteralNode()->literal().IsString()); 4951 ASSERT(url_literal->AsLiteralNode()->literal().IsString());
4952 const String& url = String::Cast(url_literal->AsLiteralNode()->literal()); 4952 const String& url = String::Cast(url_literal->AsLiteralNode()->literal());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4995 // Call the library tag handler to load the library. 4995 // Call the library tag handler to load the library.
4996 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url); 4996 CallLibraryTagHandler(Dart_kImportTag, import_pos, canon_url);
4997 // If the library tag handler succeded without registering the 4997 // If the library tag handler succeded without registering the
4998 // library we create an empty library to import. 4998 // library we create an empty library to import.
4999 library = Library::LookupLibrary(canon_url); 4999 library = Library::LookupLibrary(canon_url);
5000 if (library.IsNull()) { 5000 if (library.IsNull()) {
5001 library = Library::New(canon_url); 5001 library = Library::New(canon_url);
5002 library.Register(); 5002 library.Register();
5003 } 5003 }
5004 } 5004 }
5005 const Namespace& ns = 5005
5006 Namespace::Handle(Namespace::New(library, show_names, hide_names)); 5006 Namespace& ns =
5007 Namespace::Handle(Namespace::New(library, show_names, hide_names));
5008 if (metadata_pos >= 0) {
5009 ns.AddMetadata(metadata_pos, current_class());
5010 }
5011
5007 if (is_import) { 5012 if (is_import) {
5008 // Ensure that private dart:_ libraries are only imported into dart: 5013 // Ensure that private dart:_ libraries are only imported into dart:
5009 // libraries. 5014 // libraries.
5010 const String& lib_url = String::Handle(library_.url()); 5015 const String& lib_url = String::Handle(library_.url());
5011 if (canon_url.StartsWith(Symbols::DartSchemePrivate()) && 5016 if (canon_url.StartsWith(Symbols::DartSchemePrivate()) &&
5012 !lib_url.StartsWith(Symbols::DartScheme())) { 5017 !lib_url.StartsWith(Symbols::DartScheme())) {
5013 ErrorMsg(import_pos, "private library is not accessible"); 5018 ErrorMsg(import_pos, "private library is not accessible");
5014 } 5019 }
5015 if (prefix.IsNull() || (prefix.Length() == 0)) { 5020 if (prefix.IsNull() || (prefix.Length() == 0)) {
5016 library_.AddImport(ns); 5021 library_.AddImport(ns);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5069 } 5074 }
5070 ParseLibraryName(); 5075 ParseLibraryName();
5071 if (metadata_pos >= 0) { 5076 if (metadata_pos >= 0) {
5072 library_.AddLibraryMetadata(current_class(), metadata_pos); 5077 library_.AddLibraryMetadata(current_class(), metadata_pos);
5073 } 5078 }
5074 rewind_pos = TokenPos(); 5079 rewind_pos = TokenPos();
5075 metadata_pos = SkipMetadata(); 5080 metadata_pos = SkipMetadata();
5076 } 5081 }
5077 while ((CurrentToken() == Token::kIMPORT) || 5082 while ((CurrentToken() == Token::kIMPORT) ||
5078 (CurrentToken() == Token::kEXPORT)) { 5083 (CurrentToken() == Token::kEXPORT)) {
5079 ParseLibraryImportExport(); 5084 ParseLibraryImportExport(metadata_pos);
5080 rewind_pos = TokenPos(); 5085 rewind_pos = TokenPos();
5081 metadata_pos = SkipMetadata(); 5086 metadata_pos = SkipMetadata();
5082 } 5087 }
5083 // Core lib has not been explicitly imported, so we implicitly 5088 // Core lib has not been explicitly imported, so we implicitly
5084 // import it here. 5089 // import it here.
5085 if (!library_.ImportsCorelib()) { 5090 if (!library_.ImportsCorelib()) {
5086 Library& core_lib = Library::Handle(Library::CoreLibrary()); 5091 Library& core_lib = Library::Handle(Library::CoreLibrary());
5087 ASSERT(!core_lib.IsNull()); 5092 ASSERT(!core_lib.IsNull());
5088 const Namespace& core_ns = Namespace::Handle( 5093 const Namespace& core_ns = Namespace::Handle(
5089 Namespace::New(core_lib, Object::null_array(), Object::null_array())); 5094 Namespace::New(core_lib, Object::null_array(), Object::null_array()));
(...skipping 5688 matching lines...) Expand 10 before | Expand all | Expand 10 after
10778 void Parser::SkipQualIdent() { 10783 void Parser::SkipQualIdent() {
10779 ASSERT(IsIdentifier()); 10784 ASSERT(IsIdentifier());
10780 ConsumeToken(); 10785 ConsumeToken();
10781 if (CurrentToken() == Token::kPERIOD) { 10786 if (CurrentToken() == Token::kPERIOD) {
10782 ConsumeToken(); // Consume the kPERIOD token. 10787 ConsumeToken(); // Consume the kPERIOD token.
10783 ExpectIdentifier("identifier expected after '.'"); 10788 ExpectIdentifier("identifier expected after '.'");
10784 } 10789 }
10785 } 10790 }
10786 10791
10787 } // namespace dart 10792 } // 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