mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-09-18 22:47:25 +00:00
chore: update ZoneCodeGenerator code style
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
} // namespace
|
||||
|
||||
CommandsFileReader::CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
||||
: m_args(args),
|
||||
m_filename(std::move(filename)),
|
||||
@@ -30,7 +36,7 @@ bool CommandsFileReader::OpenBaseStream()
|
||||
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
|
||||
if (!stream->IsOpen())
|
||||
{
|
||||
std::cout << "Could not open commands file\n";
|
||||
std::cerr << "Could not open commands file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +74,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
||||
{
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Reading commands file: " << m_filename << "\n";
|
||||
std::cout << std::format("Reading commands file: {}\n", m_filename);
|
||||
}
|
||||
|
||||
if (!OpenBaseStream())
|
||||
@@ -84,9 +90,7 @@ bool CommandsFileReader::ReadCommandsFile(IDataRepository* repository)
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Processing commands took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
|
||||
}
|
||||
std::cout << std::format("Processing commands took {}ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
@@ -9,8 +9,15 @@
|
||||
|
||||
class CommandsFileReader
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
public:
|
||||
CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadCommandsFile(IDataRepository* repository);
|
||||
|
||||
private:
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
std::string m_filename;
|
||||
@@ -19,13 +26,4 @@ class CommandsFileReader
|
||||
IParserLineStream* m_stream;
|
||||
|
||||
std::vector<std::unique_ptr<IPostProcessor>> m_post_processors;
|
||||
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
public:
|
||||
explicit CommandsFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadCommandsFile(IDataRepository* repository);
|
||||
};
|
||||
|
@@ -5,9 +5,9 @@
|
||||
|
||||
class CommandsLexer final : public AbstractLexer<CommandsParserValue>
|
||||
{
|
||||
protected:
|
||||
CommandsParserValue GetNextToken() override;
|
||||
|
||||
public:
|
||||
explicit CommandsLexer(IParserLineStream* stream);
|
||||
|
||||
protected:
|
||||
CommandsParserValue GetNextToken() override;
|
||||
};
|
||||
|
@@ -8,11 +8,12 @@
|
||||
|
||||
class CommandsParser final : public AbstractParser<CommandsParserValue, CommandsParserState>
|
||||
{
|
||||
IDataRepository* m_repository;
|
||||
public:
|
||||
CommandsParser(CommandsLexer* lexer, IDataRepository* targetRepository);
|
||||
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
|
||||
public:
|
||||
CommandsParser(CommandsLexer* lexer, IDataRepository* targetRepository);
|
||||
private:
|
||||
IDataRepository* m_repository;
|
||||
};
|
||||
|
@@ -1,16 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "Persistence/IDataRepository.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class CommandsParserState
|
||||
{
|
||||
IDataRepository* m_repository;
|
||||
StructureInformation* m_in_use;
|
||||
public:
|
||||
explicit CommandsParserState(IDataRepository* repository);
|
||||
|
||||
[[nodiscard]] const IDataRepository* GetRepository() const;
|
||||
|
||||
void AddBlock(std::unique_ptr<FastFileBlock> block) const;
|
||||
void SetArchitecture(Architecture architecture) const;
|
||||
void SetGame(std::string gameName) const;
|
||||
|
||||
[[nodiscard]] StructureInformation* GetInUse() const;
|
||||
void SetInUse(StructureInformation* structure);
|
||||
|
||||
bool GetMembersFromTypename(const std::string& typeNameValue, 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,
|
||||
@@ -18,18 +30,6 @@ class CommandsParserState
|
||||
StructureInformation* type,
|
||||
std::vector<MemberInformation*>& members);
|
||||
|
||||
public:
|
||||
explicit CommandsParserState(IDataRepository* repository);
|
||||
|
||||
_NODISCARD const IDataRepository* GetRepository() const;
|
||||
|
||||
void AddBlock(std::unique_ptr<FastFileBlock> block) const;
|
||||
void SetArchitecture(Architecture architecture) const;
|
||||
void SetGame(std::string gameName) const;
|
||||
|
||||
_NODISCARD StructureInformation* GetInUse() const;
|
||||
void SetInUse(StructureInformation* structure);
|
||||
|
||||
bool GetMembersFromTypename(const std::string& typeNameValue, StructureInformation* baseType, std::vector<MemberInformation*>& members) const;
|
||||
bool GetTypenameAndMembersFromTypename(const std::string& typeNameValue, StructureInformation*& structure, std::vector<MemberInformation*>& members) const;
|
||||
IDataRepository* m_repository;
|
||||
StructureInformation* m_in_use;
|
||||
};
|
||||
|
@@ -52,10 +52,6 @@ enum class CommandsParserValueType
|
||||
class CommandsParserValue final : public IParserValue
|
||||
{
|
||||
public:
|
||||
TokenPos m_pos;
|
||||
CommandsParserValueType m_type;
|
||||
size_t m_hash;
|
||||
|
||||
union ValueType
|
||||
{
|
||||
char char_value;
|
||||
@@ -83,25 +79,28 @@ public:
|
||||
static CommandsParserValue TypeName(TokenPos pos, std::string* typeName);
|
||||
static CommandsParserValue OpType(TokenPos pos, const OperationType* operationType);
|
||||
|
||||
private:
|
||||
CommandsParserValue(TokenPos pos, CommandsParserValueType type);
|
||||
|
||||
public:
|
||||
~CommandsParserValue() override;
|
||||
CommandsParserValue(const CommandsParserValue& other) = delete;
|
||||
~CommandsParserValue() override;
|
||||
CommandsParserValue(CommandsParserValue&& other) noexcept;
|
||||
CommandsParserValue& operator=(const CommandsParserValue& other) = delete;
|
||||
CommandsParserValue& operator=(CommandsParserValue&& other) noexcept;
|
||||
|
||||
_NODISCARD bool IsEof() const override;
|
||||
_NODISCARD const TokenPos& GetPos() const override;
|
||||
[[nodiscard]] bool IsEof() const override;
|
||||
[[nodiscard]] const TokenPos& GetPos() const override;
|
||||
|
||||
_NODISCARD char CharacterValue() const;
|
||||
_NODISCARD int IntegerValue() const;
|
||||
_NODISCARD double FloatingPointValue() const;
|
||||
_NODISCARD std::string& StringValue() const;
|
||||
_NODISCARD std::string& IdentifierValue() const;
|
||||
_NODISCARD size_t IdentifierHash() const;
|
||||
_NODISCARD std::string& TypeNameValue() const;
|
||||
_NODISCARD const OperationType* OpTypeValue() const;
|
||||
[[nodiscard]] char CharacterValue() const;
|
||||
[[nodiscard]] int IntegerValue() const;
|
||||
[[nodiscard]] double FloatingPointValue() const;
|
||||
[[nodiscard]] std::string& StringValue() const;
|
||||
[[nodiscard]] std::string& IdentifierValue() const;
|
||||
[[nodiscard]] size_t IdentifierHash() const;
|
||||
[[nodiscard]] std::string& TypeNameValue() const;
|
||||
[[nodiscard]] const OperationType* OpTypeValue() const;
|
||||
|
||||
TokenPos m_pos;
|
||||
CommandsParserValueType m_type;
|
||||
size_t m_hash;
|
||||
|
||||
private:
|
||||
CommandsParserValue(TokenPos pos, CommandsParserValueType type);
|
||||
};
|
||||
|
@@ -5,11 +5,12 @@
|
||||
|
||||
class CommandsMatcherCharacter final : public AbstractMatcher<CommandsParserValue>
|
||||
{
|
||||
char m_char;
|
||||
public:
|
||||
explicit CommandsMatcherCharacter(char c);
|
||||
|
||||
protected:
|
||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit CommandsMatcherCharacter(char c);
|
||||
private:
|
||||
char m_char;
|
||||
};
|
||||
|
@@ -10,10 +10,10 @@ class CommandsMatcherFactory final : public AbstractMatcherFactory<CommandsParse
|
||||
public:
|
||||
explicit CommandsMatcherFactory(const IMatcherForLabelSupplier<CommandsParserValue>* labelSupplier);
|
||||
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Type(CommandsParserValueType type) const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Keyword(std::string value) const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Identifier() const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Integer() const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> FloatingPoint() const;
|
||||
_NODISCARD MatcherFactoryWrapper<CommandsParserValue> Char(char c) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Type(CommandsParserValueType type) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Keyword(std::string value) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Identifier() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Integer() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> FloatingPoint() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<CommandsParserValue> Char(char c) const;
|
||||
};
|
||||
|
@@ -7,12 +7,13 @@
|
||||
|
||||
class CommandsMatcherKeyword final : public AbstractMatcher<CommandsParserValue>
|
||||
{
|
||||
size_t m_hash;
|
||||
std::string m_value;
|
||||
public:
|
||||
explicit CommandsMatcherKeyword(std::string value);
|
||||
|
||||
protected:
|
||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit CommandsMatcherKeyword(std::string value);
|
||||
private:
|
||||
size_t m_hash;
|
||||
std::string m_value;
|
||||
};
|
||||
|
@@ -5,11 +5,12 @@
|
||||
|
||||
class CommandsMatcherValueType final : public AbstractMatcher<CommandsParserValue>
|
||||
{
|
||||
CommandsParserValueType m_type;
|
||||
public:
|
||||
explicit CommandsMatcherValueType(CommandsParserValueType type);
|
||||
|
||||
protected:
|
||||
MatcherResult<CommandsParserValue> CanMatch(ILexer<CommandsParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit CommandsMatcherValueType(CommandsParserValueType type);
|
||||
private:
|
||||
CommandsParserValueType m_type;
|
||||
};
|
||||
|
@@ -3,6 +3,15 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_ACTION_NAME = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARG_TYPE = 3;
|
||||
|
||||
static constexpr auto LABEL_ACTION_ARGS = 1;
|
||||
} // namespace
|
||||
|
||||
SequenceAction::SequenceAction()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,15 +4,9 @@
|
||||
|
||||
class SequenceAction final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_ACTION_NAME = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARG_TYPE = 3;
|
||||
|
||||
static constexpr auto LABEL_ACTION_ARGS = 1;
|
||||
public:
|
||||
SequenceAction();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAction();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceAllocAlign::SequenceAllocAlign()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceAllocAlign final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceAllocAlign();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAllocAlign();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_ARCHITECTURE = 1;
|
||||
}
|
||||
|
||||
SequenceArchitecture::SequenceArchitecture()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -2,15 +2,16 @@
|
||||
|
||||
#include "Parsing/Commands/Impl/CommandsParser.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
class SequenceArchitecture final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_ARCHITECTURE = 1;
|
||||
|
||||
std::unordered_map<std::string, Architecture> m_architecture_mapping;
|
||||
public:
|
||||
SequenceArchitecture();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceArchitecture();
|
||||
private:
|
||||
std::unordered_map<std::string, Architecture> m_architecture_mapping;
|
||||
};
|
||||
|
@@ -4,6 +4,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceArrayCount::SequenceArrayCount()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceArrayCount final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceArrayCount();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceArrayCount();
|
||||
};
|
||||
|
@@ -4,6 +4,12 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceArraySize::SequenceArraySize()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,12 +4,9 @@
|
||||
|
||||
class SequenceArraySize final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
public:
|
||||
SequenceArraySize();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceArraySize();
|
||||
};
|
||||
|
@@ -3,6 +3,12 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceAsset::SequenceAsset()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,12 +4,9 @@
|
||||
|
||||
class SequenceAsset final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ENUM_ENTRY = 2;
|
||||
public:
|
||||
SequenceAsset();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAsset();
|
||||
};
|
||||
|
@@ -5,6 +5,14 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceAssetRef::SequenceAssetRef()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,14 +4,9 @@
|
||||
|
||||
class SequenceAssetRef final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2;
|
||||
public:
|
||||
SequenceAssetRef();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAssetRef();
|
||||
};
|
||||
|
@@ -3,6 +3,14 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 1;
|
||||
static constexpr auto CAPTURE_BLOCK_TYPE = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceBlock::SequenceBlock()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -7,19 +7,15 @@
|
||||
|
||||
class SequenceBlock final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_DEFAULT = 1;
|
||||
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 1;
|
||||
static constexpr auto CAPTURE_BLOCK_TYPE = 2;
|
||||
|
||||
std::unordered_map<std::string, FastFileBlockType> m_type_lookup;
|
||||
|
||||
void AddFastFileBlockToLookup(std::string name, FastFileBlockType type);
|
||||
_NODISCARD bool GetFastFileBlockNameByType(const std::string& name, FastFileBlockType& type) const;
|
||||
public:
|
||||
SequenceBlock();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceBlock();
|
||||
private:
|
||||
void AddFastFileBlockToLookup(std::string name, FastFileBlockType type);
|
||||
[[nodiscard]] bool GetFastFileBlockNameByType(const std::string& name, FastFileBlockType& type) const;
|
||||
|
||||
std::unordered_map<std::string, FastFileBlockType> m_type_lookup;
|
||||
};
|
||||
|
@@ -4,6 +4,16 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_ALWAYS = 1;
|
||||
static constexpr auto TAG_NEVER = 2;
|
||||
static constexpr auto TAG_EVALUATION = 3;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceCondition::SequenceCondition()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,16 +4,9 @@
|
||||
|
||||
class SequenceCondition final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_ALWAYS = 1;
|
||||
static constexpr auto TAG_NEVER = 2;
|
||||
static constexpr auto TAG_EVALUATION = 3;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_EVALUATION = 2;
|
||||
public:
|
||||
SequenceCondition();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceCondition();
|
||||
};
|
||||
|
@@ -5,6 +5,76 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_POINTER_RESOLVE = 1;
|
||||
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARRAY_INDEX = 3;
|
||||
|
||||
void SetCountByArrayIndex(CommandsParserState* state,
|
||||
SequenceResult<CommandsParserValue>& result,
|
||||
MemberInformation* member,
|
||||
PointerDeclarationModifier* pointer,
|
||||
std::unique_ptr<IEvaluation> evaluation)
|
||||
{
|
||||
std::vector<int> arraySizes;
|
||||
std::vector<int> depthSize;
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::ARRAY)
|
||||
arraySizes.push_back(dynamic_cast<ArrayDeclarationModifier*>(modifier.get())->m_size);
|
||||
}
|
||||
|
||||
depthSize.resize(arraySizes.size());
|
||||
auto currentDepthSize = 1u;
|
||||
for (auto i = arraySizes.size(); i > 0; i--)
|
||||
{
|
||||
if (i < arraySizes.size())
|
||||
currentDepthSize *= arraySizes[i];
|
||||
depthSize[i - 1] = currentDepthSize;
|
||||
}
|
||||
|
||||
if (pointer->m_count_evaluation_by_array_index.empty())
|
||||
{
|
||||
auto neededCapacity = 0u;
|
||||
for (auto arraySize : arraySizes)
|
||||
{
|
||||
if (neededCapacity == 0)
|
||||
neededCapacity = arraySize;
|
||||
else
|
||||
neededCapacity *= arraySize;
|
||||
}
|
||||
pointer->m_count_evaluation_by_array_index.resize(neededCapacity);
|
||||
}
|
||||
|
||||
auto currentIndex = 0u;
|
||||
auto currentIndexOffset = 0u;
|
||||
while (result.HasNextCapture(CAPTURE_ARRAY_INDEX) && currentIndexOffset < depthSize.size())
|
||||
{
|
||||
const auto& arrayIndexToken = result.NextCapture(CAPTURE_ARRAY_INDEX);
|
||||
if (arrayIndexToken.m_type == CommandsParserValueType::INTEGER)
|
||||
{
|
||||
currentIndex += depthSize[currentIndexOffset++] * arrayIndexToken.IntegerValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* enumEntry = state->GetRepository()->GetEnumMemberByName(arrayIndexToken.IdentifierValue());
|
||||
if (enumEntry == nullptr)
|
||||
throw ParsingException(arrayIndexToken.GetPos(), "Unknown enum entry");
|
||||
|
||||
currentIndex += depthSize[currentIndexOffset++] * enumEntry->m_value;
|
||||
}
|
||||
}
|
||||
|
||||
pointer->m_count_evaluation_by_array_index[currentIndex] = std::move(evaluation);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SequenceCount::SequenceCount()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
@@ -23,64 +93,6 @@ SequenceCount::SequenceCount()
|
||||
});
|
||||
}
|
||||
|
||||
void SequenceCount::SetCountByArrayIndex(CommandsParserState* state,
|
||||
SequenceResult<CommandsParserValue>& result,
|
||||
MemberInformation* member,
|
||||
PointerDeclarationModifier* pointer,
|
||||
std::unique_ptr<IEvaluation> evaluation)
|
||||
{
|
||||
std::vector<int> arraySizes;
|
||||
std::vector<int> depthSize;
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::ARRAY)
|
||||
arraySizes.push_back(dynamic_cast<ArrayDeclarationModifier*>(modifier.get())->m_size);
|
||||
}
|
||||
|
||||
depthSize.resize(arraySizes.size());
|
||||
auto currentDepthSize = 1u;
|
||||
for (auto i = arraySizes.size(); i > 0; i--)
|
||||
{
|
||||
if (i < arraySizes.size())
|
||||
currentDepthSize *= arraySizes[i];
|
||||
depthSize[i - 1] = currentDepthSize;
|
||||
}
|
||||
|
||||
if (pointer->m_count_evaluation_by_array_index.empty())
|
||||
{
|
||||
auto neededCapacity = 0u;
|
||||
for (auto arraySize : arraySizes)
|
||||
{
|
||||
if (neededCapacity == 0)
|
||||
neededCapacity = arraySize;
|
||||
else
|
||||
neededCapacity *= arraySize;
|
||||
}
|
||||
pointer->m_count_evaluation_by_array_index.resize(neededCapacity);
|
||||
}
|
||||
|
||||
auto currentIndex = 0u;
|
||||
auto currentIndexOffset = 0u;
|
||||
while (result.HasNextCapture(CAPTURE_ARRAY_INDEX) && currentIndexOffset < depthSize.size())
|
||||
{
|
||||
const auto& arrayIndexToken = result.NextCapture(CAPTURE_ARRAY_INDEX);
|
||||
if (arrayIndexToken.m_type == CommandsParserValueType::INTEGER)
|
||||
{
|
||||
currentIndex += depthSize[currentIndexOffset++] * arrayIndexToken.IntegerValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto* enumEntry = state->GetRepository()->GetEnumMemberByName(arrayIndexToken.IdentifierValue());
|
||||
if (enumEntry == nullptr)
|
||||
throw ParsingException(arrayIndexToken.GetPos(), "Unknown enum entry");
|
||||
|
||||
currentIndex += depthSize[currentIndexOffset++] * enumEntry->m_value;
|
||||
}
|
||||
}
|
||||
|
||||
pointer->m_count_evaluation_by_array_index[currentIndex] = std::move(evaluation);
|
||||
}
|
||||
|
||||
void SequenceCount::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||
|
@@ -5,21 +5,9 @@
|
||||
|
||||
class SequenceCount final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_POINTER_RESOLVE = 1;
|
||||
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ARRAY_INDEX = 3;
|
||||
|
||||
static void SetCountByArrayIndex(CommandsParserState* state,
|
||||
SequenceResult<CommandsParserValue>& result,
|
||||
MemberInformation* member,
|
||||
PointerDeclarationModifier* pointer,
|
||||
std::unique_ptr<IEvaluation> evaluation);
|
||||
public:
|
||||
SequenceCount();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceCount();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_GAME = 1;
|
||||
}
|
||||
|
||||
SequenceGame::SequenceGame()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceGame final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_GAME = 1;
|
||||
public:
|
||||
SequenceGame();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceGame();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceName::SequenceName()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceName final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceName();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceName();
|
||||
};
|
||||
|
@@ -5,6 +5,43 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_FIND_FIRST = 1;
|
||||
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ENTRY = 3;
|
||||
|
||||
StructureInformation* GetType(CommandsParserState* state, SequenceResult<CommandsParserValue>& result)
|
||||
{
|
||||
if (result.HasNextCapture(CAPTURE_TYPE))
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||
StructureInformation* information;
|
||||
std::vector<MemberInformation*> memberChain;
|
||||
|
||||
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), information, memberChain))
|
||||
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
|
||||
|
||||
if (memberChain.empty())
|
||||
return information;
|
||||
|
||||
auto* lastMember = memberChain.back();
|
||||
|
||||
if (lastMember->m_type == nullptr)
|
||||
throw ParsingException(typeNameToken.GetPos(), "Member type must either be struct or union");
|
||||
|
||||
return lastMember->m_type;
|
||||
}
|
||||
|
||||
if (state->GetInUse() != nullptr)
|
||||
return state->GetInUse();
|
||||
|
||||
throw ParsingException(result.NextCapture(CAPTURE_START).GetPos(), "No type is used. Therefore one needs to be specified directly.");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SequenceReorder::SequenceReorder()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
@@ -26,34 +63,6 @@ SequenceReorder::SequenceReorder()
|
||||
});
|
||||
}
|
||||
|
||||
StructureInformation* SequenceReorder::GetType(CommandsParserState* state, SequenceResult<CommandsParserValue>& result)
|
||||
{
|
||||
if (result.HasNextCapture(CAPTURE_TYPE))
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||
StructureInformation* information;
|
||||
std::vector<MemberInformation*> memberChain;
|
||||
|
||||
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), information, memberChain))
|
||||
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
|
||||
|
||||
if (memberChain.empty())
|
||||
return information;
|
||||
|
||||
auto* lastMember = memberChain.back();
|
||||
|
||||
if (lastMember->m_type == nullptr)
|
||||
throw ParsingException(typeNameToken.GetPos(), "Member type must either be struct or union");
|
||||
|
||||
return lastMember->m_type;
|
||||
}
|
||||
|
||||
if (state->GetInUse() != nullptr)
|
||||
return state->GetInUse();
|
||||
|
||||
throw ParsingException(result.NextCapture(CAPTURE_START).GetPos(), "No type is used. Therefore one needs to be specified directly.");
|
||||
}
|
||||
|
||||
void SequenceReorder::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||
{
|
||||
auto* information = GetType(state, result);
|
||||
|
@@ -4,17 +4,9 @@
|
||||
|
||||
class SequenceReorder final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_FIND_FIRST = 1;
|
||||
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_ENTRY = 3;
|
||||
|
||||
static StructureInformation* GetType(CommandsParserState* state, SequenceResult<CommandsParserValue>& result);
|
||||
public:
|
||||
SequenceReorder();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceReorder();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceReusable::SequenceReusable()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceReusable final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceReusable();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceReusable();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceScriptString::SequenceScriptString()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceScriptString final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceScriptString();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceScriptString();
|
||||
};
|
||||
|
@@ -3,6 +3,13 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 3;
|
||||
} // namespace
|
||||
|
||||
SequenceSetBlock::SequenceSetBlock()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,13 +4,9 @@
|
||||
|
||||
class SequenceSetBlock final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_START = 1;
|
||||
static constexpr auto CAPTURE_TYPE = 2;
|
||||
static constexpr auto CAPTURE_BLOCK_ENUM_ENTRY = 3;
|
||||
public:
|
||||
SequenceSetBlock();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceSetBlock();
|
||||
};
|
||||
|
@@ -5,6 +5,11 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceString::SequenceString()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceString final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceString();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceString();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
}
|
||||
|
||||
SequenceUse::SequenceUse()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
@@ -4,11 +4,9 @@
|
||||
|
||||
class SequenceUse final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
public:
|
||||
SequenceUse();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceUse();
|
||||
};
|
||||
|
@@ -7,18 +7,12 @@
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockEnum final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining
|
||||
{
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
const BaseTypeDefinition* m_parent_type;
|
||||
bool m_is_typedef;
|
||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||
int m_next_value;
|
||||
EnumDefinition* m_enum_definition;
|
||||
|
||||
std::string m_variable_name;
|
||||
|
||||
public:
|
||||
HeaderBlockEnum(std::string typeName, const BaseTypeDefinition* parentType, bool isTypeDef);
|
||||
|
||||
@@ -29,11 +23,22 @@ public:
|
||||
void OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) override;
|
||||
|
||||
void AddEnumMember(std::unique_ptr<EnumMember> enumMember);
|
||||
_NODISCARD EnumMember* GetEnumMember(const std::string& name) const;
|
||||
_NODISCARD int GetNextEnumMemberValue() const;
|
||||
[[nodiscard]] EnumMember* GetEnumMember(const std::string& name) const;
|
||||
[[nodiscard]] int GetNextEnumMemberValue() const;
|
||||
|
||||
void SetBlockName(const TokenPos& nameTokenPos, std::string name) override;
|
||||
bool IsDefiningVariable() override;
|
||||
DataDefinition* GetVariableType() override;
|
||||
std::string GetVariableName() override;
|
||||
|
||||
private:
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
const BaseTypeDefinition* m_parent_type;
|
||||
bool m_is_typedef;
|
||||
std::vector<std::unique_ptr<EnumMember>> m_members;
|
||||
int m_next_value;
|
||||
EnumDefinition* m_enum_definition;
|
||||
|
||||
std::string m_variable_name;
|
||||
};
|
||||
|
@@ -2,10 +2,11 @@
|
||||
|
||||
#include "IHeaderBlock.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockNamespace final : public IHeaderBlock
|
||||
{
|
||||
std::string m_namespace_name;
|
||||
|
||||
public:
|
||||
explicit HeaderBlockNamespace(std::string namespaceName);
|
||||
|
||||
@@ -14,4 +15,6 @@ public:
|
||||
void OnOpen(HeaderParserState* state) override;
|
||||
void OnClose(HeaderParserState* state) override;
|
||||
void OnChildBlockClose(HeaderParserState* state, IHeaderBlock* block) override;
|
||||
|
||||
std::string m_namespace_name;
|
||||
};
|
||||
|
@@ -7,23 +7,12 @@
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "IHeaderBlockVariableHolder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockStruct final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining, public IHeaderBlockVariableHolder
|
||||
{
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
StructDefinition* m_struct_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
|
||||
public:
|
||||
HeaderBlockStruct(std::string name, bool isTypedef);
|
||||
|
||||
@@ -41,4 +30,18 @@ public:
|
||||
bool IsDefiningVariable() override;
|
||||
DataDefinition* GetVariableType() override;
|
||||
std::string GetVariableName() override;
|
||||
|
||||
private:
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
StructDefinition* m_struct_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
};
|
||||
|
@@ -5,21 +5,12 @@
|
||||
#include "IHeaderBlockVariableDefining.h"
|
||||
#include "IHeaderBlockVariableHolder.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class HeaderBlockUnion final : public IHeaderBlock, public IHeaderBlockNameHolder, public IHeaderBlockVariableDefining, public IHeaderBlockVariableHolder
|
||||
{
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
UnionDefinition* m_union_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
|
||||
public:
|
||||
HeaderBlockUnion(std::string name, bool isTypedef);
|
||||
|
||||
@@ -37,4 +28,18 @@ public:
|
||||
bool IsDefiningVariable() override;
|
||||
DataDefinition* GetVariableType() override;
|
||||
std::string GetVariableName() override;
|
||||
|
||||
private:
|
||||
std::string m_namespace;
|
||||
std::string m_type_name;
|
||||
std::vector<std::shared_ptr<Variable>> m_members;
|
||||
UnionDefinition* m_union_definition;
|
||||
|
||||
int m_custom_alignment;
|
||||
|
||||
bool m_is_typedef;
|
||||
bool m_has_custom_align;
|
||||
bool m_is_anonymous;
|
||||
|
||||
std::string m_variable_name;
|
||||
};
|
||||
|
@@ -13,8 +13,15 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
} // namespace
|
||||
|
||||
HeaderFileReader::HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename)
|
||||
: m_args(args),
|
||||
m_filename(std::move(filename)),
|
||||
@@ -29,7 +36,7 @@ bool HeaderFileReader::OpenBaseStream()
|
||||
auto stream = std::make_unique<ParserFilesystemStream>(m_filename);
|
||||
if (!stream->IsOpen())
|
||||
{
|
||||
std::cout << "Could not open header file\n";
|
||||
std::cerr << "Could not open header file\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,9 +72,7 @@ void HeaderFileReader::SetupPostProcessors()
|
||||
bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
|
||||
{
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Reading header file: " << m_filename << "\n";
|
||||
}
|
||||
std::cout << std::format("Reading header file: {}\n", m_filename);
|
||||
|
||||
if (!OpenBaseStream())
|
||||
return false;
|
||||
@@ -84,9 +89,7 @@ bool HeaderFileReader::ReadHeaderFile(IDataRepository* repository)
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
|
||||
if (m_args->m_verbose)
|
||||
{
|
||||
std::cout << "Processing header took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms\n";
|
||||
}
|
||||
std::cout << std::format("Processing header took {}ms\n", std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count());
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
@@ -10,8 +10,15 @@
|
||||
|
||||
class HeaderFileReader
|
||||
{
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_NAME = "__zonecodegenerator";
|
||||
static constexpr const char* ZONE_CODE_GENERATOR_DEFINE_VALUE = "1";
|
||||
public:
|
||||
HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadHeaderFile(IDataRepository* repository);
|
||||
|
||||
private:
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
const ZoneCodeGeneratorArguments* m_args;
|
||||
std::string m_filename;
|
||||
@@ -21,13 +28,4 @@ class HeaderFileReader
|
||||
IParserLineStream* m_stream;
|
||||
|
||||
std::vector<std::unique_ptr<IPostProcessor>> m_post_processors;
|
||||
|
||||
bool OpenBaseStream();
|
||||
void SetupStreamProxies();
|
||||
void SetupPostProcessors();
|
||||
|
||||
public:
|
||||
HeaderFileReader(const ZoneCodeGeneratorArguments* args, std::string filename);
|
||||
|
||||
bool ReadHeaderFile(IDataRepository* repository);
|
||||
};
|
||||
|
@@ -3,17 +3,19 @@
|
||||
#include "HeaderParserValue.h"
|
||||
#include "Parsing/Impl/AbstractLexer.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
class HeaderLexer final : public AbstractLexer<HeaderParserValue>
|
||||
{
|
||||
std::unordered_map<std::string, HeaderParserValueType> m_keywords;
|
||||
|
||||
void PrepareKeywords();
|
||||
public:
|
||||
explicit HeaderLexer(IParserLineStream* stream);
|
||||
|
||||
protected:
|
||||
HeaderParserValue GetNextToken() override;
|
||||
|
||||
public:
|
||||
explicit HeaderLexer(IParserLineStream* stream);
|
||||
private:
|
||||
void PrepareKeywords();
|
||||
|
||||
std::unordered_map<std::string, HeaderParserValueType> m_keywords;
|
||||
};
|
||||
|
@@ -8,11 +8,11 @@
|
||||
|
||||
class HeaderParser final : public AbstractParser<HeaderParserValue, HeaderParserState>
|
||||
{
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
|
||||
public:
|
||||
HeaderParser(HeaderLexer* lexer, const IPackValueSupplier* packValueSupplier);
|
||||
|
||||
bool SaveToRepository(IDataRepository* repository) const;
|
||||
|
||||
protected:
|
||||
const std::vector<sequence_t*>& GetTestsForState() override;
|
||||
};
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "Domain/Definition/EnumDefinition.h"
|
||||
#include "Parsing/Header/Block/HeaderBlockNone.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
HeaderParserState::HeaderParserState(const IPackValueSupplier* packValueSupplier)
|
||||
@@ -96,7 +97,7 @@ bool HeaderParserState::ResolveForwardDeclarations()
|
||||
|
||||
if (dataDefinition == nullptr)
|
||||
{
|
||||
std::cout << "Forward declaration \"" << forwardDeclaration->GetFullName() << "\" was not defined\n";
|
||||
std::cerr << std::format("Forward declaration \"{}\" was not defined\n", forwardDeclaration->GetFullName());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -12,31 +12,15 @@
|
||||
|
||||
#include <memory>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class IHeaderBlock;
|
||||
|
||||
class HeaderParserState
|
||||
{
|
||||
std::vector<std::unique_ptr<DataDefinition>> m_header_definitions;
|
||||
|
||||
std::stack<std::unique_ptr<IHeaderBlock>> m_blocks;
|
||||
std::unordered_map<std::string, const DataDefinition*> m_definitions;
|
||||
std::unordered_map<std::string, EnumMember*> m_enum_members;
|
||||
std::unordered_map<std::string, std::unique_ptr<ForwardDeclaration>> m_forward_declarations;
|
||||
|
||||
void AddBaseDataType(const BaseTypeDefinition* baseType);
|
||||
bool ResolveForwardDeclarations();
|
||||
static bool ReplaceForwardDeclarationsInStruct(StructDefinition* structDefinition);
|
||||
static bool ReplaceForwardDeclarationsInTypedef(TypedefDefinition* typedefDefinition);
|
||||
static bool ReplaceForwardDeclarationsInUnion(UnionDefinition* unionDefinition);
|
||||
bool ReplaceForwardDeclarationsInDefinitions();
|
||||
bool MoveDefinitionsToRepository(IDataRepository* repository);
|
||||
|
||||
public:
|
||||
const IPackValueSupplier* const m_pack_value_supplier;
|
||||
NamespaceBuilder m_namespace;
|
||||
|
||||
explicit HeaderParserState(const IPackValueSupplier* packValueSupplier);
|
||||
|
||||
_NODISCARD IHeaderBlock* GetBlock() const;
|
||||
@@ -50,4 +34,23 @@ public:
|
||||
EnumMember* FindEnumMember(const std::string& enumMemberName);
|
||||
|
||||
bool SaveToRepository(IDataRepository* repository);
|
||||
|
||||
const IPackValueSupplier* const m_pack_value_supplier;
|
||||
NamespaceBuilder m_namespace;
|
||||
|
||||
private:
|
||||
void AddBaseDataType(const BaseTypeDefinition* baseType);
|
||||
bool ResolveForwardDeclarations();
|
||||
static bool ReplaceForwardDeclarationsInStruct(StructDefinition* structDefinition);
|
||||
static bool ReplaceForwardDeclarationsInTypedef(TypedefDefinition* typedefDefinition);
|
||||
static bool ReplaceForwardDeclarationsInUnion(UnionDefinition* unionDefinition);
|
||||
bool ReplaceForwardDeclarationsInDefinitions();
|
||||
bool MoveDefinitionsToRepository(IDataRepository* repository);
|
||||
|
||||
std::vector<std::unique_ptr<DataDefinition>> m_header_definitions;
|
||||
|
||||
std::stack<std::unique_ptr<IHeaderBlock>> m_blocks;
|
||||
std::unordered_map<std::string, const DataDefinition*> m_definitions;
|
||||
std::unordered_map<std::string, EnumMember*> m_enum_members;
|
||||
std::unordered_map<std::string, std::unique_ptr<ForwardDeclaration>> m_forward_declarations;
|
||||
};
|
||||
|
@@ -61,9 +61,6 @@ enum class HeaderParserValueType
|
||||
class HeaderParserValue final : public IParserValue
|
||||
{
|
||||
public:
|
||||
TokenPos m_pos;
|
||||
HeaderParserValueType m_type;
|
||||
|
||||
union ValueType
|
||||
{
|
||||
char char_value;
|
||||
@@ -90,23 +87,25 @@ public:
|
||||
static HeaderParserValue Keyword(TokenPos pos, HeaderParserValueType type);
|
||||
static HeaderParserValue TypeName(TokenPos pos, std::string* typeName);
|
||||
|
||||
private:
|
||||
HeaderParserValue(TokenPos pos, HeaderParserValueType type);
|
||||
|
||||
public:
|
||||
~HeaderParserValue() override;
|
||||
HeaderParserValue(const HeaderParserValue& other) = delete;
|
||||
HeaderParserValue(HeaderParserValue&& other) noexcept;
|
||||
HeaderParserValue& operator=(const HeaderParserValue& other) = delete;
|
||||
HeaderParserValue& operator=(HeaderParserValue&& other) noexcept;
|
||||
|
||||
_NODISCARD bool IsEof() const override;
|
||||
_NODISCARD const TokenPos& GetPos() const override;
|
||||
[[nodiscard]] bool IsEof() const override;
|
||||
[[nodiscard]] const TokenPos& GetPos() const override;
|
||||
|
||||
_NODISCARD char CharacterValue() const;
|
||||
_NODISCARD int IntegerValue() const;
|
||||
_NODISCARD double FloatingPointValue() const;
|
||||
_NODISCARD std::string& StringValue() const;
|
||||
_NODISCARD std::string& IdentifierValue() const;
|
||||
_NODISCARD std::string& TypeNameValue() const;
|
||||
[[nodiscard]] char CharacterValue() const;
|
||||
[[nodiscard]] int IntegerValue() const;
|
||||
[[nodiscard]] double FloatingPointValue() const;
|
||||
[[nodiscard]] std::string& StringValue() const;
|
||||
[[nodiscard]] std::string& IdentifierValue() const;
|
||||
[[nodiscard]] std::string& TypeNameValue() const;
|
||||
|
||||
TokenPos m_pos;
|
||||
HeaderParserValueType m_type;
|
||||
|
||||
private:
|
||||
HeaderParserValue(TokenPos pos, HeaderParserValueType type);
|
||||
};
|
||||
|
@@ -5,11 +5,12 @@
|
||||
|
||||
class HeaderMatcherCharacter final : public AbstractMatcher<HeaderParserValue>
|
||||
{
|
||||
char m_char;
|
||||
public:
|
||||
explicit HeaderMatcherCharacter(char c);
|
||||
|
||||
protected:
|
||||
MatcherResult<HeaderParserValue> CanMatch(ILexer<HeaderParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit HeaderMatcherCharacter(char c);
|
||||
private:
|
||||
char m_char;
|
||||
};
|
||||
|
@@ -8,9 +8,9 @@ class HeaderMatcherFactory final : public AbstractMatcherFactory<HeaderParserVal
|
||||
public:
|
||||
explicit HeaderMatcherFactory(const IMatcherForLabelSupplier<HeaderParserValue>* labelSupplier);
|
||||
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Type(HeaderParserValueType type) const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Identifier() const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Integer() const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> FloatingPoint() const;
|
||||
_NODISCARD MatcherFactoryWrapper<HeaderParserValue> Char(char c) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Type(HeaderParserValueType type) const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Identifier() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Integer() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> FloatingPoint() const;
|
||||
[[nodiscard]] MatcherFactoryWrapper<HeaderParserValue> Char(char c) const;
|
||||
};
|
||||
|
@@ -5,11 +5,12 @@
|
||||
|
||||
class HeaderMatcherValueType final : public AbstractMatcher<HeaderParserValue>
|
||||
{
|
||||
HeaderParserValueType m_type;
|
||||
public:
|
||||
explicit HeaderMatcherValueType(HeaderParserValueType type);
|
||||
|
||||
protected:
|
||||
MatcherResult<HeaderParserValue> CanMatch(ILexer<HeaderParserValue>* lexer, unsigned tokenOffset) override;
|
||||
|
||||
public:
|
||||
explicit HeaderMatcherValueType(HeaderParserValueType type);
|
||||
private:
|
||||
HeaderParserValueType m_type;
|
||||
};
|
||||
|
@@ -4,6 +4,14 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_SEMICOLON = 1;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_CLOSING_PARENTHESIS = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceCloseBlock::SequenceCloseBlock(const bool semicolonRequired)
|
||||
: m_semicolon_required(semicolonRequired)
|
||||
{
|
||||
|
@@ -7,16 +7,12 @@
|
||||
|
||||
class SequenceCloseBlock final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_SEMICOLON = 1;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_CLOSING_PARENTHESIS = 2;
|
||||
public:
|
||||
explicit SequenceCloseBlock(bool semicolonRequired);
|
||||
|
||||
private:
|
||||
bool m_semicolon_required;
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
explicit SequenceCloseBlock(bool semicolonRequired);
|
||||
};
|
||||
|
@@ -4,6 +4,14 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_TYPEDEF = 1;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_PARENT_TYPE = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceEnum::SequenceEnum()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,14 +7,9 @@
|
||||
|
||||
class SequenceEnum final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_TYPEDEF = 1;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_PARENT_TYPE = 2;
|
||||
public:
|
||||
SequenceEnum();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceEnum();
|
||||
};
|
||||
|
@@ -4,6 +4,12 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_VALUE = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceEnumMember::SequenceEnumMember()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,12 +7,9 @@
|
||||
|
||||
class SequenceEnumMember final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_VALUE = 2;
|
||||
public:
|
||||
SequenceEnumMember();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceEnumMember();
|
||||
};
|
||||
|
@@ -3,6 +3,16 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_ENUM = 1;
|
||||
static constexpr auto TAG_STRUCT = 2;
|
||||
static constexpr auto TAG_UNION = 3;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_NAME = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceForwardDecl::SequenceForwardDecl()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,16 +7,9 @@
|
||||
|
||||
class SequenceForwardDecl final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_ENUM = 1;
|
||||
static constexpr auto TAG_STRUCT = 2;
|
||||
static constexpr auto TAG_UNION = 3;
|
||||
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
static constexpr auto CAPTURE_NAME = 2;
|
||||
public:
|
||||
SequenceForwardDecl();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceForwardDecl();
|
||||
};
|
||||
|
@@ -3,6 +3,11 @@
|
||||
#include "Parsing/Header/Block/HeaderBlockNamespace.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr int CAPTURE_NAME = 0;
|
||||
}
|
||||
|
||||
SequenceNamespace::SequenceNamespace()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,11 +7,9 @@
|
||||
|
||||
class SequenceNamespace final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr int CAPTURE_NAME = 0;
|
||||
public:
|
||||
SequenceNamespace();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceNamespace();
|
||||
};
|
||||
|
@@ -4,6 +4,15 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr int TAG_TYPEDEF = 1;
|
||||
|
||||
static constexpr int CAPTURE_NAME = 1;
|
||||
static constexpr int CAPTURE_ALIGN = 2;
|
||||
static constexpr int CAPTURE_PARENT_TYPE = 3;
|
||||
} // namespace
|
||||
|
||||
SequenceStruct::SequenceStruct()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,15 +7,9 @@
|
||||
|
||||
class SequenceStruct final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr int TAG_TYPEDEF = 1;
|
||||
|
||||
static constexpr int CAPTURE_NAME = 1;
|
||||
static constexpr int CAPTURE_ALIGN = 2;
|
||||
static constexpr int CAPTURE_PARENT_TYPE = 3;
|
||||
public:
|
||||
SequenceStruct();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceStruct();
|
||||
};
|
||||
|
@@ -5,6 +5,22 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto TAG_POINTER_TO_ARRAY = 2;
|
||||
static constexpr auto TAG_CONST = 3;
|
||||
static constexpr auto TAG_POINTER = 4;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_ALIGN = 2;
|
||||
static constexpr auto CAPTURE_TYPE = 3;
|
||||
static constexpr auto CAPTURE_ARRAY = 4;
|
||||
|
||||
static constexpr auto LABEL_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto LABEL_POINTER_TO_ARRAY = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceTypedef::SequenceTypedef()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,25 +7,13 @@
|
||||
|
||||
class SequenceTypedef final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto TAG_POINTER_TO_ARRAY = 2;
|
||||
static constexpr auto TAG_CONST = 3;
|
||||
static constexpr auto TAG_POINTER = 4;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_ALIGN = 2;
|
||||
static constexpr auto CAPTURE_TYPE = 3;
|
||||
static constexpr auto CAPTURE_ARRAY = 4;
|
||||
|
||||
static constexpr auto LABEL_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto LABEL_POINTER_TO_ARRAY = 2;
|
||||
|
||||
void AddPointerDeclarationModifiers(SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
void AddArrayDeclarationModifiers(HeaderParserState* state, SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
public:
|
||||
SequenceTypedef();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceTypedef();
|
||||
private:
|
||||
void AddPointerDeclarationModifiers(SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
void AddArrayDeclarationModifiers(HeaderParserState* state, SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
};
|
||||
|
@@ -4,6 +4,15 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr int TAG_TYPEDEF = 1;
|
||||
|
||||
static constexpr int CAPTURE_NAME = 1;
|
||||
static constexpr int CAPTURE_ALIGN = 2;
|
||||
static constexpr int CAPTURE_PARENT_TYPE = 3;
|
||||
} // namespace
|
||||
|
||||
SequenceUnion::SequenceUnion()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,15 +7,9 @@
|
||||
|
||||
class SequenceUnion final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr int TAG_TYPEDEF = 1;
|
||||
|
||||
static constexpr int CAPTURE_NAME = 1;
|
||||
static constexpr int CAPTURE_ALIGN = 2;
|
||||
static constexpr int CAPTURE_PARENT_TYPE = 3;
|
||||
public:
|
||||
SequenceUnion();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceUnion();
|
||||
};
|
||||
|
@@ -6,6 +6,23 @@
|
||||
#include "Parsing/Header/Matcher/HeaderCommonMatchers.h"
|
||||
#include "Parsing/Header/Matcher/HeaderMatcherFactory.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
static constexpr auto TAG_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto TAG_POINTER_TO_ARRAY = 2;
|
||||
static constexpr auto TAG_CONST = 3;
|
||||
static constexpr auto TAG_POINTER = 4;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_ALIGN = 2;
|
||||
static constexpr auto CAPTURE_TYPE = 3;
|
||||
static constexpr auto CAPTURE_ARRAY = 4;
|
||||
static constexpr auto CAPTURE_BIT_SIZE = 5;
|
||||
|
||||
static constexpr auto LABEL_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto LABEL_POINTER_TO_ARRAY = 2;
|
||||
} // namespace
|
||||
|
||||
SequenceVariable::SequenceVariable()
|
||||
{
|
||||
const HeaderMatcherFactory create(this);
|
||||
|
@@ -7,26 +7,13 @@
|
||||
|
||||
class SequenceVariable final : public HeaderParser::sequence_t
|
||||
{
|
||||
static constexpr auto TAG_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto TAG_POINTER_TO_ARRAY = 2;
|
||||
static constexpr auto TAG_CONST = 3;
|
||||
static constexpr auto TAG_POINTER = 4;
|
||||
|
||||
static constexpr auto CAPTURE_NAME = 1;
|
||||
static constexpr auto CAPTURE_ALIGN = 2;
|
||||
static constexpr auto CAPTURE_TYPE = 3;
|
||||
static constexpr auto CAPTURE_ARRAY = 4;
|
||||
static constexpr auto CAPTURE_BIT_SIZE = 5;
|
||||
|
||||
static constexpr auto LABEL_ARRAY_OF_POINTERS = 1;
|
||||
static constexpr auto LABEL_POINTER_TO_ARRAY = 2;
|
||||
|
||||
void AddPointerDeclarationModifiers(SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
void AddArrayDeclarationModifiers(HeaderParserState* state, SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
public:
|
||||
SequenceVariable();
|
||||
|
||||
protected:
|
||||
void ProcessMatch(HeaderParserState* state, SequenceResult<HeaderParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceVariable();
|
||||
private:
|
||||
void AddPointerDeclarationModifiers(SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
void AddArrayDeclarationModifiers(HeaderParserState* state, SequenceResult<HeaderParserValue>& result, TypeDeclaration* typeDeclaration) const;
|
||||
};
|
||||
|
@@ -7,269 +7,273 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
unsigned CalculateSizeAndAlignPostProcessor::GetPointerSizeForArchitecture(const Architecture architecture)
|
||||
namespace
|
||||
{
|
||||
switch (architecture)
|
||||
bool CalculateFieldsIfNecessary(IDataRepository* repository, const DataDefinition* definition);
|
||||
bool CalculateFields(IDataRepository* repository, TypeDeclaration* declaration);
|
||||
|
||||
unsigned GetPointerSizeForArchitecture(const Architecture architecture)
|
||||
{
|
||||
case Architecture::X86:
|
||||
return sizeof(uint32_t);
|
||||
|
||||
case Architecture::X64:
|
||||
return sizeof(uint64_t);
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
return sizeof(uint32_t);
|
||||
}
|
||||
}
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateAlign(IDataRepository* repository, TypeDeclaration* declaration)
|
||||
{
|
||||
auto hasPointerModifier = false;
|
||||
for (const auto& declarationModifier : declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (declarationModifier->GetType() == DeclarationModifierType::POINTER)
|
||||
switch (architecture)
|
||||
{
|
||||
hasPointerModifier = true;
|
||||
break;
|
||||
case Architecture::X86:
|
||||
return sizeof(uint32_t);
|
||||
|
||||
case Architecture::X64:
|
||||
return sizeof(uint64_t);
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
return sizeof(uint32_t);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPointerModifier)
|
||||
bool CalculateAlign(IDataRepository* repository, TypeDeclaration* declaration)
|
||||
{
|
||||
declaration->m_alignment = GetPointerSizeForArchitecture(repository->GetArchitecture());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CalculateFieldsIfNecessary(repository, declaration->m_type))
|
||||
return false;
|
||||
declaration->m_alignment = declaration->m_type->GetAlignment();
|
||||
if (declaration->m_type->GetForceAlignment())
|
||||
declaration->m_flags |= TypeDeclaration::FLAG_ALIGNMENT_FORCED;
|
||||
auto hasPointerModifier = false;
|
||||
for (const auto& declarationModifier : declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (declarationModifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
hasPointerModifier = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPointerModifier)
|
||||
{
|
||||
declaration->m_alignment = GetPointerSizeForArchitecture(repository->GetArchitecture());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CalculateFieldsIfNecessary(repository, declaration->m_type))
|
||||
return false;
|
||||
declaration->m_alignment = declaration->m_type->GetAlignment();
|
||||
if (declaration->m_type->GetForceAlignment())
|
||||
declaration->m_flags |= TypeDeclaration::FLAG_ALIGNMENT_FORCED;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
bool CalculateAlign(IDataRepository* repository, DefinitionWithMembers* definition)
|
||||
{
|
||||
if (definition->m_has_alignment_override)
|
||||
{
|
||||
definition->m_flags |= DefinitionWithMembers::FLAG_ALIGNMENT_FORCED;
|
||||
definition->m_alignment = definition->m_alignment_override;
|
||||
}
|
||||
else
|
||||
{
|
||||
definition->m_alignment = 0;
|
||||
for (const auto& member : definition->m_members)
|
||||
{
|
||||
if (!CalculateFields(repository, member->m_type_declaration.get()))
|
||||
return false;
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateAlign(IDataRepository* repository, DefinitionWithMembers* definition)
|
||||
{
|
||||
if (definition->m_has_alignment_override)
|
||||
{
|
||||
definition->m_flags |= DefinitionWithMembers::FLAG_ALIGNMENT_FORCED;
|
||||
definition->m_alignment = definition->m_alignment_override;
|
||||
const auto memberAlignment = member->GetAlignment();
|
||||
if (memberAlignment > definition->m_alignment)
|
||||
definition->m_alignment = memberAlignment;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
bool CalculateSize(IDataRepository* repository, TypeDeclaration* declaration)
|
||||
{
|
||||
definition->m_alignment = 0;
|
||||
if (declaration->m_declaration_modifiers.empty())
|
||||
{
|
||||
if (!CalculateFieldsIfNecessary(repository, declaration->m_type))
|
||||
return false;
|
||||
declaration->m_size = declaration->m_type->GetSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto currentSize = 0u;
|
||||
|
||||
// If the first modifier is a pointer we do not need the actual type size
|
||||
if (declaration->m_declaration_modifiers.back()->GetType() != DeclarationModifierType::POINTER)
|
||||
{
|
||||
if (!CalculateFieldsIfNecessary(repository, declaration->m_type))
|
||||
return false;
|
||||
currentSize = declaration->m_type->GetSize();
|
||||
}
|
||||
|
||||
for (auto i = declaration->m_declaration_modifiers.size(); i > 0; i--)
|
||||
{
|
||||
const auto& declarationModifier = declaration->m_declaration_modifiers[i - 1];
|
||||
|
||||
switch (declarationModifier->GetType())
|
||||
{
|
||||
case DeclarationModifierType::POINTER:
|
||||
currentSize = GetPointerSizeForArchitecture(repository->GetArchitecture());
|
||||
break;
|
||||
|
||||
case DeclarationModifierType::ARRAY:
|
||||
currentSize *= dynamic_cast<ArrayDeclarationModifier*>(declarationModifier.get())->m_size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
declaration->m_size = currentSize;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalculateSize(IDataRepository* repository, StructDefinition* definition)
|
||||
{
|
||||
definition->m_size = 0;
|
||||
auto currentBitOffset = 0u;
|
||||
|
||||
for (const auto& member : definition->m_members)
|
||||
{
|
||||
if (!CalculateFields(repository, member->m_type_declaration.get()))
|
||||
return false;
|
||||
|
||||
const auto memberAlignment = member->GetAlignment();
|
||||
if (memberAlignment > definition->m_alignment)
|
||||
definition->m_alignment = memberAlignment;
|
||||
if (member->m_type_declaration->m_has_custom_bit_size)
|
||||
{
|
||||
member->m_offset = definition->m_size + currentBitOffset / 8;
|
||||
currentBitOffset += member->m_type_declaration->m_custom_bit_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentBitOffset > 0)
|
||||
{
|
||||
currentBitOffset = utils::Align(currentBitOffset, 8u);
|
||||
definition->m_size += currentBitOffset / 8;
|
||||
currentBitOffset = 0;
|
||||
}
|
||||
|
||||
definition->m_size = utils::Align(definition->m_size,
|
||||
member->GetForceAlignment() ? member->GetAlignment() : std::min(member->GetAlignment(), definition->m_pack));
|
||||
|
||||
member->m_offset = definition->m_size;
|
||||
|
||||
definition->m_size += member->m_type_declaration->GetSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateSize(IDataRepository* repository, TypeDeclaration* declaration)
|
||||
{
|
||||
if (declaration->m_declaration_modifiers.empty())
|
||||
{
|
||||
if (!CalculateFieldsIfNecessary(repository, declaration->m_type))
|
||||
return false;
|
||||
declaration->m_size = declaration->m_type->GetSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto currentSize = 0u;
|
||||
|
||||
// If the first modifier is a pointer we do not need the actual type size
|
||||
if (declaration->m_declaration_modifiers.back()->GetType() != DeclarationModifierType::POINTER)
|
||||
if (currentBitOffset > 0)
|
||||
{
|
||||
if (!CalculateFieldsIfNecessary(repository, declaration->m_type))
|
||||
currentBitOffset = utils::Align(currentBitOffset, 8u);
|
||||
definition->m_size += currentBitOffset / 8;
|
||||
}
|
||||
|
||||
definition->m_size = utils::Align(definition->m_size, definition->m_alignment);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalculateSize(IDataRepository* repository, UnionDefinition* definition)
|
||||
{
|
||||
definition->m_size = 0;
|
||||
|
||||
for (const auto& member : definition->m_members)
|
||||
{
|
||||
if (!CalculateFields(repository, member->m_type_declaration.get()))
|
||||
return false;
|
||||
currentSize = declaration->m_type->GetSize();
|
||||
|
||||
member->m_offset = 0;
|
||||
|
||||
const auto memberSize = member->m_type_declaration->GetSize();
|
||||
if (memberSize > definition->m_size)
|
||||
definition->m_size = memberSize;
|
||||
}
|
||||
|
||||
for (auto i = declaration->m_declaration_modifiers.size(); i > 0; i--)
|
||||
{
|
||||
const auto& declarationModifier = declaration->m_declaration_modifiers[i - 1];
|
||||
definition->m_size = utils::Align(definition->m_size, definition->m_alignment);
|
||||
|
||||
switch (declarationModifier->GetType())
|
||||
{
|
||||
case DeclarationModifierType::POINTER:
|
||||
currentSize = GetPointerSizeForArchitecture(repository->GetArchitecture());
|
||||
break;
|
||||
|
||||
case DeclarationModifierType::ARRAY:
|
||||
currentSize *= dynamic_cast<ArrayDeclarationModifier*>(declarationModifier.get())->m_size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
declaration->m_size = currentSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateSize(IDataRepository* repository, StructDefinition* definition)
|
||||
{
|
||||
definition->m_size = 0;
|
||||
auto currentBitOffset = 0u;
|
||||
|
||||
for (const auto& member : definition->m_members)
|
||||
bool CalculateFields(IDataRepository* repository, TypeDeclaration* declaration)
|
||||
{
|
||||
if (!CalculateFields(repository, member->m_type_declaration.get()))
|
||||
if (declaration->m_flags & TypeDeclaration::FLAG_FIELDS_CALCULATED)
|
||||
return true;
|
||||
|
||||
if (!CalculateAlign(repository, declaration) || !CalculateSize(repository, declaration))
|
||||
return false;
|
||||
|
||||
if (member->m_type_declaration->m_has_custom_bit_size)
|
||||
{
|
||||
member->m_offset = definition->m_size + currentBitOffset / 8;
|
||||
currentBitOffset += member->m_type_declaration->m_custom_bit_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentBitOffset > 0)
|
||||
{
|
||||
currentBitOffset = utils::Align(currentBitOffset, 8u);
|
||||
definition->m_size += currentBitOffset / 8;
|
||||
currentBitOffset = 0;
|
||||
}
|
||||
|
||||
definition->m_size =
|
||||
utils::Align(definition->m_size, member->GetForceAlignment() ? member->GetAlignment() : std::min(member->GetAlignment(), definition->m_pack));
|
||||
|
||||
member->m_offset = definition->m_size;
|
||||
|
||||
definition->m_size += member->m_type_declaration->GetSize();
|
||||
}
|
||||
declaration->m_flags |= TypeDeclaration::FLAG_FIELDS_CALCULATED;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (currentBitOffset > 0)
|
||||
bool CalculateFields(IDataRepository* repository, StructDefinition* structDefinition)
|
||||
{
|
||||
currentBitOffset = utils::Align(currentBitOffset, 8u);
|
||||
definition->m_size += currentBitOffset / 8;
|
||||
}
|
||||
|
||||
definition->m_size = utils::Align(definition->m_size, definition->m_alignment);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateSize(IDataRepository* repository, UnionDefinition* definition)
|
||||
{
|
||||
definition->m_size = 0;
|
||||
|
||||
for (const auto& member : definition->m_members)
|
||||
{
|
||||
if (!CalculateFields(repository, member->m_type_declaration.get()))
|
||||
if (structDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATED)
|
||||
return true;
|
||||
if (structDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATING)
|
||||
{
|
||||
std::cerr << "Detected circular dependency:\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
member->m_offset = 0;
|
||||
structDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
|
||||
const auto memberSize = member->m_type_declaration->GetSize();
|
||||
if (memberSize > definition->m_size)
|
||||
definition->m_size = memberSize;
|
||||
}
|
||||
if (!CalculateAlign(repository, structDefinition) || !CalculateSize(repository, structDefinition))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
definition->m_size = utils::Align(definition->m_size, definition->m_alignment);
|
||||
structDefinition->m_flags &= ~DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
structDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATED;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateFields(IDataRepository* repository, TypeDeclaration* declaration)
|
||||
{
|
||||
if (declaration->m_flags & TypeDeclaration::FLAG_FIELDS_CALCULATED)
|
||||
return true;
|
||||
|
||||
if (!CalculateAlign(repository, declaration) || !CalculateSize(repository, declaration))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
declaration->m_flags |= TypeDeclaration::FLAG_FIELDS_CALCULATED;
|
||||
return true;
|
||||
}
|
||||
bool CalculateFields(IDataRepository* repository, UnionDefinition* unionDefinition)
|
||||
{
|
||||
if (unionDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATED)
|
||||
return true;
|
||||
if (unionDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATING)
|
||||
{
|
||||
std::cerr << "Detected circular dependency:\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
unionDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
|
||||
if (!CalculateAlign(repository, unionDefinition) || !CalculateSize(repository, unionDefinition))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unionDefinition->m_flags &= ~DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
unionDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATED;
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateFields(IDataRepository* repository, StructDefinition* structDefinition)
|
||||
{
|
||||
if (structDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATED)
|
||||
return true;
|
||||
if (structDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATING)
|
||||
{
|
||||
std::cout << "Detected circular dependency:\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
structDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
|
||||
if (!CalculateAlign(repository, structDefinition) || !CalculateSize(repository, structDefinition))
|
||||
bool CalculateFieldsIfNecessary(IDataRepository* repository, const DataDefinition* definition)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (definition->GetType() == DataDefinitionType::STRUCT)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<StructDefinition*>(const_cast<DataDefinition*>(definition)));
|
||||
}
|
||||
|
||||
structDefinition->m_flags &= ~DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
structDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATED;
|
||||
if (definition->GetType() == DataDefinitionType::UNION)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<UnionDefinition*>(const_cast<DataDefinition*>(definition)));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if (definition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<TypedefDefinition*>(const_cast<DataDefinition*>(definition))->m_type_declaration.get());
|
||||
}
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateFields(IDataRepository* repository, UnionDefinition* unionDefinition)
|
||||
{
|
||||
if (unionDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATED)
|
||||
return true;
|
||||
if (unionDefinition->m_flags & DefinitionWithMembers::FLAG_FIELDS_CALCULATING)
|
||||
{
|
||||
std::cout << "Detected circular dependency:\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
unionDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
|
||||
if (!CalculateAlign(repository, unionDefinition) || !CalculateSize(repository, unionDefinition))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
unionDefinition->m_flags &= ~DefinitionWithMembers::FLAG_FIELDS_CALCULATING;
|
||||
unionDefinition->m_flags |= DefinitionWithMembers::FLAG_FIELDS_CALCULATED;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::CalculateFieldsIfNecessary(IDataRepository* repository, const DataDefinition* definition)
|
||||
{
|
||||
if (definition->GetType() == DataDefinitionType::STRUCT)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<StructDefinition*>(const_cast<DataDefinition*>(definition)));
|
||||
}
|
||||
|
||||
if (definition->GetType() == DataDefinitionType::UNION)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<UnionDefinition*>(const_cast<DataDefinition*>(definition)));
|
||||
}
|
||||
|
||||
if (definition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
{
|
||||
// We can do a const cast here because the only reason that field is const anyway is because it could be a base type
|
||||
return CalculateFields(repository, dynamic_cast<TypedefDefinition*>(const_cast<DataDefinition*>(definition))->m_type_declaration.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool CalculateSizeAndAlignPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
if (repository->GetArchitecture() == Architecture::UNKNOWN)
|
||||
{
|
||||
std::cout << "You must set an architecture!\n";
|
||||
std::cerr << "You must set an architecture!\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -4,17 +4,6 @@
|
||||
|
||||
class CalculateSizeAndAlignPostProcessor final : public IPostProcessor
|
||||
{
|
||||
static unsigned GetPointerSizeForArchitecture(Architecture architecture);
|
||||
static bool CalculateAlign(IDataRepository* repository, TypeDeclaration* declaration);
|
||||
static bool CalculateAlign(IDataRepository* repository, DefinitionWithMembers* definition);
|
||||
static bool CalculateSize(IDataRepository* repository, TypeDeclaration* declaration);
|
||||
static bool CalculateSize(IDataRepository* repository, StructDefinition* definition);
|
||||
static bool CalculateSize(IDataRepository* repository, UnionDefinition* definition);
|
||||
static bool CalculateFields(IDataRepository* repository, TypeDeclaration* declaration);
|
||||
static bool CalculateFields(IDataRepository* repository, StructDefinition* structDefinition);
|
||||
static bool CalculateFields(IDataRepository* repository, UnionDefinition* unionDefinition);
|
||||
static bool CalculateFieldsIfNecessary(IDataRepository* repository, const DataDefinition* definition);
|
||||
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
||||
|
@@ -2,28 +2,31 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
bool CreateMemberInformationPostProcessor::CreateMemberInformationForStructure(IDataRepository* repository, StructureInformation* structure) const
|
||||
namespace
|
||||
{
|
||||
for (const auto& member : structure->m_definition->m_members)
|
||||
bool CreateMemberInformationForStructure(IDataRepository* repository, StructureInformation* structure)
|
||||
{
|
||||
StructureInformation* typeInfo = nullptr;
|
||||
const auto* currentDefinition = member->m_type_declaration->m_type;
|
||||
|
||||
while (currentDefinition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
for (const auto& member : structure->m_definition->m_members)
|
||||
{
|
||||
currentDefinition = dynamic_cast<const TypedefDefinition*>(currentDefinition)->m_type_declaration->m_type;
|
||||
StructureInformation* typeInfo = nullptr;
|
||||
const auto* currentDefinition = member->m_type_declaration->m_type;
|
||||
|
||||
while (currentDefinition->GetType() == DataDefinitionType::TYPEDEF)
|
||||
{
|
||||
currentDefinition = dynamic_cast<const TypedefDefinition*>(currentDefinition)->m_type_declaration->m_type;
|
||||
}
|
||||
|
||||
const auto* memberDefinition = dynamic_cast<const DefinitionWithMembers*>(currentDefinition);
|
||||
|
||||
if (memberDefinition != nullptr)
|
||||
typeInfo = repository->GetInformationFor(memberDefinition);
|
||||
|
||||
structure->m_ordered_members.emplace_back(std::make_unique<MemberInformation>(structure, typeInfo, member.get()));
|
||||
}
|
||||
|
||||
const auto* memberDefinition = dynamic_cast<const DefinitionWithMembers*>(currentDefinition);
|
||||
|
||||
if (memberDefinition != nullptr)
|
||||
typeInfo = repository->GetInformationFor(memberDefinition);
|
||||
|
||||
structure->m_ordered_members.emplace_back(std::make_unique<MemberInformation>(structure, typeInfo, member.get()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool CreateMemberInformationPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
|
@@ -4,8 +4,6 @@
|
||||
|
||||
class CreateMemberInformationPostProcessor final : public IPostProcessor
|
||||
{
|
||||
bool CreateMemberInformationForStructure(IDataRepository* repository, StructureInformation* structure) const;
|
||||
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
||||
|
@@ -4,45 +4,48 @@
|
||||
#include "Domain/Computations/StructureComputations.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
|
||||
bool LeafsPostProcessor::IsLeaf(StructureInformation* info)
|
||||
namespace
|
||||
{
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
bool IsLeaf(StructureInformation* info)
|
||||
{
|
||||
// If there is a condition to this member and it always evaluates to false: Skip this member
|
||||
if (member->m_condition && member->m_condition->IsStatic() && member->m_condition->EvaluateNumeric() == 0)
|
||||
continue;
|
||||
|
||||
// Any ScriptStrings or Strings need to be processed.
|
||||
if (member->m_is_script_string || member->m_is_string)
|
||||
return false;
|
||||
|
||||
// If there are any Pointer members that are not always count 0 it needs to be processed.
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
auto* pointer = dynamic_cast<PointerDeclarationModifier*>(modifier.get());
|
||||
const auto* countEvaluation = pointer->GetCountEvaluation();
|
||||
// If there is a condition to this member and it always evaluates to false: Skip this member
|
||||
if (member->m_condition && member->m_condition->IsStatic() && member->m_condition->EvaluateNumeric() == 0)
|
||||
continue;
|
||||
|
||||
if (!countEvaluation->IsStatic() || countEvaluation->EvaluateNumeric() != 0)
|
||||
return false;
|
||||
// Any ScriptStrings or Strings need to be processed.
|
||||
if (member->m_is_script_string || member->m_is_string)
|
||||
return false;
|
||||
|
||||
// If there are any Pointer members that are not always count 0 it needs to be processed.
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
auto* pointer = dynamic_cast<PointerDeclarationModifier*>(modifier.get());
|
||||
const auto* countEvaluation = pointer->GetCountEvaluation();
|
||||
|
||||
if (!countEvaluation->IsStatic() || countEvaluation->EvaluateNumeric() != 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
MemberComputations computations(member.get());
|
||||
|
||||
// If the member has an embedded type with dynamic size
|
||||
if (computations.HasDynamicArraySize())
|
||||
return false;
|
||||
|
||||
if (member->m_type != nullptr && member->m_type != info && !IsLeaf(member->m_type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
MemberComputations computations(member.get());
|
||||
|
||||
// If the member has an embedded type with dynamic size
|
||||
if (computations.HasDynamicArraySize())
|
||||
return false;
|
||||
|
||||
if (member->m_type != nullptr && member->m_type != info && !IsLeaf(member->m_type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool LeafsPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
|
@@ -4,8 +4,6 @@
|
||||
|
||||
class LeafsPostProcessor final : public IPostProcessor
|
||||
{
|
||||
static bool IsLeaf(StructureInformation* info);
|
||||
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
||||
|
@@ -6,61 +6,64 @@
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
bool MarkingRequiredPostProcessor::CalculateRequiresMarking(std::unordered_set<const void*>& visitedStructures, StructureInformation* info)
|
||||
namespace
|
||||
{
|
||||
if (visitedStructures.find(info) != visitedStructures.end())
|
||||
return info->m_requires_marking;
|
||||
|
||||
visitedStructures.emplace(info);
|
||||
|
||||
if (info->m_asset_enum_entry)
|
||||
bool CalculateRequiresMarking(std::unordered_set<const void*>& visitedStructures, StructureInformation* info)
|
||||
{
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
}
|
||||
if (visitedStructures.find(info) != visitedStructures.end())
|
||||
return info->m_requires_marking;
|
||||
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
// If there is a condition to this member, and it always evaluates to false: Skip this member
|
||||
if (member->m_condition && member->m_condition->IsStatic() && member->m_condition->EvaluateNumeric() == 0)
|
||||
continue;
|
||||
visitedStructures.emplace(info);
|
||||
|
||||
// Skip if it has a pointer evaluation that always resolves to 0
|
||||
auto skip = false;
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
if (info->m_asset_enum_entry)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
const auto* pointer = dynamic_cast<PointerDeclarationModifier*>(modifier.get());
|
||||
const auto* countEvaluation = pointer->GetCountEvaluation();
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (countEvaluation->IsStatic() && countEvaluation->EvaluateNumeric() == 0)
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
// If there is a condition to this member, and it always evaluates to false: Skip this member
|
||||
if (member->m_condition && member->m_condition->IsStatic() && member->m_condition->EvaluateNumeric() == 0)
|
||||
continue;
|
||||
|
||||
// Skip if it has a pointer evaluation that always resolves to 0
|
||||
auto skip = false;
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
skip = true;
|
||||
break;
|
||||
const auto* pointer = dynamic_cast<PointerDeclarationModifier*>(modifier.get());
|
||||
const auto* countEvaluation = pointer->GetCountEvaluation();
|
||||
|
||||
if (countEvaluation->IsStatic() && countEvaluation->EvaluateNumeric() == 0)
|
||||
{
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
if (skip)
|
||||
continue;
|
||||
|
||||
// Any script strings, asset refs and assets need to be processed.
|
||||
if (member->m_is_script_string || member->m_asset_ref || member->m_type && member->m_type->m_asset_enum_entry)
|
||||
{
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
// Any script strings, asset refs and assets need to be processed.
|
||||
if (member->m_is_script_string || member->m_asset_ref || member->m_type && member->m_type->m_asset_enum_entry)
|
||||
{
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (member->m_type != nullptr && member->m_type != info && CalculateRequiresMarking(visitedStructures, member->m_type))
|
||||
{
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (member->m_type != nullptr && member->m_type != info && CalculateRequiresMarking(visitedStructures, member->m_type))
|
||||
{
|
||||
info->m_requires_marking = true;
|
||||
return true;
|
||||
}
|
||||
info->m_requires_marking = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
info->m_requires_marking = false;
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool MarkingRequiredPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
|
@@ -6,8 +6,6 @@
|
||||
|
||||
class MarkingRequiredPostProcessor final : public IPostProcessor
|
||||
{
|
||||
static bool CalculateRequiresMarking(std::unordered_set<const void*>& visitedStructures, StructureInformation* info);
|
||||
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
||||
|
@@ -3,42 +3,45 @@
|
||||
#include "Domain/Computations/MemberComputations.h"
|
||||
#include "Domain/Definition/PointerDeclarationModifier.h"
|
||||
|
||||
bool MemberLeafsPostProcessor::MemberIsLeaf(MemberInformation* member)
|
||||
namespace
|
||||
{
|
||||
if (member->m_is_string || member->m_is_script_string)
|
||||
return false;
|
||||
|
||||
if (member->m_type != nullptr && !member->m_type->m_is_leaf)
|
||||
return false;
|
||||
|
||||
// If there are any Pointer members that are not always count 0 it needs to be processed.
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
bool MemberIsLeaf(MemberInformation* member)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
auto* pointer = dynamic_cast<PointerDeclarationModifier*>(modifier.get());
|
||||
const auto* countEvaluation = pointer->GetCountEvaluation();
|
||||
if (member->m_is_string || member->m_is_script_string)
|
||||
return false;
|
||||
|
||||
if (!countEvaluation->IsStatic() || countEvaluation->EvaluateNumeric() != 0)
|
||||
return false;
|
||||
if (member->m_type != nullptr && !member->m_type->m_is_leaf)
|
||||
return false;
|
||||
|
||||
// If there are any Pointer members that are not always count 0 it needs to be processed.
|
||||
for (const auto& modifier : member->m_member->m_type_declaration->m_declaration_modifiers)
|
||||
{
|
||||
if (modifier->GetType() == DeclarationModifierType::POINTER)
|
||||
{
|
||||
auto* pointer = dynamic_cast<PointerDeclarationModifier*>(modifier.get());
|
||||
const auto* countEvaluation = pointer->GetCountEvaluation();
|
||||
|
||||
if (!countEvaluation->IsStatic() || countEvaluation->EvaluateNumeric() != 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const MemberComputations computations(member);
|
||||
|
||||
if (computations.HasDynamicArraySize())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ProcessInfo(StructureInformation* info)
|
||||
{
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
member->m_is_leaf = MemberIsLeaf(member.get());
|
||||
}
|
||||
}
|
||||
|
||||
const MemberComputations computations(member);
|
||||
|
||||
if (computations.HasDynamicArraySize())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemberLeafsPostProcessor::ProcessInfo(StructureInformation* info)
|
||||
{
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
member->m_is_leaf = MemberIsLeaf(member.get());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool MemberLeafsPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
|
@@ -4,9 +4,6 @@
|
||||
|
||||
class MemberLeafsPostProcessor final : public IPostProcessor
|
||||
{
|
||||
static bool MemberIsLeaf(MemberInformation* member);
|
||||
static void ProcessInfo(StructureInformation* info);
|
||||
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
||||
|
@@ -1,40 +1,44 @@
|
||||
#include "UnionsPostProcessor.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
bool UnionsPostProcessor::ProcessUnion(StructureInformation* info)
|
||||
namespace
|
||||
{
|
||||
auto index = 0u;
|
||||
auto lastEntryWithoutCondition = 0u;
|
||||
auto entriesWithoutConditionCount = 0u;
|
||||
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
bool ProcessUnion(StructureInformation* info)
|
||||
{
|
||||
if (!member->m_condition && !member->m_is_leaf)
|
||||
auto index = 0u;
|
||||
auto lastEntryWithoutCondition = 0u;
|
||||
auto entriesWithoutConditionCount = 0u;
|
||||
|
||||
for (const auto& member : info->m_ordered_members)
|
||||
{
|
||||
entriesWithoutConditionCount++;
|
||||
lastEntryWithoutCondition = index;
|
||||
if (!member->m_condition && !member->m_is_leaf)
|
||||
{
|
||||
entriesWithoutConditionCount++;
|
||||
lastEntryWithoutCondition = index;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (entriesWithoutConditionCount > 1 && !info->m_usages.empty() && !info->m_is_leaf)
|
||||
{
|
||||
std::cout << "Union '" << info->m_definition->GetFullName() << "' has more than one entry without a condition!\n";
|
||||
return false;
|
||||
}
|
||||
if (entriesWithoutConditionCount > 1 && !info->m_usages.empty() && !info->m_is_leaf)
|
||||
{
|
||||
std::cerr << std::format("Union '{}' has more than one entry without a condition!\n", info->m_definition->GetFullName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entriesWithoutConditionCount == 1)
|
||||
{
|
||||
// If there is only one entry without condition make it the last of the ordered members
|
||||
auto entryWithoutCondition = std::move(info->m_ordered_members.at(lastEntryWithoutCondition));
|
||||
info->m_ordered_members.erase(info->m_ordered_members.begin() + lastEntryWithoutCondition);
|
||||
info->m_ordered_members.emplace_back(std::move(entryWithoutCondition));
|
||||
}
|
||||
if (entriesWithoutConditionCount == 1)
|
||||
{
|
||||
// If there is only one entry without condition make it the last of the ordered members
|
||||
auto entryWithoutCondition = std::move(info->m_ordered_members.at(lastEntryWithoutCondition));
|
||||
info->m_ordered_members.erase(info->m_ordered_members.begin() + lastEntryWithoutCondition);
|
||||
info->m_ordered_members.emplace_back(std::move(entryWithoutCondition));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool UnionsPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
|
@@ -4,8 +4,6 @@
|
||||
|
||||
class UnionsPostProcessor final : public IPostProcessor
|
||||
{
|
||||
static bool ProcessUnion(StructureInformation* info);
|
||||
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
||||
|
@@ -5,59 +5,62 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
|
||||
bool UsagesPostProcessor::ProcessAsset(StructureInformation* info)
|
||||
namespace
|
||||
{
|
||||
std::set<StructureInformation*> processedInfos;
|
||||
std::queue<StructureInformation*> processingQueue;
|
||||
|
||||
processingQueue.push(info);
|
||||
|
||||
while (!processingQueue.empty())
|
||||
bool ProcessAsset(StructureInformation* info)
|
||||
{
|
||||
auto* currentStructure = processingQueue.front();
|
||||
processingQueue.pop();
|
||||
std::unordered_set<StructureInformation*> processedInfos;
|
||||
std::queue<StructureInformation*> processingQueue;
|
||||
|
||||
if (processedInfos.find(currentStructure) != processedInfos.end())
|
||||
continue;
|
||||
processedInfos.emplace(currentStructure);
|
||||
processingQueue.push(info);
|
||||
|
||||
for (const auto& member : currentStructure->m_ordered_members)
|
||||
while (!processingQueue.empty())
|
||||
{
|
||||
if (member->m_type == nullptr)
|
||||
auto* currentStructure = processingQueue.front();
|
||||
processingQueue.pop();
|
||||
|
||||
if (processedInfos.find(currentStructure) != processedInfos.end())
|
||||
continue;
|
||||
processedInfos.emplace(currentStructure);
|
||||
|
||||
const MemberComputations computations(member.get());
|
||||
for (const auto& member : currentStructure->m_ordered_members)
|
||||
{
|
||||
if (member->m_type == nullptr)
|
||||
continue;
|
||||
|
||||
if (computations.ShouldIgnore())
|
||||
continue;
|
||||
const MemberComputations computations(member.get());
|
||||
|
||||
if (computations.ContainsNonEmbeddedReference())
|
||||
member->m_type->m_non_embedded_reference_exists = true;
|
||||
if (computations.ShouldIgnore())
|
||||
continue;
|
||||
|
||||
if (computations.ContainsSinglePointerReference())
|
||||
member->m_type->m_single_pointer_reference_exists = true;
|
||||
if (computations.ContainsNonEmbeddedReference())
|
||||
member->m_type->m_non_embedded_reference_exists = true;
|
||||
|
||||
if (computations.ContainsArrayPointerReference())
|
||||
member->m_type->m_array_pointer_reference_exists = true;
|
||||
if (computations.ContainsSinglePointerReference())
|
||||
member->m_type->m_single_pointer_reference_exists = true;
|
||||
|
||||
if (computations.ContainsArrayReference())
|
||||
member->m_type->m_array_reference_exists = true;
|
||||
if (computations.ContainsArrayPointerReference())
|
||||
member->m_type->m_array_pointer_reference_exists = true;
|
||||
|
||||
if (computations.IsNotInDefaultNormalBlock())
|
||||
member->m_type->m_reference_from_non_default_normal_block_exists = true;
|
||||
if (computations.ContainsArrayReference())
|
||||
member->m_type->m_array_reference_exists = true;
|
||||
|
||||
if (member->m_is_reusable)
|
||||
member->m_type->m_reusable_reference_exists = true;
|
||||
if (computations.IsNotInDefaultNormalBlock())
|
||||
member->m_type->m_reference_from_non_default_normal_block_exists = true;
|
||||
|
||||
member->m_type->m_usages.push_back(currentStructure);
|
||||
processingQueue.push(member->m_type);
|
||||
if (member->m_is_reusable)
|
||||
member->m_type->m_reusable_reference_exists = true;
|
||||
|
||||
member->m_type->m_usages.push_back(currentStructure);
|
||||
processingQueue.push(member->m_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool UsagesPostProcessor::PostProcess(IDataRepository* repository)
|
||||
{
|
||||
|
@@ -4,8 +4,6 @@
|
||||
|
||||
class UsagesPostProcessor final : public IPostProcessor
|
||||
{
|
||||
static bool ProcessAsset(StructureInformation* info);
|
||||
|
||||
public:
|
||||
bool PostProcess(IDataRepository* repository) override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user