not working
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
using Common;
|
||||
using Syntax.Parsing;
|
||||
using Syntax.Parsing.Node;
|
||||
using Syntax.Typing;
|
||||
using Syntax.Typing.BoundNode;
|
||||
|
||||
namespace Syntax;
|
||||
|
||||
public class DefinitionTable
|
||||
{
|
||||
private readonly IEnumerable<CompilationUnit> _compilationUnits;
|
||||
private readonly IEnumerable<SyntaxTree> _syntaxTrees;
|
||||
|
||||
public DefinitionTable(IEnumerable<CompilationUnit> compilationUnits)
|
||||
public DefinitionTable(IEnumerable<SyntaxTree> syntaxTrees)
|
||||
{
|
||||
_compilationUnits = compilationUnits;
|
||||
_syntaxTrees = syntaxTrees;
|
||||
}
|
||||
|
||||
public Optional<IFuncSignature> LookupFunc(string @namespace, string name)
|
||||
{
|
||||
var definition = _compilationUnits
|
||||
var definition = _syntaxTrees
|
||||
.Where(c => c.Namespace == @namespace)
|
||||
.SelectMany(c => c.Definitions)
|
||||
.OfType<IFuncSignature>()
|
||||
@@ -26,7 +28,7 @@ public class DefinitionTable
|
||||
|
||||
public Optional<StructDefinitionNode> LookupStruct(string @namespace, string name)
|
||||
{
|
||||
var definition = _compilationUnits
|
||||
var definition = _syntaxTrees
|
||||
.Where(c => c.Namespace == @namespace)
|
||||
.SelectMany(c => c.Definitions)
|
||||
.OfType<StructDefinitionNode>()
|
||||
@@ -37,8 +39,47 @@ public class DefinitionTable
|
||||
|
||||
public IEnumerable<StructDefinitionNode> GetStructs()
|
||||
{
|
||||
return _compilationUnits
|
||||
return _syntaxTrees
|
||||
.SelectMany(c => c.Definitions)
|
||||
.OfType<StructDefinitionNode>();
|
||||
}
|
||||
}
|
||||
|
||||
public class BoundDefinitionTable
|
||||
{
|
||||
private readonly IEnumerable<BoundSyntaxTree> _syntaxTrees;
|
||||
|
||||
public BoundDefinitionTable(IEnumerable<BoundSyntaxTree> syntaxTrees)
|
||||
{
|
||||
_syntaxTrees = syntaxTrees;
|
||||
}
|
||||
|
||||
public Optional<IBoundFuncSignature> LookupFunc(string @namespace, string name)
|
||||
{
|
||||
var definition = _syntaxTrees
|
||||
.Where(c => c.Namespace == @namespace)
|
||||
.SelectMany(c => c.Definitions)
|
||||
.OfType<IBoundFuncSignature>()
|
||||
.SingleOrDefault(f => f.Name == name);
|
||||
|
||||
return Optional.OfNullable(definition);
|
||||
}
|
||||
|
||||
public Optional<BoundStructDefinitionNode> LookupStruct(string @namespace, string name)
|
||||
{
|
||||
var definition = _syntaxTrees
|
||||
.Where(c => c.Namespace == @namespace)
|
||||
.SelectMany(c => c.Definitions)
|
||||
.OfType<BoundStructDefinitionNode>()
|
||||
.SingleOrDefault(f => f.Name == name);
|
||||
|
||||
return Optional.OfNullable(definition);
|
||||
}
|
||||
|
||||
public IEnumerable<BoundStructDefinitionNode> GetStructs()
|
||||
{
|
||||
return _syntaxTrees
|
||||
.SelectMany(c => c.Definitions)
|
||||
.OfType<BoundStructDefinitionNode>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user