ZoneCodeGenerator: Set conditions on structs that make the build fail right now

This commit is contained in:
Jan 2019-11-21 21:47:56 +01:00
parent 27f92e6c33
commit 377dc5c99b
6 changed files with 82 additions and 27 deletions

View File

@ -482,6 +482,29 @@ use menuDef_t;
set string window::name; set string window::name;
set name window::name; set name window::name;
// expressionRpnDataUnion
use expressionRpnDataUnion;
set condition cmd never;
// textDefData_t
use textDefData_t;
set condition data never;
// itemDefData_t
use itemDefData_t;
set condition data never;
// focusDefData_t
use focusDefData_t;
set condition data never;
// Operand
use Operand;
set condition internals::intVal dataType == VAL_INT;
set condition internals::floatVal dataType == VAL_FLOAT;
set condition internals::string dataType == VAL_STRING;
set condition internals::dvar never;
// ========================================= // =========================================
// LocalizeEntry // LocalizeEntry
// ========================================= // =========================================
@ -536,6 +559,10 @@ set name name;
use FxElemVisuals; use FxElemVisuals;
set condition anonymous never; set condition anonymous never;
// FxElemExtendedDefPtr
use FxElemExtendedDefPtr;
set condition unknownDef never;
// ========================================= // =========================================
// FxImpactTable // FxImpactTable
// ========================================= // =========================================
@ -664,7 +691,9 @@ set string moveUpButtonName;
set string moveDownButtonName; set string moveDownButtonName;
set string switchSeatButtonName; set string switchSeatButtonName;
set string steerGraphName; set string steerGraphName;
set condition steerGraph never;
set string accelGraphName; set string accelGraphName;
set condition accelGraph never;
// ========================================= // =========================================
// MemoryBlock // MemoryBlock

View File

@ -17,7 +17,8 @@ namespace ZoneCodeGenerator.Generating
public ISet<StructureInformation> Structures { get; } public ISet<StructureInformation> Structures { get; }
public ISet<DataType> MemberTypes { get; } public ISet<DataType> MemberTypes { get; }
public IEnumerable<StructureInformation> ReferencedAssets => Structures.Where(inf => inf.IsAsset && inf != Asset); public IEnumerable<StructureInformation> ReferencedAssets =>
Structures.Where(inf => inf.IsAsset && inf != Asset);
public IList<FastFileBlock> Blocks { get; private set; } public IList<FastFileBlock> Blocks { get; private set; }
@ -38,10 +39,10 @@ namespace ZoneCodeGenerator.Generating
if (structureInformation.IsAsset && structureInformation != Asset) if (structureInformation.IsAsset && structureInformation != Asset)
return; return;
foreach (var member in structureInformation.OrderedMembers) foreach (var member in structureInformation.OrderedMembers
.Where(member => member.StructureType != null && !member.Computations.ShouldIgnore))
{ {
if(member.StructureType != null) AddToContext(member.StructureType);
AddToContext(member.StructureType);
} }
} }
@ -55,13 +56,16 @@ namespace ZoneCodeGenerator.Generating
}; };
context.AddToContext(asset); context.AddToContext(asset);
context.MemberTypes.UnionWith(context.Structures.Where(information => !information.IsAsset || information == asset) context.MemberTypes.UnionWith(context.Structures
.Where(structureInformation => !structureInformation.IsAsset || structureInformation == asset)
.Where(structureInformation =>
structureInformation.Computations.IsUsed || structureInformation == asset)
.SelectMany(information => information.OrderedMembers) .SelectMany(information => information.OrderedMembers)
.Where(information => !information.Computations.ShouldIgnore)
.Select(information => information.Member.VariableType.Type) .Select(information => information.Member.VariableType.Type)
.Where(type => !(type is DataTypeBaseType) && type != asset.Type) .Where(type => !(type is DataTypeBaseType) && type != asset.Type)
.Distinct()); .Distinct());
return context; return context;
} }
} }

View File

@ -17,7 +17,10 @@ $endif$
%> %>
PrintOperandDynamic(op) ::= <% PrintOperandDynamic(op) ::= <%
$TypeVarName(op.Structure)$->$first(op.ReferencedMemberChain):{member | $member.Member.Name$}$$rest(op.ReferencedMemberChain):{member | .$member.Member.Name$}$ $TypeVarName(op.Structure)$
->$first(op.ReferencedMemberChain):{member | $member.Member.Name$}$
$rest(op.ReferencedMemberChain):{member | .$member.Member.Name$}$
$op.ArrayIndices:{ arrayIndex | [$arrayIndex$]}$
%> %>
PrintOperation(operation) ::= <% PrintOperation(operation) ::= <%

View File

