--- 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 <strings.h>
#include <string.h> /* required for strlen() */
#include <stdlib.h> /* required for atoi() */
+#include <errno.h> /* 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<hex_integer_c *>(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;
+}
+
/***********************************************************************/