OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// Implements support for Dart VM native method bodies of this form: | 5 /// Implements support for Dart VM native method bodies of this form: |
6 /// | 6 /// |
7 /// native STRING | 7 /// native STRING |
8 /// | 8 /// |
9 /// This support is kept separate from parser.dart as this isn't specified in | 9 /// This support is kept separate from parser.dart as this isn't specified in |
10 /// the Dart Language Specification, also we hope to remove this syntax long | 10 /// the Dart Language Specification, also we hope to remove this syntax long |
(...skipping 27 matching lines...) Expand all Loading... |
38 /// | 38 /// |
39 /// This will result in [identifiers] being | 39 /// This will result in [identifiers] being |
40 /// | 40 /// |
41 /// [";", '"List_getLength"', "native", "length", "get"] | 41 /// [";", '"List_getLength"', "native", "length", "get"] |
42 /// | 42 /// |
43 /// We need to remove '"List_getLength"' and "native" from that list. | 43 /// We need to remove '"List_getLength"' and "native" from that list. |
44 /// | 44 /// |
45 /// This method designed to be called from [Listener.handleMemberName]. | 45 /// This method designed to be called from [Listener.handleMemberName]. |
46 Link<Token> removeNativeClause(Link<Token> identifiers) { | 46 Link<Token> removeNativeClause(Link<Token> identifiers) { |
47 Link<Token> result = identifiers.tail; | 47 Link<Token> result = identifiers.tail; |
| 48 if (result.isEmpty) return identifiers; |
48 if (result.head.kind != STRING_TOKEN) return identifiers; | 49 if (result.head.kind != STRING_TOKEN) return identifiers; |
49 result = result.tail; | 50 result = result.tail; |
50 if (result.isEmpty) return identifiers; | 51 if (result.isEmpty) return identifiers; |
51 if (optional('native', result.head)) { | 52 if (optional('native', result.head)) { |
52 return result.tail.prepend(identifiers.head); | 53 return result.tail.prepend(identifiers.head); |
53 } | 54 } |
54 return identifiers; | 55 return identifiers; |
55 } | 56 } |
OLD | NEW |