Adds GetChildren method for boundNodes

This commit is contained in:
Deukhoofd 2019-01-17 13:56:53 +01:00
parent 1d6b5673d6
commit 1e7fc7629e
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
23 changed files with 144 additions and 2 deletions

View File

@ -36,6 +36,12 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return LeftExpression;
yield return RightExpression;
}
public override Type Type { get; } public override Type Type { get; }
public BoundBinaryOperator Operator { get; } public BoundBinaryOperator Operator { get; }

View File

@ -43,6 +43,15 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Identifier;
foreach (var parameter in Parameters)
{
yield return parameter;
}
}
public override Type Type { get; } public override Type Type { get; }
} }
} }

View File

@ -1,7 +1,8 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using Upsilon.BaseTypes;
using Upsilon.Text; using Upsilon.Text;
using Type = Upsilon.BaseTypes.Type;
namespace Upsilon.Binder namespace Upsilon.Binder
{ {
@ -38,6 +39,15 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
foreach (var parameter in Parameters)
{
yield return parameter;
}
yield return Block;
}
public override Type Type => Type.Function; public override Type Type => Type.Function;
public BoundScope Scope { get; set; } public BoundScope Scope { get; set; }
public Type ReturnType { get; } public Type ReturnType { get; }

View File

@ -33,6 +33,12 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Identifier;
yield return Index;
}
public override Type Type { get; } public override Type Type { get; }
} }
@ -61,6 +67,11 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Expression;
}
public override Type Type { get; } public override Type Type { get; }
} }
} }

View File

@ -17,6 +17,11 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield break;
}
public override Type Type => Value.Type; public override Type Type => Value.Type;
public ScriptType Value { get; } public ScriptType Value { get; }
} }

View File

@ -1,8 +1,9 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using Upsilon.BaseTypes;
using Upsilon.Binder.VariableSymbols; using Upsilon.Binder.VariableSymbols;
using Upsilon.Text; using Upsilon.Text;
using Type = Upsilon.BaseTypes.Type;
namespace Upsilon.Binder namespace Upsilon.Binder
{ {
@ -29,6 +30,11 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
return Statements;
}
public override Type Type => Type.Table; public override Type Type => Type.Table;

View File

@ -17,6 +17,11 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return InExpression;
}
public override Type Type { get; } public override Type Type { get; }
public BoundUnaryExpression(BoundUnaryOperator op, BoundExpression inExpression, Type type, TextSpan span) : base(span) public BoundUnaryExpression(BoundUnaryOperator op, BoundExpression inExpression, Type type, TextSpan span) : base(span)

View File

@ -19,6 +19,11 @@ namespace Upsilon.Binder
yield return Variable; yield return Variable;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield break;
}
public override Type Type => Variable.Type; public override Type Type => Variable.Type;
} }
} }

View File

@ -14,5 +14,6 @@ namespace Upsilon.Binder
public TextSpan Span { get; } public TextSpan Span { get; }
public abstract IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition); public abstract IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition);
public abstract IEnumerable<BoundNode> GetChildren();
} }
} }

View File

@ -28,6 +28,11 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
return Statements;
}
public ImmutableArray<BoundStatement> Statements { get; } public ImmutableArray<BoundStatement> Statements { get; }
} }
} }

View File

@ -14,5 +14,10 @@ namespace Upsilon.Binder
{ {
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield break;
}
} }
} }

View File

@ -14,6 +14,11 @@ namespace Upsilon.Binder
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Expression;
}
public BoundExpressionStatement(BoundExpression expression, TextSpan span):base(span) public BoundExpressionStatement(BoundExpression expression, TextSpan span):base(span)
{ {
Expression = expression; Expression = expression;

View File

@ -24,5 +24,10 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Func;
}
} }
} }

View File

@ -34,5 +34,11 @@ namespace Upsilon.Binder
} }
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return BoundEnumerableExpression;
yield return Block;
}
} }
} }

View File

@ -50,6 +50,14 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Condition;
yield return Block;
if (NextElseIf != null) yield return NextElseIf;
if (ElseStatement != null) yield return ElseStatement;
}
public BoundExpressionStatement Condition { get; } public BoundExpressionStatement Condition { get; }
public BoundBlockStatement Block { get; } public BoundBlockStatement Block { get; }
public BoundIfStatement NextElseIf { get; } public BoundIfStatement NextElseIf { get; }
@ -75,5 +83,10 @@ namespace Upsilon.Binder
} }
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Block;
}
} }
} }

View File

@ -26,5 +26,10 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Assignment;
}
} }
} }

View File

@ -39,5 +39,13 @@ namespace Upsilon.Binder
yield return boundNode; yield return boundNode;
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return BoundStart;
yield return BoundStop;
yield return BoundStep;
yield return Block;
}
} }
} }

View File

@ -19,5 +19,10 @@ namespace Upsilon.Binder
yield return boundNode; yield return boundNode;
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Expression;
}
} }
} }

View File

@ -23,6 +23,11 @@ namespace Upsilon.Binder
foreach (var boundNode in Statement.GetNodeAtPosition(linePosition, characterPosition)) yield return boundNode; foreach (var boundNode in Statement.GetNodeAtPosition(linePosition, characterPosition)) yield return boundNode;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Statement;
}
public BoundBlockStatement Statement { get; } public BoundBlockStatement Statement { get; }
public BoundScope Scope { get; } public BoundScope Scope { get; }
} }

View File

@ -26,5 +26,11 @@ namespace Upsilon.Binder
yield return boundNode; yield return boundNode;
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return TableIndexExpression;
yield return Value;
}
} }
} }

View File

@ -28,5 +28,10 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return BoundExpression;
}
} }
} }

View File

@ -27,5 +27,11 @@ namespace Upsilon.Binder
yield return boundNode; yield return boundNode;
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield return Condition;
yield return Block;
}
} }
} }

View File

@ -22,6 +22,11 @@ namespace Upsilon.Binder
yield return this; yield return this;
} }
public override IEnumerable<BoundNode> GetChildren()
{
yield break;
}
public override Type Type => VariableSymbol.Type; public override Type Type => VariableSymbol.Type;
} }
} }