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.node_listener; | 5 library dart2js.parser.node_listener; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../elements/elements.dart' show CompilationUnitElement; | 8 import '../elements/elements.dart' show CompilationUnitElement; |
9 import '../native/native.dart' as native; | 9 import '../native/native.dart' as native; |
10 import '../tokens/precedence_constants.dart' as Precedence show INDEX_INFO; | 10 import '../tokens/precedence_constants.dart' as Precedence show INDEX_INFO; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 258 } |
259 | 259 |
260 void beginCascade(Token token) { | 260 void beginCascade(Token token) { |
261 pushNode(new CascadeReceiver(popNode(), token)); | 261 pushNode(new CascadeReceiver(popNode(), token)); |
262 } | 262 } |
263 | 263 |
264 void endCascade() { | 264 void endCascade() { |
265 pushNode(new Cascade(popNode())); | 265 pushNode(new Cascade(popNode())); |
266 } | 266 } |
267 | 267 |
268 void handleAsOperator(Token operathor, Token endToken) { | 268 void handleAsOperator(Token operator, Token endToken) { |
269 TypeAnnotation type = popNode(); | 269 TypeAnnotation type = popNode(); |
270 Expression expression = popNode(); | 270 Expression expression = popNode(); |
271 NodeList arguments = new NodeList.singleton(type); | 271 NodeList arguments = new NodeList.singleton(type); |
272 pushNode(new Send(expression, new Operator(operathor), arguments)); | 272 pushNode(new Send(expression, new Operator(operator), arguments)); |
273 } | 273 } |
274 | 274 |
275 void handleAssignmentExpression(Token token) { | 275 void handleAssignmentExpression(Token token) { |
276 Node arg = popNode(); | 276 Node arg = popNode(); |
277 Node node = popNode(); | 277 Node node = popNode(); |
278 Send send = node.asSend(); | 278 Send send = node.asSend(); |
279 if (send == null || !(send.isPropertyAccess || send.isIndex)) { | 279 if (send == null || !(send.isPropertyAccess || send.isIndex)) { |
280 reportNotAssignable(node); | 280 reportNotAssignable(node); |
281 } | 281 } |
282 if (send.asSendSet() != null) internalError(node: send); | 282 if (send.asSendSet() != null) internalError(node: send); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 | 752 |
753 void endUnnamedFunction(Token token) { | 753 void endUnnamedFunction(Token token) { |
754 Statement body = popNode(); | 754 Statement body = popNode(); |
755 AsyncModifier asyncModifier = popNode(); | 755 AsyncModifier asyncModifier = popNode(); |
756 NodeList formals = popNode(); | 756 NodeList formals = popNode(); |
757 NodeList typeVariables = popNode(); | 757 NodeList typeVariables = popNode(); |
758 pushNode(new FunctionExpression(null, typeVariables, formals, body, null, | 758 pushNode(new FunctionExpression(null, typeVariables, formals, body, null, |
759 Modifiers.EMPTY, null, null, asyncModifier)); | 759 Modifiers.EMPTY, null, null, asyncModifier)); |
760 } | 760 } |
761 | 761 |
762 void handleIsOperator(Token operathor, Token not, Token endToken) { | 762 void handleIsOperator(Token operator, Token not, Token endToken) { |
763 TypeAnnotation type = popNode(); | 763 TypeAnnotation type = popNode(); |
764 Expression expression = popNode(); | 764 Expression expression = popNode(); |
765 Node argument; | 765 Node argument; |
766 if (not != null) { | 766 if (not != null) { |
767 argument = new Send.prefix(type, new Operator(not)); | 767 argument = new Send.prefix(type, new Operator(not)); |
768 } else { | 768 } else { |
769 argument = type; | 769 argument = type; |
770 } | 770 } |
771 | 771 |
772 NodeList arguments = new NodeList.singleton(argument); | 772 NodeList arguments = new NodeList.singleton(argument); |
773 pushNode(new Send(expression, new Operator(operathor), arguments)); | 773 pushNode(new Send(expression, new Operator(operator), arguments)); |
774 } | 774 } |
775 | 775 |
776 void handleLabel(Token colon) { | 776 void handleLabel(Token colon) { |
777 Identifier name = popNode(); | 777 Identifier name = popNode(); |
778 pushNode(new Label(name, colon)); | 778 pushNode(new Label(name, colon)); |
779 } | 779 } |
780 | 780 |
781 void endLabeledStatement(int labelCount) { | 781 void endLabeledStatement(int labelCount) { |
782 Statement statement = popNode(); | 782 Statement statement = popNode(); |
783 NodeList labels = makeNodeList(labelCount, null, null, null); | 783 NodeList labels = makeNodeList(labelCount, null, null, null); |
784 pushNode(new LabeledStatement(labels, statement)); | 784 pushNode(new LabeledStatement(labels, statement)); |
785 } | 785 } |
786 | 786 |
787 void log(message) { | 787 void log(message) { |
788 reporter.log(message); | 788 reporter.log(message); |
789 } | 789 } |
790 | 790 |
791 void internalError({Token token, Node node}) { | 791 void internalError({Token token, Node node}) { |
792 // TODO(ahe): This should call reporter.internalError. | 792 // TODO(ahe): This should call reporter.internalError. |
793 Spannable spannable = (token == null) ? node : token; | 793 Spannable spannable = (token == null) ? node : token; |
794 throw new SpannableAssertionFailure(spannable, 'Internal error in parser.'); | 794 throw new SpannableAssertionFailure(spannable, 'Internal error in parser.'); |
795 } | 795 } |
796 } | 796 } |
OLD | NEW |