Sync with 5.2.0
[deliverable/titan.core.git] / compiler2 / ttcn3 / AST_ttcn3.hh
CommitLineData
970ed795
EL
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
13namespace Common {
14class CodeGenHelper;
15}
16
17/**
18 * This namespace contains classes unique to TTCN-3 and some specializations
19 * of classes from Common.
20 */
21namespace 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
af710487 628 /** Generates JSON schema segments for the types defined in the modules,
629 * and references to these types. Information related to the types'
630 * JSON encoding and decoding functions is also inserted after the references.
631 *
632 * @param json JSON document containing the main schema, schema segments for
633 * the types will be inserted here
634 * @param json_refs map of JSON documents containing the references and function
635 * info related to each type */
636 virtual void generate_json_schema(JSON_Tokenizer& json, map<Type*, JSON_Tokenizer>& json_refs);
970ed795
EL
637 };
638
639 /**
640 * Module friendship declaration.
641 */
642 class FriendMod : public Node, public Location {
643 private:
644 Module *my_mod;
645 Identifier *modid;
646 WithAttribPath* w_attrib_path;
647 Group* parentgroup;
648 /** Indicates whether this friend module declaration was checked */
649 bool checked;
650 private:
651 /** Copy constructor not implemented. */
652 FriendMod(const FriendMod&);
653 /** %Assignment not implemented. */
654 FriendMod& operator=(const FriendMod&);
655 public:
656 FriendMod(Identifier *p_modid);
657 ~FriendMod();
658 virtual FriendMod* clone() const;
659 virtual void set_fullname(const string& p_fullname);
660 virtual void chk();
661 void set_my_mod(Module *p_mod) { my_mod = p_mod; }
662 const Identifier& get_modid() const {return *modid;}
663 void set_with_attr(MultiWithAttrib* p_attrib);
664 WithAttribPath* get_attrib_path();
665 void set_parent_path(WithAttribPath* p_path);
666 void set_parent_group(Group* p_group);
667 };
668
669
670 /**
671 * Imported module. Represents an import statement.
672 */
673 class ImpMod : public Node, public Location {
674 public:
675 enum imptype_t {
676 I_UNDEF,
677 I_ERROR,
678 I_ALL,
679 I_IMPORTSPEC,
680 I_IMPORTIMPORT
681 };
682 private:
683 /** Points to the target (imported) module. This is initially NULL;
684 * set during semantic analysis by Ttcn::Imports::chk_uniq() */
685 Common::Module *mod;
686 /** The importing module (indirectly our owner) */
687 Module *my_mod;
688 /** Import type: "import all", selective import, import of import, etc. */
689 imptype_t imptype;
690 /** The name given in the import statement;
691 * hopefully an actual module name */
692 Identifier *modid;
693 /** The text after "import from name language" */
694 string *language_spec;
695 /** Recursive import (already deprecated in v3.2.1) */
696 bool is_recursive;
697 WithAttribPath* w_attrib_path;
698 /** Group in which the import statement is located, if any */
699 Group* parentgroup;
700 visibility_t visibility;
701 private:
702 /** Copy constructor not implemented. */
703 ImpMod(const ImpMod&);
704 /** %Assignment not implemented */
705 ImpMod& operator=(const ImpMod&);
706 public:
707 ImpMod(Identifier *p_modid);
708 ~ImpMod();
709 virtual ImpMod* clone() const;
710 virtual void set_fullname(const string& p_fullname);
711 virtual void chk();
712 /** Checks the existence of imported symbols and checks import definitions
713 * in the imported modules recursively. */
714 void chk_imp(ReferenceChain& refch, vector<Common::Module>& moduleStack);
715 void set_my_mod(Module *p_mod) { my_mod = p_mod; }
716 const Identifier& get_modid() const {return *modid;}
717 void set_mod(Common::Module *p_mod) { mod = p_mod; }
718 Common::Module *get_mod() const { return mod; }
719 /** Returns the imported definition with name \a p_id if it is imported or
720 * NULL otherwise.
721 * \a loc is used to report an error if it is needed */
722 Common::Assignment *get_imported_def(const Identifier& p_source_modid,
723 const Identifier& p_id, const Location *loc,
724 ReferenceChain* refch, vector<ImpMod>& usedImpMods) const;
725 bool has_imported_def(const Identifier& p_source_modid,
726 const Identifier& p_id, const Location *loc) const;
727 void set_imptype(imptype_t p_imptype) { imptype = p_imptype; }
728 void set_language_spec(const char *p_language_spec);
729 void set_recursive() { is_recursive = true; }
730 void generate_code(output_struct *target);
731 virtual void dump(unsigned level) const;
732 void set_with_attr(MultiWithAttrib* p_attrib);
733 WithAttribPath* get_attrib_path();
734 void set_parent_path(WithAttribPath* p_path);
735 void set_parent_group(Group* p_group);
736 imptype_t get_imptype() {
737 return imptype;
738 }
739 void set_visibility(visibility_t p_visibility){
740 visibility = p_visibility;
741 }
742 visibility_t get_visibility() const{
743 return visibility;
744 }
745 };
746
747 /**
748 * Class Imports.
749 */
750 class Imports : public Node {
751 private:
752 /** my module */
753 Module *my_mod;
754 /** imported modules */
755 vector<ImpMod> impmods_v;
756 /** Indicates whether the import list has been checked. */
757 bool checked;
758
759 friend class ImpMod;
760 private:
761 /** Copy constructor not implemented. */
762 Imports(const Imports&);
763 /** %Assignment not implemented */
764 Imports& operator=(const Imports&);
765 public:
766 Imports() : Node(), my_mod(0), impmods_v(), checked(false) {}
767 virtual ~Imports();
768 virtual Imports* clone() const;
769 void add_impmod(ImpMod *p_impmod);
770 void set_my_mod(Module *p_mod);
771 int get_imports_size() const {return impmods_v.size();}
772 ImpMod* get_impmod(int index) const {return impmods_v[index];}
773 /** Checks the existence of imported modules and detects duplicated imports
774 * from the same module. Initializes \a impmods_m. */
775 void chk_uniq();
776 /** Checks the existence of imported symbols and checks import definitions
777 * in the imported modules recursively. */
778 void chk_imp(ReferenceChain& refch, vector<Common::Module>& moduleStack);
779 /** Returns \p true if an imported module with the given name exists,
780 * else returns \p false. */
781 bool has_impmod_withId(const Identifier& p_id) const;
782 /** Returns whether a definition with identifier \a p_id is imported
783 * from one or more modules */
784 bool has_imported_def(const Identifier& p_id, const Location *loc) const;
785 /** Returns the imported definition with name \a p_id if it is
786 * unambiguous or NULL otherwise.
787 * \a loc is used to report an error if it is needed */
788 Common::Assignment *get_imported_def(const Identifier& p_source_modid,
789 const Identifier& p_id, const Location *loc, ReferenceChain* refch);
790 void get_imported_mods(Module::module_set_t& p_imported_mods) const;
791 void generate_code(output_struct *target);
792 void generate_code(CodeGenHelper& cgh);
793 virtual void dump(unsigned level) const;
794 };
795
796 class Definition : public Common::Assignment {
797 protected: // many derived classes
798 /** Contains the C++ identifier of the definition. If empty the C++
799 * identifier is generated from \a id. */
800 string genname;
801 /** The group it's in, if any */
802 Group *parentgroup;
803 WithAttribPath* w_attrib_path;
804 ErroneousAttributes* erroneous_attrs; // set by chk_erroneous_attr() or NULL
805 /** True if function/altstep/default scope, not module scope */
806 bool local_scope;
807
808 Definition(const Definition& p)
809 : Common::Assignment(p), genname(), parentgroup(0),
810 w_attrib_path(0), erroneous_attrs(0), local_scope(false)
811 { }
812 virtual string get_genname() const;
813
814 namedbool has_implicit_omit_attr() const;
815 private:
816 /// %Assignment disabled
817 Definition& operator=(const Definition& p);
818 public:
819 Definition(asstype_t p_asstype, Identifier *p_id)
820 : Common::Assignment(p_asstype, p_id), genname(), parentgroup(0),
821 w_attrib_path(0), erroneous_attrs(0), local_scope(false)
822 { }
823 virtual ~Definition();
824 virtual Definition* clone() const = 0;
825 virtual void set_fullname(const string& p_fullname);
826 virtual bool is_local() const;
827 /** Sets the visibility type of the definition */
828 void set_visibility(const visibility_t p_visibility)
829 { visibilitytype = p_visibility; }
830 /** Marks the (template) definition as local to a func/altstep/default */
831 inline void set_local() { local_scope = true; }
832
833 void set_genname(const string& p_genname) { genname = p_genname; }
834 /** Check if two definitions are (almost) identical, the type and dimensions
835 * must always be identical, the initial values can be different depending
836 * on the definition type. If error was reported the return value is false.
837 * The initial values (if applicable) may be present/absent, different or
838 * unfoldable. The function must be overridden to be used.
839 */
840 virtual bool chk_identical(Definition *p_def);
841 /** Parse and check the erroneous attribute data,
842 * sets erroneous_attrs member */
843 void chk_erroneous_attr();
844 /** This code generation is used when this definition is embedded
845 * in a statement block. */
846 virtual char* generate_code_str(char *str);
847 virtual void ilt_generate_code(ILT *ilt);
848 /** Generates the C++ initializer sequence for a definition of a component
849 * type, appends to \a str and returns the resulting string. The function
850 * is used when \a this is realized using the C++ objects of definition
851 * \a base_defn inherited from another component type. The function is
852 * implemented only for those definitions that can appear within component
853 * types, the generic version causes \a FATAL_ERROR. */
854 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
855 virtual void dump_internal(unsigned level) const;
856 virtual void dump(unsigned level) const;
857 virtual void set_with_attr(MultiWithAttrib* p_attrib);
858 virtual WithAttribPath* get_attrib_path();
859 virtual void set_parent_path(WithAttribPath* p_path);
860 virtual void set_parent_group(Group* p_group);
861 virtual Group* get_parent_group();
862 };
863
864 /**
865 * TTCN-3 type definition (including signatures and port types).
866 */
867 class Def_Type : public Definition {
868 private:
869 Type *type;
870
871 NameBridgingScope bridgeScope;
872
873 /** Copy constructor not implemented */
874 Def_Type(const Def_Type& p);
875 /** %Assignment disabled */
876 Def_Type& operator=(const Def_Type& p);
877 public:
878 Def_Type(Identifier *p_id, Type *p_type);
879 virtual ~Def_Type();
880 virtual Def_Type* clone() const;
881 virtual void set_fullname(const string& p_fullname);
882 virtual void set_my_scope(Scope *p_scope);
883 virtual Setting *get_Setting();
884 virtual Type *get_Type();
885 virtual void chk();
886 virtual void generate_code(output_struct *target, bool clean_up = false);
887 virtual void generate_code(CodeGenHelper& cgh);
888 virtual void dump_internal(unsigned level) const;
889 virtual void set_with_attr(MultiWithAttrib* p_attrib);
890 virtual WithAttribPath* get_attrib_path();
891 virtual void set_parent_path(WithAttribPath* p_path);
970ed795
EL
892 };
893
894 /**
895 * TTCN-3 constant definition.
896 */
897 class Def_Const : public Definition {
898 private:
899 Type *type;
900 Value *value;
901 bool value_under_check;
902
903 /// Copy constructor disabled
904 Def_Const(const Def_Const& p);
905 /// %Assignment disabled
906 Def_Const& operator=(const Def_Const& p);
907 public:
908 Def_Const(Identifier *p_id, Type *p_type, Value *p_value);
909 virtual ~Def_Const();
910 virtual Def_Const *clone() const;
911 virtual void set_fullname(const string& p_fullname);
912 virtual void set_my_scope(Scope *p_scope);
913 virtual Setting *get_Setting();
914 virtual Type *get_Type();
915 virtual Value *get_Value();
916 virtual void chk();
917 virtual bool chk_identical(Definition *p_def);
918 virtual void generate_code(output_struct *target, bool clean_up = false);
919 virtual void generate_code(CodeGenHelper& cgh);
920 virtual char* generate_code_str(char *str);
921 virtual void ilt_generate_code(ILT *ilt);
922 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
923 virtual void dump_internal(unsigned level) const;
924 };
925
926 /**
927 * TTCN-3 external constant definition.
928 */
929 class Def_ExtConst : public Definition {
930 private:
931 Type *type;
932
933 /// Copy constructor disabled
934 Def_ExtConst(const Def_ExtConst& p);
935 /// %Assignment disabled
936 Def_ExtConst& operator=(const Def_ExtConst& p);
937 public:
938 Def_ExtConst(Identifier *p_id, Type *p_type);
939 virtual ~Def_ExtConst();
940 virtual Def_ExtConst *clone() const;
941 virtual void set_fullname(const string& p_fullname);
942 virtual void set_my_scope(Scope *p_scope);
943 virtual Type *get_Type();
944 virtual void chk();
945 virtual void generate_code(output_struct *target, bool clean_up = false);
946 virtual void generate_code(CodeGenHelper& cgh);
947 virtual void dump_internal(unsigned level) const;
948 };
949
950 /**
951 * TTCN-3 module parameter definition.
952 */
953 class Def_Modulepar : public Definition {
954 private:
955 Type *type;
956 Value* def_value;
957 /// Copy constructor disabled
958 Def_Modulepar(const Def_Modulepar& p);
959 /// %Assignment disabled
960 Def_Modulepar& operator=(const Def_Modulepar& p);
961 public:
962 Def_Modulepar(Identifier *p_id, Type *p_type, Value *p_defval);
963 virtual ~Def_Modulepar();
964 virtual Def_Modulepar* clone() const;
965 virtual void set_fullname(const string& p_fullname);
966 virtual void set_my_scope(Scope *p_scope);
967 virtual Type *get_Type();
968 virtual void chk();
969 virtual void generate_code(output_struct *target, bool clean_up = false);
970 virtual void generate_code(CodeGenHelper& cgh);
971 virtual void dump_internal(unsigned level) const;
972 };
973
974 /**
975 * TTCN-3 template module parameter definition.
976 */
977 class Def_Modulepar_Template : public Definition {
978 private:
979 Type *type;
980 Template* def_template;
981 /// Copy constructor disabled
982 Def_Modulepar_Template(const Def_Modulepar_Template& p);
983 /// %Assignment disabled
984 Def_Modulepar_Template& operator=(const Def_Modulepar_Template& p);
985 public:
986 Def_Modulepar_Template(Identifier *p_id, Type *p_type, Template *p_defval);
987 virtual ~Def_Modulepar_Template();
988 virtual Def_Modulepar_Template* clone() const;
989 virtual void set_fullname(const string& p_fullname);
990 virtual void set_my_scope(Scope *p_scope);
991 virtual Type *get_Type();
992 virtual void chk();
993 virtual void generate_code(output_struct *target, bool clean_up = false);
994 virtual void generate_code(CodeGenHelper& cgh);
995 virtual void dump_internal(unsigned level) const;
996 };
997
998 /**
999 * Def_Template class represents a template definition.
1000 */
1001 class Def_Template : public Definition {
1002 private:
1003 /* the type of the template */
1004 Type *type;
1005 /** The formal parameter list of the template. It is NULL in case of
1006 * non-parameterized templates. */
1007 FormalParList *fp_list;
1008 /** points to the base template reference in case of modified templates,
1009 * otherwise it is NULL */
1010 Reference *derived_ref;
1011 /** shortcut to the base template in case of modified templates,
1012 * otherwise it is NULL */
1013 Def_Template *base_template;
1014 /** Indicates whether the circular recursion chain of modified templates
1015 * has been checked. */
1016 bool recurs_deriv_checked;
1017 /** the body of the template */
1018 Template *body;
1019 /** template definition level restriction */
1020 template_restriction_t template_restriction;
1021 /** set in chk(), used by code generation,
1022 * valid if template_restriction!=TR_NONE */
1023 bool gen_restriction_check;
1024
1025 NameBridgingScope bridgeScope;
1026
1027 /// Copy constructor for Def_Template::clone() only
1028 Def_Template(const Def_Template& p);
1029 /// %Assignment disabled
1030 Def_Template& operator=(const Def_Template& p);
1031 public:
1032 Def_Template(template_restriction_t p_template_restriction,
1033 Identifier *p_id, Type *p_type, FormalParList *p_fpl,
1034 Reference *p_derived_ref, Template *p_body);
1035 virtual ~Def_Template();
1036 virtual Def_Template *clone() const;
1037 virtual void set_fullname(const string& p_fullname);
1038 virtual void set_my_scope(Scope *p_scope);
1039 virtual Setting *get_Setting();
1040 virtual Type *get_Type();
1041 virtual Template *get_Template();
1042 virtual FormalParList *get_FormalParList();
1043 virtual void chk();
1044 private:
1045 void chk_modified();
1046 void chk_default() const;
1047 void chk_recursive_derivation();
1048 public:
1049 virtual void generate_code(output_struct *target, bool clean_up = false);
1050 virtual void generate_code(CodeGenHelper& cgh);
1051 virtual char* generate_code_str(char *str);
1052 virtual void ilt_generate_code(ILT *ilt);
1053 virtual void dump_internal(unsigned level) const;
1054 template_restriction_t get_template_restriction()
1055 { return template_restriction; }
1056 };
1057
1058 /**
1059 * Def_Var class represents a variable definition.
1060 */
1061 class Def_Var : public Definition {
1062 private:
1063 Type *type;
1064 /** the initial value: optional and maybe incomplete */
1065 Value *initial_value;
1066
1067 /// Copy constructor disabled
1068 Def_Var(const Def_Var& p);
1069 /// %Assignment disabled
1070 Def_Var& operator=(const Def_Var& p);
1071 public:
1072 Def_Var(Identifier *p_id, Type *p_type, Value *p_initial_value);
1073 virtual ~Def_Var();
1074 virtual Def_Var *clone() const;
1075 virtual void set_fullname(const string& p_fullname);
1076 virtual void set_my_scope(Scope *p_scope);
1077 virtual Type *get_Type();
1078 virtual void chk();
1079 virtual bool chk_identical(Definition *p_def);
1080 virtual void generate_code(output_struct *target, bool clean_up = false);
1081 virtual void generate_code(CodeGenHelper& cgh);
1082 virtual char* generate_code_str(char *str);
1083 virtual void ilt_generate_code(ILT *ilt);
1084 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1085 virtual void dump_internal(unsigned level) const;
1086 };
1087
1088 /**
1089 * Def_Var_Template class represents a template variable (dynamic template)
1090 * definition.
1091 */
1092 class Def_Var_Template : public Definition {
1093 private:
1094 Type *type;
1095 /** the initial value: optional and maybe incomplete */
1096 Template *initial_value;
1097 /** optional restriction on this variable */
1098 template_restriction_t template_restriction;
1099 /** set in chk(), used by code generation,
1100 * valid if template_restriction!=TR_NONE */
1101 bool gen_restriction_check;
1102
1103 /// Copy constructor disabled
1104 Def_Var_Template(const Def_Var_Template& p);
1105 /// %Assignment disabled
1106 Def_Var_Template& operator=(const Def_Var_Template& p);
1107 public:
1108 Def_Var_Template(Identifier *p_id, Type *p_type, Template *p_initial_value,
1109 template_restriction_t p_template_restriction);
1110 virtual ~Def_Var_Template();
1111 virtual Def_Var_Template *clone() const;
1112 virtual void set_fullname(const string& p_fullname);
1113 virtual void set_my_scope(Scope *p_scope);
1114 virtual Type *get_Type();
1115 virtual void chk();
1116 virtual bool chk_identical(Definition *p_def);
1117 virtual void generate_code(output_struct *target, bool clean_up = false);
1118 virtual void generate_code(CodeGenHelper& cgh);
1119 virtual char* generate_code_str(char *str);
1120 virtual void ilt_generate_code(ILT *ilt);
1121 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1122 virtual void dump_internal(unsigned level) const;
1123 template_restriction_t get_template_restriction()
1124 { return template_restriction; }
1125 };
1126
1127 /**
1128 * Def_Timer class represents a single timer declaration (e.g. in a
1129 * TTCN component type).
1130 */
1131 class Def_Timer : public Definition {
1132 private:
1133 /** Describes the dimensions of a timer array. It is NULL in case
1134 * of single timer instance. */
1135 ArrayDimensions *dimensions;
1136 /** Default duration of the timers. It can be either a single
1137 * float value or an array of floats. If it is NULL the timer(s)
1138 * has no default duration. */
1139 Value *default_duration;
1140
1141 /// Copy constructor disabled
1142 Def_Timer(const Def_Timer& p);
1143 /// %Assignment disabled
1144 Def_Timer& operator=(const Def_Timer& p);
1145 public:
1146 Def_Timer(Identifier *p_id, ArrayDimensions *p_dims, Value *p_dur)
1147 : Definition(A_TIMER, p_id), dimensions(p_dims),
1148 default_duration(p_dur) { }
1149 virtual ~Def_Timer();
1150 virtual Def_Timer *clone() const;
1151 virtual void set_fullname(const string& p_fullname);
1152 virtual void set_my_scope(Scope *p_scope);
1153 virtual ArrayDimensions *get_Dimensions();
1154 virtual void chk();
1155 virtual bool chk_identical(Definition *p_def);
1156 /** Returns false if it is sure that the timer referred by array
1157 * indices \a p_subrefs does not have a default
1158 * duration. Otherwise it returns true. Argument \a p_subrefs
1159 * might be NULL when examining a single timer. */
1160 bool has_default_duration(FieldOrArrayRefs *p_subrefs);
1161 private:
1162 /** Checks if the value \a dur is suitable as duration for a single
1163 * timer. */
1164 void chk_single_duration(Value *dur);
1165 /** Checks if the value \a dur is suitable as duration for a timer
1166 * array. The function calls itself recursively, argument \a
1167 * start_dim shall be zero when called from outside. */
1168 void chk_array_duration(Value *dur, size_t start_dim = 0);
1169 public:
1170 virtual void generate_code(output_struct *target, bool clean_up = false);
1171 virtual void generate_code(CodeGenHelper& cgh);
1172 private:
1173 /** Generates a C++ code fragment that sets the default duration
1174 * of a timer array. The generated code is appended to \a str and
1175 * the resulting string is returned. The equivalent C++ object of
1176 * timer array is named \a object_name, the array value containing
1177 * the default durations is \a dur. The function calls itself
1178 * recursively, argument \a start_dim shall be zero when called
1179 * from outside. */
1180 char *generate_code_array_duration(char *str, const char *object_name,
1181 Value *dur, size_t start_dim = 0);
1182 public:
1183 virtual char* generate_code_str(char *str);
1184 virtual void ilt_generate_code(ILT *ilt);
1185 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1186 virtual void dump_internal(unsigned level) const;
1187 };
1188
1189 /**
1190 * Def_Port class represents a port declaration (in a component type).
1191 */
1192 class Def_Port : public Definition {
1193 private:
1194 /** Contains a reference to a TTCN-3 port type */
1195 Reference *type_ref;
1196 /** Points to the object describing the port type.
1197 *
1198 * Derived from \a type_ref during Def_Port::chk().
1199 * It can be NULL in case of any error (e.g. the reference points to a
1200 * non-existent port type or the referenced entity is not a port type. */
1201 Type *port_type;
1202 /** Describes the dimensions of a port array.
1203 * It is NULL in case of single port instance. */
1204 ArrayDimensions *dimensions;
1205
1206 /// Copy constructor disabled
1207 Def_Port(const Def_Port& p);
1208 /// %Assignment disabled
1209 Def_Port& operator=(const Def_Port& p);
1210 public:
1211 /** Constructor
1212 *
1213 * @param p_id identifier (must not be NULL), the name of the port
1214 * @param p_tref type reference (must not be NULL)
1215 * @param p_dims array dimensions (NULL for a single port instance)
1216 */
1217 Def_Port(Identifier *p_id, Reference *p_tref, ArrayDimensions *p_dims);
1218 virtual ~Def_Port();
1219 virtual Def_Port *clone() const;
1220 virtual void set_fullname(const string& p_fullname);
1221 virtual void set_my_scope(Scope *p_scope);
1222 /** Get the \a port_type
1223 *
1224 * @pre chk() has been called (because it computes \a port_type)
1225 */
1226 virtual Type *get_Type();
1227 virtual ArrayDimensions *get_Dimensions();
1228 virtual void chk();
1229 virtual bool chk_identical(Definition *p_def);
1230 virtual void generate_code(output_struct *target, bool clean_up = false);
1231 virtual void generate_code(CodeGenHelper& cgh);
1232 virtual char *generate_code_init_comp(char *str, Definition *base_defn);
1233 virtual void dump_internal(unsigned level) const;
1234 };
1235
1236 /**
1237 * Common base class for function and external function definitions.
1238 */
1239 class Def_Function_Base : public Definition {
1240 public:
1241 enum prototype_t {
1242 PROTOTYPE_NONE, /**< no prototype(...) attribute */
1243 PROTOTYPE_CONVERT, /**< attribute prototype(convert) */
1244 PROTOTYPE_FAST, /**< attribute prototype(fast) */
1245 PROTOTYPE_BACKTRACK, /**< attribute prototype(backtrack) */
1246 PROTOTYPE_SLIDING /**< attribute prototype(sliding) */
1247 };
1248 protected: // Def_Function and Def_ExtFunction need access
1249 /** The formal parameter list of the function. It is never NULL even if
1250 * the function has empty parameter list. Owned. */
1251 FormalParList *fp_list;
1252 /** The return type of the function or NULL in case of no return type.
1253 * Owned. */
1254 Type *return_type;
1255 /** Identifier of the enc/dec API implemented by the function */
1256 prototype_t prototype;
1257 /** Shortcut to the input type if the function implements one of the
1258 * enc/dec APIs or NULL otherwise. Not owned. */
1259 Type *input_type;
1260 /** Shortcut to the output type if the function implements one of the
1261 * enc/dec APIs or NULL otherwise. Not owned */
1262 Type *output_type;
1263 /** optional template restriction on return template value */
1264 template_restriction_t template_restriction;
1265
1266 static asstype_t determine_asstype(bool is_external, bool has_return_type,
1267 bool returns_template);
1268 /// Copy constructor disabled
1269 Def_Function_Base(const Def_Function_Base& p);
1270 /// %Assignment disabled
1271 Def_Function_Base& operator=(const Def_Function_Base& p);
1272 public:
1273 /** Constructor.
1274 *
1275 * @param is_external true if external function (the derived type is
1276 * Def_ExtFunction), false if a TTCN-3 function (Def_Function)
1277 * @param p_id the name of the function
1278 * @param p_fpl formal parameter list
1279 * @param p_return_type return type (may be NULL)
1280 * @param returns_template true if the return is a template
1281 * @param p_template_restriction restriction type
1282 */
1283 Def_Function_Base(bool is_external, Identifier *p_id,
1284 FormalParList *p_fpl, Type *p_return_type, bool returns_template,
1285 template_restriction_t p_template_restriction);
1286 virtual ~Def_Function_Base();
1287 virtual void set_fullname(const string& p_fullname);
1288 virtual void set_my_scope(Scope *p_scope);
1289 virtual Type *get_Type();
1290 virtual FormalParList *get_FormalParList();
1291 prototype_t get_prototype() const { return prototype; }
1292 void set_prototype(prototype_t p_prototype) { prototype = p_prototype; }
1293 const char *get_prototype_name() const;
1294 void chk_prototype();
1295 Type *get_input_type();
1296 Type *get_output_type();
1297 template_restriction_t get_template_restriction()
1298 { return template_restriction; }
1299 };
1300
1301 /**
1302 * Def_Function class represents a function definition.
1303 */
1304 class Def_Function : public Def_Function_Base {
1305 private:
1306 /** The 'runs on' clause (i.e. a reference to a TTCN-3 component type)
1307 * It is NULL if the function has no 'runs on' clause. */
1308 Reference *runs_on_ref;
1309 /** Points to the object describing the component type referred by
1310 * 'runs on' clause.
1311 * It is NULL if the function has no 'runs on' clause or \a runs_on_ref is
1312 * erroneous. */
1313 Type *runs_on_type;
1314 /** The body of the function */
1315 StatementBlock *block;
1316 /** Indicates whether the function is startable. That is, it can be
1317 * launched as PTC behaviour as argument of a start test component
1318 * statement. */
1319 bool is_startable;
1320 /** Opts out from location information */
1321 bool transparent;
1322
1323 NameBridgingScope bridgeScope;
1324
1325 /// Copy constructor disabled
1326 Def_Function(const Def_Function& p);
1327 /// %Assignment disabled
1328 Def_Function& operator=(const Def_Function& p);
1329 public:
1330 /** Constructor for a TTCN-3 function definition
1331 *
1332 * Called from a single location in compiler.y
1333 *
1334 * @param p_id function name
1335 * @param p_fpl formal parameter list
1336 * @param p_runs_on_ref "runs on", else NULL
1337 * @param p_return_type return type, may be NULL
1338 * @param returns_template true if the return value is a template
1339 * @param p_template_restriction restriction type
1340 * @param p_block the body of the function
1341 */
1342 Def_Function(Identifier *p_id, FormalParList *p_fpl,
1343 Reference *p_runs_on_ref, Type *p_return_type,
1344 bool returns_template,
1345 template_restriction_t p_template_restriction,
1346 StatementBlock *p_block);
1347 virtual ~Def_Function();
1348 virtual Def_Function *clone() const;
1349 virtual void set_fullname(const string& p_fullname);
1350 virtual void set_my_scope(Scope *p_scope);
1351 virtual Type *get_RunsOnType();
1352 /** Returns a scope that can access the definitions within component type
1353 * \a comptype and its parent is \a parent_scope.*/
1354 RunsOnScope *get_runs_on_scope(Type *comptype);
1355 virtual void chk();
1356 /** Checks and returns whether the function is startable.
1357 * Reports the appropriate error message(s) if not. */
1358 bool chk_startable();
1359
1360 bool is_transparent() const { return transparent; }
1361
1362 virtual void generate_code(output_struct *target, bool clean_up = false);
1363 virtual void generate_code(CodeGenHelper& cgh);
1364 virtual void dump_internal(unsigned level) const;
1365
1366 virtual void set_parent_path(WithAttribPath* p_path);
1367 };
1368
1369 /** RAII class for transparent functions.
1370 *
1371 * Calls to TTCN_Location::update_lineno are written by Ttcn::Statement
1372 * by calling Common::Location::update_location_object. These calls
1373 * need to be removed inside transparent functions.
1374 *
1375 * It is difficult (impossible) for a Statement to navigate up in the AST
1376 * to the function/altstep/testcase/control part that contains it;
1377 * instead, the Def_Function sets a static flag inside Common::Location
1378 * that says "you are inside a transparent function" while
1379 * Def_Function::generate_code function runs.
1380 */
1381 class transparency_holder {
1382 bool old_transparency;
1383 public:
1384 /** Sets Common::Location::transparency (but remembers its old vaue)
1385 *
1386 * @param df the function definition
1387 */
1388 transparency_holder(const Def_Function &df)
1389 : old_transparency(Common::Location::transparency)
1390 { Common::Location::transparency = df.is_transparent(); }
1391
1392 /** Restores the value of Common::Location::transparency */
1393 ~transparency_holder()
1394 { Common::Location::transparency = old_transparency; }
1395 };
1396
1397 /**
1398 * Def_ExtFunction class represents an external function definition.
1399 */
1400 class Def_ExtFunction : public Def_Function_Base {
1401 public:
1402 enum ExternalFunctionType_t {
1403 EXTFUNC_MANUAL, /**< written manually by the user */
1404 EXTFUNC_ENCODE, /**< automatically generated encoder function */
1405 EXTFUNC_DECODE /**< automatically generated decoder function */
1406 };
1407 private:
1408 ExternalFunctionType_t function_type;
1409 Type::MessageEncodingType_t encoding_type;
1410 string *encoding_options;
1411 Ttcn::ErrorBehaviorList *eb_list;
1412 Ttcn::PrintingType *json_printing;
1413 /// Copy constructor disabled
1414 Def_ExtFunction(const Def_ExtFunction& p);
1415 /// %Assignment disabled
1416 Def_ExtFunction& operator=(const Def_ExtFunction& p);
1417 public:
1418 /** Constructor for an external function definition
1419 *
1420 * Called from a single location in compiler.y
1421 *
1422 * @param p_id the name
1423 * @param p_fpl formal parameters
1424 * @param p_return_type the return type
1425 * @param returns_template true if it returns a template
1426 * @param p_template_restriction restriction type
1427 */
1428 Def_ExtFunction(Identifier *p_id, FormalParList *p_fpl,
1429 Type *p_return_type, bool returns_template,
1430 template_restriction_t p_template_restriction)
1431 : Def_Function_Base(true, p_id, p_fpl, p_return_type, returns_template,
1432 p_template_restriction),
1433 function_type(EXTFUNC_MANUAL), encoding_type(Type::CT_UNDEF),
1434 encoding_options(0), eb_list(0), json_printing(0) { }
1435 ~Def_ExtFunction();
1436 virtual Def_ExtFunction *clone() const;
1437 virtual void set_fullname(const string& p_fullname);
1438 void set_encode_parameters(Type::MessageEncodingType_t p_encoding_type,
1439 string *p_encoding_options);
1440 void set_decode_parameters(Type::MessageEncodingType_t p_encoding_type,
1441 string *p_encoding_options);
1442 void add_eb_list(Ttcn::ErrorBehaviorList *p_eb_list);
1443 ExternalFunctionType_t get_function_type() const { return function_type; }
1444 private:
1445 void chk_function_type();
1446 void chk_allowed_encode();
1447 public:
1448 virtual void chk();
1449 private:
1450 char *generate_code_encode(char *str);
1451 char *generate_code_decode(char *str);
1452 public:
1453 virtual void generate_code(output_struct *target, bool clean_up = false);
1454 /// Just a shim for code splitting
1455 virtual void generate_code(CodeGenHelper& cgh);
1456 virtual void dump_internal(unsigned level) const;
1457
1458 /** For JSON encoding and decoding functions only
1459 * Generates a JSON schema segment containing a reference to the encoded
1460 * type's schema and any information required to recreate this function.
1461 * If the schema with the reference already exists, the function's info is
1462 * inserted in the schema. */
1463 void generate_json_schema_ref(map<Type*, JSON_Tokenizer>& json_refs);
1464 };
1465
1466 /**
1467 * Represents an altstep definition.
1468 */
1469 class Def_Altstep : public Definition {
1470 private:
1471 /** The formal parameter list of the altstep. It is never NULL even if
1472 * the altstep has no parameters. */
1473 FormalParList *fp_list;
1474 /** The 'runs on' clause (i.e. a reference to a TTCN-3 component type)
1475 * It is NULL if the altstep has no 'runs on' clause. */
1476 Reference *runs_on_ref;
1477 /** Points to the object describing the component type referred by
1478 * 'runs on' clause.
1479 * It is NULL if the altstep has no 'runs on' clause or \a runs_on_ref is
1480 * erroneous. */
1481 Type *runs_on_type;
1482 StatementBlock *sb; /**< contains the local definitions */
1483 AltGuards *ags;
1484
1485 NameBridgingScope bridgeScope;
1486
1487 /// Copy constructor disabled
1488 Def_Altstep(const Def_Altstep& p);
1489 /// %Assignment disabled
1490 Def_Altstep& operator=(const Def_Altstep& p);
1491 public:
1492 Def_Altstep(Identifier *p_id, FormalParList *p_fpl,
1493 Reference *p_runs_on_ref, StatementBlock *p_sb,
1494 AltGuards *p_ags);
1495 virtual ~Def_Altstep();
1496 virtual Def_Altstep *clone() const;
1497 virtual void set_fullname(const string& p_fullname);
1498 virtual void set_my_scope(Scope *p_scope);
1499 virtual Type *get_RunsOnType();
1500 virtual FormalParList *get_FormalParList();
1501 /** Returns a scope that can access the definitions within component type
1502 * \a comptype and its parent is \a parent_scope.*/
1503 RunsOnScope *get_runs_on_scope(Type *comptype);
1504 virtual void chk();
1505 virtual void generate_code(output_struct *target, bool clean_up = false);
1506 virtual void generate_code(CodeGenHelper& cgh);
1507 virtual void dump_internal(unsigned level) const;
1508
1509 virtual void set_parent_path(WithAttribPath* p_path);
1510 };
1511
1512 /**
1513 * Represents an testcase definition.
1514 */
1515 class Def_Testcase : public Definition {
1516 private:
1517 /** The formal parameter list of the testcase. It is never NULL even if
1518 * the testcase has no parameters. */
1519 FormalParList *fp_list;
1520 /** The 'runs on' clause (i.e. a reference to a TTCN-3 component type)
1521 * It is never NULL. */
1522 Reference *runs_on_ref;
1523 /** Points to the object describing the component type referred by
1524 * 'runs on' clause. It is NULL only if \a runs_on_ref is erroneous. */
1525 Type *runs_on_type;
1526 /** The 'system' clause (i.e. a reference to a TTCN-3 component type)
1527 * It is NULL if the testcase has no 'system' clause. */
1528 Reference *system_ref;
1529 /** Points to the object describing the component type referred by
1530 * 'system' clause. It is NULL if the testcase has no 'system' clause or
1531 * \a system_ref is erroneous. */
1532 Type *system_type;
1533 StatementBlock *block;
1534
1535 NameBridgingScope bridgeScope;
1536
1537 /// Copy constructor disabled
1538 Def_Testcase(const Def_Testcase& p);
1539 /// %Assignment disabled
1540 Def_Testcase& operator=(const Def_Testcase& p);
1541 public:
1542 Def_Testcase(Identifier *p_id, FormalParList *p_fpl,
1543 Reference *p_runs_on_ref, Reference *p_system_ref,
1544 StatementBlock *p_block);
1545 virtual ~Def_Testcase();
1546 virtual Def_Testcase *clone() const;
1547 virtual void set_fullname(const string& p_fullname);
1548 virtual void set_my_scope(Scope *p_scope);
1549 virtual Type *get_RunsOnType();
1550 Type *get_SystemType();
1551 virtual FormalParList *get_FormalParList();
1552 /** Returns a scope that can access the definitions within component type
1553 * \a comptype and its parent is \a parent_scope.*/
1554 RunsOnScope *get_runs_on_scope(Type *comptype);
1555 virtual void chk();
1556 virtual void generate_code(output_struct *target, bool clean_up = false);
1557 virtual void generate_code(CodeGenHelper& cgh);
1558 virtual void dump_internal(unsigned level) const;
1559
1560 virtual void set_parent_path(WithAttribPath* p_path);
1561 };
1562
1563 /** General class to represent formal parameters. The inherited
1564 * attribute asstype carries the kind and direction of the
1565 * parameter. */
1566 class FormalPar : public Definition {
1567 private:
1568 Type *type;
1569 /** Default value of the parameter (optional). If \a checked flag is true
1570 * then field \a ap is used otherwise \a ti is active. */
1571 union {
1572 TemplateInstance *ti;
1573 ActualPar *ap;
1574 } defval;
1575 /** Points to the formal parameter list that \a this belongs to. */
1576 FormalParList *my_parlist;
1577 /** Flag that indicates whether the value of the parameter is overwritten
1578 * within the function/altstep/testcase body.
1579 * Used only in case of `in' value or template parameters. */
1580 bool used_as_lvalue;
1581 /** restriction on template value */
1582 template_restriction_t template_restriction;
1583 /** normal or lazy evaluation parametrization should be used */
1584 bool lazy_eval;
1585
1586 /// Copy constructor disabled
1587 FormalPar(const FormalPar& p);
1588 /// %Assignment disabled
1589 FormalPar& operator=(const FormalPar& p);
1590 public:
1591 FormalPar(asstype_t p_asstype, Type *p_type, Identifier* p_name,
1592 TemplateInstance *p_defval, bool p_lazy_eval=false);
1593 FormalPar(asstype_t p_asstype,
1594 template_restriction_t p_template_restriction,
1595 Type *p_type, Identifier* p_name, TemplateInstance *p_defval,
1596 bool p_lazy_eval=false);
1597 FormalPar(asstype_t p_asstype, Identifier* p_name,
1598 TemplateInstance *p_defval);
1599 ~FormalPar();
1600 virtual FormalPar *clone() const;
1601 virtual void set_fullname(const string& p_fullname);
1602 virtual void set_my_scope(Scope *p_scope);
1603 /** Always true. Formal parameters are considered as local definitions
1604 * even if their scope is the module definitions. */
1605 virtual bool is_local() const;
1606 virtual Type *get_Type();
1607 virtual void chk();
1608 bool has_defval() const;
1609 bool has_notused_defval() const;
1610 /** Get the default value.
1611 * \pre chk() has been called (checked==true) */
1612 ActualPar *get_defval() const;
1613 void set_defval(ActualPar *defpar);
1614 void set_my_parlist(FormalParList *p_parlist) { my_parlist = p_parlist; }
1615 FormalParList *get_my_parlist() const { return my_parlist; }
1616 ActualPar *chk_actual_par(TemplateInstance *actual_par,
1617 Type::expected_value_t exp_val);
1618 private:
1619 ActualPar *chk_actual_par_value(TemplateInstance *actual_par,
1620 Type::expected_value_t exp_val);
1621 ActualPar *chk_actual_par_template(TemplateInstance *actual_par,
1622 Type::expected_value_t exp_val);
1623 ActualPar *chk_actual_par_by_ref(TemplateInstance *actual_par,
1624 bool is_template, Type::expected_value_t exp_val);
1625 ActualPar *chk_actual_par_timer(TemplateInstance *actual_par,
1626 Type::expected_value_t exp_val);
1627 ActualPar *chk_actual_par_port(TemplateInstance *actual_par,
1628 Type::expected_value_t exp_val);
1629 public:
1630 /** Checks whether the value of the parameter may be modified in the body
1631 * of the parameterized definition (in assignment, port redirect or passing
1632 * it further as 'out' or 'inout' parameter). Applicable to `in' value or
1633 * template parameters only. Note that formal parameters of templates cannot
1634 * be modified. If the modification is allowed a flag is set, which is
1635 * considered at C++ code generation. Argument \a p_loc is used for error
1636 * reporting. */
1637 virtual void use_as_lvalue(const Location& p_loc);
1638 bool get_used_as_lvalue() const { return used_as_lvalue; }
1639 /** Generates the C++ objects that represent the default value for the
1640 * parameter (if present). */
1641 virtual void generate_code_defval(output_struct *target, bool clean_up = false);
1642 /** Generates the C++ equivalent of the formal parameter, appends it to
1643 * \a str and returns the resulting string. */
1644 char *generate_code_fpar(char *str);
1645 /** Generates a C++ statement that defines an object (variable) for the
1646 * formal parameter, appends it to \a str and returns the resulting
1647 * string. The name of the object is constructed from \a p_prefix and the
1648 * parameter identifier.
1649 * The \a refch parameter is needed when the code for start_ptc_function is
1650 * generated, because reference is generated in case of inout parameters. */
1651 char *generate_code_object(char *str, const char *p_prefix,
1652 char refch = '&');
1653 /** Generates a C++ statement that instantiates a shadow object for the
1654 * parameter when necessary. It is used when the value of an 'in' value or
1655 * template parameter is overwritten within the function body. */
1656 char *generate_shadow_object(char *str) const;
1657 /** Generates a C++ statement that calls a function that sets the parameter unbound
1658 * It is used when the value of an 'out' value */
1659 char *generate_code_set_unbound(char *str) const;
1660 virtual void dump_internal(unsigned level) const;
1661 template_restriction_t get_template_restriction()
1662 { return template_restriction; }
1663 virtual bool get_lazy_eval() const { return lazy_eval; }
1664 // code generation: get the C++ string that refers to the formal parameter
1665 // adds a casting to data type if wrapped into a lazy param
1666 string get_reference_name(Scope* scope) const;
1667 };
1668
1669 /** Class to represent a list of formal parameters. Owned by a
1670 * Def_Template, Def_Function_Base, Def_Altstep or Def_Testcase. */
1671 class FormalParList : public Scope, public Location {
1672 private:
1673 vector<FormalPar> pars_v;
1674 /** Map names to the formal parameters in pars_v. Filled by
1675 * FormalParList::chk*/
1676 map<string, FormalPar> pars_m;
1677 /** Indicates the minimal number of actual parameters that must be present
1678 * in parameterized references. Could be less than the size of pars_v
1679 * if some parameters have default values. */
1680 size_t min_nof_pars;
1681 /** Points to the definition that the parameter list belongs to. */
1682 Definition *my_def;
1683 bool checked;
1684 bool is_startable;
1685
1686 /** Copy constructor. For FormalParList::clone() only. */
1687 FormalParList(const FormalParList& p);
1688 /** %Assignment disallowed. */
1689 FormalParList& operator=(const FormalParList& p);
1690 public:
1691 FormalParList() : Scope(), Location(), pars_v(), pars_m()
1692 , min_nof_pars(0), my_def(0), checked(false), is_startable(false) {}
1693 ~FormalParList();
1694 virtual FormalParList *clone() const;
1695 virtual void set_fullname(const string& p_fullname);
1696 /** Sets the parent scope and the scope of parameters to \a p_scope. */
1697 virtual void set_my_scope(Scope *p_scope);
1698 void set_my_def(Definition *p_def) { my_def = p_def; }
1699 Definition *get_my_def() const { return my_def; }
1700 void add_fp(FormalPar *p_fp);
1701 size_t get_nof_fps() const { return pars_v.size(); }
1702 bool has_notused_defval() const;
1703 bool has_only_default_values() const;
1704 bool has_fp_withName(const Identifier& p_name);
1705 FormalPar *get_fp_byName(const Identifier& p_name);
1706 FormalPar *get_fp_byIndex(size_t n) const { return pars_v[n]; }
1707 bool get_startability();
1708 virtual Common::Assignment *get_ass_bySRef(Common::Ref_simple *p_ref);
1709 virtual bool has_ass_withId(const Identifier& p_id);
1710 /** Checks the parameter list, which belongs to definition of type
1711 * \a deftype. */
1712 void chk(Definition::asstype_t deftype);
1713 void chk_noLazyParams();
1714 /** Checks the parameter list for startability: reports error if the owner
1715 * function cannot be started on a PTC. Used by functions and function
1716 * types. Parameter \a p_what shall contain "Function" or "Function type",
1717 * \a p_name shall contain the name of the function or function type. */
1718 void chk_startability(const char *p_what, const char *p_name);
1719 /** Checks the compatibility of two formal parameter list.
1720 * They are compatible if every parameter is compatible, has the same
1721 * attribute, and name */
1722 void chk_compatibility(FormalParList* p_fp_list, const char* where);
1723 /** Checks the parsed actual parameters in \a p_tis against \a this.
1724 * The actual parameters that are the result of transformation are added to
1725 * \a p_aplist (which is usually empty when this function is called).
1726 * \return true in case of any error, false after a successful check. */
1727 bool chk_actual_parlist(TemplateInstances *p_tis, ActualParList *p_aplist);
1728 /** Fold named parameters into the unnamed (order-based) param list.
1729 *
1730 * Named parameters are checked against the formal parameters.
1731 * Found ones are transferred into the unnamed param list at the
1732 * appropriate index.
1733 *
1734 * @param p_paps actual parameters from the parser (Bison); contains
1735 * both named and unnamed parameters
1736 * @param p_aplist actual parameters
1737 * @return the result of calling chk_actual_parlist, above:
1738 * true if error, false if the check is successful
1739 */
1740 bool fold_named_and_chk(ParsedActualParameters *p_paps, ActualParList *p_aplist);
1741 bool chk_activate_argument(ActualParList *p_aplist,
1742 const char* p_description);
1743 void set_genname(const string& p_prefix);
1744 /** Generates the C++ equivalent of the formal parameter list, appends it
1745 * to \a str and returns the resulting string. */
1746 char *generate_code(char *str);
1747 /** Generates the C++ objects that represent the default values for the
1748 * parameters (if present). */
1749 void generate_code_defval(output_struct *target);
1750 /** Generates a C++ actual parameter list for wrapper functions, appends it
1751 * to \a str and returns the resulting string. It contains the
1752 * comma-separated list of parameter identifiers prefixed by \a p_prefix. */
1753 char *generate_code_actual_parlist(char *str, const char *p_prefix);
1754 /** Generates a C++ code sequence that defines an object (variable) for
1755 * each formal parameter (which is used in wrapper functions), appends it
1756 * to \a str and returns the resulting string. The name of each object is
1757 * constructed from \a p_prefix and the parameter identifier.
1758 * The \a refch parameter is needed when the code for start_ptc_function is
1759 * generated, because reference is generated in case of inout parameters. */
1760 char *generate_code_object(char *str, const char *p_prefix,
1761 char refch = '&');
1762 /** Generates the C++ shadow objects for all parameters. */
1763 char *generate_shadow_objects(char *str) const;
1764 char *generate_code_set_unbound(char *str) const;
1765 void dump(unsigned level) const;
1766 };
1767
1768} // namespace Ttcn
1769
1770#endif // _Ttcn_AST_HH
This page took 0.180685 seconds and 5 git commands to generate.