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

Unified Diff: dart/frog/leg/native_handler.dart

Issue 9568008: Do not allow native syntax on all libraries. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 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 | « dart/frog/leg/elements/elements.dart ('k') | dart/frog/leg/scanner/class_element_parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/frog/leg/native_handler.dart
===================================================================
--- dart/frog/leg/native_handler.dart (revision 5068)
+++ dart/frog/leg/native_handler.dart (working copy)
@@ -40,11 +40,20 @@
|| libraryName == 'dart:html') {
library.define(new ForeignElement(
const SourceString('native'), library), compiler);
+ library.canUseNative = true;
}
}
+void checkAllowedLibrary(ElementListener listener, Token token) {
+ LibraryElement currentLibrary = listener.compilationUnitElement.getLibrary();
+ if (!currentLibrary.canUseNative) {
+ listener.unexpected(token);
ahe 2012/03/07 09:31:23 Please use recoverableError.
ngeoffray 2012/03/07 09:35:08 Done.
+ }
+}
+
Token handleNativeBlockToSkip(Listener listener, Token token) {
- token = token.next;
+ checkAllowedLibrary(listener, token);
+ token = token.next;
if (token.kind === STRING_TOKEN) {
token = token.next;
}
@@ -56,6 +65,7 @@
}
Token handleNativeClassBodyToSkip(Listener listener, Token token) {
+ checkAllowedLibrary(listener, token);
listener.handleIdentifier(token);
token = token.next;
if (token.kind !== STRING_TOKEN) {
@@ -71,6 +81,7 @@
}
Token handleNativeClassBody(Listener listener, Token token) {
+ checkAllowedLibrary(listener, token);
token = token.next;
if (token.kind !== STRING_TOKEN) {
listener.unexpected(token);
@@ -81,6 +92,7 @@
}
Token handleNativeFunctionBody(ElementListener listener, Token token) {
+ checkAllowedLibrary(listener, token);
Token begin = token;
listener.beginExpressionStatement(token);
listener.handleIdentifier(token);
« no previous file with comments | « dart/frog/leg/elements/elements.dart ('k') | dart/frog/leg/scanner/class_element_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698