diff -r 8ba9ec4bae50 -r bd1360f29f15 stage3/constant_folding.cc --- a/stage3/constant_folding.cc Thu Oct 04 14:30:51 2012 +0100 +++ b/stage3/constant_folding.cc Thu Oct 04 15:10:45 2012 +0100 @@ -332,12 +332,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) @@ -899,7 +906,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; +} @@ -1158,4 +1173,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) {}