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

Unified Diff: runtime/vm/parser.cc

Issue 12880023: Remove legacy syntax support for library import (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/scanner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 20447)
+++ runtime/vm/parser.cc (working copy)
@@ -4197,28 +4197,7 @@
}
-// TODO(hausner): Remove support for old library definition syntax.
-void Parser::ParseLibraryNameObsoleteSyntax() {
- if ((script_.kind() == RawScript::kLibraryTag) &&
- (CurrentToken() != Token::kLEGACY_LIBRARY)) {
- // Handle error case early to get consistent error message.
- ExpectToken(Token::kLEGACY_LIBRARY);
- }
- if (CurrentToken() == Token::kLEGACY_LIBRARY) {
- ConsumeToken();
- ExpectToken(Token::kLPAREN);
- if (CurrentToken() != Token::kSTRING) {
- ErrorMsg("library name expected");
- }
- const String& name = *CurrentLiteral();
- ConsumeToken();
- ExpectToken(Token::kRPAREN);
- ExpectToken(Token::kSEMICOLON);
- library_.SetName(name);
- }
-}
-
RawObject* Parser::CallLibraryTagHandler(Dart_LibraryTag tag,
intptr_t token_pos,
const String& url) {
@@ -4252,91 +4231,6 @@
}
-// TODO(hausner): Remove support for old library definition syntax.
-void Parser::ParseLibraryImportObsoleteSyntax() {
- while (CurrentToken() == Token::kLEGACY_IMPORT) {
- const intptr_t import_pos = TokenPos();
- ConsumeToken();
- ExpectToken(Token::kLPAREN);
- if (CurrentToken() != Token::kSTRING) {
- ErrorMsg("library url expected");
- }
- const String& url = *CurrentLiteral();
- ConsumeToken();
- String& prefix = String::Handle();
- if (CurrentToken() == Token::kCOMMA) {
- ConsumeToken();
- if (!IsLiteral("prefix")) {
- ErrorMsg("prefix: expected");
- }
- ConsumeToken();
- ExpectToken(Token::kCOLON);
- if (CurrentToken() != Token::kSTRING) {
- ErrorMsg("prefix expected");
- }
- prefix = CurrentLiteral()->raw();
- // TODO(asiva): Need to also check that prefix is not a reserved keyword.
- if (!Scanner::IsIdent(prefix)) {
- ErrorMsg("prefix should be an identifier");
- }
- ConsumeToken();
- }
- ExpectToken(Token::kRPAREN);
- ExpectToken(Token::kSEMICOLON);
- const String& canon_url = String::CheckedHandle(
- CallLibraryTagHandler(kCanonicalizeUrl, import_pos, url));
- // Lookup the library URL.
- Library& library = Library::Handle(Library::LookupLibrary(canon_url));
- if (library.IsNull()) {
- // Call the library tag handler to load the library.
- CallLibraryTagHandler(kImportTag, import_pos, canon_url);
- // If the library tag handler succeded without registering the
- // library we create an empty library to import.
- library = Library::LookupLibrary(canon_url);
- if (library.IsNull()) {
- library = Library::New(canon_url);
- library.Register();
- }
- }
- // Add the import to the library.
- const Namespace& import = Namespace::Handle(
- Namespace::New(library, Array::Handle(), Array::Handle()));
- if (prefix.IsNull() || (prefix.Length() == 0)) {
- library_.AddImport(import);
- } else {
- LibraryPrefix& library_prefix = LibraryPrefix::Handle();
- library_prefix = library_.LookupLocalLibraryPrefix(prefix);
- if (!library_prefix.IsNull()) {
- library_prefix.AddImport(import);
- } else {
- library_prefix = LibraryPrefix::New(prefix, import);
- library_.AddObject(library_prefix, prefix);
- }
- }
- }
-}
-
-
-// TODO(hausner): Remove support for old library definition syntax.
-void Parser::ParseLibraryIncludeObsoleteSyntax() {
- while (CurrentToken() == Token::kLEGACY_SOURCE) {
- const intptr_t source_pos = TokenPos();
- ConsumeToken();
- ExpectToken(Token::kLPAREN);
- if (CurrentToken() != Token::kSTRING) {
- ErrorMsg("source url expected");
- }
- const String& url = *CurrentLiteral();
- ConsumeToken();
- ExpectToken(Token::kRPAREN);
- ExpectToken(Token::kSEMICOLON);
- const String& canon_url = String::CheckedHandle(
- CallLibraryTagHandler(kCanonicalizeUrl, source_pos, url));
- CallLibraryTagHandler(kSourceTag, source_pos, canon_url);
- }
-}
-
-
void Parser::ParseLibraryName() {
ASSERT(CurrentToken() == Token::kLIBRARY);
ConsumeToken();
@@ -4486,25 +4380,6 @@
ConsumeToken();
}
- // TODO(hausner): Remove support for old library definition syntax.
- if ((CurrentToken() == Token::kLEGACY_LIBRARY) ||
- (CurrentToken() == Token::kLEGACY_IMPORT) ||
- (CurrentToken() == Token::kLEGACY_SOURCE)) {
- ParseLibraryNameObsoleteSyntax();
- ParseLibraryImportObsoleteSyntax();
- ParseLibraryIncludeObsoleteSyntax();
- // Core lib has not been explicitly imported, so we implicitly
- // import it here.
- if (!library_.ImportsCorelib()) {
- Library& core_lib = Library::Handle(Library::CoreLibrary());
- ASSERT(!core_lib.IsNull());
- const Namespace& core_ns = Namespace::Handle(
- Namespace::New(core_lib, Array::Handle(), Array::Handle()));
- library_.AddImport(core_ns);
- }
- return;
- }
-
ASSERT(script_.kind() != RawScript::kSourceTag);
// We may read metadata tokens that are part of the toplevel
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698