Type.hh 57.3 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/******************************************************************************
 * Copyright (c) 2000-2016 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Baji, Laszlo
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Beres, Szabolcs
 *   Bibo, Zoltan
 *   Cserveni, Akos
 *   Delic, Adam
 *   Forstner, Matyas
 *   Gecse, Roland
 *   Kovacs, Ferenc
 *   Raduly, Csaba
 *   Szabados, Kristof
 *   Szabo, Janos Zoltan – initial implementation
 *   Szalai, Gabor
 *   Tatarka, Gabor
 *   Zalanyi, Balazs Andor
 *
 ******************************************************************************/
27

Elemer Lelik's avatar
Elemer Lelik committed
28
29
30
31
32
33
34
35
36
37
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
67
68
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
#ifndef _Common_Type_HH
#define _Common_Type_HH

#include "Setting.hh"
#include "Code.hh"
#include "Int.hh"
#include "subtype.hh"
#include "ttcn3/rawASTspec.h"
#include "ttcn3/RawAST.hh"
#include "ttcn3/TextAST.hh"
#include "ttcn3/BerAST.hh"
#include "ttcn3/JsonAST.hh"
#include <float.h>

class XerAttributes;
enum namedbool { INCOMPLETE_NOT_ALLOWED = 0, INCOMPLETE_ALLOWED = 1,
  NO_SUB_CHK = 0, SUB_CHK = 2, OMIT_NOT_ALLOWED = 0, OMIT_ALLOWED = 3,
  ANY_OR_OMIT_NOT_ALLOWED = 0, ANY_OR_OMIT_ALLOWED = 4,
  NOT_IMPLICIT_OMIT = 0, IMPLICIT_OMIT = 5, NOT_STR_ELEM = 0, IS_STR_ELEM = 6
};

namespace Asn {
  // not defined here
  class Tags;
  class Tag;
  class TagCollection;
  class Block;
  class OC_defn;
  class TableConstraint;
} // namespace Asn

namespace Ttcn {
  // not defined here
  class ArrayDimension;
  class FieldOrArrayRefs;
  class Template;
  class Definitions;
  class Definition;
  class SingleWithAttrib;
  class MultiWithAttrib;
  class WithAttribPath;
  class FormalPar;
  class FormalParList;
  class Reference;
  class PortTypeBody;
  class Def_Type;
  class Ref_pard;
} // namespace Ttcn

// not defined here
class JSON_Tokenizer;

namespace Common {

  /**
   * \ingroup AST
   *
   * \defgroup AST_Type Type
   * @{
   */
  using Asn::Tag;
  using Asn::Tags;
  using Asn::TagCollection;
  using Asn::Block;
  using Asn::OC_defn;
  using Asn::TableConstraint;
  using Ttcn::Template;

  class Type;

  // not defined here
  class Identifier;
  class Constraints;
  class Value;
  class CompField;
  class CompFieldMap;
  class EnumItem;
  class EnumItems;
  class ExcSpec;
  class NamedValues;
  class CTs_EE_CTs;
  class TypeSet;
  class TypeChain;
  class TypeCompatInfo;
  class ComponentTypeBody;
  class SignatureParam;
  class SignatureParamList;
  class SignatureExceptions;
  class CodeGenHelper;
117
  class Assignment;
Elemer Lelik's avatar
Elemer Lelik committed
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198

  /**
   * This is the base class for types.
   */
  class Type : public Governor {
  public:

    /** type of type */
    enum typetype_t {
      /** Undefined.
       *  There is never a Type object with this typetype.
       *  It may be returned by Value::get_expr_returntype() or
       *  ValueRange::get_expr_returntype().        */
      T_UNDEF,
      T_ERROR, /**< erroneous (e.g. nonexistent reference) */
      T_NULL, /**< null (ASN.1) */
      T_BOOL, /**< boolean */
      T_INT, /**< integer */
      T_INT_A, /**< integer / ASN */
      T_REAL, /**< real/float */
      T_ENUM_A, /**< enumerated / ASN */
      T_ENUM_T, /**< enumerated / TTCN */
      T_BSTR, /**< bitstring */
      T_BSTR_A, /**< bitstring */
      T_HSTR, /**< hexstring (TTCN-3) */
      T_OSTR, /**< octetstring */
      T_CSTR, /**< charstring (TTCN-3) */
      T_USTR, /**< universal charstring (TTCN-3) */
      T_UTF8STRING, /**< UTF8String (ASN.1) */
      T_NUMERICSTRING, /**< NumericString (ASN.1) */
      T_PRINTABLESTRING, /**< PrintableString (ASN.1) */
      T_TELETEXSTRING, /**< TeletexString (ASN.1) */
      T_VIDEOTEXSTRING, /**< VideotexString (ASN.1) */
      T_IA5STRING, /**< IA5String (ASN.1) */
      T_GRAPHICSTRING, /**< GraphicString (ASN.1) */
      T_VISIBLESTRING, /**< VisibleString (ASN.1) */
      T_GENERALSTRING, /**< GeneralString (ASN.1) */
      T_UNIVERSALSTRING,  /**< UniversalString (ASN.1) */
      T_BMPSTRING, /**< BMPString (ASN.1) */
      T_UNRESTRICTEDSTRING, /**< UnrestrictedCharacterString (ASN.1) */
      T_UTCTIME, /**< UTCTime (ASN.1) */
      T_GENERALIZEDTIME, /**< GeneralizedTime (ASN.1) */
      T_OBJECTDESCRIPTOR, /** Object descriptor, a kind of string (ASN.1) */
      T_OID, /**< object identifier */
      T_ROID, /**< relative OID (ASN.1) */
      T_CHOICE_A, /**< choice /ASN, uses u.secho */
      T_CHOICE_T, /**< union /TTCN, uses u.secho */
      T_SEQOF, /**< sequence (record) of */
      T_SETOF, /**< set of */
      T_SEQ_A, /**< sequence /ASN, uses u.secho */
      T_SEQ_T, /**< record /TTCN, uses u.secho */
      T_SET_A, /**< set /ASN, uses u.secho */
      T_SET_T, /**< set /TTCN, uses u.secho */
      T_OCFT, /**< ObjectClassFieldType (ASN.1) */
      T_OPENTYPE, /**< open type (ASN.1) */
      T_ANY, /**< ANY (deprecated ASN.1) */
      T_EXTERNAL, /**< %EXTERNAL (ASN.1) */
      T_EMBEDDED_PDV, /**< EMBEDDED PDV (ASN.1) */
      T_REFD, /**< referenced */
      T_REFDSPEC, /**< special referenced (by pointer, not by name) */
      T_SELTYPE, /**< selection type (ASN.1) */
      T_VERDICT, /**< verdict type (TTCN-3) */
      T_PORT, /**< port type (TTCN-3) */
      T_COMPONENT, /**< component type (TTCN-3) */
      T_ADDRESS, /**< address type (TTCN-3) */
      T_DEFAULT, /**< default type (TTCN-3) */
      T_ARRAY, /**< array (TTCN-3), uses u.array */
      T_SIGNATURE, /**< signature (TTCN-3) */
      T_FUNCTION, /**< function reference (TTCN-3) */
      T_ALTSTEP, /**< altstep reference (TTCN-3) */
      T_TESTCASE, /**< testcase reference (TTCN-3) */
      T_ANYTYPE, /**< anytype (TTCN-3) */
      // WRITE new type before this line
      T_LAST
    };       //DO NOT FORGET to update type_as_string[] in Type.cc 

