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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 class SsaFunctionCompiler implements FunctionCompiler { | 7 class SsaFunctionCompiler implements FunctionCompiler { |
8 SsaCodeGeneratorTask generator; | 8 SsaCodeGeneratorTask generator; |
9 SsaBuilderTask builder; | 9 SsaBuilderTask builder; |
10 SsaOptimizerTask optimizer; | 10 SsaOptimizerTask optimizer; |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1012 for (JumpTarget target in targetIndexMap.keys) { | 1012 for (JumpTarget target in targetIndexMap.keys) { |
1013 builder.jumpTargets.remove(target); | 1013 builder.jumpTargets.remove(target); |
1014 } | 1014 } |
1015 super.close(); | 1015 super.close(); |
1016 } | 1016 } |
1017 } | 1017 } |
1018 | 1018 |
1019 /** | 1019 /** |
1020 * This class builds SSA nodes for functions represented in AST. | 1020 * This class builds SSA nodes for functions represented in AST. |
1021 */ | 1021 */ |
1022 class SsaBuilder extends NewResolvedVisitor { | 1022 class SsaBuilder extends ast.Visitor |
1023 with BaseImplementationOfCompoundsMixin, | |
1024 SendResolverMixin, | |
1025 SemanticSendResolvedMixin, | |
1026 NewBulkMixin | |
1027 implements SemanticSendVisitor { | |
1023 final Compiler compiler; | 1028 final Compiler compiler; |
1024 final JavaScriptBackend backend; | 1029 final JavaScriptBackend backend; |
1025 final ConstantSystem constantSystem; | 1030 final ConstantSystem constantSystem; |
1026 final CodegenWorkItem work; | 1031 final CodegenWorkItem work; |
1027 final RuntimeTypes rti; | 1032 final RuntimeTypes rti; |
1033 TreeElements elements; | |
1028 SourceInformationBuilder sourceInformationBuilder; | 1034 SourceInformationBuilder sourceInformationBuilder; |
1029 bool inLazyInitializerExpression = false; | 1035 bool inLazyInitializerExpression = false; |
1030 | 1036 |
1031 /* This field is used by the native handler. */ | 1037 /* This field is used by the native handler. */ |
1032 final NativeEmitter nativeEmitter; | 1038 final NativeEmitter nativeEmitter; |
1033 | 1039 |
1034 final HGraph graph = new HGraph(); | 1040 final HGraph graph = new HGraph(); |
1035 | 1041 |
1036 /** | 1042 /** |
1037 * The current block to add instructions to. Might be null, if we are | 1043 * The current block to add instructions to. Might be null, if we are |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1112 | 1118 |
1113 SsaBuilder(JavaScriptBackend backend, | 1119 SsaBuilder(JavaScriptBackend backend, |
1114 CodegenWorkItem work, | 1120 CodegenWorkItem work, |
1115 this.nativeEmitter, | 1121 this.nativeEmitter, |
1116 SourceInformationFactory sourceInformationFactory) | 1122 SourceInformationFactory sourceInformationFactory) |
1117 : this.compiler = backend.compiler, | 1123 : this.compiler = backend.compiler, |
1118 this.backend = backend, | 1124 this.backend = backend, |
1119 this.constantSystem = backend.constantSystem, | 1125 this.constantSystem = backend.constantSystem, |
1120 this.work = work, | 1126 this.work = work, |
1121 this.rti = backend.rti, | 1127 this.rti = backend.rti, |
1122 super(work.resolutionTree) { | 1128 this.elements = work.resolutionTree { |
1123 localsHandler = new LocalsHandler(this, work.element, null); | 1129 localsHandler = new LocalsHandler(this, work.element, null); |
1124 sourceElementStack.add(work.element); | 1130 sourceElementStack.add(work.element); |
1125 sourceInformationBuilder = | 1131 sourceInformationBuilder = |
1126 sourceInformationFactory.forContext(work.element.implementation); | 1132 sourceInformationFactory.forContext(work.element.implementation); |
1127 } | 1133 } |
1128 | 1134 |
1135 @override | |
1136 SemanticSendVisitor get sendVisitor => this; | |
1137 | |
1138 @override | |
1139 void visitNode(ast.Node node) { | |
1140 internalError(node, "Unhandled node: $node"); | |
1141 } | |
1142 | |
1143 @override | |
1144 void apply(ast.Node node, [_]) { | |
1145 node.accept(this); | |
1146 } | |
1147 | |
1129 CodegenRegistry get registry => work.registry; | 1148 CodegenRegistry get registry => work.registry; |
1130 | 1149 |
1131 /// Returns the current source element. | 1150 /// Returns the current source element. |
1132 /// | 1151 /// |
1133 /// The returned element is a declaration element. | 1152 /// The returned element is a declaration element. |
1134 // TODO(johnniwinther): Check that all usages of sourceElement agree on | 1153 // TODO(johnniwinther): Check that all usages of sourceElement agree on |
1135 // implementation/declaration distinction. | 1154 // implementation/declaration distinction. |
1136 Element get sourceElement => sourceElementStack.last; | 1155 Element get sourceElement => sourceElementStack.last; |
1137 | 1156 |
1138 bool get _checkOrTrustTypes => | 1157 bool get _checkOrTrustTypes => |
(...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3116 } | 3135 } |
3117 | 3136 |
3118 visitFunctionDeclaration(ast.FunctionDeclaration node) { | 3137 visitFunctionDeclaration(ast.FunctionDeclaration node) { |
3119 assert(isReachable); | 3138 assert(isReachable); |
3120 visit(node.function); | 3139 visit(node.function); |
3121 LocalFunctionElement localFunction = | 3140 LocalFunctionElement localFunction = |
3122 elements.getFunctionDefinition(node.function); | 3141 elements.getFunctionDefinition(node.function); |
3123 localsHandler.updateLocal(localFunction, pop()); | 3142 localsHandler.updateLocal(localFunction, pop()); |
3124 } | 3143 } |
3125 | 3144 |
3145 @override | |
3146 void visitThisGet(ast.Identifier node, [_]) { | |
sigurdm
2015/06/26 07:44:19
Should this be called `handleThisGet`? I am not ex
Johnni Winther
2015/06/26 10:15:25
It is part of the [SemanticSendVisitor]. `this` is
| |
3147 stack.add(localsHandler.readThis()); | |
3148 } | |
3149 | |
3126 visitIdentifier(ast.Identifier node) { | 3150 visitIdentifier(ast.Identifier node) { |
3127 if (node.isThis()) { | 3151 if (node.isThis()) { |
3128 stack.add(localsHandler.readThis()); | 3152 visitThisGet(node); |
3129 } else { | 3153 } else { |
3130 compiler.internalError(node, | 3154 compiler.internalError(node, |
3131 "SsaFromAstMixin.visitIdentifier on non-this."); | 3155 "SsaFromAstMixin.visitIdentifier on non-this."); |
3132 } | 3156 } |
3133 } | 3157 } |
3134 | 3158 |
3135 visitIf(ast.If node) { | 3159 visitIf(ast.If node) { |
3136 assert(isReachable); | 3160 assert(isReachable); |
3137 handleIf(node, | 3161 handleIf(node, |
3138 () => visit(node.condition), | 3162 () => visit(node.condition), |
(...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4394 /// Access an unresolved super property. | 4418 /// Access an unresolved super property. |
4395 void handleUnresolvedSuperInvoke(ast.Send node) { | 4419 void handleUnresolvedSuperInvoke(ast.Send node) { |
4396 Selector selector = elements.getSelector(node); | 4420 Selector selector = elements.getSelector(node); |
4397 List<HInstruction> arguments = <HInstruction>[]; | 4421 List<HInstruction> arguments = <HInstruction>[]; |
4398 if (!node.isPropertyAccess) { | 4422 if (!node.isPropertyAccess) { |
4399 addGenericSendArgumentsToList(node.arguments, arguments); | 4423 addGenericSendArgumentsToList(node.arguments, arguments); |
4400 } | 4424 } |
4401 generateSuperNoSuchMethodSend(node, selector, arguments); | 4425 generateSuperNoSuchMethodSend(node, selector, arguments); |
4402 } | 4426 } |
4403 | 4427 |
4404 /// Handle super constructor invocation. | |
4405 @override | |
4406 void handleSuperConstructorInvoke(ast.Send node) { | |
4407 Selector selector = elements.getSelector(node); | |
4408 Element element = elements[node]; | |
4409 if (selector.applies(element, compiler.world)) { | |
4410 generateSuperInvoke(node, element); | |
4411 } else { | |
4412 generateWrongArgumentCountError(node, element, node.arguments); | |
4413 } | |
4414 } | |
4415 | |
4416 @override | 4428 @override |
4417 void visitUnresolvedSuperIndex( | 4429 void visitUnresolvedSuperIndex( |
4418 ast.Send node, | 4430 ast.Send node, |
4419 Element element, | 4431 Element element, |
4420 ast.Node index, | 4432 ast.Node index, |
4421 _) { | 4433 _) { |
4422 handleUnresolvedSuperInvoke(node); | 4434 handleUnresolvedSuperInvoke(node); |
4423 } | 4435 } |
4424 | 4436 |
4425 @override | 4437 @override |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4568 handleSuperMethodInvoke(node, method); | 4580 handleSuperMethodInvoke(node, method); |
4569 } | 4581 } |
4570 | 4582 |
4571 @override | 4583 @override |
4572 void visitSuperMethodIncompatibleInvoke( | 4584 void visitSuperMethodIncompatibleInvoke( |
4573 ast.Send node, | 4585 ast.Send node, |
4574 MethodElement method, | 4586 MethodElement method, |
4575 ast.NodeList arguments, | 4587 ast.NodeList arguments, |
4576 CallStructure callStructure, | 4588 CallStructure callStructure, |
4577 _) { | 4589 _) { |
4590 handleInvalidSuperInvoke(node, arguments); | |
4591 } | |
4592 | |
4593 @override | |
4594 visitSuperSetterInvoke( | |
sigurdm
2015/06/26 07:44:19
void return type?
Johnni Winther
2015/06/26 10:15:25
Done.
| |
4595 ast.Send node, | |
4596 SetterElement setter, | |
4597 ast.NodeList arguments, | |
4598 CallStructure callStructure, | |
4599 _) { | |
4600 handleInvalidSuperInvoke(node, arguments); | |
4601 } | |
4602 | |
4603 void handleInvalidSuperInvoke(ast.Send node, ast.NodeList arguments) { | |
4578 Selector selector = elements.getSelector(node); | 4604 Selector selector = elements.getSelector(node); |
4579 List<HInstruction> inputs = <HInstruction>[]; | 4605 List<HInstruction> inputs = <HInstruction>[]; |
4580 addGenericSendArgumentsToList(arguments.nodes, inputs); | 4606 addGenericSendArgumentsToList(arguments.nodes, inputs); |
4581 generateSuperNoSuchMethodSend(node, selector, inputs); | 4607 generateSuperNoSuchMethodSend(node, selector, inputs); |
4582 } | 4608 } |
4583 | 4609 |
4584 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { | 4610 bool needsSubstitutionForTypeVariableAccess(ClassElement cls) { |
4585 ClassWorld classWorld = compiler.world; | 4611 ClassWorld classWorld = compiler.world; |
4586 if (classWorld.isUsedAsMixin(cls)) return true; | 4612 if (classWorld.isUsedAsMixin(cls)) return true; |
4587 | 4613 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4753 typeMask: backend.dynamicType); | 4779 typeMask: backend.dynamicType); |
4754 | 4780 |
4755 // The new object will now be referenced through the | 4781 // The new object will now be referenced through the |
4756 // `setRuntimeTypeInfo` call. We therefore set the type of that | 4782 // `setRuntimeTypeInfo` call. We therefore set the type of that |
4757 // instruction to be of the object's type. | 4783 // instruction to be of the object's type. |
4758 assert(stack.last is HInvokeStatic || stack.last == newObject); | 4784 assert(stack.last is HInvokeStatic || stack.last == newObject); |
4759 stack.last.instructionType = newObject.instructionType; | 4785 stack.last.instructionType = newObject.instructionType; |
4760 return pop(); | 4786 return pop(); |
4761 } | 4787 } |
4762 | 4788 |
4763 handleNewSend(ast.NewExpression node) { | 4789 void handleNewSend(ast.NewExpression node) { |
4764 ast.Send send = node.send; | 4790 ast.Send send = node.send; |
4765 generateIsDeferredLoadedCheckOfSend(send); | 4791 generateIsDeferredLoadedCheckOfSend(send); |
4766 | 4792 |
4767 bool isFixedList = false; | 4793 bool isFixedList = false; |
4768 bool isFixedListConstructorCall = | 4794 bool isFixedListConstructorCall = |
4769 Elements.isFixedListConstructorCall(elements[send], send, compiler); | 4795 Elements.isFixedListConstructorCall(elements[send], send, compiler); |
4770 bool isGrowableListConstructorCall = | 4796 bool isGrowableListConstructorCall = |
4771 Elements.isGrowableListConstructorCall(elements[send], send, compiler); | 4797 Elements.isGrowableListConstructorCall(elements[send], send, compiler); |
4772 | 4798 |
4773 TypeMask computeType(element) { | 4799 TypeMask computeType(element) { |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5420 signature.forEachParameter((Element parameter) { | 5446 signature.forEachParameter((Element parameter) { |
5421 existingArguments.add(parameter.name); | 5447 existingArguments.add(parameter.name); |
5422 }); | 5448 }); |
5423 generateThrowNoSuchMethod(diagnosticNode, | 5449 generateThrowNoSuchMethod(diagnosticNode, |
5424 function.name, | 5450 function.name, |
5425 argumentNodes: argumentNodes, | 5451 argumentNodes: argumentNodes, |
5426 existingArguments: existingArguments); | 5452 existingArguments: existingArguments); |
5427 } | 5453 } |
5428 | 5454 |
5429 @override | 5455 @override |
5430 handleNewExpression(ast.NewExpression node) { | 5456 void bulkHandleNode(ast.Node node, String message, _) { |
5457 internalError(node, "Unexpected bulk handled node: $node"); | |
5458 } | |
5459 | |
5460 @override | |
5461 void bulkHandleNew(ast.NewExpression node, [_]) { | |
5431 Element element = elements[node.send]; | 5462 Element element = elements[node.send]; |
5432 final bool isSymbolConstructor = element == compiler.symbolConstructor; | 5463 final bool isSymbolConstructor = element == compiler.symbolConstructor; |
5433 if (!Elements.isErroneous(element)) { | 5464 if (!Elements.isErroneous(element)) { |
5434 ConstructorElement function = element; | 5465 ConstructorElement function = element; |
5435 element = function.effectiveTarget; | 5466 element = function.effectiveTarget; |
5436 } | 5467 } |
5437 if (Elements.isErroneous(element)) { | 5468 if (Elements.isErroneous(element)) { |
5438 if (element is !ErroneousElement) { | 5469 if (element is !ErroneousElement) { |
5439 // TODO(ahe): Do something like [generateWrongArgumentCountError]. | 5470 // TODO(ahe): Do something like [generateWrongArgumentCountError]. |
5440 stack.add(graph.addConstantNull(compiler)); | 5471 stack.add(graph.addConstantNull(compiler)); |
(...skipping 15 matching lines...) Expand all Loading... | |
5456 ConstructedConstantValue symbol = getConstantForNode(node); | 5487 ConstructedConstantValue symbol = getConstantForNode(node); |
5457 StringConstantValue stringConstant = symbol.fields.values.single; | 5488 StringConstantValue stringConstant = symbol.fields.values.single; |
5458 String nameString = stringConstant.toDartString().slowToString(); | 5489 String nameString = stringConstant.toDartString().slowToString(); |
5459 registry.registerConstSymbol(nameString); | 5490 registry.registerConstSymbol(nameString); |
5460 } | 5491 } |
5461 } else { | 5492 } else { |
5462 handleNewSend(node); | 5493 handleNewSend(node); |
5463 } | 5494 } |
5464 } | 5495 } |
5465 | 5496 |
5497 @override | |
5498 void errorNonConstantConstructorInvoke( | |
5499 ast.NewExpression node, | |
5500 Element element, | |
5501 DartType type, | |
5502 ast.NodeList arguments, | |
5503 CallStructure callStructure, | |
5504 _) { | |
5505 bulkHandleNew(node); | |
5506 } | |
5507 | |
5466 void pushInvokeDynamic(ast.Node node, | 5508 void pushInvokeDynamic(ast.Node node, |
5467 Selector selector, | 5509 Selector selector, |
5468 TypeMask mask, | 5510 TypeMask mask, |
5469 List<HInstruction> arguments, | 5511 List<HInstruction> arguments, |
5470 {ast.Node location}) { | 5512 {ast.Node location}) { |
5471 if (location == null) location = node; | 5513 if (location == null) location = node; |
5472 | 5514 |
5473 // We prefer to not inline certain operations on indexables, | 5515 // We prefer to not inline certain operations on indexables, |
5474 // because the constant folder will handle them better and turn | 5516 // because the constant folder will handle them better and turn |
5475 // them into simpler instructions that allow further | 5517 // them into simpler instructions that allow further |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5683 } else { | 5725 } else { |
5684 handleComplexOperatorSend(node, getterInstruction, arguments); | 5726 handleComplexOperatorSend(node, getterInstruction, arguments); |
5685 setterInputs.add(pop()); | 5727 setterInputs.add(pop()); |
5686 generateSuperSendSet(); | 5728 generateSuperSendSet(); |
5687 stack.add(node.isPostfix ? getterInstruction : setterInputs.last); | 5729 stack.add(node.isPostfix ? getterInstruction : setterInputs.last); |
5688 } | 5730 } |
5689 } | 5731 } |
5690 } | 5732 } |
5691 | 5733 |
5692 @override | 5734 @override |
5735 void handleSuperCompounds( | |
5736 ast.SendSet node, | |
5737 Element getter, | |
5738 CompoundGetter getterKind, | |
5739 Element setter, | |
5740 CompoundSetter setterKind, | |
5741 CompoundRhs rhs, | |
5742 _) { | |
5743 handleSuperSendSet(node); | |
5744 } | |
5745 | |
5746 @override | |
5747 void visitFinalSuperFieldSet( | |
5748 ast.SendSet node, | |
5749 FieldElement field, | |
5750 ast.Node rhs, | |
5751 _) { | |
5752 handleSuperSendSet(node); | |
5753 } | |
5754 | |
5755 @override | |
5756 void visitSuperFieldSet( | |
5757 ast.SendSet node, | |
5758 FieldElement field, | |
5759 ast.Node rhs, | |
5760 _) { | |
5761 handleSuperSendSet(node); | |
5762 } | |
5763 | |
5764 @override | |
5765 void visitSuperGetterSet( | |
5766 ast.SendSet node, | |
5767 FunctionElement getter, | |
5768 ast.Node rhs, | |
5769 _) { | |
5770 handleSuperSendSet(node); | |
5771 } | |
5772 | |
5773 @override | |
5774 void visitSuperIndexSet( | |
5775 ast.SendSet node, | |
5776 FunctionElement function, | |
5777 ast.Node index, | |
5778 ast.Node rhs, | |
5779 _) { | |
5780 handleSuperSendSet(node); | |
5781 } | |
5782 | |
5783 @override | |
5784 void visitSuperMethodSet( | |
5785 ast.Send node, | |
5786 MethodElement method, | |
5787 ast.Node rhs, | |
5788 _) { | |
5789 handleSuperSendSet(node); | |
5790 } | |
5791 | |
5792 @override | |
5793 void visitSuperSetterSet( | |
5794 ast.SendSet node, | |
5795 FunctionElement setter, | |
5796 ast.Node rhs, | |
5797 _) { | |
5798 handleSuperSendSet(node); | |
5799 } | |
5800 | |
5801 @override | |
5802 void visitUnresolvedSuperIndexSet( | |
5803 ast.Send node, | |
5804 Element element, | |
5805 ast.Node index, | |
5806 ast.Node rhs, | |
5807 _) { | |
5808 handleSuperSendSet(node); | |
5809 } | |
5810 | |
5811 void visitSuperIndexPrefix( | |
5812 ast.Send node, | |
5813 MethodElement indexFunction, | |
5814 MethodElement indexSetFunction, | |
5815 ast.Node index, | |
5816 IncDecOperator operator, | |
5817 _) { | |
5818 handleSuperSendSet(node); | |
5819 } | |
5820 | |
5821 void visitSuperIndexPostfix( | |
5822 ast.Send node, | |
5823 MethodElement indexFunction, | |
5824 MethodElement indexSetFunction, | |
5825 ast.Node index, | |
5826 IncDecOperator operator, | |
5827 _) { | |
5828 handleSuperSendSet(node); | |
5829 } | |
5830 | |
5831 void visitUnresolvedSuperGetterIndexPrefix( | |
5832 ast.Send node, | |
5833 Element element, | |
5834 MethodElement setter, | |
5835 ast.Node index, | |
5836 IncDecOperator operator, | |
5837 _) { | |
5838 handleSuperSendSet(node); | |
5839 } | |
5840 | |
5841 void visitUnresolvedSuperGetterIndexPostfix( | |
5842 ast.Send node, | |
5843 Element element, | |
5844 MethodElement setter, | |
5845 ast.Node index, | |
5846 IncDecOperator operator, | |
5847 _) { | |
5848 handleSuperSendSet(node); | |
5849 } | |
5850 | |
5851 void visitUnresolvedSuperSetterIndexPrefix( | |
5852 ast.Send node, | |
5853 MethodElement indexFunction, | |
5854 Element element, | |
5855 ast.Node index, | |
5856 IncDecOperator operator, | |
5857 _) { | |
5858 handleSuperSendSet(node); | |
5859 } | |
5860 | |
5861 void visitUnresolvedSuperSetterIndexPostfix( | |
5862 ast.Send node, | |
5863 MethodElement indexFunction, | |
5864 Element element, | |
5865 ast.Node index, | |
5866 IncDecOperator operator, | |
5867 _) { | |
5868 handleSuperSendSet(node); | |
5869 } | |
5870 | |
5871 void visitUnresolvedSuperIndexPrefix( | |
5872 ast.Send node, | |
5873 Element element, | |
5874 ast.Node index, | |
5875 IncDecOperator operator, | |
5876 _) { | |
5877 handleSuperSendSet(node); | |
5878 } | |
5879 | |
5880 void visitUnresolvedSuperIndexPostfix( | |
5881 ast.Send node, | |
5882 Element element, | |
5883 ast.Node index, | |
5884 IncDecOperator operator, | |
5885 _) { | |
5886 handleSuperSendSet(node); | |
5887 } | |
5888 | |
5889 void visitSuperCompoundIndexSet( | |
5890 ast.SendSet node, | |
5891 MethodElement getter, | |
5892 MethodElement setter, | |
5893 ast.Node index, | |
5894 AssignmentOperator operator, | |
5895 ast.Node rhs, | |
5896 _) { | |
5897 handleSuperSendSet(node); | |
5898 } | |
5899 | |
5900 void visitUnresolvedSuperGetterCompoundIndexSet( | |
5901 ast.Send node, | |
5902 Element element, | |
5903 MethodElement setter, | |
5904 ast.Node index, | |
5905 AssignmentOperator operator, | |
5906 ast.Node rhs, | |
5907 _) { | |
5908 handleSuperSendSet(node); | |
5909 } | |
5910 | |
5911 void visitUnresolvedSuperSetterCompoundIndexSet( | |
5912 ast.Send node, | |
5913 MethodElement getter, | |
5914 Element element, | |
5915 ast.Node index, | |
5916 AssignmentOperator operator, | |
5917 ast.Node rhs, | |
5918 _) { | |
5919 handleSuperSendSet(node); | |
5920 } | |
5921 | |
5922 void visitUnresolvedSuperCompoundIndexSet( | |
5923 ast.Send node, | |
5924 Element element, | |
5925 ast.Node index, | |
5926 AssignmentOperator operator, | |
5927 ast.Node rhs, | |
5928 _) { | |
5929 handleSuperSendSet(node); | |
5930 } | |
5931 | |
5932 void visitSuperFieldCompound( | |
5933 ast.Send node, | |
5934 FieldElement field, | |
5935 AssignmentOperator operator, | |
5936 ast.Node rhs, | |
5937 _) { | |
5938 handleSuperSendSet(node); | |
5939 } | |
5940 | |
5941 void visitFinalSuperFieldCompound( | |
5942 ast.Send node, | |
5943 FieldElement field, | |
5944 AssignmentOperator operator, | |
5945 ast.Node rhs, | |
5946 _) { | |
5947 handleSuperSendSet(node); | |
5948 } | |
5949 | |
5950 void visitFinalSuperFieldPrefix( | |
5951 ast.Send node, | |
5952 FieldElement field, | |
5953 IncDecOperator operator, | |
5954 _) { | |
5955 handleSuperSendSet(node); | |
5956 } | |
5957 | |
5958 void visitUnresolvedSuperPrefix( | |
5959 ast.Send node, | |
5960 Element element, | |
5961 IncDecOperator operator, | |
5962 _) { | |
5963 handleSuperSendSet(node); | |
5964 } | |
5965 | |
5966 void visitUnresolvedSuperPostfix( | |
5967 ast.Send node, | |
5968 Element element, | |
5969 IncDecOperator operator, | |
5970 _) { | |
5971 handleSuperSendSet(node); | |
5972 } | |
5973 | |
5974 void visitUnresolvedSuperCompound( | |
5975 ast.Send node, | |
5976 Element element, | |
5977 AssignmentOperator operator, | |
5978 ast.Node rhs, | |
5979 _) { | |
5980 handleSuperSendSet(node); | |
5981 } | |
5982 | |
5983 void visitFinalSuperFieldPostfix( | |
5984 ast.Send node, | |
5985 FieldElement field, | |
5986 IncDecOperator operator, | |
5987 _) { | |
5988 handleSuperSendSet(node); | |
5989 } | |
5990 | |
5991 void visitSuperFieldFieldCompound( | |
5992 ast.Send node, | |
5993 FieldElement readField, | |
5994 FieldElement writtenField, | |
5995 AssignmentOperator operator, | |
5996 ast.Node rhs, | |
5997 _) { | |
5998 handleSuperSendSet(node); | |
5999 } | |
6000 | |
6001 void visitSuperGetterSetterCompound( | |
6002 ast.Send node, | |
6003 FunctionElement getter, | |
6004 FunctionElement setter, | |
6005 AssignmentOperator operator, | |
6006 ast.Node rhs, | |
6007 _) { | |
6008 handleSuperSendSet(node); | |
6009 } | |
6010 | |
6011 void visitSuperMethodSetterCompound( | |
6012 ast.Send node, | |
6013 FunctionElement method, | |
6014 FunctionElement setter, | |
6015 AssignmentOperator operator, | |
6016 ast.Node rhs, | |
6017 _) { | |
6018 handleSuperSendSet(node); | |
6019 } | |
6020 | |
6021 void visitSuperMethodCompound( | |
6022 ast.Send node, | |
6023 FunctionElement method, | |
6024 AssignmentOperator operator, | |
6025 ast.Node rhs, | |
6026 _) { | |
6027 handleSuperSendSet(node); | |
6028 } | |
6029 | |
6030 void visitUnresolvedSuperGetterCompound( | |
6031 ast.Send node, | |
6032 Element element, | |
6033 MethodElement setter, | |
6034 AssignmentOperator operator, | |
6035 ast.Node rhs, | |
6036 _) { | |
6037 handleSuperSendSet(node); | |
6038 } | |
6039 | |
6040 void visitUnresolvedSuperSetterCompound( | |
6041 ast.Send node, | |
6042 MethodElement getter, | |
6043 Element element, | |
6044 AssignmentOperator operator, | |
6045 ast.Node rhs, | |
6046 _) { | |
6047 handleSuperSendSet(node); | |
6048 } | |
6049 | |
6050 void visitSuperFieldSetterCompound( | |
6051 ast.Send node, | |
6052 FieldElement field, | |
6053 FunctionElement setter, | |
6054 AssignmentOperator operator, | |
6055 ast.Node rhs, | |
6056 _) { | |
6057 handleSuperSendSet(node); | |
6058 } | |
6059 | |
6060 void visitSuperGetterFieldCompound( | |
6061 ast.Send node, | |
6062 FunctionElement getter, | |
6063 FieldElement field, | |
6064 AssignmentOperator operator, | |
6065 ast.Node rhs, | |
6066 _) { | |
6067 handleSuperSendSet(node); | |
6068 } | |
6069 | |
6070 @override | |
5693 void visitIndexSet( | 6071 void visitIndexSet( |
5694 ast.SendSet node, | 6072 ast.SendSet node, |
5695 ast.Node receiver, | 6073 ast.Node receiver, |
5696 ast.Node index, | 6074 ast.Node index, |
5697 ast.Node rhs, | 6075 ast.Node rhs, |
5698 _) { | 6076 _) { |
5699 generateDynamicSend(node); | 6077 generateDynamicSend(node); |
5700 } | 6078 } |
5701 | 6079 |
6080 void visitCompoundIndexSet( | |
6081 ast.SendSet node, | |
6082 ast.Node receiver, | |
6083 ast.Node index, | |
6084 AssignmentOperator operator, | |
6085 ast.Node rhs, | |
6086 _) { | |
6087 generateIsDeferredLoadedCheckOfSend(node); | |
6088 handleIndexSendSet(node); | |
6089 } | |
6090 | |
6091 | |
6092 void visitIndexPrefix( | |
6093 ast.Send node, | |
6094 ast.Node receiver, | |
6095 ast.Node index, | |
6096 IncDecOperator operator, | |
6097 _) { | |
6098 generateIsDeferredLoadedCheckOfSend(node); | |
6099 handleIndexSendSet(node); | |
6100 } | |
6101 | |
6102 void visitIndexPostfix( | |
6103 ast.Send node, | |
6104 ast.Node receiver, | |
6105 ast.Node index, | |
6106 IncDecOperator operator, | |
6107 _) { | |
6108 generateIsDeferredLoadedCheckOfSend(node); | |
6109 handleIndexSendSet(node); | |
6110 } | |
6111 | |
5702 void handleIndexSendSet(ast.SendSet node) { | 6112 void handleIndexSendSet(ast.SendSet node) { |
5703 ast.Operator op = node.assignmentOperator; | 6113 ast.Operator op = node.assignmentOperator; |
5704 if ("=" == op.source) { | 6114 if ("=" == op.source) { |
5705 internalError(node, "Unexpected index set."); | 6115 internalError(node, "Unexpected index set."); |
5706 } else { | 6116 } else { |
5707 visit(node.receiver); | 6117 visit(node.receiver); |
5708 HInstruction receiver = pop(); | 6118 HInstruction receiver = pop(); |
5709 Link<ast.Node> arguments = node.arguments; | 6119 Link<ast.Node> arguments = node.arguments; |
5710 HInstruction index; | 6120 HInstruction index; |
5711 if (node.isIndex) { | 6121 if (node.isIndex) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6101 HInstruction value = pop(); | 6511 HInstruction value = pop(); |
6102 generateNonInstanceSetter(node, element, value); | 6512 generateNonInstanceSetter(node, element, value); |
6103 } | 6513 } |
6104 if (node.isPostfix) { | 6514 if (node.isPostfix) { |
6105 pop(); | 6515 pop(); |
6106 stack.add(getterInstruction); | 6516 stack.add(getterInstruction); |
6107 } | 6517 } |
6108 } | 6518 } |
6109 | 6519 |
6110 @override | 6520 @override |
6111 handleSendSet(ast.SendSet node) { | 6521 void handleDynamicCompounds( |
6112 ast.Operator op = node.assignmentOperator; | 6522 ast.Send node, |
6113 generateIsDeferredLoadedCheckOfSend(node); | 6523 ast.Node receiver, |
6114 Element element = elements[node]; | 6524 CompoundRhs rhs, |
6115 if (!Elements.isUnresolved(element) && element.impliesType) { | 6525 Selector getterSelector, |
6116 ast.Identifier selector = node.selector; | 6526 Selector setterSelector, |
6117 generateThrowNoSuchMethod(node, selector.source, | 6527 _) { |
6118 argumentNodes: node.arguments); | 6528 handleCompoundSendSet(node); |
6119 } else if (node.isSuperCall) { | 6529 } |
6120 handleSuperSendSet(node); | 6530 |
6121 } else if (node.isIndex) { | 6531 @override |
6122 handleIndexSendSet(node); | 6532 void handleLocalCompounds( |
6123 } else if ("=" == op.source) { | 6533 ast.SendSet node, |
6124 internalError(node, "Unexpected assignment."); | 6534 LocalElement local, |
6125 } else if (identical(op.source, "is")) { | 6535 CompoundRhs rhs, |
6126 compiler.internalError(op, "is-operator as SendSet."); | 6536 _, |
6127 } else { | 6537 {bool isSetterValid}) { |
6128 assert("++" == op.source || "--" == op.source || | 6538 handleCompoundSendSet(node); |
6129 node.assignmentOperator.source.endsWith("=")); | 6539 } |
6130 handleCompoundSendSet(node); | 6540 |
6131 } | 6541 @override |
6542 void handleStaticCompounds( | |
6543 ast.SendSet node, | |
6544 Element getter, | |
6545 CompoundGetter getterKind, | |
6546 Element setter, | |
6547 CompoundSetter setterKind, | |
6548 CompoundRhs rhs, | |
6549 _) { | |
6550 handleCompoundSendSet(node); | |
6132 } | 6551 } |
6133 | 6552 |
6134 void visitLiteralInt(ast.LiteralInt node) { | 6553 void visitLiteralInt(ast.LiteralInt node) { |
6135 stack.add(graph.addConstantInt(node.value, compiler)); | 6554 stack.add(graph.addConstantInt(node.value, compiler)); |
6136 } | 6555 } |
6137 | 6556 |
6138 void visitLiteralDouble(ast.LiteralDouble node) { | 6557 void visitLiteralDouble(ast.LiteralDouble node) { |
6139 stack.add(graph.addConstantDouble(node.value, compiler)); | 6558 stack.add(graph.addConstantDouble(node.value, compiler)); |
6140 } | 6559 } |
6141 | 6560 |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7564 visitInlinedFunction(function); | 7983 visitInlinedFunction(function); |
7565 } | 7984 } |
7566 | 7985 |
7567 void emitReturn(HInstruction value, ast.Node node) { | 7986 void emitReturn(HInstruction value, ast.Node node) { |
7568 if (inliningStack.isEmpty) { | 7987 if (inliningStack.isEmpty) { |
7569 closeAndGotoExit(attachPosition(new HReturn(value), node)); | 7988 closeAndGotoExit(attachPosition(new HReturn(value), node)); |
7570 } else { | 7989 } else { |
7571 localsHandler.updateLocal(returnLocal, value); | 7990 localsHandler.updateLocal(returnLocal, value); |
7572 } | 7991 } |
7573 } | 7992 } |
7993 | |
7994 @override | |
7995 void handleTypeLiteralConstantCompounds( | |
7996 ast.SendSet node, | |
7997 ConstantExpression constant, | |
7998 CompoundRhs rhs, | |
7999 _) { | |
8000 if (rhs.operator.kind == BinaryOperatorKind.IF_NULL) { | |
8001 handleCompoundSendSet(node); | |
8002 } else { | |
8003 handleTypeLiteralCompound(node); | |
8004 } | |
8005 } | |
8006 | |
8007 @override | |
8008 void handleTypeVariableTypeLiteralCompounds( | |
8009 ast.SendSet node, | |
8010 TypeVariableElement typeVariable, | |
8011 CompoundRhs rhs, | |
8012 _) { | |
8013 handleTypeLiteralCompound(node); | |
8014 } | |
8015 | |
8016 void handleTypeLiteralCompound(ast.SendSet node) { | |
8017 generateIsDeferredLoadedCheckOfSend(node); | |
8018 ast.Identifier selector = node.selector; | |
8019 generateThrowNoSuchMethod(node, selector.source, | |
8020 argumentNodes: node.arguments); | |
8021 } | |
8022 | |
8023 @override | |
8024 visitConstantGet( | |
sigurdm
2015/06/26 07:44:19
void return type?
Johnni Winther
2015/06/26 10:15:25
Done.
| |
8025 ast.Send node, | |
8026 ConstantExpression constant, | |
8027 _) { | |
8028 visitNode(node); | |
8029 } | |
8030 | |
8031 @override | |
8032 visitConstantInvoke( | |
sigurdm
2015/06/26 07:44:19
void return type?
Johnni Winther
2015/06/26 10:15:25
Done.
| |
8033 ast.Send node, | |
8034 ConstantExpression constant, | |
8035 ast.NodeList arguments, | |
8036 CallStructure callStreucture, | |
8037 _) { | |
8038 visitNode(node); | |
8039 } | |
8040 | |
8041 @override | |
8042 void errorInvalidAssert( | |
8043 ast.Send node, | |
8044 ast.NodeList arguments, | |
8045 _) { | |
8046 visitNode(node); | |
8047 } | |
8048 | |
8049 @override | |
8050 void errorUndefinedBinaryExpression( | |
8051 ast.Send node, | |
8052 ast.Node left, | |
8053 ast.Operator operator, | |
8054 ast.Node right, | |
8055 _) { | |
8056 visitNode(node); | |
8057 } | |
8058 | |
8059 @override | |
8060 void errorUndefinedUnaryExpression( | |
8061 ast.Send node, | |
8062 ast.Operator operator, | |
8063 ast.Node expression, | |
8064 _) { | |
8065 visitNode(node); | |
8066 } | |
7574 } | 8067 } |
7575 | 8068 |
7576 /** | 8069 /** |
7577 * Visitor that handles generation of string literals (LiteralString, | 8070 * Visitor that handles generation of string literals (LiteralString, |
7578 * StringInterpolation), and otherwise delegates to the given visitor for | 8071 * StringInterpolation), and otherwise delegates to the given visitor for |
7579 * non-literal subexpressions. | 8072 * non-literal subexpressions. |
7580 */ | 8073 */ |
7581 class StringBuilderVisitor extends ast.Visitor { | 8074 class StringBuilderVisitor extends ast.Visitor { |
7582 final SsaBuilder builder; | 8075 final SsaBuilder builder; |
7583 final ast.Node diagnosticNode; | 8076 final ast.Node diagnosticNode; |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8160 if (unaliased is TypedefType) throw 'unable to unalias $type'; | 8653 if (unaliased is TypedefType) throw 'unable to unalias $type'; |
8161 unaliased.accept(this, builder); | 8654 unaliased.accept(this, builder); |
8162 } | 8655 } |
8163 | 8656 |
8164 void visitDynamicType(DynamicType type, SsaBuilder builder) { | 8657 void visitDynamicType(DynamicType type, SsaBuilder builder) { |
8165 JavaScriptBackend backend = builder.compiler.backend; | 8658 JavaScriptBackend backend = builder.compiler.backend; |
8166 ClassElement cls = backend.findHelper('DynamicRuntimeType'); | 8659 ClassElement cls = backend.findHelper('DynamicRuntimeType'); |
8167 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); | 8660 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); |
8168 } | 8661 } |
8169 } | 8662 } |
OLD | NEW |