OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.parser.partial_elements; | 5 library dart2js.parser.partial_elements; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart' show ParsingContext, Resolution; | 8 import '../common/resolution.dart' show ParsingContext, Resolution; |
9 import '../elements/resolution_types.dart' show ResolutionDynamicType; | 9 import '../elements/resolution_types.dart' show ResolutionDynamicType; |
10 import '../elements/elements.dart' | 10 import '../elements/elements.dart' |
(...skipping 17 matching lines...) Expand all Loading... |
28 MetadataAnnotationX, | 28 MetadataAnnotationX, |
29 MethodElementX, | 29 MethodElementX, |
30 SetterElementX, | 30 SetterElementX, |
31 TypedefElementX, | 31 TypedefElementX, |
32 VariableList; | 32 VariableList; |
33 import '../elements/visitor.dart' show ElementVisitor; | 33 import '../elements/visitor.dart' show ElementVisitor; |
34 import 'package:front_end/src/fasta/scanner.dart' show Token; | 34 import 'package:front_end/src/fasta/scanner.dart' show Token; |
35 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; | 35 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; |
36 import '../tree/tree.dart'; | 36 import '../tree/tree.dart'; |
37 import 'package:front_end/src/fasta/parser.dart' | 37 import 'package:front_end/src/fasta/parser.dart' |
38 show ClassMemberParser, Listener, Parser, ParserError; | 38 show ClassMemberParser, Listener, MemberKind, Parser, ParserError; |
39 import 'member_listener.dart' show MemberListener; | 39 import 'member_listener.dart' show MemberListener; |
40 import 'node_listener.dart' show NodeListener; | 40 import 'node_listener.dart' show NodeListener; |
41 | 41 |
42 class ClassElementParser extends ClassMemberParser { | 42 class ClassElementParser extends ClassMemberParser { |
43 ClassElementParser(Listener listener) : super(listener); | 43 ClassElementParser(Listener listener) : super(listener); |
44 | 44 |
45 Token parseFormalParameters(Token token, {bool inFunctionType: false}) { | 45 Token parseFormalParameters(Token token, MemberKind kind) { |
46 return skipFormalParameters(token); | 46 return skipFormalParameters(token, kind); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 abstract class PartialElement implements DeclarationSite { | 50 abstract class PartialElement implements DeclarationSite { |
51 Token beginToken; | 51 Token beginToken; |
52 Token endToken; | 52 Token endToken; |
53 | 53 |
54 bool hasParseError = false; | 54 bool hasParseError = false; |
55 | 55 |
56 bool get isMalformed => hasParseError; | 56 bool get isMalformed => hasParseError; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 assert(invariant(this, cachedNode != null, | 88 assert(invariant(this, cachedNode != null, |
89 message: "Node has not been computed for $this.")); | 89 message: "Node has not been computed for $this.")); |
90 return cachedNode; | 90 return cachedNode; |
91 } | 91 } |
92 | 92 |
93 FunctionExpression parseNode(ParsingContext parsing) { | 93 FunctionExpression parseNode(ParsingContext parsing) { |
94 if (cachedNode != null) return cachedNode; | 94 if (cachedNode != null) return cachedNode; |
95 parseFunction(Parser p) { | 95 parseFunction(Parser p) { |
96 if (isClassMember && modifiers.isFactory) { | 96 if (isClassMember && modifiers.isFactory) { |
97 p.parseFactoryMethod(beginToken); | 97 p.parseFactoryMethod(beginToken); |
| 98 } else if (isClassMember) { |
| 99 p.parseMember(beginToken); |
98 } else { | 100 } else { |
99 p.parseFunction(beginToken, getOrSet); | 101 p.parseTopLevelMember(beginToken); |
100 } | 102 } |
101 } | 103 } |
102 | 104 |
103 cachedNode = parse(parsing, this, declarationSite, parseFunction); | 105 cachedNode = parse(parsing, this, declarationSite, parseFunction); |
104 return cachedNode; | 106 return cachedNode; |
105 } | 107 } |
106 | 108 |
107 Token get position => _position; | 109 Token get position => _position; |
108 | 110 |
109 void reusePartialFunctionMixin() { | 111 void reusePartialFunctionMixin() { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 } on ParserError catch (e) { | 454 } on ParserError catch (e) { |
453 partial.hasParseError = true; | 455 partial.hasParseError = true; |
454 return new ErrorNode(element.position, e.message); | 456 return new ErrorNode(element.position, e.message); |
455 } | 457 } |
456 Node node = listener.popNode(); | 458 Node node = listener.popNode(); |
457 assert(listener.nodes.isEmpty); | 459 assert(listener.nodes.isEmpty); |
458 return node; | 460 return node; |
459 }); | 461 }); |
460 }); | 462 }); |
461 } | 463 } |
OLD | NEW |