    /**
     * Enumeration to represent message encoding types.
     */
    enum MessageEncodingType_t {
      CT_UNDEF, /**< undefined/unused */
199
200
201
202
203
204
205
      CT_BER,   /**< ASN.1 BER (built-in) */
      CT_PER,   /**< ASN.1 PER (through user defined coder functions) */
      CT_RAW,   /**< TTCN-3 RAW (built-in) */
      CT_TEXT,  /**< TTCN-3 TEXT (built-in) */
      CT_XER,    /**< TTCN-3 XER (built-in) */
      CT_JSON,   /**< TTCN-3 and ASN.1 JSON (built-in) */
      CT_CUSTOM  /**< user defined encoding (through user defined coder functions) */
Elemer Lelik's avatar
Elemer Lelik committed
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
    };

    /** selector for value checking algorithms */
    enum expected_value_t {
      /** the value must be known at compile time (i.e. it may refer
       *  to a TTCN-3 constant or an ASN.1 value) */
      EXPECTED_CONSTANT,
      /** the value must be static at execution time, but may be
       *  unknown at compilation time (i.e. it may refer to a TTCN-3
       *  module parameter as well) */
      EXPECTED_STATIC_VALUE,
      /** the value is known only at execution time (i.e. it may refer
       *  to a variable in addition to static values) */
      EXPECTED_DYNAMIC_VALUE,
      /** the reference may point to a dynamic value or a template
       *  (this selector is also used in template bodies where the
       *  variable references are unaccessible because of the scope
       *  hierarchy) */
      EXPECTED_TEMPLATE
    };

    /** Enumeration to represent the owner of the type.
228
      */
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
    enum TypeOwner_t {
      OT_UNKNOWN,
      OT_TYPE_ASS, ///< ASN.1 type assignment (Ass_T)
      OT_VAR_ASS,  ///< ASN.1 variable assignment (Ass_V)
      OT_VSET_ASS, ///< ASN.1 value set assignment (Ass_VS)
      OT_TYPE_FLD, ///< ASN.1 TypeFieldSpec (FieldSpec_T)
      OT_FT_V_FLD, ///< ASN.1 FixedTypeValueFieldSpec (FieldSpec_V_FT)
      OT_TYPE_MAP, ///< TTCN-3 TypeMapping
      OT_TYPE_MAP_TARGET, ///< TTCN-3 TypeMappingTarget
      OT_TYPE_DEF, ///< TTCN-3 type definition (Def_Type)
      OT_CONST_DEF, ///< TTCN-3 constant definition (DefConst, Def_ExtCOnst)
      OT_MODPAR_DEF, ///< TTCN-3 module parameter definition (Def_Modulepar)
      OT_VAR_DEF, ///< TTCN-3 variable definition (Def_Var)
      OT_VARTMPL_DEF, ///< TTCN-3 var template definition (Def_Var_Template)
      OT_FUNCTION_DEF, ///< TTCN-3 function (Def_Function, Def_ExtFunction)
      OT_TEMPLATE_DEF, ///< TTCN-3 template definition (Def_Template)
      OT_ARRAY, ///< another Type: TTCN-3 array(T_ARRAY)
      OT_RECORD_OF, ///< another Type (T_SEQOF, T_SETOF), ASN.1 or TTCN-3
      OT_FUNCTION, ///< another Type: TTCN-3 function (T_FUNCTION)
      OT_SIGNATURE, ///< another Type: TTCN-3 signature (T_SIGNATURE)
      OT_REF, ///< another Type (T_REFD)
      OT_REF_SPEC, ///< another Type (T_REFDSPEC)
      OT_COMP_FIELD, ///< a field of a record/set/union (CompField)
      OT_COMPS_OF, ///< ASN.1 "COMPONENTS OF" (CT_CompsOf)
      OT_FORMAL_PAR, ///< formal parameter (FormalPar), TTCN-3
      OT_TYPE_LIST, ///< TypeList for a 'with "extension anytype t1,t2..." '
      OT_FIELDSETTING, ///< ASN.1 FieldSetting_Type
      OT_SELTYPE, ///< another Type (T_SELTYPE), ASN.1 selection type
      OT_OCFT, ///< another Type (T_OCFT), ASN.1 obj.class field type
      OT_TEMPLATE_INST, ///< a TemplateInstance (TTCN-3)
      OT_RUNSON_SCOPE, ///< a RunsOnScope (TTCN-3)
      OT_EXC_SPEC, ///< exception Specification (ExcSpec)
      OT_SIG_PAR, ///< signature parameter (SignatureParam)
      OT_POOL ///< It's a pool type, owned by the type pool
    };
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
    
