Statement.cc 492 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
/******************************************************************************
Adam Knapp's avatar
Adam Knapp committed
2
 * Copyright (c) 2000-2021 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v2.0
Elemer Lelik's avatar
Elemer Lelik committed
5
 * which accompanies this distribution, and is available at
6
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Elemer Lelik's avatar
Elemer Lelik committed
7
8
9
10
11
12
13
14
15
16
17
18
 *
 * Contributors:
 *   Baji, Laszlo
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Beres, Szabolcs
 *   Delic, Adam
 *   Feher, Csaba
 *   Forstner, Matyas
 *   Kovacs, Ferenc
 *   Raduly, Csaba
 *   Szabados, Kristof
19
 *   Szabo, Bence Janos
Elemer Lelik's avatar
Elemer Lelik committed
20
21
22
23
 *   Szabo, Janos Zoltan – initial implementation
 *   Zalanyi, Balazs Andor
 *
 ******************************************************************************/
Elemer Lelik's avatar
Elemer Lelik committed
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "../../common/dbgnew.hh"
#include "Statement.hh"
#include "Ttcnstuff.hh"
#include "../TypeCompat.hh"
#include "../CompType.hh"
#include "../CompField.hh"
#include "../SigParam.hh"
#include "TtcnTemplate.hh"
#include "ILT.hh"
#include "ArrayDimensions.hh"
#include "../Int.hh"
#include "../main.hh"
#include "Attributes.hh"
37
#include "compiler2/Valuestuff.hh"
Elemer Lelik's avatar
Elemer Lelik committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

namespace Ttcn {

  // =================================
  // ===== StatementBlock
  // =================================

  StatementBlock::StatementBlock()
    : Scope(), checked(false), labels_checked(false), my_sb(0), my_def(0), exception_handling(EH_NONE)
  {
  }

  StatementBlock::~StatementBlock()
  {
    for(size_t i=0; i<stmts.size(); i++)
      delete stmts[i];
    stmts.clear();
    defs.clear();
    labels.clear();
  }

  StatementBlock *StatementBlock::clone() const
  {
    FATAL_ERROR("StatementBlock::clone");
  }

  void StatementBlock::dump(unsigned int level) const
  {
    size_t n = stmts.size();
67
68
    DEBUG(level, "StatementBlock at %p with %lu", static_cast<const void*>(this),
      static_cast<unsigned long>( n ));
Elemer Lelik's avatar
Elemer Lelik committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
    for (size_t i = 0; i < n; ++i) {
      stmts[i]->dump(level+1);
    }
  }

  void StatementBlock::add_stmt(Statement *p_stmt, bool to_front)
  {
    if(!p_stmt)
      FATAL_ERROR("StatementBlock::add_stmt()");
    if (to_front) {
      stmts.add_front(p_stmt);
    } else {
      stmts.add(p_stmt);
    }
    p_stmt->set_my_scope(this);
    p_stmt->set_my_sb(this, stmts.size()-1);
  }

  void StatementBlock::set_my_scope(Scope *p_scope)
  {
    set_parent_scope(p_scope);
    for(size_t i=0; i<stmts.size(); i++)
      stmts[i]->set_my_scope(this);
  }

  void StatementBlock::set_fullname(const string& p_fullname)
  {
    Node::set_fullname(p_fullname);
    for(size_t i=0; i<stmts.size(); i++)
      stmts[i]->set_fullname(p_fullname+".stmt_"+Int2string(i+1));
  }

  /** \todo handle loops and conditional statements */
  Statement *StatementBlock::get_first_stmt() const
  {
    size_t nof_stmts = stmts.size();
    for (size_t i = 0; i < nof_stmts; i++) {
      Statement *stmt = stmts[i];
      switch (stmt->get_statementtype()) {
      case Statement::S_LABEL:
	// ignore and go to the next statement
	break;
      case Statement::S_BLOCK: {
	// if the block is not empty return its first statement
	// otherwise go to the next statement
	Statement *first_stmt = stmt->get_block()->get_first_stmt();
	if (first_stmt) return first_stmt;
	else break; }
      case Statement::S_DOWHILE: {
	// if the block is not empty return its first statement
	// otherwise return the whole do-while statement
	Statement *first_stmt = stmt->get_block()->get_first_stmt();
	if (first_stmt) return first_stmt;
	else return stmt; }
      default:
        return stmt;
      }
    }
    return 0;
  }

  void StatementBlock::register_def(Definition *p_def)
  {
    if(!p_def) FATAL_ERROR("StatementBlock::register_def()");
    const Identifier& id=p_def->get_id();
    if (defs.has_key(id)) {
      const char *dispname = id.get_dispname().c_str();
      p_def->error("Duplicate definition with identifier `%s'", dispname);
      defs[id]->note("Previous definition with identifier `%s' is here",
	dispname);
    } else {
      defs.add(id, p_def);
      if (parent_scope) {
	if (parent_scope->has_ass_withId(id)) {
143
144
145
146
147
148
149
150
151
152
    if (parent_scope->get_scope_class() == NULL) {
      const char *dispname = id.get_dispname().c_str();
      p_def->error("Definition with identifier `%s' is not unique"
                         " in the scope hierarchy", dispname);
      Reference ref(0, id.clone());
      Common::Assignment *ass = parent_scope->get_ass_bySRef(&ref);
      if (!ass) FATAL_ERROR("StatementBlock::register_def()");
      ass->note("Previous definition with identifier `%s' in higher "
                       "scope unit is here", dispname);
    }
Elemer Lelik's avatar
Elemer Lelik committed
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
	} else if (parent_scope->is_valid_moduleid(id)) {
	  p_def->warning("Definition with name `%s' hides a module identifier",
	    id.get_dispname().c_str());
	}
      }
    }
  }

  bool StatementBlock::has_ass_withId(const Identifier& p_id)
  {
    return defs.has_key(p_id) || get_parent_scope()->has_ass_withId(p_id);
  }

  Common::Assignment* StatementBlock::get_ass_bySRef(Ref_simple *p_ref)
  {
168
169
170
    if(p_ref->get_modid() || p_ref->get_reftype() != Ref_simple::REF_BASIC) {
      return get_parent_scope()->get_ass_bySRef(p_ref);
    }
Elemer Lelik's avatar
Elemer Lelik committed
171
172
173
174
175
    const Identifier& id=*p_ref->get_id();
    if(defs.has_key(id)) return defs[id];
    else return get_parent_scope()->get_ass_bySRef(p_ref);
  }

Elemer Lelik's avatar
Elemer Lelik committed
176
  Type *StatementBlock::get_mtc_system_comptype(bool is_system)
Elemer Lelik's avatar
Elemer Lelik committed
177
178
  {
    // return NULL outside test cases
179
180
181
182
183
184
185
186
187
188
189
190
191
    if (!my_def)
      return 0;
    Common::Assignment::asstype_t asstype = my_def->get_asstype();
    if (asstype == Common::Assignment::A_TESTCASE) {
      if (is_system) {
        Def_Testcase *t_tc = dynamic_cast<Def_Testcase*>(my_def);
        if (!t_tc) FATAL_ERROR("StatementBlock::get_mtc_system_comptype()");
        Type *system_ct = t_tc->get_SystemType();
        if (system_ct) return system_ct;
        // otherwise (if the testcase has no system clause) the type of 'system'
        // is the same as the type of 'mtc' (which is given in 'runs on' clause)
      }
      return my_def->get_RunsOnType();
192
193
194
195
    } else if (asstype == Common::Assignment::A_FUNCTION ||
               asstype == Common::Assignment::A_FUNCTION_RVAL ||
               asstype == Common::Assignment::A_FUNCTION_RTEMP ||
               asstype == Common::Assignment::A_ALTSTEP) {
196
197
198
199
200
201
      if (is_system) {
        return my_def->get_SystemType();
      } else {
        return my_def->get_MtcType();
      }
    } else {
Elemer Lelik's avatar
Elemer Lelik committed
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
      return 0;
    }
  }

  Ttcn::StatementBlock *StatementBlock::get_statementblock_scope()
  {
    return this;
  }

  void StatementBlock::set_my_sb(StatementBlock *p_sb, size_t p_index)
  {
    my_sb=p_sb;
    my_sb_index=p_index;
    for(size_t i=0; i<stmts.size(); i++)
      stmts[i]->set_my_sb(this, i);
  }

