Skip to content

Commit

Permalink
Update Procedure.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
LPeter1997 committed Nov 13, 2024
1 parent 9b5951c commit fd42db3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Draco.Compiler/Internal/OptimizingIr/Model/Procedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ public Procedure(FunctionSymbol symbol)
public int GetParameterIndex(ParameterSymbol symbol)
{
if (symbol.IsThis) throw new ArgumentOutOfRangeException(nameof(symbol), "this parameter is treated special");
var idx = this.Symbol.Parameters.IndexOf(symbol);
if (idx == -1) throw new ArgumentOutOfRangeException(nameof(symbol));
return idx;
for (var i = 0; i < this.Parameters.Count; ++i)
{
var param = this.Parameters[i];
// TODO: A little janky...
if (param == symbol || param.GenericDefinition == symbol) return i;
}
throw new ArgumentOutOfRangeException(nameof(symbol));
}

public BasicBlock DefineBasicBlock(LabelSymbol symbol)
Expand Down

0 comments on commit fd42db3

Please sign in to comment.