mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
refactor: adjust zcg code for working in x64
This commit is contained in:
@ -12,18 +12,18 @@ DeclarationModifierComputations::DeclarationModifierComputations(const MemberInf
|
||||
m_modifier_indices(std::move(modifierIndices))
|
||||
{
|
||||
auto combinedIndex = 0;
|
||||
auto arraySizes = MemberComputations(m_information).GetArraySizes();
|
||||
const auto arraySizes = MemberComputations(m_information).GetArraySizes();
|
||||
std::vector<int> sizePerDepth(arraySizes.size());
|
||||
|
||||
auto currentDepthSize = 1;
|
||||
for (int i = arraySizes.size(); i > 0; i--)
|
||||
for (int i = static_cast<int>(arraySizes.size()); i > 0; i--)
|
||||
{
|
||||
sizePerDepth[i - 1] = currentDepthSize;
|
||||
currentDepthSize *= arraySizes[i - 1];
|
||||
}
|
||||
|
||||
auto currentDepth = 0;
|
||||
for (auto modifierIndex : m_modifier_indices)
|
||||
for (const auto modifierIndex : m_modifier_indices)
|
||||
{
|
||||
combinedIndex += sizePerDepth[currentDepth++] * modifierIndex;
|
||||
}
|
||||
@ -62,7 +62,7 @@ std::vector<DeclarationModifier*> DeclarationModifierComputations::GetFollowingD
|
||||
|
||||
if (m_modifier_indices.size() + 1 < declarationModifiers.size())
|
||||
{
|
||||
for (auto i = declarationModifiers.begin() + m_modifier_indices.size() + 1; i != declarationModifiers.end(); ++i)
|
||||
for (auto i = declarationModifiers.begin() + m_modifier_indices.size() + 1uz; i != declarationModifiers.end(); ++i)
|
||||
{
|
||||
following.push_back(i->get());
|
||||
}
|
||||
|
@ -1,5 +1,63 @@
|
||||
#include "CommandsParserState.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
MemberInformation* GetMemberWithName(const std::string& memberName, const StructureInformation* type)
|
||||
{
|
||||
for (const auto& member : type->m_ordered_members)
|
||||
{
|
||||
if (member->m_member->m_name == memberName)
|
||||
{
|
||||
return member.get();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool GetNextTypenameSeparatorPos(const std::string& typeNameValue, const size_t startPos, size_t& separatorPos)
|
||||
{
|
||||
const auto typeNameValueSize = typeNameValue.size();
|
||||
for (auto currentHead = startPos + 1; currentHead < typeNameValueSize; currentHead++)
|
||||
{
|
||||
if (typeNameValue[currentHead] == ':' && typeNameValue[currentHead - 1] == ':')
|
||||
{
|
||||
separatorPos = currentHead - 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
|
||||
size_t typeNameOffset,
|
||||
const StructureInformation* type,
|
||||
std::vector<MemberInformation*>& members)
|
||||
{
|
||||
auto startOffset = typeNameOffset;
|
||||
while (GetNextTypenameSeparatorPos(typeNameValue, typeNameOffset, typeNameOffset))
|
||||
{
|
||||
auto* foundMember = GetMemberWithName(std::string(typeNameValue, startOffset, typeNameOffset - startOffset), type);
|
||||
|
||||
if (foundMember == nullptr)
|
||||
return false;
|
||||
|
||||
members.push_back(foundMember);
|
||||
type = foundMember->m_type;
|
||||
typeNameOffset += 2;
|
||||
startOffset = typeNameOffset;
|
||||
}
|
||||
|
||||
auto* foundMember = GetMemberWithName(std::string(typeNameValue, startOffset, typeNameValue.size() - startOffset), type);
|
||||
if (foundMember == nullptr)
|
||||
return false;
|
||||
|
||||
members.push_back(foundMember);
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
CommandsParserState::CommandsParserState(IDataRepository* repository)
|
||||
: m_repository(repository),
|
||||
m_in_use(nullptr)
|
||||
@ -36,63 +94,8 @@ void CommandsParserState::SetInUse(StructureInformation* structure)
|
||||
m_in_use = structure;
|
||||
}
|
||||
|
||||
MemberInformation* CommandsParserState::GetMemberWithName(const std::string& memberName, StructureInformation* type)
|
||||
{
|
||||
for (const auto& member : type->m_ordered_members)
|
||||
{
|
||||
if (member->m_member->m_name == memberName)
|
||||
{
|
||||
return member.get();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CommandsParserState::GetNextTypenameSeparatorPos(const std::string& typeNameValue, const unsigned startPos, unsigned& separatorPos)
|
||||
{
|
||||
const auto typeNameValueSize = typeNameValue.size();
|
||||
for (auto currentHead = startPos + 1; currentHead < typeNameValueSize; currentHead++)
|
||||
{
|
||||
if (typeNameValue[currentHead] == ':' && typeNameValue[currentHead - 1] == ':')
|
||||
{
|
||||
separatorPos = currentHead - 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CommandsParserState::ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
|
||||
unsigned typeNameOffset,
|
||||
StructureInformation* type,
|
||||
std::vector<MemberInformation*>& members)
|
||||
{
|
||||
auto startOffset = typeNameOffset;
|
||||
while (GetNextTypenameSeparatorPos(typeNameValue, typeNameOffset, typeNameOffset))
|
||||
{
|
||||
auto* foundMember = GetMemberWithName(std::string(typeNameValue, startOffset, typeNameOffset - startOffset), type);
|
||||
|
||||
if (foundMember == nullptr)
|
||||
return false;
|
||||
|
||||
members.push_back(foundMember);
|
||||
type = foundMember->m_type;
|
||||
typeNameOffset += 2;
|
||||
startOffset = typeNameOffset;
|
||||
}
|
||||
|
||||
auto* foundMember = GetMemberWithName(std::string(typeNameValue, startOffset, typeNameValue.size() - startOffset), type);
|
||||
if (foundMember == nullptr)
|
||||
return false;
|
||||
|
||||
members.push_back(foundMember);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommandsParserState::GetMembersFromTypename(const std::string& typeNameValue,
|
||||
StructureInformation* baseType,
|
||||
const StructureInformation* baseType,
|
||||
std::vector<MemberInformation*>& members) const
|
||||
{
|
||||
return m_in_use != nullptr && ExtractMembersFromTypenameInternal(typeNameValue, 0, m_in_use, members)
|
||||
@ -114,7 +117,7 @@ bool CommandsParserState::GetTypenameAndMembersFromTypename(const std::string& t
|
||||
}
|
||||
|
||||
DataDefinition* foundDefinition = nullptr;
|
||||
unsigned currentSeparatorPos = 0;
|
||||
auto currentSeparatorPos = 0uz;
|
||||
while (GetNextTypenameSeparatorPos(typeNameValue, currentSeparatorPos, currentSeparatorPos))
|
||||
{
|
||||
std::string currentTypename(typeNameValue, 0, currentSeparatorPos);
|
||||
@ -134,7 +137,7 @@ bool CommandsParserState::GetTypenameAndMembersFromTypename(const std::string& t
|
||||
if (foundDefinition == nullptr)
|
||||
return false;
|
||||
|
||||
auto* definitionWithMembers = dynamic_cast<DefinitionWithMembers*>(foundDefinition);
|
||||
const auto* definitionWithMembers = dynamic_cast<DefinitionWithMembers*>(foundDefinition);
|
||||
if (definitionWithMembers == nullptr)
|
||||
return false;
|
||||
|
||||
|
@ -19,17 +19,10 @@ public:
|
||||
[[nodiscard]] StructureInformation* GetInUse() const;
|
||||
void SetInUse(StructureInformation* structure);
|
||||
|
||||
bool GetMembersFromTypename(const std::string& typeNameValue, StructureInformation* baseType, std::vector<MemberInformation*>& members) const;
|
||||
bool GetMembersFromTypename(const std::string& typeNameValue, const StructureInformation* baseType, std::vector<MemberInformation*>& members) const;
|
||||
bool GetTypenameAndMembersFromTypename(const std::string& typeNameValue, StructureInformation*& structure, std::vector<MemberInformation*>& members) const;
|
||||
|
||||
private:
|
||||
static MemberInformation* GetMemberWithName(const std::string& memberName, StructureInformation* type);
|
||||
static bool GetNextTypenameSeparatorPos(const std::string& typeNameValue, unsigned startPos, unsigned& separatorPos);
|
||||
static bool ExtractMembersFromTypenameInternal(const std::string& typeNameValue,
|
||||
unsigned typeNameOffset,
|
||||
StructureInformation* type,
|
||||
std::vector<MemberInformation*>& members);
|
||||
|
||||
IDataRepository* m_repository;
|
||||
StructureInformation* m_in_use;
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "Domain/Evaluation/Operation.h"
|
||||
|
||||
#include <list>
|
||||
#include <ranges>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
@ -353,7 +354,7 @@ std::unique_ptr<IEvaluation>
|
||||
currentType = nullptr;
|
||||
|
||||
std::vector<std::unique_ptr<IEvaluation>> operands;
|
||||
std::list<std::pair<unsigned, const OperationType*>> operators;
|
||||
std::list<std::pair<size_t, const OperationType*>> operators;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -384,7 +385,7 @@ std::unique_ptr<IEvaluation>
|
||||
}
|
||||
|
||||
operators.sort(
|
||||
[](const std::pair<unsigned, const OperationType*>& p1, const std::pair<unsigned, const OperationType*>& p2)
|
||||
[](const std::pair<size_t, const OperationType*>& p1, const std::pair<size_t, const OperationType*>& p2)
|
||||
{
|
||||
if (p1.second->m_precedence != p2.second->m_precedence)
|
||||
return p1.second->m_precedence > p2.second->m_precedence;
|
||||
@ -402,7 +403,7 @@ std::unique_ptr<IEvaluation>
|
||||
|
||||
operators.pop_back();
|
||||
|
||||
for (auto& [opIndex, _] : operators)
|
||||
for (auto& opIndex : operators | std::views::keys)
|
||||
{
|
||||
if (opIndex > operatorIndex)
|
||||
opIndex--;
|
||||
|
Reference in New Issue
Block a user