Value.cc 541 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
/******************************************************************************
balaskoa's avatar
balaskoa committed
2
 * Copyright (c) 2000-2018 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
19
20
21
22
23
 *
 * Contributors:
 *   Baji, Laszlo
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Beres, Szabolcs
 *   Bibo, Zoltan
 *   Cserveni, Akos
 *   Delic, Adam
 *   Dimitrov, Peter
 *   Feher, Csaba
 *   Forstner, Matyas
 *   Gecse, Roland
 *   Kovacs, Ferenc
 *   Ormandi, Matyas
 *   Raduly, Csaba
 *   Szabados, Kristof
24
 *   Szabo, Bence Janos
Elemer Lelik's avatar
Elemer Lelik committed
25
26
27
28
29
30
 *   Szabo, Janos Zoltan – initial implementation
 *   Szalai, Gabor
 *   Tatarka, Gabor
 *   Zalanyi, Balazs Andor
 *
 ******************************************************************************/
Elemer Lelik's avatar
Elemer Lelik committed
31
32
#include "../common/dbgnew.hh"
#include "Value.hh"
33
#include "AST.hh"
Elemer Lelik's avatar
Elemer Lelik committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "Identifier.hh"
#include "Valuestuff.hh"
#include "PredefFunc.hh"
#include "CompField.hh"
#include "CompType.hh"
#include "EnumItem.hh"
#include "TypeCompat.hh"
#include "asn1/Block.hh"
#include "asn1/TokenBuf.hh"
#include "Real.hh"
#include "Int.hh"
#include "main.hh"
#include "Setting.hh"
#include "Type.hh"
#include "ttcn3/TtcnTemplate.hh"
#include "ttcn3/ArrayDimensions.hh"
#include "ustring.hh"
#include "../common/pattern.hh"

#include "ttcn3/PatternString.hh"
#include "ttcn3/Statement.hh"

#include "ttcn3/Attributes.hh"
57
#include "ttcn3/JsonAST.hh"
Elemer Lelik's avatar
Elemer Lelik committed
58
#include "../common/JSON_Tokenizer.hh"
Elemer Lelik's avatar
Elemer Lelik committed
59
#include "ttcn3/Ttcn2Json.hh"
Elemer Lelik's avatar
Elemer Lelik committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

#include <regex.h>
#include <limits.h>

namespace Common {

  static void clean_up_string_elements(map<size_t, Value>*& string_elements)
  {
    if (string_elements) {
      for (size_t i = 0; i < string_elements->size(); i++)
	delete string_elements->get_nth_elem(i);
      string_elements->clear();
      delete string_elements;
      string_elements = 0;
    }
  }

  // =================================
  // ===== Value
  // =================================