  size_t StatementBlock::get_my_sb_index() const
  {
    if(!my_sb) FATAL_ERROR("StatementBlock::get_my_sb_index()");
    return my_sb_index;
  }

  void StatementBlock::set_my_def(Definition *p_def)
  {
    my_def=p_def;
    for(size_t i=0; i<stmts.size(); i++)
      stmts[i]->set_my_def(p_def);
  }

  void StatementBlock::set_my_ags(AltGuards *p_ags)
  {
    for(size_t i=0; i<stmts.size(); i++)
      stmts[i]->set_my_ags(p_ags);
  }

  void StatementBlock::set_my_laic_stmt(AltGuards *p_ags,
                                        Statement *p_loop_stmt)
  {
    for(size_t i=0; i<stmts.size(); i++)
      stmts[i]->set_my_laic_stmt(p_ags, p_loop_stmt);
  }

  StatementBlock::returnstatus_t StatementBlock::has_return() const
  {
    returnstatus_t ret_val = RS_NO;
    size_t nof_stmts = stmts.size();
    for (size_t i = 0; i < nof_stmts; i++) {
      Statement *stmt = stmts[i];
      if (stmt->get_statementtype() == Statement::S_GOTO) {
	if (stmt->goto_jumps_forward()) {
	  // heuristics without deep analysis of the control flow graph:
	  // skip over the next statements until a (used) label is found
	  // the behaviour will be sound (i.e. no false errors will be reported)
	  for (i++; i < nof_stmts; i++) {
	    stmt = stmts[i];
	    if (stmt->get_statementtype() == Statement::S_LABEL &&
		stmt->label_is_used()) break;
	  }
	} else return RS_YES;
      } else if (stmt->get_statementtype()==Statement::S_BLOCK && stmt->get_block()->exception_handling!=EH_NONE) {
        switch (stmt->get_block()->exception_handling) {
        case EH_TRY: // the i-th statement is a try{} statement block, the (i+1)-th must be a catch{} block
          if ((i+1)<nof_stmts && stmts[i+1]->get_statementtype()==Statement::S_BLOCK && stmts[i+1]->get_block()->exception_handling==EH_CATCH) {
            returnstatus_t try_block_rs = stmt->has_return();
            returnstatus_t catch_block_rs = stmts[i+1]->has_return();
            // 3 x 3 combinations
            if (try_block_rs==catch_block_rs) {
              switch (try_block_rs) {
              case RS_YES:
                return RS_YES;
              case RS_MAYBE:
                ret_val = RS_MAYBE;
              default:
                break;
              }
            } else {
              ret_val = RS_MAYBE;
            }
          } else { // if next statement is not a catch{} block then that error has already been reported
            ret_val = RS_MAYBE; // assume the catch block was an RS_MAYBE
          }
          break;
        case EH_CATCH:
          // logically this is part of the preceding try{} block, handle it as part of it, see above case EH_TRY
          break;
        default:
          FATAL_ERROR("StatementBlock::has_return()");
        }
      } else {
	switch (stmt->has_return()) {
	case RS_YES:
	  return RS_YES;
	case RS_MAYBE:
	  ret_val = RS_MAYBE;
	default:
	  break;
	}
      }
    }
    return ret_val;
  }

  bool StatementBlock::has_receiving_stmt(size_t start_i) const
  {
    for(size_t i=start_i; i<stmts.size(); i++)
      if(stmts[i]->has_receiving_stmt()) return true;
    return false;
  }

  bool StatementBlock::has_def_stmt_i(size_t start_i) const
  {
    for(size_t i=start_i; i<stmts.size(); i++)
      if(stmts[i]->get_statementtype()==Statement::S_DEF) return true;
    return false;
  }

  size_t StatementBlock::last_receiving_stmt_i() const
  {
    size_t nof_stmts = stmts.size();
    if (nof_stmts > 0) {
      size_t i = nof_stmts;
      do {
	if (stmts[--i]->has_receiving_stmt()) return i;
      } while (i > 0);
    }
    return nof_stmts;
  }

  StatementBlock *StatementBlock::get_parent_block() const
  {
    for (Scope *s = get_parent_scope(); s; s=s->get_parent_scope()) {
      StatementBlock *sb = dynamic_cast<StatementBlock*>(s);
      if (sb) return sb;
    }
    return 0;
  }

  void StatementBlock::chk_trycatch_blocks(Statement* s1, Statement* s2) {
    if (s1 && s1->get_statementtype()==Statement::S_BLOCK && s1->get_block()->get_exception_handling()==StatementBlock::EH_TRY) {
      if (!(s2 && s2->get_statementtype()==Statement::S_BLOCK && s2->get_block()->get_exception_handling()==StatementBlock::EH_CATCH)) {
        s1->error("`try' statement block must be followed by a `catch' block");
      }
    }
    if (s2 && s2->get_statementtype()==Statement::S_BLOCK && s2->get_block()->get_exception_handling()==StatementBlock::EH_CATCH) {
      if (!(s1 && s1->get_statementtype()==Statement::S_BLOCK && s1->get_block()->get_exception_handling()==StatementBlock::EH_TRY)) {
        s2->error("`catch' statement block must be preceded by a `try' block");
      }
    }
  }

  void StatementBlock::chk()
  {
    if (checked) return;
    chk_labels();
    bool unreach_found = false;
    size_t nof_stmts = stmts.size();
    Statement *prev_stmt = 0;
    for (size_t i = 0; i < nof_stmts; i++) {
      Statement *stmt = stmts[i];
      stmt->chk();
      if (!unreach_found && stmt->get_statementtype() != Statement::S_LABEL &&
	  prev_stmt && prev_stmt->is_terminating()) {
	// a statement is unreachable if:
	// - it is not a label (i.e. goto cannot jump to it)
	// - it is not the first statement of the block
	// - the previous statement terminates the control flow
	stmt->warning("Control never reaches this statement");
	unreach_found = true;
      }
      // check try-catch statement block usage
      chk_trycatch_blocks(prev_stmt, stmt);
      //
      prev_stmt = stmt;
    }
    chk_trycatch_blocks(prev_stmt, 0);
    chk_unused_labels();
    checked = true;
  }

  void StatementBlock::chk_allowed_interleave()
  {
    size_t nof_stmts = stmts.size();
    for (size_t i = 0; i < nof_stmts; i++)
      stmts[i]->chk_allowed_interleave();
  }

  void StatementBlock::chk_labels()
  {
    if(labels_checked) return;
    for(size_t i=0; i<stmts.size(); i++) {
      Statement *st=stmts[i];
      if(st->get_statementtype()!=Statement::S_LABEL) continue;
      const Identifier& labelid=st->get_labelid();
      if(has_label(labelid)) {
        const char *name=labelid.get_dispname().c_str();
        st->error("Duplicate label `%s'", name);
        Statement *st2=get_label(labelid);
        st2->note("Previous definition of label `%s' is here", name);
      }
      else labels.add(labelid, st);
    }
    labels_checked=true;
  }

  void StatementBlock::chk_unused_labels()
  {
    size_t nof_stmts = stmts.size();
    for (size_t i = 0; i < nof_stmts; i++) {
      Statement *stmt = stmts[i];
      if (stmt->get_statementtype() == Statement::S_LABEL &&
	  !stmt->label_is_used())
	stmt->warning("Label `%s' is defined, but not used",
	  stmt->get_labelid().get_dispname().c_str());
    }
  }

  bool StatementBlock::has_label(const Identifier& p_id) const
  {
    for (const StatementBlock *sb = this; sb; sb = sb->get_parent_block())
      if (sb->labels.has_key(p_id)) return true;
    return false;
  }

  Statement *StatementBlock::get_label(const Identifier& p_id) const
  {
    for (const StatementBlock *sb = this; sb; sb = sb->get_parent_block())
      if (sb->labels.has_key(p_id)) return sb->labels[p_id];
    FATAL_ERROR("StatementBlock::get_label()");
    return 0;
  }

