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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 61 /// If true, this is building a full AST. Otherwise, only create method |
62 /// bodies. | 62 /// bodies. |
63 final bool isFullAst; | 63 final bool isFullAst; |
64 | 64 |
| 65 final bool generateKernel; |
| 66 |
65 AstBuilder(this.errorReporter, this.library, this.member, this.elementStore, | 67 AstBuilder(this.errorReporter, this.library, this.member, this.elementStore, |
66 Scope scope, this.isFullAst, | 68 Scope scope, this.isFullAst, this.generateKernel, |
67 [Uri uri]) | 69 [Uri uri]) |
68 : uri = uri ?? library.fileUri, | 70 : uri = uri ?? library.fileUri, |
69 super(scope); | 71 super(scope); |
70 | 72 |
71 createJumpTarget(JumpTargetKind kind, int charOffset) { | 73 createJumpTarget(JumpTargetKind kind, int charOffset) { |
72 // TODO(ahe): Implement jump targets. | 74 // TODO(ahe): Implement jump targets. |
73 return null; | 75 return null; |
74 } | 76 } |
75 | 77 |
76 void beginLiteralString(Token token) { | 78 void beginLiteralString(Token token) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 void finishFunction(annotations, formals, asyncModifier, FunctionBody body) { | 293 void finishFunction(annotations, formals, asyncModifier, FunctionBody body) { |
292 debugEvent("finishFunction"); | 294 debugEvent("finishFunction"); |
293 Statement bodyStatement; | 295 Statement bodyStatement; |
294 if (body is EmptyFunctionBody) { | 296 if (body is EmptyFunctionBody) { |
295 bodyStatement = ast.emptyStatement(body.semicolon); | 297 bodyStatement = ast.emptyStatement(body.semicolon); |
296 } else if (body is ExpressionFunctionBody) { | 298 } else if (body is ExpressionFunctionBody) { |
297 bodyStatement = ast.returnStatement(null, body.expression, null); | 299 bodyStatement = ast.returnStatement(null, body.expression, null); |
298 } else { | 300 } else { |
299 bodyStatement = (body as BlockFunctionBody).block; | 301 bodyStatement = (body as BlockFunctionBody).block; |
300 } | 302 } |
301 var kernel = toKernel(bodyStatement, elementStore, library.library, scope); | 303 if (generateKernel) { |
302 if (member is ProcedureBuilder) { | 304 var kernel = |
303 ProcedureBuilder builder = member; | 305 toKernel(bodyStatement, elementStore, library.library, scope); |
304 builder.body = kernel; | 306 if (member is ProcedureBuilder) { |
305 } else { | 307 ProcedureBuilder builder = member; |
306 unexpected("procedure", "${member.runtimeType}", member.charOffset, uri); | 308 builder.body = kernel; |
| 309 } else { |
| 310 unexpected( |
| 311 "procedure", "${member.runtimeType}", member.charOffset, uri); |
| 312 } |
307 } | 313 } |
308 } | 314 } |
309 | 315 |
310 void beginCascade(Token token) { | 316 void beginCascade(Token token) { |
311 debugEvent("beginCascade"); | 317 debugEvent("beginCascade"); |
312 Expression expression = pop(); | 318 Expression expression = pop(); |
313 push(token); | 319 push(token); |
314 if (expression is CascadeExpression) { | 320 if (expression is CascadeExpression) { |
315 push(expression); | 321 push(expression); |
316 } else { | 322 } else { |
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 } else if (identical('var', s)) { | 2027 } else if (identical('var', s)) { |
2022 finalConstOrVarKeyword = token; | 2028 finalConstOrVarKeyword = token; |
2023 } else if (identical('covariant', s)) { | 2029 } else if (identical('covariant', s)) { |
2024 covariantKeyword = token; | 2030 covariantKeyword = token; |
2025 } else { | 2031 } else { |
2026 unhandled("$s", "modifier", token.charOffset, null); | 2032 unhandled("$s", "modifier", token.charOffset, null); |
2027 } | 2033 } |
2028 } | 2034 } |
2029 } | 2035 } |
2030 } | 2036 } |
OLD | NEW |