    /**
     * Enumeration to represent the default method of encoding or decoding for a type.
     */
    enum coding_type_t {
      CODING_UNSET, ///< No encoding/decoding method has been set for the type.
      CODING_BUILT_IN, ///< The type uses a built-in codec for encoding/decoding.
      CODING_BY_FUNCTION, ///< The type uses a user defined function for encoding/decoding.
      CODING_MULTIPLE ///< Multiple encoding/decoding methods have been set for the type.
    };
    
    /**
     * Structure containing the default encoding or decoding settings for a type.
     * These settings determine how values of the type are encoded or decoded by
     * the following TTCN-3 language elements:
     * 'encvalue' (encode), 'encvalue_unichar' (encode), 'decvalue' (decode),
     * 'decvalue_unichar' (decode), 'decmatch' (decode) and '@decoded' (decode).
     */
    struct coding_t {
      coding_type_t type; ///< Type of encoding/decoding
      union {
        MessageEncodingType_t built_in_coding; ///< Built-in codec (if type is CODING_BUILT_IN)
        Assignment* function_def; ///< Pointer to external function definition (if type is CODING_BY_FUNCTION)
      };
    };
Elemer Lelik's avatar
Elemer Lelik committed
289
290
291
292
293

    /** Returns the display string of \a encoding_type. */
    static const char *get_encoding_name(MessageEncodingType_t encoding_type);
    /** Returns a pool type that represents the encoded stream of the given
     * \a encoding_type. */
Elemer Lelik's avatar
Elemer Lelik committed
294
    static Type *get_stream_type(MessageEncodingType_t encoding_type, int stream_variant=0);
Elemer Lelik's avatar
Elemer Lelik committed
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

    enum truth {
      No, Maybe, Yes
    };

  private:
    typetype_t typetype;
    bool tags_checked;
    bool tbl_cons_checked;
    bool text_checked;
    bool json_checked;
    bool raw_parsed;
    bool raw_checked;
    bool xer_checked;
    bool raw_length_calculated;
    bool has_opentypes;
    bool opentype_outermost;
    bool code_generated;
    bool embed_values_possible;
    bool use_nil_possible;
    bool use_order_possible;
    int raw_length;
    Type *parent_type;
    Tags *tags;
    Constraints *constraints;
    /// The type's attributes (with context)
    Ttcn::WithAttribPath* w_attrib_path;
    /** A copy of all the AT_ENCODEs  */
    Ttcn::WithAttribPath* encode_attrib_path;
    RawAST *rawattrib;
    TextAST *textattrib;
    XerAttributes *xerattrib;
    BerAST *berattrib;
    JsonAST *jsonattrib;

    vector<SubTypeParse> *parsed_restr; ///< parsed subtype restrictions are stored here until they are moved to the sub_type member
    SubType *sub_type; ///< effective/aggregate subtype of this type, NULL if neither inherited nor own subtype restrictions exist

333
334
335
    coding_t default_encoding; ///< default settings for encoding values of this type
    coding_t default_decoding; ///< default settings for decoding values of this type
    
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
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
    /** What kind of AST element owns the type.
     *  It may not be known at creation type, so it's initially OT_UNKNOWN.
     *  We want this information so we don't have to bother with XER
     *  if the type is an ASN.1 construct, or it's the type in a "runs on" scope,
     *  the type of a variable declaration/module par/const, etc. */
    TypeOwner_t ownertype;
    Node *owner;

    union {
      struct {
        Block *block;
        NamedValues *nvs;
      } namednums;
      struct {
        EnumItems *eis; ///< Final set of enum items
        Int first_unused;  ///< First  unused >=0 value (for UNKNOWN_VALUE)
        Int second_unused; ///< Second unused >=0 value (for UNBOUND_VALUE)
        Block *block; ///< ASN.1 block to be parsed
        EnumItems *eis1; ///< First set of enum items before the ellipsis
        bool ellipsis; ///< true if there was an ellipsis, false otherwise
        ExcSpec *excSpec; ///< Exception specification
        EnumItems *eis2; ///< Second set of enum items after the ellipsis
        map<string, size_t> *eis_by_name;
      } enums;
      struct {
        CompFieldMap *cfm;
        Block *block; ///< Unparsed block; will be 0 after parse_block_...()
        CTs_EE_CTs *ctss;
        bool tr_compsof_ready;
        bool component_internal;
        map<string, size_t> *field_by_name;
        OC_defn *oc_defn; /**< link to...  */
        const Identifier *oc_fieldname; /**< link to...  */
        const TableConstraint *my_tableconstraint; /**< link to...  */
        bool has_single_charenc; /**< Has a single character-encodable field
                                  * with the UNTAGGED encoding instruction.
                                  * X693amd1 32.2.2 applies to the field. */
      } secho; /**< data for T_(SEQUENCE|SET_CHOICE)_[AT] */
      struct {
        Type *ofType;
        bool component_internal;
      } seof; /**< data for SEQUENCE OF/SET OF */
      struct {
        Reference *ref;
        Type *type_refd; /**< link to...  */
        OC_defn *oc_defn; /**< link to...  */
        const Identifier *oc_fieldname; /**< link to...  */
        bool component_internal;
      } ref;
      struct {
        Identifier *id;
        Type *type;
        Type *type_refd;
      } seltype;
      struct {
        Type *element_type;
	Ttcn::ArrayDimension *dimension;
	bool in_typedef;
        bool component_internal;
      } array;
      Ttcn::PortTypeBody *port;
      ComponentTypeBody *component;
      Type *address; /**< link to...  */
      struct {
	SignatureParamList *parameters;
	Type *return_type;
	bool no_block;
        bool component_internal;
	SignatureExceptions *exceptions;
      } signature;
      struct {
        Ttcn::FormalParList *fp_list;
	struct {
          bool self;
          Ttcn::Reference *ref;
          Type *type; // useful only after check
	} runs_on;
        union {
          Type *return_type;
          struct {
            Ttcn::Reference *ref;
            Type *type; // useful only after check
          } system;
        };
        bool returns_template;
        template_restriction_t template_restriction;
        bool is_startable;
      } fatref;
    } u;
    static const char* type_as_string[];
    
