| 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");
|
|
|