@@ -51,9 +51,9 @@ namespace UTAP
5151 */
5252 struct variable_t
5353 {
54- symbol_t uid; /* *< The symbol of the variables */
55- expression_t expr; /* *< The initialiser */
56- std::string toString () const ;
54+ symbol_t uid; /* *< The symbol of the variable */
55+ expression_t init; /* *< The initializer */
56+ std::string str () const ; /* *< computes a string representation */
5757 };
5858
5959 /* * Information about a location.
@@ -62,15 +62,15 @@ namespace UTAP
6262 is generated by the type checker; until then the rate
6363 expressions are part of the invariant.
6464 */
65- struct state_t
65+ struct location_t
6666 {
6767 symbol_t uid; /* *< The symbol of the location */
6868 expression_t name; /* *< TODO: the location name with its position */
6969 expression_t invariant; /* *< The invariant */
7070 expression_t exponentialRate;
7171 expression_t costRate; /* *< Rate expression */
72- int32_t locNr ; /* *< Location number in template */
73- std::string toString () const ;
72+ int32_t nr ; /* *< Location number in a template */
73+ std::string str () const ;
7474 };
7575
7676 /* * Information about a branchpoint.
@@ -95,16 +95,16 @@ namespace UTAP
9595 int nr; /* *< Placement in input file */
9696 bool control; /* *< Controllable (true/false) */
9797 std::string actname;
98- state_t * src; /* *< Pointer to source location */
98+ location_t * src; /* *< Pointer to source location */
9999 branchpoint_t * srcb; /* *< Pointer to source branchpoint */
100- state_t * dst; /* *< Pointer to destination location */
100+ location_t * dst; /* *< Pointer to destination location */
101101 branchpoint_t * dstb; /* *< Pointer to destination branchpoint */
102102 frame_t select; /* *< Frame for non-deterministic select */
103103 expression_t guard; /* *< The guard */
104104 expression_t assign; /* *< The assignment */
105105 expression_t sync; /* *< The synchronisation */
106106 expression_t prob; /* *< Probability for probabilistic edges. */
107- std::string toString () const ;
107+ std::string str () const ;
108108 std::vector<int32_t > selectValues; /* *<The select values, if any */
109109 };
110110
@@ -118,10 +118,10 @@ namespace UTAP
118118 symbol_t uid; /* *< The symbol of the function. */
119119 std::set<symbol_t > changes{}; /* *< Variables changed by this function. */
120120 std::set<symbol_t > depends{}; /* *< Variables the function depends on. */
121- std::list<variable_t > variables{}; /* *< Local variables. */
121+ std::list<variable_t > variables{}; /* *< Local variables. List is used for stable pointers. */
122122 std::unique_ptr<BlockStatement> body{nullptr }; /* *< Pointer to the block. */
123123 function_t () = default ;
124- std::string toString () const ; // used to write the XML file
124+ std::string str () const ; /* *< string representation, used to write the XML file */
125125 };
126126
127127 struct progress_t
@@ -167,7 +167,7 @@ namespace UTAP
167167 struct declarations_t
168168 {
169169 frame_t frame;
170- std::list<variable_t > variables; /* *< Variables */
170+ std::list<variable_t > variables; /* *< Variables. List is used for stable pointers. */
171171 std::list<function_t > functions; /* *< Functions */
172172 std::list<progress_t > progress; /* *< Progress measures */
173173 std::list<iodecl_t > iodecl;
@@ -176,7 +176,7 @@ namespace UTAP
176176 /* * Add function declaration. */
177177 bool addFunction (type_t type, std::string name, position_t , function_t *&);
178178 /* * The following methods are used to write the declarations in an XML file */
179- std::string toString (bool global = false ) const ;
179+ std::string str (bool global = false ) const ;
180180 std::string getConstants () const ;
181181 std::string getTypeDefinitions () const ;
182182 std::string getVariables (bool global) const ;
@@ -198,7 +198,7 @@ namespace UTAP
198198 expression_t label; /* *< The label */
199199 bool isInPrechart{};
200200 int get_nr () const { return nr; }
201- message_t () = default ;
201+ bool empty () const { return nr == - 1 ; }
202202 };
203203 /* * Information about a condition. Conditions have an anchor instance lines.
204204 * The label is stored as an expression.
@@ -207,12 +207,12 @@ namespace UTAP
207207 {
208208 int nr{-1 }; /* *< Placement in input file */
209209 int location{-1 };
210- std::vector<instanceLine_t*> anchors{}; /* *< Pointer to anchor instance lines */ // TODO
211- expression_t label; /* *< The label */
210+ std::vector<instanceLine_t*> anchors{}; /* *< Pointer to anchor instance lines */
211+ expression_t label; /* *< The label */
212212 bool isInPrechart{false };
213213 bool isHot{false };
214214 int get_nr () const { return nr; }
215- condition_t () = default ;
215+ bool empty () const { return nr == - 1 ; }
216216 };
217217
218218 /* * Information about an update. Update have an anchor instance line.
@@ -225,8 +225,8 @@ namespace UTAP
225225 instanceLine_t* anchor{nullptr }; /* *< Pointer to anchor instance line */
226226 expression_t label; /* *< The label */
227227 bool isInPrechart{};
228- update_t () = default ;
229228 int get_nr () const { return nr; }
229+ bool empty () const { return nr == -1 ; }
230230 };
231231
232232 struct simregion_t
@@ -253,8 +253,10 @@ namespace UTAP
253253 delete update;
254254 }
255255
256- std::string toString () const ;
257-
256+ std::string str () const ;
257+ bool has_message () const { return message != nullptr && !message->empty (); }
258+ bool has_condition () const { return condition != nullptr && !condition->empty (); }
259+ bool has_update () const { return update != nullptr && !update->empty (); }
258260 void setMessage (std::deque<message_t >& messages, int nr);
259261 void setCondition (std::deque<condition_t >& conditions, int nr);
260262 void setUpdate (std::deque<update_t >& updates, int nr);
@@ -289,11 +291,13 @@ namespace UTAP
289291
290292 bool equals (const cut_t & y) const ;
291293
292- std::string toString () const
294+ std::string str () const
293295 {
294296 std::string s = " CUT(" ;
295- for (unsigned int i = 0 ; i < simregions.size (); ++i)
296- s += simregions[i].toString () + " " ;
297+ for (unsigned int i = 0 ; i < simregions.size (); ++i) {
298+ s += simregions[i].str ();
299+ s += " " ;
300+ }
297301 s = s.substr (0 , s.size () - 1 );
298302 s += " )" ;
299303 return s;
@@ -357,7 +361,7 @@ namespace UTAP
357361 {
358362 symbol_t init; /* *< The initial location */
359363 frame_t templateset; /* *< Template set decls */
360- std::deque<state_t > states; /* *< Locations */
364+ std::deque<location_t > locations; /* *< Locations */
361365 std::deque<branchpoint_t > branchpoints; /* *< Branchpoints */
362366 std::deque<edge_t > edges; /* *< Edges */
363367 std::vector<expression_t > dynamicEvals;
@@ -372,7 +376,7 @@ namespace UTAP
372376 std::vector<expression_t >& getDynamicEval () { return dynamicEvals; }
373377
374378 /* * Add another location to template. */
375- state_t & addLocation (const std::string& name, expression_t inv, expression_t er, position_t pos);
379+ location_t & addLocation (const std::string& name, expression_t inv, expression_t er, position_t pos);
376380
377381 /* * Add another branchpoint to template. */
378382 branchpoint_t & addBranchpoint (const std::string&, position_t );
@@ -430,7 +434,7 @@ namespace UTAP
430434 expression_t head; // !< First expression in priority declaration
431435 tail_t tail; // !< Pairs: separator and channel expressions
432436
433- std::string toString () const ;
437+ std::string str () const ;
434438 };
435439
436440 enum class expectation_type { Symbolic, Probability, NumericValue, _ErrorValue };
@@ -492,7 +496,7 @@ namespace UTAP
492496 virtual void visitVariable (variable_t &) {}
493497 virtual bool visitTemplateBefore (template_t &) { return true ; }
494498 virtual void visitTemplateAfter (template_t &) {}
495- virtual void visitState ( state_t &) {}
499+ virtual void visitLocation ( location_t &) {}
496500 virtual void visitEdge (edge_t &) {}
497501 virtual void visitInstance (instance_t &) {}
498502 virtual void visitProcess (instance_t &) {}
0 commit comments