author | Manuele Conti <conti.ma@alice.it> |
Sun, 10 Jun 2012 21:28:21 +0200 | |
changeset 577 | f578f14cb97f |
parent 558 | 9273dfc5fa7c |
child 603 | a45a62dd6df9 |
permissions | -rwxr-xr-x |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1 |
/* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
2 |
* matiec - a compiler for the programming languages defined in IEC 61131-3 |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
3 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
4 |
* Copyright (C) 2009-2012 Mario de Sousa (msousa@fe.up.pt) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
5 |
* Copyright (C) 2012 Manuele Conti (manuele.conti@sirius-es.it) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
6 |
* Copyright (C) 2012 Matteo Facchinetti (matteo.facchinetti@sirius-es.it) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
7 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
8 |
* This program is free software: you can redistribute it and/or modify |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
9 |
* it under the terms of the GNU General Public License as published by |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
11 |
* (at your option) any later version. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
12 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
13 |
* This program is distributed in the hope that it will be useful, |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
16 |
* GNU General Public License for more details. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
17 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
20 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
21 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
22 |
* This code is made available on the understanding that it will not be |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
23 |
* used in safety-critical situations without a full and competent review. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
24 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
25 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
26 |
/* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
27 |
* An IEC 61131-3 compiler. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
28 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
29 |
* Based on the |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
30 |
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
31 |
* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
32 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
33 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
34 |
|
541 | 35 |
/* TODO - things yet not checked by this data type checker... |
36 |
* |
|
37 |
* - check variable declarations |
|
38 |
* - check data type declarations |
|
39 |
* - check inside configurations (variable declarations) |
|
40 |
* - check SFC code |
|
41 |
* - must fix S and R IL functions (includes potientialy fixing stage4 code!) |
|
42 |
*/ |
|
43 |
||
44 |
||
552 | 45 |
/* NOTE: The algorithm implemented here assumes that flow control analysis has already been completed! |
46 |
* BEFORE running this visitor, be sure to CALL the flow_control_analysis_c visitor! |
|
47 |
*/ |
|
48 |
||
49 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
50 |
/* |
552 | 51 |
* Fill the candidate datatype list for all symbols that may legally 'have' a data type (e.g. variables, literals, function calls, expressions, etc.) |
52 |
* |
|
53 |
* The candidate datatype list will be filled with a list of all the data types that expression may legally take. |
|
54 |
* For example, the very simple literal '0' (as in foo := 0), may represent a: |
|
55 |
* BOOL, BYTE, WORD, DWORD, LWORD, USINT, SINT, UINT, INT, UDINT, DINT, ULINT, LINT (as well as the SAFE versions of these data tyes too!) |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
56 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
57 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
58 |
#include "fill_candidate_datatypes.hh" |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
59 |
#include "datatype_functions.hh" |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
60 |
#include <typeinfo> |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
61 |
#include <list> |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
62 |
#include <string> |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
63 |
#include <string.h> |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
64 |
#include <strings.h> |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
65 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
66 |
/* set to 1 to see debug info during execution */ |
454
099aa5d655de
Finish support for semantic verification of IL paranthesised expressions.
Mario de Sousa <msousa@fe.up.pt>
parents:
453
diff
changeset
|
67 |
static int debug = 0; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
68 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
69 |
fill_candidate_datatypes_c::fill_candidate_datatypes_c(symbol_c *ignore) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
70 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
71 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
72 |
fill_candidate_datatypes_c::~fill_candidate_datatypes_c(void) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
73 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
74 |
|
478
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
75 |
symbol_c *fill_candidate_datatypes_c::widening_conversion(symbol_c *left_type, symbol_c *right_type, const struct widen_entry widen_table[]) { |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
76 |
int k; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
77 |
/* find a widening table entry compatible */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
78 |
for (k = 0; NULL != widen_table[k].left; k++) |
478
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
79 |
if ((typeid(*left_type) == typeid(*widen_table[k].left)) && (typeid(*right_type) == typeid(*widen_table[k].right))) |
476
38d85e9a0507
Add check widening status for IL operator.
Manuele Conti <conti.ma@alice.it>
parents:
473
diff
changeset
|
80 |
return widen_table[k].result; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
81 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
82 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
83 |
|
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
84 |
|
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
85 |
/* add a data type to a candidate data type list, while guaranteeing no duplicate entries! */ |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
86 |
/* Returns true if it really did add the datatype to the list, or false if it was already present in the list! */ |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
87 |
bool fill_candidate_datatypes_c::add_datatype_to_candidate_list(symbol_c *symbol, symbol_c *datatype) { |
478
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
88 |
/* If it is an invalid data type, do not insert! |
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
89 |
* NOTE: it reduces overall code size to do this test here, instead of doing every time before calling the add_datatype_to_candidate_list() function. |
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
90 |
*/ |
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
91 |
if (!is_type_valid(datatype)) /* checks for NULL and invalid_type_name_c */ |
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
92 |
return false; |
b13feab3b918
Change setting of deprecated_operation from fill to narrow_candidate_datatypes_c.
Mario de Sousa <msousa@fe.up.pt>
parents:
476
diff
changeset
|
93 |
|
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
94 |
if (search_in_candidate_datatype_list(datatype, symbol->candidate_datatypes) >= 0) |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
95 |
/* already in the list, Just return! */ |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
96 |
return false; |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
97 |
|
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
98 |
/* not yet in the candidate data type list, so we insert it now! */ |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
99 |
symbol->candidate_datatypes.push_back(datatype); |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
100 |
return true; |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
101 |
} |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
102 |
|
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
103 |
|
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
104 |
bool fill_candidate_datatypes_c::add_2datatypes_to_candidate_list(symbol_c *symbol, symbol_c *datatype1, symbol_c *datatype2) { |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
105 |
add_datatype_to_candidate_list(symbol, datatype1); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
106 |
add_datatype_to_candidate_list(symbol, datatype2); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
107 |
return true; |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
108 |
} |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
109 |
|
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
110 |
|
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
111 |
/* returns true if compatible function/FB invocation, otherwise returns false */ |
424
43d73e28eca8
Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents:
422
diff
changeset
|
112 |
/* Assumes that the candidate_datatype lists of all the parameters being passed haved already been filled in */ |
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
113 |
/* |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
114 |
* All parameters being passed to the called function MUST be in the parameter list to which f_call points to! |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
115 |
* This means that, for non formal function calls in IL, de current (default value) must be artificially added to the |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
116 |
* beginning of the parameter list BEFORE calling handle_function_call(). |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
117 |
*/ |
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
118 |
bool fill_candidate_datatypes_c::match_nonformal_call(symbol_c *f_call, symbol_c *f_decl) { |
449
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
119 |
symbol_c *call_param_value, *param_datatype; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
120 |
identifier_c *param_name; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
121 |
function_param_iterator_c fp_iterator(f_decl); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
122 |
function_call_param_iterator_c fcp_iterator(f_call); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
123 |
int extensible_parameter_highest_index = -1; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
124 |
unsigned int i; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
125 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
126 |
/* Iterating through the non-formal parameters of the function call */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
127 |
while((call_param_value = fcp_iterator.next_nf()) != NULL) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
128 |
/* Iterate to the next parameter of the function being called. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
129 |
* Get the name of that parameter, and ignore if EN or ENO. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
130 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
131 |
do { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
132 |
param_name = fp_iterator.next(); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
133 |
/* If there is no other parameter declared, then we are passing too many parameters... */ |
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
134 |
if(param_name == NULL) return false; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
135 |
} while ((strcmp(param_name->value, "EN") == 0) || (strcmp(param_name->value, "ENO") == 0)); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
136 |
|
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
137 |
/* TODO: verify if it is lvalue when INOUT or OUTPUT parameters! */ |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
138 |
/* Get the parameter type */ |
449
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
139 |
param_datatype = base_type(fp_iterator.param_type()); |
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
140 |
|
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
141 |
/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */ |
449
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
142 |
if (search_in_candidate_datatype_list(param_datatype, call_param_value->candidate_datatypes) < 0) |
442 | 143 |
return false; /* return false if param_type not in the list! */ |
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
144 |
} |
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
145 |
/* call is compatible! */ |
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
146 |
return true; |
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
147 |
} |
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
148 |
|
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
149 |
|
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
150 |
|
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
151 |
/* returns true if compatible function/FB invocation, otherwise returns false */ |
424
43d73e28eca8
Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents:
422
diff
changeset
|
152 |
/* Assumes that the candidate_datatype lists of all the parameters being passed haved already been filled in */ |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
153 |
bool fill_candidate_datatypes_c::match_formal_call(symbol_c *f_call, symbol_c *f_decl, symbol_c **first_param_datatype) { |
449
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
154 |
symbol_c *call_param_value, *call_param_name, *param_datatype; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
155 |
symbol_c *verify_duplicate_param; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
156 |
identifier_c *param_name; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
157 |
function_param_iterator_c fp_iterator(f_decl); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
158 |
function_call_param_iterator_c fcp_iterator(f_call); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
159 |
int extensible_parameter_highest_index = -1; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
160 |
identifier_c *extensible_parameter_name; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
161 |
unsigned int i; |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
162 |
bool is_first_param = true; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
163 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
164 |
/* Iterating through the formal parameters of the function call */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
165 |
while((call_param_name = fcp_iterator.next_f()) != NULL) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
166 |
/* Obtaining the value being passed in the function call */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
167 |
call_param_value = fcp_iterator.get_current_value(); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
168 |
/* the following should never occur. If it does, then we have a bug in our code... */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
169 |
if (NULL == call_param_value) ERROR; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
170 |
|
449
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
171 |
/* Obtaining the assignment direction: := (assign_in) or => (assign_out) */ |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
172 |
function_call_param_iterator_c::assign_direction_t call_param_dir = fcp_iterator.get_assign_direction(); |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
173 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
174 |
/* Checking if there are duplicated parameter values */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
175 |
verify_duplicate_param = fcp_iterator.search_f(call_param_name); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
176 |
if(verify_duplicate_param != call_param_value) |
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
177 |
return false; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
178 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
179 |
/* Obtaining the type of the value being passed in the function call */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
180 |
std::vector <symbol_c *>&call_param_types = call_param_value->candidate_datatypes; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
181 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
182 |
/* Find the corresponding parameter in function declaration */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
183 |
param_name = fp_iterator.search(call_param_name); |
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
184 |
if(param_name == NULL) return false; |
449
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
185 |
/* Get the parameter data type */ |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
186 |
param_datatype = base_type(fp_iterator.param_type()); |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
187 |
/* Get the parameter direction: IN, OUT, IN_OUT */ |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
188 |
function_param_iterator_c::param_direction_t param_dir = fp_iterator.param_direction(); |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
189 |
|
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
190 |
/* check whether direction (IN, OUT, IN_OUT) and assignment types (:= , =>) are compatible !!! */ |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
191 |
if (function_call_param_iterator_c::assign_in == call_param_dir) { |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
192 |
if ((function_param_iterator_c::direction_in != param_dir) && |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
193 |
(function_param_iterator_c::direction_inout != param_dir)) |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
194 |
return false; |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
195 |
} else if (function_call_param_iterator_c::assign_out == call_param_dir) { |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
196 |
if ((function_param_iterator_c::direction_out != param_dir)) |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
197 |
return false; |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
198 |
} else ERROR; |
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
199 |
|
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
200 |
/* check whether one of the candidate_data_types of the value being passed is the same as the param_type */ |
449
3c6225521059
Semantic verification: Add compatibility check for parameter direction in function invocation.
Mario de Sousa <msousa@fe.up.pt>
parents:
448
diff
changeset
|
201 |
if (search_in_candidate_datatype_list(param_datatype, call_param_types) < 0) |
442 | 202 |
return false; /* return false if param_type not in the list! */ |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
203 |
|
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
204 |
/* If this is the first parameter, then copy the datatype to *first_param_datatype */ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
205 |
if (is_first_param) |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
206 |
if (NULL != first_param_datatype) |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
207 |
*first_param_datatype = param_datatype; |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
208 |
is_first_param = false; |
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
209 |
} |
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
210 |
/* call is compatible! */ |
420
866eb35e4e14
Fix search_varfb_instance_decl to be able to find variables and FB when only given an identifier.
Mario de Sousa <msousa@fe.up.pt>
parents:
419
diff
changeset
|
211 |
return true; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
212 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
213 |
|
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
214 |
|
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
215 |
|
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
216 |
|
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
217 |
/* Handle a generic function call! |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
218 |
* Assumes that the parameter_list containing the values being passed in this function invocation |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
219 |
* has already had all the candidate_datatype lists filled in! |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
220 |
* |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
221 |
* All parameters being passed to the called function MUST be in the parameter list to which f_call points to! |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
222 |
* This means that, for non formal function calls in IL, de current (default value) must be artificially added to the |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
223 |
* beginning of the parameter list BEFORE calling handle_function_call(). |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
224 |
*/ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
225 |
/* |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
226 |
typedef struct { |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
227 |
symbol_c *function_name, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
228 |
symbol_c *nonformal_operand_list, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
229 |
symbol_c * formal_operand_list, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
230 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
231 |
std::vector <symbol_c *> &candidate_functions, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
232 |
symbol_c &*called_function_declaration, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
233 |
int &extensible_param_count |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
234 |
} generic_function_call_t; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
235 |
*/ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
236 |
/* |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
237 |
void narrow_candidate_datatypes_c::narrow_function_invocation(symbol_c *fcall, generic_function_call_t fcall_data) { |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
238 |
void *fill_candidate_datatypes_c::handle_function_call(symbol_c *f_call, symbol_c *function_name, invocation_type_t invocation_type, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
239 |
std::vector <symbol_c *> *candidate_datatypes, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
240 |
std::vector <symbol_c *> *candidate_functions) { |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
241 |
*/ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
242 |
void fill_candidate_datatypes_c::handle_function_call(symbol_c *fcall, generic_function_call_t fcall_data) { |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
243 |
function_declaration_c *f_decl; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
244 |
list_c *parameter_list; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
245 |
list_c *parameter_candidate_datatypes; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
246 |
symbol_c *returned_parameter_type; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
247 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
248 |
if (debug) std::cout << "function()\n"; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
249 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
250 |
function_symtable_t::iterator lower = function_symtable.lower_bound(fcall_data.function_name); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
251 |
function_symtable_t::iterator upper = function_symtable.upper_bound(fcall_data.function_name); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
252 |
/* If the name of the function being called is not found in the function symbol table, then this is an invalid call */ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
253 |
/* Since the lexical parser already checks for this, then if this occurs then we have an internal compiler error. */ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
254 |
if (lower == function_symtable.end()) ERROR; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
255 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
256 |
/* Look for all compatible function declarations, and add their return datatypes |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
257 |
* to the candidate_datatype list of this function invocation. |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
258 |
* |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
259 |
* If only one function exists, we add its return datatype to the candidate_datatype list, |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
260 |
* even if the parameters passed to it are invalid. |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
261 |
* This guarantees that the remainder of the expression in which the function call is inserted |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
262 |
* is treated as if the function call returns correctly, and therefore does not generate |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
263 |
* spurious error messages. |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
264 |
* Even if the parameters to the function call are invalid, doing this is still safe, as the |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
265 |
* expressions inside the function call will themselves have erros and will guarantee that |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
266 |
* compilation is aborted in stage3 (in print_datatypes_error_c). |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
267 |
*/ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
268 |
if (function_symtable.multiplicity(fcall_data.function_name) == 1) { |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
269 |
f_decl = function_symtable.get_value(lower); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
270 |
returned_parameter_type = base_type(f_decl->type_name); |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
271 |
if (add_datatype_to_candidate_list(fcall, returned_parameter_type)) |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
272 |
/* we only add it to the function declaration list if this entry was not already present in the candidate datatype list! */ |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
273 |
fcall_data.candidate_functions.push_back(f_decl); |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
274 |
|
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
275 |
} |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
276 |
for(; lower != upper; lower++) { |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
277 |
bool compatible = false; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
278 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
279 |
f_decl = function_symtable.get_value(lower); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
280 |
/* Check if function declaration in symbol_table is compatible with parameters */ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
281 |
if (NULL != fcall_data.nonformal_operand_list) compatible=match_nonformal_call(fcall, f_decl); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
282 |
if (NULL != fcall_data. formal_operand_list) compatible= match_formal_call(fcall, f_decl); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
283 |
if (compatible) { |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
284 |
/* Add the data type returned by the called functions. |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
285 |
* However, only do this if this data type is not already present in the candidate_datatypes list_c |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
286 |
*/ |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
287 |
returned_parameter_type = base_type(f_decl->type_name); |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
288 |
if (add_datatype_to_candidate_list(fcall, returned_parameter_type)) |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
289 |
/* we only add it to the function declaration list if this entry was not already present in the candidate datatype list! */ |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
290 |
fcall_data.candidate_functions.push_back(f_decl); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
291 |
} |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
292 |
} |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
293 |
if (debug) std::cout << "end_function() [" << fcall->candidate_datatypes.size() << "] result.\n"; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
294 |
return; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
295 |
} |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
296 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
297 |
|
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
298 |
/* handle implicit FB call in IL. |
448
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
299 |
* e.g. CLK ton_var |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
300 |
* CU counter_var |
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
301 |
*/ |
489
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
302 |
void *fill_candidate_datatypes_c::handle_implicit_il_fb_call(symbol_c *il_instruction, const char *param_name, symbol_c *&called_fb_declaration) { |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
303 |
symbol_c *fb_type_id = search_varfb_instance_type->get_basetype_id(il_operand); |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
304 |
/* Although a call to a non-declared FB is a semantic error, this is currently caught by stage 2! */ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
305 |
if (NULL == fb_type_id) ERROR; |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
306 |
|
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
307 |
function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(fb_type_id); |
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
308 |
if (function_block_type_symtable.end_value() == fb_decl) |
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
309 |
/* The il_operand is not the name of a FB instance. Most probably it is the name of a variable of some other type. |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
310 |
* this is a semantic error. |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
311 |
*/ |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
312 |
fb_decl = NULL; |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
313 |
|
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
314 |
/* The narrow_candidate_datatypes_c does not rely on this called_fb_declaration pointer being == NULL to conclude that |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
315 |
* we have a datatype incompatibility error, so we set it to fb_decl to allow the print_datatype_error_c to print out |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
316 |
* more informative error messages! |
450
eb1b28acec2e
Fix a few more bugs related to FB/function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
449
diff
changeset
|
317 |
*/ |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
318 |
called_fb_declaration = fb_decl; |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
319 |
|
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
320 |
/* This implicit FB call does not change the value stored in the current/default IL variable */ |
456 | 321 |
/* It does, however, require that the datatype be compatible with the input parameter of the FB being called. |
322 |
* If we were to follow the filling & narrowing algorithm correctly (implemented in fill_candidate_datatypes_c |
|
323 |
* & narrow_candidate_datatypes_c respectively), we should be restricting the candidate_datatpes to the datatypes |
|
324 |
* that are compatible to the FB call. |
|
325 |
* However, doing the above will often result in some very confusing error messages for the user, especially in the case |
|
326 |
* in which the FB call is wrong, so the resulting cadidate datatypes is an empty list. In this case, the user would see |
|
327 |
* many error messages related to the IL instructions that follow the FB call, even though those IL instructions may be perfectly |
|
328 |
* correct. |
|
329 |
* For now, we will simply let the narrow_candidate_datatypes_c verify if the datatypes are compatible (something that should be done |
|
330 |
* here). |
|
331 |
*/ |
|
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
332 |
if (NULL != prev_il_instruction) |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
333 |
il_instruction->candidate_datatypes = prev_il_instruction->candidate_datatypes; |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
334 |
|
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
335 |
if (debug) std::cout << "handle_implicit_il_fb_call() [" << prev_il_instruction->candidate_datatypes.size() << "] ==> " << il_instruction->candidate_datatypes.size() << " result.\n"; |
489
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
336 |
return NULL; |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
337 |
} |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
338 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
339 |
|
479 | 340 |
|
341 |
||
342 |
/* handle a binary IL operator, like ADD, SUB, etc... */ |
|
343 |
void *fill_candidate_datatypes_c::handle_binary_operator(const struct widen_entry widen_table[], symbol_c *symbol, symbol_c *l_expr, symbol_c *r_expr) { |
|
344 |
if (NULL == l_expr) /* if no prev_il_instruction */ |
|
345 |
return NULL; |
|
346 |
||
347 |
for(unsigned int i = 0; i < l_expr->candidate_datatypes.size(); i++) |
|
348 |
for(unsigned int j = 0; j < r_expr->candidate_datatypes.size(); j++) |
|
349 |
/* NOTE: add_datatype_to_candidate_list() will only really add the datatype if it is != NULL !!! */ |
|
350 |
add_datatype_to_candidate_list(symbol, widening_conversion(l_expr->candidate_datatypes[i], r_expr->candidate_datatypes[j], widen_table)); |
|
351 |
||
352 |
if (debug) std::cout << "[" << l_expr->candidate_datatypes.size() << "," << r_expr->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
|
353 |
return NULL; |
|
354 |
} |
|
355 |
||
356 |
||
357 |
/* handle a binary ST expression, like '+', '-', etc... */ |
|
358 |
void *fill_candidate_datatypes_c::handle_binary_expression(const struct widen_entry widen_table[], symbol_c *symbol, symbol_c *l_expr, symbol_c *r_expr) { |
|
359 |
l_expr->accept(*this); |
|
360 |
r_expr->accept(*this); |
|
361 |
return handle_binary_operator(widen_table, symbol, l_expr, r_expr); |
|
362 |
} |
|
363 |
||
364 |
||
365 |
||
366 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
367 |
/* a helper function... */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
368 |
symbol_c *fill_candidate_datatypes_c::base_type(symbol_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
369 |
/* NOTE: symbol == NULL is valid. It will occur when, for e.g., an undefined/undeclared symbolic_variable is used |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
370 |
* in the code. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
371 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
372 |
if (symbol == NULL) return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
373 |
return (symbol_c *)symbol->accept(search_base_type); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
374 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
375 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
376 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
377 |
/* B 1.2 - Constants */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
378 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
379 |
/******************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
380 |
/* B 1.2.1 - Numeric Literals */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
381 |
/******************************/ |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
382 |
#define sizeoftype(symbol) get_sizeof_datatype_c::getsize(symbol) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
383 |
|
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
384 |
void *fill_candidate_datatypes_c::handle_any_integer(symbol_c *symbol) { |
488 | 385 |
int calc_size = sizeoftype(symbol); |
386 |
||
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
387 |
if (calc_size <= sizeoftype(&search_constant_type_c::bool_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
388 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::bool_type_name, &search_constant_type_c::safebool_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
389 |
if (calc_size <= sizeoftype(&search_constant_type_c::byte_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
390 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::byte_type_name, &search_constant_type_c::safebyte_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
391 |
if (calc_size <= sizeoftype(&search_constant_type_c::word_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
392 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::word_type_name, &search_constant_type_c::safeword_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
393 |
if (calc_size <= sizeoftype(&search_constant_type_c::dword_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
394 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::dword_type_name, &search_constant_type_c::safedword_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
395 |
if (calc_size <= sizeoftype(&search_constant_type_c::lword_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
396 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::lword_type_name, &search_constant_type_c::safelword_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
397 |
|
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
398 |
if (calc_size < sizeoftype(&search_constant_type_c::sint_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
399 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::sint_type_name, &search_constant_type_c::safesint_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
400 |
if (calc_size < sizeoftype(&search_constant_type_c::int_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
401 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::int_type_name, &search_constant_type_c::safeint_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
402 |
if (calc_size < sizeoftype(&search_constant_type_c::dint_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
403 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::dint_type_name, &search_constant_type_c::safedint_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
404 |
if (calc_size < sizeoftype(&search_constant_type_c::lint_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
405 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::lint_type_name, &search_constant_type_c::safelint_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
406 |
if (calc_size <= sizeoftype(&search_constant_type_c::usint_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
407 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::usint_type_name, &search_constant_type_c::safeusint_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
408 |
if (calc_size <= sizeoftype(&search_constant_type_c::uint_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
409 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::uint_type_name, &search_constant_type_c::safeuint_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
410 |
if (calc_size <= sizeoftype(&search_constant_type_c::udint_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
411 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::udint_type_name, &search_constant_type_c::safeudint_type_name); |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
412 |
if (calc_size <= sizeoftype(&search_constant_type_c::ulint_type_name)) |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
413 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::ulint_type_name, &search_constant_type_c::safeulint_type_name); |
479 | 414 |
|
415 |
if (debug) std::cout << "ANY_INT [" << symbol->candidate_datatypes.size()<< "]" << std::endl; |
|
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
416 |
return NULL; |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
417 |
} |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
418 |
|
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
419 |
|
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
420 |
|
488 | 421 |
void *fill_candidate_datatypes_c::handle_any_real(symbol_c *symbol) { |
422 |
int calc_size = sizeoftype(symbol); |
|
423 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
424 |
if (calc_size <= sizeoftype(&search_constant_type_c::real_type_name)) |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
425 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::real_type_name, &search_constant_type_c::safereal_type_name); |
429
26bec44c591f
Fix bug in analysing real literals (thanks Andreas!)
Mario de Sousa <msousa@fe.up.pt>
parents:
427
diff
changeset
|
426 |
if (calc_size <= sizeoftype(&search_constant_type_c::lreal_type_name)) |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
427 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::lreal_type_name, &search_constant_type_c::safelreal_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
428 |
if (debug) std::cout << "ANY_REAL [" << symbol->candidate_datatypes.size() << "]" << std::endl; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
429 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
430 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
431 |
|
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
432 |
|
488 | 433 |
|
434 |
void *fill_candidate_datatypes_c::handle_any_literal(symbol_c *symbol, symbol_c *symbol_value, symbol_c *symbol_type) { |
|
435 |
symbol_value->accept(*this); |
|
436 |
if (search_in_candidate_datatype_list(symbol_type, symbol_value->candidate_datatypes) >= 0) |
|
437 |
add_datatype_to_candidate_list(symbol, symbol_type); |
|
438 |
if (debug) std::cout << "XXX_LITERAL [" << symbol->candidate_datatypes.size() << "]\n"; |
|
439 |
return NULL; |
|
440 |
} |
|
441 |
||
442 |
||
443 |
||
444 |
void *fill_candidate_datatypes_c::visit( real_c *symbol) {return handle_any_real(symbol);} |
|
445 |
void *fill_candidate_datatypes_c::visit(neg_real_c *symbol) {return handle_any_real(symbol);} |
|
446 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
447 |
|
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
448 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
449 |
void *fill_candidate_datatypes_c::visit(neg_integer_c *symbol) { |
488 | 450 |
int calc_size = sizeoftype(symbol); |
451 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
452 |
if (calc_size <= sizeoftype(&search_constant_type_c::int_type_name)) |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
453 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::int_type_name, &search_constant_type_c::safeint_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
454 |
if (calc_size <= sizeoftype(&search_constant_type_c::sint_type_name)) |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
455 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::sint_type_name, &search_constant_type_c::safesint_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
456 |
if (calc_size <= sizeoftype(&search_constant_type_c::dint_type_name)) |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
457 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::dint_type_name, &search_constant_type_c::safedint_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
458 |
if (calc_size <= sizeoftype(&search_constant_type_c::lint_type_name)) |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
459 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::lint_type_name, &search_constant_type_c::safelint_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
460 |
if (debug) std::cout << "neg ANY_INT [" << symbol->candidate_datatypes.size() << "]" << std::endl; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
461 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
462 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
463 |
|
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
464 |
|
488 | 465 |
|
479 | 466 |
void *fill_candidate_datatypes_c::visit(integer_c *symbol) {return handle_any_integer(symbol);} |
467 |
void *fill_candidate_datatypes_c::visit(binary_integer_c *symbol) {return handle_any_integer(symbol);} |
|
468 |
void *fill_candidate_datatypes_c::visit(octal_integer_c *symbol) {return handle_any_integer(symbol);} |
|
469 |
void *fill_candidate_datatypes_c::visit(hex_integer_c *symbol) {return handle_any_integer(symbol);} |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
470 |
|
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
471 |
|
488 | 472 |
|
427
eb9bc99944d9
Better error reporting in function invocations, and in invalid literal values.
Mario de Sousa <msousa@fe.up.pt>
parents:
426
diff
changeset
|
473 |
// SYM_REF2(integer_literal_c, type, value) |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
474 |
/* |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
475 |
* integer_literal: |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
476 |
* integer_type_name '#' signed_integer |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
477 |
* | integer_type_name '#' binary_integer |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
478 |
* | integer_type_name '#' octal_integer |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
479 |
* | integer_type_name '#' hex_integer |
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
480 |
*/ |
488 | 481 |
void *fill_candidate_datatypes_c::visit( integer_literal_c *symbol) {return handle_any_literal(symbol, symbol->value, symbol->type);} |
482 |
void *fill_candidate_datatypes_c::visit( real_literal_c *symbol) {return handle_any_literal(symbol, symbol->value, symbol->type);} |
|
483 |
void *fill_candidate_datatypes_c::visit(bit_string_literal_c *symbol) {return handle_any_literal(symbol, symbol->value, symbol->type);} |
|
484 |
||
485 |
void *fill_candidate_datatypes_c::visit( boolean_literal_c *symbol) { |
|
486 |
if (NULL != symbol->type) return handle_any_literal(symbol, symbol->value, symbol->type); |
|
487 |
||
427
eb9bc99944d9
Better error reporting in function invocations, and in invalid literal values.
Mario de Sousa <msousa@fe.up.pt>
parents:
426
diff
changeset
|
488 |
symbol->value->accept(*this); |
488 | 489 |
symbol->candidate_datatypes = symbol->value->candidate_datatypes; |
490 |
return NULL; |
|
491 |
} |
|
492 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
493 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
494 |
void *fill_candidate_datatypes_c::visit(boolean_true_c *symbol) { |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
495 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::bool_type_name, &search_constant_type_c::safebool_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
496 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
497 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
498 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
499 |
void *fill_candidate_datatypes_c::visit(boolean_false_c *symbol) { |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
500 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::bool_type_name, &search_constant_type_c::safebool_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
501 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
502 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
503 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
504 |
/*******************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
505 |
/* B.1.2.2 Character Strings */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
506 |
/*******************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
507 |
void *fill_candidate_datatypes_c::visit(double_byte_character_string_c *symbol) { |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
508 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::wstring_type_name, &search_constant_type_c::safewstring_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
509 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
510 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
511 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
512 |
void *fill_candidate_datatypes_c::visit(single_byte_character_string_c *symbol) { |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
513 |
add_2datatypes_to_candidate_list(symbol, &search_constant_type_c::string_type_name, &search_constant_type_c::safestring_type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
514 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
515 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
516 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
517 |
/***************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
518 |
/* B 1.2.3 - Time Literals */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
519 |
/***************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
520 |
/************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
521 |
/* B 1.2.3.1 - Duration */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
522 |
/************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
523 |
void *fill_candidate_datatypes_c::visit(duration_c *symbol) { |
437
0e09a8840c92
Add TODO comment, and delete unused debugging code.
Mario de Sousa <msousa@fe.up.pt>
parents:
435
diff
changeset
|
524 |
/* TODO: check whether the literal follows the rules specified in section '2.2.3.1 Duration' of the standard! */ |
459
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
525 |
|
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
526 |
add_datatype_to_candidate_list(symbol, symbol->type_name); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
527 |
if (debug) std::cout << "TIME_LITERAL [" << symbol->candidate_datatypes.size() << "]\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
528 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
529 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
530 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
531 |
/************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
532 |
/* B 1.2.3.2 - Time of day and Date */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
533 |
/************************************/ |
479 | 534 |
void *fill_candidate_datatypes_c::visit(time_of_day_c *symbol) {add_datatype_to_candidate_list(symbol, symbol->type_name); return NULL;} |
535 |
void *fill_candidate_datatypes_c::visit(date_c *symbol) {add_datatype_to_candidate_list(symbol, symbol->type_name); return NULL;} |
|
536 |
void *fill_candidate_datatypes_c::visit(date_and_time_c *symbol) {add_datatype_to_candidate_list(symbol, symbol->type_name); return NULL;} |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
537 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
538 |
/**********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
539 |
/* B 1.3 - Data types */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
540 |
/**********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
541 |
/********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
542 |
/* B 1.3.3 - Derived data types */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
543 |
/********************************/ |
502
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
544 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
545 |
/* simple_specification ASSIGN constant */ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
546 |
// SYM_REF2(simple_spec_init_c, simple_specification, constant) |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
547 |
void *fill_candidate_datatypes_c::visit(simple_spec_init_c *symbol) { |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
548 |
if (NULL != symbol->constant) symbol->constant->accept(*this); |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
549 |
add_datatype_to_candidate_list(symbol->simple_specification, base_type(symbol->simple_specification)); |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
550 |
symbol->candidate_datatypes = symbol->simple_specification->candidate_datatypes; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
551 |
/* NOTE: Even if the constant and the type are of incompatible data types, we let the |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
552 |
* simple_spec_init_c object inherit the data type of the type declaration (simple_specification) |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
553 |
* This will let us produce more informative error messages when checking data type compatibility |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
554 |
* with located variables (AT %QW3.4 : WORD). |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
555 |
*/ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
556 |
// if (NULL != symbol->constant) intersect_candidate_datatype_list(symbol /*origin, dest.*/, symbol->constant /*with*/); |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
557 |
return NULL; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
558 |
} |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
559 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
560 |
/* signed_integer DOTDOT signed_integer */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
561 |
// SYM_REF2(subrange_c, lower_limit, upper_limit) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
562 |
void *fill_candidate_datatypes_c::visit(subrange_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
563 |
symbol->lower_limit->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
564 |
symbol->upper_limit->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
565 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
566 |
for (unsigned int u = 0; u < symbol->upper_limit->candidate_datatypes.size(); u++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
567 |
for(unsigned int l = 0; l < symbol->lower_limit->candidate_datatypes.size(); l++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
568 |
if (is_type_equal(symbol->upper_limit->candidate_datatypes[u], symbol->lower_limit->candidate_datatypes[l])) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
569 |
add_datatype_to_candidate_list(symbol, symbol->lower_limit->candidate_datatypes[l]); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
570 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
571 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
572 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
573 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
574 |
|
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
575 |
/* TYPE type_declaration_list END_TYPE */ |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
576 |
// SYM_REF1(data_type_declaration_c, type_declaration_list) |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
577 |
/* NOTE: Not required. already handled by iterator_visitor_c base class */ |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
578 |
/* |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
579 |
void *fill_candidate_datatypes_c::visit(data_type_declaration_c *symbol) { |
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
580 |
symbol->type_declaration_list->accept(*this); |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
581 |
return NULL; |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
582 |
} |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
583 |
*/ |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
584 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
585 |
void *fill_candidate_datatypes_c::visit(enumerated_value_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
586 |
symbol_c *enumerated_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
587 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
588 |
if (NULL != symbol->type) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
589 |
enumerated_type = symbol->type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
590 |
else { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
591 |
enumerated_type = enumerated_value_symtable.find_value(symbol->value); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
592 |
if (enumerated_type == enumerated_value_symtable.end_value()) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
593 |
enumerated_type = NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
594 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
595 |
enumerated_type = base_type(enumerated_type); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
596 |
if (NULL != enumerated_type) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
597 |
add_datatype_to_candidate_list(symbol, enumerated_type); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
598 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
599 |
if (debug) std::cout << "ENUMERATE [" << symbol->candidate_datatypes.size() << "]\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
600 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
601 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
602 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
603 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
604 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
605 |
/* B 1.4 - Variables */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
606 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
607 |
void *fill_candidate_datatypes_c::visit(symbolic_variable_c *symbol) { |
479 | 608 |
add_datatype_to_candidate_list(symbol, search_varfb_instance_type->get_basetype_decl(symbol)); /* will only add if non NULL */ |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
609 |
if (debug) std::cout << "VAR [" << symbol->candidate_datatypes.size() << "]\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
610 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
611 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
612 |
|
502
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
613 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
614 |
/********************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
615 |
/* B 1.4.1 - Directly Represented Variables */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
616 |
/********************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
617 |
void *fill_candidate_datatypes_c::visit(direct_variable_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
618 |
/* Comment added by mario: |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
619 |
* The following code is safe, actually, as the lexical parser guarantees the correct IEC61131-3 syntax was used. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
620 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
621 |
/* However, we should probably add an assertion in case we later change the lexical parser! */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
622 |
/* if (symbol->value == NULL) ERROR; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
623 |
* if (symbol->value[0] == '\0') ERROR; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
624 |
* if (symbol->value[1] == '\0') ERROR; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
625 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
626 |
switch (symbol->value[2]) { |
502
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
627 |
case 'x': case 'X': /* bit - 1 bit */ add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name); break; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
628 |
case 'b': case 'B': /* byte - 8 bits */ add_datatype_to_candidate_list(symbol, &search_constant_type_c::byte_type_name); break; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
629 |
case 'w': case 'W': /* word - 16 bits */ add_datatype_to_candidate_list(symbol, &search_constant_type_c::word_type_name); break; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
630 |
case 'd': case 'D': /* dword - 32 bits */ add_datatype_to_candidate_list(symbol, &search_constant_type_c::dword_type_name); break; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
631 |
case 'l': case 'L': /* lword - 64 bits */ add_datatype_to_candidate_list(symbol, &search_constant_type_c::lword_type_name); break; |
479 | 632 |
/* if none of the above, then the empty string was used <=> boolean */ |
633 |
default: add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name); break; |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
634 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
635 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
636 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
637 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
638 |
/*************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
639 |
/* B 1.4.2 - Multi-element variables */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
640 |
/*************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
641 |
/* subscripted_variable '[' subscript_list ']' */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
642 |
// SYM_REF2(array_variable_c, subscripted_variable, subscript_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
643 |
void *fill_candidate_datatypes_c::visit(array_variable_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
644 |
/* get the declaration of the data type __stored__ in the array... */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
645 |
/* if we were to want the data type of the array itself, then we should call_param_name |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
646 |
* search_varfb_instance_type->get_basetype_decl(symbol->subscripted_variable) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
647 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
648 |
symbol_c *result = search_varfb_instance_type->get_basetype_decl(symbol); |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
649 |
if (NULL != result) add_datatype_to_candidate_list(symbol, result); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
650 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
651 |
/* recursively call the subscript list, so we can check the data types of the expressions used for the subscripts */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
652 |
symbol->subscript_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
653 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
654 |
if (debug) std::cout << "ARRAY_VAR [" << symbol->candidate_datatypes.size() << "]\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
655 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
656 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
657 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
658 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
659 |
/* subscript_list ',' subscript */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
660 |
// SYM_LIST(subscript_list_c) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
661 |
/* NOTE: we inherit from iterator visitor, so we do not need to implement this method... */ |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
662 |
// void *fill_candidate_datatypes_c::visit(subscript_list_c *symbol) |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
663 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
664 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
665 |
/* record_variable '.' field_selector */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
666 |
/* WARNING: input and/or output variables of function blocks |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
667 |
* may be accessed as fields of a structured variable! |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
668 |
* Code handling a structured_variable_c must take |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
669 |
* this into account! |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
670 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
671 |
// SYM_REF2(structured_variable_c, record_variable, field_selector) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
672 |
/* NOTE: We do not need to recursively determine the data types of each field_selector, as the search_varfb_instance_type |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
673 |
* will do that for us. So we determine the candidate datatypes only for the full structured_variable. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
674 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
675 |
void *fill_candidate_datatypes_c::visit(structured_variable_c *symbol) { |
479 | 676 |
add_datatype_to_candidate_list(symbol, search_varfb_instance_type->get_basetype_decl(symbol)); /* will only add if non NULL */ |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
677 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
678 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
679 |
|
502
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
680 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
681 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
682 |
/******************************************/ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
683 |
/* B 1.4.3 - Declaration & Initialisation */ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
684 |
/******************************************/ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
685 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
686 |
void *fill_candidate_datatypes_c::visit(var1_list_c *symbol) { |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
687 |
#if 0 /* We don't really need to set the datatype of each variable. We just check the declaration itself! */ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
688 |
for(int i = 0; i < symbol->n; i++) { |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
689 |
add_datatype_to_candidate_list(symbol->elements[i], search_varfb_instance_type->get_basetype_decl(symbol->elements[i])); /* will only add if non NULL */ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
690 |
} |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
691 |
#endif |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
692 |
return NULL; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
693 |
} |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
694 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
695 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
696 |
/* AT direct_variable */ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
697 |
// SYM_REF1(location_c, direct_variable) |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
698 |
void *fill_candidate_datatypes_c::visit(location_c *symbol) { |
558
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
699 |
/* This is a special situation. |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
700 |
* |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
701 |
* The reason is that a located variable may be declared to be of any data type, as long as the size |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
702 |
* matches the location (lines 1 3 and 4 of table 17). For example: |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
703 |
* var1 AT %MB42.0 : BYTE; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
704 |
* var1 AT %MB42.1 : SINT; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
705 |
* var1 AT %MB42.2 : USINT; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
706 |
* var1 AT %MW64 : INT; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
707 |
* var1 AT %MD56 : DINT; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
708 |
* var1 AT %MD57 : REAL; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
709 |
* are all valid!! |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
710 |
* |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
711 |
* However, when used inside an expression, the direct variable (uses the same syntax as the location |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
712 |
* of a located variable) is limited to the following (ANY_BIT) data types: |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
713 |
* %MX --> BOOL |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
714 |
* %MB --> BYTE |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
715 |
* %MW --> WORD |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
716 |
* %MD --> DWORD |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
717 |
* %ML --> LWORD |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
718 |
* |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
719 |
* So, in order to be able to analyse expressions with direct variables |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
720 |
* e.g: var1 := 66 OR %MW34 |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
721 |
* where the direct variable may only take the ANY_BIT data types, the fill_candidate_datatypes_c |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
722 |
* considers that only the ANY_BIT data types are allowed for a direct variable. |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
723 |
* However, it appears from the examples in the standard (lines 1 3 and 4 of table 17) |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
724 |
* a location may have any data type (presumably as long as the size in bits match). |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
725 |
* For this reason, a location_c may have more allowable data types than a direct_variable_c |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
726 |
*/ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
727 |
|
502
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
728 |
symbol->direct_variable->accept(*this); |
558
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
729 |
for (unsigned int i = 0; i < symbol->direct_variable->candidate_datatypes.size(); i++) { |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
730 |
switch (get_sizeof_datatype_c::getsize(symbol->direct_variable->candidate_datatypes[i])) { |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
731 |
case 1: /* bit - 1 bit */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
732 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::bool_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
733 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safebool_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
734 |
break; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
735 |
case 8: /* byte - 8 bits */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
736 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::byte_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
737 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safebyte_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
738 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::sint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
739 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safesint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
740 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::usint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
741 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safeusint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
742 |
break; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
743 |
case 16: /* word - 16 bits */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
744 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::word_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
745 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safeword_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
746 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::int_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
747 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safeint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
748 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::uint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
749 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safeuint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
750 |
break; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
751 |
case 32: /* dword - 32 bits */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
752 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::dword_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
753 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safedword_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
754 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::dint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
755 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safedint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
756 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::udint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
757 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safeudint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
758 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::real_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
759 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safereal_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
760 |
break; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
761 |
case 64: /* lword - 64 bits */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
762 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::lword_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
763 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safelword_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
764 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::lint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
765 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safelint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
766 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::ulint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
767 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safeulint_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
768 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::lreal_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
769 |
add_datatype_to_candidate_list(symbol, &search_constant_type_c::safelreal_type_name); |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
770 |
break; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
771 |
default: /* if none of the above, then no valid datatype allowed... */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
772 |
break; |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
773 |
} /* switch() */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
774 |
} /* for */ |
9273dfc5fa7c
Located variables may have other data types besides ANY_BIT.
mjsousa <msousa@fe.up.pt>
parents:
552
diff
changeset
|
775 |
|
502
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
776 |
return NULL; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
777 |
} |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
778 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
779 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
780 |
/* [variable_name] location ':' located_var_spec_init */ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
781 |
/* variable_name -> may be NULL ! */ |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
782 |
// SYM_REF3(located_var_decl_c, variable_name, location, located_var_spec_init) |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
783 |
void *fill_candidate_datatypes_c::visit(located_var_decl_c *symbol) { |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
784 |
symbol->located_var_spec_init->accept(*this); |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
785 |
symbol->location->accept(*this); |
523
773303b7f31f
Remove potential access to NULL pointer.
Mario de Sousa <msousa@fe.up.pt>
parents:
502
diff
changeset
|
786 |
if (NULL != symbol->variable_name) { |
773303b7f31f
Remove potential access to NULL pointer.
Mario de Sousa <msousa@fe.up.pt>
parents:
502
diff
changeset
|
787 |
symbol->variable_name->candidate_datatypes = symbol->location->candidate_datatypes; |
773303b7f31f
Remove potential access to NULL pointer.
Mario de Sousa <msousa@fe.up.pt>
parents:
502
diff
changeset
|
788 |
intersect_candidate_datatype_list(symbol->variable_name /*origin, dest.*/, symbol->located_var_spec_init /*with*/); |
773303b7f31f
Remove potential access to NULL pointer.
Mario de Sousa <msousa@fe.up.pt>
parents:
502
diff
changeset
|
789 |
} |
502
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
790 |
return NULL; |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
791 |
} |
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
792 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
793 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
794 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
795 |
|
a6211f73690b
Start data type checking of var declarations (including direct variables!)
Mario de Sousa <msousa@fe.up.pt>
parents:
490
diff
changeset
|
796 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
797 |
/************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
798 |
/* B 1.5 Program organization units */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
799 |
/************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
800 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
801 |
/* B 1.5.1 Functions */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
802 |
/*********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
803 |
void *fill_candidate_datatypes_c::visit(function_declaration_c *symbol) { |
479 | 804 |
if (debug) printf("Filling candidate data types list of function %s\n", ((token_c *)(symbol->derived_function_name))->value); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
805 |
search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
806 |
symbol->var_declarations_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
807 |
symbol->function_body->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
808 |
delete search_varfb_instance_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
809 |
search_varfb_instance_type = NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
810 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
811 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
812 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
813 |
/***************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
814 |
/* B 1.5.2 Function blocks */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
815 |
/***************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
816 |
void *fill_candidate_datatypes_c::visit(function_block_declaration_c *symbol) { |
479 | 817 |
if (debug) printf("Filling candidate data types list of FB %s\n", ((token_c *)(symbol->fblock_name))->value); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
818 |
search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
819 |
symbol->var_declarations->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
820 |
symbol->fblock_body->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
821 |
delete search_varfb_instance_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
822 |
search_varfb_instance_type = NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
823 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
824 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
825 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
826 |
/**********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
827 |
/* B 1.5.3 - Programs */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
828 |
/**********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
829 |
void *fill_candidate_datatypes_c::visit(program_declaration_c *symbol) { |
479 | 830 |
if (debug) printf("Filling candidate data types list in program %s\n", ((token_c *)(symbol->program_type_name))->value); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
831 |
search_varfb_instance_type = new search_varfb_instance_type_c(symbol); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
832 |
symbol->var_declarations->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
833 |
symbol->function_block_body->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
834 |
delete search_varfb_instance_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
835 |
search_varfb_instance_type = NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
836 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
837 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
838 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
839 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
840 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
841 |
/********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
842 |
/* B 1.7 Configuration elements */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
843 |
/********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
844 |
void *fill_candidate_datatypes_c::visit(configuration_declaration_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
845 |
// TODO !!! |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
846 |
/* for the moment we must return NULL so semantic analysis of remaining code is not interrupted! */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
847 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
848 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
849 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
850 |
/****************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
851 |
/* B.2 - Language IL (Instruction List) */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
852 |
/****************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
853 |
/***********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
854 |
/* B 2.1 Instructions and Operands */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
855 |
/***********************************/ |
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
856 |
|
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
857 |
/*| instruction_list il_instruction */ |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
858 |
// SYM_LIST(instruction_list_c) |
464
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
859 |
void *fill_candidate_datatypes_c::visit(instruction_list_c *symbol) { |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
860 |
/* In order to fill the data type candidates correctly |
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
861 |
* in IL instruction lists containing JMPs to labels that come before the JMP instruction |
464
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
862 |
* itself, we need to run the fill candidate datatypes algorithm twice on the Instruction List. |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
863 |
* e.g.: ... |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
864 |
* ld 23 |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
865 |
* label1:st byte_var |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
866 |
* ld 34 |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
867 |
* JMP label1 |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
868 |
* |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
869 |
* Note that the second time we run the algorithm, most of the candidate datatypes are already filled |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
870 |
* in, so it will be able to produce tha correct candidate datatypes for the IL instruction referenced |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
871 |
* by the label, as in the 2nd pass we already know the candidate datatypes of the JMP instruction! |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
872 |
*/ |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
873 |
for(int j = 0; j < 2; j++) { |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
874 |
for(int i = 0; i < symbol->n; i++) { |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
875 |
symbol->elements[i]->accept(*this); |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
876 |
} |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
877 |
} |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
878 |
return NULL; |
319ee8b218f3
Handle JMP to labels preceding the JMP instruction itself.
Mario de Sousa <msousa@fe.up.pt>
parents:
462
diff
changeset
|
879 |
} |
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
880 |
|
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
881 |
|
459
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
882 |
|
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
883 |
/* | label ':' [il_incomplete_instruction] eol_list */ |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
884 |
// SYM_REF2(il_instruction_c, label, il_instruction) |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
885 |
// void *visit(instruction_list_c *symbol); |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
886 |
void *fill_candidate_datatypes_c::visit(il_instruction_c *symbol) { |
448
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
887 |
if (NULL == symbol->il_instruction) { |
450
eb1b28acec2e
Fix a few more bugs related to FB/function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
449
diff
changeset
|
888 |
/* This empty/null il_instruction does not change the value of the current/default IL variable. |
eb1b28acec2e
Fix a few more bugs related to FB/function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
449
diff
changeset
|
889 |
* So it inherits the candidate_datatypes from it's previous IL instructions! |
eb1b28acec2e
Fix a few more bugs related to FB/function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
449
diff
changeset
|
890 |
*/ |
459
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
891 |
intersect_prev_candidate_datatype_lists(symbol); |
448
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
892 |
} else { |
459
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
893 |
il_instruction_c fake_prev_il_instruction = *symbol; |
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
894 |
intersect_prev_candidate_datatype_lists(&fake_prev_il_instruction); |
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
895 |
|
457
67d8b07bac22
Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents:
456
diff
changeset
|
896 |
if (symbol->prev_il_instruction.size() == 0) prev_il_instruction = NULL; |
459
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
897 |
else prev_il_instruction = &fake_prev_il_instruction; |
448
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
898 |
symbol->il_instruction->accept(*this); |
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
899 |
prev_il_instruction = NULL; |
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
900 |
|
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
901 |
/* This object has (inherits) the same candidate datatypes as the il_instruction */ |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
902 |
symbol->candidate_datatypes = symbol->il_instruction->candidate_datatypes; |
448
1bd18fc06911
Add support for semantic verification for implict FB calls in IL (e.g. PV ton_var)
Mario de Sousa <msousa@fe.up.pt>
parents:
447
diff
changeset
|
903 |
} |
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
904 |
|
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
905 |
return NULL; |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
906 |
} |
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
907 |
|
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
908 |
|
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
909 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
910 |
void *fill_candidate_datatypes_c::visit(il_simple_operation_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
911 |
/* determine the data type of the operand */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
912 |
if (NULL != symbol->il_operand) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
913 |
symbol->il_operand->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
914 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
915 |
/* recursive call to fill the candidate data types list */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
916 |
il_operand = symbol->il_operand; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
917 |
symbol->il_simple_operator->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
918 |
il_operand = NULL; |
443
ff4d26b7e51d
Narrow IL code backwords, so as to correctly handle invocations to overloaded functions from IL code.
Mario de Sousa <msousa@fe.up.pt>
parents:
442
diff
changeset
|
919 |
/* This object has (inherits) the same candidate datatypes as the il_simple_operator */ |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
920 |
symbol->candidate_datatypes = symbol->il_simple_operator->candidate_datatypes; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
921 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
922 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
923 |
|
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
924 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
925 |
/* | function_name [il_operand_list] */ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
926 |
/* NOTE: The parameters 'called_function_declaration' and 'extensible_param_count' are used to pass data between the stage 3 and stage 4. */ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
927 |
// SYM_REF2(il_function_call_c, function_name, il_operand_list, symbol_c *called_function_declaration; int extensible_param_count;) |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
928 |
void *fill_candidate_datatypes_c::visit(il_function_call_c *symbol) { |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
929 |
/* The first parameter of a non formal function call in IL will be the 'current value' (i.e. the prev_il_instruction) |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
930 |
* In order to be able to handle this without coding special cases, we will simply prepend that symbol |
451 | 931 |
* to the il_operand_list, and remove it after calling handle_function_call(). |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
932 |
* |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
933 |
* However, if no further paramters are given, then il_operand_list will be NULL, and we will |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
934 |
* need to create a new object to hold the pointer to prev_il_instruction. |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
935 |
*/ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
936 |
if (NULL == symbol->il_operand_list) symbol->il_operand_list = new il_operand_list_c; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
937 |
if (NULL == symbol->il_operand_list) ERROR; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
938 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
939 |
symbol->il_operand_list->accept(*this); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
940 |
|
451 | 941 |
if (NULL != prev_il_instruction) { |
942 |
((list_c *)symbol->il_operand_list)->insert_element(prev_il_instruction, 0); |
|
943 |
||
944 |
generic_function_call_t fcall_param = { |
|
945 |
/* fcall_param.function_name = */ symbol->function_name, |
|
946 |
/* fcall_param.nonformal_operand_list = */ symbol->il_operand_list, |
|
947 |
/* fcall_param.formal_operand_list = */ NULL, |
|
948 |
/* enum {POU_FB, POU_function} POU_type = */ generic_function_call_t::POU_function, |
|
949 |
/* fcall_param.candidate_functions = */ symbol->candidate_functions, |
|
950 |
/* fcall_param.called_function_declaration = */ symbol->called_function_declaration, |
|
951 |
/* fcall_param.extensible_param_count = */ symbol->extensible_param_count |
|
952 |
}; |
|
953 |
handle_function_call(symbol, fcall_param); |
|
954 |
||
955 |
/* Undo the changes to the abstract syntax tree we made above... */ |
|
956 |
((list_c *)symbol->il_operand_list)->remove_element(0); |
|
957 |
} |
|
958 |
||
959 |
/* Undo the changes to the abstract syntax tree we made above... */ |
|
960 |
if (((list_c *)symbol->il_operand_list)->n == 0) { |
|
961 |
/* if the list becomes empty, then that means that it did not exist before we made these changes, so we delete it! */ |
|
962 |
delete symbol->il_operand_list; |
|
963 |
symbol->il_operand_list = NULL; |
|
964 |
} |
|
965 |
||
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
966 |
if (debug) std::cout << "il_function_call_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
967 |
return NULL; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
968 |
} |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
969 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
970 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
971 |
/* | il_expr_operator '(' [il_operand] eol_list [simple_instr_list] ')' */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
972 |
// SYM_REF3(il_expression_c, il_expr_operator, il_operand, simple_instr_list); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
973 |
void *fill_candidate_datatypes_c::visit(il_expression_c *symbol) { |
453
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
974 |
symbol_c *prev_il_instruction_backup = prev_il_instruction; |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
975 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
976 |
if (NULL != symbol->il_operand) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
977 |
symbol->il_operand->accept(*this); |
453
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
978 |
|
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
979 |
if(symbol->simple_instr_list != NULL) |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
980 |
symbol->simple_instr_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
981 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
982 |
/* Now check the if the data type semantics of operation are correct, */ |
452
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
983 |
il_operand = symbol->simple_instr_list; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
984 |
prev_il_instruction = prev_il_instruction_backup; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
985 |
symbol->il_expr_operator->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
986 |
il_operand = NULL; |
454
099aa5d655de
Finish support for semantic verification of IL paranthesised expressions.
Mario de Sousa <msousa@fe.up.pt>
parents:
453
diff
changeset
|
987 |
|
099aa5d655de
Finish support for semantic verification of IL paranthesised expressions.
Mario de Sousa <msousa@fe.up.pt>
parents:
453
diff
changeset
|
988 |
/* This object has the same candidate datatypes as the il_expr_operator. */ |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
989 |
symbol->candidate_datatypes = symbol->il_expr_operator->candidate_datatypes; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
990 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
991 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
992 |
|
462
f7dada0a8952
Fix filling candidate datatypes of JMP operations
Mario de Sousa <msousa@fe.up.pt>
parents:
459
diff
changeset
|
993 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
994 |
void *fill_candidate_datatypes_c::visit(il_jump_operation_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
995 |
/* recursive call to fill the candidate data types list */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
996 |
il_operand = NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
997 |
symbol->il_jump_operator->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
998 |
il_operand = NULL; |
462
f7dada0a8952
Fix filling candidate datatypes of JMP operations
Mario de Sousa <msousa@fe.up.pt>
parents:
459
diff
changeset
|
999 |
/* This object has the same candidate datatypes as the il_jump_operator. */ |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
1000 |
symbol->candidate_datatypes = symbol->il_jump_operator->candidate_datatypes; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1001 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1002 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1003 |
|
439
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1004 |
|
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1005 |
/* il_call_operator prev_declared_fb_name |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1006 |
* | il_call_operator prev_declared_fb_name '(' ')' |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1007 |
* | il_call_operator prev_declared_fb_name '(' eol_list ')' |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1008 |
* | il_call_operator prev_declared_fb_name '(' il_operand_list ')' |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1009 |
* | il_call_operator prev_declared_fb_name '(' eol_list il_param_list ')' |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1010 |
*/ |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1011 |
/* NOTE: The parameter 'called_fb_declaration'is used to pass data between stage 3 and stage4 (although currently it is not used in stage 4 */ |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1012 |
// SYM_REF4(il_fb_call_c, il_call_operator, fb_name, il_operand_list, il_param_list, symbol_c *called_fb_declaration) |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1013 |
void *fill_candidate_datatypes_c::visit(il_fb_call_c *symbol) { |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1014 |
/* We do not call |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1015 |
* fb_decl = search_varfb_instance_type->get_basetype_decl(symbol->fb_name); |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1016 |
* because we want to make sure it is a FB instance, and not some other data type... |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1017 |
*/ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1018 |
symbol_c *fb_type_id = search_varfb_instance_type->get_basetype_id(symbol->fb_name); |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1019 |
/* Although a call to a non-declared FB is a semantic error, this is currently caught by stage 2! */ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1020 |
if (NULL == fb_type_id) ERROR; |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1021 |
|
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1022 |
function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(fb_type_id); |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1023 |
if (function_block_type_symtable.end_value() == fb_decl) |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1024 |
/* The fb_name not the name of a FB instance. Most probably it is the name of a variable of some other type. */ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1025 |
fb_decl = NULL; |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1026 |
|
439
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1027 |
/* Although a call to a non-declared FB is a semantic error, this is currently caught by stage 2! */ |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1028 |
if (NULL == fb_decl) ERROR; |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1029 |
|
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1030 |
if (symbol-> il_param_list != NULL) symbol->il_param_list->accept(*this); |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1031 |
if (symbol->il_operand_list != NULL) symbol->il_operand_list->accept(*this); |
439
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1032 |
|
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1033 |
/* The print_datatypes_error_c does not rely on this called_fb_declaration pointer being != NULL to conclude that |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1034 |
* we have a datat type incompatibility error, so setting it to the correct fb_decl is actually safe, |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1035 |
* as the compiler will never reach the compilation stage! |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1036 |
*/ |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1037 |
symbol->called_fb_declaration = fb_decl; |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1038 |
|
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1039 |
/* Let the il_call_operator (CAL, CALC, or CALCN) determine the candidate datatypes of the il_fb_call_c... */ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1040 |
/* NOTE: We ignore whether the call is 'compatible' or not when filling in the candidate datatypes list. |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1041 |
* Even if it is not compatible, we fill in the candidate datatypes list correctly so that the following |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1042 |
* IL instructions may be handled correctly and debuged. |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1043 |
* Doing this is actually safe, as the parameter_list will still contain errors that will be found by |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1044 |
* print_datatypes_error_c, so the code will never reach stage 4! |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1045 |
*/ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1046 |
symbol->il_call_operator->accept(*this); |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
1047 |
symbol->candidate_datatypes = symbol->il_call_operator->candidate_datatypes; |
450
eb1b28acec2e
Fix a few more bugs related to FB/function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
449
diff
changeset
|
1048 |
|
439
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1049 |
if (debug) std::cout << "FB [] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1050 |
return NULL; |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1051 |
} |
cf7d6862033d
Add semantic verification of FB calls in IL (not yet complete - missing printing of errors!)
Mario de Sousa <msousa@fe.up.pt>
parents:
438
diff
changeset
|
1052 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1053 |
|
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1054 |
/* | function_name '(' eol_list [il_param_list] ')' */ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1055 |
/* NOTE: The parameter 'called_function_declaration' is used to pass data between the stage 3 and stage 4. */ |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1056 |
// SYM_REF2(il_formal_funct_call_c, function_name, il_param_list, symbol_c *called_function_declaration; int extensible_param_count;) |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1057 |
void *fill_candidate_datatypes_c::visit(il_formal_funct_call_c *symbol) { |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1058 |
symbol->il_param_list->accept(*this); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1059 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1060 |
generic_function_call_t fcall_param = { |
441
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1061 |
/* fcall_param.function_name = */ symbol->function_name, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1062 |
/* fcall_param.nonformal_operand_list = */ NULL, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1063 |
/* fcall_param.formal_operand_list = */ symbol->il_param_list, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1064 |
/* enum {POU_FB, POU_function} POU_type = */ generic_function_call_t::POU_function, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1065 |
/* fcall_param.candidate_functions = */ symbol->candidate_functions, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1066 |
/* fcall_param.called_function_declaration = */ symbol->called_function_declaration, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1067 |
/* fcall_param.extensible_param_count = */ symbol->extensible_param_count |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1068 |
}; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1069 |
handle_function_call(symbol, fcall_param); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1070 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1071 |
if (debug) std::cout << "il_formal_funct_call_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1072 |
return NULL; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1073 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1074 |
|
452
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1075 |
|
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1076 |
// void *visit(il_operand_list_c *symbol); |
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1077 |
|
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1078 |
|
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1079 |
/* | simple_instr_list il_simple_instruction */ |
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1080 |
/* This object is referenced by il_expression_c objects */ |
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1081 |
void *fill_candidate_datatypes_c::visit(simple_instr_list_c *symbol) { |
453
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1082 |
if (symbol->n <= 0) |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1083 |
return NULL; /* List is empty! Nothing to do. */ |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1084 |
|
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1085 |
for(int i = 0; i < symbol->n; i++) |
452
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1086 |
symbol->elements[i]->accept(*this); |
453
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1087 |
|
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1088 |
/* This object has (inherits) the same candidate datatypes as the last il_instruction */ |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
1089 |
symbol->candidate_datatypes = symbol->elements[symbol->n-1]->candidate_datatypes; |
452
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1090 |
|
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1091 |
if (debug) std::cout << "simple_instr_list_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1092 |
return NULL; |
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1093 |
} |
79ac274d1cc4
Start of support for IL expressions (parenthesis).
Mario de Sousa <msousa@fe.up.pt>
parents:
451
diff
changeset
|
1094 |
|
457
67d8b07bac22
Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents:
456
diff
changeset
|
1095 |
|
67d8b07bac22
Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents:
456
diff
changeset
|
1096 |
|
67d8b07bac22
Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents:
456
diff
changeset
|
1097 |
|
453
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1098 |
// SYM_REF1(il_simple_instruction_c, il_simple_instruction, symbol_c *prev_il_instruction;) |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1099 |
void *fill_candidate_datatypes_c::visit(il_simple_instruction_c *symbol) { |
459
01f6664bf8c5
Continue adding support for semantic verification of JMP and RET.
Mario de Sousa <msousa@fe.up.pt>
parents:
457
diff
changeset
|
1100 |
if (symbol->prev_il_instruction.size() > 1) ERROR; /* There should be no labeled insructions inside an IL expression! */ |
457
67d8b07bac22
Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents:
456
diff
changeset
|
1101 |
if (symbol->prev_il_instruction.size() == 0) prev_il_instruction = NULL; |
67d8b07bac22
Change prev_il_instruction to a vector<>
Mario de Sousa <msousa@fe.up.pt>
parents:
456
diff
changeset
|
1102 |
else prev_il_instruction = symbol->prev_il_instruction[0]; |
453
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1103 |
symbol->il_simple_instruction->accept(*this); |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1104 |
prev_il_instruction = NULL; |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1105 |
|
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1106 |
/* This object has (inherits) the same candidate datatypes as the il_simple_instruction it points to */ |
467
4910eaa1206a
Delete no longer needed copy_candidate_datatype_list() function.
Mario de Sousa <msousa@fe.up.pt>
parents:
465
diff
changeset
|
1107 |
symbol->candidate_datatypes = symbol->il_simple_instruction->candidate_datatypes; |
453
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1108 |
return NULL; |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1109 |
} |
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1110 |
|
4733f662362a
More changes for support of semantic verification of il_expressions
Mario de Sousa <msousa@fe.up.pt>
parents:
452
diff
changeset
|
1111 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1112 |
/* |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1113 |
void *visit(il_param_list_c *symbol); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1114 |
void *visit(il_param_assignment_c *symbol); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1115 |
void *visit(il_param_out_assignment_c *symbol); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1116 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1117 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1118 |
/*******************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1119 |
/* B 2.2 Operators */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1120 |
/*******************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1121 |
void *fill_candidate_datatypes_c::visit(LD_operator_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1122 |
for(unsigned int i = 0; i < il_operand->candidate_datatypes.size(); i++) { |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1123 |
add_datatype_to_candidate_list(symbol, il_operand->candidate_datatypes[i]); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1124 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1125 |
if (debug) std::cout << "LD [" << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1126 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1127 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1128 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1129 |
void *fill_candidate_datatypes_c::visit(LDN_operator_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1130 |
for(unsigned int i = 0; i < il_operand->candidate_datatypes.size(); i++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1131 |
if (is_ANY_BIT_compatible(il_operand->candidate_datatypes[i])) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1132 |
add_datatype_to_candidate_list(symbol, il_operand->candidate_datatypes[i]); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1133 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1134 |
if (debug) std::cout << "LDN [" << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1135 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1136 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1137 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1138 |
void *fill_candidate_datatypes_c::visit(ST_operator_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1139 |
symbol_c *prev_instruction_type, *operand_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1140 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1141 |
if (NULL == prev_il_instruction) return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1142 |
for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1143 |
for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1144 |
prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1145 |
operand_type = il_operand->candidate_datatypes[j]; |
440
a745f7d38a5d
Fix typo error in some il visit in fill_candidate_datatypes_c class.
Manuele Conti <conti.ma@alice.it>
parents:
439
diff
changeset
|
1146 |
if (is_type_equal(prev_instruction_type, operand_type)) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1147 |
add_datatype_to_candidate_list(symbol, prev_instruction_type); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1148 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1149 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1150 |
if (debug) std::cout << "ST [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1151 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1152 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1153 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1154 |
void *fill_candidate_datatypes_c::visit(STN_operator_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1155 |
symbol_c *prev_instruction_type, *operand_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1156 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1157 |
if (NULL == prev_il_instruction) return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1158 |
for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1159 |
for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1160 |
prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1161 |
operand_type = il_operand->candidate_datatypes[j]; |
440
a745f7d38a5d
Fix typo error in some il visit in fill_candidate_datatypes_c class.
Manuele Conti <conti.ma@alice.it>
parents:
439
diff
changeset
|
1162 |
if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BIT_compatible(operand_type)) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1163 |
add_datatype_to_candidate_list(symbol, prev_instruction_type); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1164 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1165 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1166 |
if (debug) std::cout << "STN [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1167 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1168 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1169 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1170 |
void *fill_candidate_datatypes_c::visit(NOT_operator_c *symbol) { |
470
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1171 |
/* NOTE: the standard allows syntax in which the NOT operator is followed by an optional <il_operand> |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1172 |
* NOT [<il_operand>] |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1173 |
* However, it does not define the semantic of the NOT operation when the <il_operand> is specified. |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1174 |
* We therefore consider it an error if an il_operand is specified! |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1175 |
*/ |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1176 |
if (NULL == prev_il_instruction) return NULL; |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1177 |
for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1178 |
if (is_ANY_BIT_compatible(prev_il_instruction->candidate_datatypes[i])) |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1179 |
add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]); |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1180 |
} |
d2cd05c5e01a
Semantic verification of NOT operator.
Mario de Sousa <msousa@fe.up.pt>
parents:
467
diff
changeset
|
1181 |
if (debug) std::cout << "NOT_operator [" << prev_il_instruction->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1182 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1183 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1184 |
|
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
1185 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1186 |
void *fill_candidate_datatypes_c::visit(S_operator_c *symbol) { |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
1187 |
/* TODO: what if this is a FB call ?? */ |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1188 |
symbol_c *prev_instruction_type, *operand_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1189 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1190 |
if (NULL == prev_il_instruction) return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1191 |
for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1192 |
for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1193 |
prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1194 |
operand_type = il_operand->candidate_datatypes[j]; |
473 | 1195 |
/* TODO: I believe the following is wrong! The data types of prev_instruction_type and operand_type DO NOT have to be equal. |
1196 |
* the prev_instruction_type MUST be BOOL compatible. |
|
1197 |
* I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check! |
|
1198 |
*/ |
|
440
a745f7d38a5d
Fix typo error in some il visit in fill_candidate_datatypes_c class.
Manuele Conti <conti.ma@alice.it>
parents:
439
diff
changeset
|
1199 |
if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type)) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1200 |
add_datatype_to_candidate_list(symbol, prev_instruction_type); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1201 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1202 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1203 |
if (debug) std::cout << "S [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1204 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1205 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1206 |
|
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
1207 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1208 |
void *fill_candidate_datatypes_c::visit(R_operator_c *symbol) { |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
1209 |
/* TODO: what if this is a FB call ?? */ |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1210 |
symbol_c *prev_instruction_type, *operand_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1211 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1212 |
if (NULL == prev_il_instruction) return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1213 |
for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1214 |
for(unsigned int j = 0; j < il_operand->candidate_datatypes.size(); j++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1215 |
prev_instruction_type = prev_il_instruction->candidate_datatypes[i]; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1216 |
operand_type = il_operand->candidate_datatypes[j]; |
473 | 1217 |
/* TODO: I believe the following is wrong! The data types of prev_instruction_type and operand_type DO NOT have to be equal. |
1218 |
* the prev_instruction_type MUST be BOOL compatible. |
|
1219 |
* I am not too sure about operand_type, does it have to be BOOL compatible, or can it be ANY_BIT compatible? Must check! |
|
1220 |
*/ |
|
440
a745f7d38a5d
Fix typo error in some il visit in fill_candidate_datatypes_c class.
Manuele Conti <conti.ma@alice.it>
parents:
439
diff
changeset
|
1221 |
if (is_type_equal(prev_instruction_type,operand_type) && is_ANY_BOOL_compatible(operand_type)) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1222 |
add_datatype_to_candidate_list(symbol, prev_instruction_type); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1223 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1224 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1225 |
if (debug) std::cout << "R [" << prev_il_instruction->candidate_datatypes.size() << "," << il_operand->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1226 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1227 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1228 |
|
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
1229 |
|
489
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1230 |
void *fill_candidate_datatypes_c::visit( S1_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "S1", symbol->called_fb_declaration);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1231 |
void *fill_candidate_datatypes_c::visit( R1_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "R1", symbol->called_fb_declaration);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1232 |
void *fill_candidate_datatypes_c::visit( CLK_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "CLK", symbol->called_fb_declaration);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1233 |
void *fill_candidate_datatypes_c::visit( CU_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "CU", symbol->called_fb_declaration);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1234 |
void *fill_candidate_datatypes_c::visit( CD_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "CD", symbol->called_fb_declaration);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1235 |
void *fill_candidate_datatypes_c::visit( PV_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "PV", symbol->called_fb_declaration);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1236 |
void *fill_candidate_datatypes_c::visit( IN_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "IN", symbol->called_fb_declaration);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1237 |
void *fill_candidate_datatypes_c::visit( PT_operator_c *symbol) {return handle_implicit_il_fb_call(symbol, "PT", symbol->called_fb_declaration);} |
447
aad0f3e5df33
Start of support for semantic verification of FB calls in IL using special IL instructions.
Mario de Sousa <msousa@fe.up.pt>
parents:
445
diff
changeset
|
1238 |
|
483
7f839fb100c1
Cleaning up XORN, ANDN, and ORN operator code.
Mario de Sousa <msousa@fe.up.pt>
parents:
481
diff
changeset
|
1239 |
void *fill_candidate_datatypes_c::visit( AND_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);} |
489
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1240 |
void *fill_candidate_datatypes_c::visit( OR_operator_c *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);} |
483
7f839fb100c1
Cleaning up XORN, ANDN, and ORN operator code.
Mario de Sousa <msousa@fe.up.pt>
parents:
481
diff
changeset
|
1241 |
void *fill_candidate_datatypes_c::visit( XOR_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);} |
7f839fb100c1
Cleaning up XORN, ANDN, and ORN operator code.
Mario de Sousa <msousa@fe.up.pt>
parents:
481
diff
changeset
|
1242 |
void *fill_candidate_datatypes_c::visit(ANDN_operator_c *symbol) {return handle_binary_operator(widen_AND_table, symbol, prev_il_instruction, il_operand);} |
7f839fb100c1
Cleaning up XORN, ANDN, and ORN operator code.
Mario de Sousa <msousa@fe.up.pt>
parents:
481
diff
changeset
|
1243 |
void *fill_candidate_datatypes_c::visit( ORN_operator_c *symbol) {return handle_binary_operator( widen_OR_table, symbol, prev_il_instruction, il_operand);} |
7f839fb100c1
Cleaning up XORN, ANDN, and ORN operator code.
Mario de Sousa <msousa@fe.up.pt>
parents:
481
diff
changeset
|
1244 |
void *fill_candidate_datatypes_c::visit(XORN_operator_c *symbol) {return handle_binary_operator(widen_XOR_table, symbol, prev_il_instruction, il_operand);} |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1245 |
|
489
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1246 |
void *fill_candidate_datatypes_c::visit( ADD_operator_c *symbol) {return handle_binary_operator(widen_ADD_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1247 |
void *fill_candidate_datatypes_c::visit( SUB_operator_c *symbol) {return handle_binary_operator(widen_SUB_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1248 |
void *fill_candidate_datatypes_c::visit( MUL_operator_c *symbol) {return handle_binary_operator(widen_MUL_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1249 |
void *fill_candidate_datatypes_c::visit( DIV_operator_c *symbol) {return handle_binary_operator(widen_DIV_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1250 |
void *fill_candidate_datatypes_c::visit( MOD_operator_c *symbol) {return handle_binary_operator(widen_MOD_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1251 |
|
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1252 |
void *fill_candidate_datatypes_c::visit( GT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1253 |
void *fill_candidate_datatypes_c::visit( GE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1254 |
void *fill_candidate_datatypes_c::visit( EQ_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1255 |
void *fill_candidate_datatypes_c::visit( LT_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1256 |
void *fill_candidate_datatypes_c::visit( LE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1257 |
void *fill_candidate_datatypes_c::visit( NE_operator_c *symbol) {return handle_binary_operator(widen_CMP_table, symbol, prev_il_instruction, il_operand);} |
484
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1258 |
|
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1259 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1260 |
|
487 | 1261 |
void *fill_candidate_datatypes_c::handle_conditional_il_flow_control_operator(symbol_c *symbol) { |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1262 |
if (NULL == prev_il_instruction) return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1263 |
for (unsigned int i = 0; i < prev_il_instruction->candidate_datatypes.size(); i++) { |
472
d26759a2274a
Clean up code, and add support for 'safe' version of literals.
Mario de Sousa <msousa@fe.up.pt>
parents:
470
diff
changeset
|
1264 |
if (is_ANY_BOOL_compatible(prev_il_instruction->candidate_datatypes[i])) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1265 |
add_datatype_to_candidate_list(symbol, prev_il_instruction->candidate_datatypes[i]); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1266 |
} |
487 | 1267 |
return NULL; |
1268 |
} |
|
1269 |
||
489
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1270 |
void *fill_candidate_datatypes_c::visit( CAL_operator_c *symbol) {if (NULL != prev_il_instruction) symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1271 |
void *fill_candidate_datatypes_c::visit( RET_operator_c *symbol) {if (NULL != prev_il_instruction) symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;} |
2c874cccbb44
Some stupid code cleanups.
Mario de Sousa <msousa@fe.up.pt>
parents:
488
diff
changeset
|
1272 |
void *fill_candidate_datatypes_c::visit( JMP_operator_c *symbol) {if (NULL != prev_il_instruction) symbol->candidate_datatypes = prev_il_instruction->candidate_datatypes; return NULL;} |
487 | 1273 |
void *fill_candidate_datatypes_c::visit( CALC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);} |
1274 |
void *fill_candidate_datatypes_c::visit(CALCN_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);} |
|
1275 |
void *fill_candidate_datatypes_c::visit( RETC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);} |
|
1276 |
void *fill_candidate_datatypes_c::visit(RETCN_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);} |
|
1277 |
void *fill_candidate_datatypes_c::visit( JMPC_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);} |
|
1278 |
void *fill_candidate_datatypes_c::visit(JMPCN_operator_c *symbol) {return handle_conditional_il_flow_control_operator(symbol);} |
|
1279 |
||
1280 |
||
1281 |
||
1282 |
||
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1283 |
/* Symbol class handled together with function call checks */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1284 |
// void *visit(il_assign_operator_c *symbol, variable_name); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1285 |
/* Symbol class handled together with function call checks */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1286 |
// void *visit(il_assign_operator_c *symbol, option, variable_name); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1287 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1288 |
/***************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1289 |
/* B.3 - Language ST (Structured Text) */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1290 |
/***************************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1291 |
/***********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1292 |
/* B 3.1 - Expressions */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1293 |
/***********************/ |
484
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1294 |
void *fill_candidate_datatypes_c::visit( or_expression_c *symbol) {return handle_binary_expression(widen_OR_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1295 |
void *fill_candidate_datatypes_c::visit( xor_expression_c *symbol) {return handle_binary_expression(widen_XOR_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1296 |
void *fill_candidate_datatypes_c::visit( and_expression_c *symbol) {return handle_binary_expression(widen_AND_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1297 |
|
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1298 |
void *fill_candidate_datatypes_c::visit( equ_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1299 |
void *fill_candidate_datatypes_c::visit(notequ_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1300 |
void *fill_candidate_datatypes_c::visit( lt_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1301 |
void *fill_candidate_datatypes_c::visit( gt_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1302 |
void *fill_candidate_datatypes_c::visit( le_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);} |
f78750994a82
Clean code for comparison operations & operators.
Mario de Sousa <msousa@fe.up.pt>
parents:
483
diff
changeset
|
1303 |
void *fill_candidate_datatypes_c::visit( ge_expression_c *symbol) {return handle_binary_expression(widen_CMP_table, symbol, symbol->l_exp, symbol->r_exp);} |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1304 |
|
479 | 1305 |
|
1306 |
/* The following code is correct when handling the addition of 2 symbolic_variables |
|
1307 |
* In this case, adding two variables (e.g. USINT_var1 + USINT_var2) will always yield |
|
1308 |
* the same data type, even if the result of the adition could not fit inside the same |
|
1309 |
* data type (due to overflowing) |
|
1310 |
* |
|
1311 |
* However, when adding two literals (e.g. USINT#42 + USINT#3) |
|
1312 |
* we should be able to detect overflows of the result, and therefore not consider |
|
1313 |
* that the result may be of type USINT. |
|
1314 |
* Currently we do not yet detect these overflows, and allow handling the sum of two USINTs |
|
1315 |
* as always resulting in an USINT, even in the following expression |
|
1316 |
* (USINT#65535 + USINT#2). |
|
1317 |
* |
|
1318 |
* In the future we can add some code to reduce |
|
1319 |
* all the expressions that are based on literals into the resulting literal |
|
1320 |
* value (maybe some visitor class that will run before or after data type |
|
1321 |
* checking). Since this class will have to be very careful to make sure it implements the same mathematical |
|
1322 |
* details (e.g. how to round and truncate numbers) as defined in IEC 61131-3, we will leave this to the future. |
|
1323 |
* Also, the question will arise if we should also replace calls to standard |
|
1324 |
* functions if the input parameters are all literals (e.g. ADD(42, 42)). This |
|
1325 |
* means this class will be more difficult than it appears at first. |
|
1326 |
*/ |
|
490 | 1327 |
void *fill_candidate_datatypes_c::visit( add_expression_c *symbol) {return handle_binary_expression(widen_ADD_table, symbol, symbol->l_exp, symbol->r_exp);} |
1328 |
void *fill_candidate_datatypes_c::visit( sub_expression_c *symbol) {return handle_binary_expression(widen_SUB_table, symbol, symbol->l_exp, symbol->r_exp);} |
|
1329 |
void *fill_candidate_datatypes_c::visit( mul_expression_c *symbol) {return handle_binary_expression(widen_MUL_table, symbol, symbol->l_exp, symbol->r_exp);} |
|
1330 |
void *fill_candidate_datatypes_c::visit( div_expression_c *symbol) {return handle_binary_expression(widen_DIV_table, symbol, symbol->l_exp, symbol->r_exp);} |
|
1331 |
void *fill_candidate_datatypes_c::visit( mod_expression_c *symbol) {return handle_binary_expression(widen_MOD_table, symbol, symbol->l_exp, symbol->r_exp);} |
|
1332 |
void *fill_candidate_datatypes_c::visit(power_expression_c *symbol) {return handle_binary_expression(widen_EXPT_table, symbol, symbol->l_exp, symbol->r_exp);} |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1333 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1334 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1335 |
void *fill_candidate_datatypes_c::visit(neg_expression_c *symbol) { |
435
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1336 |
/* NOTE: The standard defines the syntax for this 'negation' operation, but |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1337 |
* does not define the its semantics. |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1338 |
* |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1339 |
* We could be tempted to consider that the semantics of the |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1340 |
* 'negation' operation are similar/identical to the semantics of the |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1341 |
* SUB expression/operation. This would include assuming that the |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1342 |
* possible datatypes for the 'negation' operation is also |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1343 |
* the same as those for the SUB expression/operation, namely ANY_MAGNITUDE. |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1344 |
* |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1345 |
* However, this would then mean that the following ST code would be |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1346 |
* syntactically and semantically correct: |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1347 |
* uint_var := - (uint_var); |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1348 |
* |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1349 |
* According to the standard, the above code should result in a |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1350 |
* runtime error, when we try to apply a negative value to the |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1351 |
* UINT typed variable 'uint_var'. |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1352 |
* |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1353 |
* It is much easier for the compiler to detect this at compile time, |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1354 |
* and it is probably safer to the resulting code too. |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1355 |
* |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1356 |
* To detect these tyes of errors at compile time, the easisest solution |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1357 |
* is to only allow ANY_NUM datatytpes that are signed. |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1358 |
* So, that is what we do here! |
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1359 |
*/ |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1360 |
symbol->exp->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1361 |
for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) { |
435
82cb6a64a763
Change negation expression (neg_expression_c) to only allow signed data types.
Mario de Sousa <msousa@fe.up.pt>
parents:
431
diff
changeset
|
1362 |
if (is_ANY_signed_MAGNITUDE_compatible(symbol->exp->candidate_datatypes[i])) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1363 |
add_datatype_to_candidate_list(symbol, symbol->exp->candidate_datatypes[i]); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1364 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1365 |
if (debug) std::cout << "neg [" << symbol->exp->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1366 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1367 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1368 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1369 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1370 |
void *fill_candidate_datatypes_c::visit(not_expression_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1371 |
symbol->exp->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1372 |
for (unsigned int i = 0; i < symbol->exp->candidate_datatypes.size(); i++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1373 |
if (is_ANY_BIT_compatible(symbol->exp->candidate_datatypes[i])) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1374 |
add_datatype_to_candidate_list(symbol, symbol->exp->candidate_datatypes[i]); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1375 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1376 |
if (debug) std::cout << "not [" << symbol->exp->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1377 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1378 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1379 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1380 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1381 |
void *fill_candidate_datatypes_c::visit(function_invocation_c *symbol) { |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1382 |
if (NULL != symbol->formal_param_list) symbol-> formal_param_list->accept(*this); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1383 |
else if (NULL != symbol->nonformal_param_list) symbol->nonformal_param_list->accept(*this); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1384 |
else ERROR; |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1385 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1386 |
generic_function_call_t fcall_param = { |
441
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1387 |
/* fcall_param.function_name = */ symbol->function_name, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1388 |
/* fcall_param.nonformal_operand_list = */ symbol->nonformal_param_list, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1389 |
/* fcall_param.formal_operand_list = */ symbol->formal_param_list, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1390 |
/* enum {POU_FB, POU_function} POU_type = */ generic_function_call_t::POU_function, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1391 |
/* fcall_param.candidate_functions = */ symbol->candidate_functions, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1392 |
/* fcall_param.called_function_declaration = */ symbol->called_function_declaration, |
e8de43eefcc5
Add printing of semantic errors when calling FB from IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
440
diff
changeset
|
1393 |
/* fcall_param.extensible_param_count = */ symbol->extensible_param_count |
438
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1394 |
}; |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1395 |
handle_function_call(symbol, fcall_param); |
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1396 |
|
744b125d911e
Add support for semantic verification of function calls in IL.
Mario de Sousa <msousa@fe.up.pt>
parents:
437
diff
changeset
|
1397 |
if (debug) std::cout << "function_invocation_c [" << symbol->candidate_datatypes.size() << "] result.\n"; |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1398 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1399 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1400 |
|
421
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
1401 |
|
840cb1e1e177
Add support in stage 3 for checking function invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
420
diff
changeset
|
1402 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1403 |
/********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1404 |
/* B 3.2 Statements */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1405 |
/********************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1406 |
// SYM_LIST(statement_list_c) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1407 |
/* The visitor of the base class search_visitor_c will handle calling each instruction in the list. |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1408 |
* We do not need to do anything here... |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1409 |
*/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1410 |
// void *fill_candidate_datatypes_c::visit(statement_list_c *symbol) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1411 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1412 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1413 |
/*********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1414 |
/* B 3.2.1 Assignment Statements */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1415 |
/*********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1416 |
void *fill_candidate_datatypes_c::visit(assignment_statement_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1417 |
symbol_c *left_type, *right_type; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1418 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1419 |
symbol->l_exp->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1420 |
symbol->r_exp->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1421 |
for (unsigned int i = 0; i < symbol->l_exp->candidate_datatypes.size(); i++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1422 |
for(unsigned int j = 0; j < symbol->r_exp->candidate_datatypes.size(); j++) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1423 |
left_type = symbol->l_exp->candidate_datatypes[i]; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1424 |
right_type = symbol->r_exp->candidate_datatypes[j]; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1425 |
if (is_type_equal(left_type, right_type)) |
465
b52ec62773db
Do not allow duplicate values in candidate datatype list.
Mario de Sousa <msousa@fe.up.pt>
parents:
464
diff
changeset
|
1426 |
add_datatype_to_candidate_list(symbol, left_type); |
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1427 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1428 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1429 |
if (debug) std::cout << ":= [" << symbol->l_exp->candidate_datatypes.size() << "," << symbol->r_exp->candidate_datatypes.size() << "] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1430 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1431 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1432 |
|
418
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1433 |
/*****************************************/ |
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1434 |
/* B 3.2.2 Subprogram Control Statements */ |
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1435 |
/*****************************************/ |
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1436 |
void *fill_candidate_datatypes_c::visit(fb_invocation_c *symbol) { |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1437 |
symbol_c *fb_type_id = search_varfb_instance_type->get_basetype_id(symbol->fb_name); |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1438 |
/* Although a call to a non-declared FB is a semantic error, this is currently caught by stage 2! */ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1439 |
if (NULL == fb_type_id) ERROR; |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1440 |
|
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1441 |
function_block_declaration_c *fb_decl = function_block_type_symtable.find_value(fb_type_id); |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1442 |
if (function_block_type_symtable.end_value() == fb_decl) |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1443 |
/* The fb_name not the name of a FB instance. Most probably it is the name of a variable of some other type. */ |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1444 |
fb_decl = NULL; |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1445 |
|
424
43d73e28eca8
Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents:
422
diff
changeset
|
1446 |
/* Although a call to a non-declared FB is a semantic error, this is currently caught by stage 2! */ |
418
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1447 |
if (NULL == fb_decl) ERROR; |
455
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1448 |
|
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1449 |
if (symbol-> formal_param_list != NULL) symbol->formal_param_list->accept(*this); |
933c0dccc82f
Add support for semantic verification of CALC, CALCN, etc..
Mario de Sousa <msousa@fe.up.pt>
parents:
454
diff
changeset
|
1450 |
if (symbol->nonformal_param_list != NULL) symbol->nonformal_param_list->accept(*this); |
424
43d73e28eca8
Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents:
422
diff
changeset
|
1451 |
|
431
5792016eedd8
More detailed error messages for FB invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
429
diff
changeset
|
1452 |
/* The print_datatypes_error_c does not rely on this called_fb_declaration pointer being != NULL to conclude that |
5792016eedd8
More detailed error messages for FB invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
429
diff
changeset
|
1453 |
* we have a datat type incompatibility error, so setting it to the correct fb_decl is actually safe, |
5792016eedd8
More detailed error messages for FB invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
429
diff
changeset
|
1454 |
* as the compiler will never reach the compilation stage! |
5792016eedd8
More detailed error messages for FB invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
429
diff
changeset
|
1455 |
*/ |
5792016eedd8
More detailed error messages for FB invocations in ST.
Mario de Sousa <msousa@fe.up.pt>
parents:
429
diff
changeset
|
1456 |
symbol->called_fb_declaration = fb_decl; |
424
43d73e28eca8
Continue checking data type compatibility inside expressions used to pass paramters to invalid function/FB calls
Mario de Sousa <msousa@fe.up.pt>
parents:
422
diff
changeset
|
1457 |
|
418
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1458 |
if (debug) std::cout << "FB [] ==> " << symbol->candidate_datatypes.size() << " result.\n"; |
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1459 |
return NULL; |
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1460 |
} |
2ac41d2cba91
Add fill candidate method for fb_invocation_c symbol.
Manuele Conti <conti.ma@alice.it>
parents:
417
diff
changeset
|
1461 |
|
417
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1462 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1463 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1464 |
/********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1465 |
/* B 3.2.3 Selection Statements */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1466 |
/********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1467 |
void *fill_candidate_datatypes_c::visit(if_statement_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1468 |
symbol->expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1469 |
if (NULL != symbol->statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1470 |
symbol->statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1471 |
if (NULL != symbol->elseif_statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1472 |
symbol->elseif_statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1473 |
if (NULL != symbol->else_statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1474 |
symbol->else_statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1475 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1476 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1477 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1478 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1479 |
void *fill_candidate_datatypes_c::visit(elseif_statement_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1480 |
symbol->expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1481 |
if (NULL != symbol->statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1482 |
symbol->statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1483 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1484 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1485 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1486 |
/* CASE expression OF case_element_list ELSE statement_list END_CASE */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1487 |
// SYM_REF3(case_statement_c, expression, case_element_list, statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1488 |
void *fill_candidate_datatypes_c::visit(case_statement_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1489 |
symbol->expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1490 |
if (NULL != symbol->case_element_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1491 |
symbol->case_element_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1492 |
if (NULL != symbol->statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1493 |
symbol->statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1494 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1495 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1496 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1497 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1498 |
/* helper symbol for case_statement */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1499 |
// SYM_LIST(case_element_list_c) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1500 |
/* NOTE: visitor method for case_element_list_c is not required since we inherit from iterator_visitor_c */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1501 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1502 |
/* case_list ':' statement_list */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1503 |
// SYM_REF2(case_element_c, case_list, statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1504 |
/* NOTE: visitor method for case_element_c is not required since we inherit from iterator_visitor_c */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1505 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1506 |
// SYM_LIST(case_list_c) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1507 |
/* NOTE: visitor method for case_list_c is not required since we inherit from iterator_visitor_c */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1508 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1509 |
/********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1510 |
/* B 3.2.4 Iteration Statements */ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1511 |
/********************************/ |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1512 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1513 |
void *fill_candidate_datatypes_c::visit(for_statement_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1514 |
symbol->control_variable->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1515 |
symbol->beg_expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1516 |
symbol->end_expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1517 |
if (NULL != symbol->by_expression) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1518 |
symbol->by_expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1519 |
if (NULL != symbol->statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1520 |
symbol->statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1521 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1522 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1523 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1524 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1525 |
void *fill_candidate_datatypes_c::visit(while_statement_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1526 |
symbol->expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1527 |
if (NULL != symbol->statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1528 |
symbol->statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1529 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1530 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1531 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1532 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1533 |
void *fill_candidate_datatypes_c::visit(repeat_statement_c *symbol) { |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1534 |
symbol->expression->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1535 |
if (NULL != symbol->statement_list) |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1536 |
symbol->statement_list->accept(*this); |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1537 |
return NULL; |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1538 |
} |
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1539 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1540 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1541 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1542 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1543 |
|
d48f53715f77
Re-write of stage3 code (done by Manuele and I), re-write of search_varfb_instance_type_c (done by myself), and several other bug fixes.
Mario de Sousa <msousa@fe.up.pt>
parents:
diff
changeset
|
1544 |