    /** True if chk() has finished running. 
      * Prevents force_raw() from running chk_raw(), chk_text() or chk_json() on unchecked types. */
    bool chk_finished;
Elemer Lelik's avatar
Elemer Lelik committed
430
431
432
433
434
    
    /** Signifies that this type is an instance of an ASN.1 parameterized type.
      * It will not have its own segment and reference generated in the JSON schema,
      * its schema segment will be generated as an embedded type's would. */
    bool pard_type_instance;
435
436
437
438
439
    
    /** Indicates that the component array version (used with the help of the
      * 'any from' clause) of the 'done' function needs to be generated for
      * this type. */
    bool needs_any_from_done;
Elemer Lelik's avatar
Elemer Lelik committed
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

    /** Copy constructor, for the use of Type::clone() only. */
    Type(const Type& p);
    /** Assignment disabled */
    Type& operator=(const Type& p);
    /** Set fields to their default values */
    void init();
    /** Free up resources */
    void clean_up();
    /** Returns the default tag of the type. */
    Tag *get_default_tag();
    /** Returns the number in UNIVERSAL tag class that belongs to ASN.1 type
     * type \a p_tt. In case of invalid argument -1 is returned */
    static int get_default_tagnumber(typetype_t p_tt);
    /** Container for the allocated tags that do not belong to a particular
     * Type object */
    static map<typetype_t, Tag> *default_tags;
    static void destroy_default_tags();
    /** Container for the allocated pool types */
    static map<typetype_t, Type> *pooltypes;
    /** Drops the elements of \a pooltypes */
    static void destroy_pooltypes();
    /** Returns the TTCN-3 equivalent of \a p_tt. */
    static typetype_t get_typetype_ttcn3(typetype_t p_tt);

