BRIDGE: add node data in BridgeCFNode
This commit is contained in:
parent
701319e0d5
commit
7e0532b9d8
|
|
@ -13,6 +13,7 @@ typedef struct
|
|||
bool split; //node is a split (brtrue points to the next node)
|
||||
void* userdata; //user data
|
||||
ListInfo exits; //exits (including brtrue and brfalse, duint)
|
||||
ListInfo data; //block data
|
||||
} BridgeCFNodeList;
|
||||
|
||||
typedef struct
|
||||
|
|
@ -41,10 +42,11 @@ struct BridgeCFNode
|
|||
bool split; //node is a split (brtrue points to the next node)
|
||||
void* userdata; //user data
|
||||
std::vector<duint> exits; //exits (including brtrue and brfalse)
|
||||
std::vector<unsigned char> data; //block data
|
||||
|
||||
explicit BridgeCFNode(BridgeCFNodeList* nodeList, bool freedata = true)
|
||||
{
|
||||
if(!nodeList || nodeList->exits.size != nodeList->exits.count * sizeof(duint))
|
||||
if(!nodeList)
|
||||
__debugbreak();
|
||||
parentGraph = nodeList->parentGraph;
|
||||
start = nodeList->start;
|
||||
|
|
@ -55,12 +57,10 @@ struct BridgeCFNode
|
|||
terminal = nodeList->terminal;
|
||||
split = nodeList->split;
|
||||
userdata = nodeList->userdata;
|
||||
auto data = (duint*)nodeList->exits.data;
|
||||
exits.resize(nodeList->exits.count);
|
||||
for(int i = 0; i < nodeList->exits.count; i++)
|
||||
exits[i] = data[i];
|
||||
if(freedata)
|
||||
BridgeFree(data);
|
||||
if(!BridgeList<duint>::ToVector(&nodeList->exits, exits, freedata))
|
||||
__debugbreak();
|
||||
if(!BridgeList<unsigned char>::ToVector(&nodeList->data, data, freedata))
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
explicit BridgeCFNode(duint parentGraph, duint start, duint end)
|
||||
|
|
@ -94,6 +94,7 @@ struct BridgeCFNode
|
|||
out.split = split;
|
||||
out.userdata = userdata;
|
||||
BridgeList<duint>::CopyData(&out.exits, exits);
|
||||
BridgeList<unsigned char>::CopyData(&out.data, data);
|
||||
return std::move(out);
|
||||
}
|
||||
};
|
||||
|
|
@ -114,7 +115,7 @@ struct BridgeCFGraph
|
|||
auto data = (BridgeCFNodeList*)graphList->nodes.data;
|
||||
for(int i = 0; i < graphList->nodes.count; i++)
|
||||
AddNode(BridgeCFNode(&data[i], freedata));
|
||||
if(freedata)
|
||||
if(freedata && data)
|
||||
BridgeFree(data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,18 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool ToVector(const ListInfo* listInfo, std::vector<Type> & listData, bool freedata = true)
|
||||
{
|
||||
if(!listInfo || listInfo->size != listInfo->count * sizeof(Type) || (listInfo->count && !listInfo->data))
|
||||
return false;
|
||||
listData.resize(listInfo->count);
|
||||
for(int i = 0; i < listInfo->count; i++)
|
||||
listData[i] = ((Type*)listInfo->data)[i];
|
||||
if(freedata && listInfo->data)
|
||||
BridgeFree(listInfo->data);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
ListInfo _listInfo;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue