aboutsummaryrefslogtreecommitdiff
path: root/Spv.Generator/InstructionOperands.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Spv.Generator/InstructionOperands.cs')
-rw-r--r--Spv.Generator/InstructionOperands.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/Spv.Generator/InstructionOperands.cs b/Spv.Generator/InstructionOperands.cs
index a349827a..c48b004f 100644
--- a/Spv.Generator/InstructionOperands.cs
+++ b/Spv.Generator/InstructionOperands.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Runtime.InteropServices;
namespace Spv.Generator
@@ -49,5 +51,22 @@ namespace Spv.Generator
Overflow[Count++] = operand;
}
}
+
+ private IEnumerable<Operand> AllOperands => new[] { Operand1, Operand2, Operand3, Operand4, Operand5 }
+ .Concat(Overflow ?? Array.Empty<Operand>())
+ .Take(Count);
+
+ public override string ToString()
+ {
+ return $"({string.Join(", ", AllOperands)})";
+ }
+
+ public string ToString(string[] labels)
+ {
+ var labeledParams = AllOperands.Zip(labels, (op, label) => $"{label}: {op}");
+ var unlabeledParams = AllOperands.Skip(labels.Length).Select(op => op.ToString());
+ var paramsToPrint = labeledParams.Concat(unlabeledParams);
+ return $"({string.Join(", ", paramsToPrint)})";
+ }
}
}