  public:
    /** @name Constructors
     *  @{ */
    /// Construct a predefined type (including anytype and address)
    Type(typetype_t p_tt);
    /// Construct a TTCN enumerated type
    Type(typetype_t p_tt, EnumItems *p_eis);
    /** Construct an ASN.1 enum, sequence, set, choice, integer with
     * named numbers, or a bitstring with named bits */
    Type(typetype_t p_tt, Block *p_block);
    /// Construct an ASN.1 enum, with or without extension
    Type(typetype_t p_tt,
         EnumItems *p_eis1, bool p_ellipsis, EnumItems *p_eis2);
    /// Construct a TTCN3 sequence, set or choice
    Type(typetype_t p_tt, CompFieldMap *p_cfm);
    /** Construct a type with an embedded type: a record-of, set-of,
    * or a special reference (involved in: ASN.1 table constraint,
    * TTCN3 (ext)const definition, module parameter, variable instance) */
    Type(typetype_t p_tt, Type *p_type);
    /// Create an ASN.1 selection type
    Type(typetype_t p_tt, Identifier *p_id, Type *p_type);
    /// ASN.1 ObjectClassFieldType
    Type(typetype_t p_tt, Type *p_type, OC_defn *p_oc_defn,
         const Identifier *p_id);
    /// Create a TTCN3 array
    Type(typetype_t p_tt, Type *p_type, Ttcn::ArrayDimension *p_dim,
	 bool p_in_typedef);
    /// Create an ASN.1 open type
    Type(typetype_t p_tt, OC_defn *p_oc_defn, const Identifier *p_id);
    /// Create a reference
    Type(typetype_t p_tt, Reference *p_ref);
    /// Create a TTCN3 port type
    Type(typetype_t p_tt, Ttcn::PortTypeBody *p_pb);
    /// Create a TTCN3 component type
    Type(typetype_t p_tt, ComponentTypeBody *p_cb);
    /// Create a TTCN3 signature
    Type(typetype_t p_tt, SignatureParamList *p_params, Type *p_returntype,
	bool p_noblock, SignatureExceptions *p_exceptions);
    /// Create a TTCN3 function reference
    Type(typetype_t p_tt,Ttcn::FormalParList *p_params,
        Ttcn::Reference* p_runs_on_ref, bool p_runs_on_self,
        Type *p_returntype, bool p_returns_template,
        template_restriction_t p_template_restriction);
    /// Create a TTCN3 altstep
    Type(typetype_t p_tt,Ttcn::FormalParList *p_params,
        Ttcn::Reference* p_runs_on_ref, bool p_runs_on_self);
    /// Create a TTCN3 testcase
    Type(typetype_t p_tt,Ttcn::FormalParList *p_params,
        Ttcn::Reference* p_runs_on_ref, Ttcn::Reference *p_system_ref);
    /** @} */
    virtual ~Type();
    /** This function must be called to clean up the pool types,
     *  tags, etc. It is called by main() */
    static void free_pools();
    /** Create a (partial) copy of the object */
    virtual Type* clone() const;
    /** Return the type of type. */
    typetype_t get_typetype() const { return typetype; }
    /** Returns the TTCN-3 equivalent of \a typetype. */
    typetype_t get_typetype_ttcn3() const
      { return get_typetype_ttcn3(typetype); }
    /** Returns a simple/built-in type from the pool */
    static Type* get_pooltype(typetype_t p_typetype);
    /** Returns whether the type is defined in an ASN.1 module. */
    bool is_asn1() const;
    /** Returns true if it is a type reference. */
    bool is_ref() const;
    /** Returns true if it is a Sequence, Set or Choice. */
    bool is_secho() const;
    /** Returns true if this is a character-encodable type.
     *  Being character-encodable is a requirement for a type to be
     *  encoded as an XML attribute. */
    truth is_charenc();
    /** Return true if at least one abstract value of the type
     *  has an empty "ExtendedXMLValue" encoding (only possible with EXER).
     *  Possible for record/set when all components are optional,
     *  and record-of/set-of when 0 length is not forbidden. */
    bool has_empty_xml();
    /** Returns whether \a this is a sequence-of/record-of or set-of type. */
    bool is_seof() const { return typetype == T_SEQOF || typetype == T_SETOF; }
    /** Returns the \a sub_type member */
    SubType* get_sub_type() const { return sub_type; }
    /** If this is a reference, returns the referenced type.
     *  Otherwise, it's a fatal error. */
    Type* get_type_refd(ReferenceChain *refch=0);
    /** Walk through all references to the referenced type */
    Type* get_type_refd_last(ReferenceChain *refch=0);
    /** Returns the type of the field, which is referenced by \a subrefs from
     * \a this. It checks the array indices against \a expected_index. In case
     * of error NULL is returned.
     * Special case: if \a interrupt_if_optional is true then return NULL if an
     * optional field has been reached. Using this bool parameter it can be
     * checked if a referenced field is on an optional path (used by template
     * restriction checking code) */
    Type *get_field_type(Ttcn::FieldOrArrayRefs *subrefs,
      expected_value_t expected_index, ReferenceChain *refch = 0,
      bool interrupt_if_optional = false);
    /** subrefs must point to an existing field, get_field_type() should be used
      * to check. subrefs_array will be filled with the indexes of the fields,
      * type_array will be filled with types whose field indexes were collected,
      * if an invalid index is encountered false will be returned */
    bool get_subrefs_as_array(const Ttcn::FieldOrArrayRefs *subrefs,
      dynamic_array<size_t>& subrefs_array, dynamic_array<Type*>& type_array);
    /** Returns whether the last field referenced by \a subrefs is an optional
     * record/SEQUENCE or set/SET field. It can be used only after a successful
     * semantic check (e.g. during code generation) or the behaviour will be
     * unpredictable. */
    bool field_is_optional(Ttcn::FieldOrArrayRefs *subrefs);
    /** Returns whether this type instance is the type of an optional field.  */
    bool is_optional_field() const;
    virtual void set_fullname(const string& p_fullname);
    /** Sets the internal pointer my_scope to \a p_scope. */
    virtual void set_my_scope(Scope *p_scope);
    /** Checks the type (including tags). */
    virtual void chk();
    /** Return whether the two typetypes are compatible.  Sometimes, this is
     *  just a question of \p p_tt1 == \p p_tt2.  When there are multiple
     *  typetypes for a type (e.g. T_ENUM_A and T_ENUM_T) then all
     *  combinations of those are compatible.  */
    static bool is_compatible_tt_tt(typetype_t p_tt1, typetype_t p_tt2,
                                    bool p_is_asn11, bool p_is_asn12);
    /** Returns whether the type is compatible with \a p_tt.  Used if the
     *  other value is unfoldable, but we can determine its expr_typetype.
     *  Note: The compatibility relation is asymmetric.  The function returns
     *  true if the set of possible values in \a p_type is a subset of
     *  possible values in \a this.  */
    bool is_compatible_tt(typetype_t p_tt, bool p_is_asn1);
    /** Returns whether this type is compatible with \a p_type.  Note: The
     *  compatibility relation is asymmetric.  The function returns true if
     *  the set of possible values in \a p_type is a subset of possible values
     *  in \a this.  It returns false if the two types cannot be compatible
     *  ever.  If the two types are compatible, but they need additional
     *  "type" conversion code generated with run-time checks \p p_info will
     *  provide more information.  \p p_info is used to collect type
     *  information to report more precise errors.  \p p_left_chain and
     *  \p p_right_chain are there to prevent infinite recursion.
     *  \p p_left_chain contains the type chain of the left operand from the
     *  "root" type to this point in the type's structure.  \p p_right_chain
Elemer Lelik's avatar
Elemer Lelik committed
603
604
605
     *  is the same for the right operand.
     * \p p_is_inline_template indicates that the conversion is requested for an
     * inline template. Type conversion code is not needed in this case. */
Elemer Lelik's avatar
Elemer Lelik committed
606
    bool is_compatible(Type *p_type, TypeCompatInfo *p_info,
607
                       Location* p_loc,
Elemer Lelik's avatar
Elemer Lelik committed
608
                       TypeChain *p_left_chain = NULL,
Elemer Lelik's avatar
Elemer Lelik committed
609
610
                       TypeChain *p_right_chain = NULL,
                       bool p_is_inline_template = false);
Elemer Lelik's avatar
Elemer Lelik committed
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
    /** Check if the restrictions of a T_SEQOF/T_SETOF are "compatible" with
     *  the given type \a p_type.  Can be called only as a T_SEQOF/T_SETOF.
     *  Currently, used for structured types only.  \a p_type can be any kind
     *  of structured type.  */
    bool is_subtype_length_compatible(Type *p_type);
    /** Check if it's a structured type.  Return true if the current type is a
     *  structured type, false otherwise.  */
    bool is_structured_type() const;
    /** returns the type as a string */
    virtual const char* asString() const;
    static const char* asString(typetype_t type);

