230 dimension = std::numeric_limits< unsigned long long int >::max() - 1; // -1 because it will be incremented at the end of this function!! |
230 dimension = std::numeric_limits< unsigned long long int >::max() - 1; // -1 because it will be incremented at the end of this function!! |
231 } else if (!VALID_CVALUE(uint64, symbol->lower_limit) && !VALID_CVALUE( int64, symbol->lower_limit)) { |
231 } else if (!VALID_CVALUE(uint64, symbol->lower_limit) && !VALID_CVALUE( int64, symbol->lower_limit)) { |
232 STAGE3_ERROR(0, symbol->lower_limit, symbol->lower_limit, "Subrange lower limit is not a constant value."); |
232 STAGE3_ERROR(0, symbol->lower_limit, symbol->lower_limit, "Subrange lower limit is not a constant value."); |
233 // set dimension to largest possible value so we do not get any further related error messages. |
233 // set dimension to largest possible value so we do not get any further related error messages. |
234 dimension = std::numeric_limits< unsigned long long int >::max() - 1; // -1 because it will be incremented at the end of this function!! |
234 dimension = std::numeric_limits< unsigned long long int >::max() - 1; // -1 because it will be incremented at the end of this function!! |
|
235 /* NOTE: Note that both the "subrange *** limit is not a constant value" error messages are only necessary due to an extension |
|
236 * that matiec supports by allowing non-literals in subrange declarations (currently only subranges in array declarations). |
|
237 * e.g.: array_var: ARRAY [1..max] of INT; <--- illegal according to IEC 61131-1 due to the 'max' non literal |
|
238 * Matiec will allow the above syntax, as long as the 'max' variable can be determined to be constant throughout |
|
239 * the program execution at runtime (and not only constant when program initiates) - for example, a VAR CONSTANT |
|
240 * variable. |
|
241 * These two checks will verify if we were able to fold the variable into a constant value, or not. |
|
242 */ |
235 } else {ERROR;} |
243 } else {ERROR;} |
236 |
244 |
237 /* correct value for dimension is actually ---> dimension = upper_limit - lower_limit + 1 |
245 /* correct value for dimension is actually ---> dimension = upper_limit - lower_limit + 1 |
238 * Up to now, we have only determined dimension = upper_limit - lower_limit |
246 * Up to now, we have only determined dimension = upper_limit - lower_limit |
239 * We must first check whether this last increment will cause an overflow! |
247 * We must first check whether this last increment will cause an overflow! |