  void StatementBlock::set_code_section(
    GovernedSimple::code_section_t p_code_section)
  {
    for(size_t i = 0; i < stmts.size(); i++)
      stmts[i]->set_code_section(p_code_section);
  }

441
  char* StatementBlock::generate_code(char *str, char*& def_glob_vars, char*& src_glob_vars)
Elemer Lelik's avatar
Elemer Lelik committed
442
443
444
445
446
447
  {
    if (exception_handling==EH_TRY) {
      str = mputstr(str, "TTCN_TryBlock try_block;\n");
    }
    if (stmts.size()>0) {
      Statement* first_stmt = stmts[0];
448
      str = first_stmt->generate_code(str, def_glob_vars, src_glob_vars);
Elemer Lelik's avatar
Elemer Lelik committed
449
450
451
452
453
454
455
456
      if (exception_handling==EH_CATCH) {
        if (first_stmt->get_statementtype()!=Statement::S_DEF) FATAL_ERROR("StatementBlock::generate_code()");
        Definition* error_msg_def = first_stmt->get_def();
        string error_msg_name = error_msg_def->get_id().get_name();
        str = mputprintf(str, "%s = ttcn_error.get_message();\n", error_msg_name.c_str());
      }
    }
    for(size_t i=1; i<stmts.size(); i++) {
457
      str = stmts[i]->generate_code(str, def_glob_vars, src_glob_vars);
Elemer Lelik's avatar
Elemer Lelik committed
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
    }
    return str;
  }

  void StatementBlock::ilt_generate_code(ILT *ilt)
  {
    size_t nof_stmts = stmts.size();
    if (nof_stmts == 0) return;
    char*& str=ilt->get_out_branches();
    size_t last_recv_stmt_i=last_receiving_stmt_i();
    // has no receiving stmt
    if (last_recv_stmt_i == nof_stmts) {
      bool has_def=has_def_stmt_i();
      if(has_def) str=mputstr(str, "{\n");
      for(size_t i=0; i<nof_stmts; i++)
473
474
        str=stmts[i]->generate_code(str, ilt->get_out_def_glob_vars(),
          ilt->get_out_src_glob_vars());
Elemer Lelik's avatar
Elemer Lelik committed
475
476
477
478
479
480
481
482
483
484
      if(has_def) str=mputstr(str, "}\n");
      return;
    }
    for(size_t i=0; i<=last_recv_stmt_i; i++)
      stmts[i]->ilt_generate_code(ilt);
    // the last part which does not contain receiving stmt
    if(last_recv_stmt_i==nof_stmts-1) return;
    bool has_def=has_def_stmt_i(last_recv_stmt_i+1);
    if(has_def) str=mputstr(str, "{\n");
    for(size_t i=last_recv_stmt_i+1; i<nof_stmts; i++)
485
486
      str=stmts[i]->generate_code(str, ilt->get_out_def_glob_vars(),
        ilt->get_out_src_glob_vars());
Elemer Lelik's avatar
Elemer Lelik committed
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
    if(has_def) str=mputstr(str, "}\n");
  }

  void StatementBlock::set_parent_path(WithAttribPath* p_path)
  {
    for (size_t i = 0; i < stmts.size(); i++)
      stmts[i]->set_parent_path(p_path);
  }

  // =================================
  // ===== Statement
  // =================================

