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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 26472002: Add TypeVariable object on runtime to support reflection on type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * A special element for the extra parameter taken by intercepted 8 * A special element for the extra parameter taken by intercepted
9 * methods. We need to override [Element.computeType] because our 9 * methods. We need to override [Element.computeType] because our
10 * optimizers may look at its declared type. 10 * optimizers may look at its declared type.
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2764 // to the runtime type information for type variables as instructions. 2764 // to the runtime type information for type variables as instructions.
2765 if (type.kind == TypeKind.TYPE_VARIABLE) { 2765 if (type.kind == TypeKind.TYPE_VARIABLE) {
2766 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]); 2766 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]);
2767 } else { 2767 } else {
2768 assert(type.element.isClass()); 2768 assert(type.element.isClass());
2769 InterfaceType interface = type; 2769 InterfaceType interface = type;
2770 List<HInstruction> inputs = <HInstruction>[]; 2770 List<HInstruction> inputs = <HInstruction>[];
2771 bool first = true; 2771 bool first = true;
2772 List<String> templates = <String>[]; 2772 List<String> templates = <String>[];
2773 for (DartType argument in interface.typeArguments) { 2773 for (DartType argument in interface.typeArguments) {
2774 templates.add(rti.getTypeRepresentation(argument, (variable) { 2774 templates.add(rti.getTypeRepresentationWithHashes(argument, (variable) {
2775 HInstruction runtimeType = addTypeVariableReference(variable); 2775 HInstruction runtimeType = addTypeVariableReference(variable);
2776 inputs.add(runtimeType); 2776 inputs.add(runtimeType);
2777 })); 2777 }));
2778 } 2778 }
2779 String template = '[${templates.join(', ')}]'; 2779 String template = '[${templates.join(', ')}]';
2780 js.Expression code = js.js.parseForeignJS(template); 2780 js.Expression code = js.js.parseForeignJS(template);
2781 HInstruction representation = 2781 HInstruction representation =
2782 createForeign(code, backend.readableArrayType, inputs); 2782 createForeign(code, backend.readableArrayType, inputs);
2783 return representation; 2783 return representation;
2784 } 2784 }
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
3462 } 3462 }
3463 3463
3464 HInstruction analyzeTypeArgument(DartType argument) { 3464 HInstruction analyzeTypeArgument(DartType argument) {
3465 if (argument.treatAsDynamic) { 3465 if (argument.treatAsDynamic) {
3466 // Represent [dynamic] as [null]. 3466 // Represent [dynamic] as [null].
3467 return graph.addConstantNull(compiler); 3467 return graph.addConstantNull(compiler);
3468 } 3468 }
3469 3469
3470 List<HInstruction> inputs = <HInstruction>[]; 3470 List<HInstruction> inputs = <HInstruction>[];
3471 3471
3472 String template = rti.getTypeRepresentation(argument, (variable) { 3472 String template = rti.getTypeRepresentationWithHashes(argument, (variable) {
3473 inputs.add(addTypeVariableReference(variable)); 3473 inputs.add(addTypeVariableReference(variable));
3474 }); 3474 });
3475 3475
3476 js.Expression code = js.js.parseForeignJS(template); 3476 js.Expression code = js.js.parseForeignJS(template);
3477 HInstruction result = createForeign(code, backend.stringType, inputs); 3477 HInstruction result = createForeign(code, backend.stringType, inputs);
3478 add(result); 3478 add(result);
3479 return result; 3479 return result;
3480 } 3480 }
3481 3481
3482 void handleListConstructor(InterfaceType type, 3482 void handleListConstructor(InterfaceType type,
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after
5555 new HSubGraphBlockInformation(elseBranch.graph)); 5555 new HSubGraphBlockInformation(elseBranch.graph));
5556 5556
5557 HBasicBlock conditionStartBlock = conditionBranch.block; 5557 HBasicBlock conditionStartBlock = conditionBranch.block;
5558 conditionStartBlock.setBlockFlow(info, joinBlock); 5558 conditionStartBlock.setBlockFlow(info, joinBlock);
5559 SubGraph conditionGraph = conditionBranch.graph; 5559 SubGraph conditionGraph = conditionBranch.graph;
5560 HIf branch = conditionGraph.end.last; 5560 HIf branch = conditionGraph.end.last;
5561 assert(branch is HIf); 5561 assert(branch is HIf);
5562 branch.blockInformation = conditionStartBlock.blockFlow; 5562 branch.blockInformation = conditionStartBlock.blockFlow;
5563 } 5563 }
5564 } 5564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698