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

Side by Side Diff: pkg/compiler/lib/src/kernel/kernel_visitor.dart

Issue 2934333002: More dart2js strong mode cleanup. (Closed)
Patch Set: Created 3 years, 6 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 import 'package:kernel/frontend/accessors.dart' 6 import 'package:kernel/frontend/accessors.dart'
7 show 7 show
8 Accessor, 8 Accessor,
9 IndexAccessor, 9 IndexAccessor,
10 NullAwarePropertyAccessor, 10 NullAwarePropertyAccessor,
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 if (kernel.hasHierarchyProblem(constructor.enclosingClass)) { 1486 if (kernel.hasHierarchyProblem(constructor.enclosingClass)) {
1487 constructorInitializers.add(new ir.InvalidInitializer()); 1487 constructorInitializers.add(new ir.InvalidInitializer());
1488 } else if (constructor.isSynthesized) { 1488 } else if (constructor.isSynthesized) {
1489 List<ir.Expression> arguments = const <ir.Expression>[]; 1489 List<ir.Expression> arguments = const <ir.Expression>[];
1490 List<ir.NamedExpression> named = const <ir.NamedExpression>[]; 1490 List<ir.NamedExpression> named = const <ir.NamedExpression>[];
1491 FunctionSignature signature = constructor.functionSignature; 1491 FunctionSignature signature = constructor.functionSignature;
1492 if (signature.parameterCount != 0) { 1492 if (signature.parameterCount != 0) {
1493 // Mixin application implicit super call. 1493 // Mixin application implicit super call.
1494 arguments = <ir.Expression>[]; 1494 arguments = <ir.Expression>[];
1495 named = <ir.NamedExpression>[]; 1495 named = <ir.NamedExpression>[];
1496 signature.orderedForEachParameter((ParameterElement parameter) { 1496 signature.orderedForEachParameter((_parameter) {
1497 ParameterElement parameter = _parameter;
1497 ir.VariableGet argument = buildLocalGet(parameter); 1498 ir.VariableGet argument = buildLocalGet(parameter);
1498 if (parameter.isNamed) { 1499 if (parameter.isNamed) {
1499 named.add(new ir.NamedExpression(parameter.name, argument)); 1500 named.add(new ir.NamedExpression(parameter.name, argument));
1500 } else { 1501 } else {
1501 arguments.add(argument); 1502 arguments.add(argument);
1502 } 1503 }
1503 }); 1504 });
1504 } 1505 }
1505 if (kernel.isSyntheticError(constructor.definingConstructor)) { 1506 if (kernel.isSyntheticError(constructor.definingConstructor)) {
1506 constructorInitializers.add(new ir.InvalidInitializer()); 1507 constructorInitializers.add(new ir.InvalidInitializer());
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 ir.FunctionNode buildFunctionNode(FunctionElement function, Node bodyNode) { 2106 ir.FunctionNode buildFunctionNode(FunctionElement function, Node bodyNode) {
2106 List<ir.TypeParameter> typeParameters = <ir.TypeParameter>[]; 2107 List<ir.TypeParameter> typeParameters = <ir.TypeParameter>[];
2107 List<ir.VariableDeclaration> positionalParameters = 2108 List<ir.VariableDeclaration> positionalParameters =
2108 <ir.VariableDeclaration>[]; 2109 <ir.VariableDeclaration>[];
2109 List<ir.VariableDeclaration> namedParameters = <ir.VariableDeclaration>[]; 2110 List<ir.VariableDeclaration> namedParameters = <ir.VariableDeclaration>[];
2110 int requiredParameterCount = 0; 2111 int requiredParameterCount = 0;
2111 ir.DartType returnType = const ir.DynamicType(); 2112 ir.DartType returnType = const ir.DynamicType();
2112 if (function.hasFunctionSignature) { 2113 if (function.hasFunctionSignature) {
2113 FunctionSignature signature = function.functionSignature; 2114 FunctionSignature signature = function.functionSignature;
2114 requiredParameterCount = signature.requiredParameterCount; 2115 requiredParameterCount = signature.requiredParameterCount;
2115 signature.forEachParameter((ParameterElement parameter) { 2116 signature.forEachParameter((_parameter) {
2117 ParameterElement parameter = _parameter;
2116 ir.VariableDeclaration variable = getLocal(parameter); 2118 ir.VariableDeclaration variable = getLocal(parameter);
2117 if (parameter.isNamed) { 2119 if (parameter.isNamed) {
2118 namedParameters.add(variable); 2120 namedParameters.add(variable);
2119 } else { 2121 } else {
2120 positionalParameters.add(variable); 2122 positionalParameters.add(variable);
2121 } 2123 }
2122 }); 2124 });
2123 signature.forEachParameter((ParameterElement parameter) { 2125 signature.forEachParameter((_parameter) {
2126 ParameterElement parameter = _parameter;
2124 if (!parameter.isOptional) return; 2127 if (!parameter.isOptional) return;
2125 ir.Expression initializer = visitForValue(parameter.initializer); 2128 ir.Expression initializer = visitForValue(parameter.initializer);
2126 ir.VariableDeclaration variable = getLocal(parameter); 2129 ir.VariableDeclaration variable = getLocal(parameter);
2127 if (initializer != null) { 2130 if (initializer != null) {
2128 variable.initializer = initializer; 2131 variable.initializer = initializer;
2129 initializer.parent = variable; 2132 initializer.parent = variable;
2130 kernel.parameterInitializerNodeToConstant[initializer] = 2133 kernel.parameterInitializerNodeToConstant[initializer] =
2131 parameter.constant; 2134 parameter.constant;
2132 } 2135 }
2133 }); 2136 });
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 } 2874 }
2872 2875
2873 @override 2876 @override
2874 ir.Expression visitSuperIndexSetIfNull(SendSet node, MethodElement getter, 2877 ir.Expression visitSuperIndexSetIfNull(SendSet node, MethodElement getter,
2875 MethodElement setter, Node index, Node rhs, _) { 2878 MethodElement setter, Node index, Node rhs, _) {
2876 return _finishSetIfNull( 2879 return _finishSetIfNull(
2877 node, buildSuperIndexAccessor(index, getter, setter), rhs); 2880 node, buildSuperIndexAccessor(index, getter, setter), rhs);
2878 } 2881 }
2879 2882
2880 @override 2883 @override
2881 // ignore: INVALID_METHOD_OVERRIDE_RETURN_TYPE
2882 ir.Node visitVariableDefinitions(VariableDefinitions definitions) { 2884 ir.Node visitVariableDefinitions(VariableDefinitions definitions) {
2883 // TODO(ahe): This method is copied from [SemanticDeclarationResolvedMixin] 2885 // TODO(ahe): This method is copied from [SemanticDeclarationResolvedMixin]
2884 // and modified. Perhaps we can find a way to avoid code duplication. 2886 // and modified. Perhaps we can find a way to avoid code duplication.
2885 List<ir.VariableDeclaration> variables = <ir.VariableDeclaration>[]; 2887 List<ir.VariableDeclaration> variables = <ir.VariableDeclaration>[];
2886 computeVariableStructures(definitions, 2888 computeVariableStructures(definitions,
2887 (Node node, VariableStructure structure) { 2889 (Node node, VariableStructure structure) {
2888 if (structure == null) { 2890 if (structure == null) {
2889 return internalError(node, 'No structure for $node'); 2891 internalError(node, 'No structure for $node');
2890 } else { 2892 } else {
2891 ir.VariableDeclaration variable = 2893 ir.VariableDeclaration variable =
2892 structure.dispatch(declVisitor, node, null); 2894 structure.dispatch(declVisitor, node, null);
2893 variables.add(variable); 2895 variables.add(variable);
2894 return variable;
Emily Fortuna 2017/06/14 20:31:20 we remove this return statement, too?
ahe 2017/06/14 20:46:58 computeVariableStructures ignores what this callba
2895 } 2896 }
2896 }); 2897 });
2897 if (variables.length == 1) return variables.single; 2898 if (variables.length == 1) return variables.single;
2898 return new VariableDeclarations(variables); 2899 return new VariableDeclarations(variables);
2899 } 2900 }
2900 2901
2901 IrFunction buildFunction() { 2902 IrFunction buildFunction() {
2902 return kernel.compiler.reporter.withCurrentElement(currentElement, () { 2903 return kernel.compiler.reporter.withCurrentElement(currentElement, () {
2903 if (kernel.isSyntheticError(currentElement)) { 2904 if (kernel.isSyntheticError(currentElement)) {
2904 kernel.internalError(currentElement, 2905 kernel.internalError(currentElement,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 : this(null, true, node, initializers); 2968 : this(null, true, node, initializers);
2968 2969
2969 accept(ir.Visitor v) => throw "unsupported"; 2970 accept(ir.Visitor v) => throw "unsupported";
2970 2971
2971 visitChildren(ir.Visitor v) => throw "unsupported"; 2972 visitChildren(ir.Visitor v) => throw "unsupported";
2972 2973
2973 String toString() { 2974 String toString() {
2974 return "IrFunction($kind, $isConstructor, $node, $initializers)"; 2975 return "IrFunction($kind, $isConstructor, $node, $initializers)";
2975 } 2976 }
2976 } 2977 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/inferrer_engine.dart ('k') | pkg/compiler/lib/src/resolution/members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698