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:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; | 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; |
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; | 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; |
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; | 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 * `native` support. | 51 * `native` support. |
52 */ | 52 */ |
53 Parser parser; | 53 Parser parser; |
54 | 54 |
55 bool parseGenericMethodComments = false; | 55 bool parseGenericMethodComments = false; |
56 | 56 |
57 /// The name of the class currently being parsed, or `null` if no class is | 57 /// The name of the class currently being parsed, or `null` if no class is |
58 /// being parsed. | 58 /// being parsed. |
59 String className; | 59 String className; |
60 | 60 |
| 61 /// If true, this is building a full AST. Otherwise, only create method |
| 62 /// bodies. |
| 63 final bool isFullAst; |
| 64 |
61 AstBuilder(this.errorReporter, this.library, this.member, this.elementStore, | 65 AstBuilder(this.errorReporter, this.library, this.member, this.elementStore, |
62 Scope scope, | 66 Scope scope, this.isFullAst, |
63 [Uri uri]) | 67 [Uri uri]) |
64 : uri = uri ?? library.fileUri, | 68 : uri = uri ?? library.fileUri, |
65 super(scope); | 69 super(scope); |
66 | 70 |
67 createJumpTarget(JumpTargetKind kind, int charOffset) { | 71 createJumpTarget(JumpTargetKind kind, int charOffset) { |
68 // TODO(ahe): Implement jump targets. | 72 // TODO(ahe): Implement jump targets. |
69 return null; | 73 return null; |
70 } | 74 } |
71 | 75 |
72 void beginLiteralString(Token token) { | 76 void beginLiteralString(Token token) { |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 Statement elsePart = popIfNotNull(elseToken); | 400 Statement elsePart = popIfNotNull(elseToken); |
397 Statement thenPart = pop(); | 401 Statement thenPart = pop(); |
398 Expression condition = pop(); | 402 Expression condition = pop(); |
399 analyzer.BeginToken leftParenthesis = ifToken.next; | 403 analyzer.BeginToken leftParenthesis = ifToken.next; |
400 push(ast.ifStatement(ifToken, ifToken.next, condition, | 404 push(ast.ifStatement(ifToken, ifToken.next, condition, |
401 leftParenthesis.endGroup, thenPart, elseToken, elsePart)); | 405 leftParenthesis.endGroup, thenPart, elseToken, elsePart)); |
402 } | 406 } |
403 | 407 |
404 void handleNoInitializers() { | 408 void handleNoInitializers() { |
405 debugEvent("NoInitializers"); | 409 debugEvent("NoInitializers"); |
| 410 if (!isFullAst) return; |
406 push(NullValue.ConstructorInitializerSeparator); | 411 push(NullValue.ConstructorInitializerSeparator); |
407 push(NullValue.ConstructorInitializers); | 412 push(NullValue.ConstructorInitializers); |
408 } | 413 } |
409 | 414 |
410 void endInitializers(int count, Token beginToken, Token endToken) { | 415 void endInitializers(int count, Token beginToken, Token endToken) { |
411 debugEvent("Initializers"); | 416 debugEvent("Initializers"); |
412 List<Object> initializerObjects = popList(count) ?? const []; | 417 List<Object> initializerObjects = popList(count) ?? const []; |
| 418 if (!isFullAst) return; |
413 | 419 |
414 push(beginToken); | 420 push(beginToken); |
415 | 421 |
416 var initializers = <ConstructorInitializer>[]; | 422 var initializers = <ConstructorInitializer>[]; |
417 for (Object initializerObject in initializerObjects) { | 423 for (Object initializerObject in initializerObjects) { |
418 if (initializerObject is FunctionExpressionInvocation) { | 424 if (initializerObject is FunctionExpressionInvocation) { |
419 Expression function = initializerObject.function; | 425 Expression function = initializerObject.function; |
420 if (function is SuperExpression) { | 426 if (function is SuperExpression) { |
421 initializers.add(ast.superConstructorInvocation(function.superKeyword, | 427 initializers.add(ast.superConstructorInvocation(function.superKeyword, |
422 null, null, initializerObject.argumentList)); | 428 null, null, initializerObject.argumentList)); |
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 } else if (identical('var', s)) { | 2021 } else if (identical('var', s)) { |
2016 finalConstOrVarKeyword = token; | 2022 finalConstOrVarKeyword = token; |
2017 } else if (identical('covariant', s)) { | 2023 } else if (identical('covariant', s)) { |
2018 covariantKeyword = token; | 2024 covariantKeyword = token; |
2019 } else { | 2025 } else { |
2020 internalError('Unhandled modifier: $s'); | 2026 internalError('Unhandled modifier: $s'); |
2021 } | 2027 } |
2022 } | 2028 } |
2023 } | 2029 } |
2024 } | 2030 } |
OLD | NEW |