  private:
    /** Helper functions for is_compatible().  These functions can be called
     *  only for a Type that the name suggests.  \p p_type is the Type we're
     *  checking compatibility against.  \p p_info is used to collect type
     *  information to report more precise errors.  \p p_left_chain and
     *  \p p_right_chain are there to prevent infinite recursion.
     *  \p p_left_chain contains the type chain of the left operand from the
     *  "root" type to this point in the type's structure.  \p p_right_chain
Elemer Lelik's avatar
Elemer Lelik committed
631
632
633
     *  is the same for the right operand. 
     *  \p p_is_inline_template indicates that the conversion is requested for an
     *  inline template. Type conversion code is not needed in this case. */
Elemer Lelik's avatar
Elemer Lelik committed
634
    bool is_compatible_record(Type *p_type, TypeCompatInfo *p_info,
635
                              Location* p_loc,
Elemer Lelik's avatar
Elemer Lelik committed
636
                              TypeChain *p_left_chain = NULL,
Elemer Lelik's avatar
Elemer Lelik committed
637
638
                              TypeChain *p_right_chain = NULL,
                              bool p_is_inline_template = false);
Elemer Lelik's avatar
Elemer Lelik committed
639
    bool is_compatible_record_of(Type *p_type, TypeCompatInfo *p_info,
640
                                 Location* p_loc,
Elemer Lelik's avatar
Elemer Lelik committed
641
                                 TypeChain *p_left_chain = NULL,
Elemer Lelik's avatar
Elemer Lelik committed
642
643
                                 TypeChain *p_right_chain = NULL,
                                 bool p_is_inline_template = false);
Elemer Lelik's avatar
Elemer Lelik committed
644
    bool is_compatible_set(Type *p_type, TypeCompatInfo *p_info,
645
                           Location* p_loc,
Elemer Lelik's avatar
Elemer Lelik committed
646
                           TypeChain *p_left_chain = NULL,
Elemer Lelik's avatar
Elemer Lelik committed
647
648
                           TypeChain *p_right_chain = NULL,
                           bool p_is_inline_template = false);
Elemer Lelik's avatar
Elemer Lelik committed
649
    bool is_compatible_set_of(Type *p_type, TypeCompatInfo *p_info,
650
                              Location* p_loc,
Elemer Lelik's avatar
Elemer Lelik committed
651
                              TypeChain *p_left_chain = NULL,
Elemer Lelik's avatar
Elemer Lelik committed
652
653
                              TypeChain *p_right_chain = NULL,
                              bool p_is_inline_template = false);
Elemer Lelik's avatar
Elemer Lelik committed
654
    bool is_compatible_array(Type *p_type, TypeCompatInfo *p_info,
655
                             Location* p_loc,
Elemer Lelik's avatar
Elemer Lelik committed
656
                             TypeChain *p_left_chain = NULL,
Elemer Lelik's avatar
Elemer Lelik committed
657
658
                             TypeChain *p_right_chain = NULL,
                             bool p_is_inline_template = false);
Elemer Lelik's avatar
Elemer Lelik committed
659
    bool is_compatible_choice_anytype(Type *p_type, TypeCompatInfo *p_info,
660
                                      Location* p_loc,
Elemer Lelik's avatar
Elemer Lelik committed
661
                                      TypeChain *p_left_chain = NULL,
Elemer Lelik's avatar
Elemer Lelik committed
662
663
                                      TypeChain *p_right_chain = NULL,
                                      bool p_is_inline_template = false);
Elemer Lelik's avatar
Elemer Lelik committed
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
  public:
    /** Returns whether this type is identical to \a p_type from TTCN-3 point
     *  of view.  Note: This relation is symmetric.  The function returns true
     *  only if the sets of possible values are the same in both types.  */
    bool is_identical(Type *p_type);
    /** Tasks: Decides whether the type needs automatic tagging, performs the
     *  COMPONENTS OF transformations (recursively) and adds the automatic
     *  tags. */
    void tr_compsof(ReferenceChain *refch = 0);
    /** Returns whether the T_FUNCTION is startable.
     *  @pre typetype is T_FUNCTION, or else FATAL_ERROR occurs.  */
    bool is_startable();

    /** Returns true if this is a list type (string, rec.of, set.of or array */
    bool is_list_type(bool allow_array);

Elemer Lelik's avatar
Elemer Lelik committed
680
    /** Sets the encoding or decoding function for the type (in case of custom
681
682
683
684
      * or PER encoding). */
    void set_coding_function(bool encode, Assignment* function_def);
    
    /** Sets the codec to use when encoding or decoding the ASN.1 type */
685
    void set_asn_coding(bool encode, MessageEncodingType_t new_coding);
686
687
688
689
690
691
692
693
694
    
    /** Determines the method of encoding or decoding for values of this type
      * based on its attributes and on encoder or decoder function definitions
      * with this type as their input or output. An error is displayed if the
      * coding method cannot be determined.
      *
      * @note Because this check depends on the checks of other AST elements
      * (external functions), it is sometimes delayed to the end of the semantic
      * analysis. */
695
    void chk_coding(bool encode, Module* usage_mod, bool delayed = false);
696
697
698
    
    /** Indicates whether the type is encoded/decoded by a function or by a
      * built-in codec. */
699
    bool is_coding_by_function(bool encode) const;
700
701
702
703
704
705
706
707
708
709
    
    /** Returns the string representation of the type's default codec.
      * Used during code generation for types encoded/decoded by a built-in
      * codec. */
    string get_coding(bool encode) const;
    
    /** Returns the function definition of the type's encoder/decoder function.
      * Used during code generation for types encoded/decoded by functions. */
    Assignment* get_coding_function(bool encode) const;
    
Elemer Lelik's avatar
Elemer Lelik committed
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
780
781
782
783
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
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
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
  private:
    static MessageEncodingType_t get_enc_type(const Ttcn::SingleWithAttrib& enc);

