This commit is contained in:
nub31
2025-09-20 19:19:40 +02:00
parent 68f0da8065
commit 6e403a9884
4 changed files with 59 additions and 63 deletions

View File

@@ -467,7 +467,7 @@ public class QBEGenerator
private void EmitBlock(BlockNode block, Scope? scope = null)
{
scope ??= Scope.SubScope();
scope ??= new Scope();
_scopes.Push(scope);
foreach (var statement in block.Statements)
@@ -1295,12 +1295,6 @@ public class QBEGenerator
return new NubStructType(definition.Module, definition.Name, fieldTypes, functionTypes);
}
private NubFuncType TypeOfFunc(FuncSignatureNode signature)
{
var parameters = signature.Parameters.Select(x => x.Type).ToList();
return new NubFuncType(parameters, signature.ReturnType);
}
private string TmpName()
{
return $"%.t{++_tmpIndex}";
@@ -1342,16 +1336,10 @@ public class QBEGenerator
}
}
// todo(nub31): Parent is not used when getting variables and deferred statements
public class Scope(Scope? parent = null)
public class Scope
{
public readonly Stack<StatementNode> DeferredStatements = [];
public readonly Stack<Variable> Variables = [];
public Scope SubScope()
{
return new Scope(this);
}
}
public record Variable(string Name, NubType Type);