This commit is contained in:
nub31
2025-07-07 19:01:26 +02:00
parent 5672d181fe
commit 85066f8678

View File

@@ -363,7 +363,9 @@ public partial class QBEGenerator
builder.Append(name); builder.Append(name);
builder.Append($"({string.Join(", ", parameters.Select(x => FuncQBETypeName(x.Type) + $" %{x.Name}"))})"); var parameterStrings = parameters.Select(x => FuncQBETypeName(x.Type) + $" %{x.Name}");
builder.Append($"({string.Join(", ", parameterStrings)})");
_writer.StartFunction(builder.ToString()); _writer.StartFunction(builder.ToString());
@@ -374,6 +376,8 @@ public partial class QBEGenerator
scope.Declare(parameter.Name, new Val("%" + parameter.Name, parameter.Type, ValKind.Direct)); scope.Declare(parameter.Name, new Val("%" + parameter.Name, parameter.Type, ValKind.Direct));
} }
EmitBlock(body, scope);
if (body.Statements.LastOrDefault() is not BoundReturn) if (body.Statements.LastOrDefault() is not BoundReturn)
{ {
if (returnType is NubVoidType) if (returnType is NubVoidType)
@@ -447,10 +451,13 @@ public partial class QBEGenerator
{ {
_scopes.Push(scope ?? Scope.SubScope()); _scopes.Push(scope ?? Scope.SubScope());
foreach (var statement in block.Statements.Where(_ => _codeIsReachable)) foreach (var statement in block.Statements)
{
if (_codeIsReachable)
{ {
EmitStatement(statement); EmitStatement(statement);
} }
}
_scopes.Pop(); _scopes.Pop();