Commit 80ee5e79 authored by Julian Kranz's avatar Julian Kranz

Jgdrr

- Continued to implement jgdrr
parent e053a4e2
......@@ -3,13 +3,13 @@ package rreil;
import rreil.linear.LinearExpression;
public class Address {
private long size;
protected long size;
public long getSize() {
return size;
}
private LinearExpression address;
protected LinearExpression address;
public LinearExpression getAddress() {
return address;
......@@ -19,4 +19,9 @@ public class Address {
this.size = size;
this.address = address;
}
@Override
public String toString() {
return address + ":" + size;
}
}
......@@ -3,13 +3,13 @@ package rreil;
import rreil.id.Id;
public class Variable {
private Id id;
protected Id id;
public Id getId() {
return id;
}
private long offset;
protected long offset;
public long getOffset() {
return offset;
......@@ -19,4 +19,9 @@ public class Variable {
this.id = id;
this.offset = offset;
}
@Override
public String toString() {
return id + "@" + offset;
}
}
package rreil.id;
public class Id {
public abstract class Id {
}
package rreil.id;
public class VirtualEqualsId extends Id {
@Override
public String toString() {
return "[Virtual Equals]";
}
}
package rreil.id;
public class VirtualEqualsNotId extends Id {
@Override
public String toString() {
return "[Virtual Equals Not]";
}
}
package rreil.id;
public class VirtualLessOrEqualSignedId extends Id {
@Override
public String toString() {
return "[Virtual Less Or Equal Signed]";
}
}
package rreil.id;
public class VirtualLessOrEqualUnsignedId extends Id {
@Override
public String toString() {
return "[Virtual Less Or Equal Unsigned]";
}
}
package rreil.id;
public class VirtualLessSignedId extends Id {
@Override
public String toString() {
return "[Virtual Less Signed]";
}
}
package rreil.id;
public class VirtualLessUnsignedId extends Id {
@Override
public String toString() {
return "[Virtual Less Unsigned]";
}
}
package rreil.id;
public class VirtualTemporaryId extends Id {
private long id;
protected long id;
public long getId() {
return id;
......@@ -10,4 +10,9 @@ public class VirtualTemporaryId extends Id {
public VirtualTemporaryId(long id) {
this.id = id;
}
@Override
public String toString() {
return "t" + id;
}
}
......@@ -6,4 +6,9 @@ public class LinearAdditionExpression extends LinearBinaryExpression {
LinearExpression operand2) {
super(operand1, operand2);
}
@Override
protected String getOperatorString() {
return "+";
}
}
package rreil.linear;
public class LinearBinaryExpression extends LinearExpression {
private LinearExpression operand1;
public abstract class LinearBinaryExpression extends LinearExpression {
protected LinearExpression operand1;
public LinearExpression getOperand1() {
return operand1;
}
private LinearExpression operand2;
protected LinearExpression operand2;
public LinearExpression getOperand2() {
return operand2;
......@@ -17,4 +17,11 @@ public class LinearBinaryExpression extends LinearExpression {
this.operand1 = operand1;
this.operand2 = operand2;
}
protected abstract String getOperatorString();
@Override
public String toString() {
return "(" + operand1 + " " + getOperatorString() + " " + ")";
}
}
package rreil.linear;
public class LinearImmediateExpression extends LinearExpression {
private long immediate;
protected long immediate;
public long getImmediate() {
return immediate;
......@@ -10,4 +10,9 @@ public class LinearImmediateExpression extends LinearExpression {
public LinearImmediateExpression(long immediate) {
this.immediate = immediate;
}
@Override
public String toString() {
return Long.toString(immediate);
}
}
package rreil.linear;
public class LinearScaleExpression extends LinearExpression {
private long immediate;
protected long immediate;
public long getImmediate() {
return immediate;
}
private LinearExpression operand;
protected LinearExpression operand;
public LinearExpression getOperand1() {
return operand;
......@@ -17,4 +17,9 @@ public class LinearScaleExpression extends LinearExpression {
this.immediate = immediate;
this.operand = operand;
}
@Override
public String toString() {
return immediate + "*" + operand;
}
}
......@@ -7,4 +7,8 @@ public class LinearSubtractionExpression extends LinearBinaryExpression {
super(operand1, operand2);
}
@Override
protected String getOperatorString() {
return "-";
}
}
......@@ -3,7 +3,7 @@ package rreil.linear;
import rreil.Variable;
public class LinearVariableExpression extends LinearExpression {
private Variable variable;
protected Variable variable;
public Variable getVariable() {
return variable;
......@@ -12,4 +12,9 @@ public class LinearVariableExpression extends LinearExpression {
public LinearVariableExpression(Variable variable) {
this.variable = variable;
}
@Override
public String toString() {
return variable.toString();
}
}
......@@ -8,4 +8,9 @@ public class AndOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " &:" + size + " + operand2";
}
}
......@@ -5,4 +5,9 @@ public class ArbitraryOperation extends Operation {
public ArbitraryOperation(long size) {
super(size);
}
@Override
public String toString() {
return "arbitrary:" + size;
}
}
......@@ -3,13 +3,13 @@ package rreil.operation;
import rreil.linear.LinearExpression;
public abstract class BinaryOperation extends Operation {
private LinearExpression operand1;
protected LinearExpression operand1;
public LinearExpression getOperand1() {
return operand1;
}
private LinearExpression operand2;
protected LinearExpression operand2;
public LinearExpression getOperand2() {
return operand2;
......
......@@ -8,4 +8,9 @@ public class CompareEqualOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " ==:" + size + " + operand2";
}
}
......@@ -8,4 +8,8 @@ public class CompareLesOrEqualSignedOperation extends BinaryOperation {
LinearExpression operand1, LinearExpression operand2) {
super(size, operand1, operand2);
}
public String toString() {
return operand1 + " <=s:" + size + " + operand2";
}
}
......@@ -8,4 +8,8 @@ public class CompareLessOrEqualUnsignedOperation extends BinaryOperation {
LinearExpression operand1, LinearExpression operand2) {
super(size, operand1, operand2);
}
public String toString() {
return operand1 + " <=u:" + size + " + operand2";
}
}
......@@ -8,4 +8,8 @@ public class CompareLessSignedOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
public String toString() {
return operand1 + " <s:" + size + " + operand2";
}
}
......@@ -8,4 +8,8 @@ public class CompareLessUnsignedOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
public String toString() {
return operand1 + " <u:" + size + " + operand2";
}
}
......@@ -8,4 +8,8 @@ public class CompareNotEqualOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
public String toString() {
return operand1 + " !=:" + size + " + operand2";
}
}
......@@ -8,4 +8,8 @@ public class DivisionOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
public String toString() {
return operand1 + " /u:" + size + " + operand2";
}
}
......@@ -3,13 +3,13 @@ package rreil.operation;
import rreil.linear.LinearExpression;
public abstract class ExtendOperation extends Operation {
private long fromsize;
protected long fromsize;
public long getfromsize() {
return fromsize;
}
private LinearExpression operand1;
protected LinearExpression operand1;
public LinearExpression getOperand1() {
return operand1;
......@@ -21,4 +21,10 @@ public abstract class ExtendOperation extends Operation {
this.fromsize = fromsize;
this.operand1 = operand1;
}
public abstract String getSignedUnsignedString();
public String toString() {
return getSignedUnsignedString() + "x:[" + fromsize + "=>" + size + "] " + operand1;
}
}
......@@ -7,4 +7,9 @@ public class LinearOperation extends UnaryOperation {
public LinearOperation(long size, LinearExpression operand1) {
super(size, operand1);
}
@Override
public String toString() {
return "lin:" + size + " " + operand1;
}
}
......@@ -8,4 +8,9 @@ public class ModuloOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " %:" + size + " + operand2";
}
}
......@@ -8,4 +8,9 @@ public class MultiplicationOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " *:" + size + " + operand2";
}
}
package rreil.operation;
public abstract class Operation {
private long size;
protected long size;
public long getSize() {
return size;
......
......@@ -8,4 +8,9 @@ public class OrOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " |:" + size + " + operand2";
}
}
......@@ -8,4 +8,9 @@ public class ShiftLeftOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " <<:" + size + " + operand2";
}
}
......@@ -8,4 +8,9 @@ public class ShiftRightOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " >>u:" + size + " + operand2";
}
}
......@@ -8,4 +8,9 @@ public class ShiftRightSignedOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " >>s:" + size + " + operand2";
}
}
......@@ -8,4 +8,9 @@ public class SignExtendOperation extends ExtendOperation {
LinearExpression operand1) {
super(size, fromsize, operand1);
}
@Override
public String getSignedUnsignedString() {
return "s";
}
}
......@@ -8,4 +8,9 @@ public class SignedDivisionOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " /s:" + size + " + operand2";
}
}
......@@ -3,7 +3,7 @@ package rreil.operation;
import rreil.linear.LinearExpression;
public abstract class UnaryOperation extends Operation {
private LinearExpression operand1;
protected LinearExpression operand1;
public LinearExpression getOperand1() {
return operand1;
......
......@@ -8,4 +8,9 @@ public class XorOperation extends BinaryOperation {
LinearExpression operand2) {
super(size, operand1, operand2);
}
@Override
public String toString() {
return operand1 + " ^:" + size + " + operand2";
}
}
......@@ -8,4 +8,9 @@ public class ZeroExtendOperation extends ExtendOperation {
LinearExpression operand1) {
super(size, fromsize, operand1);
}
@Override
public String getSignedUnsignedString() {
return "z";
}
}
package rreil.statement;
import rreil.Variable;
import rreil.operation.Operation;
public class AssignStatement extends Statement {
protected Variable lhs;
public Variable getLhs() {
return lhs;
}
protected Operation rhs;
public Operation getRhs() {
return rhs;
}
public AssignStatement(Variable lhs, Operation rhs) {
this.lhs = lhs;
this.rhs = rhs;
}
@Override
public String toString() {
return lhs + " = " + rhs;
}
}
package rreil.statement;
import rreil.Address;
import rreil.BranchHint;
public class BranchStatement extends Statement {
protected BranchHint hint;
public BranchHint getHint() {
return hint;
}
protected Address target;
public Address getTarget() {
return target;
}
public BranchStatement(BranchHint hint, Address target) {
this.hint = hint;
this.target = target;
}
@Override
public String toString() {
return "goto[" + hint + "] " + target;
}
}
package rreil.statement;
import rreil.Address;
import rreil.linear.LinearExpression;
public class ConditionalBranchStatement extends Statement {
protected LinearExpression condition;
public LinearExpression getCondition() {
return condition;
}
protected Address targetTrue;
public Address getTargetTrue() {
return targetTrue;
}
protected Address targetFalse;
public Address getTargetFalse() {
return targetFalse;
}
public ConditionalBranchStatement(LinearExpression condition,
Address targetTrue, Address targetFalse) {
this.condition = condition;
this.targetTrue = targetTrue;
this.targetFalse = targetFalse;
}
}
package rreil.statement;
import java.util.ArrayList;
import rreil.linear.LinearExpression;
public class IfThenElseStatement extends Statement {
protected LinearExpression condition;
public LinearExpression getCondition() {
return condition;
}
protected ArrayList<Statement> thenBranch;
public ArrayList<Statement> getThenBranch() {
return thenBranch;
}
protected ArrayList<Statement> elseBranch;
public ArrayList<Statement> getElseBranch() {
return elseBranch;
}
public IfThenElseStatement(LinearExpression condition,
ArrayList<Statement> thenBranch, ArrayList<Statement> elseBranch) {
this.condition = condition;
this.thenBranch = thenBranch;
this.elseBranch = elseBranch;
}
}
package rreil.statement;
import rreil.Address;
import rreil.Variable;
public class LoadStatement extends Statement {
protected Variable lhs;
public Variable getLhs() {
return lhs;
}
protected long size;
public long getSize() {
return size;
}
protected Address address;
public Address getAddress() {
return address;
}
public LoadStatement(Variable lhs, long size, Address address) {
this.lhs = lhs;
this.size = size;
this.address = address;
}
}
package rreil.statement;
import rreil.Address;
import rreil.operation.Operation;
public class StoreStatement extends Statement {
protected Address address;
public Address getAddress() {
return address;
}
protected Operation rhs;
public Operation getRhs() {
return rhs;
}
public StoreStatement(Address address, Operation rhs) {
this.address = address;
this.rhs = rhs;
}
}
package rreil.statement;
import java.util.ArrayList;
import rreil.linear.LinearExpression;
public class WhileStatement extends Statement {
protected LinearExpression condition;
public LinearExpression getCondition() {
return condition;
}
protected ArrayList<Statement> body;