Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2899073004: Use declared return type for inference of return and yield statements. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 import 'package:front_end/src/fasta/source/scope_listener.dart' 28 import 'package:front_end/src/fasta/source/scope_listener.dart'
29 show JumpTargetKind, NullValue, ScopeListener; 29 show JumpTargetKind, NullValue, ScopeListener;
30 import 'analyzer.dart' show toKernel; 30 import 'analyzer.dart' show toKernel;
31 import 'element_store.dart' 31 import 'element_store.dart'
32 show 32 show
33 AnalyzerLocalVariableElemment, 33 AnalyzerLocalVariableElemment,
34 AnalyzerParameterElement, 34 AnalyzerParameterElement,
35 ElementStore, 35 ElementStore,
36 KernelClassElement; 36 KernelClassElement;
37 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; 37 import 'package:analyzer/src/dart/error/syntactic_errors.dart';
38 import 'package:kernel/ast.dart' show FunctionNode;
38 import 'token_utils.dart' show toAnalyzerToken, toAnalyzerCommentToken; 39 import 'token_utils.dart' show toAnalyzerToken, toAnalyzerCommentToken;
39 40
40 class AstBuilder extends ScopeListener { 41 class AstBuilder extends ScopeListener {
41 final AstFactory ast = standard.astFactory; 42 final AstFactory ast = standard.astFactory;
42 43
43 final ErrorReporter errorReporter; 44 final ErrorReporter errorReporter;
44 final KernelLibraryBuilder library; 45 final KernelLibraryBuilder library;
45 final Builder member; 46 final Builder member;
46 final ElementStore elementStore; 47 final ElementStore elementStore;
47 48
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (beginToken != null) { 286 if (beginToken != null) {
286 exitLocalScope(); 287 exitLocalScope();
287 } 288 }
288 Block block = ast.block( 289 Block block = ast.block(
289 toAnalyzerToken(beginToken), statements, toAnalyzerToken(endToken)); 290 toAnalyzerToken(beginToken), statements, toAnalyzerToken(endToken));
290 analyzer.Token star = pop(); 291 analyzer.Token star = pop();
291 analyzer.Token asyncKeyword = pop(); 292 analyzer.Token asyncKeyword = pop();
292 push(ast.blockFunctionBody(asyncKeyword, star, block)); 293 push(ast.blockFunctionBody(asyncKeyword, star, block));
293 } 294 }
294 295
295 void finishFunction(formals, asyncModifier, FunctionBody body) { 296 void finishFunction(
297 FunctionNode function, formals, asyncModifier, FunctionBody body) {
296 debugEvent("finishFunction"); 298 debugEvent("finishFunction");
297 Statement bodyStatement; 299 Statement bodyStatement;
298 if (body is EmptyFunctionBody) { 300 if (body is EmptyFunctionBody) {
299 bodyStatement = ast.emptyStatement(body.semicolon); 301 bodyStatement = ast.emptyStatement(body.semicolon);
300 } else if (body is ExpressionFunctionBody) { 302 } else if (body is ExpressionFunctionBody) {
301 bodyStatement = ast.returnStatement(null, body.expression, null); 303 bodyStatement = ast.returnStatement(null, body.expression, null);
302 } else { 304 } else {
303 bodyStatement = (body as BlockFunctionBody).block; 305 bodyStatement = (body as BlockFunctionBody).block;
304 } 306 }
305 var kernel = toKernel(bodyStatement, elementStore, library.library, scope); 307 var kernel = toKernel(bodyStatement, elementStore, library.library, scope);
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 } else if (identical('var', s)) { 2102 } else if (identical('var', s)) {
2101 finalConstOrVarKeyword = token; 2103 finalConstOrVarKeyword = token;
2102 } else if (identical('covariant', s)) { 2104 } else if (identical('covariant', s)) {
2103 covariantKeyword = token; 2105 covariantKeyword = token;
2104 } else { 2106 } else {
2105 internalError('Unhandled modifier: $s'); 2107 internalError('Unhandled modifier: $s');
2106 } 2108 }
2107 } 2109 }
2108 } 2110 }
2109 } 2111 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | pkg/front_end/lib/src/fasta/builder/procedure_builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698