85e69998c10d43e891a9d9a2d9acb468cc7f1db6
[deliverable/titan.core.git] / compiler2 / ttcn3 / AST_ttcn3.hh
1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2000-2014 Ericsson Telecom AB
3 // All rights reserved. This program and the accompanying materials
4 // are made available under the terms of the Eclipse Public License v1.0
5 // which accompanies this distribution, and is available at
6 // http://www.eclipse.org/legal/epl-v10.html
7 ///////////////////////////////////////////////////////////////////////////////
8 #ifndef _Ttcn_AST_HH
9 #define _Ttcn_AST_HH
10
11 #include "../AST.hh"
12
13 namespace Common {
14 class CodeGenHelper;
15 }
16
17 /**
18 * This namespace contains classes unique to TTCN-3 and some specializations
19 * of classes from Common.
20 */
21 namespace Ttcn {
22
23 /**
24 * \addtogroup AST
25 *
26 * @{
27 */
28
29 using namespace Common;
30
31 class Module;
32 class Definition;
33 class FriendMod;
34 class Imports;
35 class ImpMod;
36 class ActualPar;
37 class ActualParList;
38 class FormalParList;
39 class ParsedActualParameters;
40 class Template;
41 class TemplateInstance;
42 class TemplateInstances;
43 class ArrayDimensions;
44 class Timer;
45 class StatementBlock;
46 class AltGuards;
47 class ILT;
48 class Group;
49 class WithAttribPath;
50 class ErrorBehaviorList;
51 class ErroneousAttributes;
52 class ErroneousAttributeSpec;
53 class PrintingType;
54
55 /** Class to represent an actual parameter */
56 class ActualPar : public Node {
57 public:
58 enum ap_selection_t {
59 AP_ERROR, ///< erroneous
60 AP_VALUE, ///< "in" value parameter
61 AP_TEMPLATE, ///< "in" template parameter
62 AP_REF, ///< out/inout value or template parameter
63 AP_DEFAULT ///< created from the default value of a formal parameter
64 };
65 private:
66 ap_selection_t selection;
67 union {
68 Value *val; ///< Value for AP_VALUE. Owned by ActualPar
69 TemplateInstance *temp; ///< %Template for AP_TEMPLATE. Owned by ActualPar
70 Ref_base *ref; ///< %Reference for AP_REF. Owned by ActualPar
71 ActualPar *act; ///< For AP_DEFAULT. \b Not owned by ActualPar
72 };
73 Scope *my_scope; ///< %Scope. Not owned
74 /** tells what runtime template restriction check to generate,
75 * TR_NONE means that no check is needed because it could be determined
76 * in compile time */
77 template_restriction_t gen_restriction_check;
78 /** if this is an actual template parameter of an external function add
79 * runtime checks for out and inout parameters after the call */
80 template_restriction_t gen_post_restriction_check;
81 private:
82 /** Copy constructor not implemented */
83 ActualPar(const ActualPar& p);
84 /** %Assignment disabled */
85 ActualPar& operator=(const ActualPar& p);
86 public:
87 /// Constructor for an erroneous object (fallback)
88 ActualPar()
89 : Node(), selection(AP_ERROR), my_scope(0),
90 gen_restriction_check(TR_NONE), gen_post_restriction_check(TR_NONE) {}
91 /// Actual par for an in value parameter
92 ActualPar(Value *v);
93 /// Actual par for an in template parameter
94 ActualPar(TemplateInstance *t);
95 /// Actual par for an {out or inout} {value or template} parameter
96 ActualPar(Ref_base *r);
97 /// Created from the default value of a formal par, at the call site,
98 ///
99 ActualPar(ActualPar *a);
100 virtual ~ActualPar();
101 virtual ActualPar *clone() const;
102 virtual void set_fullname(const string& p_fullname);
103 virtual void set_my_scope(Scope *p_scope);
104 bool is_erroneous() const { return selection == AP_ERROR; }
105 ap_selection_t get_selection() const { return selection; }
106 Value *get_Value() const;
107 TemplateInstance *get_TemplateInstance() const;
108 Ref_base *get_Ref() const;
109 ActualPar *get_ActualPar() const;
110 /** Checks the embedded recursions within the value or template instance. */
111 void chk_recursions(ReferenceChain& refch);
112 /** Returns whether the actual parameter can be represented by an in-line
113 * C++ expression. */
114 bool has_single_expr();
115 void set_code_section(GovernedSimple::code_section_t p_code_section);
116 /** Generates the C++ equivalent of \a this into \a expr.
117 * Flag \a copy_needed indicates whether to add an extra copy constructor
118 * call if \a this contains a referenced value or template to avoid
119 * aliasing problems with other out/inout parameters. */
120 void generate_code(expression_struct *expr, bool copy_needed, bool lazy_param=false, bool used_as_lvalue=false) const;
121 /** Appends the initialization sequence of all (directly or indirectly)
122 * referred non-parameterized templates to \a str and returns the resulting
123 * string. Flag \a is_local indicates whether the respective formal
124 * parameter is in the same module as \a this. It is considered only if
125 * \a selection is AP_DEFAULT. */
126 char *rearrange_init_code(char *str, bool is_local);
127 char *rearrange_init_code_defval(char *str);
128 /** Appends the string representation of the actual parameter to \a str. */
129 void append_stringRepr(string& str) const;
130 virtual void dump(unsigned level) const;
131 void set_gen_restriction_check(template_restriction_t tr)
132 { gen_restriction_check = tr; }
133 template_restriction_t get_gen_restriction_check()
134 { return gen_restriction_check; }
135 void set_gen_post_restriction_check(
136 template_restriction_t p_gen_post_restriction_check)
137 { gen_post_restriction_check = p_gen_post_restriction_check; }
138 };
139
140 /// A collection of actual parameters (parameter list)
141 class ActualParList : public Node {
142 vector<ActualPar> params;
143 public:
144 ActualParList(): Node(), params() { }
145 ActualParList(const ActualParList& p);
146 ~ActualParList();
147 ActualParList* clone() const;
148 virtual void set_fullname(const string& p_fullname);
149 virtual void set_my_scope(Scope *p_scope);
150 size_t get_nof_pars() const { return params.size(); }
151 void add(ActualPar* p) { params.add(p); }
152 ActualPar* get_par(size_t i) const { return params[i]; }
153 /** Checks the embedded recursions within the values and template
154 * instances of actual parameters. */
155 void chk_recursions(ReferenceChain& refch);
156 /** Generates the C++ equivalent of the actual parameter list without
157 * considering any aliasing between variables and 'in' parameters. */
158 void generate_code_noalias(expression_struct *expr, FormalParList *p_fpl);
159 /** Generates the C++ equivalent of the actual parameter list considering
160 * aliasing problems between the 'in' parameters and 'out'/'inout'
161 * parameters as well as component variables seen by the called definition.
162 * Argument \a p_fpl points to the formal parameter list of the referred
163 * definition if it is known, otherwise it is NULL. Argument \a p_comptype
164 * points to the component type identified by the 'runs on' clause of the
165 * referred definition (if exists and relevant for alias analysis,
166 * otherwise NULL).
167 * When invoke() is used with FAT types: the special case of 'runs on self'
168 * has the argument \a p_compself set to true and \a p_comptype is NULL,
169 * but the component is 'self' or any compatible component. */
170 void generate_code_alias(expression_struct *expr, FormalParList *p_fpl,
171 Type *p_comptype, bool p_compself);
172 /** Walks through the parameter list and appends the initialization
173 * sequence of all (directly or indirectly) referred non-parameterized
174 * templates to \a str and returns the resulting string. Flag \a is_local
175 * indicates whether the respective formal parameter list is in the same
176 * module as \a this. */
177 char *rearrange_init_code(char *str, bool is_local);
178 virtual void dump(unsigned level) const;
179 };
180
181 /** Helper class for the Ttcn::Reference */
182 class FieldOrArrayRef : public Node, public Location {
183 public:
184 enum reftype { FIELD_REF, ARRAY_REF };
185 private:
186 reftype ref_type; ///< reference type
187 /** The stored reference. Owned and destroyed by FieldOrArrayRef */
188 union {
189 Identifier *id; ///< name of the field, used by FIELD_REF
190 Value *arp; ///< value of the index, used by ARRAY_REF
191 } u;
192 /** Copy constructor for clone() only */
193 FieldOrArrayRef(const FieldOrArrayRef& p);
194 /** %Assignment disabled */
195 FieldOrArrayRef& operator=(const FieldOrArrayRef& p);
196 public:
197 FieldOrArrayRef(Identifier *p_id);
198 FieldOrArrayRef(Value *p_arp);
199 ~FieldOrArrayRef();
200 virtual FieldOrArrayRef* clone() const;
201 virtual void set_fullname(const string& p_fullname);
202 virtual void set_my_scope(Scope *p_scope);
203 reftype get_type() const { return ref_type; }
204 /** Return the identifier.
205 * @pre reftype is FIELD_REF, or else FATAL_ERROR */
206 const Identifier* get_id() const;
207 /** Returns the value.
208 * @pre reftype is ARRAY_REF, or else FATAL_ERROR */
209 Value* get_val() const;
210 /** Appends the string representation of the sub-reference to \a str. */
211 void append_stringRepr(string& str) const;
212 };
213
214 /** A vector of FieldOrArrayRef objects */
215 class FieldOrArrayRefs : public Node {
216 /** Element holder. This FieldOrArrayRefs object owns the elements
217 * and will free them in the destructor. */
218 vector<FieldOrArrayRef> refs;
219 /** Indicates whether the last array index refers to an element of a
220 * string value. */
221 bool refs_str_element;
222 public:
223 FieldOrArrayRefs() : Node(), refs(), refs_str_element(false) { }
224 FieldOrArrayRefs(const FieldOrArrayRefs& p);
225 ~FieldOrArrayRefs();
226 FieldOrArrayRefs *clone() const;
227 virtual void set_fullname(const string& p_fullname);
228 virtual void set_my_scope(Scope *p_scope);
229 void add(FieldOrArrayRef *p_ref) { refs.add(p_ref); }
230 size_t get_nof_refs() const { return refs.size(); }
231 FieldOrArrayRef* get_ref(size_t i) const { return refs[i]; }
232 bool has_unfoldable_index() const;
233 /** Removes (deletes) the first \a n field references. */
234 void remove_refs(size_t n);
235 Identifier *remove_last_field();
236 /** Generates the C++ sub-expression that accesses
237 * the given sub-references of definition \a ass.
238 * @param nof_subrefs indicates the number of sub-references
239 * to generate code from (UINT_MAX means all of them) */
240 void generate_code(expression_struct *expr, Common::Assignment *ass, size_t nof_subrefs = UINT_MAX);
241 /** Appends the string representation of sub-references to \a str. */
242 void append_stringRepr(string &str) const;
243 bool refers_to_string_element() const { return refs_str_element; }
244 void set_string_element_ref() { refs_str_element = true; }
245 void clear_string_element_ref() { refs_str_element = false; }
246 };
247
248 /**
249 * Base class for all TTCN-3 references.
250 * Includes the common functionality for parameterized and non-parameterized
251 * references (e.g. handling of field or array subreferences).
252 */
253 class Ref_base : public Ref_simple {
254 protected: // Ttcn::Reference and Ttcn::Ref_pard need access
255 Identifier *modid;
256 /** If id is a NULL pointer all components are stored in subrefs */
257 Identifier *id;
258 FieldOrArrayRefs subrefs;
259 /** Indicates whether the consistency of formal and actual parameter lists
260 * has been verified. */
261 bool params_checked;
262 bool usedInIsbound;
263 Ref_base(const Ref_base& p);
264 private:
265 Ref_base& operator=(const Ref_base& p);
266 public:
267 /** Default constructor: sets \a modid and \a id to NULL. Used by
268 * non-parameterized references only. It is automatically guessed whether
269 * the first component of \a subrefs is a module id or not. */
270 Ref_base() : Ref_simple(), modid(0), id(0), subrefs(), params_checked(0)
271 , usedInIsbound(false) {}
272 Ref_base(Identifier *p_modid, Identifier *p_id);
273 ~Ref_base();
274 virtual Ref_base *clone() const = 0;
275 virtual void set_fullname(const string& p_fullname);
276 virtual void set_my_scope(Scope *p_scope);
277 /** Sets the scope of the base reference to \a p_scope.
278 * The scope of array indices in \a subrefs remains unchanged. */
279 void set_base_scope(Scope *p_scope) { Ref_simple::set_my_scope(p_scope); }
280 virtual bool getUsedInIsbound() {return usedInIsbound;}
281 virtual void setUsedInIsbound() {usedInIsbound = true;}
282 Setting *get_refd_setting();
283 FieldOrArrayRefs *get_subrefs();
284 /** Appends \a p_ref to the sub-references */
285 void add(FieldOrArrayRef *p_ref) { subrefs.add(p_ref); }
286 virtual bool has_single_expr();
287 virtual void set_code_section(
288 GovernedSimple::code_section_t p_code_section);
289 /** Generates the C++ equivalent of the reference (including the parameter
290 * list and sub-references) as an access to a constant resource.
291 */
292 virtual void generate_code_const_ref(expression_struct_t *expr);
293 };
294
295 /**
296 * TTCN-3 reference without parameters.
297 * Implements the automatic detection whether the first identifier is a
298 * module name or not.
299 */
300 class Reference : public Ref_base {
301 ActualParList *parlist;
302 public:
303 Reference(Identifier *p_id);
304 Reference(Identifier *p_modid, Identifier *p_id)
305 : Ref_base(p_modid, p_id), parlist(0) { }
306 ~Reference();
307 virtual Reference *clone() const;
308 virtual string get_dispname();
309 virtual Common::Assignment *get_refd_assignment(bool check_parlist = true);
310 virtual const Identifier* get_modid();
311 virtual const Identifier* get_id();
312 /** Checks whether \a this points to a variable or value parameter.
313 * Returns the type of the respective variable or variable field or NULL
314 * in case of error. */
315 Type *chk_variable_ref();
316 /** Checks if \a this points to a component.
317 * Returns the type of the component if so or NULL in case of error. */
318 Type *chk_comptype_ref();
319 virtual bool has_single_expr();
320 virtual void generate_code(expression_struct_t *expr);
321 /** Generates the C++ equivalent of port references within
322 * connect/disconnect/map/unmap statements into \a expr.
323 * Argument \a p_scope shall point to the scope of the statement. */
324 void generate_code_portref(expression_struct_t *expr, Scope *p_scope);
325 virtual void generate_code_const_ref(expression_struct_t *expr);
326 /**
327 * Generates code for checking if the reference
328 * and the referred objects are bound or not.*/
329 void generate_code_ispresentbound(expression_struct_t *expr,
330 bool is_template, const bool isbound);
331 private:
332 /** Detects whether the first identifier in subrefs is a module id */
333 void detect_modid();
334 };
335
336 /**
337 * Parameterized TTCN-3 reference
338 */
339 class Ref_pard : public Ref_base {
340 /** "Processed" parameter list, after the semantic check. */
341 ActualParList parlist;
342 /** "Raw" parameter list, before the semantic check. */
343 Ttcn::ParsedActualParameters *params;
344 /** Used by generate_code_cached(). Stores the generated expression string,
345 * so it doesn't get regenerated every time. */
346 char* expr_cache;
347 /** Copy constructor. Private, used by Ref_pard::clone() only */
348 Ref_pard(const Ref_pard& p);
349 /// %Assignment disabled
350 Ref_pard& operator=(const Ref_pard& p);
351 public:
352 /** Constructor
353 * \param p_modid the module in which it resides
354 * \param p_id the identifier
355 * \param p_params parameters. For a function, this is the list constructed
356 * for the actual parameters.
357 * */
358 Ref_pard(Identifier *p_modid, Identifier *p_id,
359 ParsedActualParameters *p_params);
360 ~Ref_pard();
361 virtual Ref_pard *clone() const;
362 virtual void set_fullname(const string& p_fullname);
363 virtual void set_my_scope(Scope *p_scope);
364 string get_dispname();
365 virtual Common::Assignment *get_refd_assignment(bool check_parlist = true);
366 virtual const Identifier *get_modid();
367 virtual const Identifier *get_id();
368 virtual ActualParList *get_parlist();
369 /** Checks whether \a this is a correct argument of an activate operation
370 * or statement. The reference shall point to an altstep with proper
371 * `runs on' clause and the actual parameters that are passed by reference
372 * shall not point to local definitions. The function returns true if the
373 * altstep reference is correct and false in case of any error. */
374 bool chk_activate_argument();
375 virtual bool has_single_expr();
376 virtual void set_code_section(
377 GovernedSimple::code_section_t p_code_section);
378 virtual void generate_code (expression_struct_t *expr);
379 virtual void generate_code_const_ref(expression_struct_t *expr);
380
381 /** Used when an 'all from' is called on a function or parametrised template,
382 * generate_code would generate new temporaries for the function's parameters
383 * each call. This method makes sure the same temporaries are used every time
384 * the function is called in the generated code.
385 * On the first run calls generate_code and stores its result (only expr.expr
386 * is cached, since the preamble is only needed after the first call).
387 * On further runs the cached expression is returned.*/
388 virtual void generate_code_cached (expression_struct_t *expr);
389 };
390
391 /**
392 * Class Ttcn::NameBridgingScope.
393 * This scope unit is NOT A REAL SCOPE UNIT,
394 * its only purpose is to serve as a bridge with a name between two real scope
395 * units. All operations are transfered automatically.
396 */
397 class NameBridgingScope : public Scope {
398 virtual string get_scopeMacro_name() const;
399 virtual NameBridgingScope* clone() const;
400 virtual Common::Assignment* get_ass_bySRef(Ref_simple *p_ref);
401 };
402
403 /**
404 * Class Ttcn::RunsOnScope.
405 * Implements the scoping rules for functions, altsteps and testcases that
406 * have a 'runs on' clause. First looks for the definitions in the given
407 * component type first then it searches in its parent scope.
408 * Note: This scope unit cannot access the parent scope of the component type
409 * (which is a module Definitions) unless the component type and the
410 * 'runs on' clause is defined in the same module.
411 */
412 class RunsOnScope : public Scope {
413 /** Points to the component type. */
414 Type *component_type;
415 /** Shortcut to the definitions within \a component_type. */
416 ComponentTypeBody *component_defs;
417
418 /** Not implemented. Causes \a FATAL_ERROR. */
419 RunsOnScope(const RunsOnScope& p);
420 /** %Assignment not implemented */
421 RunsOnScope& operator=(const RunsOnScope& p);
422 public:
423 RunsOnScope(Type *p_comptype);
424 virtual RunsOnScope *clone() const;
425
426 Type *get_component_type() const { return component_type; }
427 /** Checks the uniqueness of definitions within \a component_defs and
428 * reports warnings in case of hiding. */
429 void chk_uniq();
430
431 virtual RunsOnScope *get_scope_runs_on();
432 virtual Common::Assignment *get_ass_bySRef(Ref_simple *p_ref);
433 virtual bool has_ass_withId(const Identifier& p_id);
434 };
435
436 /**
437 * Class Ttcn::Definitions.
438 *
439 * Owns the contained Definition objects.
440 */
441 class Definitions : public Common::Assignments {
442 protected:
443 /** Searchable map of definitions. Used after chk_uniq. */
444 map<string, Definition> ass_m;
445 /** Indicates whether the uniqueness of identifiers has been checked. */
446 bool checked;
447 /** Vector containing all definitions. Used for building. */
448 vector<Definition> ass_v;
449
450 Definitions(const Definitions& p);
451 public:
452
453 Definitions() : Common::Assignments(), ass_m(), checked(false), ass_v() {}
454 ~Definitions();
455 Definitions *clone() const;
456 virtual void set_fullname(const string& p_fullname);
457 /** Adds the assignment p_ass and becomes the owner of it.
458 * The uniqueness of the identifier is not checked. */
459 void add_ass(Definition *p_ass);
460 virtual bool has_local_ass_withId(const Identifier& p_id);
461 virtual Common::Assignment* get_local_ass_byId(const Identifier& p_id);
462 virtual size_t get_nof_asss();
463 virtual Common::Assignment* get_ass_byIndex(size_t p_i);
464 size_t get_nof_raw_asss();
465 Definition *get_raw_ass_byIndex(size_t p_i);
466 /** Checks the uniqueness of identifiers. */
467 void chk_uniq();
468 /** Checks all definitions. */
469 void chk();
470 /** Checks the definitions within the header of a for loop. */
471 void chk_for();
472 /** Sets the genname of embedded definitions using \a prefix. */
473 void set_genname(const string& prefix);
474 /** Generates code for all assignments into \a target. */
475 void generate_code(output_struct *target);
476 void generate_code(CodeGenHelper& cgh);
477 char* generate_code_str(char *str);
478 void ilt_generate_code(ILT *ilt);
479 /** Prints the contents of all assignments. */
480 virtual void dump(unsigned level) const;
481 };
482
483 /**
484 * Class Ttcn::Definitions.
485 *
486 * Owns the contained Definition objects.
487 */
488 /* class Definitions : public OtherDefinitions {
489 public:
490 Definitions() : OtherDefinitions() {}
491 ~Definitions();
492 Definitions *clone() const;
493 void add_ass(Definition *p_ass);
494 };*/
495
496 /** Represents a TTCN-3 group
497 *
498 * @note a Group is not a Scope */
499 class Group : public Node, public Location {
500 private:
501 Group* parent_group;
502 WithAttribPath* w_attrib_path;
503 /// Definitions that belong to this group (directly)
504 vector<Definition> ass_v;
505 /// Map the name to the definition (filled in chk_uniq)
506 map<string,Definition> ass_m;
507 /// Subgroups
508 vector<Group> group_v;
509 /// Map the name to the subgroup
510 map<string,Group> group_m;
511 vector<ImpMod> impmods_v;
512 vector<FriendMod> friendmods_v;
513 Identifier *id;
514 bool checked;
515 private:
516 /** Copy constructor not implemented */
517 Group(const Group& p);
518 /** %Assignment not implemented */
519 Group& operator=(const Group& p);
520 public:
521 Group(Identifier *p_id);
522 ~Group();
523 virtual Group* clone() const;
524 virtual void set_fullname(const string& p_fullname);
525 void add_ass(Definition* p_ass);
526 void add_group(Group* p_group);
527 void set_parent_group(Group* p_parent_group);
528 Group* get_parent_group() const { return parent_group; }
529 void set_attrib_path(WithAttribPath* p_path);
530 const Identifier& get_id() const { return *id; }
531 void chk_uniq();
532 virtual void chk();
533 void add_impmod(ImpMod *p_impmod);
534 void add_friendmod(FriendMod *p_friendmod);
535 virtual void dump(unsigned level) const;
536 void set_with_attr(MultiWithAttrib* p_attrib);
537 WithAttribPath* get_attrib_path();
538 void set_parent_path(WithAttribPath* p_path);
539 };
540
541 class ControlPart : public Node, public Location {
542 private:
543 StatementBlock* block;
544 WithAttribPath* w_attrib_path;
545
546 NameBridgingScope bridgeScope;
547
548 /// Copy constructor disabled
549 ControlPart(const ControlPart& p);
550 /// %Assignment disabled
551 ControlPart& operator=(const ControlPart& p);
552 public:
553 ControlPart(StatementBlock* p_block);
554 ~ControlPart();
555 virtual ControlPart* clone() const;
556 virtual void set_fullname(const string& p_fullname);
557 virtual void set_my_scope(Scope *p_scope);
558 void chk();
559 void generate_code(output_struct *target, Module *my_module);
560 void set_with_attr(MultiWithAttrib* p_attrib);
561 WithAttribPath* get_attrib_path();
562 void set_parent_path(WithAttribPath* p_path);
563 void dump(unsigned level) const;
564 };
565
566 /** A TTCN-3 module */
567 class Module : public Common::Module {
568 private:
569 string *language_spec;
570 Definitions *asss;
571 vector<Group> group_v;
572 map<string, Group> group_m;
573 WithAttribPath* w_attrib_path;
574 Imports *imp;
575 ControlPart* controlpart;
576 /** For caching the scope objects that are created in
577 * \a get_runs_on_scope(). */
578 vector<RunsOnScope> runs_on_scopes;
579 private:
580 /** Copy constructor not implemented */
581 Module(const Module& p);
582 /** %Assignment not implemented */
583 Module& operator=(const Module& p);
584 public:
585 vector<FriendMod> friendmods_v;
586 Module(Identifier *p_modid);
587 ~Module();
588 void add_group(Group* p_group);
589 void add_friendmod(FriendMod *p_friendmod);
590 virtual Module* clone() const;
591 virtual Common::Assignment* importAssignment(
592 const Identifier& p_source_modid, const Identifier& p_id) const;
593 virtual void set_fullname(const string& p_fullname);
594 virtual Common::Assignments* get_scope_asss();
595 virtual bool has_imported_ass_withId(const Identifier& p_id);
596 virtual Common::Assignment* get_ass_bySRef(Ref_simple *p_ref);
597 virtual bool is_valid_moduleid(const Identifier& p_id);
598 virtual Common::Assignments *get_asss();
599 virtual bool exports_sym(const Identifier& p_id);
600 virtual Type *get_address_type();
601 virtual void chk_imp(ReferenceChain& refch, vector<Common::Module>& moduleStack);
602 virtual void chk();
603 private:
604 void chk_friends();
605 void chk_groups();
606 virtual void get_imported_mods(module_set_t& p_imported_mods);
607 virtual void generate_code_internal(CodeGenHelper& cgh);
608 public:
609 /** Returns a scope that can access the definitions within component type
610 * \a comptype (which is imported from another module) and its parent scope
611 * is \a asss. Note that this scope cannot see the scope of \a comptype.
612 * The function uses \a runs_on_scopes for caching the scope objects: if an
613 * object has been created for a component type it will be returned later
614 * instead of creating a new one. */
615 RunsOnScope *get_runs_on_scope(Type *comptype);
616 virtual void dump(unsigned level) const;
617 void set_language_spec(const char *p_language_spec);
618 void add_ass(Definition* p_ass);
619 void add_impmod(ImpMod *p_impmod);
620 void add_controlpart(ControlPart* p_controlpart);
621 void set_with_attr(MultiWithAttrib* p_attrib);
622 WithAttribPath* get_attrib_path();
623 void set_parent_path(WithAttribPath* p_path);
624 const Imports& get_imports() const { return *imp; }
625
626 bool is_visible(const Identifier& id, visibility_t visibility);
627
628 /** Generates JSON schema segments for the types defined in the module
629 * and adds them to the JSON schema parameter. */
630 void add_types_to_json_schema(JSON_Tokenizer& json);
631
632 /** Generates JSON schemas containing references to the types that have JSON
633 * encoding and/or decoding functions declared in the module. Information
634 * related to these functions is also inserted after the references. */
635 void add_func_to_json_schema(map<Type*, JSON_Tokenizer>& json_refs);
636 };
637
638 /**
639 * Module friendship declaration.
640 */
641 class FriendMod : public Node, public Location {
642 private:
643 Module *my_mod;
644 Identifier *modid;
645 WithAttribPath* w_attrib_path;
646 Group* parentgroup;
647 /** Indicates whether this friend module declaration was checked */
648 bool checked;
649 private:
650 /** Copy constructor not implemented. */
651 FriendMod(const FriendMod&);
652 /** %Assignment not implemented. */
653 FriendMod& operator=(const FriendMod&);
654 public:
655 FriendMod(Identifier *p_modid);
656 ~FriendMod();
657 virtual FriendMod* clone() const;
658 virtual void set_fullname(const string& p_fullname);
659 virtual void chk();
660 void set_my_mod(Module *p_mod) { my_mod = p_mod; }
661 const Identifier& get_modid() const {return *modid;}
662 void set_with_attr(MultiWithAttrib* p_attrib);
663 WithAttribPath* get_attrib_path();
664 void set_parent_path(WithAttribPath* p_path);
665 void set_parent_group(Group* p_group);
666 };
667
668
669 /**
670 * Imported module. Represents an import statement.
671 */
672 class ImpMod : public Node, public Location {
673 public:
674 enum imptype_t {
675 I_UNDEF,
676 I_ERROR,
677 I_ALL,
678 I_IMPORTSPEC,
679 I_IMPORTIMPORT
680 };
681 private:
682 /** Points to the target (imported) module. This is initially NULL;
683 * set during semantic analysis by Ttcn::Imports::chk_uniq() */
684 Common::Module *mod;
685 /** The importing module (indirectly our owner) */
686 Module *my_mod;
687 /** Import type: "import all", selective import, import of import, etc. */
688 imptype_t imptype;
689 /** The name given in the import statement;
690 * hopefully an actual module name */
691 Identifier *modid;
692 /** The text after "import from name language" */
693 string *language_spec;
694 /** Recursive import (already deprecated in v3.2.1) */
695 bool is_recursive;
696 WithAttribPath* w_attrib_path;
697 /** Group in which the import statement is located, if any */
698 Group* parentgroup;
699 visibility_t visibility;
700 private:
701 /** Copy constructor not implemented. */
702 ImpMod(const ImpMod&);
703 /** %Assignment not implemented */
704 ImpMod& operator=(const ImpMod&);
705 public:
706 ImpMod(Identifier *p_modid);
707 ~ImpMod();
708 virtual ImpMod* clone() const;
709 virtual void set_fullname(const string& p_fullname);
710 virtual void chk();
711 /** Checks the existence of imported symbols and checks import definitions
712 * in the imported modules recursively. */
713 void chk_imp(ReferenceChain& refch, vector<Common::Module>& moduleStack);
714 void set_my_mod(Module *p_mod) { my_mod = p_mod; }
715 const Identifier& get_modid() const {return *modid;}
716 void set_mod(Common::Module *p_mod) { mod = p_mod; }
717 Common::Module *get_mod() const { return mod; }
718 /** Returns the imported definition with name \a p_id if it is imported or
719 * NULL otherwise.
720 * \a loc is used to report an error if it is needed */
721 Common::Assignment *get_imported_def(const Identifier& p_source_modid,
722 const Identifier& p_id, const Location *loc,
723 ReferenceChain* refch, vector<ImpMod>& usedImpMods) const;
724 bool has_imported_def(const Identifier& p_source_modid,
725 const Identifier& p_id, const Location *loc) const;
726 void set_imptype(imptype_t p_imptype) { imptype = p_imptype; }
727 void set_language_spec(const char *p_language_spec);
728 void set_recursive() { is_recursive = true; }
729 void generate_code(output_struct *target);
730 virtual void dump(unsigned level) const;
731 void set_with_attr(MultiWithAttrib* p_attrib);
732 WithAttribPath* get_attrib_path();
733 void set_parent_path(WithAttribPath* p_path);
734 void set_parent_group(Group* p_group);
735 imptype_t get_imptype() {
736 return imptype;
737 }
738 void set_visibility(visibility_t p_visibility){
739 visibility = p_visibility;
740 }
741 visibility_t get_visibility() const{
742 return visibility;
743 }
744 };
745
746 /**
747 * Class Imports.
748 */
749 class Imports : public Node {
750 private:
751 /** my module */
752 Module *my_mod;
753 /** imported modules */
754 vector<ImpMod> impmods_v;
755 /** Indicates whether the import list has been checked. */
756 bool checked;
757
758 friend class ImpMod;
759 private:
760 /** Copy constructor not implemented. */
761 Imports(const Imports&);
762 /** %Assignment not implemented */
763 Imports& operator=(const Imports&);
764 public:
765 Imports() : Node(), my_mod(0), impmods_v(), checked(false) {}
766 virtual ~Imports();
767 virtual Imports* clone() const;
768 void add_impmod(ImpMod *p_impmod);
769 void set_my_mod(Module *p_mod);
770 int get_imports_size() const {return impmods_v.size();}
771 ImpMod* get_impmod(int index) const {return impmods_v[index];}
772 /** Checks the existence of imported modules and detects duplicated imports
773 * from the same module. Initializes \a impmods_m. */
774 void chk_uniq();
775 /** Checks the existence of imported symbols and checks import definitions
776 * in the imported modules recursively. */
777 void chk_imp(ReferenceChain& refch, vector<Common::Module>& moduleStack);
778 /** Returns \p true if an imported module with the given name exists,
779 * else returns \p false. */
780 bool has_impmod_withId(const Identifier& p_id) const;
781 /** Returns whether a definition with identifier \a p_id is imported
782 * from one or more modules */
783 bool has_imported_def(const Identifier& p_id, const Location *loc) const;
784 /** Returns the imported definition with name \a p_id if it is
785 * unambiguous or NULL otherwise.
786 * \a loc is used to report an error if it is needed */
787 Common::Assignment *get_imported_def(const Identifier& p_source_modid,
788 const Identifier& p_id, const Location *loc, ReferenceChain* refch);
789 void get_imported_mods(Module::module_set_t& p_imported_mods) const;
790 void generate_code(output_struct *target);
791 void generate_code(CodeGenHelper& cgh);
792 virtual void dump(unsigned level) const;
793 };
794
795 class Definition : public Common::Assignment {
796 protected: // many derived classes
797 /** Contains the C++ identifier of the definition. If empty the C++
798 * identifier is generated from \a id. */
799 string genname;
800 /** The group it's in, if any */
801 Group *parentgroup;
802 WithAttribPath* w_attrib_path;
803 ErroneousAttributes* erroneous_attrs; // set by chk_erroneous_attr() or NULL
804 /** True if function/altstep/default scope, not module scope */
805 bool local_scope;
806
807 Definition(const Definition& p)
808 : Common::Assignment(p), genname(), parentgroup(0),
809 w_attrib_path(0), erroneous_attrs(0), local_scope(false)
810 { }
811 virtual string get_genname() const;
812
813 namedbool has_implicit_omit_attr() const;
814 private:
815 /// %Assignment disabled
816 Definition& operator=(const Definition& p);
817 public:
818 Definition(asstype_t p_asstype, Identifier *p_id)
819 : Common::Assignment(p_asstype, p_id), genname(), parentgroup(0),
820 w_attrib_path(0), erroneous_attrs(0), local_scope(false)
821 { }
822 virtual ~Definition();
823 virtual Definition* clone() const = 0;
824 virtual void set_fullname(const string& p_fullname);
825 virtual bool is_local() const;
826 /** Sets the visibility type of the definition */
827 void set_visibility(const visibility_t p_visibility)
828 { visibilitytype = p_visibility; }
829 /** Marks the (template) definition as local to a func/altstep/default */
830 inline void set_local() { local_scope = true; }
831
832 void set_genname(const string& p_genname) { genname = p_genname; }
833 /** Check if two definitions are (almost) identical, the type and dimensions
834 * must always be identical, the initial values can be different depending
835 * on the definition type. If error was reported the return value is false.
836 * The initial values (if applicable) may be present/absent, different or
837 * unfoldable. The function must be overridden to be used.
838 */
839 virtual bool chk_identical(Definition *p_def);
840 /** Parse and check the erroneous attribute data,
841 * sets erroneous_attrs member */
842 void chk_erroneous_attr();
843 /** This code generation is used when this definition is embedded
844 * in a statement block. */
845 virtual char* generate_code_str(char *str);
846 virtual void ilt_generate_code(ILT *ilt);
847 /** Generates the C++ initializer sequence for a definition of a component
848 * type, appends to \a str and returns the resulting string. The function
849 * is used when \a this is realized using the C++ objects of definition
850 * \a base_defn inherited from another component type. The function is
851 * implemented only for those definitions that can appear within component
852 * types, the generic version causes \a FATAL_ERROR. */
853 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
854 virtual void dump_internal(unsigned level) const;
855 virtual void dump(unsigned level) const;
856 virtual void set_with_attr(MultiWithAttrib* p_attrib);
857 virtual WithAttribPath* get_attrib_path();
858 virtual void set_parent_path(WithAttribPath* p_path);
859 virtual void set_parent_group(Group* p_group);
860 virtual Group* get_parent_group();
861 };
862
863 /**
864 * TTCN-3 type definition (including signatures and port types).
865 */
866 class Def_Type : public Definition {
867 private:
868 Type *type;
869
870 NameBridgingScope bridgeScope;
871
872 /** Copy constructor not implemented */
873 Def_Type(const Def_Type& p);
874 /** %Assignment disabled */
875 Def_Type& operator=(const Def_Type& p);
876 public:
877 Def_Type(Identifier *p_id, Type *p_type);
878 virtual ~Def_Type();
879 virtual Def_Type* clone() const;
880 virtual void set_fullname(const string& p_fullname);
881 virtual void set_my_scope(Scope *p_scope);
882 virtual Setting *get_Setting();
883 virtual Type *get_Type();
884 virtual void chk();
885 virtual void generate_code(output_struct *target, bool clean_up = false);
886 virtual void generate_code(CodeGenHelper& cgh);
887 virtual void dump_internal(unsigned level) const;
888 virtual void set_with_attr(MultiWithAttrib* p_attrib);
889 virtual WithAttribPath* get_attrib_path();
890 virtual void set_parent_path(WithAttribPath* p_path);
891
892 /** Generates a JSON schema segment for the defined type and inserts it into
893 * the JSON schema parameter. */
894 void generate_json_schema(JSON_Tokenizer& json);
895 };
896
897 /**
898 * TTCN-3 constant definition.
899 */
900 class Def_Const : public Definition {
901 private:
902 Type *type;
903 Value *value;
904 bool value_under_check;
905
906 /// Copy constructor disabled
907 Def_Const(const Def_Const& p);
908 /// %Assignment disabled
909 Def_Const& operator=(const Def_Const& p);
910 public:
911 Def_Const(Identifier *p_id, Type *p_type, Value *p_value);
912 virtual ~Def_Const();
913 virtual Def_Const *clone() const;
914 virtual void set_fullname(const string& p_fullname);
915 virtual void set_my_scope(Scope *p_scope);
916 virtual Setting *get_Setting();
917 virtual Type *get_Type();
918 virtual Value *get_Value();
919 virtual void chk();
920 virtual bool chk_identical(Definition *p_def);
921 virtual void generate_code(output_struct *target, bool clean_up = false);
922 virtual void generate_code(CodeGenHelper& cgh);
923 virtual char* generate_code_str(char *str);
924 virtual void ilt_generate_code(ILT *ilt);
925 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
926 virtual void dump_internal(unsigned level) const;
927 };
928
929 /**
930 * TTCN-3 external constant definition.
931 */
932 class Def_ExtConst : public Definition {
933 private:
934 Type *type;
935
936 /// Copy constructor disabled
937 Def_ExtConst(const Def_ExtConst& p);
938 /// %Assignment disabled
939 Def_ExtConst& operator=(const Def_ExtConst& p);
940 public:
941 Def_ExtConst(Identifier *p_id, Type *p_type);
942 virtual ~Def_ExtConst();
943 virtual Def_ExtConst *clone() const;
944 virtual void set_fullname(const string& p_fullname);
945 virtual void set_my_scope(Scope *p_scope);
946 virtual Type *get_Type();
947 virtual void chk();
948 virtual void generate_code(output_struct *target, bool clean_up = false);
949 virtual void generate_code(CodeGenHelper& cgh);
950 virtual void dump_internal(unsigned level) const;
951 };
952
953 /**
954 * TTCN-3 module parameter definition.
955 */
956 class Def_Modulepar : public Definition {
957 private:
958 Type *type;
959 Value* def_value;
960 /// Copy constructor disabled
961 Def_Modulepar(const Def_Modulepar& p);
962 /// %Assignment disabled
963 Def_Modulepar& operator=(const Def_Modulepar& p);
964 public:
965 Def_Modulepar(Identifier *p_id, Type *p_type, Value *p_defval);
966 virtual ~Def_Modulepar();
967 virtual Def_Modulepar* clone() const;
968 virtual void set_fullname(const string& p_fullname);
969 virtual void set_my_scope(Scope *p_scope);
970 virtual Type *get_Type();
971 virtual void chk();
972 virtual void generate_code(output_struct *target, bool clean_up = false);
973 virtual void generate_code(CodeGenHelper& cgh);
974 virtual void dump_internal(unsigned level) const;
975 };
976
977 /**
978 * TTCN-3 template module parameter definition.
979 */
980 class Def_Modulepar_Template : public Definition {
981 private:
982 Type *type;
983 Template* def_template;
984 /// Copy constructor disabled
985 Def_Modulepar_Template(const Def_Modulepar_Template& p);
986 /// %Assignment disabled
987 Def_Modulepar_Template& operator=(const Def_Modulepar_Template& p);
988 public:
989 Def_Modulepar_Template(Identifier *p_id, Type *p_type, Template *p_defval);
990 virtual ~Def_Modulepar_Template();
991 virtual Def_Modulepar_Template* clone() const;
992 virtual void set_fullname(const string& p_fullname);
993 virtual void set_my_scope(Scope *p_scope);
994 virtual Type *get_Type();
995 virtual void chk();
996 virtual void generate_code(output_struct *target, bool clean_up = false);
997 virtual void generate_code(CodeGenHelper& cgh);
998 virtual void dump_internal(unsigned level) const;
999 };
1000
1001 /**
1002 * Def_Template class represents a template definition.
1003 */
1004 class Def_Template : public Definition {
1005 private:
1006 /* the type of the template */
1007 Type *type;
1008 /** The formal parameter list of the template. It is NULL in case of
1009 * non-parameterized templates. */
1010 FormalParList *fp_list;
1011 /** points to the base template reference in case of modified templates,
1012 * otherwise it is NULL */
1013 Reference *derived_ref;
1014 /** shortcut to the base template in case of modified templates,
1015 * otherwise it is NULL */
1016 Def_Template *base_template;
1017 /** Indicates whether the circular recursion chain of modified templates
1018 * has been checked. */
1019 bool recurs_deriv_checked;
1020 /** the body of the template */
1021 Template *body;
1022 /** template definition level restriction */
1023 template_restriction_t template_restriction;
1024 /** set in chk(), used by code generation,
1025 * valid if template_restriction!=TR_NONE */
1026 bool gen_restriction_check;
1027
1028 NameBridgingScope bridgeScope;
1029
1030 /// Copy constructor for Def_Template::clone() only
1031 Def_Template(const Def_Template& p);
1032 /// %Assignment disabled
1033 Def_Template& operator=(const Def_Template& p);
1034 public:
1035 Def_Template(template_restriction_t p_template_restriction,
1036 Identifier *p_id, Type *p_type, FormalParList *p_fpl,
1037 Reference *p_derived_ref, Template *p_body);
1038 virtual ~Def_Template();
1039 virtual Def_Template *clone() const;
1040 virtual void set_fullname(const string& p_fullname);
1041 virtual void set_my_scope(Scope *p_scope);
1042 virtual Setting *get_Setting();
1043 virtual Type *get_Type();
1044 virtual Template *get_Template();
1045 virtual FormalParList *get_FormalParList();
1046 virtual void chk();
1047 private:
1048 void chk_modified();
1049 void chk_default() const;
1050 void chk_recursive_derivation();
1051 public:
1052 virtual void generate_code(output_struct *target, bool clean_up = false);
1053 virtual void generate_code(CodeGenHelper& cgh);
1054 virtual char* generate_code_str(char *str);
1055 virtual void ilt_generate_code(ILT *ilt);
1056 virtual void dump_internal(unsigned level) const;
1057 template_restriction_t get_template_restriction()
1058 { return template_restriction; }
1059 };
1060
1061 /**
1062 * Def_Var class represents a variable definition.
1063 */
1064 class Def_Var : public Definition {
1065 private:
1066 Type *type;
1067 /** the initial value: optional and maybe incomplete */
1068 Value *initial_value;
1069
1070 /// Copy constructor disabled
1071 Def_Var(const Def_Var& p);
1072 /// %Assignment disabled
1073 Def_Var& operator=(const Def_Var& p);
1074 public:
1075 Def_Var(Identifier *p_id, Type *p_type, Value *p_initial_value);
1076 virtual ~Def_Var();
1077 virtual Def_Var *clone() const;
1078 virtual void set_fullname(const string& p_fullname);
1079 virtual void set_my_scope(Scope *p_scope);
1080 virtual Type *get_Type();
1081 virtual void chk();
1082 virtual bool chk_identical(Definition *p_def);
1083 virtual void generate_code(output_struct *target, bool clean_up = false);
1084 virtual void generate_code(CodeGenHelper& cgh);
1085 virtual char* generate_code_str(char *str);
1086 virtual void ilt_generate_code(ILT *ilt);
1087 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1088 virtual void dump_internal(unsigned level) const;
1089 };
1090
1091 /**
1092 * Def_Var_Template class represents a template variable (dynamic template)
1093 * definition.
1094 */
1095 class Def_Var_Template : public Definition {
1096 private:
1097 Type *type;
1098 /** the initial value: optional and maybe incomplete */
1099 Template *initial_value;
1100 /** optional restriction on this variable */
1101 template_restriction_t template_restriction;
1102 /** set in chk(), used by code generation,
1103 * valid if template_restriction!=TR_NONE */
1104 bool gen_restriction_check;
1105
1106 /// Copy constructor disabled
1107 Def_Var_Template(const Def_Var_Template& p);
1108 /// %Assignment disabled
1109 Def_Var_Template& operator=(const Def_Var_Template& p);
1110 public:
1111 Def_Var_Template(Identifier *p_id, Type *p_type, Template *p_initial_value,
1112 template_restriction_t p_template_restriction);
1113 virtual ~Def_Var_Template();
1114 virtual Def_Var_Template *clone() const;
1115 virtual void set_fullname(const string& p_fullname);
1116 virtual void set_my_scope(Scope *p_scope);
1117 virtual Type *get_Type();
1118 virtual void chk();
1119 virtual bool chk_identical(Definition *p_def);
1120 virtual void generate_code(output_struct *target, bool clean_up = false);
1121 virtual void generate_code(CodeGenHelper& cgh);
1122 virtual char* generate_code_str(char *str);
1123 virtual void ilt_generate_code(ILT *ilt);
1124 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1125 virtual void dump_internal(unsigned level) const;
1126 template_restriction_t get_template_restriction()
1127 { return template_restriction; }
1128 };
1129
1130 /**
1131 * Def_Timer class represents a single timer declaration (e.g. in a
1132 * TTCN component type).
1133 */
1134 class Def_Timer : public Definition {
1135 private:
1136 /** Describes the dimensions of a timer array. It is NULL in case
1137 * of single timer instance. */
1138 ArrayDimensions *dimensions;
1139 /** Default duration of the timers. It can be either a single
1140 * float value or an array of floats. If it is NULL the timer(s)
1141 * has no default duration. */
1142 Value *default_duration;
1143
1144 /// Copy constructor disabled
1145 Def_Timer(const Def_Timer& p);
1146 /// %Assignment disabled
1147 Def_Timer& operator=(const Def_Timer& p);
1148 public:
1149 Def_Timer(Identifier *p_id, ArrayDimensions *p_dims, Value *p_dur)
1150 : Definition(A_TIMER, p_id), dimensions(p_dims),
1151 default_duration(p_dur) { }
1152 virtual ~Def_Timer();
1153 virtual Def_Timer *clone() const;
1154 virtual void set_fullname(const string& p_fullname);
1155 virtual void set_my_scope(Scope *p_scope);
1156 virtual ArrayDimensions *get_Dimensions();
1157 virtual void chk();
1158 virtual bool chk_identical(Definition *p_def);
1159 /** Returns false if it is sure that the timer referred by array
1160 * indices \a p_subrefs does not have a default
1161 * duration. Otherwise it returns true. Argument \a p_subrefs
1162 * might be NULL when examining a single timer. */
1163 bool has_default_duration(FieldOrArrayRefs *p_subrefs);
1164 private:
1165 /** Checks if the value \a dur is suitable as duration for a single
1166 * timer. */
1167 void chk_single_duration(Value *dur);
1168 /** Checks if the value \a dur is suitable as duration for a timer
1169 * array. The function calls itself recursively, argument \a
1170 * start_dim shall be zero when called from outside. */
1171 void chk_array_duration(Value *dur, size_t start_dim = 0);
1172 public:
1173 virtual void generate_code(output_struct *target, bool clean_up = false);
1174 virtual void generate_code(CodeGenHelper& cgh);
1175 private:
1176 /** Generates a C++ code fragment that sets the default duration
1177 * of a timer array. The generated code is appended to \a str and
1178 * the resulting string is returned. The equivalent C++ object of
1179 * timer array is named \a object_name, the array value containing
1180 * the default durations is \a dur. The function calls itself
1181 * recursively, argument \a start_dim shall be zero when called
1182 * from outside. */
1183 char *generate_code_array_duration(char *str, const char *object_name,
1184 Value *dur, size_t start_dim = 0);
1185 public:
1186 virtual char* generate_code_str(char *str);
1187 virtual void ilt_generate_code(ILT *ilt);
1188 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1189 virtual void dump_internal(unsigned level) const;
1190 };
1191
1192 /**
1193 * Def_Port class represents a port declaration (in a component type).
1194 */
1195 class Def_Port : public Definition {
1196 private:
1197 /** Contains a reference to a TTCN-3 port type */
1198 Reference *type_ref;
1199 /** Points to the object describing the port type.
1200 *
1201 * Derived from \a type_ref during Def_Port::chk().
1202 * It can be NULL in case of any error (e.g. the reference points to a
1203 * non-existent port type or the referenced entity is not a port type. */
1204 Type *port_type;
1205 /** Describes the dimensions of a port array.
1206 * It is NULL in case of single port instance. */
1207 ArrayDimensions *dimensions;
1208
1209 /// Copy constructor disabled
1210 Def_Port(const Def_Port& p);
1211 /// %Assignment disabled
1212 Def_Port& operator=(const Def_Port& p);
1213 public:
1214 /** Constructor
1215 *
1216 * @param p_id identifier (must not be NULL), the name of the port
1217 * @param p_tref type reference (must not be NULL)
1218 * @param p_dims array dimensions (NULL for a single port instance)
1219 */
1220 Def_Port(Identifier *p_id, Reference *p_tref, ArrayDimensions *p_dims);
1221 virtual ~Def_Port();
1222 virtual Def_Port *clone() const;
1223 virtual void set_fullname(const string& p_fullname);
1224 virtual void set_my_scope(Scope *p_scope);
1225 /** Get the \a port_type
1226 *
1227 * @pre chk() has been called (because it computes \a port_type)
1228 */
1229 virtual Type *get_Type();
1230 virtual ArrayDimensions *get_Dimensions();
1231 virtual void chk();
1232 virtual bool chk_identical(Definition *p_def);
1233 virtual void generate_code(output_struct *target, bool clean_up = false);
1234 virtual void generate_code(CodeGenHelper& cgh);
1235 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1236 virtual void dump_internal(unsigned level) const;
1237 };
1238
1239 /**
1240 * Common base class for function and external function definitions.
1241 */
1242 class Def_Function_Base : public Definition {
1243 public:
1244 enum prototype_t {
1245 PROTOTYPE_NONE, /**< no prototype(...) attribute */
1246 PROTOTYPE_CONVERT, /**< attribute prototype(convert) */
1247 PROTOTYPE_FAST, /**< attribute prototype(fast) */
1248 PROTOTYPE_BACKTRACK, /**< attribute prototype(backtrack) */
1249 PROTOTYPE_SLIDING /**< attribute prototype(sliding) */
1250 };
1251 protected: // Def_Function and Def_ExtFunction need access
1252 /** The formal parameter list of the function. It is never NULL even if
1253 * the function has empty parameter list. Owned. */
1254 FormalParList *fp_list;
1255 /** The return type of the function or NULL in case of no return type.
1256 * Owned. */
1257 Type *return_type;
1258 /** Identifier of the enc/dec API implemented by the function */
1259 prototype_t prototype;
1260 /** Shortcut to the input type if the function implements one of the
1261 * enc/dec APIs or NULL otherwise. Not owned. */
1262 Type *input_type;
1263 /** Shortcut to the output type if the function implements one of the
1264 * enc/dec APIs or NULL otherwise. Not owned */
1265 Type *output_type;
1266 /** optional template restriction on return template value */
1267 template_restriction_t template_restriction;
1268
1269 static asstype_t determine_asstype(bool is_external, bool has_return_type,
1270 bool returns_template);
1271 /// Copy constructor disabled
1272 Def_Function_Base(const Def_Function_Base& p);
1273 /// %Assignment disabled
1274 Def_Function_Base& operator=(const Def_Function_Base& p);
1275 public:
1276 /** Constructor.
1277 *
1278 * @param is_external true if external function (the derived type is
1279 * Def_ExtFunction), false if a TTCN-3 function (Def_Function)
1280 * @param p_id the name of the function
1281 * @param p_fpl formal parameter list
1282 * @param p_return_type return type (may be NULL)
1283 * @param returns_template true if the return is a template
1284 * @param p_template_restriction restriction type
1285 */
1286 Def_Function_Base(bool is_external, Identifier *p_id,
1287 FormalParList *p_fpl, Type *p_return_type, bool returns_template,
1288 template_restriction_t p_template_restriction);
1289 virtual ~Def_Function_Base();
1290 virtual void set_fullname(const string& p_fullname);
1291 virtual void set_my_scope(Scope *p_scope);
1292 virtual Type *get_Type();
1293 virtual FormalParList *get_FormalParList();
1294 prototype_t get_prototype() const { return prototype; }
1295 void set_prototype(prototype_t p_prototype) { prototype = p_prototype; }
1296 const char *get_prototype_name() const;
1297 void chk_prototype();
1298 Type *get_input_type();
1299 Type *get_output_type();
1300 template_restriction_t get_template_restriction()
1301 { return template_restriction; }
1302 };
1303
1304 /**
1305 * Def_Function class represents a function definition.
1306 */
1307 class Def_Function : public Def_Function_Base {
1308 private:
1309 /** The 'runs on' clause (i.e. a reference to a TTCN-3 component type)
1310 * It is NULL if the function has no 'runs on' clause. */
1311 Reference *runs_on_ref;
1312 /** Points to the object describing the component type referred by
1313 * 'runs on' clause.
1314 * It is NULL if the function has no 'runs on' clause or \a runs_on_ref is
1315 * erroneous. */
1316 Type *runs_on_type;
1317 /** The body of the function */
1318 StatementBlock *block;
1319 /** Indicates whether the function is startable. That is, it can be
1320 * launched as PTC behaviour as argument of a start test component
1321 * statement. */
1322 bool is_startable;
1323 /** Opts out from location information */
1324 bool transparent;
1325
1326 NameBridgingScope bridgeScope;
1327
1328 /// Copy constructor disabled
1329 Def_Function(const Def_Function& p);
1330 /// %Assignment disabled
1331 Def_Function& operator=(const Def_Function& p);
1332 public:
1333 /** Constructor for a TTCN-3 function definition
1334 *
1335 * Called from a single location in compiler.y
1336 *
1337 * @param p_id function name
1338 * @param p_fpl formal parameter list
1339 * @param p_runs_on_ref "runs on", else NULL
1340 * @param p_return_type return type, may be NULL
1341 * @param returns_template true if the return value is a template
1342 * @param p_template_restriction restriction type
1343 * @param p_block the body of the function
1344 */
1345 Def_Function(Identifier *p_id, FormalParList *p_fpl,
1346 Reference *p_runs_on_ref, Type *p_return_type,
1347 bool returns_template,
1348 template_restriction_t p_template_restriction,
1349 StatementBlock *p_block);
1350 virtual ~Def_Function();
1351 virtual Def_Function *clone() const;
1352 virtual void set_fullname(const string& p_fullname);
1353 virtual void set_my_scope(Scope *p_scope);
1354 virtual Type *get_RunsOnType();
1355 /** Returns a scope that can access the definitions within component type
1356 * \a comptype and its parent is \a parent_scope.*/
1357 RunsOnScope *get_runs_on_scope(Type *comptype);
1358 virtual void chk();
1359 /** Checks and returns whether the function is startable.
1360 * Reports the appropriate error message(s) if not. */
1361 bool chk_startable();
1362
1363 bool is_transparent() const { return transparent; }
1364
1365 virtual void generate_code(output_struct *target, bool clean_up = false);
1366 virtual void generate_code(CodeGenHelper& cgh);
1367 virtual void dump_internal(unsigned level) const;
1368
1369 virtual void set_parent_path(WithAttribPath* p_path);
1370 };
1371
1372 /** RAII class for transparent functions.
1373 *
1374 * Calls to TTCN_Location::update_lineno are written by Ttcn::Statement
1375 * by calling Common::Location::update_location_object. These calls
1376 * need to be removed inside transparent functions.
1377 *
1378 * It is difficult (impossible) for a Statement to navigate up in the AST
1379 * to the function/altstep/testcase/control part that contains it;
1380 * instead, the Def_Function sets a static flag inside Common::Location
1381 * that says "you are inside a transparent function" while
1382 * Def_Function::generate_code function runs.
1383 */
1384 class transparency_holder {
1385 bool old_transparency;
1386 public:
1387 /** Sets Common::Location::transparency (but remembers its old vaue)
1388 *
1389 * @param df the function definition
1390 */
1391 transparency_holder(const Def_Function &df)
1392 : old_transparency(Common::Location::transparency)
1393 { Common::Location::transparency = df.is_transparent(); }
1394
1395 /** Restores the value of Common::Location::transparency */
1396 ~transparency_holder()
1397 { Common::Location::transparency = old_transparency; }
1398 };
1399
1400 /**
1401 * Def_ExtFunction class represents an external function definition.
1402 */
1403 class Def_ExtFunction : public Def_Function_Base {
1404 public:
1405 enum ExternalFunctionType_t {
1406 EXTFUNC_MANUAL, /**< written manually by the user */
1407 EXTFUNC_ENCODE, /**< automatically generated encoder function */
1408 EXTFUNC_DECODE /**< automatically generated decoder function */
1409 };
1410 private:
1411 ExternalFunctionType_t function_type;
1412 Type::MessageEncodingType_t encoding_type;
1413 string *encoding_options;
1414 Ttcn::ErrorBehaviorList *eb_list;
1415 Ttcn::PrintingType *json_printing;
1416 /// Copy constructor disabled
1417 Def_ExtFunction(const Def_ExtFunction& p);
1418 /// %Assignment disabled
1419 Def_ExtFunction& operator=(const Def_ExtFunction& p);
1420 public:
1421 /** Constructor for an external function definition
1422 *
1423 * Called from a single location in compiler.y
1424 *
1425 * @param p_id the name
1426 * @param p_fpl formal parameters
1427 * @param p_return_type the return type
1428 * @param returns_template true if it returns a template
1429 * @param p_template_restriction restriction type
1430 */
1431 Def_ExtFunction(Identifier *p_id, FormalParList *p_fpl,
1432 Type *p_return_type, bool returns_template,
1433 template_restriction_t p_template_restriction)
1434 : Def_Function_Base(true, p_id, p_fpl, p_return_type, returns_template,
1435 p_template_restriction),
1436 function_type(EXTFUNC_MANUAL), encoding_type(Type::CT_UNDEF),
1437 encoding_options(0), eb_list(0), json_printing(0) { }
1438 ~Def_ExtFunction();
1439 virtual Def_ExtFunction *clone() const;
1440 virtual void set_fullname(const string& p_fullname);
1441 void set_encode_parameters(Type::MessageEncodingType_t p_encoding_type,
1442 string *p_encoding_options);
1443 void set_decode_parameters(Type::MessageEncodingType_t p_encoding_type,
1444 string *p_encoding_options);
1445 void add_eb_list(Ttcn::ErrorBehaviorList *p_eb_list);
1446 ExternalFunctionType_t get_function_type() const { return function_type; }
1447 private:
1448 void chk_function_type();
1449 void chk_allowed_encode();
1450 public:
1451 virtual void chk();
1452 private:
1453 char *generate_code_encode(char *str);
1454 char *generate_code_decode(char *str);
1455 public:
1456 virtual void generate_code(output_struct *target, bool clean_up = false);
1457 /// Just a shim for code splitting
1458 virtual void generate_code(CodeGenHelper& cgh);
1459 virtual void dump_internal(unsigned level) const;
1460
1461 /** For JSON encoding and decoding functions only
1462 * Generates a JSON schema segment containing a reference to the encoded
1463 * type's schema and any information required to recreate this function.
1464 * If the schema with the reference already exists, the function's info is
1465 * inserted in the schema. */
1466 void generate_json_schema_ref(map<Type*, JSON_Tokenizer>& json_refs);
1467 };
1468
1469 /**
1470 * Represents an altstep definition.
1471 */
1472 class Def_Altstep : public Definition {
1473 private:
1474 /** The formal parameter list of the altstep. It is never NULL even if
1475 * the altstep has no parameters. */
1476 FormalParList *fp_list;
1477 /** The 'runs on' clause (i.e. a reference to a TTCN-3 component type)
1478 * It is NULL if the altstep has no 'runs on' clause. */
1479 Reference *runs_on_ref;
1480 /** Points to the object describing the component type referred by
1481 * 'runs on' clause.
1482 * It is NULL if the altstep has no 'runs on' clause or \a runs_on_ref is
1483 * erroneous. */
1484 Type *runs_on_type;
1485 StatementBlock *sb; /**< contains the local definitions */
1486 AltGuards *ags;
1487
1488 NameBridgingScope bridgeScope;
1489
1490 /// Copy constructor disabled
1491 Def_Altstep(const Def_Altstep& p);
1492 /// %Assignment disabled
1493 Def_Altstep& operator=(const Def_Altstep& p);
1494 public:
1495 Def_Altstep(Identifier *p_id, FormalParList *p_fpl,
1496 Reference *p_runs_on_ref, StatementBlock *p_sb,
1497 AltGuards *p_ags);
1498 virtual ~Def_Altstep();
1499 virtual Def_Altstep *clone() const;
1500 virtual void set_fullname(const string& p_fullname);
1501 virtual void set_my_scope(Scope *p_scope);
1502 virtual Type *get_RunsOnType();
1503 virtual FormalParList *get_FormalParList();
1504 /** Returns a scope that can access the definitions within component type
1505 * \a comptype and its parent is \a parent_scope.*/
1506 RunsOnScope *get_runs_on_scope(Type *comptype);
1507 virtual void chk();
1508 virtual void generate_code(output_struct *target, bool clean_up = false);
1509 virtual void generate_code(CodeGenHelper& cgh);
1510 virtual void dump_internal(unsigned level) const;
1511
1512 virtual void set_parent_path(WithAttribPath* p_path);
1513 };
1514
1515 /**
1516 * Represents an testcase definition.
1517 */
1518 class Def_Testcase : public Definition {
1519 private:
1520 /** The formal parameter list of the testcase. It is never NULL even if
1521 * the testcase has no parameters. */
1522 FormalParList *fp_list;
1523 /** The 'runs on' clause (i.e. a reference to a TTCN-3 component type)
1524 * It is never NULL. */
1525 Reference *runs_on_ref;
1526 /** Points to the object describing the component type referred by
1527 * 'runs on' clause. It is NULL only if \a runs_on_ref is erroneous. */
1528 Type *runs_on_type;
1529 /** The 'system' clause (i.e. a reference to a TTCN-3 component type)
1530 * It is NULL if the testcase has no 'system' clause. */
1531 Reference *system_ref;
1532 /** Points to the object describing the component type referred by
1533 * 'system' clause. It is NULL if the testcase has no 'system' clause or
1534 * \a system_ref is erroneous. */
1535 Type *system_type;
1536 StatementBlock *block;
1537
1538 NameBridgingScope bridgeScope;
1539
1540 /// Copy constructor disabled
1541 Def_Testcase(const Def_Testcase& p);
1542 /// %Assignment disabled
1543 Def_Testcase& operator=(const Def_Testcase& p);
1544 public:
1545 Def_Testcase(Identifier *p_id, FormalParList *p_fpl,
1546 Reference *p_runs_on_ref, Reference *p_system_ref,
1547 StatementBlock *p_block);
1548 virtual ~Def_Testcase();
1549 virtual Def_Testcase *clone() const;
1550 virtual void set_fullname(const string& p_fullname);
1551 virtual void set_my_scope(Scope *p_scope);
1552 virtual Type *get_RunsOnType();
1553 Type *get_SystemType();
1554 virtual FormalParList *get_FormalParList();
1555 /** Returns a scope that can access the definitions within component type
1556 * \a comptype and its parent is \a parent_scope.*/
1557 RunsOnScope *get_runs_on_scope(Type *comptype);
1558 virtual void chk();
1559 virtual void generate_code(output_struct *target, bool clean_up = false);
1560 virtual void generate_code(CodeGenHelper& cgh);
1561 virtual void dump_internal(unsigned level) const;
1562
1563 virtual void set_parent_path(WithAttribPath* p_path);
1564 };
1565
1566 /** General class to represent formal parameters. The inherited
1567 * attribute asstype carries the kind and direction of the
1568 * parameter. */
1569 class FormalPar : public Definition {
1570 private:
1571 Type *type;
1572 /** Default value of the parameter (optional). If \a checked flag is true
1573 * then field \a ap is used otherwise \a ti is active. */
1574 union {
1575 TemplateInstance *ti;
1576 ActualPar *ap;
1577 } defval;
1578 /** Points to the formal parameter list that \a this belongs to. */
1579 FormalParList *my_parlist;
1580 /** Flag that indicates whether the value of the parameter is overwritten
1581 * within the function/altstep/testcase body.
1582 * Used only in case of `in' value or template parameters. */
1583 bool used_as_lvalue;
1584 /** restriction on template value */
1585 template_restriction_t template_restriction;
1586 /** normal or lazy evaluation parametrization should be used */
1587 bool lazy_eval;
1588
1589 /// Copy constructor disabled
1590 FormalPar(const FormalPar& p);
1591 /// %Assignment disabled
1592 FormalPar& operator=(const FormalPar& p);
1593 public:
1594 FormalPar(asstype_t p_asstype, Type *p_type, Identifier* p_name,
1595 TemplateInstance *p_defval, bool p_lazy_eval=false);
1596 FormalPar(asstype_t p_asstype,
1597 template_restriction_t p_template_restriction,
1598 Type *p_type, Identifier* p_name, TemplateInstance *p_defval,
1599 bool p_lazy_eval=false);
1600 FormalPar(asstype_t p_asstype, Identifier* p_name,
1601 TemplateInstance *p_defval);
1602 ~FormalPar();
1603 virtual FormalPar *clone() const;
1604 virtual void set_fullname(const string& p_fullname);
1605 virtual void set_my_scope(Scope *p_scope);
1606 /** Always true. Formal parameters are considered as local definitions
1607 * even if their scope is the module definitions. */
1608 virtual bool is_local() const;
1609 virtual Type *get_Type();
1610 virtual void chk();
1611 bool has_defval() const;
1612 bool has_notused_defval() const;
1613 /** Get the default value.
1614 * \pre chk() has been called (checked==true) */
1615 ActualPar *get_defval() const;
1616 void set_defval(ActualPar *defpar);
1617 void set_my_parlist(FormalParList *p_parlist) { my_parlist = p_parlist; }
1618 FormalParList *get_my_parlist() const { return my_parlist; }
1619 ActualPar *chk_actual_par(TemplateInstance *actual_par,
1620 Type::expected_value_t exp_val);
1621 private:
1622 ActualPar *chk_actual_par_value(TemplateInstance *actual_par,
1623 Type::expected_value_t exp_val);
1624 ActualPar *chk_actual_par_template(TemplateInstance *actual_par,
1625 Type::expected_value_t exp_val);
1626 ActualPar *chk_actual_par_by_ref(TemplateInstance *actual_par,
1627 bool is_template, Type::expected_value_t exp_val);
1628 ActualPar *chk_actual_par_timer(TemplateInstance *actual_par,
1629 Type::expected_value_t exp_val);
1630 ActualPar *chk_actual_par_port(TemplateInstance *actual_par,
1631 Type::expected_value_t exp_val);
1632 public:
1633 /** Checks whether the value of the parameter may be modified in the body
1634 * of the parameterized definition (in assignment, port redirect or passing
1635 * it further as 'out' or 'inout' parameter). Applicable to `in' value or
1636 * template parameters only. Note that formal parameters of templates cannot
1637 * be modified. If the modification is allowed a flag is set, which is
1638 * considered at C++ code generation. Argument \a p_loc is used for error
1639 * reporting. */
1640 virtual void use_as_lvalue(const Location& p_loc);
1641 bool get_used_as_lvalue() const { return used_as_lvalue; }
1642 /** Generates the C++ objects that represent the default value for the
1643 * parameter (if present). */
1644 virtual void generate_code_defval(output_struct *target, bool clean_up = false);
1645 /** Generates the C++ equivalent of the formal parameter, appends it to
1646 * \a str and returns the resulting string. */
1647 char *generate_code_fpar(char *str);
1648 /** Generates a C++ statement that defines an object (variable) for the
1649 * formal parameter, appends it to \a str and returns the resulting
1650 * string. The name of the object is constructed from \a p_prefix and the
1651 * parameter identifier.
1652 * The \a refch parameter is needed when the code for start_ptc_function is
1653 * generated, because reference is generated in case of inout parameters. */
1654 char *generate_code_object(char *str, const char *p_prefix,
1655 char refch = '&');
1656 /** Generates a C++ statement that instantiates a shadow object for the
1657 * parameter when necessary. It is used when the value of an 'in' value or
1658 * template parameter is overwritten within the function body. */
1659 char *generate_shadow_object(char *str) const;
1660 /** Generates a C++ statement that calls a function that sets the parameter unbound
1661 * It is used when the value of an 'out' value */
1662 char *generate_code_set_unbound(char *str) const;
1663 virtual void dump_internal(unsigned level) const;
1664 template_restriction_t get_template_restriction()
1665 { return template_restriction; }
1666 virtual bool get_lazy_eval() const { return lazy_eval; }
1667 // code generation: get the C++ string that refers to the formal parameter
1668 // adds a casting to data type if wrapped into a lazy param
1669 string get_reference_name(Scope* scope) const;
1670 };
1671
1672 /** Class to represent a list of formal parameters. Owned by a
1673 * Def_Template, Def_Function_Base, Def_Altstep or Def_Testcase. */
1674 class FormalParList : public Scope, public Location {
1675 private:
1676 vector<FormalPar> pars_v;
1677 /** Map names to the formal parameters in pars_v. Filled by
1678 * FormalParList::chk*/
1679 map<string, FormalPar> pars_m;
1680 /** Indicates the minimal number of actual parameters that must be present
1681 * in parameterized references. Could be less than the size of pars_v
1682 * if some parameters have default values. */
1683 size_t min_nof_pars;
1684 /** Points to the definition that the parameter list belongs to. */
1685 Definition *my_def;
1686 bool checked;
1687 bool is_startable;
1688
1689 /** Copy constructor. For FormalParList::clone() only. */
1690 FormalParList(const FormalParList& p);
1691 /** %Assignment disallowed. */
1692 FormalParList& operator=(const FormalParList& p);
1693 public:
1694 FormalParList() : Scope(), Location(), pars_v(), pars_m()
1695 , min_nof_pars(0), my_def(0), checked(false), is_startable(false) {}
1696 ~FormalParList();
1697 virtual FormalParList *clone() const;
1698 virtual void set_fullname(const string& p_fullname);
1699 /** Sets the parent scope and the scope of parameters to \a p_scope. */
1700 virtual void set_my_scope(Scope *p_scope);
1701 void set_my_def(Definition *p_def) { my_def = p_def; }
1702 Definition *get_my_def() const { return my_def; }
1703 void add_fp(FormalPar *p_fp);
1704 size_t get_nof_fps() const { return pars_v.size(); }
1705 bool has_notused_defval() const;
1706 bool has_only_default_values() const;
1707 bool has_fp_withName(const Identifier& p_name);
1708 FormalPar *get_fp_byName(const Identifier& p_name);
1709 FormalPar *get_fp_byIndex(size_t n) const { return pars_v[n]; }
1710 bool get_startability();
1711 virtual Common::Assignment *get_ass_bySRef(Common::Ref_simple *p_ref);
1712 virtual bool has_ass_withId(const Identifier& p_id);
1713 /** Checks the parameter list, which belongs to definition of type
1714 * \a deftype. */
1715 void chk(Definition::asstype_t deftype);
1716 void chk_noLazyParams();
1717 /** Checks the parameter list for startability: reports error if the owner
1718 * function cannot be started on a PTC. Used by functions and function
1719 * types. Parameter \a p_what shall contain "Function" or "Function type",
1720 * \a p_name shall contain the name of the function or function type. */
1721 void chk_startability(const char *p_what, const char *p_name);
1722 /** Checks the compatibility of two formal parameter list.
1723 * They are compatible if every parameter is compatible, has the same
1724 * attribute, and name */
1725 void chk_compatibility(FormalParList* p_fp_list, const char* where);
1726 /** Checks the parsed actual parameters in \a p_tis against \a this.
1727 * The actual parameters that are the result of transformation are added to
1728 * \a p_aplist (which is usually empty when this function is called).
1729 * \return true in case of any error, false after a successful check. */
1730 bool chk_actual_parlist(TemplateInstances *p_tis, ActualParList *p_aplist);
1731 /** Fold named parameters into the unnamed (order-based) param list.
1732 *
1733 * Named parameters are checked against the formal parameters.
1734 * Found ones are transferred into the unnamed param list at the
1735 * appropriate index.
1736 *
1737 * @param p_paps actual parameters from the parser (Bison); contains
1738 * both named and unnamed parameters
1739 * @param p_aplist actual parameters
1740 * @return the result of calling chk_actual_parlist, above:
1741 * true if error, false if the check is successful
1742 */
1743 bool fold_named_and_chk(ParsedActualParameters *p_paps, ActualParList *p_aplist);
1744 bool chk_activate_argument(ActualParList *p_aplist,
1745 const char* p_description);
1746 void set_genname(const string& p_prefix);
1747 /** Generates the C++ equivalent of the formal parameter list, appends it
1748 * to \a str and returns the resulting string. */
1749 char *generate_code(char *str);
1750 /** Generates the C++ objects that represent the default values for the
1751 * parameters (if present). */
1752 void generate_code_defval(output_struct *target);
1753 /** Generates a C++ actual parameter list for wrapper functions, appends it
1754 * to \a str and returns the resulting string. It contains the
1755 * comma-separated list of parameter identifiers prefixed by \a p_prefix. */
1756 char *generate_code_actual_parlist(char *str, const char *p_prefix);
1757 /** Generates a C++ code sequence that defines an object (variable) for
1758 * each formal parameter (which is used in wrapper functions), appends it
1759 * to \a str and returns the resulting string. The name of each object is
1760 * constructed from \a p_prefix and the parameter identifier.
1761 * The \a refch parameter is needed when the code for start_ptc_function is
1762 * generated, because reference is generated in case of inout parameters. */
1763 char *generate_code_object(char *str, const char *p_prefix,
1764 char refch = '&');
1765 /** Generates the C++ shadow objects for all parameters. */
1766 char *generate_shadow_objects(char *str) const;
1767 char *generate_code_set_unbound(char *str) const;
1768 void dump(unsigned level) const;
1769 };
1770
1771 } // namespace Ttcn
1772
1773 #endif // _Ttcn_AST_HH
This page took 0.095262 seconds and 4 git commands to generate.