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

Unified Diff: lib/compiler/implementation/scanner/listener.dart

Issue 10824347: Make top-level patch injections be compilation unit under library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Offline discussed changes. Created 8 years, 4 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
Index: lib/compiler/implementation/scanner/listener.dart
diff --git a/lib/compiler/implementation/scanner/listener.dart b/lib/compiler/implementation/scanner/listener.dart
index 18c0442b725a8e2b19a8a0e57c37a21da12a0242..54d68f9e7e892626ee5cadaa9b3a0b5e34edfadb 100644
--- a/lib/compiler/implementation/scanner/listener.dart
+++ b/lib/compiler/implementation/scanner/listener.dart
@@ -547,6 +547,13 @@ class ElementListener extends Listener {
return node;
}
+ bool allowScriptTags() {
+ // Script tags are only allowed in the library file itself, not in
+ // sourced files.
+ LibraryElement library = compilationUnitElement.getLibrary();
+ return library.entryCompilationUnit == compilationUnitElement;
+ }
+
void endScriptTag(bool hasPrefix, Token beginToken, Token endToken) {
StringNode prefix = null;
Identifier argumentName = null;
@@ -556,14 +563,13 @@ class ElementListener extends Listener {
}
StringNode firstArgument = popLiteralString();
Identifier tag = popNode();
- LibraryElement library = compilationUnitElement.getLibrary();
- if (library.entryCompilationUnit != compilationUnitElement) {
+ if (!allowScriptTags()) {
// Only allow script tags in the entry compilation unit.
listener.cancel("script tags not allowed here", node: tag);
}
ScriptTag scriptTag = new ScriptTag(tag, firstArgument, argumentName,
prefix, beginToken, endToken);
- library.addTag(scriptTag, listener);
+ addScriptTag(scriptTag);
}
void endClassDeclaration(int interfacesCount, Token beginToken,
@@ -792,6 +798,10 @@ class ElementListener extends Listener {
compilationUnitElement.addMember(element, listener);
}
+ void addScriptTag(ScriptTag tag) {
+ compilationUnitElement.getLibrary().addTag(tag, listener);
+ }
+
void pushNode(Node node) {
nodes = nodes.prepend(node);
if (VERBOSE) log("push $nodes");
« no previous file with comments | « lib/compiler/implementation/patch_parser.dart ('k') | lib/compiler/implementation/scanner/scanner_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698