author | Manuele conti <conti.ma@alice.it> |
Tue, 12 Jun 2012 09:45:31 +0200 | |
changeset 582 | 8495119e7271 |
parent 581 | 1e158dc9f9c1 |
child 592 | 99a284cec1f2 |
permissions | -rw-r--r-- |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
1 |
/* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
3 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
4 |
* Copyright (C) 2009-2012 Mario de Sousa (msousa@fe.up.pt) |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
5 |
* Copyright (C) 2012 Manuele Conti (conti.ma@alice.it) |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
6 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
7 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
8 |
* This program is free software: you can redistribute it and/or modify |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
9 |
* it under the terms of the GNU General Public License as published by |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
11 |
* (at your option) any later version. |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
12 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
13 |
* This program is distributed in the hope that it will be useful, |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
16 |
* GNU General Public License for more details. |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
17 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
20 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
21 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
22 |
* This code is made available on the understanding that it will not be |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
23 |
* used in safety-critical situations without a full and competent review. |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
24 |
*/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
25 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
26 |
/* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
27 |
* An IEC 61131-3 compiler. |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
28 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
29 |
* Based on the |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
30 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
31 |
* |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
32 |
*/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
33 |
|
560
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
34 |
// #include <vector> |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
35 |
#include "../absyntax_utils/absyntax_utils.hh" |
560
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
36 |
// #include "datatype_functions.hh" |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
37 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
38 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
39 |
|
560
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
40 |
class array_range_check_c: public iterator_visitor_c { |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
41 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
42 |
private: |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
43 |
search_varfb_instance_type_c *search_varfb_instance_type; |
560
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
44 |
// search_var_instance_decl_c *search_var_instance_decl; |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
45 |
search_base_type_c search_base_type; |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
46 |
int error_count; |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
47 |
int current_display_error_level; |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
48 |
|
560
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
49 |
void check_dimension_count(array_variable_c *symbol); |
581
1e158dc9f9c1
Add check array out of bound.
Manuele Conti <conti.ma@alice.it>
parents:
560
diff
changeset
|
50 |
void check_bounds(array_variable_c *symbol); |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
51 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
52 |
public: |
560
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
53 |
array_range_check_c(symbol_c *ignore); |
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
54 |
virtual ~array_range_check_c(void); |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
55 |
int get_error_count(); |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
56 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
57 |
/*********************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
58 |
/* B 1.4 - Variables */ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
59 |
/*********************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
60 |
/*************************************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
61 |
/* B 1.4.2 - Multi-element variables */ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
62 |
/*************************************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
63 |
void *visit(array_variable_c *symbol); |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
64 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
65 |
/**************************************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
66 |
/* B 1.5 - Program organisation units */ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
67 |
/**************************************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
68 |
/***********************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
69 |
/* B 1.5.1 - Functions */ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
70 |
/***********************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
71 |
void *visit(function_declaration_c *symbol); |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
72 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
73 |
/*****************************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
74 |
/* B 1.5.2 - Function blocks */ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
75 |
/*****************************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
76 |
void *visit(function_block_declaration_c *symbol); |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
77 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
78 |
/**********************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
79 |
/* B 1.5.3 - Programs */ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
80 |
/**********************/ |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
81 |
void *visit(program_declaration_c *symbol); |
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
82 |
|
560
13b5b7faa3d7
Renamed class, remove unused code, delete allocated objects.
mjsousa <msousa@fe.up.pt>
parents:
559
diff
changeset
|
83 |
}; /* array_range_check_c */ |
559
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
84 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
85 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
86 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
87 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
88 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
89 |
|
a3b8925e640c
Start sematinc range check class.
Manuele Conti <conti.ma@alice.it>
parents:
diff
changeset
|
90 |