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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 2599213002: More kernel-ification of type variables passed around constructors. (Closed)
Patch Set: . Created 4 years 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return typeBuilder.potentiallyCheckOrTrustType( 217 return typeBuilder.potentiallyCheckOrTrustType(
218 value, compiler.commonElements.boolType, 218 value, compiler.commonElements.boolType,
219 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK); 219 kind: HTypeConversion.BOOLEAN_CONVERSION_CHECK);
220 } 220 }
221 HInstruction result = new HBoolify(value, commonMasks.boolType); 221 HInstruction result = new HBoolify(value, commonMasks.boolType);
222 add(result); 222 add(result);
223 return result; 223 return result;
224 } 224 }
225 225
226 void _addClassTypeVariablesIfNeeded(ir.Member constructor) { 226 void _addClassTypeVariablesIfNeeded(ir.Member constructor) {
227 var enclosing = astAdapter.getElement(constructor).enclosingElement; 227 var enclosing = constructor.enclosingClass;
228 if (backend.classNeedsRti(enclosing)) { 228 if (backend.classNeedsRti(astAdapter.getElement(enclosing))) {
229 enclosing.typeVariables.forEach((TypeVariableType typeVariable) { 229 enclosing.typeParameters.forEach((ir.TypeParameter typeParameter) {
230 var typeParamElement = astAdapter.getElement(typeParameter);
230 HParameterValue param = 231 HParameterValue param =
231 addParameter(typeVariable.element, commonMasks.nonNullType); 232 addParameter(typeParamElement, commonMasks.nonNullType);
233 var dart_type = astAdapter.getDartType(typeParameter.bound);
234 // This is a little bit wacky (and n^2) until we make the localsHandler
235 // take Kernel DartTypes instead of just the AST DartTypes.
236 var typeVariableType = (astAdapter.getElement(constructor))
237 .enclosingElement
238 .typeVariables
239 .firstWhere((TypeVariableType i) => i.name == typeParameter.name);
232 localsHandler.directLocals[ 240 localsHandler.directLocals[
233 localsHandler.getTypeVariableAsLocal(typeVariable)] = param; 241 localsHandler.getTypeVariableAsLocal(typeVariableType)] = param;
234 }); 242 });
235 } 243 }
236 } 244 }
237 245
238 /// Builds generative constructors. 246 /// Builds generative constructors.
239 /// 247 ///
240 /// Generative constructors are built in two stages. 248 /// Generative constructors are built in two stages.
241 /// 249 ///
242 /// First, the field values for every instance field for every class in the 250 /// First, the field values for every instance field for every class in the
243 /// class hierarchy are collected. Then, create a function body that sets 251 /// class hierarchy are collected. Then, create a function body that sets
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 isExpression.operand.accept(this); 1965 isExpression.operand.accept(this);
1958 HInstruction expression = pop(); 1966 HInstruction expression = pop();
1959 push(buildIsNode(isExpression, isExpression.type, expression)); 1967 push(buildIsNode(isExpression, isExpression.type, expression));
1960 } 1968 }
1961 1969
1962 HInstruction buildIsNode( 1970 HInstruction buildIsNode(
1963 ir.Node node, ir.DartType type, HInstruction expression) { 1971 ir.Node node, ir.DartType type, HInstruction expression) {
1964 // Note: The call to "unalias" this type like in the original SSA builder is 1972 // Note: The call to "unalias" this type like in the original SSA builder is
1965 // unnecessary in kernel because Kernel has no notion of typedef. 1973 // unnecessary in kernel because Kernel has no notion of typedef.
1966 // TODO(efortuna): Add test for this. 1974 // TODO(efortuna): Add test for this.
1967 DartType typeValue = localsHandler.substInContext( 1975 DartType typeValue =
1968 astAdapter.getDartType(type)); 1976 localsHandler.substInContext(astAdapter.getDartType(type));
1969 if (type is ir.InvalidType) { 1977 if (type is ir.InvalidType) {
1970 generateTypeError(node, (typeValue.element as ErroneousElement).message); 1978 generateTypeError(node, (typeValue.element as ErroneousElement).message);
1971 return new HIs.compound( 1979 return new HIs.compound(
1972 typeValue, expression, pop(), commonMasks.boolType); 1980 typeValue, expression, pop(), commonMasks.boolType);
1973 } 1981 }
1974 1982
1975 if (type is ir.FunctionType) { 1983 if (type is ir.FunctionType) {
1976 List arguments = [buildFunctionType(typeValue), expression]; 1984 List arguments = [buildFunctionType(typeValue), expression];
1977 _pushDynamicInvocation(node, null, arguments, 1985 _pushDynamicInvocation(node, null, arguments,
1978 selector: new Selector.call( 1986 selector: new Selector.call(
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 kernelBuilder.open(exitBlock); 2338 kernelBuilder.open(exitBlock);
2331 enterBlock.setBlockFlow( 2339 enterBlock.setBlockFlow(
2332 new HTryBlockInformation( 2340 new HTryBlockInformation(
2333 kernelBuilder.wrapStatementGraph(bodyGraph), 2341 kernelBuilder.wrapStatementGraph(bodyGraph),
2334 exception, 2342 exception,
2335 kernelBuilder.wrapStatementGraph(catchGraph), 2343 kernelBuilder.wrapStatementGraph(catchGraph),
2336 kernelBuilder.wrapStatementGraph(finallyGraph)), 2344 kernelBuilder.wrapStatementGraph(finallyGraph)),
2337 exitBlock); 2345 exitBlock);
2338 } 2346 }
2339 } 2347 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698