    void chk_Int_A();
    void chk_Enum_A();
    void chk_Enum_item(EnumItem *ei, bool after_ellipsis,
                       map<Int, EnumItem>& value_map);
    void chk_Enum_T();
    void chk_BStr_A();
    void chk_SeCho_T();
    void chk_Choice_A();
    void chk_Se_A();
    void chk_SeOf();
    void chk_refd();
    void chk_seltype();
    void chk_Array();
    void chk_Signature();
    void chk_Fat();
  public:
    /** Checks whether the type can be the TTCN-3 address type. Not allowed:
     * the default type, references pointing to port types, component types
     * and signatures */
    void chk_address();
    /** Checks whether the type can be a component of another type definition
     *  (e.g. field of a structured type, parameter/return type/exception of a
     *  signature).
     *  Not allowed types: ports, signatures.
     *  Default type is allowed only within structured types.
     *  The text for the end of the error message is passed as parameter.
     */
    void chk_embedded(bool default_allowed, const char *error_msg);
    /** Checks for circular references within embedded types */
    void chk_recursions(ReferenceChain& refch);
    /** Checks that the structured type does not have fields
     * with the name of its definition.
     */
    void chk_constructor_name(const Identifier& p_id);
    bool chk_startability();
    /** Checks if it can be a return type */
    void chk_as_return_type(bool as_value, const char* what);
  private:
    void parse_block_Int();
    void parse_block_Enum();
    void parse_block_BStr();
    void parse_block_Choice();
    void parse_block_Se();
    int get_length_multiplier();
    void parse_attributes();
    void chk_raw();
    /** If the type does not have a rawattrib, create one. */
    void force_raw();
    void chk_text();
    void chk_text_matching_values(textAST_matching_values *matching_values,
      const char *attrib_name);
    /** If the type does not have a textattrib, create one. */
    void force_text();
    
    void chk_json();
    void chk_json_default();
    /** If the type does not have a jsonattrib, create one. */
    void force_json();

    void chk_xer();
    void chk_xer_any_attributes();
    void chk_xer_any_element();
    void chk_xer_attribute();
    void chk_xer_dfe();
    Value *new_value_for_dfe(Type *last, const char *dfe_str);
    void target_of_text(string& text);
    void chk_xer_embed_values(int num_attributes);
    void chk_xer_text();
    void chk_xer_untagged();
    void chk_xer_use_nil();
    void chk_xer_use_order(int num_attributes);
    void chk_xer_use_type();
    void chk_xer_use_union();

    bool is_root_basic();
    int get_raw_length();
  public:
    void set_parent_type(Type *p_parent_type) {parent_type=p_parent_type;}
    Type* get_parent_type() const {return parent_type;}
    void set_has_opentypes() {has_opentypes=true;}
    bool get_has_opentypes() const {return has_opentypes;}
    void set_opentype_outermost() {opentype_outermost=true;}
    bool get_is_opentype_outermost() const {return opentype_outermost;}
    /** If \a value is an undef lowerid, then this member decides
     * whether it is a reference or a lowerid value (e.g., enum, named
     * number). */
    void chk_this_value_ref(Value *value);
    bool chk_this_value(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool omit_allowed, namedbool sub_chk,
      namedbool implicit_omit = NOT_IMPLICIT_OMIT,
      namedbool str_elem = NOT_STR_ELEM);
    /** Checks the given referenced value */
    bool chk_this_refd_value(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, ReferenceChain *refch=0,
      namedbool str_elem = NOT_STR_ELEM);
    /** Checks the given invocation */
    void chk_this_invoked_value(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value);
  private:
    void chk_this_value_Null(Value *value);
    void chk_this_value_Bool(Value *value);
    void chk_this_value_Int(Value *value);
    void chk_this_value_Int_A(Value *value);
    void chk_this_value_Real(Value *value);
    void chk_this_value_Enum(Value *value);
    void chk_this_value_BStr(Value *value);
    void chk_this_value_namedbits(Value *value);
    void chk_this_value_BStr_A(Value *value);
    void chk_this_value_HStr(Value *value);
    void chk_this_value_OStr(Value *value);
    void chk_this_value_CStr(Value *value);
    void chk_this_value_OID(Value *value);
    void chk_this_value_ROID(Value *value);
    void chk_this_value_Any(Value *value);
    bool chk_this_value_Choice(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool implicit_omit = NOT_IMPLICIT_OMIT);
    bool chk_this_value_Se(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool implicit_omit = NOT_IMPLICIT_OMIT);
    bool chk_this_value_Se_T(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool implicit_omit = NOT_IMPLICIT_OMIT);
    bool chk_this_value_Seq_T(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool implicit_omit = NOT_IMPLICIT_OMIT);
    bool chk_this_value_Set_T(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool implicit_omit = NOT_IMPLICIT_OMIT);
    bool chk_this_value_Se_A(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool implicit_omit);
    bool chk_this_value_Seq_A(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool implicit_omit);
    bool chk_this_value_Set_A(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool implicit_omit);
    bool chk_this_value_SeOf(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool implicit_omit = NOT_IMPLICIT_OMIT);
    void chk_this_value_Verdict(Value *value);
    void chk_this_value_Default(Value *value);
    bool chk_this_value_Array(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed,
      namedbool implicit_omit);
    bool chk_this_value_Signature(Value *value, Common::Assignment *lhs,
      expected_value_t expected_value, namedbool incomplete_allowed);
    void chk_this_value_Component(Value *value);
    void chk_this_value_FAT(Value *value);
  public:
    /** Checks whether template \a t is a specific value and the embedded value
     * is a referenced one. If the reference in the value points to a
     * template-like entity then it sets the template type to TEMPLATE_REFD,
     * otherwise it leaves everything as is. */
    void chk_this_template_ref(Template *t);
    /** Checks for self references in functions returning templates (external or otherwise)
      * and in parametrised templates. Returns true if the reference in assignment \a lhs 
      * is found. 
      * Recursive: calls itself incase of multiple embedded functions / parametrised templates.*/
    bool chk_this_template_ref_pard(Ttcn::Ref_pard* ref_pard, Common::Assignment* lhs);
    bool chk_this_template_generic(Template *t, namedbool incomplete_allowed,
     namedbool allow_omit, namedbool allow_any_or_omit, namedbool sub_chk,
     namedbool implicit_omit, Common::Assignment *lhs);
  private:
    bool chk_this_refd_template(Template *t, Common::Assignment *lhs);
    void chk_this_template_length_restriction(Template *t);
    bool chk_this_template(Template *t, namedbool is_modified, namedbool sub_chk,
      namedbool implicit_omit, Common::Assignment *);
880
881
    bool chk_this_template_Str(Template *t, namedbool implicit_omit,
      Common::Assignment *lhs);
Elemer Lelik's avatar
Elemer Lelik committed
882
883
884
885
886
887
888
889
890
891
    /** Checks whether \a v is a correct range boundary for this type.
     * Applicable to the following types: integer, float, charstring,
     * universal charstring.
     * Argument \a v might be NULL in case of + or - infinity.
     * Argument \a which shall contain the word "lower" or "upper".
     * Argument \a loc is used for error reporting if \a v is NULL (it points
     * to the surrounding template).
     * If \a v is correct and it is or refers to a constant the constant value
     * is returned for further checking. Otherwise the return value is NULL. */
    Value *chk_range_boundary(Value *v, const char *which, const Location& loc);
Elemer Lelik's avatar
Elemer Lelik committed
892
    void chk_range_boundary_infinity(Value *v, bool is_upper);
Elemer Lelik's avatar
Elemer Lelik committed
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
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
    void chk_this_template_builtin(Template *t);
    void chk_this_template_Int_Real(Template *t);
    void chk_this_template_Enum(Template *t);
    bool chk_this_template_Choice(Template *t, namedbool is_modified,
      namedbool implicit_omit, Common::Assignment *lhs);
    bool chk_this_template_Seq(Template *t, namedbool is_modified,
      namedbool implicit_omit, Common::Assignment *lhs);
    bool chk_this_template_Set(Template *t, namedbool is_modified,
      namedbool implicit_omit, Common::Assignment *lhs);
    bool chk_this_template_SeqOf(Template *t, namedbool is_modified,
      namedbool implicit_omit, Common::Assignment *lhs);
    bool chk_this_template_SetOf(Template *t, namedbool is_modified,
      namedbool implicit_omit, Common::Assignment *lhs);
    bool chk_this_template_array(Template *t, namedbool is_modified,
      namedbool implicit_omit, Common::Assignment *lhs);
    void chk_this_template_Fat(Template *t);
    void chk_this_template_Signature(Template *t, namedbool is_modified);
  public:
    /** Check whether there is an enum item with the given name.
     *
     * @pre typetype is T_ENUM_T or T_ENUM_A */
    bool has_ei_withName(const Identifier& p_id) const;

