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

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

Issue 1976213002: Adjusts dart2js backend to handle method type arguments. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
(...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 "${localsHandler.contextClass}."); 2587 "${localsHandler.contextClass}.");
2588 } 2588 }
2589 2589
2590 /// Build a [HTypeConversion] for convertion [original] to type [type]. 2590 /// Build a [HTypeConversion] for convertion [original] to type [type].
2591 /// 2591 ///
2592 /// Invariant: [type] must be valid in the context. 2592 /// Invariant: [type] must be valid in the context.
2593 /// See [LocalsHandler.substInContext]. 2593 /// See [LocalsHandler.substInContext].
2594 HInstruction buildTypeConversion( 2594 HInstruction buildTypeConversion(
2595 HInstruction original, DartType type, int kind) { 2595 HInstruction original, DartType type, int kind) {
2596 if (type == null) return original; 2596 if (type == null) return original;
2597 // TODO(eernst): The following statement was added for parsing and ignoring
2598 // method type variables; must be generalized for full support of generic
2599 // methods.
2600 type = type.eraseMethodTypeVariableType;
2597 type = type.unaliased; 2601 type = type.unaliased;
2598 assert(assertTypeInContext(type, original)); 2602 assert(assertTypeInContext(type, original));
2599 if (type.isInterfaceType && !type.treatAsRaw) { 2603 if (type.isInterfaceType && !type.treatAsRaw) {
2600 TypeMask subtype = new TypeMask.subtype(type.element, compiler.world); 2604 TypeMask subtype = new TypeMask.subtype(type.element, compiler.world);
2601 HInstruction representations = buildTypeArgumentRepresentations(type); 2605 HInstruction representations = buildTypeArgumentRepresentations(type);
2602 add(representations); 2606 add(representations);
2603 return new HTypeConversion.withTypeRepresentation( 2607 return new HTypeConversion.withTypeRepresentation(
2604 type, kind, subtype, original, representations); 2608 type, kind, subtype, original, representations);
2605 } else if (type.isTypeVariable) { 2609 } else if (type.isTypeVariable) {
2606 TypeMask subtype = original.instructionType; 2610 TypeMask subtype = original.instructionType;
(...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after
4765 // never built standalone, so in that case [target] is not 4769 // never built standalone, so in that case [target] is not
4766 // the [member] itself. 4770 // the [member] itself.
4767 (member.isField && member != target)) { 4771 (member.isField && member != target)) {
4768 // The type variable is stored in a parameter of the method. 4772 // The type variable is stored in a parameter of the method.
4769 return localsHandler.readLocal(typeVariableLocal, 4773 return localsHandler.readLocal(typeVariableLocal,
4770 sourceInformation: sourceInformation); 4774 sourceInformation: sourceInformation);
4771 } else if (member.isInstanceMember) { 4775 } else if (member.isInstanceMember) {
4772 // The type variable is stored on the object. 4776 // The type variable is stored on the object.
4773 return readTypeVariable(member.enclosingClass, type.element, 4777 return readTypeVariable(member.enclosingClass, type.element,
4774 sourceInformation: sourceInformation); 4778 sourceInformation: sourceInformation);
4779 } else if (type is MethodTypeVariableType) {
Johnni Winther 2016/05/17 10:27:05 When is this used?
eernst 2016/05/17 14:48:54 I believe that it is not used any more: with the n
4780 // TODO(eernst): The enclosing `else if` was added to provide minimal
4781 // support for generic methods: The method type arguments are always
4782 // pretending to have the value `dynamic`. Revise for full support.
4783 DynamicType type = const DynamicType();
4784 JavaScriptBackend backend = compiler.backend;
4785 ClassElement cls = backend.helpers.DynamicRuntimeType;
4786 HInstruction instruction =
4787 new HDynamicType(type, new TypeMask.exact(cls, compiler.world));
4788 add(instruction);
4789 return instruction;
4775 } else { 4790 } else {
4776 reporter.internalError( 4791 reporter.internalError(
4777 type.element, 'Unexpected type variable in static context.'); 4792 type.element, 'Unexpected type variable in static context.');
4778 return null; 4793 return null;
4779 } 4794 }
4780 } 4795 }
4781 4796
4782 HInstruction analyzeTypeArgument(DartType argument, 4797 HInstruction analyzeTypeArgument(DartType argument,
4783 {SourceInformation sourceInformation}) { 4798 {SourceInformation sourceInformation}) {
4784 assert(assertTypeInContext(argument)); 4799 assert(assertTypeInContext(argument));
(...skipping 3821 matching lines...) Expand 10 before | Expand all | Expand 10 after
8606 const _LoopTypeVisitor(); 8621 const _LoopTypeVisitor();
8607 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; 8622 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP;
8608 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; 8623 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP;
8609 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; 8624 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP;
8610 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; 8625 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP;
8611 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 8626 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
8612 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 8627 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
8613 int visitSwitchStatement(ast.SwitchStatement node) => 8628 int visitSwitchStatement(ast.SwitchStatement node) =>
8614 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; 8629 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
8615 } 8630 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698