  void Statement::clean_up()
  {
    switch (statementtype) {
    case S_ERROR:
    case S_BREAK:
    case S_CONTINUE:
    case S_STOP_EXEC:
    case S_REPEAT:
Elemer Lelik's avatar
Elemer Lelik committed
508
509
    case S_START_PROFILER:
    case S_STOP_PROFILER:
Elemer Lelik's avatar
Elemer Lelik committed
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
      break;
    case S_START_UNDEF:
    case S_STOP_UNDEF:
      delete undefstartstop.ref;
      delete undefstartstop.val;
      break;
    case S_UNKNOWN_INSTANCE:
    case S_FUNCTION_INSTANCE:
    case S_ALTSTEP_INSTANCE:
    case S_ACTIVATE:
      delete ref_pard;
      break;
    case S_DEF:
      delete def;
      break;
    case S_ASSIGNMENT:
      delete ass;
      break;
    case S_BLOCK:
      delete block;
      break;
    case S_LOG:
    case S_ACTION:
    case S_STOP_TESTCASE:
      delete logargs;
      break;
    case S_LABEL:
      delete label.id;
      delete label.clabel;
      break;
    case S_GOTO:
      delete go_to.id;
      break;
    case S_IF:
      delete if_stmt.ics;
      delete if_stmt.elseblock;
      delete if_stmt.elseblock_location;
      break;
    case S_SELECT:
      delete select.expr;
      delete select.scs;
      break;
552
553
554
555
    case S_SELECTUNION:
      delete select_union.expr;
      delete select_union.sus;
      break;
556
557
558
559
    case S_SELECT_CLASS:
      delete select_class.ref;
      delete select_class.sccs;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
    case S_FOR:
      if(loop.for_stmt.varinst)
        delete loop.for_stmt.init_varinst;
      else
        delete loop.for_stmt.init_ass;
      delete loop.for_stmt.finalexpr;
      delete loop.for_stmt.step;
      delete loop.block;
      if (loop.label_next)
        delete loop.label_next;
      if (loop.il_label_end)
        delete loop.il_label_end;
      break;
    case S_WHILE:
    case S_DOWHILE:
      delete loop.expr;
      delete loop.block;
      if (loop.label_next)
        delete loop.label_next;
      if (loop.il_label_end)
        delete loop.il_label_end;
      break;
    case S_ALT:
    case S_INTERLEAVE:
      delete ags;
      break;
    case S_RETURN:
      delete returnexpr.v;
      delete returnexpr.t;
      break;
    case S_DEACTIVATE:
      delete deactivate;
      break;
    case S_SEND:
      delete port_op.portref;
      delete port_op.s.sendpar;
      delete port_op.s.toclause;
597
      delete port_op.s.timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
598
599
600
601
602
603
604
      break;
    case S_CALL:
      delete port_op.portref;
      delete port_op.s.sendpar;
      delete port_op.s.call.timer;
      delete port_op.s.toclause;
      delete port_op.s.call.body;
605
      delete port_op.s.timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
606
607
608
609
610
611
      break;
    case S_REPLY:
      delete port_op.portref;
      delete port_op.s.sendpar;
      delete port_op.s.replyval;
      delete port_op.s.toclause;
612
      delete port_op.s.timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
613
614
615
616
617
618
      break;
    case S_RAISE:
      delete port_op.portref;
      delete port_op.s.raise.signature_ref;
      delete port_op.s.sendpar;
      delete port_op.s.toclause;
619
      delete port_op.s.timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
620
621
622
623
624
625
626
627
628
      break;
    case S_RECEIVE:
    case S_CHECK_RECEIVE:
    case S_TRIGGER:
      delete port_op.portref;
      delete port_op.r.rcvpar;
      delete port_op.r.fromclause;
      delete port_op.r.redirect.value;
      delete port_op.r.redirect.sender;
629
      delete port_op.r.redirect.index;
630
      delete port_op.r.redirect.timestamp;
Elemer Lelik's avatar
Elemer Lelik committed
631
632
633
634
635
636
637
638
      break;
    case S_GETCALL:
    case S_CHECK_GETCALL:
      delete port_op.portref;
      delete port_op.r.rcvpar;
      delete port_op.r.fromclause;
      delete port_op.r.redirect.param;
      delete port_op.r.redirect.sender;
639
      delete port_op.r.redirect.index;
640
      delete port_op.r.redirect.timestamp;
Elemer Lelik's avatar
Elemer Lelik committed
641
642
643
644
645
646
647
648
649
650
      break;
    case S_GETREPLY:
    case S_CHECK_GETREPLY:
      delete port_op.portref;
      delete port_op.r.rcvpar;
      delete port_op.r.getreply_valuematch;
      delete port_op.r.fromclause;
      delete port_op.r.redirect.value;
      delete port_op.r.redirect.param;
      delete port_op.r.redirect.sender;
651
      delete port_op.r.redirect.index;
652
      delete port_op.r.redirect.timestamp;
Elemer Lelik's avatar
Elemer Lelik committed
653
654
655
656
657
658
659
660
661
      break;
    case S_CATCH:
    case S_CHECK_CATCH:
      delete port_op.portref;
      delete port_op.r.ctch.signature_ref;
      delete port_op.r.rcvpar;
      delete port_op.r.fromclause;
      delete port_op.r.redirect.value;
      delete port_op.r.redirect.sender;
662
      delete port_op.r.redirect.index;
663
      delete port_op.r.redirect.timestamp;
Elemer Lelik's avatar
Elemer Lelik committed
664
665
666
667
668
      break;
    case S_CHECK:
      delete port_op.portref;
      delete port_op.r.fromclause;
      delete port_op.r.redirect.sender;
669
      delete port_op.r.redirect.index;
670
      delete port_op.r.redirect.timestamp;
Elemer Lelik's avatar
Elemer Lelik committed
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
      break;
    case S_CLEAR:
    case S_START_PORT:
    case S_STOP_PORT:
    case S_HALT:
      delete port_op.portref;
      break;
    case S_START_COMP:
      delete comp_op.compref;
      delete comp_op.funcinstref;
      break;
    case S_START_COMP_REFD:
      delete comp_op.compref;
      delete comp_op.derefered.value;
      delete comp_op.derefered.ap_list2;
      break;
    case S_STOP_COMP:
    case S_KILL:
689
690
      delete comp_op.compref;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
691
692
    case S_KILLED:
      delete comp_op.compref;
693
      delete comp_op.index_redirect;
Elemer Lelik's avatar
Elemer Lelik committed
694
695
696
697
698
699
      break;
    case S_DONE:
      if (comp_op.compref) {
        delete comp_op.compref;
        delete comp_op.donereturn.donematch;
        delete comp_op.donereturn.redirect;
700
        delete comp_op.index_redirect;
Elemer Lelik's avatar
Elemer Lelik committed
701
702
703
704
705
706
707
708
709
710
      }
      break;
    case S_CONNECT:
    case S_MAP:
    case S_DISCONNECT:
    case S_UNMAP:
      delete config_op.compref1;
      delete config_op.portref1;
      delete config_op.compref2;
      delete config_op.portref2;
711
      delete config_op.ap_list;
Elemer Lelik's avatar
Elemer Lelik committed
712
713
714
715
716
717
      break;
    case S_START_TIMER:
      delete timer_op.timerref;
      delete timer_op.value;
      break;
    case S_TIMEOUT:
718
      delete timer_op.index_redirect;
719
720
721
      // no break
    case S_STOP_TIMER:
      delete timer_op.timerref;
Elemer Lelik's avatar
Elemer Lelik committed
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
      break;
    case S_SETVERDICT:
      delete setverdict.verdictval;
      delete setverdict.logargs;
      break;
    case S_TESTCASE_INSTANCE:
      delete testcase_inst.tcref;
      delete testcase_inst.timerval;
      break;
    case S_TESTCASE_INSTANCE_REFD:
      delete execute_refd.value;
      delete execute_refd.ap_list2;
      delete execute_refd.timerval;
      break;
    case S_ACTIVATE_REFD:
    case S_UNKNOWN_INVOKED:
    case S_FUNCTION_INVOKED:
    case S_ALTSTEP_INVOKED:
      delete fau_refd.value;
      delete fau_refd.ap_list2;
      break;
    case S_STRING2TTCN:
Elemer Lelik's avatar
Elemer Lelik committed
744
745
746
    case S_INT2ENUM:
      delete convert_op.val;
      delete convert_op.ref;
Elemer Lelik's avatar
Elemer Lelik committed
747
      break;
748
749
750
751
752
    case S_UPDATE:
      delete update_op.ref;
      delete update_op.w_attrib_path;
      delete update_op.err_attrib;
      break;
753
754
755
756
    case S_SETSTATE:
      delete setstate_op.val;
      delete setstate_op.ti;
      break;
757
758
759
760
    case S_SETENCODE:
      delete setencode_op.type;
      delete setencode_op.encoding;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
761
762
763
764
765
766
767
768
769
770
771
772
773
    default:
      FATAL_ERROR("Statement::clean_up()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_REPEAT:
      ags=0;
    case S_ERROR:
    case S_STOP_EXEC:
Elemer Lelik's avatar
Elemer Lelik committed
774
775
    case S_START_PROFILER:
    case S_STOP_PROFILER:
Elemer Lelik's avatar
Elemer Lelik committed
776
777
778
779
780
781
782
783
784
785
786
      break;
    case S_BREAK:
    case S_CONTINUE:
      brk_cnt.loop_stmt=0;
      brk_cnt.ags=0;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

787
  Statement::Statement(statementtype_t p_st, Reference *p_ref, Value *p_val)
Elemer Lelik's avatar
Elemer Lelik committed
788
789
790
791
792
793
794
795
796
797
798
799
800
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_START_UNDEF:
      if (!p_ref) FATAL_ERROR("Statement::Statement()");
      undefstartstop.ref=p_ref;
      undefstartstop.val=p_val;
      break;
    case S_STOP_UNDEF:
      if (!p_ref || p_val) FATAL_ERROR("Statement::Statement()");
      undefstartstop.ref=p_ref;
      undefstartstop.val=0;
      break;
801
802
803
804
805
806
    case S_TESTCASE_INSTANCE:
      if(!p_ref)
        FATAL_ERROR("Statement::Statement()");
      testcase_inst.tcref=p_ref;
      testcase_inst.timerval=p_val;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
807
808
809
810
811
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

812
  Statement::Statement(statementtype_t p_st, Reference *p_ref)
Elemer Lelik's avatar
Elemer Lelik committed
813
814
815
816
817
818
819
820
821
822
823
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_UNKNOWN_INSTANCE:
    case S_FUNCTION_INSTANCE:
    case S_ALTSTEP_INSTANCE:
    case S_ACTIVATE:
      if(!p_ref)
        FATAL_ERROR("Statement::Statement()");
      ref_pard=p_ref;
      break;
824
825
826
827
828
829
830
831
832
    case S_CLEAR:
    case S_START_PORT:
    case S_STOP_PORT:
    case S_HALT:
      port_op.portref=p_ref;
      break;
    case S_STOP_TIMER:
      timer_op.timerref=p_ref;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Value *p_derefered_value,
                       ParsedActualParameters *p_ap_list)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_ACTIVATE_REFD:
    case S_UNKNOWN_INVOKED:
    case S_FUNCTION_INVOKED:
    case S_ALTSTEP_INVOKED:
      if(!p_derefered_value || !p_ap_list)
        FATAL_ERROR("Statement::Statement()");
      fau_refd.value = p_derefered_value;
      fau_refd.t_list1 = p_ap_list;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    }
  }

  Statement::Statement(statementtype_t p_st, Definition *p_def)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_DEF:
      if(!p_def)
        FATAL_ERROR("Statement::Statement()");
      def=p_def;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Assignment *p_ass)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_ASSIGNMENT:
      if(!p_ass)
        FATAL_ERROR("Statement::Statement()");
      ass=p_ass;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, StatementBlock *p_block)
    : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_BLOCK:
      if (!p_block) FATAL_ERROR("Statement::Statement()");
      block = p_block;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, LogArguments *p_logargs)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_LOG:
    case S_ACTION:
    case S_STOP_TESTCASE:
      logargs=p_logargs;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Identifier *p_id)
    : statementtype(p_st), my_sb(0)
  {
    if (!p_id)
      FATAL_ERROR("Statement::Statement()");
    switch (statementtype) {
    case S_LABEL:
      label.id = p_id;
      label.stmt_idx = 0;
      label.clabel = 0;
      label.used = false;
      break;
    case S_GOTO:
      go_to.id = p_id;
      go_to.stmt_idx = 0;
      go_to.label = 0;
      go_to.jumps_forward = false;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, IfClauses *p_ics,
                       StatementBlock *p_block, Location *p_loc)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_IF:
      if(!p_ics)
        FATAL_ERROR("Statement::Statement()");
      if_stmt.ics=p_ics;
      if (p_block) {
	if (!p_loc) FATAL_ERROR("Statement::Statement()");
	if_stmt.elseblock = p_block;
	if_stmt.elseblock_location = p_loc;
      } else {
	if (p_loc) FATAL_ERROR("Statement::Statement()");
	if_stmt.elseblock = 0;
	if_stmt.elseblock_location = 0;
      }
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Value *p_expr, SelectCases *p_scs)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_SELECT:
      if(!p_expr || !p_scs)
        FATAL_ERROR("Statement::Statement()");
      select.expr=p_expr;
      select.scs=p_scs;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }
973
  
974
  Statement::Statement(statementtype_t p_st, Value *p_expr, SelectUnions *p_sus)
975
976
977
978
979
980
981
982
983
984
985
986
987
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_SELECTUNION:
      if(!p_expr || !p_sus)
        FATAL_ERROR("Statement::Statement()");
      select_union.expr=p_expr;
      select_union.sus=p_sus;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
    
  Statement::Statement(statementtype_t p_st, Reference *p_ref, SelectClassCases *p_sccs)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_SELECT_CLASS:
      if (p_ref == NULL || p_sccs == NULL) {
        FATAL_ERROR("Statement::Statement()");
      }
      select_class.ref = p_ref;
      select_class.sccs = p_sccs;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }
Elemer Lelik's avatar
Elemer Lelik committed
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105

  Statement::Statement(statementtype_t p_st, Definitions *p_defs,
                       Assignment *p_ass, Value *p_final,
                       Assignment *p_step, StatementBlock *p_block)
    : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_FOR: // precisely one of p_defs, p_ass allowed
      if (p_defs) {
        // it came from a for loop which looked like this:
        // for (var integer foo:=1; foo<10; foo:=foo+1) ;
	if (p_ass) FATAL_ERROR("Statement::Statement()");
	loop.for_stmt.varinst = true;
	loop.for_stmt.init_varinst = p_defs;
      } else {
        // it came from a for loop which looked like this:
        // for (foo:=1; foo<10; foo:=foo+1) ;
	if (!p_ass) FATAL_ERROR("Statement::Statement()");
	loop.for_stmt.varinst = false;
	loop.for_stmt.init_ass = p_ass;
      }
      if(!p_final || !p_step || !p_block)
        FATAL_ERROR("Statement::Statement()");
      loop.for_stmt.finalexpr=p_final;
      loop.for_stmt.step=p_step;
      loop.block=p_block;
      loop.label_next=0;
      loop.il_label_end=0;
      loop.has_cnt=false;
      loop.has_brk=false;
      loop.has_cnt_in_ags=false;
      loop.iterate_once=false; // not used by for
      loop.is_ilt=false;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Value *p_val,
                       StatementBlock *p_block)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_WHILE:
    case S_DOWHILE:
      if(!p_val || !p_block)
        FATAL_ERROR("Statement::Statement()");
      loop.expr=p_val;
      loop.block=p_block;
      loop.label_next=0;
      loop.il_label_end=0;
      loop.has_cnt=false;
      loop.has_brk=false;
      loop.has_cnt_in_ags=false;
      loop.iterate_once=false; // used only by do-while
      loop.is_ilt=false;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, AltGuards *p_ags)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_ALT:
    case S_INTERLEAVE:
      if(!p_ags)
        FATAL_ERROR("Statement::Statement()");
      ags=p_ags;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Template *p_temp)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_RETURN:
      returnexpr.v=0;
      returnexpr.t=p_temp;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Value *p_val)
    : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_STOP_COMP:
    case S_KILL:
      comp_op.compref=p_val;
      break;
    case S_DEACTIVATE:
      deactivate=p_val;
      break;
1106
1107
1108
1109
    case S_SETSTATE:
      setstate_op.val = p_val;
      setstate_op.ti = NULL;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
1110
1111
1112
1113
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
  
  Statement::Statement(statementtype_t p_st, Value *p_val, bool p_any_from,
                       Reference* p_index_redirect)
    : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_KILLED:
      if (p_val == NULL) {
        FATAL_ERROR("Statement::Statement()");
      }
      comp_op.compref = p_val;
      comp_op.any_from = p_any_from;
      comp_op.index_redirect = p_index_redirect;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }
Elemer Lelik's avatar
Elemer Lelik committed
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143

  Statement::Statement(statementtype_t p_st, Value *p_val,
                       LogArguments *p_logargs)
    : statementtype(p_st), my_sb(0)
  {
    if (!p_val || statementtype != S_SETVERDICT)
      FATAL_ERROR("Statement::Statement()");
    setverdict.verdictval = p_val;
    setverdict.logargs = p_logargs;
  }

  Statement::Statement(statementtype_t p_st, Reference *p_ref,
1144
1145
                       TemplateInstance *p_templinst, Value *p_val,
                       Reference* p_timestampredirect, bool p_translate)
Elemer Lelik's avatar
Elemer Lelik committed
1146
1147
1148
1149
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_SEND:
1150
      if((!p_ref && p_translate == false) || !p_templinst)
Elemer Lelik's avatar
Elemer Lelik committed
1151
1152
        FATAL_ERROR("Statement::Statement()");
      port_op.portref=p_ref;
1153
      port_op.translate = p_translate;
Elemer Lelik's avatar
Elemer Lelik committed
1154
1155
      port_op.s.sendpar=p_templinst;
      port_op.s.toclause=p_val;
1156
      port_op.s.timestampredirect = p_timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
1157
1158
1159
1160
1161
1162
1163
1164
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Reference *p_ref,
              TemplateInstance *p_templinst, Value *p_timerval,
1165
1166
              bool p_nowait, Value *p_toclause, Reference* p_timestampredirect,
              AltGuards *p_callbody)
Elemer Lelik's avatar
Elemer Lelik committed
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_CALL:
      if(!p_ref || !p_templinst || (p_timerval && p_nowait))
        FATAL_ERROR("Statement::Statement()");
      port_op.portref=p_ref;
      port_op.s.sendpar=p_templinst;
      port_op.s.call.timer=p_timerval;
      port_op.s.call.nowait=p_nowait;
      port_op.s.toclause=p_toclause;
      port_op.s.call.body=p_callbody;
1179
      port_op.s.timestampredirect = p_timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
1180
1181
1182
1183
1184
1185
1186
1187
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Reference *p_ref,
                       TemplateInstance *p_templinst, Value *p_replyval,
1188
                       Value *p_toclause, Reference* p_timestampredirect)
Elemer Lelik's avatar
Elemer Lelik committed
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_REPLY:
      if(!p_ref || !p_templinst)
        FATAL_ERROR("Statement::Statement()");
      port_op.portref=p_ref;
      port_op.s.sendpar=p_templinst;
      port_op.s.replyval=p_replyval;
      port_op.s.toclause=p_toclause;
1199
      port_op.s.timestampredirect = p_timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
1200
1201
1202
1203
1204
1205
1206
1207
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Reference *p_ref,
                       Reference *p_sig, TemplateInstance *p_templinst,
1208
                       Value *p_toclause, Reference* p_timestampredirect)
Elemer Lelik's avatar
Elemer Lelik committed
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_RAISE:
      if(!p_ref || !p_templinst || !p_sig)
        FATAL_ERROR("Statement::Statement()");
      port_op.portref=p_ref;
      port_op.s.raise.signature_ref=p_sig;
      port_op.s.raise.signature=0;
      port_op.s.sendpar=p_templinst;
      port_op.s.toclause=p_toclause;
1220
      port_op.s.timestampredirect = p_timestampredirect;
Elemer Lelik's avatar
Elemer Lelik committed
1221
1222
1223
1224
1225
1226
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

1227
  Statement::Statement(statementtype_t p_st, Reference *p_ref, bool p_anyfrom,
Elemer Lelik's avatar
Elemer Lelik committed
1228
1229
                       TemplateInstance *p_templinst,
                       TemplateInstance *p_fromclause,
1230
                       ValueRedirect *p_redirectval, Reference *p_redirectsender,
1231
1232
                       Reference* p_redirectindex, Reference* p_timestamp_redirect,
                       bool p_translate)
Elemer Lelik's avatar
Elemer Lelik committed
1233
1234
1235
1236
1237
1238
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_RECEIVE:
    case S_CHECK_RECEIVE:
    case S_TRIGGER:
1239
      port_op.translate = p_translate;
Elemer Lelik's avatar
Elemer Lelik committed
1240
      port_op.portref=p_ref;
1241
      port_op.anyfrom = p_anyfrom;
Elemer Lelik's avatar
Elemer Lelik committed
1242
1243
1244
1245
1246
      port_op.r.rcvpar=p_templinst;
      port_op.r.fromclause=p_fromclause;
      port_op.r.redirect.value=p_redirectval;
      port_op.r.redirect.param=0;
      port_op.r.redirect.sender=p_redirectsender;
