From 21be468e6cdfb086c839d1fbf7554e0e8326b710 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 25 Jun 2014 14:34:08 +0400 Subject: [PATCH] Pseudocode: Merge all access instructions into single file --- .../eval/AccessValueInstruction.kt | 40 -------------- .../eval/WriteValueInstruction.kt | 55 ------------------- ...ueInstruction.kt => accessInstructions.kt} | 49 ++++++++++++++++- 3 files changed, 47 insertions(+), 97 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/AccessValueInstruction.kt delete mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/WriteValueInstruction.kt rename compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/{ReadValueInstruction.kt => accessInstructions.kt} (62%) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/AccessValueInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/AccessValueInstruction.kt deleted file mode 100644 index 4a23137e339..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/AccessValueInstruction.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2010-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.lang.cfg.pseudocode.instructions.eval - -import org.jetbrains.jet.lang.psi.JetElement -import org.jetbrains.jet.lang.cfg.pseudocode.PseudoValue -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.LexicalScope -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionWithNext -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall -import org.jetbrains.jet.lang.descriptors.VariableDescriptor -import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind -import java.util.Collections - -public trait AccessTarget { - public data class Declaration(val descriptor: VariableDescriptor): AccessTarget - public data class Call(val resolvedCall: ResolvedCall<*>): AccessTarget - public object BlackBox: AccessTarget -} - -public abstract class AccessValueInstruction protected ( - element: JetElement, - lexicalScope: LexicalScope, - public val target: AccessTarget, - public override val receiverValues: Map -) : InstructionWithNext(element, lexicalScope), InstructionWithReceivers \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/WriteValueInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/WriteValueInstruction.kt deleted file mode 100644 index 43beda2653a..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/WriteValueInstruction.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.jet.lang.cfg.pseudocode.instructions.eval - -import org.jetbrains.jet.lang.psi.JetElement -import org.jetbrains.jet.lang.psi.JetNamedDeclaration -import java.util.Collections -import org.jetbrains.jet.lang.cfg.pseudocode.PseudoValue -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.LexicalScope -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionVisitor -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionVisitorWithResult -import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionImpl -import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue - -public class WriteValueInstruction( - assignment: JetElement, - lexicalScope: LexicalScope, - target: AccessTarget, - receiverValues: Map, - public val lValue: JetElement, - public val rValue: PseudoValue -) : AccessValueInstruction(assignment, lexicalScope, target, receiverValues) { - override val inputValues: List - get() = receiverValues.keySet() + rValue - - override fun accept(visitor: InstructionVisitor) { - visitor.visitWriteValue(this) - } - - override fun accept(visitor: InstructionVisitorWithResult): R { - return visitor.visitWriteValue(this) - } - - override fun toString(): String { - val lhs = (lValue as? JetNamedDeclaration)?.getName() ?: render(lValue) - return "w($lhs|${inputValues.makeString(", ")})" - } - - override fun createCopy(): InstructionImpl = - WriteValueInstruction(element, lexicalScope, target, receiverValues, lValue, rValue) -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/ReadValueInstruction.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/accessInstructions.kt similarity index 62% rename from compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/ReadValueInstruction.kt rename to compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/accessInstructions.kt index 4cb533a4ce8..c55a1a934dc 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/ReadValueInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/instructions/eval/accessInstructions.kt @@ -17,13 +17,30 @@ package org.jetbrains.jet.lang.cfg.pseudocode.instructions.eval import org.jetbrains.jet.lang.psi.JetElement -import org.jetbrains.jet.lang.cfg.pseudocode.PseudoValueFactory import org.jetbrains.jet.lang.cfg.pseudocode.PseudoValue import org.jetbrains.jet.lang.cfg.pseudocode.instructions.LexicalScope +import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionWithNext +import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall +import org.jetbrains.jet.lang.descriptors.VariableDescriptor +import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.jet.lang.cfg.pseudocode.PseudoValueFactory import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionVisitor import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionVisitorWithResult import org.jetbrains.jet.lang.cfg.pseudocode.instructions.InstructionImpl -import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.jet.lang.psi.JetNamedDeclaration + +public trait AccessTarget { + public data class Declaration(val descriptor: VariableDescriptor): AccessTarget + public data class Call(val resolvedCall: ResolvedCall<*>): AccessTarget + public object BlackBox: AccessTarget +} + +public abstract class AccessValueInstruction protected ( + element: JetElement, + lexicalScope: LexicalScope, + public val target: AccessTarget, + public override val receiverValues: Map +) : InstructionWithNext(element, lexicalScope), InstructionWithReceivers public class ReadValueInstruction private ( element: JetElement, @@ -74,3 +91,31 @@ public class ReadValueInstruction private ( } } } + +public class WriteValueInstruction( + assignment: JetElement, + lexicalScope: LexicalScope, + target: AccessTarget, + receiverValues: Map, + public val lValue: JetElement, + public val rValue: PseudoValue +) : AccessValueInstruction(assignment, lexicalScope, target, receiverValues) { + override val inputValues: List + get() = receiverValues.keySet() + rValue + + override fun accept(visitor: InstructionVisitor) { + visitor.visitWriteValue(this) + } + + override fun accept(visitor: InstructionVisitorWithResult): R { + return visitor.visitWriteValue(this) + } + + override fun toString(): String { + val lhs = (lValue as? JetNamedDeclaration)?.getName() ?: render(lValue) + return "w($lhs|${inputValues.makeString(", ")})" + } + + override fun createCopy(): InstructionImpl = + WriteValueInstruction(element, lexicalScope, target, receiverValues, lValue, rValue) +} \ No newline at end of file