Use index to handle IfThenBlockState

This commit is contained in:
merry 2022-02-14 21:48:28 +00:00
parent d86dcaa13d
commit d2d71f93f0
2 changed files with 12 additions and 5 deletions

View file

@ -105,7 +105,7 @@ namespace ARMeilleure.Instructions
{ {
OpCodeT16IfThen op = (OpCodeT16IfThen)context.CurrOp; OpCodeT16IfThen op = (OpCodeT16IfThen)context.CurrOp;
context.IfThenBlockState = op.IfThenBlockConds; context.SetIfThenBlockState(op.IfThenBlockConds);
} }
} }
} }

View file

@ -55,9 +55,10 @@ namespace ARMeilleure.Translation
public bool HighCq { get; } public bool HighCq { get; }
public Aarch32Mode Mode { get; } public Aarch32Mode Mode { get; }
public bool IsInIfThenBlock { get { return IfThenBlockState != null && IfThenBlockState.Length > 0; } } private int _ifThenBlockStateIndex = 0;
public Condition CurrentIfThenBlockCond { get { return IfThenBlockState[0]; } } private Condition[] _ifThenBlockState = { };
public Condition[] IfThenBlockState { get; set; } public bool IsInIfThenBlock => _ifThenBlockStateIndex < _ifThenBlockState.Length;
public Condition CurrentIfThenBlockCond => _ifThenBlockState[_ifThenBlockStateIndex];
public ArmEmitterContext( public ArmEmitterContext(
IMemoryManager memory, IMemoryManager memory,
@ -202,11 +203,17 @@ namespace ARMeilleure.Translation
return default; return default;
} }
public void SetIfThenBlockState(Condition[] state)
{
_ifThenBlockState = state;
_ifThenBlockStateIndex = 0;
}
public void AdvanceIfThenBlockState() public void AdvanceIfThenBlockState()
{ {
if (IsInIfThenBlock) if (IsInIfThenBlock)
{ {
IfThenBlockState = IfThenBlockState.Skip(1).ToArray(); _ifThenBlockStateIndex++;
} }
} }
} }