1247
      port_op.r.redirect.index = p_redirectindex;
1248
      port_op.r.redirect.timestamp = p_timestamp_redirect;
Elemer Lelik's avatar
Elemer Lelik committed
1249
1250
1251
1252
1253
1254
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

1255
  Statement::Statement(statementtype_t p_st, Reference *p_ref, bool p_anyfrom,
Elemer Lelik's avatar
Elemer Lelik committed
1256
1257
1258
                       TemplateInstance *p_templinst,
                       TemplateInstance *p_fromclause,
                       ParamRedirect *p_redirectparam,
1259
                       Reference *p_redirectsender,
1260
1261
                       Reference* p_redirectindex,
                       Reference* p_timestamp_redirect)
Elemer Lelik's avatar
Elemer Lelik committed
1262
1263
1264
1265
1266
1267
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_GETCALL:
    case S_CHECK_GETCALL:
      port_op.portref=p_ref;
1268
      port_op.anyfrom = p_anyfrom;
Elemer Lelik's avatar
Elemer Lelik committed
1269
1270
1271
1272
1273
      port_op.r.rcvpar=p_templinst;
      port_op.r.fromclause=p_fromclause;
      port_op.r.redirect.value=0;
      port_op.r.redirect.param=p_redirectparam;
      port_op.r.redirect.sender=p_redirectsender;
1274
      port_op.r.redirect.index = p_redirectindex;
1275
      port_op.r.redirect.timestamp = p_timestamp_redirect;
Elemer Lelik's avatar
Elemer Lelik committed
1276
1277
1278
1279
1280
1281
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

1282
  Statement::Statement(statementtype_t p_st, Reference *p_ref, bool p_anyfrom,
Elemer Lelik's avatar
Elemer Lelik committed
1283
1284
1285
                       TemplateInstance *p_templinst,
                       TemplateInstance *p_valuematch,
                       TemplateInstance *p_fromclause,
1286
                       ValueRedirect *p_redirectval, ParamRedirect *p_redirectparam,
1287
1288
                       Reference *p_redirectsender, Reference* p_redirectindex,
                       Reference* p_timestamp_redirect)
Elemer Lelik's avatar
Elemer Lelik committed
1289
1290
1291
1292
1293
1294
1295
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_GETREPLY:
    case S_CHECK_GETREPLY:
      if (!p_templinst && p_valuematch) FATAL_ERROR("Statement::Statement()");
      port_op.portref=p_ref;
1296
      port_op.anyfrom = p_anyfrom;
Elemer Lelik's avatar
Elemer Lelik committed
1297
1298
1299
1300
1301
1302
      port_op.r.rcvpar=p_templinst;
      port_op.r.getreply_valuematch=p_valuematch;
      port_op.r.fromclause=p_fromclause;
      port_op.r.redirect.value=p_redirectval;
      port_op.r.redirect.param=p_redirectparam;
      port_op.r.redirect.sender=p_redirectsender;
1303
      port_op.r.redirect.index = p_redirectindex;
1304
      port_op.r.redirect.timestamp = p_timestamp_redirect;
Elemer Lelik's avatar
Elemer Lelik committed
1305
1306
1307
1308
1309
1310
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

1311
  Statement::Statement(statementtype_t p_st, Reference *p_ref, bool p_anyfrom,
Elemer Lelik's avatar
Elemer Lelik committed
1312
1313
                       Reference *p_sig, TemplateInstance *p_templinst,
                       bool p_timeout, TemplateInstance *p_fromclause,
1314
                       ValueRedirect *p_redirectval, Reference *p_redirectsender,
1315
                       Reference* p_redirectindex, Reference* p_timestamp_redirect)
Elemer Lelik's avatar
Elemer Lelik committed
1316
1317
1318
1319
1320
1321
1322
1323
1324
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_CATCH:
    case S_CHECK_CATCH:
      if (((p_sig || p_templinst) && p_timeout) ||
        (p_sig && !p_templinst) || (!p_sig && p_templinst))
	FATAL_ERROR("Statement::Statement()");
      port_op.portref=p_ref;
1325
      port_op.anyfrom = p_anyfrom;
Elemer Lelik's avatar
Elemer Lelik committed
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
      port_op.r.ctch.signature_ref=p_sig;
      port_op.r.ctch.signature=0;
      port_op.r.rcvpar=p_templinst;
      port_op.r.ctch.timeout=p_timeout;
      port_op.r.ctch.in_call=false;
      port_op.r.ctch.call_has_timer=false;
      port_op.r.fromclause=p_fromclause;
      port_op.r.redirect.value=p_redirectval;
      port_op.r.redirect.param=0;
      port_op.r.redirect.sender=p_redirectsender;
1336
      port_op.r.redirect.index = p_redirectindex;
1337
      port_op.r.redirect.timestamp = p_timestamp_redirect;
Elemer Lelik's avatar
Elemer Lelik committed
1338
1339
1340
1341
1342
1343
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

1344
  Statement::Statement(statementtype_t p_st, Reference *p_ref, bool p_anyfrom,
Elemer Lelik's avatar
Elemer Lelik committed
1345
                       TemplateInstance *p_fromclause,
1346
1347
                       Reference *p_redirectsender, Reference* p_redirectindex,
                       Reference* p_timestamp_redirect)
Elemer Lelik's avatar
Elemer Lelik committed
1348
1349
1350
1351
1352
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_CHECK:
      port_op.portref=p_ref; // may be NULL for "any port.check"
1353
      port_op.anyfrom = p_anyfrom;
Elemer Lelik's avatar
Elemer Lelik committed
1354
1355
1356
1357
      port_op.r.fromclause=p_fromclause;
      port_op.r.redirect.value=0;
      port_op.r.redirect.param=0;
      port_op.r.redirect.sender=p_redirectsender;
1358
      port_op.r.redirect.index = p_redirectindex;
1359
      port_op.r.redirect.timestamp = p_timestamp_redirect;
Elemer Lelik's avatar
Elemer Lelik committed
1360
1361
1362
1363
1364
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
  
  Statement::Statement(statementtype_t p_st, Reference *p_ref, bool p_any_from,
                       Reference* p_redirectindex)
    : statementtype(p_st), my_sb(0)
  {
    if (statementtype != S_TIMEOUT) {
      FATAL_ERROR("Statement::Statement()");
    }
    timer_op.timerref = p_ref;
    timer_op.any_from = p_any_from;
    timer_op.index_redirect = p_redirectindex;
  }
Elemer Lelik's avatar
Elemer Lelik committed
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395

  Statement::Statement(statementtype_t p_st, Value *p_compref,
                        Value *p_derefered_value, ParsedActualParameters *p_ap_list)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_START_COMP_REFD:
      if(!p_compref || !p_derefered_value || !p_ap_list)
        FATAL_ERROR("Statement::Statement()");
      comp_op.compref = p_compref;
      comp_op.derefered.value = p_derefered_value;
      comp_op.derefered.t_list1 = p_ap_list;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    }
  }

  Statement::Statement(statementtype_t p_st, Value *p_compref,
1396
1397
                       TemplateInstance *p_donematch, ValueRedirect *p_redirect,
                       Reference* p_index_redirect, bool p_any_from)
Elemer Lelik's avatar
Elemer Lelik committed
1398
1399
1400
1401
1402
1403
1404
1405
    : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_DONE:
      if (!p_compref) FATAL_ERROR("Statement::Statement()");
      comp_op.compref = p_compref;
      comp_op.donereturn.donematch = p_donematch;
      comp_op.donereturn.redirect = p_redirect;
1406
1407
      comp_op.index_redirect = p_index_redirect;
      comp_op.any_from = p_any_from;
Elemer Lelik's avatar
Elemer Lelik committed
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, component_t p_anyall)
    : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_DONE:
1419
1420
1421
      comp_op.donereturn.donematch = NULL;
      comp_op.donereturn.redirect = NULL;
      // no break
Elemer Lelik's avatar
Elemer Lelik committed
1422
1423
1424
    case S_KILLED:
      comp_op.compref = 0;
      comp_op.any_or_all = p_anyall;
1425
1426
      comp_op.any_from = false;
      comp_op.index_redirect = NULL;
Elemer Lelik's avatar
Elemer Lelik committed
1427
1428
1429
1430
1431
1432
1433
1434
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st,
                       Value *p_compref1, Reference *p_portref1,
