mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
Add dynamic allocation alignment to be able to load T6 MemoryBlock asset which isnt used at all so why am i doing this again
This commit is contained in:
@ -20,6 +20,7 @@ public:
|
||||
bool m_is_reusable;
|
||||
bool m_is_leaf;
|
||||
std::unique_ptr<IEvaluation> m_condition;
|
||||
std::unique_ptr<IEvaluation> m_alloc_alignment;
|
||||
const FastFileBlock* m_fast_file_block;
|
||||
|
||||
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
|
||||
|
@ -554,7 +554,14 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
|
||||
// (Alignment specified via `__declspec(align())` showing as correct via intellisense but is incorrect when compiled for types that have a larger alignment than the specified value)
|
||||
// this was changed to make ZoneCodeGenerator calculate what is supposed to be used as alignment when allocating.
|
||||
// This is more reliable when being used with different compilers and the value used can be seen in the source code directly
|
||||
LINE(MakeMemberAccess(info, member, modifier)<<" = m_stream->Alloc<"<<typeDecl<<followingReferences<<">("<<modifier.GetAlignment()<<");")
|
||||
if (member->m_alloc_alignment)
|
||||
{
|
||||
LINE(MakeMemberAccess(info, member, modifier)<<" = m_stream->Alloc<"<<typeDecl<<followingReferences<<">("<<MakeEvaluation(member->m_alloc_alignment.get())<<");")
|
||||
}
|
||||
else
|
||||
{
|
||||
LINE(MakeMemberAccess(info, member, modifier)<<" = m_stream->Alloc<"<<typeDecl<<followingReferences<<">("<<modifier.GetAlignment()<<");")
|
||||
}
|
||||
|
||||
if (computations.IsInTempBlock())
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "CommandsParser.h"
|
||||
|
||||
#include "Parsing/Commands/Sequence/SequenceAction.h"
|
||||
#include "Parsing/Commands/Sequence/SequenceAllocAlign.h"
|
||||
#include "Parsing/Commands/Sequence/SequenceArchitecture.h"
|
||||
#include "Parsing/Commands/Sequence/SequenceArrayCount.h"
|
||||
#include "Parsing/Commands/Sequence/SequenceArraySize.h"
|
||||
@ -27,6 +28,7 @@ const std::vector<CommandsParser::sequence_t*>& CommandsParser::GetTestsForState
|
||||
{
|
||||
static std::vector<sequence_t*> tests({
|
||||
new SequenceAction(),
|
||||
new SequenceAllocAlign(),
|
||||
new SequenceArchitecture(),
|
||||
new SequenceArrayCount(),
|
||||
new SequenceArraySize(),
|
||||
|
@ -0,0 +1,34 @@
|
||||
#include "SequenceAllocAlign.h"
|
||||
|
||||
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
|
||||
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
|
||||
|
||||
SequenceAllocAlign::SequenceAllocAlign()
|
||||
{
|
||||
const CommandsMatcherFactory create(this);
|
||||
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
|
||||
AddLabeledMatchers(CommandsCommonMatchers::Evaluation(this), CommandsCommonMatchers::LABEL_EVALUATION);
|
||||
AddMatchers({
|
||||
create.Keyword("set"),
|
||||
create.Keyword("allocalign"),
|
||||
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
|
||||
create.Label(CommandsCommonMatchers::LABEL_EVALUATION),
|
||||
create.Char(';')
|
||||
});
|
||||
}
|
||||
|
||||
void SequenceAllocAlign::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
|
||||
{
|
||||
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
|
||||
StructureInformation* type;
|
||||
std::vector<MemberInformation*> memberChain;
|
||||
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), type, memberChain))
|
||||
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
|
||||
|
||||
if(memberChain.empty())
|
||||
throw ParsingException(typeNameToken.GetPos(), "Need to specify a member");
|
||||
|
||||
auto allocAlignEvaluation = CommandsCommonMatchers::ProcessEvaluation(state, result, type);
|
||||
memberChain.back()->m_alloc_alignment = std::move(allocAlignEvaluation);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "Parsing/Commands/Impl/CommandsParser.h"
|
||||
|
||||
class SequenceAllocAlign final : public CommandsParser::sequence_t
|
||||
{
|
||||
static constexpr auto CAPTURE_TYPE = 1;
|
||||
|
||||
protected:
|
||||
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
|
||||
|
||||
public:
|
||||
SequenceAllocAlign();
|
||||
};
|
Reference in New Issue
Block a user