    /** Return the enum item with the given name.
     *
     * @pre typetype is T_ENUM_T or T_ENUM_A */
    EnumItem *get_ei_byName(const Identifier& p_id) const;

    /** Return the enum item with the given index.
     *
     * @pre typetype is T_ENUM_T or T_ENUM_A */
    EnumItem *get_ei_byIndex(size_t i) const;

    /** Get the number of components.
     *
     * @return the number of components from the appropriate alternative
     * depending on the \a typetype.
     *
     * @pre \a typetype is one of T_CHOICE_T, T_SEQ_T, T_SET_T, T_OPENTYPE,
     * T_SEQ_A, T_SET_A, T_CHOICE_A,  T_ARRAY, T_SIGNATURE, T_ANYTYPE */
    size_t get_nof_comps();

    /** Get the name (id) of the component with the given index.
     *
     * @pre \a typetype is one of T_CHOICE_T, T_SEQ_T, T_SET_T, T_OPENTYPE,
     * T_SEQ_A, T_SET_A, T_CHOICE_A, T_SIGNATURE, T_ANYTYPE
     *
     * @note Not valid for T_ARRAY */
    const Identifier& get_comp_id_byIndex(size_t n);

    /** Get the component with the given index.
     *
     * @pre \a typetype is one of T_CHOICE_T, T_SEQ_T, T_SET_T, T_OPENTYPE,
     * T_SEQ_A, T_SET_A, T_CHOICE_A, T_ANYTYPE
     *
     * @note Not valid for T_ARRAY or T_SIGNATURE */
    CompField* get_comp_byIndex(size_t n);

    /** Get the index of the component with the given name
     *
     * @pre \a typetype of the last referenced type is one of
     * T_CHOICE_T, T_SEQ_T, T_SET_T, T_OPENTYPE,
     * T_SEQ_A, T_SET_A, T_CHOICE_A, T_ANYTYPE */
    size_t get_comp_index_byName(const Identifier& p_name);

    /** Get the index of the enum item with the given name
     *
     * @pre typetype is T_ENUM_T or T_ENUM_A */
    size_t get_eis_index_byName(const Identifier& p_name);

    const Int& get_enum_val_byId(const Identifier& p_name);

    size_t get_nof_root_comps();
    CompField* get_root_comp_byIndex(size_t n);

    /** Get the name (id) of the component with the given index.
     *
     * @pre \a typetype is one of T_CHOICE_T, T_SEQ_T, T_SET_T, T_OPENTYPE,
     * T_SEQ_A, T_SET_A, T_CHOICE_A, T_SIGNATURE, T_ANYTYPE
     *
     * @note Not valid for T_ARRAY */
    bool has_comp_withName(const Identifier& p_name);
    CompField* get_comp_byName(const Identifier& p_name);
    void add_comp(CompField *p_cf);

    /** Returns the embedded type of 'sequence/record of', 'set of' or array
     * types. */
    Type *get_ofType();

    OC_defn* get_my_oc();
    const Identifier& get_oc_fieldname();
    void set_my_tableconstraint(const TableConstraint *p_tc);
    const TableConstraint* get_my_tableconstraint();

    /** Returns the array dimension. Applicable only if typetype == T_ARRAY. */
    Ttcn::ArrayDimension *get_dimension() const;

    /** Returns the PortTypeBody if typetype == T_PORT */
    Ttcn::PortTypeBody *get_PortBody() const;

    /** Returns the ComponentTypeBody if typetype == T_COMPONENT */
    ComponentTypeBody *get_CompBody() const;

    /** Returns the parameters of a signature.
     * Applicable only if typetype == T_SIGNATURE. */
    SignatureParamList *get_signature_parameters() const;
    /** Returns the parameters of a signature.
     * Applicable only if typetype == T_SIGNATURE. */
For faster browsing, not all history is shown. View entire blame