misc: chore: Use explicit types in Generator projects

This commit is contained in:
Evan Husted 2025-01-25 14:11:46 -06:00
parent fe661dc750
commit e6b393e420
9 changed files with 45 additions and 44 deletions

View file

@ -239,8 +239,8 @@ namespace Spv.Generator
public override string ToString()
{
var labels = _operandLabels.TryGetValue(Opcode, out var opLabels) ? opLabels : Array.Empty<string>();
var result = _resultType == null ? string.Empty : $"{_resultType} ";
string[] labels = _operandLabels.TryGetValue(Opcode, out string[] opLabels) ? opLabels : Array.Empty<string>();
string result = _resultType == null ? string.Empty : $"{_resultType} ";
return $"{result}{Opcode}{_operands.ToString(labels)}";
}
}

View file

@ -63,9 +63,9 @@ namespace Spv.Generator
public readonly 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);
IEnumerable<string> labeledParams = AllOperands.Zip(labels, (op, label) => $"{label}: {op}");
IEnumerable<string> unlabeledParams = AllOperands.Skip(labels.Length).Select(op => op.ToString());
IEnumerable<string> paramsToPrint = labeledParams.Concat(unlabeledParams);
return $"({string.Join(", ", paramsToPrint)})";
}
}

View file

@ -85,7 +85,7 @@ namespace Spv.Generator
public Instruction NewInstruction(Op opcode, uint id = Instruction.InvalidId, Instruction resultType = null)
{
var result = _instPool.Allocate();
Instruction result = _instPool.Allocate();
result.Set(opcode, id, resultType);
return result;
@ -93,7 +93,7 @@ namespace Spv.Generator
public Instruction AddExtInstImport(string import)
{
var key = new DeterministicStringKey(import);
DeterministicStringKey key = new DeterministicStringKey(import);
if (_extInstImports.TryGetValue(key, out Instruction extInstImport))
{
@ -113,7 +113,7 @@ namespace Spv.Generator
private void AddTypeDeclaration(Instruction instruction, bool forceIdAllocation)
{
var key = new TypeDeclarationKey(instruction);
TypeDeclarationKey key = new TypeDeclarationKey(instruction);
if (!forceIdAllocation)
{
@ -214,7 +214,7 @@ namespace Spv.Generator
constant.Opcode == Op.OpConstantNull ||
constant.Opcode == Op.OpConstantComposite);
var key = new ConstantKey(constant);
ConstantKey key = new ConstantKey(constant);
if (_constants.TryGetValue(key, out Instruction global))
{