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

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/dart_vm_native.dart

Issue 2738903002: Change the calling conventions for handleUnrecoverableError. (Closed)
Patch Set: Fix a code path I missed in element_listener.dart Created 3 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 unified diff | Download patch
OLDNEW
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 on this form: 5 /// Implements support for Dart VM native method bodies on 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 10 matching lines...) Expand all
21 21
22 /// When parsing a Dart VM library file, we may encounter a native clause 22 /// When parsing a Dart VM library file, we may encounter a native clause
23 /// instead of a function body. This method skips such a clause. 23 /// instead of a function body. This method skips such a clause.
24 /// 24 ///
25 /// This method is designed to be called when encountering 25 /// This method is designed to be called when encountering
26 /// [ErrorKind.ExpectedBlockToSkip] in [Listener.handleUnrecoverableError]. 26 /// [ErrorKind.ExpectedBlockToSkip] in [Listener.handleUnrecoverableError].
27 Token skipNativeClause(Token token) { 27 Token skipNativeClause(Token token) {
28 if (!optional("native", token)) return null; 28 if (!optional("native", token)) return null;
29 token = token.next; 29 token = token.next;
30 if (token.kind != STRING_TOKEN) return null; 30 if (token.kind != STRING_TOKEN) return null;
31 token = token.next; 31 if (!optional(";", token.next)) return null;
32 if (!optional(";", token)) return null;
33 return token; 32 return token;
34 } 33 }
35 34
36 /// When parsing a Dart VM library file, we may encounter native getters like 35 /// When parsing a Dart VM library file, we may encounter native getters like
37 /// 36 ///
38 /// int get length native "List_getLength"; 37 /// int get length native "List_getLength";
39 /// 38 ///
40 /// This will result in [identifiers] being 39 /// This will result in [identifiers] being
41 /// 40 ///
42 /// [";", '"List_getLength"', "native", "length", "get"] 41 /// [";", '"List_getLength"', "native", "length", "get"]
43 /// 42 ///
44 /// We need to remove '"List_getLength"' and "native" from that list. 43 /// We need to remove '"List_getLength"' and "native" from that list.
45 /// 44 ///
46 /// This method designed to be called from [Listener.handleMemberName]. 45 /// This method designed to be called from [Listener.handleMemberName].
47 Link<Token> removeNativeClause(Link<Token> identifiers) { 46 Link<Token> removeNativeClause(Link<Token> identifiers) {
48 Link<Token> result = identifiers.tail; 47 Link<Token> result = identifiers.tail;
49 if (result.head.kind != STRING_TOKEN) return identifiers; 48 if (result.head.kind != STRING_TOKEN) return identifiers;
50 result = result.tail; 49 result = result.tail;
51 if (result.isEmpty) return identifiers; 50 if (result.isEmpty) return identifiers;
52 if (optional('native', result.head)) { 51 if (optional('native', result.head)) {
53 return result.tail.prepend(identifiers.head); 52 return result.tail.prepend(identifiers.head);
54 } 53 }
55 return identifiers; 54 return identifiers;
56 } 55 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | pkg/front_end/lib/src/fasta/parser/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698