Debugger - Stage 1 (artf511247)
[deliverable/titan.core.git] / compiler2 / CodeGenHelper.hh
1 /******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 * Balasko, Jeno
10 * Raduly, Csaba
11 * Zalanyi, Balazs Andor
12 *
13 ******************************************************************************/
14 #ifndef _Common_CodeGenHelper_HH
15 #define _Common_CodeGenHelper_HH
16
17 #include "ttcn3/compiler.h"
18 #include "map.hh"
19 #include "vector.hh"
20 #include "string.hh"
21 #include "ttcn3/AST_ttcn3.hh"
22 #include "Type.hh"
23
24 namespace Ttcn {
25 class Definition;
26 }
27
28 namespace Common {
29
30 class CodeGenHelper {
31 public:
32 enum split_type {
33 SPLIT_NONE, ///< original code generation
34 SPLIT_BY_KIND, ///< place different kind of types in their own file
35 SPLIT_BY_NAME, ///< place all definitions/assignments in their own file
36 SPLIT_BY_HEURISTICS ///< heuristic function will decide the structure
37 };
38
39 private:
40 struct generated_output_t {
41
42 generated_output_t();
43 ~generated_output_t();
44
45 output_struct os;
46 string modulename;
47 string module_dispname;
48 string filename;
49 bool is_module;
50 bool is_ttcn;
51 bool has_circular_import;
52 };
53
54 static const char* const typetypemap[];
55
56 typedef map<string, generated_output_t> output_map_t;
57
58 output_map_t generated_code;
59 split_type split_mode;
60
61 struct module_names_t {
62 string name;
63 string dispname;
64 };
65
66 vector<module_names_t> modules;
67 string current_module;
68
69 static CodeGenHelper* instance;
70
71 public:
72 CodeGenHelper();
73
74 static CodeGenHelper& GetInstance();
75
76 void set_split_mode(split_type st);
77 bool set_split_mode(const char* type);
78 split_type get_split_mode() const;
79
80 void add_module(const string& name, const string& dispname, bool is_ttcn,
81 bool has_circular_import);
82 output_struct* get_outputstruct(const string& name);
83 output_struct* get_outputstruct(Ttcn::Definition* def);
84 output_struct* get_outputstruct(Type* type);
85 output_struct* get_current_outputstruct();
86 void finalize_generation(Type* type);
87
88 void set_current_module(const string& name);
89
90 void write_output();
91
92 ~CodeGenHelper();
93
94 private:
95 string get_key(Ttcn::Definition& def) const;
96 string get_key(Type& type) const;
97 static void transfer_value(char* &dst, char* &src);
98 };
99
100 }
101
102 #endif /* _Common_CodeGenHelper_HH */
This page took 0.034434 seconds and 5 git commands to generate.