Commit 85c62112 authored by Julian Kranz's avatar Julian Kranz

RReil: sem_op => sem_expr

RReil: Moved sem_prim to sem_stmt
parent 41e77a52
......@@ -11,7 +11,6 @@ import rreil.id.IId;
import rreil.linear.ILinearExpression;
import rreil.operation.ICompareOperation;
import rreil.operation.IOperation;
import rreil.prim.IPrim;
import rreil.sexpression.ISimpleExpression;
import rreil.statement.IStatement;
......@@ -26,10 +25,11 @@ public class NativeInterface {
this.builder = builder;
}
public IRReilCollection decodeAndTranslate(byte[] bytes) {
@SuppressWarnings("unchecked")
public IRReilCollection<IStatement> decodeAndTranslate(byte[] bytes) {
if (!backendSet)
throw new RuntimeException("Backend not set");
return (IRReilCollection) decodeAndTranslateNative(bytes);
return (IRReilCollection<IStatement>) decodeAndTranslateNative(bytes);
}
public String[] getBackends() {
......@@ -406,7 +406,7 @@ public class NativeInterface {
}
/*
* sem_op
* sem_expr
*/
private Object sem_lin(Object size, Object opnd1) {
......@@ -519,25 +519,6 @@ public class NativeInterface {
return builder.sem_flop_fmul();
}
/*
* sem_prim
*/
@SuppressWarnings("unchecked")
private Object sem_prim_generic(String op, Object res, Object args) {
return builder.sem_prim_generic(op,
(IRReilCollection<ILimitedVariable>) res,
(IRReilCollection<ILimitedVariable>) args);
}
@SuppressWarnings("unchecked")
private Object sem_prim_flop(Object op, Object flags, Object res,
Object args) {
return builder.sem_prim_flop((IFlop) op, (IVariable) flags,
(ILimitedVariable) res,
(IRReilCollection<ILimitedVariable>) args);
}
/*
* sem_stmt
*/
......@@ -555,14 +536,16 @@ public class NativeInterface {
return builder.sem_store((IAddress) address, (IOperation) rhs);
}
@SuppressWarnings("unchecked")
private Object sem_ite(Object cond, Object then_branch, Object else_branch) {
return builder.sem_ite((ISimpleExpression) cond,
(IRReilCollection) then_branch, (IRReilCollection) else_branch);
(IRReilCollection<IStatement>) then_branch, (IRReilCollection<IStatement>) else_branch);
}
@SuppressWarnings("unchecked")
private Object sem_while(Object cond, Object body) {
return builder.sem_while((ISimpleExpression) cond,
(IRReilCollection) body);
(IRReilCollection<IStatement>) body);
}
private Object sem_cbranch(Object cond, Object target_true,
......@@ -575,8 +558,19 @@ public class NativeInterface {
return builder.sem_branch((IBranchHint) branch_hint, (IAddress) target);
}
private Object sem_prim(Object prim) {
return builder.sem_prim((IPrim) prim);
@SuppressWarnings("unchecked")
private Object sem_flop_stmt(Object op, Object flags, Object lhs,
Object rhs) {
return builder.sem_flop_stmt((IFlop) op, (IVariable) flags,
(ILimitedVariable) lhs,
(IRReilCollection<ILimitedVariable>) rhs);
}
@SuppressWarnings("unchecked")
private Object sem_prim(String op, Object lhs, Object rhs) {
return builder.sem_prim(op,
(IRReilCollection<ILimitedVariable>) lhs,
(IRReilCollection<ILimitedVariable>) rhs);
}
/*
......
......@@ -475,7 +475,7 @@ static obj_t sem_cmpltu(state_t state, int_t size, obj_t opnd1, obj_t opnd2) {
return (obj_t)ret;
}
// sem_op
// 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);
return (obj_t)ret;
......@@ -586,16 +586,6 @@ static obj_t sem_flop(state_t state, int_t con) {
return (obj_t)ret;
}
// sem_prim
static obj_t sem_prim_generic(state_t state, obj_t op, obj_t res, obj_t args) {
jobject ret = java_method_call(state, "sem_prim_generic", 3, java_string_create(state, (char*)op), (jobject)res, (jobject)args);
return (obj_t)ret;
}
static obj_t sem_prim_flop(state_t state, obj_t op, obj_t flags, obj_t res, obj_t args) {
jobject ret = java_method_call(state, "sem_prim_flop", 4, (jobject)op, (jobject)flags, (jobject)res, (jobject)args);
return (obj_t)ret;
}
// sem_stmt
static obj_t sem_assign(state_t state, obj_t lhs, obj_t rhs) {
jobject ret = java_method_call(state, "sem_assign", 2, (jobject)lhs, (jobject)rhs);
......@@ -628,8 +618,12 @@ static obj_t sem_branch(state_t state, obj_t branch_hint, obj_t target) {
jobject ret = java_method_call(state, "sem_branch", 2, (jobject)branch_hint, (jobject)target);
return (obj_t)ret;
}
static obj_t sem_prim(state_t state, obj_t prim) {
jobject ret = java_method_call(state, "sem_prim", 1, (jobject)prim);
static obj_t sem_flop_stmt(state_t state, obj_t op, obj_t flags, obj_t lhs, obj_t rhs) {
jobject ret = java_method_call(state, "sem_flop_stmt", 4, (jobject)op, (jobject)flags, (jobject)lhs, (jobject)rhs);
return (obj_t)ret;
}
static obj_t sem_prim(state_t state, obj_t op, obj_t lhs, obj_t rhs) {
jobject ret = java_method_call(state, "sem_prim", 3, java_string_create(state, (char*)op), (jobject)lhs, (jobject)rhs);
return (obj_t)ret;
}
......@@ -738,7 +732,7 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject
.sem_cmpltu = &sem_cmpltu
};
unboxed_sem_op_callbacks_t sem_op_callbacks = {
unboxed_sem_expr_callbacks_t sem_expr_callbacks = {
.sem_lin = &sem_lin,
.sem_mul = &sem_mul,
.sem_div = &sem_div,
......@@ -769,11 +763,6 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject
.sem_flop_ = &sem_flop
};
unboxed_sem_prim_callbacks_t sem_prim_callbacks = {
.sem_prim_generic = &sem_prim_generic,
.sem_prim_flop = &sem_prim_flop
};
unboxed_sem_stmt_callbacks_t sem_stmt_callbacks = {
.sem_assign = &sem_assign,
.sem_load = &sem_load,
......@@ -782,6 +771,7 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject
.sem_while = &sem_while,
.sem_cbranch = &sem_cbranch,
.sem_branch = &sem_branch,
.sem_flop = &sem_flop_stmt,
.sem_prim = &sem_prim
};
......@@ -806,11 +796,10 @@ JNICALL Java_rnati_NativeInterface_decodeAndTranslateNative(JNIEnv *env, jobject
.sem_linear = &sem_linear_callbacks,
.sem_sexpr = &sem_sexpr_callbacks,
.sem_op_cmp = &sem_op_cmp_callbacks,
.sem_op = &sem_op_callbacks,
.sem_expr = &sem_expr_callbacks,
.sem_varl = &sem_varl_callbacks,
.sem_varls = &sem_varls_callbacks,
.sem_flop = &sem_flop_callbacks,
.sem_prim = &sem_prim_callbacks,
.sem_stmt = &sem_stmt_callbacks,
.branch_hint = &branch_hint_callbacks,
.sem_stmts = &sem_stmts_callbacks
......
......@@ -44,9 +44,6 @@ import rreil.operation.SignExtendOperation;
import rreil.operation.SignedDivisionOperation;
import rreil.operation.XorOperation;
import rreil.operation.ZeroExtendOperation;
import rreil.prim.FlopPrimitive;
import rreil.prim.GenericPrimitive;
import rreil.prim.IPrim;
import rreil.sexpression.ISimpleExpression;
import rreil.sexpression.SimpleCompareExpression;
import rreil.sexpression.SimpleExpression;
......@@ -54,6 +51,7 @@ import rreil.sexpression.SimpleLinearExpression;
import rreil.statement.AssignStatement;
import rreil.statement.BranchStatement;
import rreil.statement.ConditionalBranchStatement;
import rreil.statement.FlopStatement;
import rreil.statement.IStatement;
import rreil.statement.IfThenElseStatement;
import rreil.statement.LoadStatement;
......@@ -510,7 +508,7 @@ public class DefaultRReilBuilder implements IRReilBuilder {
}
/*
* sem_op
* sem_expr
*/
@Override
......@@ -652,25 +650,6 @@ public class DefaultRReilBuilder implements IRReilBuilder {
return Flop.FMUL;
}
/*
* sem_prim
*/
@Override
public IPrim sem_prim_generic(String op,
IRReilCollection<ILimitedVariable> res,
IRReilCollection<ILimitedVariable> args) {
return new GenericPrimitive(op, (DefaultLimitedVariableCollection) res,
(DefaultLimitedVariableCollection) args);
}
@Override
public IPrim sem_prim_flop(IFlop op, IVariable flags, ILimitedVariable res,
IRReilCollection<ILimitedVariable> args) {
return new FlopPrimitive((Flop) op, (Variable) flags,
(LimitedVariable) res, (DefaultLimitedVariableCollection) args);
}
/*
* sem_stmt
*/
......@@ -692,14 +671,14 @@ public class DefaultRReilBuilder implements IRReilBuilder {
@Override
public Statement sem_ite(ISimpleExpression cond,
IRReilCollection then_branch, IRReilCollection else_branch) {
IRReilCollection<IStatement> then_branch, IRReilCollection<IStatement> else_branch) {
return new IfThenElseStatement((SimpleExpression) cond,
(DefaultStatementCollection) then_branch,
(DefaultStatementCollection) else_branch);
}
@Override
public Statement sem_while(ISimpleExpression cond, IRReilCollection body) {
public Statement sem_while(ISimpleExpression cond, IRReilCollection<IStatement> body) {
return new WhileStatement((SimpleExpression) cond,
(DefaultStatementCollection) body);
}
......@@ -717,8 +696,18 @@ public class DefaultRReilBuilder implements IRReilBuilder {
}
@Override
public IStatement sem_prim(IPrim prim) {
return new PrimitiveStatement(prim);
public Statement sem_flop_stmt(IFlop op, IVariable flags, ILimitedVariable lhs,
IRReilCollection<ILimitedVariable> rhs) {
return new FlopStatement((Flop) op, (Variable) flags,
(LimitedVariable) lhs, (DefaultLimitedVariableCollection) rhs);
}
@Override
public Statement sem_prim(String op,
IRReilCollection<ILimitedVariable> lhs,
IRReilCollection<ILimitedVariable> rhs) {
return new PrimitiveStatement(op, (DefaultLimitedVariableCollection) lhs,
(DefaultLimitedVariableCollection) rhs);
}
/*
......
......@@ -4,7 +4,6 @@ import rreil.id.IId;
import rreil.linear.ILinearExpression;
import rreil.operation.ICompareOperation;
import rreil.operation.IOperation;
import rreil.prim.IPrim;
import rreil.sexpression.ISimpleExpression;
import rreil.statement.IStatement;
......@@ -204,7 +203,7 @@ public interface IRReilBuilder {
ILinearExpression opnd2);
/*
* sem_op
* sem_expr
*/
IOperation sem_lin(long size, ILinearExpression opnd1);
......@@ -271,14 +270,6 @@ public interface IRReilBuilder {
IFlop sem_flop_fmul();
/*
* sem_prim
*/
IPrim sem_prim_generic(String op, IRReilCollection<ILimitedVariable> res, IRReilCollection<ILimitedVariable> args);
IPrim sem_prim_flop(IFlop op, IVariable flags, ILimitedVariable res, IRReilCollection<ILimitedVariable> args);
/*
* sem_stmt
*/
......@@ -299,7 +290,9 @@ public interface IRReilBuilder {
IStatement sem_branch(IBranchHint branch_hint, IAddress target);
IStatement sem_prim(IPrim prim);
IStatement sem_flop_stmt(IFlop op, IVariable flags, ILimitedVariable lhs, IRReilCollection<ILimitedVariable> rhs);
IStatement sem_prim(String op, IRReilCollection<ILimitedVariable> lhs, IRReilCollection<ILimitedVariable> rhs);
/*
* sem_branch_hint
......
package rreil.prim;
import rreil.DefaultLimitedVariableCollection;
public class GenericPrimitive implements IPrim {
private String op;
public String getOp() {
return op;
}
private DefaultLimitedVariableCollection res;
public DefaultLimitedVariableCollection getRes() {
return res;
}
private DefaultLimitedVariableCollection args;
public DefaultLimitedVariableCollection getArgs() {
return args;
}
public GenericPrimitive(String op, DefaultLimitedVariableCollection res, DefaultLimitedVariableCollection args) {
this.op = op;
this.res = res;
this.args = args;
}
@Override
public String toString() {
return res + " = $" + op + " " + args;
}
}
package rreil.prim;
public interface IPrim {
}
package rreil.prim;
package rreil.statement;
import rreil.DefaultLimitedVariableCollection;
import rreil.Flop;
import rreil.LimitedVariable;
import rreil.Variable;
public class FlopPrimitive implements IPrim {
public class FlopStatement extends Statement {
private Flop flop;
public Flop getFlop() {
......@@ -18,28 +18,28 @@ public class FlopPrimitive implements IPrim {
return flags;
}
private LimitedVariable res;
private LimitedVariable lhs;
public LimitedVariable getRes() {
return res;
return lhs;
}
private DefaultLimitedVariableCollection args;
private DefaultLimitedVariableCollection rhs;
public DefaultLimitedVariableCollection getArgs() {
return args;
return rhs;
}
public FlopPrimitive(Flop flop, Variable flags, LimitedVariable res,
DefaultLimitedVariableCollection args) {
public FlopStatement(Flop flop, Variable flags, LimitedVariable lhs,
DefaultLimitedVariableCollection rhs) {
this.flop = flop;
this.flags = flags;
this.res = res;
this.args = args;
this.lhs = lhs;
this.rhs = rhs;
}
@Override
public String toString() {
return res + " = $" + flop + " " + args + " [flags:" + flags + "]";
return lhs + " = $" + flop + " " + rhs + " [flags:" + flags + "]";
}
}
package rreil.statement;
import rreil.prim.IPrim;
import rreil.DefaultLimitedVariableCollection;
public class PrimitiveStatement extends Statement implements IPrim {
private IPrim primitive;
public class PrimitiveStatement extends Statement {
private String op;
public IPrim getPrimitive() {
return primitive;
public String getOp() {
return op;
}
public PrimitiveStatement(IPrim primitive) {
this.primitive = primitive;
private DefaultLimitedVariableCollection lhs;
public DefaultLimitedVariableCollection getRes() {
return lhs;
}
private DefaultLimitedVariableCollection rhs;
public DefaultLimitedVariableCollection getArgs() {
return rhs;
}
public PrimitiveStatement(String op, DefaultLimitedVariableCollection lhs, DefaultLimitedVariableCollection rhs) {
this.op = op;
this.lhs = lhs;
this.rhs = rhs;
}
@Override
public String toString() {
return primitive.toString();
return lhs + " = $" + op + " " + rhs;
}
}
......@@ -18,7 +18,6 @@
#include <rreil/rreil_op.h>
#include <rreil/rreil_variable_limited.h>
#include <rreil/rreil_flop.h>
#include <rreil/rreil_prim.h>
#include <rreil/rreil_statement.h>
#include <rreil/rreil_branch_hint.h>
......
/*
* rreil_prim.h
*
* Created on: Sep 13, 2013
* Author: jucs
*/
#ifndef RREIL_PRIM_H_
#define RREIL_PRIM_H_
#include "rreil_variable_limited.h"
#include "rreil_prim.h"
#include "rreil_variable.h"
enum rreil_prim_type {
RREIL_PRIM_TYPE_GENERIC, RREIL_PRIM_TYPE_FLOP
};
struct rreil_prim {
enum rreil_prim_type type;
union {
struct {
char *op;
struct rreil_variable_limited_tuple *res;
struct rreil_variable_limited_tuple *args;
} generic;
struct {
enum rreil_flop *op;
struct rreil_variable *flags;
struct rreil_variable_limited *res;
struct rreil_variable_limited_tuple *args;
} flop;
};
};
#endif /* RREIL_PRIM_H_ */
......@@ -25,6 +25,7 @@ enum rreil_statement_type {
RREIL_STATEMENT_TYPE_WHILE,
RREIL_STATEMENT_TYPE_CBRANCH,
RREIL_STATEMENT_TYPE_BRANCH,
RREIL_STATEMENT_TYPE_FLOP,
RREIL_STATEMENT_TYPE_PRIM
};
......@@ -62,7 +63,17 @@ struct rreil_statement {
enum rreil_branch_hint *hint;
struct rreil_address *target;
} branch;
struct rreil_prim *prim;
struct {
enum rreil_flop *op;
struct rreil_variable *flags;
struct rreil_variable_limited *lhs;
struct rreil_variable_limited_tuple *rhs;
} flop;
struct {
char *op;
struct rreil_variable_limited_tuple *lhs;
struct rreil_variable_limited_tuple *rhs;
} prim;
};
};
......
......@@ -166,24 +166,6 @@ void rreil_flop_free(enum rreil_flop *flop) {
free(flop);
}
void rreil_prim_free(struct rreil_prim *prim) {
switch(prim->type) {
case RREIL_PRIM_TYPE_GENERIC: {
//prim->generic.op: allocated on GDSL heap
rreil_variable_limited_tuple_free(prim->generic.res);
rreil_variable_limited_tuple_free(prim->generic.args);
break;
}
case RREIL_PRIM_TYPE_FLOP: {
rreil_flop_free(prim->flop.op);
rreil_variable_free(prim->flop.flags);
rreil_variable_limited_free(prim->flop.res);
rreil_variable_limited_tuple_free(prim->flop.args);
}
}
free(prim);
}
void rreil_statement_free(struct rreil_statement *statement) {
switch (statement->type) {
case RREIL_STATEMENT_TYPE_ASSIGN: {
......@@ -223,8 +205,17 @@ void rreil_statement_free(struct rreil_statement *statement) {
rreil_address_free(statement->branch.target);
break;
}
case RREIL_STATEMENT_TYPE_FLOP: {
rreil_flop_free(statement->flop.op);
rreil_variable_free(statement->flop.flags);
rreil_variable_limited_free(statement->flop.lhs);
rreil_variable_limited_tuple_free(statement->flop.rhs);
break;
}
case RREIL_STATEMENT_TYPE_PRIM: {
rreil_prim_free(statement->prim);
//prim->generic.op: allocated on GDSL heap
rreil_variable_limited_tuple_free(statement->prim.lhs);
rreil_variable_limited_tuple_free(statement->prim.rhs);
break;
}
}
......
......@@ -398,25 +398,6 @@ static obj_t sem_flop(state_t state, int_t con) {
return (obj_t)rreil_flop;
}
// sem_prim
static obj_t sem_prim_generic(state_t state, obj_t op, obj_t res, obj_t args) {
struct rreil_prim *prim = (struct rreil_prim*)malloc(sizeof(struct rreil_prim));
prim->type = RREIL_PRIM_TYPE_GENERIC;
prim->generic.op = (char*)op;
prim->generic.res = (struct rreil_variable_limited_tuple*)res;
prim->generic.args = (struct rreil_variable_limited_tuple*)args;
return (obj_t)prim;
}
static obj_t sem_prim_flop(state_t state, obj_t op, obj_t flags, obj_t res, obj_t args) {
struct rreil_prim *prim = (struct rreil_prim*)malloc(sizeof(struct rreil_prim));
prim->type = RREIL_PRIM_TYPE_FLOP;
prim->flop.op = (enum rreil_flop*)op;
prim->flop.flags = (struct rreil_variable*)flags;
prim->flop.res = (struct rreil_variable_limited*)res;
prim->flop.args = (struct rreil_variable_limited_tuple*)args;
return (obj_t)prim;
}
// sem_stmt
static obj_t sem_assign(state_t state, obj_t lhs,
obj_t rhs) {
......@@ -484,12 +465,23 @@ static obj_t sem_branch(state_t state,
statement->branch.target = (struct rreil_address*)target;
return (obj_t)statement;
}
static obj_t sem_prim(state_t state,
obj_t prim) {
static obj_t sem_flop_stmt(state_t state, obj_t op, obj_t flags, obj_t lhs, obj_t rhs) {
struct rreil_statement *statement = (struct rreil_statement*)malloc(
sizeof(struct rreil_statement));
statement->type = RREIL_STATEMENT_TYPE_FLOP;
statement->flop.op = (enum rreil_flop*)op;
statement->flop.flags = (struct rreil_variable*)flags;
statement->flop.lhs = (struct rreil_variable_limited*)lhs;
statement->flop.rhs = (struct rreil_variable_limited_tuple*)rhs;
return (obj_t)statement;
}
static obj_t sem_prim(state_t state, obj_t op, obj_t lhs, obj_t rhs) {
struct rreil_statement *statement = (struct rreil_statement*)malloc(
sizeof(struct rreil_statement));
statement->type = RREIL_STATEMENT_TYPE_PRIM;
statement->prim = (struct rreil_prim*)prim;
statement->prim.op = (char*)op;
statement->prim.lhs = (struct rreil_variable_limited_tuple*)lhs;
statement->prim.rhs = (struct rreil_variable_limited_tuple*)rhs;
return (obj_t)statement;
}
......@@ -606,11 +598,6 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
.sem_flop_ = &sem_flop
};
unboxed_sem_prim_callbacks_t sem_prim_callbacks = {
.sem_prim_generic = &sem_prim_generic,
.sem_prim_flop = &sem_prim_flop
};
unboxed_sem_stmt_callbacks_t sem_stmt_callbacks = {
.sem_assign = &sem_assign,
.sem_load = &sem_load,
......@@ -619,6 +606,7 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
.sem_while = &sem_while,
.sem_cbranch = &sem_cbranch,
.sem_branch = &sem_branch,
.sem_flop = &sem_flop_stmt,
.sem_prim = &sem_prim
};
......@@ -649,7 +637,6 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
unboxed_sem_varl_callbacks_t sem_varl_callbacks;
unboxed_sem_varls_callbacks_t sem_varls_callbacks;
unboxed_sem_flop_callbacks_t sem_flop_callbacks;
unboxed_sem_prim_callbacks_t sem_prim_callbacks;
unboxed_sem_stmt_callbacks_t sem_stmt_callbacks;
unboxed_branch_hint_callbacks_t branch_hint_callbacks;
unboxed_sem_stmts_callbacks_t sem_stmts_callbacks;
......@@ -666,7 +653,6 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
callbacks_heap->sem_varl_callbacks = sem_varl_callbacks;
callbacks_heap->sem_varls_callbacks = sem_varls_callbacks;
callbacks_heap->sem_flop_callbacks = sem_flop_callbacks;
callbacks_heap->sem_prim_callbacks = sem_prim_callbacks;
callbacks_heap->sem_stmt_callbacks = sem_stmt_callbacks;
callbacks_heap->branch_hint_callbacks = branch_hint_callbacks;
callbacks_heap->sem_stmts_callbacks = sem_stmts_callbacks;
......@@ -682,7 +668,6 @@ callbacks_t rreil_gdrr_builder_callbacks_get(state_t state) {
.sem_varl = &callbacks_heap->sem_varl_callbacks,
.sem_varls = &callbacks_heap->sem_varls_callbacks,
.sem_flop = &callbacks_heap->sem_flop_callbacks,
.sem_prim = &callbacks_heap->sem_prim_callbacks,
.sem_stmt = &callbacks_heap->sem_stmt_callbacks,
.branch_hint = &callbacks_heap->branch_hint_callbacks,
.sem_stmts = &callbacks_heap->sem_stmts_callbacks
......
......@@ -283,28 +283,6 @@ void rreil_flop_print(FILE *stream, enum rreil_flop *flop) {
}
}
void rreil_prim_print(FILE *stream, struct rreil_prim *prim) {
switch(prim->type) {
case RREIL_PRIM_TYPE_GENERIC: {
rreil_varls_print(stream, prim->generic.res);
fprintf(stream, " = $%s ", prim->generic.op);
rreil_varls_print(stream, prim->generic.args);
break;
}
case RREIL_PRIM_TYPE_FLOP: {
rreil_varl_print(stream, prim->flop.res);
fprintf(stream, " = $");
rreil_flop_print(stream, prim->flop.op);
fprintf(stream, " ");
rreil_varls_print(stream, prim->flop.args);
fprintf(stream, " [flags:");
rreil_variable_print(stream, prim->flop.flags);
fprintf(stream, "]");
break;
}
}
}
void rreil_statement_print(struct rreil_statement *statement) {
switch(statement->type) {
case RREIL_STATEMENT_TYPE_ASSIGN: {
......@@ -362,8 +340,21 @@ void rreil_statement_print(struct rreil_statement *statement) {
rreil_address_print(statement->branch.target);
break;
}
case RREIL_STATEMENT_TYPE_FLOP: {
rreil_varl_print(stdout, statement->flop.lhs);
fprintf(stdout, " = $");
rreil_flop_print(stdout, statement->flop.op);
fprintf(stdout, " ");
rreil_varls_print(stdout, statement->flop.rhs);
fprintf(stdout, " [flags:");
rreil_variable_print(stdout, statement->flop.flags);
fprintf(stdout, "]");
break;
}
case RREIL_STATEMENT_TYPE_PRIM: {
rreil_prim_print(stdout, statement->prim);
rreil_varls_print(stdout, statement->prim.lhs);
fprintf(stdout, " = $%s ", statement->prim.op);
rreil_varls_print(stdout, statement->prim.rhs);
break;
}
}
......
......@@ -18,8 +18,7 @@ type sem_expr_callbacks = {sem_lin:int, sem_mul:int, sem_div:int, sem_divs:int,
type sem_varl_callbacks = {sem_varl_:int}
type sem_varls_callbacks = {sem_varls_next:int, sem_varls_init:int}
type sem_flop_callbacks = {sem_flop_:int}
<