Call function directly when identifier is a func

This commit is contained in:
nub31
2025-06-10 18:07:04 +02:00
parent 79ec5f9b0f
commit 7f34719205

View File

@@ -1279,20 +1279,28 @@ public class QBEGenerator
parameterStrings.Add($"{qbeParameterType} {result}");
}
// var funcPointer = GenerateExpression(funcCall.Expression);
string funcTarget;
if (funcCall.Expression is IdentifierNode identifier && _symbolTable.Lookup(identifier.Namespace, identifier.Name) is SymbolTable.Func func)
{
funcTarget = func.GeneratedName;
}
else
{
var funcPointerPointer = GenerateExpression(funcCall.Expression);
var funcPointer = GenVarName();
_builder.AppendLine($" {funcPointer} =l loadl {funcPointerPointer}");
funcTarget = funcPointer;
}
if (funcType.ReturnType is not NubVoidType)
{
var outputName = GenVarName();
_builder.AppendLine($" {outputName} {QBEAssign(funcCall.Type)} call {funcPointer}({string.Join(", ", parameterStrings)})");
_builder.AppendLine($" {outputName} {QBEAssign(funcCall.Type)} call {funcTarget}({string.Join(", ", parameterStrings)})");
return outputName;
}
else
{
_builder.AppendLine($" call {funcPointer}({string.Join(", ", parameterStrings)})");
_builder.AppendLine($" call {funcTarget}({string.Join(", ", parameterStrings)})");
return "fuck";
}
}