Commit 29c356c7 authored by Axel Simon's avatar Axel Simon

Merge branch 'experimental' of versioncontrolseidl.in.tum.de:jucs/gdsl-toolkit

parents 792b9871 20121c82
/*
* rreil.h
*
* Created on: Aug 19, 2014
* Author: jucs
*/
#pragma once
#include "address.h"
#include "branch_hint.h"
#include "flop.h"
#include "variable_limited.h"
#include "variable.h"
#include "visitor.h"
#include "statement/statement.h"
#include "statement/statement_visitor.h"
#include "statement/assign.h"
#include "statement/branch.h"
#include "statement/cbranch.h"
#include "statement/floating.h"
#include "statement/ite.h"
#include "statement/load.h"
#include "statement/prim.h"
#include "statement/store.h"
#include "statement/throw.h"
#include "statement/while.h"
#include "sexpr/sexpr.h"
#include "sexpr/sexpr_visitor.h"
#include "sexpr/arbitrary.h"
#include "sexpr/sexpr_cmp.h"
#include "sexpr/sexpr_lin.h"
#include "linear/linear.h"
#include "linear/linear_visitor.h"
#include "linear/binop_lin_op.h"
#include "linear/lin_binop.h"
#include "linear/lin_imm.h"
#include "linear/lin_scale.h"
#include "linear/lin_var.h"
#include "id/id.h"
#include "id/id_visitor.h"
#include "id/arch_id.h"
#include "id/shared_id.h"
#include "id/virtual.h"
#include "expr_cmp/cmp_op.h"
#include "expr_cmp/expr_cmp.h"
#include "expr/expr.h"
#include "expr/expr_visitor.h"
#include "expr/binop_op.h"
#include "expr/expr_binop.h"
#include "expr/expr_ext.h"
#include "expr/expr_sexpr.h"
#include "exception/exception.h"
#include "exception/exception_visitor.h"
#include "exception/arch_exception.h"
#include "exception/shared_exception.h"
......@@ -11,6 +11,7 @@
extern "C" {
#include <gdsl_generic.h>
}
#include <vector>
namespace gdsl {
namespace rreil {
......@@ -18,23 +19,23 @@ namespace rreil {
class ite : public statement {
private:
sexpr *cond;
statement *then_branch;
statement *else_branch;
std::vector<statement*> *then_branch;
std::vector<statement*> *else_branch;
void put(std::ostream &out);
public:
ite(sexpr *cond, statement *then_branch, statement *else_branch);
ite(sexpr *cond, std::vector<statement*> *then_branch, std::vector<statement*> *else_branch);
~ite();
sexpr *get_cond() {
return cond;
}
statement *get_then_branch() {
std::vector<statement*> *get_then_branch() {
return then_branch;
}
statement *get_else_branch() {
std::vector<statement*> *get_else_branch() {
return else_branch;
}
......
......@@ -12,24 +12,26 @@ extern "C" {
#include <gdsl_generic.h>
}
#include <vector>
namespace gdsl {
namespace rreil {
class _while : public statement {
private:
sexpr *cond;
statement *body;
std::vector<statement*> *body;
void put(std::ostream &out);
public:
_while(sexpr *cond, statement *body);
_while(sexpr *cond, std::vector<statement*> *body);
~_while();
sexpr *get_cond() {
return cond;
}
statement *get_body() {
std::vector<statement*> *get_body() {
return body;
}
......
......@@ -10,7 +10,7 @@
using namespace std;
gdsl::rreil::ite::ite(sexpr *cond, statement *then_branch, statement *else_branch) {
gdsl::rreil::ite::ite(sexpr *cond, std::vector<statement*> *then_branch, std::vector<statement*> *else_branch) {
this->cond = cond;
this->then_branch = then_branch;
this->else_branch = else_branch;
......@@ -18,8 +18,12 @@ gdsl::rreil::ite::ite(sexpr *cond, statement *then_branch, statement *else_branc
gdsl::rreil::ite::~ite() {
delete this->cond;
delete this->then_branch;
delete this->else_branch;
for(auto stmt : *then_branch)
delete stmt;
delete then_branch;
for(auto stmt : *else_branch)
delete stmt;
delete else_branch;
}
void gdsl::rreil::ite::accept(statement_visitor &v) {
......@@ -28,7 +32,10 @@ void gdsl::rreil::ite::accept(statement_visitor &v) {
void gdsl::rreil::ite::put(std::ostream &out) {
out << "if(" << *cond << ") {\n";
out << *then_branch << "\n}{\n";
out << *else_branch;
out << "\n}";
for(auto stmt : *then_branch)
out << *stmt << "\n";
out << "}{\n";
for(auto stmt : *else_branch)
out << *stmt << "\n";
out << "}";
}
......@@ -11,13 +11,15 @@
using namespace std;
gdsl::rreil::_while::_while(sexpr *cond, statement *body) {
gdsl::rreil::_while::_while(sexpr *cond, vector<statement*> *body) {
this->cond = cond;
this->body = body;
}
gdsl::rreil::_while::~_while() {
delete this->cond;
for(auto stmt : *body)
delete stmt;
delete this->body;
}
......@@ -27,5 +29,7 @@ void gdsl::rreil::_while::accept(statement_visitor &v) {
void gdsl::rreil::_while::put(ostream &out) {
out << "while(" << *cond << ") {\n";
out << *body << "\n}";
for(auto stmt: *body)
out << stmt;
out << "\n}";
}
......@@ -82,14 +82,17 @@ void gdsl::rreil::visitor::visit(store *a) {
void gdsl::rreil::visitor::visit(ite *a) {
statement_visitor::visit(a);
a->get_cond()->accept(*this);
a->get_then_branch()->accept(*this);
a->get_else_branch()->accept(*this);
for(auto stmt : *a->get_then_branch())
stmt->accept(*this);
for(auto stmt : *a->get_else_branch())
stmt->accept(*this);
}
void gdsl::rreil::visitor::visit(_while *a) {
statement_visitor::visit(a);
a->get_cond()->accept(*this);
a->get_body()->accept(*this);
for(auto stmt : *a->get_body())
stmt->accept(*this);
}
void gdsl::rreil::visitor::visit(cbranch *a) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment