equal
deleted
inserted
replaced
80 /* initialize the iterator object. |
80 /* initialize the iterator object. |
81 * We must be given a reference to a array_specification_c that will be analyzed... |
81 * We must be given a reference to a array_specification_c that will be analyzed... |
82 */ |
82 */ |
83 array_dimension_iterator_c::array_dimension_iterator_c(symbol_c *symbol) { |
83 array_dimension_iterator_c::array_dimension_iterator_c(symbol_c *symbol) { |
84 /* do some consistency check... */ |
84 /* do some consistency check... */ |
85 array_specification_c* array_spec = dynamic_cast<array_specification_c*>(symbol); |
85 /* NOTE: We comment out the consistency check so the compiler does not bork when it encounters buggy source code. |
86 |
86 * e.g. Code that handles a non array variable as an array! |
87 if (NULL == array_spec) ERROR; |
87 * VAR v1, v2: int; END_VAR |
|
88 * v1 := v2[33, 45]; |
|
89 * The above error will be caught by the datatype checking algorithms! |
|
90 */ |
|
91 array_spec_init_c * array_spec_init = dynamic_cast<array_spec_init_c *>(symbol); |
|
92 if (NULL != array_spec_init) symbol = array_spec_init->array_specification; |
|
93 array_specification_c* array_spec = dynamic_cast<array_specification_c*>(symbol); |
|
94 // if (NULL == array_spec) ERROR; |
88 |
95 |
89 /* OK. Now initialize this object... */ |
96 /* OK. Now initialize this object... */ |
90 this->array_specification = symbol; |
97 this->array_specification = array_spec; // Set to array_spec and not symbol => will be NULL if not an array_specification_c* !! |
91 reset(); |
98 reset(); |
92 } |
99 } |
93 |
100 |
94 |
101 |
95 |
102 |
99 * reference the first subrange... |
106 * reference the first subrange... |
100 * |
107 * |
101 * Returns the subrange symbol! |
108 * Returns the subrange symbol! |
102 */ |
109 */ |
103 subrange_c *array_dimension_iterator_c::next(void) { |
110 subrange_c *array_dimension_iterator_c::next(void) { |
|
111 if (NULL == array_specification) return NULL; /* The source code probably has a bug which will be caught somewhere else! */ |
104 void *res = array_specification->accept(*this); |
112 void *res = array_specification->accept(*this); |
105 if (res == NULL) |
113 if (NULL == res) return NULL; |
106 return NULL; |
|
107 |
114 |
108 return current_array_dimension; |
115 return current_array_dimension; |
109 } |
116 } |
110 |
117 |
111 /********************************/ |
118 /********************************/ |