Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 3780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3791 HInstruction invokeInterceptor(HInstruction receiver) { | 3791 HInstruction invokeInterceptor(HInstruction receiver) { |
| 3792 HInterceptor interceptor = new HInterceptor(receiver, backend.nonNullType); | 3792 HInterceptor interceptor = new HInterceptor(receiver, backend.nonNullType); |
| 3793 add(interceptor); | 3793 add(interceptor); |
| 3794 return interceptor; | 3794 return interceptor; |
| 3795 } | 3795 } |
| 3796 | 3796 |
| 3797 HLiteralList buildLiteralList(List<HInstruction> inputs) { | 3797 HLiteralList buildLiteralList(List<HInstruction> inputs) { |
| 3798 return new HLiteralList(inputs, backend.extendableArrayType); | 3798 return new HLiteralList(inputs, backend.extendableArrayType); |
| 3799 } | 3799 } |
| 3800 | 3800 |
| 3801 // TODO(karlklose): change construction of the representations to be GVN'able | |
| 3802 // (dartbug.com/7182). | |
| 3803 HInstruction buildTypeArgumentRepresentations(DartType type) { | 3801 HInstruction buildTypeArgumentRepresentations(DartType type) { |
| 3802 assert(!type.isTypeVariable); | |
| 3804 // Compute the representation of the type arguments, including access | 3803 // Compute the representation of the type arguments, including access |
| 3805 // to the runtime type information for type variables as instructions. | 3804 // to the runtime type information for type variables as instructions. |
| 3806 if (type.isTypeVariable) { | 3805 assert(type.element.isClass); |
| 3807 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]); | 3806 InterfaceType interface = type; |
|
sra1
2016/08/19 22:21:32
This makes no sense and the path is infeasible. De
| |
| 3808 } else { | 3807 List<HInstruction> inputs = <HInstruction>[]; |
| 3809 assert(type.element.isClass); | 3808 for (DartType argument in interface.typeArguments) { |
| 3810 InterfaceType interface = type; | 3809 inputs.add(analyzeTypeArgument(argument)); |
| 3811 List<HInstruction> inputs = <HInstruction>[]; | |
| 3812 List<js.Expression> templates = <js.Expression>[]; | |
| 3813 for (DartType argument in interface.typeArguments) { | |
| 3814 // As we construct the template in stages, we have to make sure that for | |
| 3815 // each part the generated sub-template's holes match the index of the | |
| 3816 // inputs that are later used to instantiate it. We do this by starting | |
| 3817 // the indexing with the number of inputs from previous sub-templates. | |
| 3818 templates.add(rtiEncoder.getTypeRepresentationWithPlaceholders(argument, | |
| 3819 (variable) { | |
| 3820 HInstruction runtimeType = addTypeVariableReference(variable); | |
| 3821 inputs.add(runtimeType); | |
| 3822 }, firstPlaceholderIndex: inputs.length)); | |
| 3823 } | |
| 3824 // TODO(sra): This is a fresh template each time. We can't let the | |
| 3825 // template manager build them. | |
| 3826 js.Template code = | |
| 3827 new js.Template(null, new js.ArrayInitializer(templates)); | |
| 3828 HInstruction representation = new HForeignCode( | |
| 3829 code, backend.readableArrayType, inputs, | |
| 3830 nativeBehavior: native.NativeBehavior.PURE_ALLOCATION); | |
| 3831 return representation; | |
| 3832 } | 3810 } |
| 3811 HInstruction representation = new HTypeInfoExpression( | |
| 3812 TypeInfoExpressionKind.INSTANCE, | |
| 3813 interface.element.thisType, | |
| 3814 inputs, | |
| 3815 backend.dynamicType); | |
| 3816 return representation; | |
| 3833 } | 3817 } |
| 3834 | 3818 |
| 3835 @override | 3819 @override |
| 3836 void visitAs(ast.Send node, ast.Node expression, DartType type, _) { | 3820 void visitAs(ast.Send node, ast.Node expression, DartType type, _) { |
| 3837 HInstruction expressionInstruction = visitAndPop(expression); | 3821 HInstruction expressionInstruction = visitAndPop(expression); |
| 3838 if (type.isMalformed) { | 3822 if (type.isMalformed) { |
| 3839 String message; | 3823 String message; |
| 3840 if (type is MalformedType) { | 3824 if (type is MalformedType) { |
| 3841 ErroneousElement element = type.element; | 3825 ErroneousElement element = type.element; |
| 3842 message = element.message; | 3826 message = element.message; |
| (...skipping 4812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8655 const _LoopTypeVisitor(); | 8639 const _LoopTypeVisitor(); |
| 8656 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; | 8640 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; |
| 8657 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; | 8641 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; |
| 8658 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; | 8642 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; |
| 8659 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; | 8643 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; |
| 8660 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 8644 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
| 8661 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; | 8645 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; |
| 8662 int visitSwitchStatement(ast.SwitchStatement node) => | 8646 int visitSwitchStatement(ast.SwitchStatement node) => |
| 8663 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; | 8647 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; |
| 8664 } | 8648 } |
| OLD | NEW |