| 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 11 matching lines...) Expand all Loading... |
| 22 void addLibraryTag(LibraryTag tag) { | 22 void addLibraryTag(LibraryTag tag) { |
| 23 pushNode(tag); | 23 pushNode(tag); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void addPartOfTag(PartOf tag) { | 26 void addPartOfTag(PartOf tag) { |
| 27 pushNode(tag); | 27 pushNode(tag); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void endLibraryName(Token libraryKeyword, Token semicolon) { | 30 void endLibraryName(Token libraryKeyword, Token semicolon) { |
| 31 Expression name = popNode(); | 31 Expression name = popNode(); |
| 32 pushNode(new LibraryName(libraryKeyword, name, | 32 pushNode(new LibraryName( |
| 33 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation | 33 libraryKeyword, |
| 34 // (element) instead of Metatada (node). | 34 name, |
| 35 null)); | 35 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
| 36 // (element) instead of Metatada (node). |
| 37 null)); |
| 36 } | 38 } |
| 37 | 39 |
| 38 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, | 40 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, |
| 39 Token semicolon) { | 41 Token semicolon) { |
| 40 NodeList combinators = popNode(); | 42 NodeList combinators = popNode(); |
| 41 Identifier prefix = asKeyword != null ? popNode() : null; | 43 Identifier prefix = asKeyword != null ? popNode() : null; |
| 42 NodeList conditionalUris = popNode(); | 44 NodeList conditionalUris = popNode(); |
| 43 StringNode uri = popLiteralString(); | 45 StringNode uri = popLiteralString(); |
| 44 pushNode(new Import(importKeyword, uri, conditionalUris, prefix, | 46 pushNode(new Import( |
| 45 combinators, | 47 importKeyword, |
| 46 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation | 48 uri, |
| 47 // (element) instead of Metatada (node). | 49 conditionalUris, |
| 48 null, isDeferred: deferredKeyword != null)); | 50 prefix, |
| 51 combinators, |
| 52 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
| 53 // (element) instead of Metatada (node). |
| 54 null, |
| 55 isDeferred: deferredKeyword != null)); |
| 49 } | 56 } |
| 50 | 57 |
| 51 void endExport(Token exportKeyword, Token semicolon) { | 58 void endExport(Token exportKeyword, Token semicolon) { |
| 52 NodeList combinators = popNode(); | 59 NodeList combinators = popNode(); |
| 53 NodeList conditionalUris = popNode(); | 60 NodeList conditionalUris = popNode(); |
| 54 StringNode uri = popLiteralString(); | 61 StringNode uri = popLiteralString(); |
| 55 pushNode(new Export(exportKeyword, uri, conditionalUris, combinators, | 62 pushNode(new Export( |
| 56 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation | 63 exportKeyword, |
| 57 // (element) instead of Metatada (node). | 64 uri, |
| 58 null)); | 65 conditionalUris, |
| 66 combinators, |
| 67 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
| 68 // (element) instead of Metatada (node). |
| 69 null)); |
| 59 } | 70 } |
| 60 | 71 |
| 61 void endPart(Token partKeyword, Token semicolon) { | 72 void endPart(Token partKeyword, Token semicolon) { |
| 62 StringNode uri = popLiteralString(); | 73 StringNode uri = popLiteralString(); |
| 63 pushNode(new Part(partKeyword, uri, | 74 pushNode(new Part( |
| 64 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation | 75 partKeyword, |
| 65 // (element) instead of Metatada (node). | 76 uri, |
| 66 null)); | 77 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
| 78 // (element) instead of Metatada (node). |
| 79 null)); |
| 67 } | 80 } |
| 68 | 81 |
| 69 void endPartOf(Token partKeyword, Token semicolon) { | 82 void endPartOf(Token partKeyword, Token semicolon) { |
| 70 Expression name = popNode(); // name | 83 Expression name = popNode(); // name |
| 71 pushNode(new PartOf(partKeyword, name, | 84 pushNode(new PartOf( |
| 72 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation | 85 partKeyword, |
| 73 // (element) instead of Metatada (node). | 86 name, |
| 74 null)); | 87 // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
| 88 // (element) instead of Metatada (node). |
| 89 null)); |
| 75 } | 90 } |
| 76 | 91 |
| 77 void endClassDeclaration(int interfacesCount, Token beginToken, | 92 void endClassDeclaration(int interfacesCount, Token beginToken, |
| 78 Token extendsKeyword, Token implementsKeyword, Token endToken) { | 93 Token extendsKeyword, Token implementsKeyword, Token endToken) { |
| 79 NodeList body = popNode(); | 94 NodeList body = popNode(); |
| 80 NodeList interfaces = | 95 NodeList interfaces = |
| 81 makeNodeList(interfacesCount, implementsKeyword, null, ","); | 96 makeNodeList(interfacesCount, implementsKeyword, null, ","); |
| 82 Node supertype = popNode(); | 97 Node supertype = popNode(); |
| 83 NodeList typeParameters = popNode(); | 98 NodeList typeParameters = popNode(); |
| 84 Identifier name = popNode(); | 99 Identifier name = popNode(); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 void handleConditionalExpression(Token question, Token colon) { | 373 void handleConditionalExpression(Token question, Token colon) { |
| 359 Node elseExpression = popNode(); | 374 Node elseExpression = popNode(); |
| 360 Node thenExpression = popNode(); | 375 Node thenExpression = popNode(); |
| 361 Node condition = popNode(); | 376 Node condition = popNode(); |
| 362 pushNode(new Conditional( | 377 pushNode(new Conditional( |
| 363 condition, thenExpression, elseExpression, question, colon)); | 378 condition, thenExpression, elseExpression, question, colon)); |
| 364 } | 379 } |
| 365 | 380 |
| 366 void endSend(Token token) { | 381 void endSend(Token token) { |
| 367 NodeList arguments = popNode(); | 382 NodeList arguments = popNode(); |
| 368 popNode(); // typeArguments | 383 NodeList typeArguments = popNode(); |
| 369 Node selector = popNode(); | 384 Node selector = popNode(); |
| 370 // TODO(ahe): Handle receiver. | 385 // TODO(ahe): Handle receiver. |
| 371 pushNode(new Send(null, selector, arguments)); | 386 pushNode(new Send(null, selector, arguments, typeArguments)); |
| 372 } | 387 } |
| 373 | 388 |
| 374 void endFunctionBody(int count, Token beginToken, Token endToken) { | 389 void endFunctionBody(int count, Token beginToken, Token endToken) { |
| 375 if (count == 0 && beginToken == null) { | 390 if (count == 0 && beginToken == null) { |
| 376 pushNode(new EmptyStatement(endToken)); | 391 pushNode(new EmptyStatement(endToken)); |
| 377 } else { | 392 } else { |
| 378 pushNode(new Block(makeNodeList(count, beginToken, endToken, null))); | 393 pushNode(new Block(makeNodeList(count, beginToken, endToken, null))); |
| 379 } | 394 } |
| 380 } | 395 } |
| 381 | 396 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 void log(message) { | 864 void log(message) { |
| 850 reporter.log(message); | 865 reporter.log(message); |
| 851 } | 866 } |
| 852 | 867 |
| 853 void internalError({Token token, Node node}) { | 868 void internalError({Token token, Node node}) { |
| 854 // TODO(ahe): This should call reporter.internalError. | 869 // TODO(ahe): This should call reporter.internalError. |
| 855 Spannable spannable = (token == null) ? node : token; | 870 Spannable spannable = (token == null) ? node : token; |
| 856 throw new SpannableAssertionFailure(spannable, 'Internal error in parser.'); | 871 throw new SpannableAssertionFailure(spannable, 'Internal error in parser.'); |
| 857 } | 872 } |
| 858 } | 873 } |
| OLD | NEW |