Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.analyzer.ast_builder; | 5 library fasta.analyzer.ast_builder; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/scanner/token.dart' | 7 import 'package:front_end/src/fasta/scanner/token.dart' |
| 8 show BeginGroupToken, Token; | 8 show BeginGroupToken, Token; |
| 9 | 9 |
| 10 import 'package:analyzer/analyzer.dart'; | 10 import 'package:analyzer/analyzer.dart'; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 for (int i = identifierCount - 1; i >= 0; i--) { | 450 for (int i = identifierCount - 1; i >= 0; i--) { |
| 451 SimpleIdentifier identifier = pop(); | 451 SimpleIdentifier identifier = pop(); |
| 452 components[i] = identifier.token; | 452 components[i] = identifier.token; |
| 453 } | 453 } |
| 454 push(ast.symbolLiteral(toAnalyzerToken(hashToken), components)); | 454 push(ast.symbolLiteral(toAnalyzerToken(hashToken), components)); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void endType(Token beginToken, Token endToken) { | 457 void endType(Token beginToken, Token endToken) { |
| 458 debugEvent("Type"); | 458 debugEvent("Type"); |
| 459 TypeArgumentList arguments = pop(); | 459 TypeArgumentList arguments = pop(); |
| 460 SimpleIdentifier name = pop(); | 460 Identifier name = pop(); |
| 461 // TODO(paulberry,ahe): what if the type doesn't resolve to a class | |
| 462 // element? | |
|
ahe
2017/02/22 11:42:08
We should try to share this method with BodyBuilde
Paul Berry
2017/02/22 16:34:53
Acknowledged.
| |
| 461 KernelClassElement cls = name.staticElement; | 463 KernelClassElement cls = name.staticElement; |
| 462 if (cls == null) { | 464 if (cls == null) { |
| 465 // TODO(paulberry): This is a kludge. Ideally we should already have | |
| 466 // set the static element at the time that handleIdentifier was called. | |
|
ahe
2017/02/22 11:42:08
For inspiration (or code sharing) take a look at B
Paul Berry
2017/02/22 16:34:53
Acknowledged.
| |
| 463 Builder builder = scope.lookup(name.name, beginToken.charOffset, uri); | 467 Builder builder = scope.lookup(name.name, beginToken.charOffset, uri); |
| 464 if (builder == null) { | 468 if (builder == null) { |
| 465 internalError("Undefined name: $name"); | 469 internalError("Undefined name: $name"); |
| 466 } | 470 } |
| 467 // TODO(paulberry,ahe): what if the type doesn't resolve to a class | |
| 468 // element? | |
| 469 cls = elementStore[builder]; | 471 cls = elementStore[builder]; |
| 470 assert(cls != null); | 472 assert(cls != null); |
| 471 name.staticElement = cls; | 473 if (name is SimpleIdentifier) { |
| 474 name.staticElement = cls; | |
| 475 } | |
| 472 } | 476 } |
| 473 push(ast.typeName(name, arguments)..type = cls.rawType); | 477 push(ast.typeName(name, arguments)..type = cls.rawType); |
| 474 } | 478 } |
| 475 | 479 |
| 476 void handleAsOperator(Token operator, Token endToken) { | 480 void handleAsOperator(Token operator, Token endToken) { |
| 477 debugEvent("AsOperator"); | 481 debugEvent("AsOperator"); |
| 478 TypeName type = pop(); | 482 TypeName type = pop(); |
| 479 Expression expression = pop(); | 483 Expression expression = pop(); |
| 480 push(ast.asExpression(expression, toAnalyzerToken(operator), type)); | 484 push(ast.asExpression(expression, toAnalyzerToken(operator), type)); |
| 481 } | 485 } |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 List<Annotation> metadata = pop(); | 936 List<Annotation> metadata = pop(); |
| 933 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | 937 // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
| 934 Comment comment = null; | 938 Comment comment = null; |
| 935 push(ast.libraryDirective(comment, metadata, | 939 push(ast.libraryDirective(comment, metadata, |
| 936 toAnalyzerToken(libraryKeyword), name, toAnalyzerToken(semicolon))); | 940 toAnalyzerToken(libraryKeyword), name, toAnalyzerToken(semicolon))); |
| 937 accumulateIdentifierComponents = false; | 941 accumulateIdentifierComponents = false; |
| 938 } | 942 } |
| 939 | 943 |
| 940 @override | 944 @override |
| 941 void handleQualified(Token period) { | 945 void handleQualified(Token period) { |
| 946 SimpleIdentifier identifier = pop(); | |
| 942 if (accumulateIdentifierComponents) { | 947 if (accumulateIdentifierComponents) { |
| 943 SimpleIdentifier identifier = pop(); | |
| 944 List<SimpleIdentifier> list = pop(); | 948 List<SimpleIdentifier> list = pop(); |
| 945 list.add(identifier); | 949 list.add(identifier); |
| 946 push(list); | 950 push(list); |
| 947 } else { | 951 } else { |
| 948 // TODO(paulberry): implement. | 952 var prefix = pop(); |
| 949 logEvent('Qualified'); | 953 if (prefix is SimpleIdentifier) { |
| 954 // TODO(paulberry): resolve [identifier]. | |
|
ahe
2017/02/22 11:42:08
I'm using SendAccessor to handle this in BodyBuild
Paul Berry
2017/02/22 16:34:53
Acknowledged.
| |
| 955 push(ast.prefixedIdentifier(prefix, toAnalyzerToken(period), identifier) ); | |
|
ahe
2017/02/22 11:42:08
Long line.
Paul Berry
2017/02/22 16:34:53
Thanks. Konstantin fixed this in https://coderevi
| |
| 956 } else { | |
| 957 // TODO(paulberry): implement. | |
| 958 logEvent('Qualified with >1 dot'); | |
| 959 } | |
| 950 } | 960 } |
| 951 } | 961 } |
| 952 | 962 |
| 953 @override | 963 @override |
| 954 void endPart(Token partKeyword, Token semicolon) { | 964 void endPart(Token partKeyword, Token semicolon) { |
| 955 debugEvent("Part"); | 965 debugEvent("Part"); |
| 956 StringLiteral uri = pop(); | 966 StringLiteral uri = pop(); |
| 957 List<Annotation> metadata = pop(); | 967 List<Annotation> metadata = pop(); |
| 958 // TODO(paulberry): capture doc comments. See dartbug.com/28851. | 968 // TODO(paulberry): capture doc comments. See dartbug.com/28851. |
| 959 Comment comment = null; | 969 Comment comment = null; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1159 /// [ClassDeclaration] or [ClassTypeAlias] object. | 1169 /// [ClassDeclaration] or [ClassTypeAlias] object. |
| 1160 class _MixinApplication { | 1170 class _MixinApplication { |
| 1161 final TypeName supertype; | 1171 final TypeName supertype; |
| 1162 | 1172 |
| 1163 final Token withKeyword; | 1173 final Token withKeyword; |
| 1164 | 1174 |
| 1165 final List<TypeName> mixinTypes; | 1175 final List<TypeName> mixinTypes; |
| 1166 | 1176 |
| 1167 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); | 1177 _MixinApplication(this.supertype, this.withKeyword, this.mixinTypes); |
| 1168 } | 1178 } |
| OLD | NEW |