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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2877253003: Don't type promote local functions. (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.body_builder; 5 library fasta.body_builder;
6 6
7 import '../fasta_codes.dart' 7 import '../fasta_codes.dart'
8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody;
9 9
10 import '../parser/parser.dart' show FormalParameterType, optional; 10 import '../parser/parser.dart' show FormalParameterType, optional;
11 11
12 import '../parser/identifier_context.dart' show IdentifierContext; 12 import '../parser/identifier_context.dart' show IdentifierContext;
13 13
14 import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory; 14 import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory;
15 15
16 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 16 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
17 show KernelArguments, KernelField; 17 show KernelArguments, KernelField, KernelFunctionDeclaration;
18 18
19 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; 19 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken;
20 20
21 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart' 21 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'
22 show FieldNode; 22 show FieldNode;
23 23
24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' 24 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'
25 show TypeInferrer; 25 show TypeInferrer;
26 26
27 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' 27 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'
(...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 Identifier identifier = pop(); 2035 Identifier identifier = pop();
2036 push(new NamedExpression(identifier.name, value)); 2036 push(new NamedExpression(identifier.name, value));
2037 } 2037 }
2038 2038
2039 @override 2039 @override
2040 void endFunctionName(Token beginToken, Token token) { 2040 void endFunctionName(Token beginToken, Token token) {
2041 debugEvent("FunctionName"); 2041 debugEvent("FunctionName");
2042 Identifier name = pop(); 2042 Identifier name = pop();
2043 VariableDeclaration variable = astFactory.variableDeclaration( 2043 VariableDeclaration variable = astFactory.variableDeclaration(
2044 name.name, name.token, functionNestingLevel, 2044 name.name, name.token, functionNestingLevel,
2045 isFinal: true); 2045 isFinal: true, isLocalFunction: true);
2046 push(new FunctionDeclaration( 2046 push(new KernelFunctionDeclaration(
2047 variable, new FunctionNode(new InvalidStatement())) 2047 variable, new FunctionNode(new InvalidStatement()))
2048 ..fileOffset = beginToken.charOffset); 2048 ..fileOffset = beginToken.charOffset);
2049 scope[variable.name] = new KernelVariableBuilder( 2049 scope[variable.name] = new KernelVariableBuilder(
2050 variable, member ?? classBuilder ?? library, uri); 2050 variable, member ?? classBuilder ?? library, uri);
2051 enterLocalScope(); 2051 enterLocalScope();
2052 } 2052 }
2053 2053
2054 void enterFunction() { 2054 void enterFunction() {
2055 debugEvent("enterFunction"); 2055 debugEvent("enterFunction");
2056 functionNestingLevel++; 2056 functionNestingLevel++;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 ..fileEndOffset = endToken.charOffset)); 2095 ..fileEndOffset = endToken.charOffset));
2096 } 2096 }
2097 2097
2098 @override 2098 @override
2099 void endFunctionDeclaration(Token token) { 2099 void endFunctionDeclaration(Token token) {
2100 debugEvent("FunctionDeclaration"); 2100 debugEvent("FunctionDeclaration");
2101 FunctionNode function = pop(); 2101 FunctionNode function = pop();
2102 exitLocalScope(); 2102 exitLocalScope();
2103 FunctionDeclaration declaration = pop(); 2103 FunctionDeclaration declaration = pop();
2104 function.returnType = pop() ?? const DynamicType(); 2104 function.returnType = pop() ?? const DynamicType();
2105 declaration.variable.type = function.functionType;
2105 pop(); // Modifiers. 2106 pop(); // Modifiers.
2106 exitFunction(); 2107 exitFunction();
2107 declaration.function = function; 2108 declaration.function = function;
2108 function.parent = declaration; 2109 function.parent = declaration;
2109 push(declaration); 2110 push(declaration);
2110 } 2111 }
2111 2112
2112 @override 2113 @override
2113 void endUnnamedFunction(Token beginToken, Token token) { 2114 void endUnnamedFunction(Token beginToken, Token token) {
2114 debugEvent("UnnamedFunction"); 2115 debugEvent("UnnamedFunction");
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 } else if (node is PrefixBuilder) { 3132 } else if (node is PrefixBuilder) {
3132 return node.name; 3133 return node.name;
3133 } else if (node is ThisAccessor) { 3134 } else if (node is ThisAccessor) {
3134 return node.isSuper ? "super" : "this"; 3135 return node.isSuper ? "super" : "this";
3135 } else if (node is FastaAccessor) { 3136 } else if (node is FastaAccessor) {
3136 return node.plainNameForRead; 3137 return node.plainNameForRead;
3137 } else { 3138 } else {
3138 return internalError("Unhandled: ${node.runtimeType}"); 3139 return internalError("Unhandled: ${node.runtimeType}");
3139 } 3140 }
3140 } 3141 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/builder/ast_factory.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698