| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of native; | 5 part of native; |
| 6 | 6 |
| 7 void checkAllowedLibrary(ElementListener listener, Token token) { | 7 void checkAllowedLibrary(ElementListener listener, Token token) { |
| 8 LibraryElement currentLibrary = listener.compilationUnitElement.library; | 8 LibraryElement currentLibrary = listener.compilationUnitElement.library; |
| 9 if (!currentLibrary.canUseNative) { | 9 if (currentLibrary.canUseNative) return; |
| 10 listener.recoverableError(token, "Unexpected token"); | 10 listener.reportError(token, MessageKind.NATIVE_NOT_SUPPORTED); |
| 11 } | |
| 12 } | 11 } |
| 13 | 12 |
| 14 Token handleNativeBlockToSkip(Listener listener, Token token) { | 13 Token handleNativeBlockToSkip(Listener listener, Token token) { |
| 15 checkAllowedLibrary(listener, token); | 14 checkAllowedLibrary(listener, token); |
| 16 token = token.next; | 15 token = token.next; |
| 17 if (identical(token.kind, STRING_TOKEN)) { | 16 if (identical(token.kind, STRING_TOKEN)) { |
| 18 token = token.next; | 17 token = token.next; |
| 19 } | 18 } |
| 20 if (identical(token.stringValue, '{')) { | 19 if (identical(token.stringValue, '{')) { |
| 21 BeginGroupToken beginGroupToken = token; | 20 BeginGroupToken beginGroupToken = token; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 hasExpression = true; | 33 hasExpression = true; |
| 35 listener.beginLiteralString(token); | 34 listener.beginLiteralString(token); |
| 36 listener.endLiteralString(0); | 35 listener.endLiteralString(0); |
| 37 token = token.next; | 36 token = token.next; |
| 38 } | 37 } |
| 39 listener.endReturnStatement(hasExpression, begin, token); | 38 listener.endReturnStatement(hasExpression, begin, token); |
| 40 // TODO(ngeoffray): expect a ';'. | 39 // TODO(ngeoffray): expect a ';'. |
| 41 // Currently there are method with both native marker and Dart body. | 40 // Currently there are method with both native marker and Dart body. |
| 42 return token.next; | 41 return token.next; |
| 43 } | 42 } |
| OLD | NEW |