summaryrefslogtreecommitdiff
path: root/trace_parser.hpp
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-11-26 15:26:14 +0000
committerJosé Fonseca <jfonseca@vmware.com>2010-11-26 15:26:14 +0000
commitf84c70e16aaf953f8984981456f5baf8eada7153 (patch)
tree1b1584e39e4df5dea4a0b3cd750f53060e57b70d /trace_parser.hpp
parent2250a0e42a0fcad757f38121859ce7de10384df3 (diff)
More efficient enum representation.
Diffstat (limited to 'trace_parser.hpp')
-rw-r--r--trace_parser.hpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/trace_parser.hpp b/trace_parser.hpp
index 5d51315..254141c 100644
--- a/trace_parser.hpp
+++ b/trace_parser.hpp
@@ -59,6 +59,9 @@ protected:
typedef std::map<size_t, Call::Signature *> FunctionMap;
FunctionMap functions;
+ typedef std::map<size_t, Enum *> EnumMap;
+ EnumMap enums;
+
typedef std::map<size_t, Bitmask::Signature *> BitmaskMap;
BitmaskMap bitmasks;
@@ -207,8 +210,8 @@ public:
return parse_double();
case Trace::TYPE_STRING:
return parse_string();
- case Trace::TYPE_CONST:
- return parse_const();
+ case Trace::TYPE_ENUM:
+ return parse_enum();
case Trace::TYPE_BITMASK:
return parse_bitmask();
case Trace::TYPE_ARRAY:
@@ -250,10 +253,20 @@ public:
return new String(read_string());
}
- Value *parse_const() {
- std::string name = read_name();
- Value *value = parse_value();
- return new Const(name, value);
+ Value *parse_enum() {
+ size_t id = read_uint();
+ Enum *sig;
+ EnumMap::const_iterator it = enums.find(id);
+ if (it == enums.end()) {
+ std::string name = read_string();
+ Value *value = parse_value();
+ sig = new Enum(name, value);
+ enums[id] = sig;
+ } else {
+ sig = it->second;
+ }
+ assert(sig);
+ return sig;
}
Value *parse_bitmask() {