| 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 import '../common.dart'; | 5 import '../common.dart'; |
| 6 import '../parser/element_listener.dart' show ElementListener; | 6 import '../parser/element_listener.dart' show ElementListener; |
| 7 import '../parser/listener.dart' show Listener; | 7 import '../parser/listener.dart' show Listener; |
| 8 import '../tokens/token.dart' show BeginGroupToken, Token; | 8 import '../tokens/token.dart' show BeginGroupToken, Token; |
| 9 import '../tokens/token_constants.dart' as Tokens show STRING_TOKEN; | 9 import '../tokens/token_constants.dart' as Tokens show STRING_TOKEN; |
| 10 | 10 |
| 11 void checkAllowedLibrary(ElementListener listener, Token token) { | 11 void checkAllowedLibrary(ElementListener listener, Token token) { |
| 12 if (listener.scannerOptions.canUseNative) return; | 12 if (listener.scannerOptions.canUseNative) return; |
| 13 listener.reportError(token, MessageKind.NATIVE_NOT_SUPPORTED); | 13 listener.reportError(token, MessageKind.NATIVE_NOT_SUPPORTED); |
| 14 } | 14 } |
| 15 | 15 |
| 16 Token handleNativeBlockToSkip(Listener listener, Token token) { | 16 Token handleNativeBlockToSkip(ElementListener listener, Token token) { |
| 17 checkAllowedLibrary(listener, token); | 17 checkAllowedLibrary(listener, token); |
| 18 token = token.next; | 18 token = token.next; |
| 19 if (identical(token.kind, Tokens.STRING_TOKEN)) { | 19 if (identical(token.kind, Tokens.STRING_TOKEN)) { |
| 20 token = token.next; | 20 token = token.next; |
| 21 } | 21 } |
| 22 if (identical(token.stringValue, '{')) { | 22 if (identical(token.stringValue, '{')) { |
| 23 BeginGroupToken beginGroupToken = token; | 23 BeginGroupToken beginGroupToken = token; |
| 24 token = beginGroupToken.endGroup; | 24 token = beginGroupToken.endGroup; |
| 25 } | 25 } |
| 26 return token; | 26 return token; |
| 27 } | 27 } |
| 28 | 28 |
| 29 Token handleNativeFunctionBody(ElementListener listener, Token token) { | 29 Token handleNativeFunctionBody(ElementListener listener, Token token) { |
| 30 checkAllowedLibrary(listener, token); | 30 checkAllowedLibrary(listener, token); |
| 31 Token begin = token; | 31 Token begin = token; |
| 32 listener.beginReturnStatement(token); | 32 listener.beginReturnStatement(token); |
| 33 token = token.next; | 33 token = token.next; |
| 34 bool hasExpression = false; | 34 bool hasExpression = false; |
| 35 if (identical(token.kind, Tokens.STRING_TOKEN)) { | 35 if (identical(token.kind, Tokens.STRING_TOKEN)) { |
| 36 hasExpression = true; | 36 hasExpression = true; |
| 37 listener.beginLiteralString(token); | 37 listener.beginLiteralString(token); |
| 38 listener.endLiteralString(0); | 38 listener.endLiteralString(0); |
| 39 token = token.next; | 39 token = token.next; |
| 40 } | 40 } |
| 41 listener.endReturnStatement(hasExpression, begin, token); | 41 listener.endReturnStatement(hasExpression, begin, token); |
| 42 // TODO(ngeoffray): expect a ';'. | 42 // TODO(ngeoffray): expect a ';'. |
| 43 // Currently there are method with both native marker and Dart body. | 43 // Currently there are method with both native marker and Dart body. |
| 44 return token.next; | 44 return token.next; |
| 45 } | 45 } |
| OLD | NEW |