author | mjsousa |
Sun, 16 Feb 2014 14:27:06 +0000 | |
changeset 868 | 23f271534a7c |
parent 812 | 6679b6b21214 |
child 962 | 98e7a0d3af21 |
permissions | -rw-r--r-- |
656
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
1 |
/* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
3 |
* |
658
fe5e1f01a49e
store POU reference to POU declaration instead of global var declarations.
Mario de Sousa <msousa@fe.up.pt>
parents:
656
diff
changeset
|
4 |
* Copyright (C) 2003-2012 Mario de Sousa (msousa@fe.up.pt) |
656
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
5 |
* Copyright (C) 2012 Manuele Conti (conti.ma@alice.it) |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
6 |
* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
7 |
* This program is free software: you can redistribute it and/or modify |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
8 |
* it under the terms of the GNU General Public License as published by |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
9 |
* the Free Software Foundation, either version 3 of the License, or |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
10 |
* (at your option) any later version. |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
11 |
* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
12 |
* This program is distributed in the hope that it will be useful, |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
15 |
* GNU General Public License for more details. |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
16 |
* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
19 |
* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
20 |
* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
21 |
* This code is made available on the understanding that it will not be |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
22 |
* used in safety-critical situations without a full and competent review. |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
23 |
*/ |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
24 |
|
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
25 |
/* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
26 |
* An IEC 61131-3 compiler. |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
27 |
* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
28 |
* Based on the |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
29 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
30 |
* |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
31 |
*/ |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
32 |
|
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
33 |
#include <vector> |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
34 |
|
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
35 |
#include "../absyntax_utils/absyntax_utils.hh" |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
36 |
|
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
37 |
|
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
38 |
class declaration_check_c : public iterator_visitor_c { |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
39 |
int error_count; |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
40 |
int current_display_error_level; |
658
fe5e1f01a49e
store POU reference to POU declaration instead of global var declarations.
Mario de Sousa <msousa@fe.up.pt>
parents:
656
diff
changeset
|
41 |
symbol_c *current_pou_decl; |
812
6679b6b21214
Partial fix to VAR_EXTERN vs VAR_GLOBAL check. Now considers globals declared in resources too. TODO: recursively check FB declared in the program.
Mario de Sousa <msousa@fe.up.pt>
parents:
718
diff
changeset
|
42 |
symbol_c *current_resource_decl; |
656
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
43 |
|
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
44 |
public: |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
45 |
declaration_check_c(symbol_c *ignore); |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
46 |
virtual ~declaration_check_c(void); |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
47 |
int get_error_count(); |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
48 |
|
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
49 |
void check_global_decl(symbol_c *p_decl); |
660
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
50 |
|
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
51 |
/*****************************/ |
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
52 |
/* B 1.5.2 - Function Blocks */ |
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
53 |
/*****************************/ |
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
54 |
void *visit(function_block_declaration_c *symbol); |
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
55 |
|
656
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
56 |
/******************************************/ |
658
fe5e1f01a49e
store POU reference to POU declaration instead of global var declarations.
Mario de Sousa <msousa@fe.up.pt>
parents:
656
diff
changeset
|
57 |
/* B 1.5.3 - Declaration & Initialisation */ |
656
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
58 |
/******************************************/ |
658
fe5e1f01a49e
store POU reference to POU declaration instead of global var declarations.
Mario de Sousa <msousa@fe.up.pt>
parents:
656
diff
changeset
|
59 |
void *visit(program_declaration_c *symbol); |
660
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
60 |
|
656
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
61 |
/********************************/ |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
62 |
/* B 1.7 Configuration elements */ |
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
63 |
/********************************/ |
660
9565d7d944ce
Also check external/global variable consistency in configurations and FBs.
Mario de Sousa <msousa@fe.up.pt>
parents:
658
diff
changeset
|
64 |
void *visit(configuration_declaration_c *symbol); |
812
6679b6b21214
Partial fix to VAR_EXTERN vs VAR_GLOBAL check. Now considers globals declared in resources too. TODO: recursively check FB declared in the program.
Mario de Sousa <msousa@fe.up.pt>
parents:
718
diff
changeset
|
65 |
void *visit(resource_declaration_c *symbol); |
6679b6b21214
Partial fix to VAR_EXTERN vs VAR_GLOBAL check. Now considers globals declared in resources too. TODO: recursively check FB declared in the program.
Mario de Sousa <msousa@fe.up.pt>
parents:
718
diff
changeset
|
66 |
void *visit(program_configuration_c *symbol); |
656
45a796bce487
Start declaration check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
67 |
}; |