00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00035 #ifndef UTAP_IOINTERFACE_HH
00036 #define UTAP_IOINTERFACE_HH
00037
00038 #include "utap/system.h"
00039 #include "utap/statement.h"
00040
00041
00042 #include <list>
00043 #include <set>
00044 #include <map>
00045
00046
00047 #include <stack>
00048
00049 namespace UTAP {
00056 class IOInterface: public StatementVisitor
00057 {
00058 protected:
00059 struct less_str {
00060 bool operator()(const char* s1, const char* s2){
00061 return (strcmp(s1,s2)<0);
00062 }
00063 };
00064 typedef std::set<const char*, less_str> strs_t;
00065 struct iota_t;
00066 typedef std::map<const iota_t*, strs_t> iota2strs_t;
00067 typedef std::map<const char*, strs_t> str2strs_t;
00068
00069 typedef struct iota_t {
00070 const char* name;
00071 strs_t inChans, outChans;
00072 str2strs_t rdVars, wtVars;
00073 iota2strs_t outEdges;
00074 iota_t(const char* _name): name(_name) {}
00075 };
00076 typedef std::map<const char*, std::set<iota_t*>, less_str> str2tas_t;
00077 const char* title;
00078 std::list<iota_t> automata;
00079 str2tas_t receivers, transmiters;
00080 strs_t procs, channels, variables;
00081 iota_t* cTA;
00082 process_t* cP;
00083 const char* cChan;
00084 bool inp, out, sync, paramsExpanded;
00085 std::stack<std::pair<bool, bool> > ioStack;
00086
00087 bool checkParams(const symbol_t &s);
00088 void addChan(const symbol_t &, strs_t &, str2tas_t&);
00089 void addVar(const symbol_t &, str2strs_t&, str2tas_t&);
00090 void visitProcess(process_t &);
00091 void visitExpression(const expression_t &);
00092 void pushIO(){
00093 ioStack.push(std::make_pair<bool, bool>(inp, out));
00094 }
00095 void popIO() {
00096 inp = ioStack.top().first;
00097 out = ioStack.top().second;
00098 ioStack.pop();
00099 }
00100
00101 public:
00105 IOInterface(const char* _title, TimedAutomataSystem& ta);
00110 virtual ~IOInterface() {}
00111
00115 void printForTron(std::ostream &os);
00116
00123 void printForDot(std::ostream &os, bool ranked, bool erd, bool cEdged);
00124
00130 int32_t visitEmptyStatement(EmptyStatement *stat);
00131 int32_t visitExprStatement(ExprStatement *stat);
00132 int32_t visitForStatement(ForStatement *stat);
00133 int32_t visitIterationStatement(IterationStatement *stat);
00134 int32_t visitWhileStatement(WhileStatement *stat);
00135 int32_t visitDoWhileStatement(DoWhileStatement *stat);
00136 int32_t visitBlockStatement(BlockStatement *stat);
00137 int32_t visitSwitchStatement(SwitchStatement *stat);
00138 int32_t visitCaseStatement(CaseStatement *stat);
00139 int32_t visitDefaultStatement(DefaultStatement *stat);
00140 int32_t visitIfStatement(IfStatement *stat);
00141 int32_t visitBreakStatement(BreakStatement *stat);
00142 int32_t visitContinueStatement(ContinueStatement *stat);
00143 int32_t visitReturnStatement(ReturnStatement *stat);
00144 };
00145 }
00146
00147 #endif