diff -r 61410284a9b4 -r dabffc3086dc absyntax_utils/absyntax_utils.cc --- a/absyntax_utils/absyntax_utils.cc Tue Jun 05 11:10:12 2012 +0200 +++ b/absyntax_utils/absyntax_utils.cc Tue Jun 05 19:17:29 2012 +0200 @@ -52,6 +52,7 @@ #include #include /* required for strlen() */ #include /* required for atoi() */ +#include /* required for errno */ #include "../util/symtable.hh" #include "../util/dsymtable.hh" @@ -115,6 +116,22 @@ return atoll(str.c_str()); } +uint64_t extract_hex_value(symbol_c *sym) { + std::string str = ""; + char *endptr; + hex_integer_c * hex_integer; + uint64_t ret; + + if ((hex_integer = dynamic_cast(sym)) == NULL) ERROR; + for(unsigned int i = 3; i < strlen(hex_integer->value); i++) + if (hex_integer->value[i] != '_') str += hex_integer->value[i]; + errno = 0; /* To distinguish success/failure after call */ + ret = strtol(str.c_str(), &endptr, 16); + if (errno != 0) ERROR; + + return ret; +} + /***********************************************************************/