added copy() method to Instruction
This commit is contained in:
+7
@@ -50,4 +50,11 @@ public abstract class AbstractJumpInstruction extends InstructionImpl {
|
||||
public void setResolvedTarget(Instruction resolvedTarget) {
|
||||
this.resolvedTarget = outgoingEdgeTo(resolvedTarget);
|
||||
}
|
||||
|
||||
abstract AbstractJumpInstruction copy(@NotNull Label newLabel);
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return copy(targetLabel);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -71,4 +71,9 @@ public class ConditionalJumpInstruction extends AbstractJumpInstruction {
|
||||
String instr = onTrue ? "jt" : "jf";
|
||||
return instr + "(" + getTargetLabel().getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
AbstractJumpInstruction copy(@NotNull Label newLabel) {
|
||||
return new ConditionalJumpInstruction(onTrue, newLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,4 +66,6 @@ public abstract class InstructionImpl implements Instruction {
|
||||
public boolean isDead() {
|
||||
return isDead;
|
||||
}
|
||||
|
||||
public abstract Instruction copy();
|
||||
}
|
||||
|
||||
+5
@@ -71,4 +71,9 @@ public class LocalDeclarationInstruction extends InstructionWithNext {
|
||||
public String toString() {
|
||||
return "d" + "(" + element.getText() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new LocalDeclarationInstruction((JetDeclaration) element, body);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -88,4 +88,9 @@ public class NondeterministicJumpInstruction extends InstructionImpl{
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new NondeterministicJumpInstruction(getTargetLabels());
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -37,4 +37,9 @@ public class ReadUnitValueInstruction extends InstructionWithNext {
|
||||
public String toString() {
|
||||
return "read (Unit)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new ReadUnitValueInstruction((JetExpression) element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,9 @@ public class ReadValueInstruction extends InstructionWithNext {
|
||||
public String toString() {
|
||||
return "r(" + element.getText() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new ReadValueInstruction(element);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -47,4 +47,9 @@ public class ReturnNoValueInstruction extends AbstractJumpInstruction implements
|
||||
public String toString() {
|
||||
return "ret " + getTargetLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
AbstractJumpInstruction copy(@NotNull Label newLabel) {
|
||||
return new ReturnNoValueInstruction(element, newLabel);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -48,4 +48,9 @@ public class ReturnValueInstruction extends AbstractJumpInstruction implements J
|
||||
public JetElement getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
AbstractJumpInstruction copy(@NotNull Label newLabel) {
|
||||
return new ReturnValueInstruction((JetExpression) element, newLabel);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -43,4 +43,9 @@ public class SubroutineEnterInstruction extends InstructionWithNext {
|
||||
public String toString() {
|
||||
return "<START>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new SubroutineEnterInstruction(subroutine);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -59,4 +59,9 @@ public class SubroutineExitInstruction extends InstructionImpl {
|
||||
public String toString() {
|
||||
return debugLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new SubroutineExitInstruction(subroutine, debugLabel);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -53,4 +53,9 @@ public class SubroutineSinkInstruction extends InstructionImpl {
|
||||
public String toString() {
|
||||
return debugLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new SubroutineSinkInstruction(subroutine, debugLabel);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.cfg.pseudocode;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.cfg.Label;
|
||||
|
||||
/**
|
||||
@@ -38,4 +39,8 @@ public class UnconditionalJumpInstruction extends AbstractJumpInstruction {
|
||||
return "jmp(" + getTargetLabel().getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
AbstractJumpInstruction copy(@NotNull Label newLabel) {
|
||||
return new UnconditionalJumpInstruction(newLabel);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -37,4 +37,9 @@ public class UnsupportedElementInstruction extends InstructionWithNext {
|
||||
public String toString() {
|
||||
return "unsupported(" + element + " : " + element.getText() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new UnsupportedElementInstruction(element);
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -47,4 +47,12 @@ public class VariableDeclarationInstruction extends InstructionWithNext {
|
||||
public String toString() {
|
||||
return "v(" + element.getText() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
if (element instanceof JetParameter) {
|
||||
return new VariableDeclarationInstruction((JetParameter) element);
|
||||
}
|
||||
return new VariableDeclarationInstruction((JetVariableDeclaration) element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,4 +50,9 @@ public class WriteValueInstruction extends InstructionWithNext {
|
||||
}
|
||||
return "w(" + lValue.getText() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction copy() {
|
||||
return new WriteValueInstruction(element, lValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user