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
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)$));
// $member.Member.VariableType.Type.Alignment$
$\n$
LoadArrayPointer_Loading(context, structure, member, reference) ::= <<
$if(member.Computations.IsTempBlock)$
$member.Member.VariableType.Type.FullName$* ptr = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;
$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)$
$TypeVarName(member.Member.VariableType.Type)$ = $TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$;$\n$
LoadArray_$member.Member.VariableType.Type.Name$(true, $PrintEvaluation(reference.ArrayPointerCountEvaluation)$);
$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$
%>
>>
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)$));
@ -37,10 +53,17 @@ $LoadArrayPointer_Loading(context, structure, member, reference)$
$endif$
%>
LoadArrayPointer_PointerCheck(context, structure, member, reference) ::= <<
if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$)
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)
{
$if(member.IsReusable)$
$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)$
@ -48,7 +71,15 @@ if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(refere
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) ::= <<
if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$)
{
$if(member.IsReusable)$
$LoadArrayPointer_Reuse(context, structure, member, reference)$
$else$
$LoadArrayPointer_TypeCheck(context, structure, member, reference)$
$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)$;
$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)$