author | Mario de Sousa <msousa@fe.up.pt> |
Fri, 10 Jun 2011 10:13:15 +0100 | |
changeset 323 | d3f2ef59b310 |
parent 279 | c0453b7f99df |
child 706 | 31553c22f318 |
permissions | -rwxr-xr-x |
181 | 1 |
/* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
181 | 3 |
* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
4 |
* Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
279
c0453b7f99df
Re-generated std lib related code, with updated headers, updated all forgotten headers
Edouard Tisserant
parents:
265
diff
changeset
|
5 |
* Copyright (C) 2007-2011 Laurent Bessard and Edouard Tisserant |
181 | 6 |
* |
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
7 |
* This program is free software: you can redistribute it and/or modify |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
8 |
* it under the terms of the GNU General Public License as published by |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
9 |
* the Free Software Foundation, either version 3 of the License, or |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
10 |
* (at your option) any later version. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
11 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
15 |
* GNU General Public License for more details. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
16 |
* |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
19 |
* |
181 | 20 |
* |
21 |
* This code is made available on the understanding that it will not be |
|
22 |
* used in safety-critical situations without a full and competent review. |
|
23 |
*/ |
|
24 |
||
25 |
/* |
|
265
4d222f46f8cc
Updating license info (with Edouard's permission for relevant files).
Mario de Sousa <msousa@fe.up.pt>
parents:
181
diff
changeset
|
26 |
* An IEC 61131-3 compiler. |
181 | 27 |
* |
28 |
* Based on the |
|
29 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
|
30 |
* |
|
31 |
*/ |
|
32 |
||
33 |
||
34 |
||
35 |
/* Returns the function block type declaration |
|
36 |
* of a specific function block instance. |
|
37 |
*/ |
|
38 |
||
39 |
||
40 |
||
41 |
/* Returns the type name of a specific function block |
|
42 |
* instance. This class will search the variable |
|
43 |
* declarations inside the scope given to it |
|
44 |
* searching for the declaration of the function |
|
45 |
* block instance. |
|
46 |
* |
|
47 |
* The class constructor must be given the search scope |
|
48 |
* (function, function block or program within which |
|
49 |
* the function block instance was declared). |
|
50 |
* |
|
51 |
* This class will search the tree from the root given to the |
|
52 |
* constructor. Another option would be to build a symbol table, |
|
53 |
* and search that instead. Building the symbol table would be done |
|
54 |
* while visiting the variable declaration objects in the parse |
|
55 |
* tree. Unfortuantely, generate_c_c does not visit these |
|
56 |
* objects, delegating it to another class. This means that |
|
57 |
* we would need another specialised class just to build the |
|
58 |
* symbol table. We might just as well have a specialised class |
|
59 |
* that searches the tree itself for the relevant info. This |
|
60 |
* class is exactly that...! |
|
61 |
*/ |
|
62 |
||
63 |
||
64 |
class search_fb_instance_decl_c: public search_visitor_c { |
|
65 |
||
66 |
private: |
|
67 |
symbol_c *search_scope; |
|
68 |
||
69 |
symbol_c *search_name; |
|
70 |
symbol_c *current_fb_type_name; |
|
71 |
||
72 |
public: |
|
73 |
search_fb_instance_decl_c(symbol_c *search_scope); |
|
74 |
symbol_c *get_type_name(symbol_c *fb_instance_name); |
|
75 |
||
76 |
public: |
|
77 |
/***************************/ |
|
78 |
/* B 0 - Programming Model */ |
|
79 |
/***************************/ |
|
80 |
void *visit(library_c *symbol); |
|
81 |
||
82 |
/******************************************/ |
|
83 |
/* B 1.4.3 - Declaration & Initialisation */ |
|
84 |
/******************************************/ |
|
85 |
||
86 |
/* name_list ':' function_block_type_name ASSIGN structure_initialization */ |
|
87 |
/* structure_initialization -> may be NULL ! */ |
|
88 |
void *visit(fb_name_decl_c *symbol); |
|
89 |
/* name_list ',' fb_name */ |
|
90 |
void *visit(fb_name_list_c *symbol); |
|
91 |
||
92 |
/**************************************/ |
|
93 |
/* B.1.5 - Program organization units */ |
|
94 |
/**************************************/ |
|
95 |
/***********************/ |
|
96 |
/* B 1.5.1 - Functions */ |
|
97 |
/***********************/ |
|
98 |
void *visit(function_declaration_c *symbol); |
|
99 |
||
100 |
/*****************************/ |
|
101 |
/* B 1.5.2 - Function Blocks */ |
|
102 |
/*****************************/ |
|
103 |
void *visit(function_block_declaration_c *symbol); |
|
104 |
||
105 |
/**********************/ |
|
106 |
/* B 1.5.3 - Programs */ |
|
107 |
/**********************/ |
|
108 |
void *visit(program_declaration_c *symbol); |
|
109 |
}; // search_fb_instance_decl_c |
|
110 |
||
111 |
||
112 |
||
113 |