...
This commit is contained in:
@@ -4,7 +4,7 @@ using Syntax.Typing.BoundNode;
|
|||||||
|
|
||||||
namespace Generation.QBE;
|
namespace Generation.QBE;
|
||||||
|
|
||||||
public class QBEWriter
|
internal class QBEWriter
|
||||||
{
|
{
|
||||||
private readonly StringBuilder _builder = new();
|
private readonly StringBuilder _builder = new();
|
||||||
private int _currentLine = -1;
|
private int _currentLine = -1;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class DefinitionTable
|
|||||||
_syntaxTrees = syntaxTrees;
|
_syntaxTrees = syntaxTrees;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<FuncDefinition> LookupFunc(string @namespace, string name)
|
public Optional<FuncDefinition> LookupFunction(string @namespace, string name)
|
||||||
{
|
{
|
||||||
var definition = _syntaxTrees
|
var definition = _syntaxTrees
|
||||||
.Where(c => c.Namespace == @namespace)
|
.Where(c => c.Namespace == @namespace)
|
||||||
@@ -43,6 +43,13 @@ public class DefinitionTable
|
|||||||
.SelectMany(c => c.Definitions)
|
.SelectMany(c => c.Definitions)
|
||||||
.OfType<StructDefinitionNode>();
|
.OfType<StructDefinitionNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FuncDefinition> GetFunctions()
|
||||||
|
{
|
||||||
|
return _syntaxTrees
|
||||||
|
.SelectMany(c => c.Definitions)
|
||||||
|
.OfType<FuncDefinition>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BoundDefinitionTable
|
public class BoundDefinitionTable
|
||||||
@@ -82,4 +89,11 @@ public class BoundDefinitionTable
|
|||||||
.SelectMany(c => c.Definitions)
|
.SelectMany(c => c.Definitions)
|
||||||
.OfType<BoundStructDefinitionNode>();
|
.OfType<BoundStructDefinitionNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<BoundFuncDefinition> GetFunctions()
|
||||||
|
{
|
||||||
|
return _syntaxTrees
|
||||||
|
.SelectMany(c => c.Definitions)
|
||||||
|
.OfType<BoundFuncDefinition>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -315,7 +315,7 @@ public static class Binder
|
|||||||
{
|
{
|
||||||
NubType? type = null;
|
NubType? type = null;
|
||||||
|
|
||||||
var definition = _definitionTable.LookupFunc(expression.Namespace.Or(_syntaxTree.Namespace), expression.Name);
|
var definition = _definitionTable.LookupFunction(expression.Namespace.Or(_syntaxTree.Namespace), expression.Name);
|
||||||
if (definition.HasValue)
|
if (definition.HasValue)
|
||||||
{
|
{
|
||||||
type = new NubFuncType(definition.Value.ReturnType, definition.Value.Parameters.Select(p => p.Type).ToList());
|
type = new NubFuncType(definition.Value.ReturnType, definition.Value.Parameters.Select(p => p.Type).ToList());
|
||||||
|
|||||||
Reference in New Issue
Block a user