ZoneCodeGenerator: Make arraypointer work with temp block

This commit is contained in:
Jan 2020-09-08 12:01:15 +02:00
parent b25fe9a9f7
commit 79848b4631
2 changed files with 48 additions and 17 deletions

View File

@ -2,22 +2,38 @@ delimiters "$", "$"
// Everything related to loading a pointer with a count that can be larger than 1 // Everything related to loading a pointer with a count that can be larger than 1
LoadArrayPointer_Loading(context, structure, member, reference) ::= <% LoadArrayPointer_Loading(context, structure, member, reference) ::= <<
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$)); $if(member.Computations.IsTempBlock)$
// $member.Member.VariableType.Type.Alignment$ $member.Member.VariableType.Type.FullName$* ptr = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;
$\n$ $endif$$\\$
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$)); $\\$
// $member.Member.VariableType.Type.Alignment$$\\$
$\\$
$\\$
$if(member.Computations.IsTempBlock)$
$member.Member.VariableType.Type.FullName$** toInsert = nullptr;
if(ptr == PTR_INSERT)
toInsert = m_stream->InsertPointer<$member.Member.VariableType.Type.FullName$>();
$endif$$\\$
$\\$
$\\$
$if(member.StructureType && !member.StructureType.IsLeaf && !member.Computations.IsRuntimeBlock)$ $if(member.StructureType && !member.StructureType.IsLeaf && !member.Computations.IsRuntimeBlock)$
$TypeVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$ $TypeVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadArray_$member.Member.VariableType.Type.Name$(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$); LoadArray_$member.Member.VariableType.Type.Name$(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$else$ $else$
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);$\\$
$endif$$\\$
$\\$
$if(member.Computations.IsTempBlock)$
m_stream->Load<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$); if(toInsert != nullptr)
*toInsert = $TypeVarName(structure.Type)$->$member.Member.Name$;$\\$
$endif$ $endif$
%> >>
LoadArrayPointer_ScriptString(context, structure, member, reference) ::= <% LoadArrayPointer_ScriptString(context, structure, member, reference) ::= <%
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$)); $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$));
@ -37,18 +53,33 @@ $LoadArrayPointer_Loading(context, structure, member, reference)$
$endif$ $endif$
%> %>
LoadArrayPointer_Reuse(context, structure, member, reference) ::= <<
$if(member.Computations.IsTempBlock)$
if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING || $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_INSERT)
{
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$
}
else
{
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToAlias($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
}$\\$
$else$
if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING)
{
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$
}
else
{
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
}$\\$
$endif$
>>
LoadArrayPointer_PointerCheck(context, structure, member, reference) ::= << LoadArrayPointer_PointerCheck(context, structure, member, reference) ::= <<
if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$) if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$)
{ {
$if(member.IsReusable)$ $if(member.IsReusable)$
if($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ == PTR_FOLLOWING) $LoadArrayPointer_Reuse(context, structure, member, reference)$
{
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$
}
else
{
$TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->ConvertOffsetToPointer($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$);
}
$else$ $else$
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$ $LoadArrayPointer_TypeCheck(context, structure, member, reference)$
$endif$ $endif$

View File

@ -7,7 +7,7 @@ $if(member.Computations.IsTempBlock)$
$member.Member.VariableType.Type.FullName$* ptr = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$; $member.Member.VariableType.Type.FullName$* ptr = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;
$endif$$\\$ $endif$$\\$
$TypeVarName(structure.Type)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$)); // $member.Member.VariableType.Type.Alignment$$\\$ $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$>(alignof($TypeDeclaration(member.Member.VariableType)$$PrintFollowingReferences(reference.FollowingReferences)$)); // $member.Member.VariableType.Type.Alignment$$\\$
$\\$ $\\$
$\\$ $\\$
$if(member.Computations.IsTempBlock)$ $if(member.Computations.IsTempBlock)$