  Value::Value(const Value& p)
    : GovernedSimple(p), valuetype(p.valuetype), my_governor(0)
83
    , in_brackets(p.in_brackets)
Elemer Lelik's avatar
Elemer Lelik committed
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  {
    switch(valuetype) {
    case V_ERROR:
    case V_NULL:
    case V_OMIT:
    case V_TTCN3_NULL:
    case V_DEFAULT_NULL:
    case V_FAT_NULL:
    case V_NOTUSED:
      break;
    case V_BOOL:
      u.val_bool=p.u.val_bool;
      break;
    case V_INT:
      u.val_Int=new int_val_t(*(p.u.val_Int));
      break;
    case V_NAMEDINT:
    case V_ENUM:
    case V_UNDEF_LOWERID:
      u.val_id=p.u.val_id->clone();
      break;
    case V_REAL:
      u.val_Real=p.u.val_Real;
      break;
    case V_BSTR:
    case V_HSTR:
    case V_OSTR:
    case V_CSTR:
    case V_ISO2022STR:
      set_val_str(new string(*p.u.str.val_str));
      break;
    case V_USTR:
      set_val_ustr(new ustring(*p.u.ustr.val_ustr));
      u.ustr.convert_str = p.u.ustr.convert_str;
      break;
    case V_CHARSYMS:
      u.char_syms = p.u.char_syms->clone();
      break;
    case V_OID:
    case V_ROID:
      u.oid_comps=new vector<OID_comp>;
      for(size_t i=0; i<p.u.oid_comps->size(); i++)
        add_oid_comp((*p.u.oid_comps)[i]->clone());
      break;
    case V_CHOICE:
      u.choice.alt_name=p.u.choice.alt_name->clone();
      u.choice.alt_value=p.u.choice.alt_value->clone();
      break;
    case V_SEQOF:
    case V_SETOF:
    case V_ARRAY:
      u.val_vs=p.u.val_vs->clone();
      break;
    case V_SEQ:
    case V_SET:
      u.val_nvs=p.u.val_nvs->clone();
      break;
    case V_REFD:
      u.ref.ref=p.u.ref.ref->clone();
      u.ref.refd_last=0;
      break;
    case V_NAMEDBITS:
      for(size_t i=0; i<p.u.ids->size(); i++) {
        Identifier *id = p.u.ids->get_nth_elem(i);
        u.ids->add(id->get_name(), id->clone());
      }
      break;
    case V_UNDEF_BLOCK:
      u.block=p.u.block->clone();
      break;
    case V_VERDICT:
      u.verdict=p.u.verdict;
      break;
    case V_EXPR:
      u.expr.v_optype = p.u.expr.v_optype;
      u.expr.state = EXPR_NOT_CHECKED;
      switch(u.expr.v_optype) {
      case OPTYPE_RND: // -
      case OPTYPE_COMP_NULL:
      case OPTYPE_COMP_MTC:
      case OPTYPE_COMP_SYSTEM:
      case OPTYPE_COMP_SELF:
      case OPTYPE_COMP_RUNNING_ANY:
      case OPTYPE_COMP_RUNNING_ALL:
      case OPTYPE_COMP_ALIVE_ANY:
      case OPTYPE_COMP_ALIVE_ALL:
      case OPTYPE_TMR_RUNNING_ANY:
      case OPTYPE_GETVERDICT:
      case OPTYPE_TESTCASENAME:
Elemer Lelik's avatar
Elemer Lelik committed
173
      case OPTYPE_PROF_RUNNING:
Elemer Lelik's avatar
Elemer Lelik committed
174
        break;
175
176
177
      case OPTYPE_GET_PORT_REF:
        u.expr.type = p.u.expr.type; // the type is not owned, don't copy it
        break;
178
179
180
181
182
      case OPTYPE_COMP_RUNNING: // v1 [r2] b4
      case OPTYPE_COMP_ALIVE:
        u.expr.r2 = p.u.expr.r2 != NULL ? p.u.expr.r2->clone() : NULL;
        u.expr.b4 = p.u.expr.b4;
        // no break
Elemer Lelik's avatar
Elemer Lelik committed
183
184
185
186
187
188
189
190
      case OPTYPE_UNARYPLUS: // v1
      case OPTYPE_UNARYMINUS:
      case OPTYPE_NOT:
      case OPTYPE_NOT4B:
      case OPTYPE_BIT2HEX:
      case OPTYPE_BIT2INT:
      case OPTYPE_BIT2OCT:
      case OPTYPE_BIT2STR:
191
      case OPTYPE_BSON2JSON:
192
      case OPTYPE_CBOR2JSON:
Elemer Lelik's avatar
Elemer Lelik committed
193
194
195
196
197
198
199
200
201
202
203
204
      case OPTYPE_CHAR2INT:
      case OPTYPE_CHAR2OCT:
      case OPTYPE_FLOAT2INT:
      case OPTYPE_FLOAT2STR:
      case OPTYPE_HEX2BIT:
      case OPTYPE_HEX2INT:
      case OPTYPE_HEX2OCT:
      case OPTYPE_HEX2STR:
      case OPTYPE_INT2CHAR:
      case OPTYPE_INT2FLOAT:
      case OPTYPE_INT2STR:
      case OPTYPE_INT2UNICHAR:
205
      case OPTYPE_JSON2BSON:
206
      case OPTYPE_JSON2CBOR:
Elemer Lelik's avatar
Elemer Lelik committed
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
      case OPTYPE_OCT2BIT:
      case OPTYPE_OCT2CHAR:
      case OPTYPE_OCT2HEX:
      case OPTYPE_OCT2INT:
      case OPTYPE_OCT2STR:
      case OPTYPE_STR2BIT:
      case OPTYPE_STR2FLOAT:
      case OPTYPE_STR2HEX:
      case OPTYPE_STR2INT:
      case OPTYPE_STR2OCT:
      case OPTYPE_UNICHAR2INT:
      case OPTYPE_UNICHAR2CHAR:
      case OPTYPE_ENUM2INT:
      case OPTYPE_RNDWITHVAL:
      case OPTYPE_GET_STRINGENCODING:
      case OPTYPE_DECODE_BASE64:
      case OPTYPE_REMOVE_BOM:
        u.expr.v1=p.u.expr.v1->clone();
        break;
ebensza's avatar
ebensza committed
226
227
228
      case OPTYPE_HOSTID: // [v1]
        u.expr.v1=p.u.expr.v1?p.u.expr.v1->clone():0;
        break;
Elemer Lelik's avatar
Elemer Lelik committed
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
      case OPTYPE_ADD: // v1 v2
      case OPTYPE_SUBTRACT:
      case OPTYPE_MULTIPLY:
      case OPTYPE_DIVIDE:
      case OPTYPE_MOD:
      case OPTYPE_REM:
      case OPTYPE_CONCAT:
      case OPTYPE_EQ:
      case OPTYPE_LT:
      case OPTYPE_GT:
      case OPTYPE_NE:
      case OPTYPE_GE:
      case OPTYPE_LE:
      case OPTYPE_AND:
      case OPTYPE_OR:
      case OPTYPE_XOR:
      case OPTYPE_AND4B:
      case OPTYPE_OR4B:
      case OPTYPE_XOR4B:
      case OPTYPE_SHL:
      case OPTYPE_SHR:
      case OPTYPE_ROTL:
      case OPTYPE_ROTR:
      case OPTYPE_INT2BIT:
      case OPTYPE_INT2HEX:
      case OPTYPE_INT2OCT:
        u.expr.v1=p.u.expr.v1->clone();
        u.expr.v2=p.u.expr.v2->clone();
        break;
      case OPTYPE_UNICHAR2OCT: // v1 [v2]
      case OPTYPE_OCT2UNICHAR:
      case OPTYPE_ENCODE_BASE64:
        u.expr.v1=p.u.expr.v1->clone();
        u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0;
        break;
264
265
      case OPTYPE_UNDEF_RUNNING: // r1 [r2] b4
      case OPTYPE_TMR_RUNNING: // r1 [r2] b4
Elemer Lelik's avatar
Elemer Lelik committed
266
        u.expr.r1=p.u.expr.r1->clone();
267
268
        u.expr.r2 = p.u.expr.r2 != NULL ? p.u.expr.r2->clone() : NULL;
        u.expr.b4 = p.u.expr.b4;
Elemer Lelik's avatar
Elemer Lelik committed
269
        break;
270
271
272
273
274
275
      case OPTYPE_DECODE: // r1 r2 [v3] [v4]
        u.expr.r1 = p.u.expr.r1->clone();
        u.expr.r2 = p.u.expr.r2->clone();
        u.expr.v2 = p.u.expr.v3 != NULL ? p.u.expr.v3->clone() : NULL;
        u.expr.v3 = p.u.expr.v4 != NULL ? p.u.expr.v4->clone() : NULL;
        break;
Elemer Lelik's avatar
Elemer Lelik committed
276
      case OPTYPE_SUBSTR:
277
      case OPTYPE_ENCODE:
Elemer Lelik's avatar
Elemer Lelik committed
278
        u.expr.ti1=p.u.expr.ti1->clone();
279
280
        u.expr.v2 = p.u.expr.v2 != NULL ? p.u.expr.v2->clone() : NULL;
        u.expr.v3 = p.u.expr.v3 != NULL ? p.u.expr.v3->clone() : NULL;
Elemer Lelik's avatar
Elemer Lelik committed
281
282
283
284
285
        break;
      case OPTYPE_REGEXP:
        u.expr.ti1=p.u.expr.ti1->clone();
        u.expr.t2=p.u.expr.t2->clone();
        u.expr.v3=p.u.expr.v3->clone();
286
        u.expr.b4=p.u.expr.b4;
Elemer Lelik's avatar
Elemer Lelik committed
287
288
289
290
291
292
293
294
295
296
297
298
        break;
      case OPTYPE_DECOMP: // v1 v2 v3
        u.expr.v1=p.u.expr.v1->clone();
        u.expr.v2=p.u.expr.v2->clone();
        u.expr.v3=p.u.expr.v3->clone();
        break;
      case OPTYPE_REPLACE:
        u.expr.ti1 = p.u.expr.ti1->clone();
        u.expr.v2 = p.u.expr.v2->clone();
        u.expr.v3 = p.u.expr.v3->clone();
        u.expr.ti4 = p.u.expr.ti4->clone();
        break;
299
300
301
      case OPTYPE_VALUEOF: // ti1 [subrefs2]
        u.expr.subrefs2 = p.u.expr.subrefs2 != NULL ? u.expr.subrefs2->clone() : NULL;
        // fall through
Elemer Lelik's avatar
Elemer Lelik committed
302
303
304
305
      case OPTYPE_LENGTHOF: // ti1
      case OPTYPE_SIZEOF:  // ti1
      case OPTYPE_ISPRESENT:
      case OPTYPE_TTCN2STRING:
306
307
      case OPTYPE_ISVALUE:
      case OPTYPE_ISBOUND:
Elemer Lelik's avatar
Elemer Lelik committed
308
309
        u.expr.ti1=p.u.expr.ti1->clone();
        break;
310
      case OPTYPE_ENCVALUE_UNICHAR: // ti1 [v2] [v3] [v4]
311
312
        u.expr.ti1=p.u.expr.ti1->clone();
        u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0;
313
314
        u.expr.v3 = p.u.expr.v3 != NULL ? p.u.expr.v3->clone() : NULL;
        u.expr.v4 = p.u.expr.v4 != NULL ? p.u.expr.v4->clone() : NULL;
315
        break; 
316
      case OPTYPE_DECVALUE_UNICHAR: // r1 r2 [v3] [v4] [v5]
317
318
        u.expr.r1 = p.u.expr.r1->clone();
        u.expr.r2 = p.u.expr.r2->clone();
319
320
321
        u.expr.v3 = p.u.expr.v3 != NULL ? p.u.expr.v3->clone() : NULL;
        u.expr.v4 = p.u.expr.v4 != NULL ? p.u.expr.v4->clone() : NULL;
        u.expr.v5 = p.u.expr.v5 != NULL ? p.u.expr.v5->clone() : NULL;
322
        break;
Elemer Lelik's avatar
Elemer Lelik committed
323
324
325
326
327
328
329
330
      case OPTYPE_TMR_READ:
      case OPTYPE_ACTIVATE:
        u.expr.r1=p.u.expr.r1->clone();
        break;
      case OPTYPE_EXECUTE: // r1 [v2]
        u.expr.r1=p.u.expr.r1->clone();
        u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0;
        break;
331
332
333
334
335
      case OPTYPE_CHECKSTATE_ANY: // [r1] v2
      case OPTYPE_CHECKSTATE_ALL:
        u.expr.r1=p.u.expr.r1?p.u.expr.r1->clone():0;
        u.expr.v2=p.u.expr.v2->clone();
        break;
Elemer Lelik's avatar
Elemer Lelik committed
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
      case OPTYPE_COMP_CREATE: // r1 [v2] [v3]
        u.expr.r1=p.u.expr.r1->clone();
        u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0;
        u.expr.v3=p.u.expr.v3?p.u.expr.v3->clone():0;
        u.expr.b4 = p.u.expr.b4;
        break;
      case OPTYPE_MATCH: // v1 t2
        u.expr.v1=p.u.expr.v1->clone();
        u.expr.t2=p.u.expr.t2->clone();
        break;
      case OPTYPE_ISCHOSEN: // r1 i2
        u.expr.r1=p.u.expr.r1->clone();
        u.expr.i2=p.u.expr.i2->clone();
        break;
      case OPTYPE_ISCHOSEN_V: // v1 i2
        u.expr.v1=p.u.expr.v1->clone();
        u.expr.i2=p.u.expr.i2->clone();
        break;
      case OPTYPE_ISCHOSEN_T: // t1 i2
        u.expr.t1=p.u.expr.t1->clone();
        u.expr.i2=p.u.expr.i2->clone();
        break;
      case OPTYPE_ACTIVATE_REFD:
        u.expr.v1 = p.u.expr.v1->clone();
        if(p.u.expr.state!=EXPR_CHECKED)
          u.expr.t_list2 = p.u.expr.t_list2->clone();
        else {
          u.expr.ap_list2 = p.u.expr.ap_list2->clone();
          u.expr.state = EXPR_CHECKED;
          }
        break;
      case OPTYPE_EXECUTE_REFD:
        u.expr.v1 = p.u.expr.v1->clone();
        if(p.u.expr.state!=EXPR_CHECKED)
          u.expr.t_list2 = p.u.expr.t_list2->clone();
        else {
          u.expr.ap_list2 = p.u.expr.ap_list2->clone();
          u.expr.state = EXPR_CHECKED;
          }
        u.expr.v3 = p.u.expr.v3 ? p.u.expr.v3->clone() : 0;
        break;
      case OPTYPE_LOG2STR:
378
      case OPTYPE_ANY2UNISTR:
Elemer Lelik's avatar
Elemer Lelik committed
379
380
        u.expr.logargs = p.u.expr.logargs->clone();
        break;
381
382
383
384
      case OPTYPE_ISTEMPLATEKIND:
        u.expr.ti1 = p.u.expr.ti1->clone();
        u.expr.v2 = p.u.expr.v2->clone();
        break;
Elemer Lelik's avatar
Elemer Lelik committed
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
      default:
        FATAL_ERROR("Value::Value()");
      } // switch
      break;
    case V_MACRO:
      u.macro = p.u.macro;
      break;
    case V_FUNCTION:
    case V_ALTSTEP:
    case V_TESTCASE:
      u.refd_fat = p.u.refd_fat;
      break;
    case V_INVOKE:
      u.invoke.v = p.u.invoke.v->clone();
      u.invoke.t_list = p.u.invoke.t_list?p.u.invoke.t_list->clone():0;
      u.invoke.ap_list = p.u.invoke.ap_list?p.u.invoke.ap_list->clone():0;
      break;
    case V_REFER:
      u.refered = p.u.refered->clone();
      break;
405
406
407
408
    case V_ANY_VALUE:
    case V_ANY_OR_OMIT:
      u.len_res = p.u.len_res != NULL ? p.u.len_res->clone() : NULL;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
409
410
411
412
413
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
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
552
553
554
555
556
557
558
559
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
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
  void Value::chk_expr_immutability() {
    switch (valuetype) {
      case V_REFD: {/**< referenced */
        int asstype = get_reference()->get_refd_assignment()->get_asstype();
        switch (asstype) {
          case Assignment::A_TYPE:           /**< type */
          case Assignment::A_CONST:          /**< value (const) */
          case Assignment::A_UNDEF:          /**< undefined/undecided (ASN.1) */
          case Assignment::A_ERROR:          /**< erroneous; the kind cannot be deduced (ASN.1) */
          case Assignment::A_OC:             /**< information object class (ASN.1) */
          case Assignment::A_OBJECT:         /**< information object (ASN.1) */
          case Assignment::A_OS:             /**< information object set (ASN.1) */
          case Assignment::A_VS:             /**< value set (ASN.1) */
          case Assignment::A_EXT_CONST:      /**< external constant (TTCN-3) */
          case Assignment::A_MODULEPAR:      /**< module parameter (TTCN-3) */
          case Assignment::A_MODULEPAR_TEMP: /**< template module parameter */
          case Assignment::A_VAR:            /**< variable (TTCN-3) */
          case Assignment::A_VAR_TEMPLATE:   /**< template variable: dynamic template (TTCN-3) */
          case Assignment::A_TIMER:          /**< timer (TTCN-3) */
          case Assignment::A_PORT:           /**< port (TTCN-3) */
          case Assignment::A_ALTSTEP:        /**< altstep (TTCN-3) */
          case Assignment::A_TESTCASE:       /**< testcase Assignment::(TTCN-3) */
          case Assignment::A_PAR_TIMER:      /**< formal parameter (timer) (TTCN-3) */
          case Assignment::A_PAR_PORT:        /**< formal parameter (port) (TTCN-3) */
            break;
          case Assignment::A_TEMPLATE:
            if(get_reference()->get_parlist())
              get_reference()->get_parlist()->chk_immutability();
            break;
          case Assignment::A_FUNCTION:       /**< function without return type (TTCN-3) */
          case Assignment::A_FUNCTION_RVAL:  /**< function that returns a value (TTCN-3) */
          case Assignment::A_FUNCTION_RTEMP: /**< function that returns a template (TTCN-3) */
          case Assignment::A_EXT_FUNCTION:   /**< external function without return type (TTCN-3) */
          case Assignment::A_EXT_FUNCTION_RVAL:  /**< ext. func that returns a value (TTCN-3) */
          case Assignment::A_EXT_FUNCTION_RTEMP: /**< ext. func that returns a template (TTCN-3) */
            warning("Function invocation '%s' may change the actual snapshot.",
              get_reference()->get_dispname().c_str());
            break;
          case Assignment::A_PAR_VAL:        /**< formal parameter (value) (TTCN-3) */
          case Assignment::A_PAR_VAL_IN:     /**< formal parameter (in value) (TTCN-3) */
          case Assignment::A_PAR_VAL_OUT:    /**< formal parameter (out value) (TTCN-3) */
            // TODO: @fuzzy INOUT parameter is not valid
          case Assignment::A_PAR_VAL_INOUT:  /**< formal parameter (inout value) (TTCN-3) */
          case Assignment::A_PAR_TEMPL_IN:   /**< formal parameter ([in] template) (TTCN-3) */
          case Assignment::A_PAR_TEMPL_OUT:  /**< formal parameter (out template) (TTCN-3) */
          case Assignment::A_PAR_TEMPL_INOUT:/**< formal parameter (inout template) (TTCN-3) */
            if (get_reference()->get_refd_assignment()->get_eval_type() == FUZZY_EVAL)
              warning("Fuzzy parameter '%s' may change (during) the actual snapshot.",
                get_reference()->get_dispname().c_str());
            break;
          default:
            FATAL_ERROR("Value::chk_expr_immutability()");
        }
        break;}
      case V_EXPR: /**< expressions */
        switch (u.expr.v_optype) {
          case OPTYPE_TESTCASENAME: // -
            break;
          case OPTYPE_RND: // -
          case OPTYPE_RNDWITHVAL: /** \todo -> SEED */ // v1
            warning("Random number generation 'rnd()' change the actual snapshot.");
            break;
          case OPTYPE_UNARYPLUS: // v1
          case OPTYPE_UNARYMINUS: // v1
          case OPTYPE_NOT: // v1
          case OPTYPE_NOT4B: // v1
          case OPTYPE_BIT2HEX: // v1  6
          case OPTYPE_BIT2INT: // v1
          case OPTYPE_BIT2OCT: // v1
          case OPTYPE_BIT2STR: // v1
          case OPTYPE_CHAR2INT: // v1  10
          case OPTYPE_CHAR2OCT: // v1
          case OPTYPE_FLOAT2INT: // v1
          case OPTYPE_FLOAT2STR: // v1
          case OPTYPE_HEX2BIT: // v1
          case OPTYPE_HEX2INT: // v1
          case OPTYPE_HEX2OCT: // v1
          case OPTYPE_HEX2STR: // v1
          case OPTYPE_INT2CHAR: // v1
          case OPTYPE_INT2FLOAT: // v1
          case OPTYPE_INT2STR: // v1   20
          case OPTYPE_INT2UNICHAR: // v1
          case OPTYPE_OCT2BIT: // v1
          case OPTYPE_OCT2CHAR: // v1
          case OPTYPE_OCT2HEX: // v1
          case OPTYPE_OCT2INT: // v1
          case OPTYPE_OCT2STR: // v1
          case OPTYPE_STR2BIT: // v1
          case OPTYPE_STR2FLOAT: // v1
          case OPTYPE_STR2HEX: // v1
          case OPTYPE_STR2INT: // v1    30
          case OPTYPE_STR2OCT: // v1
          case OPTYPE_UNICHAR2INT: // v1
          case OPTYPE_UNICHAR2CHAR: // v1
          case OPTYPE_ENUM2INT: // v1
          case OPTYPE_REMOVE_BOM: //v1
          case OPTYPE_GET_STRINGENCODING: //v1
          case OPTYPE_DECODE_BASE64: //v1
          case OPTYPE_CBOR2JSON: // v1
          case OPTYPE_JSON2CBOR: // v1
          case OPTYPE_BSON2JSON: // v1
          case OPTYPE_JSON2BSON: // v1
            u.expr.v1->chk_expr_immutability();
            break;
          case OPTYPE_UNICHAR2OCT: // v1 [v2]
          case OPTYPE_OCT2UNICHAR: // v1 [v2]
          case OPTYPE_ENCODE_BASE64: //v1 [v2]
            u.expr.v1->chk_expr_immutability();
            if (u.expr.v2) u.expr.v2->chk_expr_immutability();
            break;
          case OPTYPE_ADD: // v1 v2
          case OPTYPE_SUBTRACT: // v1 v2
          case OPTYPE_MULTIPLY: // v1 v2
          case OPTYPE_DIVIDE: // v1 v2      40
          case OPTYPE_MOD: // v1 v2
          case OPTYPE_REM: // v1 v2
          case OPTYPE_CONCAT: // v1 v2
          case OPTYPE_EQ: // v1 v2 ==
          case OPTYPE_LT: // v1 v2 <
          case OPTYPE_GT: // v1 v2 >
          case OPTYPE_NE: // v1 v2 !=
          case OPTYPE_GE: // v1 v2 >=
          case OPTYPE_LE: // v1 v2 <=
          case OPTYPE_AND: // v1 v2    50
          case OPTYPE_OR: // v1 v2
          case OPTYPE_XOR: // v1 v2
          case OPTYPE_AND4B: // v1 v2
          case OPTYPE_OR4B: // v1 v2
          case OPTYPE_XOR4B: // v1 v2
          case OPTYPE_SHL: // v1 v2
          case OPTYPE_SHR: // v1 v2
          case OPTYPE_ROTL: // v1 v2
          case OPTYPE_ROTR: // v1 v2
          case OPTYPE_INT2BIT: // v1 v2    60
          case OPTYPE_INT2HEX: // v1 v2
          case OPTYPE_INT2OCT: // v1 v2
            u.expr.v1->chk_expr_immutability();
            u.expr.v2->chk_expr_immutability();
            break;
          case OPTYPE_ENCODE: // ti1 [v2] [v3] 35
          case OPTYPE_DECODE: // r1 r2 [v3] [v4]
            // not yet done.
            break;
          case OPTYPE_SUBSTR:
            u.expr.ti1->chk_immutability();
            u.expr.v2->chk_expr_immutability();
            u.expr.v3->chk_expr_immutability();
            break;
          case OPTYPE_REGEXP: 
            u.expr.ti1->chk_immutability();
            u.expr.t2->chk_immutability();
            u.expr.v3->chk_expr_immutability();
            break;
          case OPTYPE_DECOMP: // not implemented (reference guide)
            u.expr.v1->chk_expr_immutability();
            u.expr.v2->chk_expr_immutability();
            u.expr.v3->chk_expr_immutability();
            break;
          case OPTYPE_REPLACE: // ti1 v2 v3 ti4
            u.expr.ti1->chk_immutability();
            u.expr.v2->chk_expr_immutability();
            u.expr.v3->chk_expr_immutability();
            u.expr.ti4->chk_immutability();
            break;
          case OPTYPE_ISVALUE: // ti1   68
          case OPTYPE_ISBOUND: // ti1
          case OPTYPE_ISPRESENT: // ti1
          case OPTYPE_LENGTHOF: // ti1
          case OPTYPE_SIZEOF: // ti1 
          case OPTYPE_VALUEOF: // ti1
          case OPTYPE_TTCN2STRING: // ti1
            u.expr.ti1->chk_immutability();
            break;
          case OPTYPE_ISCHOSEN: // r1 i2
            break;
          case OPTYPE_ISCHOSEN_V: // v1 i2
            u.expr.v1->chk_expr_immutability();
            break;
          case OPTYPE_ISCHOSEN_T: // t1 i2
            u.expr.t1->chk_immutability();
            break;
          case OPTYPE_MATCH: // v1 t2
            u.expr.v1->chk_expr_immutability();
            u.expr.t2->chk_immutability();
            break;
          case OPTYPE_UNDEF_RUNNING:
          case OPTYPE_COMP_NULL:
          case OPTYPE_COMP_MTC:
          case OPTYPE_COMP_SYSTEM:
          case OPTYPE_COMP_SELF:
          case OPTYPE_COMP_CREATE: // r1 [v2] [v3] b4
            break;
          case OPTYPE_COMP_RUNNING: // v1 [r2] b4
          case OPTYPE_COMP_RUNNING_ANY: // -
          case OPTYPE_COMP_RUNNING_ALL: // -
          case OPTYPE_COMP_ALIVE: // v1
          case OPTYPE_COMP_ALIVE_ANY: // -
          case OPTYPE_COMP_ALIVE_ALL: // -
            warning("State of component(s) may change during the actual snapshot.");
            break;
          case OPTYPE_TMR_READ: // r1     90
          case OPTYPE_TMR_RUNNING: // r1 [r2] b4
          case OPTYPE_TMR_RUNNING_ANY: // -
            warning("State of timer(s) may change during the actual snapshot.");
            break;
          case OPTYPE_GETVERDICT: // -
          case OPTYPE_ACTIVATE: // r1
          case OPTYPE_ACTIVATE_REFD: //v1 t_list2
          case OPTYPE_EXECUTE: // r1 [v2]
          case OPTYPE_EXECUTE_REFD: // v1 t_list2 [v3]
          case OPTYPE_LOG2STR: // logargs
          case OPTYPE_PROF_RUNNING: // -     99
          case OPTYPE_ENCVALUE_UNICHAR: // ti1 [v2] [v3] [v4]
          case OPTYPE_DECVALUE_UNICHAR: // r1 r2 [v3] [v4] [v5]
          case OPTYPE_GET_PORT_REF: // -optypes
          case OPTYPE_ANY2UNISTR: // logarg: length = 1
            break;
          case OPTYPE_CHECKSTATE_ANY: // [r1] v2: port or any
          case OPTYPE_CHECKSTATE_ALL: // [r1] v2: port or all
633
            warning("State of port(s) may change during the actual snapshot.");
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
            break;
          case OPTYPE_HOSTID: // [v1]
            if (u.expr.v1) u.expr.v1->chk_expr_immutability();
            break;
          case OPTYPE_ISTEMPLATEKIND: // ti1 v2
            u.expr.v2->chk_expr_immutability();
            u.expr.ti1->chk_immutability();
            break;
          default:
            FATAL_ERROR("Value::chk_expr_immutability()");
        }
        break;
      case V_ERROR: /**< erroneous */
      case V_UNDEF_LOWERID: /**< undefined loweridentifier */
      case V_NULL: /**< NULL (for ASN.1 NULL type: also in TTCN-3) */
      case V_BOOL: /**< boolean */
      case V_NAMEDINT: /**< integer / named number */
      case V_NAMEDBITS: /**< named bits (identifiers) */
      case V_INT: /**< integer */
      case V_REAL: /**< real/float */
      case V_ENUM: /**< enumerated */
      case V_BSTR: /**< bitstring */
      case V_HSTR: /**< hexstring */
      case V_OSTR: /**< octetstring */
      case V_CSTR: /**< charstring */
      case V_USTR: /**< universal charstring */
      case V_ISO2022STR: /**< ISO-2022 string (treat as octetstring) */
      case V_CHARSYMS: /**< parsed ASN.1 universal string notation */
      case V_OID: /**< object identifier */
      case V_ROID: /**< relative object identifier */
      case V_CHOICE: /**< choice; set directly by the ASN.1 parser */
      case V_SEQOF: /**< sequence (record) of */
      case V_SETOF: /**< set of */
      case V_ARRAY: /**< array */
      case V_SEQ: /**< sequence (record) */
        // TODO test?
      case V_SET: /**< set */
      case V_OPENTYPE: /**< open type */
      case V_UNDEF_BLOCK: /**< undefined {block} */
      case V_OMIT: /**< special value for optional values */
      case V_VERDICT: /**< verdict */
      case V_TTCN3_NULL: /**< TTCN-3 null (for component or default references) */
      case V_DEFAULT_NULL: /**< null default reference */
      case V_FAT_NULL: /**< null for function: altstep and testcase */
      case V_MACRO: /**< macros (%%something) */
      case V_NOTUSED: /**< not used symbol ('-') */
      case V_FUNCTION: /**< function */
      case V_ALTSTEP: /**< altstep */
      case V_TESTCASE: /**< testcase */
      case V_INVOKE: /**< invoke operation */
      case V_REFER: /**< refer(function) */
      case V_ANY_VALUE: /**< any value (?) - used by template concatenation */
      case V_ANY_OR_OMIT: /**< any or omit (*) - used by template concatenation */
        break;
      default:
        FATAL_ERROR("Value::chk_expr_immutability()");
    } // switch
  }

Elemer Lelik's avatar
Elemer Lelik committed
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
  void Value::clean_up()
  {
    switch (valuetype) {
    case V_ERROR:
    case V_NULL:
    case V_BOOL:
    case V_REAL:
    case V_OMIT:
    case V_VERDICT:
    case V_TTCN3_NULL:
    case V_DEFAULT_NULL:
    case V_FAT_NULL:
    case V_MACRO:
    case V_NOTUSED:
    case V_FUNCTION:
    case V_ALTSTEP:
    case V_TESTCASE:
      break;
    case V_INT:
      delete u.val_Int;
      break;
    case V_NAMEDINT:
    case V_ENUM:
    case V_UNDEF_LOWERID:
      delete u.val_id;
      break;
    case V_BSTR:
    case V_HSTR:
    case V_OSTR:
    case V_CSTR:
    case V_ISO2022STR:
      delete u.str.val_str;
      clean_up_string_elements(u.str.str_elements);
      break;
    case V_USTR:
      delete u.ustr.val_ustr;
      clean_up_string_elements(u.ustr.ustr_elements);
      break;
    case V_CHARSYMS:
      delete u.char_syms;
      break;
    case V_OID:
    case V_ROID:
      if (u.oid_comps) {
	for(size_t i=0; i<u.oid_comps->size(); i++)
          delete (*u.oid_comps)[i];
	u.oid_comps->clear();
	delete u.oid_comps;
      }
      break;
    case V_EXPR:
      clean_up_expr();
      break;
    case V_CHOICE:
      delete u.choice.alt_name;
      delete u.choice.alt_value;
      break;
    case V_SEQOF:
    case V_SETOF:
    case V_ARRAY:
      delete u.val_vs;
      break;
    case V_SEQ:
    case V_SET:
      delete u.val_nvs;
      break;
    case V_REFD:
      delete u.ref.ref;
      break;
    case V_REFER:
      delete u.refered;
      break;
    case V_INVOKE:
      delete u.invoke.v;
      delete u.invoke.t_list;
      delete u.invoke.ap_list;
      break;
    case V_NAMEDBITS:
      if(u.ids) {
        for(size_t i=0; i<u.ids->size(); i++) delete u.ids->get_nth_elem(i);
        u.ids->clear();
        delete u.ids;
      }
      break;
    case V_UNDEF_BLOCK:
      delete u.block;
      break;
780
781
782
783
    case V_ANY_VALUE:
    case V_ANY_OR_OMIT:
      delete u.len_res;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
    default:
      FATAL_ERROR("Value::clean_up()");
    } // switch
  }

  void Value::clean_up_expr()
  {
    switch (u.expr.state) {
    case EXPR_CHECKING:
    case EXPR_CHECKING_ERR:
      FATAL_ERROR("Value::clean_up_expr()");
    default:
      break;
    }
    switch (u.expr.v_optype) {
    case OPTYPE_RND: // -
    case OPTYPE_COMP_NULL:
    case OPTYPE_COMP_MTC:
    case OPTYPE_COMP_SYSTEM:
    case OPTYPE_COMP_SELF:
    case OPTYPE_COMP_RUNNING_ANY:
    case OPTYPE_COMP_RUNNING_ALL:
    case OPTYPE_COMP_ALIVE_ANY:
    case OPTYPE_COMP_ALIVE_ALL:
    case OPTYPE_TMR_RUNNING_ANY:
    case OPTYPE_GETVERDICT:
    case OPTYPE_TESTCASENAME:
Elemer Lelik's avatar
Elemer Lelik committed
811
    case OPTYPE_PROF_RUNNING:
812
    case OPTYPE_GET_PORT_REF: // type (not owned)
Elemer Lelik's avatar
Elemer Lelik committed
813
      break;
814
815
816
817
    case OPTYPE_COMP_RUNNING: // v1 [r2] b4
    case OPTYPE_COMP_ALIVE:
      delete u.expr.r2;
      // no break
Elemer Lelik's avatar
Elemer Lelik committed
818
819
820
821
822
823
824
825
    case OPTYPE_UNARYPLUS: // v1
    case OPTYPE_UNARYMINUS:
    case OPTYPE_NOT:
    case OPTYPE_NOT4B:
    case OPTYPE_BIT2HEX:
    case OPTYPE_BIT2INT:
    case OPTYPE_BIT2OCT:
    case OPTYPE_BIT2STR:
826
    case OPTYPE_BSON2JSON:
827
    case OPTYPE_CBOR2JSON:
Elemer Lelik's avatar
Elemer Lelik committed
828
829
830
831
832
833
834
835
836
837
838
839
    case OPTYPE_CHAR2INT:
    case OPTYPE_CHAR2OCT:
    case OPTYPE_FLOAT2INT:
    case OPTYPE_FLOAT2STR:
    case OPTYPE_HEX2BIT:
    case OPTYPE_HEX2INT:
    case OPTYPE_HEX2OCT:
    case OPTYPE_HEX2STR:
    case OPTYPE_INT2CHAR:
    case OPTYPE_INT2FLOAT:
    case OPTYPE_INT2STR:
    case OPTYPE_INT2UNICHAR:
840
    case OPTYPE_JSON2BSON:
841
    case OPTYPE_JSON2CBOR:
Elemer Lelik's avatar
Elemer Lelik committed
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
    case OPTYPE_OCT2BIT:
    case OPTYPE_OCT2CHAR:
    case OPTYPE_OCT2HEX:
    case OPTYPE_OCT2INT:
    case OPTYPE_OCT2STR:
    case OPTYPE_STR2BIT:
    case OPTYPE_STR2FLOAT:
    case OPTYPE_STR2HEX:
    case OPTYPE_STR2INT:
    case OPTYPE_STR2OCT:
    case OPTYPE_UNICHAR2INT:
    case OPTYPE_UNICHAR2CHAR:
    case OPTYPE_ENUM2INT:
    case OPTYPE_RNDWITHVAL:
    case OPTYPE_REMOVE_BOM:
    case OPTYPE_GET_STRINGENCODING:
    case OPTYPE_DECODE_BASE64:
ebensza's avatar
ebensza committed
859
    case OPTYPE_HOSTID:
Elemer Lelik's avatar
Elemer Lelik committed
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
      delete u.expr.v1;
      break;
    case OPTYPE_ADD: // v1 v2
    case OPTYPE_SUBTRACT:
    case OPTYPE_MULTIPLY:
    case OPTYPE_DIVIDE:
    case OPTYPE_MOD:
    case OPTYPE_REM:
    case OPTYPE_CONCAT:
    case OPTYPE_EQ:
    case OPTYPE_LT:
    case OPTYPE_GT:
    case OPTYPE_NE:
    case OPTYPE_GE:
    case OPTYPE_LE:
    case OPTYPE_AND:
    case OPTYPE_OR:
    case OPTYPE_XOR:
    case OPTYPE_AND4B:
    case OPTYPE_OR4B:
    case OPTYPE_XOR4B:
    case OPTYPE_SHL:
    case OPTYPE_SHR:
    case OPTYPE_ROTL:
    case OPTYPE_ROTR:
    case OPTYPE_INT2BIT:
    case OPTYPE_INT2HEX:
    case OPTYPE_INT2OCT:
    case OPTYPE_UNICHAR2OCT:
    case OPTYPE_OCT2UNICHAR:
    case OPTYPE_ENCODE_BASE64:
      delete u.expr.v1;
      delete u.expr.v2;
      break;
894
895
    case OPTYPE_UNDEF_RUNNING: // r1 [r2] b4
    case OPTYPE_TMR_RUNNING: // r1 [r2] b4
Elemer Lelik's avatar
Elemer Lelik committed
896
897
898
      delete u.expr.r1;
      delete u.expr.r2;
      break;
899
900
901
902
903
904
    case OPTYPE_DECODE: // r1 r2 [v3] [v4]
      delete u.expr.r1;
      delete u.expr.r2;
      delete u.expr.v3;
      delete u.expr.v4;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
905
    case OPTYPE_SUBSTR:
906
    case OPTYPE_ENCODE:
Elemer Lelik's avatar
Elemer Lelik committed
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
      delete u.expr.ti1;
      delete u.expr.v2;
      delete u.expr.v3;
      break;
    case OPTYPE_REGEXP:
      delete u.expr.ti1;
      delete u.expr.t2;
      delete u.expr.v3;
      break;
    case OPTYPE_DECOMP: // v1 v2 v3
      delete u.expr.v1;
      delete u.expr.v2;
      delete u.expr.v3;
      break;
    case OPTYPE_REPLACE:
      delete u.expr.ti1;
      delete u.expr.v2;
      delete u.expr.v3;
      delete u.expr.ti4;
      break;
927
928
929
    case OPTYPE_VALUEOF: // ti1 [subrefs2]
      delete u.expr.subrefs2;
      // fall through
Elemer Lelik's avatar
Elemer Lelik committed
930
931
932
933
934
935
936
937
    case OPTYPE_LENGTHOF: // ti1
    case OPTYPE_SIZEOF:  // ti1
    case OPTYPE_ISVALUE:
    case OPTYPE_ISBOUND:
    case OPTYPE_ISPRESENT:
    case OPTYPE_TTCN2STRING:
      delete u.expr.ti1;
      break;
938
    case OPTYPE_ISTEMPLATEKIND: // ti1 v2
939
940
941
      delete u.expr.ti1;
      delete u.expr.v2;
      break;
942
943
944
945
946
947
948
    case OPTYPE_ENCVALUE_UNICHAR: // ti1 [v2] [v3] [v4]
      delete u.expr.ti1;
      delete u.expr.v2;
      delete u.expr.v3;
      delete u.expr.v4;
      break;
    case OPTYPE_DECVALUE_UNICHAR: // r1 r2 [v3] [v4] [v5]
949
950
951
      delete u.expr.r1;
      delete u.expr.r2;
      delete u.expr.v3;
952
953
      delete u.expr.v4;
      delete u.expr.v5;
954
      break;
Elemer Lelik's avatar
Elemer Lelik committed
955
956
957
958
959
960
961
962
    case OPTYPE_TMR_READ:
    case OPTYPE_ACTIVATE:
      delete u.expr.r1;
      break;
    case OPTYPE_EXECUTE: // r1 [v2]
      delete u.expr.r1;
      delete u.expr.v2;
      break;
963
964
965
966
967
    case OPTYPE_CHECKSTATE_ANY: // [r1] v2
    case OPTYPE_CHECKSTATE_ALL:
      delete u.expr.r1;
      delete u.expr.v2;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
    case OPTYPE_COMP_CREATE: // r1 [v2] [v3] b4
      delete u.expr.r1;
      delete u.expr.v2;
      delete u.expr.v3;
      break;
    case OPTYPE_MATCH: // v1 t2
      delete u.expr.v1;
      delete u.expr.t2;
      break;
    case OPTYPE_ISCHOSEN: // r1 i2
      delete u.expr.r1;
      delete u.expr.i2;
      break;
    case OPTYPE_ISCHOSEN_V: // v1 i2
      delete u.expr.v1;
      delete u.expr.i2;
      break;
    case OPTYPE_ISCHOSEN_T: // t1 i2
      delete u.expr.t1;
      delete u.expr.i2;
      break;
    case OPTYPE_ACTIVATE_REFD: //v1 t_list2
      delete u.expr.v1;
      if(u.expr.state!=EXPR_CHECKED)
        delete u.expr.t_list2;
      else
        delete u.expr.ap_list2;
      break;
    case OPTYPE_EXECUTE_REFD: //v1 t_list2 [v3]
      delete u.expr.v1;
      if(u.expr.state!=EXPR_CHECKED)
        delete u.expr.t_list2;
      else
        delete u.expr.ap_list2;
      delete u.expr.v3;
      break;
    case OPTYPE_LOG2STR:
1005
    case OPTYPE_ANY2UNISTR:
Elemer Lelik's avatar
Elemer Lelik committed
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
      delete u.expr.logargs;
      break;
    default:
      FATAL_ERROR("Value::clean_up_expr()");
    } // switch
  }

  void Value::copy_and_destroy(Value *src)
  {
    clean_up();
    valuetype = src->valuetype;
    u = src->u;
    // update the pointer used for caching if it points to the value itself
    if (valuetype == V_REFD && u.ref.refd_last == src) u.ref.refd_last = this;
    src->valuetype = V_ERROR;
    delete src;
  }

  Value::Value(valuetype_t p_vt)
1025
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
  {
    switch(valuetype) {
    case V_NULL:
    case V_TTCN3_NULL:
    case V_OMIT:
    case V_NOTUSED:
    case V_ERROR:
      break;
    case V_OID:
    case V_ROID:
      u.oid_comps=new vector<OID_comp>();
      break;
    case V_NAMEDBITS:
      u.ids=new map<string, Identifier>();
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, bool p_val_bool)
1047
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
  {
    switch(valuetype) {
    case V_BOOL:
      u.val_bool=p_val_bool;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, const Int& p_val_Int)
1059
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
  {
    switch(valuetype) {
    case V_INT:
      u.val_Int=new int_val_t(p_val_Int);
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, int_val_t *p_val_Int)
1071
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
  {
    switch(valuetype){
    case V_INT:
      u.val_Int=p_val_Int;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    }
  }

  Value::Value(valuetype_t p_vt, string *p_val_str)
1083
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
  {
    if(!p_val_str) FATAL_ERROR("NULL parameter");
    switch(valuetype) {
    case V_BSTR:
    case V_HSTR:
    case V_OSTR:
    case V_CSTR:
    case V_ISO2022STR:
      set_val_str(p_val_str);
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, ustring *p_val_ustr)
1100
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1101
1102
1103
1104
1105
1106
1107
  {
    if (p_vt != V_USTR || !p_val_ustr) FATAL_ERROR("Value::Value()");
    set_val_ustr(p_val_ustr);
    u.ustr.convert_str = false;
  }

  Value::Value(valuetype_t p_vt, CharSyms *p_char_syms)
1108
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
  {
    if (!p_char_syms) FATAL_ERROR("NULL parameter");
    switch (valuetype) {
    case V_CHARSYMS:
      u.char_syms = p_char_syms;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, Identifier *p_val_id)
1121
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
  {
    if(!p_val_id)
      FATAL_ERROR("NULL parameter");
    switch(valuetype) {
    case V_NAMEDINT:
    case V_ENUM:
    case V_UNDEF_LOWERID:
      u.val_id=p_val_id;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, Identifier *p_id, Value *p_val)
1137
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
  {
    if(!p_id || !p_val)
      FATAL_ERROR("NULL parameter");
    switch(valuetype) {
    case V_CHOICE:
      u.choice.alt_name=p_id;
      u.choice.alt_value=p_val;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, const Real& p_val_Real)
1152
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
  {
    switch(valuetype) {
    case V_REAL:
      u.val_Real=p_val_Real;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, Values *p_vs)
1164
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
  {
    if(!p_vs) FATAL_ERROR("NULL parameter");
    switch(valuetype) {
    case V_SEQOF:
    case V_SETOF:
    case V_ARRAY:
      u.val_vs=p_vs;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, Value *p_v,
    Ttcn::ParsedActualParameters *p_t_list)
1180
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
  {
    if(!p_v || !p_t_list) FATAL_ERROR("NULL parameter");
    switch(valuetype) {
    case V_INVOKE:
      u.invoke.v = p_v;
      u.invoke.t_list = p_t_list;
      u.invoke.ap_list = 0;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    }
  }

  // -
  Value::Value(operationtype_t p_optype)
1196
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_RND:
    case OPTYPE_COMP_NULL:
    case OPTYPE_COMP_MTC:
    case OPTYPE_COMP_SYSTEM:
    case OPTYPE_COMP_SELF:
    case OPTYPE_COMP_RUNNING_ANY:
    case OPTYPE_COMP_RUNNING_ALL:
    case OPTYPE_COMP_ALIVE_ANY:
    case OPTYPE_COMP_ALIVE_ALL:
    case OPTYPE_TMR_RUNNING_ANY:
    case OPTYPE_GETVERDICT:
    case OPTYPE_TESTCASENAME:
Elemer Lelik's avatar
Elemer Lelik committed
1213
    case OPTYPE_PROF_RUNNING:
Elemer Lelik's avatar
Elemer Lelik committed
1214
      break;
1215
1216
1217
    case OPTYPE_GET_PORT_REF:
      u.expr.type = NULL; // will be set during semantic analysis
      break;
Elemer Lelik's avatar
Elemer Lelik committed
1218
1219
1220
1221
1222
1223
1224
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  // v1
  Value::Value(operationtype_t p_optype, Value *p_v1)
1225
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_UNARYPLUS:
    case OPTYPE_UNARYMINUS:
    case OPTYPE_NOT:
    case OPTYPE_NOT4B:
    case OPTYPE_BIT2HEX:
    case OPTYPE_BIT2INT:
    case OPTYPE_BIT2OCT:
    case OPTYPE_BIT2STR:
1238
    case OPTYPE_BSON2JSON:
1239
    case OPTYPE_CBOR2JSON:
Elemer Lelik's avatar
Elemer Lelik committed
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
    case OPTYPE_CHAR2INT:
    case OPTYPE_CHAR2OCT:
    case OPTYPE_FLOAT2INT:
    case OPTYPE_FLOAT2STR:
    case OPTYPE_HEX2BIT:
    case OPTYPE_HEX2INT:
    case OPTYPE_HEX2OCT:
    case OPTYPE_HEX2STR:
    case OPTYPE_INT2CHAR:
    case OPTYPE_INT2FLOAT:
    case OPTYPE_INT2STR:
    case OPTYPE_INT2UNICHAR:
1252
    case OPTYPE_JSON2BSON:
1253
    case OPTYPE_JSON2CBOR:
Elemer Lelik's avatar
Elemer Lelik committed
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
    case OPTYPE_OCT2BIT:
    case OPTYPE_OCT2CHAR:
    case OPTYPE_OCT2HEX:
    case OPTYPE_OCT2INT:
    case OPTYPE_OCT2STR:
    case OPTYPE_STR2BIT:
    case OPTYPE_STR2FLOAT:
    case OPTYPE_STR2HEX:
    case OPTYPE_STR2INT:
    case OPTYPE_STR2OCT:
    case OPTYPE_UNICHAR2INT:
    case OPTYPE_UNICHAR2CHAR:
    case OPTYPE_ENUM2INT:
    case OPTYPE_RNDWITHVAL:
    case OPTYPE_REMOVE_BOM:
    case OPTYPE_GET_STRINGENCODING:
    case OPTYPE_DECODE_BASE64:
      if(!p_v1) FATAL_ERROR("Value::Value()");
      u.expr.v1=p_v1;
      break;
ebensza's avatar
ebensza committed
1274
1275
1276
    case OPTYPE_HOSTID:
      u.expr.v1=p_v1;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
1277
1278
1279
1280
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
1281
1282
1283
1284
  
  // v1 [r2] b4
  Value::Value(operationtype_t p_optype, Value* p_v1, Ttcn::Ref_base *p_r2,
               bool p_b4)
1285
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_COMP_RUNNING:
    case OPTYPE_COMP_ALIVE:
      if (p_v1 == NULL) {
        FATAL_ERROR("Value::Value()");
      }
      u.expr.v1 = p_v1;
      u.expr.r2 = p_r2;
      u.expr.b4 = p_b4;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
Elemer Lelik's avatar
Elemer Lelik committed
1303
1304
1305

  // ti1
  Value::Value(operationtype_t p_optype, TemplateInstance *p_ti1)
1306
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1307
1308
1309
1310
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
1311
1312
1313
1314
1315
    case OPTYPE_ENCVALUE_UNICHAR:
      u.expr.v2 = NULL;
      u.expr.v3 = NULL;
      u.expr.v4 = NULL;
      // fall through
Elemer Lelik's avatar
Elemer Lelik committed
1316
1317
1318
1319
1320
1321
1322
1323
1324
    case OPTYPE_LENGTHOF:
    case OPTYPE_SIZEOF:
    case OPTYPE_VALUEOF:
    case OPTYPE_ISVALUE:
    case OPTYPE_ISBOUND:
    case OPTYPE_ISPRESENT:
    case OPTYPE_TTCN2STRING:
      if(!p_ti1) FATAL_ERROR("Value::Value()");
      u.expr.ti1=p_ti1;
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
      if (p_optype == OPTYPE_VALUEOF) {
        u.expr.subrefs2 = NULL;
      }
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
  
  // ti1 subrefs2
  Value::Value(operationtype_t p_optype, TemplateInstance* p_ti1,
               Ttcn::FieldOrArrayRefs* p_subrefs2)
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch (p_optype) {
    case OPTYPE_VALUEOF:
      if (p_ti1 == NULL || p_subrefs2 == NULL) {
        FATAL_ERROR("Value::Value()");
      }
      u.expr.ti1 = p_ti1;
      u.expr.subrefs2 = p_subrefs2;
Elemer Lelik's avatar
Elemer Lelik committed
1348
1349
1350
1351
1352
1353
1354
1355
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  // r1
  Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1)
1356
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_TMR_READ:
    case OPTYPE_ACTIVATE:
      if(!p_r1) FATAL_ERROR("Value::Value()");
      u.expr.r1=p_r1;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
1370
1371
1372
1373
  
  // r1 [r2] b4
  Value::Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
               bool p_b4)
1374
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch (p_optype) {
    case OPTYPE_UNDEF_RUNNING:
      if (p_r1 == NULL) {
        FATAL_ERROR("Value::Value()");
      }
      u.expr.r1 = p_r1;
      u.expr.r2 = p_r2;
      u.expr.b4 = p_b4;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
Elemer Lelik's avatar
Elemer Lelik committed
1391
1392
1393
1394

  // v1 t_list2
  Value::Value(operationtype_t p_optype, Value *p_v1,
      Ttcn::ParsedActualParameters *p_ap_list)
1395
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_ACTIVATE_REFD:
      if(!p_v1 || !p_ap_list) FATAL_ERROR("Value::Value()");
      u.expr.v1 = p_v1;
      u.expr.t_list2 = p_ap_list;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    }
  }

  //v1 t_list2 v3
  Value::Value(operationtype_t p_optype, Value *p_v1,
    Ttcn::ParsedActualParameters *p_t_list2, Value *p_v3)
1413
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_EXECUTE_REFD:
      if(!p_v1 || !p_t_list2) FATAL_ERROR("Value::Value()");
      u.expr.v1 = p_v1;
      u.expr.t_list2 = p_t_list2;
      u.expr.v3 = p_v3;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    }
  }

1429
  // r1 [v2] or [r1] v2
Elemer Lelik's avatar
Elemer Lelik committed
1430
  Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Value *p_v2)
1431
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1432
1433
1434
1435
1436
1437
1438
1439
1440
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_EXECUTE:
      if(!p_r1) FATAL_ERROR("Value::Value()");
      u.expr.r1=p_r1;
      u.expr.v2=p_v2;
      break;
1441
1442
1443
1444
1445
1446
    case OPTYPE_CHECKSTATE_ANY:
    case OPTYPE_CHECKSTATE_ALL:
      if(!p_v2) FATAL_ERROR("Value::Value()");
      u.expr.r1=p_r1; // may be null if any port or all port
      u.expr.v2=p_v2;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
1447
1448
1449
1450
1451
1452
1453
1454
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  // r1 [v2] [v3] b4
  Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1,
               Value *p_v2, Value *p_v3, bool p_b4)
1455
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_COMP_CREATE:
      if(!p_r1) FATAL_ERROR("Value::Value()");
      u.expr.r1=p_r1;
      u.expr.v2=p_v2;
      u.expr.v3=p_v3;
      u.expr.b4=p_b4;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  // v1 v2
  Value::Value(operationtype_t p_optype, Value *p_v1, Value *p_v2)
1474
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_ADD:
    case OPTYPE_SUBTRACT:
    case OPTYPE_MULTIPLY:
    case OPTYPE_DIVIDE:
    case OPTYPE_MOD:
    case OPTYPE_REM:
    case OPTYPE_CONCAT:
    case OPTYPE_EQ:
    case OPTYPE_LT:
    case OPTYPE_GT:
    case OPTYPE_NE:
    case OPTYPE_GE:
    case OPTYPE_LE:
    case OPTYPE_AND:
    case OPTYPE_OR:
    case OPTYPE_XOR:
    case OPTYPE_AND4B:
    case OPTYPE_OR4B:
    case OPTYPE_XOR4B:
    case OPTYPE_SHL:
    case OPTYPE_SHR:
    case OPTYPE_ROTL:
    case OPTYPE_ROTR:
    case OPTYPE_INT2BIT:
    case OPTYPE_INT2HEX:
    case OPTYPE_INT2OCT:
      if(!p_v1 || !p_v2) FATAL_ERROR("Value::Value()");
      u.expr.v1=p_v1;
      u.expr.v2=p_v2;
      break;
    case OPTYPE_UNICHAR2OCT:
    case OPTYPE_OCT2UNICHAR:
    case OPTYPE_ENCODE_BASE64:
      if(!p_v1) FATAL_ERROR("Value::Value()");
      u.expr.v1=p_v1;
      // p_v2 may be NULL if there is no second param
      u.expr.v2=p_v2;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  // ti1 v2 v3 ti4
  Value::Value(operationtype_t p_optype, TemplateInstance *p_ti1, Value *p_v2,
    Value *p_v3, TemplateInstance *p_ti4) :
1525
      GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch (p_optype) {
    case OPTYPE_REPLACE:
      if (!p_ti1 || !p_v2 || !p_v3 || !p_ti4) FATAL_ERROR("Value::Value()");
      u.expr.ti1 = p_ti1;
      u.expr.v2 = p_v2;
      u.expr.v3 = p_v3;
      u.expr.ti4 = p_ti4;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  // v1 v2 v3
  Value::Value(operationtype_t p_optype, Value *p_v1, Value *p_v2, Value *p_v3)
1544
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1545
1546
1547
1548
1549
1550
1551
1552
1553
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_DECOMP:
      if(!p_v1 || !p_v2 || !p_v3) FATAL_ERROR("Value::Value()");
      u.expr.v1=p_v1;
      u.expr.v2=p_v2;
      u.expr.v3=p_v3;
1554
      break;   
Elemer Lelik's avatar
Elemer Lelik committed
1555
1556
1557
1558
1559
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

1560
1561
  // ti1 [v2]
  Value::Value(operationtype_t p_optype, TemplateInstance *p_ti1,  Value *p_v2)
1562
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
1563
1564
1565
1566
1567
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_ENCVALUE_UNICHAR:
1568
1569
1570
1571
      u.expr.v3 = NULL;
      u.expr.v4 = NULL;
      // fall through
    case OPTYPE_ISTEMPLATEKIND:    
1572
1573
1574
1575
1576
1577
1578
1579
1580
      if(!p_ti1 || !p_v2) FATAL_ERROR("Value::Value()");
      u.expr.ti1=p_ti1;
      u.expr.v2=p_v2;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
  
Elemer Lelik's avatar
Elemer Lelik committed
1581
1582
  // ti1 v2 v3
  Value::Value(operationtype_t p_optype, TemplateInstance *p_ti1, Value *p_v2, Value *p_v3)
1583
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1584
1585
1586
1587
  {
    u.expr.v_optype=p_optype;
    u.expr.state=EXPR_NOT_CHECKED;
    switch(p_optype) {
1588
1589
1590
1591
    case OPTYPE_ENCVALUE_UNICHAR:
      u.expr.v4 = NULL;
      // fall through
    case OPTYPE_SUBSTR:          
Elemer Lelik's avatar
Elemer Lelik committed
1592
1593
1594
1595
1596
      if(!p_ti1 || !p_v2 || !p_v3) FATAL_ERROR("Value::Value()");
      u.expr.ti1 = p_ti1;
      u.expr.v2=p_v2;
      u.expr.v3=p_v3;
      break;
1597
1598
1599
1600
1601
1602
1603
1604
    case OPTYPE_ENCODE:
      if (p_ti1 == NULL) {
        FATAL_ERROR("Value::Value()");
      }
      u.expr.ti1 = p_ti1;
      u.expr.v2 = p_v2;
      u.expr.v3 = p_v3;
      break;
Elemer Lelik's avatar
Elemer Lelik committed
1605
1606
1607
1608
1609
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

1610
1611
1612
  // ti1 t2 v3 b4
  Value::Value(operationtype_t p_optype, TemplateInstance *p_ti1,
               TemplateInstance *p_t2, Value *p_v3, bool p_b4)
1613
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1614
1615
1616
1617
1618
1619
1620
1621
  {
    u.expr.v_optype=p_optype;
    u.expr.state=EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_REGEXP:
      if(!p_ti1 || !p_t2 || !p_v3) FATAL_ERROR("Value::Value()");
      u.expr.ti1 = p_ti1;
      u.expr.t2 = p_t2;
1622
1623
      u.expr.v3 = p_v3;
      u.expr.b4 = p_b4;
Elemer Lelik's avatar
Elemer Lelik committed
1624
1625
1626
1627
1628
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
  
  // ti1 v2 v3 v4
  Value::Value(operationtype_t p_optype, TemplateInstance* p_ti1, Value* p_v2,
               Value* p_v3, Value* p_v4)
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch (p_optype) {
    case OPTYPE_ENCVALUE_UNICHAR:
      if (p_ti1 == NULL || p_v2 == NULL || p_v3 == NULL || p_v4 == NULL) {
        FATAL_ERROR("Value::Value()");
      }
      u.expr.ti1 = p_ti1;
      u.expr.v2 = p_v2;
      u.expr.v3 = p_v3;
      u.expr.v4 = p_v4;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    }
  }
Elemer Lelik's avatar
Elemer Lelik committed
1651
1652
1653

  // v1 t2
  Value::Value(operationtype_t p_optype, Value *p_v1, TemplateInstance *p_t2)
1654
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_MATCH:
      if(!p_v1 || !p_t2) FATAL_ERROR("Value::Value()");
      u.expr.v1=p_v1;
      u.expr.t2=p_t2;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  // r1 i2
  Value::Value(operationtype_t p_optype, Ttcn::Reference *p_r1,
               Identifier *p_i2)
1672
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_ISCHOSEN:
      if(!p_r1 || !p_i2) FATAL_ERROR("Value::Value()");
      u.expr.r1=p_r1;
      u.expr.i2=p_i2;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(operationtype_t p_optype, LogArguments *p_logargs)
1688
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1689
1690
1691
1692
1693
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_LOG2STR:
1694
    case OPTYPE_ANY2UNISTR:
Elemer Lelik's avatar
Elemer Lelik committed
1695
1696
1697
1698
1699
1700
1701
1702
1703
      if (!p_logargs) FATAL_ERROR("Value::Value()");
      u.expr.logargs = p_logargs;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, macrotype_t p_macrotype)
1704
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
  {
    if (p_vt != V_MACRO) FATAL_ERROR("Value::Value()");
    switch (p_macrotype) {
    case MACRO_MODULEID:
    case MACRO_FILENAME:
    case MACRO_BFILENAME:
    case MACRO_FILEPATH:
    case MACRO_LINENUMBER:
    case MACRO_LINENUMBER_C:
    case MACRO_DEFINITIONID:
    case MACRO_SCOPE:
    case MACRO_TESTCASEID:
      break;
    default:
      FATAL_ERROR("Value::Value()");
    }
    u.macro = p_macrotype;
  }

  Value::Value(valuetype_t p_vt, NamedValues *p_nvs)
1725
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
  {
    if(!p_nvs) FATAL_ERROR("NULL parameter");
    switch(valuetype) {
    case V_SEQ:
    case V_SET:
      u.val_nvs=p_nvs;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, Reference *p_ref)
1739
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
  {
    if (!p_ref) FATAL_ERROR("NULL parameter: Value::Value()");
    switch(p_vt) {
    case V_REFD:
      u.ref.ref = p_ref;
      u.ref.refd_last = 0;
      break;
    case V_REFER:
      u.refered = p_ref;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    }
  }

  Value::Value(valuetype_t p_vt, Block *p_block)
1756
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
  {
    if(!p_block) FATAL_ERROR("NULL parameter");
    switch(valuetype) {
    case V_UNDEF_BLOCK:
      u.block=p_block;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }

  Value::Value(valuetype_t p_vt, verdict_t p_verdict)
1769
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
  {
    if (valuetype != V_VERDICT) FATAL_ERROR("Value::Value()");
    switch (p_verdict) {
    case Verdict_NONE:
    case Verdict_PASS:
    case Verdict_INCONC:
    case Verdict_FAIL:
    case Verdict_ERROR:
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
    u.verdict = p_verdict;
  }

  Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Ttcn::Ref_base *p_r2)
1786
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
Elemer Lelik's avatar
Elemer Lelik committed
1787
1788
1789
1790
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
1791
    case OPTYPE_DECVALUE_UNICHAR:
1792
1793
1794
      u.expr.v5 = NULL;
      // fall through
    case OPTYPE_DECODE:
Elemer Lelik's avatar
Elemer Lelik committed
1795
1796
1797
      if(!p_r1 || !p_r2) FATAL_ERROR("Value::Value()");
      u.expr.r1=p_r1;
      u.expr.r2=p_r2;
1798
      u.expr.v3=NULL;
1799
      u.expr.v4 = NULL;
Elemer Lelik's avatar
Elemer Lelik committed
1800
1801
1802
1803
1804
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
1805
1806
1807
1808
  
  // r1 r2 [v3]
  Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Ttcn::Ref_base *p_r2,
          Value *p_v3)
1809
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
1810
1811
1812
1813
1814
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch(p_optype) {
    case OPTYPE_DECVALUE_UNICHAR:
1815
1816
1817
      u.expr.v5 = NULL;
      // fall through
    case OPTYPE_DECODE:
1818
1819
1820
1821
      if(!p_r1 || !p_r2 || !p_v3) FATAL_ERROR("Value::Value()");
      u.expr.r1=p_r1;
      u.expr.r2=p_r2;
      u.expr.v3=p_v3;
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
      u.expr.v4 = NULL;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
  
  // r1 r2 [v3] [v4]
  Value::Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
               Value* p_v3, Value* p_v4)
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch (p_optype) {
    case OPTYPE_DECVALUE_UNICHAR:
      u.expr.v5 = NULL;
      // fall through
    case OPTYPE_DECODE:
      if(p_r1 == NULL || p_r2 == NULL || p_v3 == NULL || p_v4 == NULL) {
        FATAL_ERROR("Value::Value()");
      }
      u.expr.r1 = p_r1;
      u.expr.r2 = p_r2;
      u.expr.v3 = p_v3;
      u.expr.v4 = p_v4;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
  
  // r1 r2 [v3] [v4] [v5]
  Value::Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
               Value* p_v3, Value* p_v4, Value* p_v5)
    : GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
  {
    u.expr.v_optype = p_optype;
    u.expr.state = EXPR_NOT_CHECKED;
    switch (p_optype) {
    case OPTYPE_DECVALUE_UNICHAR:
      if(p_r1 == NULL || p_r2 == NULL || p_v3 == NULL || p_v4 == NULL || p_v5 == NULL) {
        FATAL_ERROR("Value::Value()");
      }
      u.expr.r1 = p_r1;
      u.expr.r2 = p_r2;
      u.expr.v3 = p_v3;
      u.expr.v4 = p_v4;
      u.expr.v5 = p_v5;
1871
1872
1873
1874
1875
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
  
  // V_ANY_VALUE, V_ANY_OR_OMIT
  Value::Value(valuetype_t p_vt, Ttcn::LengthRestriction* p_len_res)
    : GovernedSimple(S_V), valuetype(p_vt), my_governor(0)
  {
    switch(p_vt) {
    case V_ANY_VALUE:
    case V_ANY_OR_OMIT:
      u.len_res = p_len_res;
      break;
    default:
      FATAL_ERROR("Value::Value()");
    } // switch
  }
Elemer Lelik's avatar
Elemer Lelik committed
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906

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

  Value *Value::clone() const
  {
    return new Value(*this);
  }

  Value::operationtype_t Value::get_optype() const
  {
    if(valuetype!=V_EXPR)
      FATAL_ERROR("Value::get_optype()");
    return u.expr.v_optype;
  }
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
  
  Value* Value::get_concat_operand(bool first_operand) const
  {
    if (valuetype != V_EXPR || u.expr.v_optype != OPTYPE_CONCAT) {
      FATAL_ERROR("Value::get_concat_operand()");
    }
    return first_operand ? u.expr.v1 : u.expr.v2;
  }
  
  Ttcn::LengthRestriction* Value::take_length_restriction()
  {
    if (valuetype != V_ANY_VALUE && valuetype != V_ANY_OR_OMIT) {
      FATAL_ERROR("Value::take_length_restriction()");
    }
    Ttcn::LengthRestriction* ptr = u.len_res;
    u.len_res = NULL;
    return ptr;
  }
Elemer Lelik's avatar
Elemer Lelik committed
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039

  void Value::set_my_governor(Type *p_gov)
  {
    if(!p_gov)
      FATAL_ERROR("Value::set_my_governor(): NULL parameter");
    my_governor=p_gov;
  }

  Type *Value::get_my_governor() const
  {
    return my_governor;
  }

  void Value::set_fullname(const string& p_fullname)
  {
    GovernedSimple::set_fullname(p_fullname);
    switch(valuetype) {
    case V_CHARSYMS:
      u.char_syms->set_fullname(p_fullname);
      break;
    case V_OID:
    case V_ROID:
      for(size_t i=0; i<u.oid_comps->size(); i++)
        (*u.oid_comps)[i]->set_fullname(p_fullname+"."+Int2string(i+1));
      break;
    case V_CHOICE:
      u.choice.alt_value->set_fullname(p_fullname + "." +
        u.choice.alt_name->get_dispname());
      break;
    case V_SEQOF:
    case V_SETOF:
    case V_ARRAY:
      u.val_vs->set_fullname(p_fullname);
      break;
    case V_SEQ:
    case V_SET:
      u.val_nvs->set_fullname(p_fullname);
      break;
    case V_REFD:
      u.ref.ref->set_fullname(p_fullname);
      break;
    case V_REFER:
      u.refered->set_fullname(p_fullname);
      break;
    case V_INVOKE:
      u.invoke.v->set_fullname(p_fullname);
      if(u.invoke.t_list) u.invoke.t_list->set_fullname(p_fullname);
      if(u.invoke.ap_list) u.invoke.ap_list->set_fullname(p_fullname);
      break;
    case V_EXPR:
      set_fullname_expr(p_fullname);
      break;
    default:
      break;
    } // switch
  }

  void Value::set_my_scope(Scope *p_scope)
  {
    GovernedSimple::set_my_scope(p_scope);
    switch(valuetype) {
    case V_CHARSYMS:
      u.char_syms->set_my_scope(p_scope);
      break;
    case V_OID:
    case V_ROID:
      for(size_t i=0; i<u.oid_comps->size(); i++)
        (*u.oid_comps)[i]->set_my_scope(p_scope);
      break;
    case V_CHOICE:
      u.choice.alt_value->set_my_scope(p_scope);
      break;
    case V_SEQOF:
    case V_SETOF:
    case V_ARRAY:
      u.val_vs->set_my_scope(p_scope);
      break;
    case V_SEQ:
    case V_SET:
      u.val_nvs->set_my_scope(p_scope);
      break;
    case V_REFD:
      u.ref.ref->set_my_scope(p_scope);
      break;
    case V_REFER:
      u.refered->set_my_scope(p_scope);
      break;
    case V_INVOKE:
      u.invoke.v->set_my_scope(p_scope);
      if(u.invoke.t_list) u.invoke.t_list->set_my_scope(p_scope);
      if(u.invoke.ap_list) u.invoke.ap_list->set_my_scope(p_scope);
      break;
    case V_EXPR:
      set_my_scope_expr(p_scope);
      break;
    default:
      break;
    } // switch
  }

  void Value::set_fullname_expr(const string& p_fullname)
  {
    switch (u.expr.v_optype) {
    case OPTYPE_RND: // -
    case OPTYPE_COMP_NULL:
    case OPTYPE_COMP_MTC:
    case OPTYPE_COMP_SYSTEM:
    case OPTYPE_COMP_SELF:
    case OPTYPE_COMP_RUNNING_ANY:
    case OPTYPE_COMP_RUNNING_ALL:
    case OPTYPE_COMP_ALIVE_ANY:
    case OPTYPE_COMP_ALIVE_ALL:
    case OPTYPE_TMR_RUNNING_ANY:
    case OPTYPE_GETVERDICT:
    case OPTYPE_TESTCASENAME:
Elemer Lelik's avatar
Elemer Lelik committed
2040
    case OPTYPE_PROF_RUNNING:
2041
    case OPTYPE_GET_PORT_REF:
Elemer Lelik's avatar
Elemer Lelik committed
2042
2043
2044
2045
2046
2047
2048
2049
2050
      break;
    case OPTYPE_UNARYPLUS: // v1
    case OPTYPE_UNARYMINUS:
    case OPTYPE_NOT:
    case OPTYPE_NOT4B:
    case OPTYPE_BIT2HEX:
    case OPTYPE_BIT2INT:
    case OPTYPE_BIT2OCT:
    case OPTYPE_BIT2STR:
2051
    case OPTYPE_BSON2JSON:
2052
    case OPTYPE_CBOR2JSON:
Elemer Lelik's avatar
Elemer Lelik committed
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
    case OPTYPE_CHAR2INT:
    case OPTYPE_CHAR2OCT:
    case OPTYPE_FLOAT2INT:
    case OPTYPE_FLOAT2STR:
    case OPTYPE_HEX2BIT:
    case OPTYPE_HEX2INT:
    case OPTYPE_HEX2OCT:
    case OPTYPE_HEX2STR:
    case OPTYPE_INT2CHAR:
    case OPTYPE_INT2FLOAT:
    case OPTYPE_INT2STR:
    case OPTYPE_INT2UNICHAR:
2065
    case OPTYPE_JSON2BSON:
2066
    case OPTYPE_JSON2CBOR:
Elemer Lelik's avatar
Elemer Lelik committed
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
    case OPTYPE_OCT2BIT:
    case OPTYPE_OCT2CHAR:
    case OPTYPE_OCT2HEX:
    case OPTYPE_OCT2INT:
    case OPTYPE_OCT2STR:
    case OPTYPE_STR2BIT:
    case OPTYPE_STR2FLOAT:
    case OPTYPE_STR2HEX:
    case OPTYPE_STR2INT:
    case OPTYPE_STR2OCT:
    case OPTYPE_UNICHAR2INT:
    case OPTYPE_UNICHAR2CHAR:
    case OPTYPE_ENUM2INT:
    case OPTYPE_RNDWITHVAL:
    case OPTYPE_REMOVE_BOM:
    case OPTYPE_GET_STRINGENCODING:
    case OPTYPE_DECODE_BASE64:
      u.expr.v1->set_fullname(p_fullname+".<operand>");
      break;
ebensza's avatar
ebensza committed
2086
2087
2088
    case OPTYPE_HOSTID: // [v1]
      if(u.expr.v1) u.expr.v1->set_fullname(p_fullname+".<operand>");
      break;
Elemer Lelik's avatar
Elemer Lelik committed
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
    case OPTYPE_ADD: // v1 v2
    case OPTYPE_SUBTRACT:
    case OPTYPE_MULTIPLY:
    case OPTYPE_DIVIDE:
    case OPTYPE_MOD:
    case OPTYPE_REM:
    case OPTYPE_CONCAT:
    case OPTYPE_EQ:
    case OPTYPE_LT:
    case OPTYPE_GT:
    case OPTYPE_NE:
    case OPTYPE_GE:
    case OPTYPE_LE:
    case OPTYPE_AND:
    case OPTYPE_OR:
    case OPTYPE_XOR:
    case OPTYPE_AND4B:
    case OPTYPE_OR4B:
    case OPTYPE_XOR4B:
    case OPTYPE_SHL:
    case OPTYPE_SHR:
    case OPTYPE_ROTL:
    case OPTYPE_ROTR:
    case OPTYPE_INT2BIT:
    case OPTYPE_INT2HEX:
    case OPTYPE_INT2OCT:
      u.expr.v1->set_fullname(p_fullname+".<operand1>");
      u.expr.v2->set_fullname(p_fullname+".<operand2>");
      break;
    case OPTYPE_UNICHAR2OCT:
    case OPTYPE_OCT2UNICHAR:
    case OPTYPE_ENCODE_BASE64:
      u.expr.v1->set_fullname(p_fullname+".<operand1>");
      if(u.expr.v2) u.expr.v2->set_fullname(p_fullname+".<operand2>");
      break;
    case OPTYPE_DECODE:
      u.expr.r1->set_fullname(p_fullname+".<operand1>");
      u.expr.r2->set_fullname(p_fullname+".<operand2>");
2127
2128
2129
2130
2131
2132
      if (u.expr.v3 != NULL) {
        u.expr.v3->set_fullname(p_fullname+".<operand2>");
      }
      if (u.expr.v4 != NULL) {
        u.expr.v4->set_fullname(p_fullname+".<operand3>");
      }
Elemer Lelik's avatar
Elemer Lelik committed
2133
2134
      break;
    case OPTYPE_SUBSTR:
2135
    case OPTYPE_ENCODE:
Elemer Lelik's avatar
Elemer Lelik committed
2136
      u.expr.ti1->set_fullname(p_fullname+".<operand1>");
2137
2138
2139
2140
2141
2142
      if (u.expr.v2 != NULL) {
        u.expr.v2->set_fullname(p_fullname+".<operand2>");
      }
      if (u.expr.v3 != NULL) {
        u.expr.v3->set_fullname(p_fullname+".<operand3>");
      }
Elemer Lelik's avatar
Elemer Lelik committed
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
      break;
    case OPTYPE_REGEXP:
      u.expr.ti1->set_fullname(p_fullname+".<operand1>");
      u.expr.t2->set_fullname(p_fullname+".<operand2>");
      u.expr.v3->set_fullname(p_fullname+".<operand3>");
      break;
    case OPTYPE_DECOMP: // v1 v2 v3
      u.expr.v1->set_fullname(p_fullname+".<operand1>");
      u.expr.v2->set_fullname(p_fullname+".<operand2>");
      u.expr.v3->set_fullname(p_fullname+".<operand3>");
      break;
    case OPTYPE_REPLACE:
      u.expr.ti1->set_fullname(p_fullname+".<operand1>");
      u.expr.v2->set_fullname(p_fullname+".<operand2>");
      u.expr.v3->set_fullname(p_fullname+".<operand3>");
      u.expr.ti4->set_fullname(p_fullname+".<operand4>");
      break;
2160
2161
2162
2163
2164
    case OPTYPE_VALUEOF: // ti1 [subrefs2]
      if (u.expr.subrefs2 != NULL) {
        u.expr.subrefs2->set_fullname(p_fullname + ".<subrefs>");
      }
      // fall through
Elemer Lelik's avatar
Elemer Lelik committed
2165
2166
2167
2168
2169
2170
2171
2172
    case OPTYPE_LENGTHOF: // ti1
    case OPTYPE_SIZEOF:   // ti1
    case OPTYPE_ISVALUE:
    case OPTYPE_ISBOUND:
    case OPTYPE_ISPRESENT:
    case OPTYPE_TTCN2STRING:
      u.expr.ti1->set_fullname(p_fullname+".<operand>");
      break;
2173
2174
2175
2176
    case OPTYPE_ISTEMPLATEKIND: // ti1 v2
      u.expr.ti1->set_fullname(p_fullname+".<operand1>");
      u.expr.v2->set_fullname(p_fullname+".<operand2>");
      break;
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
    case OPTYPE_ENCVALUE_UNICHAR: // ti1 [v2] [v3] [v4]
      u.expr.ti1->set_fullname(p_fullname + ".<operand1>");
      if (u.expr.v2 != NULL) {
        u.expr.v2->set_fullname(p_fullname + ".<operand2>");
      }
      if (u.expr.v3 != NULL) {
        u.expr.v3->set_fullname(p_fullname + ".<operand3>");
      }
      if (u.expr.v4 != NULL) {
        u.expr.v4->set_fullname(p_fullname + ".<operand4>");
      }
      break;
    case OPTYPE_DECVALUE_UNICHAR: // r1 r2 [v3] [v4] [v5]
      u.expr.r1->set_fullname(p_fullname + ".<operand1>");
      u.expr.r2->set_fullname(p_fullname + ".<operand2>");
      if (u.expr.v3 != NULL) {
        u.expr.v3->set_fullname(p_fullname + ".<operand3>");
      }
      if (u.expr.v4 != NULL) {
        u.expr.v4->set_fullname(p_fullname + ".<operand4>");
      }
      if (u.expr.v5 != NULL) {
        u.expr.v4->set_fullname(p_fullname + ".<operand5>");
      }
2201
      break;
2202
    case OPTYPE_TMR_READ: // r1
Elemer Lelik's avatar
Elemer Lelik committed
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
    case OPTYPE_ACTIVATE:
      u.expr.r1->set_fullname(p_fullname+".<operand>");
      break;
    case OPTYPE_EXECUTE: // r1 [v2]
      u.expr.r1->set_fullname(p_fullname+".<operand1>");
      if(u.expr.v2) u.expr.v2->set_fullname(p_fullname+".<operand2>");
      break;
    case OPTYPE_COMP_CREATE: // r1 [v2] [v3] b4
      u.expr.r1->set_fullname(p_fullname+".<operand1>");
      if(u.expr.v2) u.expr.v2->set_fullname(p_fullname+".<operand2>");
      if(u.expr.v3) u.expr.v3->set_fullname(p_fullname+".<operand3>");
      break;
    case OPTYPE_MATCH: // v1 t2
      u.expr.v1->set_fullname(p_fullname+".<operand1>");
      u.expr.t2->set_fullname(p_fullname+".<operand2>");
      break;
    case OPTYPE_ISCHOSEN: // r1 i2
      u.expr.r1->set_fullname(p_fullname+".<operand>");
      break;
    case OPTYPE_ISCHOSEN_V: // v1 i2
      u.expr.v1->set_fullname(p_fullname+".<operand>");
      break;
    case OPTYPE_ISCHOSEN_T: // t1 i2
      u.expr.t1->set_fullname(p_fullname+".<operand>");
      break;
    case OPTYPE_ACTIVATE_REFD:
      u.expr.v1->set_fullname(p_fullname+".<reference>");
      if(u.expr.state!=EXPR_CHECKED)
        u.expr.t_list2->set_fullname(p_fullname+".<parameterlist>");
      else
        u.expr.ap_list2->set_fullname(p_fullname+".<parameterlist>");
      break;
    case OPTYPE_EXECUTE_REFD:
      u.expr.v1->set_fullname(p_fullname+".<reference>");
      if(u.expr.state!=EXPR_CHECKED)
        u.expr.t_list2->set_fullname(p_fullname+".<parameterlist>");
      else
        u.expr.ap_list2->set_fullname(p_fullname+".<parameterlist>");
      if(u.expr.v3)
        u.expr.v3->set_fullname(p_fullname+".<operand3>");
      break;
    case OPTYPE_LOG2STR:
      u.expr.logargs->set_fullname(p_fullname+".<logargs>");
      break;
2247
2248
2249
    case OPTYPE_ANY2UNISTR:
      u.expr.logargs->set_fullname(p_fullname+".<logarg>");
      break;
2250
2251
2252
2253
    case OPTYPE_CHECKSTATE_ANY: // [r1] v2
    case OPTYPE_CHECKSTATE_ALL:
      u.expr.v2->set_fullname(p_fullname+".<operand1>");
      break;
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
    case OPTYPE_UNDEF_RUNNING: // r1 [r2] b4
    case OPTYPE_TMR_RUNNING:
      u.expr.r1->set_fullname(p_fullname+".<operand>");
      if (u.expr.r2 != NULL) {
        u.expr.r2->set_fullname(p_fullname+".redirindex");
      }
      break;
    case OPTYPE_COMP_RUNNING: // v1 [r2] b4
    case OPTYPE_COMP_ALIVE:
      u.expr.v1->set_fullname(p_fullname+".<operand>");
      if (u.expr.r2 != NULL) {
        u.expr.r2->set_fullname(p_fullname+".redirindex");
      }
      break;
Elemer Lelik's avatar
Elemer Lelik committed
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
    default:
      FATAL_ERROR("Value::set_fullname_expr()");
    } // switch
  }

  void Value::set_my_scope_expr(Scope *p_scope)
  {
    switch (u.expr.v_optype) {
    case OPTYPE_RND: // -
    case OPTYPE_COMP_NULL:
    case OPTYPE_COMP_MTC:
    case OPTYPE_COMP_SYSTEM:
    case OPTYPE_COMP_SELF:
    case OPTYPE_COMP_RUNNING_ANY:
    case OPTYPE_COMP_RUNNING_ALL:
    case OPTYPE_COMP_ALIVE_ANY:
    case OPTYPE_COMP_ALIVE_ALL:
    case OPTYPE_TMR_RUNNING_ANY:
    case OPTYPE_GETVERDICT:
    case OPTYPE_TESTCASENAME:
Elemer Lelik's avatar
Elemer Lelik committed
2288
    case OPTYPE_PROF_RUNNING:
2289
    case OPTYPE_GET_PORT_REF:
Elemer Lelik's avatar
Elemer Lelik committed
2290
      break;
2291
2292
2293
2294
2295
2296
    case OPTYPE_COMP_RUNNING: // v1 [r2] b4
    case OPTYPE_COMP_ALIVE:
      if (u.expr.r2 != NULL) {
        u.expr.r2->set_my_scope(p_scope);
      }
      // no break
Elemer Lelik's avatar
Elemer Lelik committed
2297
2298
2299
2300
2301
2302
2303
2304
    case OPTYPE_UNARYPLUS: // v1
    case OPTYPE_UNARYMINUS:
    case OPTYPE_NOT:
    case OPTYPE_NOT4B:
    case OPTYPE_BIT2HEX:
    case OPTYPE_BIT2INT:
    case OPTYPE_BIT2OCT:
    case OPTYPE_BIT2STR:
2305
    case OPTYPE_BSON2JSON:
2306
    case OPTYPE_CBOR2JSON:
Elemer Lelik's avatar
Elemer Lelik committed
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
    case OPTYPE_CHAR2INT:
    case OPTYPE_CHAR2OCT:
    case OPTYPE_FLOAT2INT:
    case OPTYPE_FLOAT2STR:
    case OPTYPE_HEX2BIT:
    case OPTYPE_HEX2INT:
    case OPTYPE_HEX2OCT:
    case OPTYPE_HEX2STR:
    case OPTYPE_INT2CHAR:
    case OPTYPE_INT2FLOAT:
    case OPTYPE_INT2STR:
    case OPTYPE_INT2UNICHAR:
2319
    case OPTYPE_JSON2BSON:
2320
    case OPTYPE_JSON2CBOR:
Elemer Lelik's avatar
Elemer Lelik committed
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
    case OPTYPE_OCT2BIT:
    case OPTYPE_OCT2CHAR:
    case OPTYPE_OCT2HEX:
    case OPTYPE_OCT2INT:
    case OPTYPE_OCT2STR:
    case OPTYPE_STR2BIT:
    case OPTYPE_STR2FLOAT:
    case OPTYPE_STR2HEX:
    case OPTYPE_STR2INT:
    case OPTYPE_STR2OCT:
    case OPTYPE_UNICHAR2INT:
    case OPTYPE_UNICHAR2CHAR:
    case OPTYPE_ENUM2INT:
    case OPTYPE_RNDWITHVAL:
    case OPTYPE_REMOVE_BOM:
    case OPTYPE_GET_STRINGENCODING:
    case OPTYPE_DECODE_BASE64:
      u.expr.v1->set_my_scope(p_scope);
      break;
ebensza's avatar
ebensza committed
2340
2341
2342
    case OPTYPE_HOSTID: // [v1]
      if(u.expr.v1) u.expr.v1->set_my_scope(p_scope);
      break;
Elemer Lelik's avatar
Elemer Lelik committed
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
    case OPTYPE_ADD: // v1 v2
    case OPTYPE_SUBTRACT:
    case OPTYPE_MULTIPLY:
    case OPTYPE_DIVIDE:
    case OPTYPE_MOD:
    case OPTYPE_REM:
    case OPTYPE_CONCAT:
    case OPTYPE_EQ:
    case OPTYPE_LT:
    case OPTYPE_GT:
    case OPTYPE_NE:
    case OPTYPE_GE:
    case OPTYPE_LE:
    case OPTYPE_AND:
    case OPTYPE_OR:
    case OPTYPE_XOR:
    case OPTYPE_AND4B:
    case OPTYPE_OR4B:
    case OPTYPE_XOR4B:
    case OPTYPE_SHL:
    case OPTYPE_SHR:
    case OPTYPE_ROTL:
    case OPTYPE_ROTR:
    case OPTYPE_INT2BIT:
    case OPTYPE_INT2HEX:
    case OPTYPE_INT2OCT:
      u.expr.v1->set_my_scope(p_scope);
      u.expr.v2->set_my_scope(p_scope);
      break;
    case OPTYPE_UNICHAR2OCT:
    case OPTYPE_OCT2UNICHAR:
    case OPTYPE_ENCODE_BASE64:
      u.expr.v1->set_my_scope(p_scope);
      if(u.expr.v2) u.expr.v2->set_my_scope(p_scope);
      break;
2378
2379
    case OPTYPE_UNDEF_RUNNING: // r1 [r2] b4
    case OPTYPE_TMR_RUNNING: // r1 [r2] b4
Elemer Lelik's avatar
Elemer Lelik committed
2380
      u.expr.r1->set_my_scope(p_scope);
2381
2382
2383
      if (u.expr.r2 != NULL) {
        u.expr.r2->set_my_scope(p_scope);
      }
Elemer Lelik's avatar
Elemer Lelik committed
2384
      break;
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
    case OPTYPE_DECODE: // r1 r2 [v3] [v4]
      u.expr.r1->set_my_scope(p_scope);
      u.expr.r2->set_my_scope(p_scope);
      if (u.expr.v3 != NULL) {
        u.expr.v3->set_my_scope(p_scope);
      }
      if (u.expr.v4 != NULL) {
        u.expr.v4->set_my_scope(p_scope);
      }
      break;
Elemer Lelik's avatar
Elemer Lelik committed
2395
    case OPTYPE_SUBSTR:
2396
    case OPTYPE_ENCODE:
Elemer Lelik's avatar
Elemer Lelik committed
2397
      u.expr.ti1->set_my_scope(p_scope);
2398
2399
2400
2401
2402
2403
      if (u.expr.v2 != NULL) {
        u.expr.v2->set_my_scope(p_scope);
      }
      if (u.expr.v3 != NULL) {
        u.expr.v3->set_my_scope(p_scope);
      }
Elemer Lelik's avatar
Elemer Lelik committed
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
      break;
    case OPTYPE_REGEXP:
      u.expr.ti1->set_my_scope(p_scope);
      u.expr.t2->set_my_scope(p_scope);
      u.expr.v3->set_my_scope(p_scope);
      break;
    case OPTYPE_DECOMP: // v1 v2 v3
      u.expr.v1->set_my_scope(p_scope);
      u.expr.v2->set_my_scope(p_scope);
      u.expr.v3->set_my_scope(p_scope);
      break;
    case OPTYPE_REPLACE:
      u.expr.ti1->set_my_scope(p_scope);
      u.expr.v2->set_my_scope(p_scope);
      u.expr.v3->set_my_scope(p_scope);
      u.expr.ti4->set_my_scope(p_scope);
      break;