# HG changeset patch # User Laurent Bessard # Date 1347546910 -7200 # Node ID 73b56dc69e610ae030316bba6f7cbea674c69f1d # Parent 76c3d707ffa1861ee3a91e49b32a5b4f4cdd75ba Fix bug with task interval using fixed_point value for duration items diff -r 76c3d707ffa1 -r 73b56dc69e61 stage3/constant_folding.cc --- a/stage3/constant_folding.cc Thu Sep 13 15:14:55 2012 +0200 +++ b/stage3/constant_folding.cc Thu Sep 13 16:35:10 2012 +0200 @@ -313,12 +313,19 @@ real64_t extract_real_value(symbol_c *sym, bool *overflow) { std::string str = ""; real_c *real_sym; + fixed_point_c *fixed_point_sym; char *endptr; real64_t ret; - if ((real_sym = dynamic_cast(sym)) == NULL) ERROR; - for(unsigned int i = 0; i < strlen(real_sym->value); i++) - if (real_sym->value[i] != '_') str += real_sym->value[i]; + if ((real_sym = dynamic_cast(sym)) != NULL) { + for(unsigned int i = 0; i < strlen(real_sym->value); i++) + if (real_sym->value[i] != '_') str += real_sym->value[i]; + } + else if ((fixed_point_sym = dynamic_cast(sym)) != NULL) { + for(unsigned int i = 0; i < strlen(fixed_point_sym->value); i++) + if (fixed_point_sym->value[i] != '_') str += fixed_point_sym->value[i]; + } + else ERROR; errno = 0; // since strtoXX() may legally return 0, we must set errno to 0 to detect errors correctly! #if (real64_t == float) @@ -835,7 +842,15 @@ return NULL; } - +/************************/ +/* B 1.2.3.1 - Duration */ +/********* **************/ +void *constant_folding_c::visit(fixed_point_c *symbol) { + bool overflow; + SET_CVALUE(real64, symbol, extract_real_value(symbol, &overflow)); + if (overflow) SET_OVFLOW(real64, symbol); + return NULL; +} @@ -1094,4 +1109,4 @@ void *constant_folding_c::visit( not_expression_c *symbol) {symbol-> exp->accept(*this); return handle_not(symbol, symbol->exp);} /* TODO: handle function invocations... */ -// void *fill_candidate_datatypes_c::visit(function_invocation_c *symbol) {} \ No newline at end of file +// void *fill_candidate_datatypes_c::visit(function_invocation_c *symbol) {} diff -r 76c3d707ffa1 -r 73b56dc69e61 stage3/constant_folding.hh --- a/stage3/constant_folding.hh Thu Sep 13 15:14:55 2012 +0200 +++ b/stage3/constant_folding.hh Thu Sep 13 16:35:10 2012 +0200 @@ -82,6 +82,11 @@ void *visit(boolean_true_c *symbol); void *visit(boolean_false_c *symbol); + /************************/ + /* B 1.2.3.1 - Duration */ + /********* **************/ + void *visit(fixed_point_c *symbol); + /****************************************/ /* B.2 - Language IL (Instruction List) */ /****************************************/