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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1637843002: typeInformation in CreateInstance is a kind of TypeExpression (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closure; 7 import '../closure.dart' as closure;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart' show 9 import '../common/names.dart' show
10 Names, 10 Names,
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 /// 5. Returns the created object. 375 /// 5. Returns the created object.
376 ir.FunctionDefinition buildConstructor(ConstructorElement constructor) { 376 ir.FunctionDefinition buildConstructor(ConstructorElement constructor) {
377 // TODO(asgerf): Optimization: If constructor is redirecting, then just 377 // TODO(asgerf): Optimization: If constructor is redirecting, then just
378 // evaluate arguments and call the target constructor. 378 // evaluate arguments and call the target constructor.
379 constructor = constructor.implementation; 379 constructor = constructor.implementation;
380 ClassElement classElement = constructor.enclosingClass.implementation; 380 ClassElement classElement = constructor.enclosingClass.implementation;
381 381
382 IrBuilder builder = getBuilderFor(constructor); 382 IrBuilder builder = getBuilderFor(constructor);
383 383
384 final bool requiresTypeInformation = 384 final bool requiresTypeInformation =
385 builder.program.requiresRuntimeTypesFor(classElement); 385 builder.program.requiresRuntimeTypesFor(classElement);
386 386
387 return withBuilder(builder, () { 387 return withBuilder(builder, () {
388 // Setup parameters and create a box if anything is captured. 388 // Setup parameters and create a box if anything is captured.
389 List<Local> parameters = <Local>[]; 389 List<Local> parameters = <Local>[];
390 constructor.functionSignature.orderedForEachParameter( 390 constructor.functionSignature.orderedForEachParameter(
391 (ParameterElement p) => parameters.add(p)); 391 (ParameterElement p) => parameters.add(p));
392 392
393 int firstTypeArgumentParameterIndex; 393 int firstTypeArgumentParameterIndex;
394 394
395 // If instances of the class may need runtime type information, we add a 395 // If instances of the class may need runtime type information, we add a
396 // synthetic parameter for each type parameter. 396 // synthetic parameter for each type parameter.
397 if (requiresTypeInformation) { 397 if (requiresTypeInformation) {
398 firstTypeArgumentParameterIndex = parameters.length; 398 firstTypeArgumentParameterIndex = parameters.length;
399 classElement.typeVariables.forEach((TypeVariableType variable) { 399 classElement.typeVariables.forEach((TypeVariableType variable) {
400 parameters.add(new closure.TypeVariableLocal(variable, constructor)); 400 parameters.add(new closure.TypeVariableLocal(variable, constructor));
401 }); 401 });
402 } else { 402 } else {
403 classElement.typeVariables.forEach((TypeVariableType variable) { 403 classElement.typeVariables.forEach((TypeVariableType variable) {
404 irBuilder.declareTypeVariable(variable, const DynamicType()); 404 irBuilder.declareTypeVariable(variable, const DynamicType());
405 }); 405 });
406 } 406 }
407 407
408 // Create IR parameters and setup the environment. 408 // Create IR parameters and setup the environment.
409 List<ir.Parameter> irParameters = builder.buildFunctionHeader(parameters, 409 List<ir.Parameter> irParameters = builder.buildFunctionHeader(parameters,
410 closureScope: getClosureScopeForFunction(constructor)); 410 closureScope: getClosureScopeForFunction(constructor));
411 411
412 // Create a list of the values of all type argument parameters, if any. 412 // Create a list of the values of all type argument parameters, if any.
413 List<ir.Primitive> typeInformation; 413 ir.Primitive typeInformation;
414 if (requiresTypeInformation) { 414 if (requiresTypeInformation) {
415 typeInformation = irParameters.sublist(firstTypeArgumentParameterIndex); 415 typeInformation = new ir.TypeExpression(
416 ir.TypeExpressionKind.INSTANCE,
417 classElement.thisType,
418 irParameters.sublist(firstTypeArgumentParameterIndex));
419 irBuilder.add(new ir.LetPrim(typeInformation));
416 } else { 420 } else {
417 typeInformation = const <ir.Primitive>[]; 421 typeInformation = null;
418 } 422 }
419 423
420 // -- Load values for type variables declared on super classes -- 424 // -- Load values for type variables declared on super classes --
421 // Field initializers for super classes can reference these, so they 425 // Field initializers for super classes can reference these, so they
422 // must be available before evaluating field initializers. 426 // must be available before evaluating field initializers.
423 // This could be interleaved with field initialization, but we choose do 427 // This could be interleaved with field initialization, but we choose do
424 // get it out of the way here to avoid complications with mixins. 428 // get it out of the way here to avoid complications with mixins.
425 loadTypeVariablesForSuperClasses(classElement); 429 loadTypeVariablesForSuperClasses(classElement);
426 430
427 /// Maps each field from this class or a superclass to its initial value. 431 /// Maps each field from this class or a superclass to its initial value.
(...skipping 3165 matching lines...) Expand 10 before | Expand all | Expand 10 after
3593 } 3597 }
3594 3598
3595 Element get closureConverter { 3599 Element get closureConverter {
3596 return _backend.helpers.closureConverter; 3600 return _backend.helpers.closureConverter;
3597 } 3601 }
3598 3602
3599 void addNativeMethod(FunctionElement function) { 3603 void addNativeMethod(FunctionElement function) {
3600 _backend.emitter.nativeEmitter.nativeMethods.add(function); 3604 _backend.emitter.nativeEmitter.nativeMethods.add(function);
3601 } 3605 }
3602 } 3606 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698