Commit 489d7ad3 authored by Julian Kranz's avatar Julian Kranz

RReil: sem_op => sem_expr

RReil: Moved sem_prim to sem_stmt
RReil: SEM_LIN / SEM_CMP => SEM_SEXPR in sem_expr
parent 85c62112
......@@ -7,10 +7,10 @@ import rreil.ILimitedVariable;
import rreil.IRReilBuilder;
import rreil.IRReilCollection;
import rreil.IVariable;
import rreil.expression.ICompare;
import rreil.expression.IExpression;
import rreil.id.IId;
import rreil.linear.ILinearExpression;
import rreil.operation.ICompareOperation;
import rreil.operation.IOperation;
import rreil.sexpression.ISimpleExpression;
import rreil.statement.IStatement;
......@@ -368,7 +368,7 @@ public class NativeInterface {
}
private Object sem_sexpr_cmp(Object _this) {
return builder.sem_sexpr_lin((ILinearExpression) _this);
return builder.sem_sexpr_cmp((ICompare) _this);
}
/*
......@@ -409,8 +409,8 @@ public class NativeInterface {
* sem_expr
*/
private Object sem_lin(Object size, Object opnd1) {
return builder.sem_lin((Long) size, (ILinearExpression) opnd1);
private Object sem_sexpr(Object size, Object opnd1) {
return builder.sem_sexpr((Long) size, (ISimpleExpression) opnd1);
}
private Object sem_mul(Object size, Object opnd1, Object opnd2) {
......@@ -473,10 +473,6 @@ public class NativeInterface {
(ILinearExpression) opnd1);
}
private Object sem_cmp(Object _this) {
return builder.sem_cmp((ICompareOperation) _this);
}
private Object sem_arb(Object size) {
return builder.sem_arb((Long) size);
}
......@@ -524,7 +520,7 @@ public class NativeInterface {
*/
private Object sem_assign(Object lhs, Object rhs) {
return builder.sem_assign((IVariable) lhs, (IOperation) rhs);
return builder.sem_assign((IVariable) lhs, (IExpression) rhs);
}
private Object sem_load(Object lhs, Object size, Object address) {
......@@ -533,7 +529,7 @@ public class NativeInterface {
}
private Object sem_store(Object address, Object rhs) {
return builder.sem_store((IAddress) address, (IOperation) rhs);
return builder.sem_store((IAddress) address, (IExpression) rhs);
}
@SuppressWarnings("unchecked")
......
......@@ -476,8 +476,8 @@ static obj_t sem_cmpltu(state_t state, int_t size, obj_t opnd1, obj_t opnd2) {
}
// sem_expr
static obj_t sem_lin(state_t state, int_t size, obj_t opnd1) {
jobject ret = java_method_call(state, "sem_lin", 2, java_long_create(state, (long int)size), (jobject)opnd1);
static obj_t sem_sexpr(state_t state, int_t size, obj_t opnd1) {
jobject ret = java_method_call(state, "sem_sexpr", 2, java_long_create(state, (long int)size), (jobject)opnd1);
return (obj_t)ret;
}
static obj_t sem_mul(state_t state, int_t size, obj_t opnd1, obj_t opnd2) {
......@@ -540,10 +540,6 @@ static obj_t sem_zx(state_t state, int_t size, int_t fromsize, obj_t opnd1) {
java_long_create(state, (long int)fromsize), (jobject)opnd1);
return (obj_t)ret;
}
static obj_t sem_cmp(state_t state, obj_t this) {
jobject ret = java_method_call(state, "sem_cmp", 1, (jobject)this);
return (obj_t)ret;
}
static obj_t sem_arb(state_t state, int_t size) {
jobject ret = java_method_call(state, "sem_arb", 1, java_long_create(state, (long int)size));
return (obj_t)ret;
......@@ -733,7 +729,7 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject
};
unboxed_sem_expr_callbacks_t sem_expr_callbacks = {
.sem_lin = &sem_lin,
.sem_sexpr = &sem_sexpr,
.sem_mul = &sem_mul,
.sem_div = &sem_div,
.sem_divs = &sem_divs,
......@@ -746,7 +742,6 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject
.sem_xor = &sem_xor,
.sem_sx = &sem_sx,
.sem_zx = &sem_zx,
.sem_cmp = &sem_cmp,
.sem_arb = &sem_arb
};
......
package rreil;
import rreil.expression.ICompare;
import rreil.expression.IExpression;
import rreil.id.IId;
import rreil.linear.ILinearExpression;
import rreil.operation.ICompareOperation;
import rreil.operation.IOperation;
import rreil.sexpression.ISimpleExpression;
import rreil.statement.IStatement;
......@@ -178,73 +178,71 @@ public interface IRReilBuilder {
ISimpleExpression sem_sexpr_lin(ILinearExpression _this);
ISimpleExpression sem_sexpr_cmp(ICompareOperation _this);
ISimpleExpression sem_sexpr_cmp(ICompare _this);
/*
* sem_op_cmp
*/
ICompareOperation sem_cmpeq(long size, ILinearExpression opnd1,
ICompare sem_cmpeq(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
ICompareOperation sem_cmpneq(long size, ILinearExpression opnd1,
ICompare sem_cmpneq(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
ICompareOperation sem_cmples(long size, ILinearExpression opnd1,
ICompare sem_cmples(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
ICompareOperation sem_cmpleu(long size, ILinearExpression opnd1,
ICompare sem_cmpleu(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
ICompareOperation sem_cmplts(long size, ILinearExpression opnd1,
ICompare sem_cmplts(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
ICompareOperation sem_cmpltu(long size, ILinearExpression opnd1,
ICompare sem_cmpltu(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
/*
* sem_expr
*/
IOperation sem_lin(long size, ILinearExpression opnd1);
IExpression sem_sexpr(long size, ISimpleExpression opnd1);
IOperation sem_mul(long size, ILinearExpression opnd1,
IExpression sem_mul(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_div(long size, ILinearExpression opnd1,
IExpression sem_div(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_divs(long size, ILinearExpression opnd1,
IExpression sem_divs(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_mod(long size, ILinearExpression opnd1,
IExpression sem_mod(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_shl(long size, ILinearExpression opnd1,
IExpression sem_shl(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_shr(long size, ILinearExpression opnd1,
IExpression sem_shr(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_shrs(long size, ILinearExpression opnd1,
IExpression sem_shrs(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_and(long size, ILinearExpression opnd1,
IExpression sem_and(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_or(long size, ILinearExpression opnd1,
IExpression sem_or(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_xor(long size, ILinearExpression opnd1,
IExpression sem_xor(long size, ILinearExpression opnd1,
ILinearExpression opnd2);
IOperation sem_sx(long size, long fromsize, ILinearExpression opnd1);
IExpression sem_sx(long size, long fromsize, ILinearExpression opnd1);
IOperation sem_zx(long size, long fromsize, ILinearExpression opnd1);
IExpression sem_zx(long size, long fromsize, ILinearExpression opnd1);
IOperation sem_cmp(ICompareOperation _this);
IOperation sem_arb(long size);
IExpression sem_arb(long size);
/*
* sem_varl
......@@ -274,11 +272,11 @@ public interface IRReilBuilder {
* sem_stmt
*/
IStatement sem_assign(IVariable lhs, IOperation rhs);
IStatement sem_assign(IVariable lhs, IExpression rhs);
IStatement sem_load(IVariable lhs, long size, IAddress address);
IStatement sem_store(IAddress address, IOperation rhs);
IStatement sem_store(IAddress address, IExpression rhs);
IStatement sem_ite(ISimpleExpression cond, IRReilCollection<IStatement> then_branch,
IRReilCollection<IStatement> else_branch);
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class AndOperation extends BinaryOperation {
public class And extends Binary {
public AndOperation(long size, LinearExpression operand1,
public And(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
public class ArbitraryOperation extends Operation {
public class Arbitrary extends Expression {
public ArbitraryOperation(long size) {
public Arbitrary(long size) {
super(size);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public abstract class BinaryOperation extends Operation {
public abstract class Binary extends Expression {
protected LinearExpression operand1;
public LinearExpression getOperand1() {
......@@ -15,7 +15,7 @@ public abstract class BinaryOperation extends Operation {
return operand2;
}
public BinaryOperation(long size, LinearExpression operand1,
public Binary(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size);
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public abstract class CompareOperation extends BinaryOperation implements ICompareOperation {
public abstract class Compare extends Binary implements ICompare {
public CompareOperation(long size, LinearExpression operand1,
public Compare(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class CompareEqualOperation extends CompareOperation {
public class CompareEqual extends Compare {
public CompareEqualOperation(long size, LinearExpression operand1,
public CompareEqual(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class CompareLessOrEqualSignedOperation extends CompareOperation {
public class CompareLessOrEqualSigned extends Compare {
public CompareLessOrEqualSignedOperation(long size,
public CompareLessOrEqualSigned(long size,
LinearExpression operand1, LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class CompareLessOrEqualUnsignedOperation extends CompareOperation {
public class CompareLessOrEqualUnsigned extends Compare {
public CompareLessOrEqualUnsignedOperation(long size,
public CompareLessOrEqualUnsigned(long size,
LinearExpression operand1, LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class CompareLessSignedOperation extends CompareOperation {
public class CompareLessSigned extends Compare {
public CompareLessSignedOperation(long size, LinearExpression operand1,
public CompareLessSigned(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class CompareLessUnsignedOperation extends CompareOperation {
public class CompareLessUnsigned extends Compare {
public CompareLessUnsignedOperation(long size, LinearExpression operand1,
public CompareLessUnsigned(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class CompareNotEqualOperation extends CompareOperation {
public class CompareNotEqual extends Compare {
public CompareNotEqualOperation(long size, LinearExpression operand1,
public CompareNotEqual(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class DivisionOperation extends BinaryOperation {
public class Division extends Binary {
public DivisionOperation(long size, LinearExpression operand1,
public Division(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
public abstract class Operation implements IOperation {
public abstract class Expression implements IExpression {
protected long size;
public long getSize() {
return size;
}
public Operation(long size) {
public Expression(long size) {
this.size = size;
}
}
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public abstract class ExtendOperation extends Operation {
public abstract class Extend extends Expression {
protected long fromsize;
public long getfromsize() {
......@@ -15,7 +15,7 @@ public abstract class ExtendOperation extends Operation {
return operand1;
}
public ExtendOperation(long size, long fromsize, LinearExpression operand1) {
public Extend(long size, long fromsize, LinearExpression operand1) {
super(size);
this.fromsize = fromsize;
......
package rreil.expression;
public interface ICompare extends IExpression {
}
package rreil.expression;
public interface IExpression {
}
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class ModuloOperation extends BinaryOperation {
public class Modulo extends Binary {
public ModuloOperation(long size, LinearExpression operand1,
public Modulo(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class MultiplicationOperation extends BinaryOperation {
public class Multiplication extends Binary {
public MultiplicationOperation(long size, LinearExpression operand1,
public Multiplication(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class OrOperation extends BinaryOperation {
public class Or extends Binary {
public OrOperation(long size, LinearExpression operand1,
public Or(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class ShiftLeftOperation extends BinaryOperation {
public class ShiftLeft extends Binary {
public ShiftLeftOperation(long size, LinearExpression operand1,
public ShiftLeft(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class ShiftRightOperation extends BinaryOperation {
public class ShiftRight extends Binary {
public ShiftRightOperation(long size, LinearExpression operand1,
public ShiftRight(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class ShiftRightSignedOperation extends BinaryOperation {
public class ShiftRightSigned extends Binary {
public ShiftRightSignedOperation(long size, LinearExpression operand1,
public ShiftRightSigned(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class SignExtendOperation extends ExtendOperation {
public class SignExtend extends Extend {
public SignExtendOperation(long size, long fromsize,
public SignExtend(long size, long fromsize,
LinearExpression operand1) {
super(size, fromsize, operand1);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class SignedDivisionOperation extends BinaryOperation {
public class SignedDivision extends Binary {
public SignedDivisionOperation(long size, LinearExpression operand1,
public SignedDivision(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.expression;
import rreil.sexpression.SimpleExpression;
public class Simple extends Expression {
SimpleExpression operand1;
public SimpleExpression getSexpr() {
return operand1;
}
public Simple(long size, SimpleExpression operand1) {
super(size);
this.operand1 = operand1;
}
@Override
public String toString() {
return "sexpr:" + size + " " + operand1;
}
}
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public abstract class UnaryOperation extends Operation {
public abstract class Unary extends Expression {
protected LinearExpression operand1;
public LinearExpression getOperand1() {
return operand1;
}
public UnaryOperation(long size, LinearExpression operand1) {
public Unary(long size, LinearExpression operand1) {
super(size);
this.operand1 = operand1;
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class XorOperation extends BinaryOperation {
public class Xor extends Binary {
public XorOperation(long size, LinearExpression operand1,
public Xor(long size, LinearExpression operand1,
LinearExpression operand2) {
super(size, operand1, operand2);
}
......
package rreil.operation;
package rreil.expression;
import rreil.linear.LinearExpression;
public class ZeroExtendOperation extends ExtendOperation {
public class ZeroExtend extends Extend {
public ZeroExtendOperation(long size, long fromsize,
public ZeroExtend(long size, long fromsize,
LinearExpression operand1) {
super(size, fromsize, operand1);
}
......
package rreil.operation;
public interface ICompareOperation extends IOperation {
}
package rreil.operation;
public interface IOperation {
}
package rreil.operation;
import rreil.linear.LinearExpression;
public class LinearOperation extends UnaryOperation {
public LinearOperation(long size, LinearExpression operand1) {
super(size, operand1);
}
@Override
public String toString() {
return "lin:" + size + " " + operand1;
}
}
package rreil.sexpression;
import rreil.operation.CompareOperation;
import rreil.expression.Compare;
public class SimpleCompareExpression extends SimpleExpression {
protected CompareOperation _this;
protected Compare _this;
public CompareOperation getThis() {
public Compare getThis() {
return _this;
}
public SimpleCompareExpression(CompareOperation _this) {
public SimpleCompareExpression(Compare _this) {
this._this = _this;
}
......
package rreil.statement;
import rreil.Variable;
import rreil.operation.Operation;
import rreil.expression.Expression;
public class AssignStatement extends Statement {
protected Variable lhs;
......@@ -10,13 +10,13 @@ public class AssignStatement extends Statement {
return lhs;
}