1435
1436
                       Value *p_compref2, Reference *p_portref2,
                       ParsedActualParameters* p_params)
Elemer Lelik's avatar
Elemer Lelik committed
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_CONNECT:
    case S_MAP:
    case S_DISCONNECT:
    case S_UNMAP:
      if(!p_compref1 || !p_portref1 || !p_compref2 || !p_portref2)
        FATAL_ERROR("Statement::Statement()");
      config_op.compref1=p_compref1;
      config_op.portref1=p_portref1;
      config_op.compref2=p_compref2;
      config_op.portref2=p_portref2;
1450
      config_op.translate=false;
1451
1452
      config_op.parsed_params=p_params;
      config_op.fp_list=NULL;
Elemer Lelik's avatar
Elemer Lelik committed
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    } // switch statementtype
  }

  Statement::Statement(statementtype_t p_st, Value *p_derefered_value,
                        TemplateInstances *p_ap_list, Value *p_val)
    : statementtype(p_st), my_sb(0)
  {
    switch(statementtype) {
    case S_TESTCASE_INSTANCE_REFD:
      if(!p_derefered_value) FATAL_ERROR("Statement::Statement()");
      execute_refd.value = p_derefered_value;
      execute_refd.t_list1 = p_ap_list;
      execute_refd.timerval = p_val;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    }
  }

Elemer Lelik's avatar
Elemer Lelik committed
1475
1476
  Statement::Statement(statementtype_t p_st, Value* p_val, Reference* p_ref)
    : statementtype(p_st), my_sb(0)
Elemer Lelik's avatar
Elemer Lelik committed
1477
  {
Elemer Lelik's avatar
Elemer Lelik committed
1478
1479
1480
1481
1482
1483
1484
1485
1486
    switch (statementtype) {
    case S_STRING2TTCN:
    case S_INT2ENUM:
      if (p_val==NULL || p_ref==NULL) {
        FATAL_ERROR("Statement::Statement()");
      }
      convert_op.val = p_val;
      convert_op.ref = p_ref;
      break;
1487
1488
1489
1490
1491
1492
1493
    case S_START_COMP:
      if (p_val==NULL || p_ref==NULL) {
        FATAL_ERROR("Statement::Statement()");
      }
      comp_op.compref = p_val;
      comp_op.funcinstref = p_ref;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
1494
1495
1496
    default:
      FATAL_ERROR("Statement::Statement()");
    }
Elemer Lelik's avatar
Elemer Lelik committed
1497
  }
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
  
  Statement::Statement(statementtype_t p_st, Reference* p_ref, MultiWithAttrib* p_attrib)
  : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_UPDATE:
      if (p_ref == NULL) {
        FATAL_ERROR("Statement::Statement()");
      }
      update_op.ref = p_ref;
      if (p_attrib != NULL) {
        update_op.w_attrib_path = new WithAttribPath;
        update_op.w_attrib_path->set_with_attr(p_attrib);
      }
      else {
        update_op.w_attrib_path = NULL;
      }
      update_op.err_attrib = NULL;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    }
  }
1521
  
1522
  Statement::Statement(statementtype_t p_st, Value* p_val, TemplateInstance* p_ti)
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
  : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_SETSTATE:
      if (p_val == NULL || p_ti == NULL) {
        FATAL_ERROR("Statement::Statement()");
      }
      setstate_op.val = p_val;
      setstate_op.ti = p_ti;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    }
  }
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
    
  Statement::Statement(statementtype_t p_st, Type* p_type, Value* p_encoding)
  : statementtype(p_st), my_sb(0)
  {
    switch (statementtype) {
    case S_SETENCODE:
      if (p_type == NULL || p_encoding == NULL) {
        FATAL_ERROR("Statement::Statement()");
      }
      setencode_op.type = p_type;
      setencode_op.encoding = p_encoding;
      break;
    default:
      FATAL_ERROR("Statement::Statement()");
    }
  }