@ -1,8 +1,21 @@
// Everything related to loading an embedded reference // Everything related to loading an embedded reference
LoadEmbedded(context, structure, member) ::= << LoadEmbedded_Load(context, structure, member) ::= <<
$if(!member.Computations.ShouldIgnore)$
$TypeVarName(member.StructureType)$ = &$TypeVarName(structure)$->$member.Member.Name$; $TypeVarName(member.StructureType)$ = &$TypeVarName(structure)$->$member.Member.Name$;
Load_$member.Member.VariableType.Type.Name$(false); Load_$member.Member.VariableType.Type.Name$(false);
$endif$
>> >>
LoadEmbedded_Array(context, structure, member) ::= <<
>>
LoadEmbedded(context, structure, member) ::= <%
$if(!member.Computations.ShouldIgnore)$
$if(member.Computations.IsArray)$
$LoadEmbedded_Array(context, structure, member)$
$else$
$LoadEmbedded_Load(context, structure, member)$
$endif$
$endif$
%>

View File

@ -1,26 +1,30 @@
// String // String
LoadStringSingleDepth(context, structure, member) ::= << LoadStringSingleDepth(context, structure, member) ::= <%
$if(!member.Computations.IsArray)$ $if(!member.Computations.IsArray)$
varXString = &$TypeVarName(structure)$->$member.Member.Name$; varXString = &$TypeVarName(structure)$->$member.Member.Name$;$\n$
LoadXString(false); $\\$ LoadXString(false);$\n$
$else$ $else$
varXString = $TypeVarName(structure)$->$member.Member.Name$; varXString = $TypeVarName(structure)$->$member.Member.Name$;$\n$
LoadXStringArray(false, $first(member.Computations.ArraySizes)$); $\\$ LoadXStringArray(false, $first(member.Computations.ArraySizes)$);$\n$
$endif$ $endif$
>> %>
LoadString(context, structure, member) ::= << LoadString_PointerCheck(context, structure, member) ::= <<
$if(member.Computations.PointerDepthIsOne)$
$LoadStringSingleDepth(context, structure, member)$ $\\$
$elseif(member.Computations.PointerDepthIsTwo && member.Computations.ArrayPointerCountEvaluation)$
if ($TypeVarName(structure)$->$member.Member.Name$) if ($TypeVarName(structure)$->$member.Member.Name$)
{ {
$TypeVarName(structure)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$*>(alignof($TypeDeclaration(member.Member.VariableType)$*)); $TypeVarName(structure)$->$member.Member.Name$ = m_stream->Alloc<$TypeDeclaration(member.Member.VariableType)$*>(alignof($TypeDeclaration(member.Member.VariableType)$*));
varXString = $TypeVarName(structure)$->$member.Member.Name$; varXString = $TypeVarName(structure)$->$member.Member.Name$;
LoadXStringArray(true, $PrintEvaluation(member.Computations.ArrayPointerCountEvaluation)$); LoadXStringArray(true, $PrintEvaluation(member.Computations.ArrayPointerCountEvaluation)$);
} $\\$ }
$else$
#error Cannot load string $member.Member.Name$ $\\$
$endif$
>> >>
LoadString(context, structure, member) ::= <%
$if(member.Computations.PointerDepthIsOne)$
$LoadStringSingleDepth(context, structure, member)$
$elseif(member.Computations.PointerDepthIsTwo && member.Computations.ArrayPointerCountEvaluation)$
$LoadString_PointerCheck(context, structure, member)$
$else$
#error Cannot load string $member.Member.Name$
$endif$
%>

View File

@ -5,6 +5,7 @@ import "Common.stg"
import "Loading/Common.stg" import "Loading/Common.stg"
import "Loading/String.stg" import "Loading/String.stg"
import "Loading/ArrayPointer.stg" import "Loading/ArrayPointer.stg"
import "Loading/Embedded.stg"
import "Loading/SinglePointer.stg" import "Loading/SinglePointer.stg"
// Loading common // Loading common
@ -39,7 +40,7 @@ $HeaderArrayPtrLoadMethodDeclaration(structure)$
$\n$ $\n$
$endif$ $endif$
$if(structure.NonEmbeddedReferenceExists && !structure.IsLeaf)$ $if(!structure.IsLeaf && structure.Computations.IsUsed)$
$HeaderLoadMethodDeclaration(structure)$ $HeaderLoadMethodDeclaration(structure)$
$\n$ $\n$
$endif$ $endif$
@ -98,7 +99,8 @@ $elseif(member.Computations.IsArrayPointerReference && member.Computations.Point
$LoadArrayPointer(context, structure, member)$ $LoadArrayPointer(context, structure, member)$
$elseif(member.Computations.IsSinglePointerReference)$ $elseif(member.Computations.IsSinglePointerReference)$
$LoadSinglePointer(context, structure, member)$ $LoadSinglePointer(context, structure, member)$
$elseif(member.Computations.IsEmbeddedReference && member.StructureType)$ $elseif(member.Computations.IsEmbeddedReference && member.StructureType && !member.StructureType.IsLeaf)$
$LoadEmbedded(context, structure, member)$
$endif$ $endif$
%> %>
@ -200,7 +202,7 @@ $if(structure.ArrayPointerReferenceExists && !structure.IsLeaf)$
$LoadArrayPtrMethod(structure, context)$ $LoadArrayPtrMethod(structure, context)$
$endif$ $endif$
$if(structure.NonEmbeddedReferenceExists && !structure.IsLeaf)$ $if(!structure.IsLeaf && structure.Computations.IsUsed)$
$LoadMethod(structure, context)$ $LoadMethod(structure, context)$
$endif$ $endif$