From 09a68bdd84d4789626f5c8b8631f61e7a41ca03d Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Wed, 11 Jan 2017 15:42:08 -0500 Subject: Use named type references for registered types, use qualified names for types --- architecture.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 14 deletions(-) (limited to 'architecture.cpp') diff --git a/architecture.cpp b/architecture.cpp index e84b7f78..d0d87df4 100644 --- a/architecture.cpp +++ b/architecture.cpp @@ -746,9 +746,8 @@ void Architecture::SetBinaryViewTypeConstant(const string& type, const string& n bool Architecture::ParseTypesFromSource(const string& source, const string& fileName, - map>& types, map>& variables, - map>& functions, string& errors, - const vector& includeDirs) + map, Ref>& types, map, Ref>& variables, + map, Ref>& functions, string& errors, const vector& includeDirs) { BNTypeParserResult result; char* errorStr; @@ -762,26 +761,41 @@ bool Architecture::ParseTypesFromSource(const string& source, const string& file functions.clear(); bool ok = BNParseTypesFromSource(m_object, source.c_str(), fileName.c_str(), &result, - &errorStr, includeDirList, includeDirs.size()); + &errorStr, includeDirList, includeDirs.size()); errors = errorStr; BNFreeString(errorStr); if (!ok) return false; for (size_t i = 0; i < result.typeCount; i++) - types[result.types[i].name] = new Type(BNNewTypeReference(result.types[i].type)); + { + vector name; + for (size_t j = 0; j < result.types[i].nameCount; j++) + name.push_back(result.types[i].name[j]); + types[name] = new Type(BNNewTypeReference(result.types[i].type)); + } for (size_t i = 0; i < result.variableCount; i++) - types[result.variables[i].name] = new Type(BNNewTypeReference(result.variables[i].type)); + { + vector name; + for (size_t j = 0; j < result.variables[i].nameCount; j++) + name.push_back(result.variables[i].name[j]); + types[name] = new Type(BNNewTypeReference(result.variables[i].type)); + } for (size_t i = 0; i < result.functionCount; i++) - types[result.functions[i].name] = new Type(BNNewTypeReference(result.functions[i].type)); + { + vector name; + for (size_t j = 0; j < result.functions[i].nameCount; j++) + name.push_back(result.functions[i].name[j]); + types[name] = new Type(BNNewTypeReference(result.functions[i].type)); + } BNFreeTypeParserResult(&result); return true; } -bool Architecture::ParseTypesFromSourceFile(const string& fileName, map>& types, - map>& variables, map>& functions, - string& errors, const vector& includeDirs) +bool Architecture::ParseTypesFromSourceFile(const string& fileName, map, Ref>& types, + map, Ref>& variables, map, Ref>& functions, + string& errors, const vector& includeDirs) { BNTypeParserResult result; char* errorStr; @@ -795,18 +809,33 @@ bool Architecture::ParseTypesFromSourceFile(const string& fileName, map name; + for (size_t j = 0; j < result.types[i].nameCount; j++) + name.push_back(result.types[i].name[j]); + types[name] = new Type(BNNewTypeReference(result.types[i].type)); + } for (size_t i = 0; i < result.variableCount; i++) - variables[result.variables[i].name] = new Type(BNNewTypeReference(result.variables[i].type)); + { + vector name; + for (size_t j = 0; j < result.variables[i].nameCount; j++) + name.push_back(result.variables[i].name[j]); + variables[name] = new Type(BNNewTypeReference(result.variables[i].type)); + } for (size_t i = 0; i < result.functionCount; i++) - functions[result.functions[i].name] = new Type(BNNewTypeReference(result.functions[i].type)); + { + vector name; + for (size_t j = 0; j < result.functions[i].nameCount; j++) + name.push_back(result.functions[i].name[j]); + functions[name] = new Type(BNNewTypeReference(result.functions[i].type)); + } BNFreeTypeParserResult(&result); return true; } -- cgit v1.3.1