Elemer Lelik's avatar
Elemer Lelik committed
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565

  Statement::~Statement()
  {
    clean_up();
  }

  Statement *Statement::clone() const
  {
    FATAL_ERROR("Statement::clone");
  }

  void Statement::dump(unsigned int level) const
  {
1566
    DEBUG(level, "Statement at %p, a(n) %s", static_cast<const void *>(this),
Elemer Lelik's avatar
Elemer Lelik committed
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
          get_stmt_name());
    switch (statementtype) {
    case S_TESTCASE_INSTANCE:
    case S_TESTCASE_INSTANCE_REFD: {
      Common::Value *v = execute_refd.value;
      v->dump(level + 1);
    } break;
    case S_DEF:
      def->dump(level + 1);
      break;
    case S_ASSIGNMENT:
      ass->dump(level + 1);
      break;
    case S_BLOCK:
      block->dump(level + 1);
      break;
    case S_IF:
      if_stmt.ics->dump(level + 1);
      if (if_stmt.elseblock) if_stmt.elseblock->dump(level + 1);
      break;
    default:
      break;
    }
  }

  size_t Statement::get_my_sb_index() const
  {
    switch (statementtype) {
    case S_LABEL:
      return label.stmt_idx;
    case S_GOTO:
      return go_to.stmt_idx;
    default:
      FATAL_ERROR("Statement::get_my_sb_index()");
      return 0;
    }
  }

  const char *Statement::get_stmt_name() const
  {
    switch(statementtype) {
    case S_ERROR: return "<erroneous statement>";
    case S_START_UNDEF: return "start";
    case S_STOP_UNDEF: return "stop";
    case S_UNKNOWN_INSTANCE: return "function or altstep instance";
    case S_UNKNOWN_INVOKED: return "function or altstep type invocation";
    case S_DEF: return "definition";
    case S_ASSIGNMENT: return "assignment";
    case S_FUNCTION_INSTANCE: return "function instance";
    case S_FUNCTION_INVOKED: return "function type invocation";
    case S_BLOCK: return "statement block";
    case S_LOG: return "log";
    case S_LABEL: return "label";
    case S_GOTO: return "goto";
    case S_IF: return "if";
    case S_SELECT: return "select-case";
1623
    case S_SELECTUNION: return "select-union";
1624
    case S_SELECT_CLASS: return "select-class";
Elemer Lelik's avatar
Elemer Lelik committed
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
    case S_FOR: return "for";
    case S_WHILE: return "while";
    case S_DOWHILE: return "do-while";
    case S_BREAK: return "break";
    case S_CONTINUE: return "continue";
    case S_STOP_EXEC: return "stop";
    case S_STOP_TESTCASE: return "testcase.stop";
    case S_ALT: return "alt";
    case S_REPEAT: return "repeat";
    case S_INTERLEAVE: return "interleave";
    case S_ALTSTEP_INSTANCE: return "altstep instance";
    case S_ALTSTEP_INVOKED: return "altstep type invocation";
    case S_RETURN: return "return";
    case S_ACTIVATE:
    case S_ACTIVATE_REFD:
      return "activate";
    case S_DEACTIVATE: return "deactivate";
    case S_SEND: return "send";
    case S_CALL: return "call";
    case S_REPLY: return "reply";
    case S_RAISE: return "raise";
    case S_RECEIVE: return "receive";
    case S_TRIGGER: return "trigger";
    case S_GETCALL: return "getcall";
    case S_GETREPLY: return "getreply";
    case S_CATCH: return "catch";
    case S_CHECK: return "check";
    case S_CHECK_RECEIVE: return "check-receive";
    case S_CHECK_GETCALL: return "check-getcall";
    case S_CHECK_GETREPLY: return "check-getreply";
    case S_CHECK_CATCH: return "check-catch";
    case S_CLEAR: return "clear";
    case S_START_PORT: return "start port";
    case S_STOP_PORT: return "stop port";
    case S_HALT: return "halt";
    case S_START_COMP:
    case S_START_COMP_REFD:
      return "start test component";
    case S_STOP_COMP: return "stop test component";
    case S_DONE: return "done";
    case S_KILL: return "kill";
    case S_KILLED: return "killed";
    case S_CONNECT: return "connect";
    case S_MAP: return "map";
    case S_DISCONNECT: return "disconnect";
    case S_UNMAP: return "unmap";
    case S_START_TIMER: return "start timer";
    case S_STOP_TIMER: return "stop timer";
    case S_TIMEOUT: return "timeout";
    case S_SETVERDICT: return "setverdict";
    case S_ACTION: return "action";
    case S_TESTCASE_INSTANCE:
    case S_TESTCASE_INSTANCE_REFD:
      return "execute";
    case S_STRING2TTCN: return "string2ttcn";
Elemer Lelik's avatar
Elemer Lelik committed
1680
    case S_INT2ENUM: return "int2enum";
Elemer Lelik's avatar
Elemer Lelik committed
1681
1682
    case S_START_PROFILER: return "@profiler.start";
    case S_STOP_PROFILER: return "@profiler.stop";
1683
    case S_UPDATE: return "@update";
1684
    case S_SETSTATE: return "setstate";
1685
    case S_SETENCODE: return "setencode";
Elemer Lelik's avatar
Elemer Lelik committed
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
    default:
      FATAL_ERROR("Statement::get_stmt_name()");
      return "";
    } // switch statementtype
  }

  const Identifier& Statement::get_labelid() const
  {
    switch (statementtype) {
    case S_LABEL:
      return *label.id;
    case S_GOTO:
      return *go_to.id;
    default:
      FATAL_ERROR("Statement::get_labelid()");
      return *label.id;
    }
  }

  bool Statement::label_is_used() const
  {
    if (statementtype != S_LABEL) FATAL_ERROR("Statement::label_is_used()");
    return label.used;
  }

  bool Statement::goto_jumps_forward() const
  {
    if (statementtype != S_GOTO) FATAL_ERROR("Statement::goto_jumps_forward()");
    return go_to.jumps_forward;
  }

  const string& Statement::get_clabel()
  {
    if (statementtype != S_LABEL || !my_sb)
      FATAL_ERROR("Statement::get_clabel()");
    if (!label.clabel) label.clabel =
	new string(my_sb->get_scope_mod_gen()->get_temporary_id());
    return *label.clabel;
  }

  Definition *Statement::get_def() const
  {
    if (statementtype != S_DEF) FATAL_ERROR("Statement::get_def()");
    return def;
  }

  AltGuards *Statement::get_ags() const
  {
    if (statementtype != S_ALT && statementtype != S_INTERLEAVE)
      FATAL_ERROR("Statement::get_ags()");
    return ags;
  }

  StatementBlock *Statement::get_block() const
  {
    switch (statementtype) {
    case S_BLOCK:
      return block;
    case S_FOR:
    case S_WHILE:
    case S_DOWHILE:
      return loop.block;
    default:
      FATAL_ERROR("Statement::get_block()");
      return 0;
    }
  }

  void Statement::set_my_scope(Scope *p_scope)
  {
    switch(statementtype) {
    case S_ERROR:
    case S_LABEL:
    case S_GOTO:
    case S_BREAK:
    case S_CONTINUE:
    case S_STOP_EXEC:
    case S_REPEAT:
Elemer Lelik's avatar
Elemer Lelik committed
1764
1765
    case S_START_PROFILER:
    case S_STOP_PROFILER:
Elemer Lelik's avatar
Elemer Lelik committed
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
      break;
    case S_START_UNDEF:
    case S_STOP_UNDEF:
      undefstartstop.ref->set_my_scope(p_scope);
      if (undefstartstop.val) undefstartstop.val->set_my_scope(p_scope);
      break;
    case S_UNKNOWN_INSTANCE:
    case S_FUNCTION_INSTANCE:
    case S_ALTSTEP_INSTANCE:
    case S_ACTIVATE:
      ref_pard->set_my_scope(p_scope);
      break;
    case S_DEF:
      def->set_my_scope(p_scope);
      break;
    case S_ASSIGNMENT:
      ass->set_my_scope(p_scope);
      break;
    case S_BLOCK:
      block->set_my_scope(p_scope);
      break;
    case S_LOG:
    case S_ACTION:
    case S_STOP_TESTCASE:
      if (logargs) logargs->set_my_scope(p_scope);
      break;
    case S_IF:
      if_stmt.ics->set_my_scope(p_scope);
      if(if_stmt.elseblock) if_stmt.elseblock->set_my_scope(p_scope);
      break;
    case S_SELECT:
      select.expr->set_my_scope(p_scope);
      select.scs->set_my_scope(p_scope);
      break;
1800
1801
1802
1803
    case S_SELECTUNION:
      select_union.expr->set_my_scope(p_scope);
      select_union.sus->set_my_scope(p_scope);
      break;
1804
1805
1806
1807
    case S_SELECT_CLASS:
      select_class.ref->set_my_scope(p_scope);
      select_class.sccs->set_my_scope(p_scope);
      break;
Elemer Lelik's avatar
Elemer Lelik committed
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
    case S_FOR:
      if (loop.for_stmt.varinst) {
        loop.for_stmt.init_varinst->set_parent_scope(p_scope);
        loop.for_stmt.finalexpr->set_my_scope(loop.for_stmt.init_varinst);
        loop.for_stmt.step->set_my_scope(loop.for_stmt.init_varinst);
        loop.block->set_my_scope(loop.for_stmt.init_varinst);
      } else {
        loop.for_stmt.init_ass->set_my_scope(p_scope);
        loop.for_stmt.finalexpr->set_my_scope(p_scope);
        loop.for_stmt.step->set_my_scope(p_scope);
        loop.block->set_my_scope(p_scope);
      }
      break;
    case S_WHILE:
    case S_DOWHILE:
      loop.expr->set_my_scope(p_scope);
      loop.block->set_my_scope(p_scope);
      break;
    case S_ALT:
    case S_INTERLEAVE:
      ags->set_my_scope(p_scope);
      break;
    case S_RETURN:
      if (returnexpr.v) returnexpr.v->set_my_scope(p_scope);
      if (returnexpr.t) returnexpr.t->set_my_scope(p_scope);
      break;
    case S_DEACTIVATE:
      if (deactivate) deactivate->set_my_scope(p_scope);
      break;
    case S_SEND:
1838
      if (!port_op.translate) port_op.portref->set_my_scope(p_scope);
Elemer Lelik's avatar
Elemer Lelik committed
1839
1840
      port_op.s.sendpar->set_my_scope(p_scope);
      if(port_op.s.toclause) port_op.s.toclause->set_my_scope(p_scope);
1841
1842
1843
      if (port_op.s.timestampredirect != NULL) {
        port_op.s.timestampredirect->set_my_scope(p_scope);
      }
Elemer Lelik's avatar
Elemer Lelik committed
1844
1845
1846
1847
1848
1849
1850
      break;
    case S_CALL:
      port_op.portref->set_my_scope(p_scope);
      port_op.s.sendpar->set_my_scope(p_scope);
      if(port_op.s.toclause) port_op.s.toclause->set_my_scope(p_scope);
      if(port_op.s.call.timer) port_op.s.call.timer->set_my_scope(p_scope);
      if(port_op.s.call.body) port_op.s.call.body->set_my_scope(p_scope);
1851
1852
1853
      if (port_op.s.timestampredirect != NULL) {
        port_op.s.timestampredirect->set_my_scope(p_scope);
      }
Elemer Lelik's avatar
Elemer Lelik committed
1854
1855
1856
1857
1858
1859
      break;
    case S_REPLY:
      port_op.portref->set_my_scope(p_scope);
      port_op.s.sendpar->set_my_scope(p_scope);
      if(port_op.s.replyval) port_op.s.replyval->set_my_scope(p_scope);
      if(port_op.s.toclause) port_op.s.toclause->set_my_scope(p_scope);
1860
1861
1862
      if (port_op.s.timestampredirect != NULL) {
        port_op.s.timestampredirect->set_my_scope(p_scope);
      }
Elemer Lelik's avatar
Elemer Lelik committed
1863
1864
1865
1866
1867
1868
      break;
    case S_RAISE:
      port_op.portref->set_my_scope(p_scope);
      port_op.s.raise.signature_ref->set_my_scope(p_scope);
      port_op.s.sendpar->set_my_scope(p_scope);
      if(port_op.s.toclause) port_op.s.toclause->set_my_scope(p_scope);
1869
1870
1871
      if (port_op.s.timestampredirect != NULL) {
        port_op.s.timestampredirect->set_my_scope(p_scope);
      }