diff --git a/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg b/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg index 12df0b3c..11b744b3 100644 --- a/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg +++ b/src/ZoneCodeGenerator/Generating/Templates/Loading/ArrayPointer.stg @@ -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,18 +53,33 @@ $LoadArrayPointer_Loading(context, structure, member, reference)$ $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) ::= << if ($TypeVarName(structure.Type)$->$member.Member.Name$$PrintArrayIndices(reference)$) { $if(member.IsReusable)$ - 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)$); - } + $LoadArrayPointer_Reuse(context, structure, member, reference)$ $else$ $LoadArrayPointer_TypeCheck(context, structure, member, reference)$ $endif$ diff --git a/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg b/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg index e17e9aa1..2c516f73 100644 --- a/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg +++ b/src/ZoneCodeGenerator/Generating/Templates/Loading/SinglePointer.stg @@ -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)$