2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-06 16:57:25 +00:00

ZoneCodeGenerator: Make pointer counts be able to differ by array index

This commit is contained in:
Jan
2019-12-18 15:30:47 +01:00
parent a7936c9eaa
commit be17ae6a48
6 changed files with 123 additions and 22 deletions

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ZoneCodeGenerator.Domain.Evaluation;
namespace ZoneCodeGenerator.Domain
@@ -8,7 +10,20 @@ namespace ZoneCodeGenerator.Domain
public static IEvaluation DefaultCount = new OperandStatic(1);
public IEvaluation Count { get; set; } = DefaultCount;
public IEvaluation[] CountByArrayIndex { get; set; }
public bool HasCountByArrayIndex => CountByArrayIndex != null;
public bool IsArray => !Count.IsStatic || Count.EvaluateNumeric() > 1;
private static bool EvaluationIsArray(IEvaluation eval)
{
return !eval.IsStatic || eval.EvaluateNumeric() > 1;
}
public bool IsArray(int index)
{
return EvaluationIsArray(HasCountByArrayIndex ? CountByArrayIndex[index] : Count);
}
public bool AnyIsArray =>
HasCountByArrayIndex ? CountByArrayIndex.Any(EvaluationIsArray) : EvaluationIsArray(Count);
}
}
}