Better handling of finding bottom node
This commit is contained in:
parent
f903a3ca58
commit
c1fd6081fd
|
@ -896,12 +896,12 @@ namespace Upsilon.Binder
|
||||||
private BoundStatement BindGenericForStatement(GenericForStatementSyntax e)
|
private BoundStatement BindGenericForStatement(GenericForStatementSyntax e)
|
||||||
{
|
{
|
||||||
Scope = new BoundScope(Scope);
|
Scope = new BoundScope(Scope);
|
||||||
var array = ImmutableArray.CreateBuilder<VariableSymbol>();
|
var array = ImmutableArray.CreateBuilder<BoundVariableSymbol>();
|
||||||
foreach (var variableIdentifier in e.Variables)
|
foreach (var variableIdentifier in e.Variables)
|
||||||
{
|
{
|
||||||
var variable = new VariableSymbol(variableIdentifier.Name, Type.Unknown, true);
|
var variable = new VariableSymbol(variableIdentifier.Name, Type.Unknown, true);
|
||||||
Scope.DefineLocalVariable(variable);
|
Scope.DefineLocalVariable(variable);
|
||||||
array.Add(variable);
|
array.Add(new BoundVariableSymbol(variable, true, variableIdentifier.Span));
|
||||||
}
|
}
|
||||||
var boundEnumerableExpression = BindExpression(e.EnumerableExpression);
|
var boundEnumerableExpression = BindExpression(e.EnumerableExpression);
|
||||||
var block = BindBlockStatement(e.Block);
|
var block = BindBlockStatement(e.Block);
|
||||||
|
|
|
@ -11,10 +11,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundBadExpression;
|
public override BoundKind Kind => BoundKind.BoundBadExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,25 +17,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundBinaryExpression;
|
public override BoundKind Kind => BoundKind.BoundBinaryExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int line, int character)
|
|
||||||
{
|
|
||||||
if (LeftExpression.Span.Contains(line, character))
|
|
||||||
{
|
|
||||||
foreach (var exp in LeftExpression.GetNodeAtPosition(line, character))
|
|
||||||
{
|
|
||||||
yield return exp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (RightExpression.Span.Contains(line, character))
|
|
||||||
{
|
|
||||||
foreach (var exp in RightExpression.GetNodeAtPosition(line, character))
|
|
||||||
{
|
|
||||||
yield return exp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
yield return LeftExpression;
|
yield return LeftExpression;
|
||||||
|
|
|
@ -19,29 +19,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundFunctionCallExpression;
|
public override BoundKind Kind => BoundKind.BoundFunctionCallExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int line, int character)
|
|
||||||
{
|
|
||||||
if (Identifier.Span.Contains(line, character))
|
|
||||||
{
|
|
||||||
foreach (var exp in Identifier.GetNodeAtPosition(line, character))
|
|
||||||
{
|
|
||||||
yield return exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
foreach (var parameter in Parameters)
|
|
||||||
{
|
|
||||||
if (parameter.Span.Contains(line, character))
|
|
||||||
{
|
|
||||||
foreach (var exp in parameter.GetNodeAtPosition(line, character))
|
|
||||||
{
|
|
||||||
yield return exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,23 +21,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundFunctionExpression;
|
public override BoundKind Kind => BoundKind.BoundFunctionExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
foreach (var parameter in Parameters)
|
|
||||||
{
|
|
||||||
if (parameter.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in parameter.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Block.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Block.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,20 +18,6 @@ namespace Upsilon.Binder
|
||||||
public BoundExpression Index { get; }
|
public BoundExpression Index { get; }
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundIndexExpression;
|
public override BoundKind Kind => BoundKind.BoundIndexExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Identifier.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Identifier.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
if (Index.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Index.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
@ -55,17 +41,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundFullstopIndexExpression;
|
public override BoundKind Kind => BoundKind.BoundFullstopIndexExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Expression.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Expression.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,10 +12,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundLiteralExpression;
|
public override BoundKind Kind => BoundKind.BoundLiteralExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int line, int character)
|
|
||||||
{
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,17 +18,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundTableExpression;
|
public override BoundKind Kind => BoundKind.BoundTableExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
foreach (var statement in Statements)
|
|
||||||
{
|
|
||||||
if (statement.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
yield return statement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,15 +7,6 @@ namespace Upsilon.Binder
|
||||||
public class BoundUnaryExpression : BoundExpression
|
public class BoundUnaryExpression : BoundExpression
|
||||||
{
|
{
|
||||||
public override BoundKind Kind => BoundKind.BoundUnaryExpression;
|
public override BoundKind Kind => BoundKind.BoundUnaryExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (InExpression.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in InExpression.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,10 +14,6 @@ namespace Upsilon.Binder
|
||||||
|
|
||||||
public BoundVariableSymbol Variable { get; }
|
public BoundVariableSymbol Variable { get; }
|
||||||
public override BoundKind Kind => BoundKind.VariableExpression;
|
public override BoundKind Kind => BoundKind.VariableExpression;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
yield return Variable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,28 @@ namespace Upsilon.Binder
|
||||||
public abstract BoundKind Kind { get; }
|
public abstract BoundKind Kind { get; }
|
||||||
public TextSpan Span { get; }
|
public TextSpan Span { get; }
|
||||||
|
|
||||||
public abstract IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition);
|
public virtual IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
||||||
|
{
|
||||||
|
var e = GetChildren().GetEnumerator();
|
||||||
|
while (e.MoveNext())
|
||||||
|
{
|
||||||
|
var current = e.Current;
|
||||||
|
if (current == null)
|
||||||
|
continue;
|
||||||
|
if (current.Span.Contains(linePosition, characterPosition))
|
||||||
|
{
|
||||||
|
var children = current.GetNodeAtPosition(linePosition, characterPosition);
|
||||||
|
foreach (var child in children)
|
||||||
|
{
|
||||||
|
yield return child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.Dispose();
|
||||||
|
|
||||||
|
if (Span.Contains(linePosition, characterPosition))
|
||||||
|
yield return this;
|
||||||
|
}
|
||||||
public abstract IEnumerable<BoundNode> GetChildren();
|
public abstract IEnumerable<BoundNode> GetChildren();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,20 +13,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundBlockStatement;
|
public override BoundKind Kind => BoundKind.BoundBlockStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
foreach (var statement in Statements)
|
|
||||||
{
|
|
||||||
if (statement.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var node in statement.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
yield return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,10 +10,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundBreakStatement;
|
public override BoundKind Kind => BoundKind.BoundBreakStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,12 +7,6 @@ namespace Upsilon.Binder
|
||||||
{
|
{
|
||||||
public BoundExpression Expression { get; }
|
public BoundExpression Expression { get; }
|
||||||
public override BoundKind Kind => BoundKind.BoundExpressionStatement;
|
public override BoundKind Kind => BoundKind.BoundExpressionStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Expression.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,14 +16,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundFunctionAssignmentStatement;
|
public override BoundKind Kind => BoundKind.BoundFunctionAssignmentStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Func.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Func.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,11 +7,11 @@ namespace Upsilon.Binder
|
||||||
{
|
{
|
||||||
public class BoundGenericForStatement : BoundStatement
|
public class BoundGenericForStatement : BoundStatement
|
||||||
{
|
{
|
||||||
public ImmutableArray<VariableSymbol> Variables { get; }
|
public ImmutableArray<BoundVariableSymbol> Variables { get; }
|
||||||
public BoundExpression BoundEnumerableExpression { get; }
|
public BoundExpression BoundEnumerableExpression { get; }
|
||||||
public BoundStatement Block { get; }
|
public BoundStatement Block { get; }
|
||||||
|
|
||||||
public BoundGenericForStatement(ImmutableArray<VariableSymbol> variables,
|
public BoundGenericForStatement(ImmutableArray<BoundVariableSymbol> variables,
|
||||||
BoundExpression boundEnumerableExpression, BoundStatement block, TextSpan span) : base(span)
|
BoundExpression boundEnumerableExpression, BoundStatement block, TextSpan span) : base(span)
|
||||||
{
|
{
|
||||||
Variables = variables;
|
Variables = variables;
|
||||||
|
@ -20,23 +20,13 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundGenericForStatement;
|
public override BoundKind Kind => BoundKind.BoundGenericForStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (BoundEnumerableExpression.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in BoundEnumerableExpression.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
if (Block.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Block.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
foreach (var variable in Variables)
|
||||||
|
{
|
||||||
|
yield return variable;
|
||||||
|
}
|
||||||
yield return BoundEnumerableExpression;
|
yield return BoundEnumerableExpression;
|
||||||
yield return Block;
|
yield return Block;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,31 +25,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundIfStatement;
|
public override BoundKind Kind => BoundKind.BoundIfStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Condition.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Condition.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
if (Block.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Block.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
if (NextElseIf != null && NextElseIf.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in NextElseIf.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
if (ElseStatement != null && ElseStatement.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in ElseStatement.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
yield return Condition;
|
yield return Condition;
|
||||||
|
@ -74,15 +49,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundElseStatement;
|
public override BoundKind Kind => BoundKind.BoundElseStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Block.Span.Contains(linePosition, characterPosition))
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Block.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,14 +18,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundMultiAssignmentStatement;
|
public override BoundKind Kind => BoundKind.BoundMultiAssignmentStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Assignment.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Assignment.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,22 +23,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundNumericForStatement;
|
public override BoundKind Kind => BoundKind.BoundNumericForStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (BoundStart.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in BoundStart.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
if (BoundStop.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in BoundStop.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
if (BoundStep.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in BoundStep.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
if (Block.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Block.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,13 +12,6 @@ namespace Upsilon.Binder
|
||||||
|
|
||||||
public BoundExpression Expression { get; }
|
public BoundExpression Expression { get; }
|
||||||
public override BoundKind Kind => BoundKind.BoundReturnStatement;
|
public override BoundKind Kind => BoundKind.BoundReturnStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Expression.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Expression.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,10 +18,6 @@ namespace Upsilon.Binder
|
||||||
|
|
||||||
public string FileName { get; set; }
|
public string FileName { get; set; }
|
||||||
public override BoundKind Kind => BoundKind.BoundScript;
|
public override BoundKind Kind => BoundKind.BoundScript;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
foreach (var boundNode in Statement.GetNodeAtPosition(linePosition, characterPosition)) yield return boundNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,16 +16,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundTableAssigmentStatement;
|
public override BoundKind Kind => BoundKind.BoundTableAssigmentStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (TableIndexExpression.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in TableIndexExpression.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
if (Value.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Value.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,16 +18,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundAssignmentStatement;
|
public override BoundKind Kind => BoundKind.BoundAssignmentStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Variable.Span.Contains(linePosition, characterPosition))
|
|
||||||
yield return Variable;
|
|
||||||
if (BoundExpression.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in BoundExpression.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,16 +17,6 @@ namespace Upsilon.Binder
|
||||||
}
|
}
|
||||||
|
|
||||||
public override BoundKind Kind => BoundKind.BoundWhileStatement;
|
public override BoundKind Kind => BoundKind.BoundWhileStatement;
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
if (Condition.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Condition.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
if (Block.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Block.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetChildren()
|
public override IEnumerable<BoundNode> GetChildren()
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,22 +19,5 @@ namespace Upsilon.Binder
|
||||||
|
|
||||||
public BlockStatementSyntax UnboundBlock { get; }
|
public BlockStatementSyntax UnboundBlock { get; }
|
||||||
|
|
||||||
public override IEnumerable<BoundNode> GetNodeAtPosition(int linePosition, int characterPosition)
|
|
||||||
{
|
|
||||||
foreach (var parameter in Parameters)
|
|
||||||
{
|
|
||||||
if (parameter.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in parameter.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Block != null)
|
|
||||||
{
|
|
||||||
if (Block.Span.Contains(linePosition, characterPosition))
|
|
||||||
foreach (var boundNode in Block.GetNodeAtPosition(linePosition, characterPosition))
|
|
||||||
yield return boundNode;
|
|
||||||
}
|
|
||||||
yield return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -733,10 +733,10 @@ namespace Upsilon.Evaluator
|
||||||
}
|
}
|
||||||
|
|
||||||
var table = (SimpleScriptTable)current;
|
var table = (SimpleScriptTable)current;
|
||||||
if (e.Variables[0].Name != "_")
|
if (e.Variables[0].VariableSymbol.Name != "_")
|
||||||
innerEvaluator.Scope.CreateLocal(e.Variables[0], table[0].ToScriptType());
|
innerEvaluator.Scope.CreateLocal(e.Variables[0].VariableSymbol, table[0].ToScriptType());
|
||||||
if (e.Variables[1].Name != "_")
|
if (e.Variables[1].VariableSymbol.Name != "_")
|
||||||
innerEvaluator.Scope.CreateLocal(e.Variables[1], table[1]);
|
innerEvaluator.Scope.CreateLocal(e.Variables[1].VariableSymbol, table[1]);
|
||||||
innerEvaluator.EvaluateBoundBlockStatement((BoundBlockStatement) e.Block);
|
innerEvaluator.EvaluateBoundBlockStatement((BoundBlockStatement) e.Block);
|
||||||
if (innerEvaluator.HasBroken || innerEvaluator.HasReturned)
|
if (innerEvaluator.HasBroken || innerEvaluator.HasReturned)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,8 +27,10 @@ namespace Upsilon.Text
|
||||||
|
|
||||||
public bool Contains(int linePosition, int characterPosition)
|
public bool Contains(int linePosition, int characterPosition)
|
||||||
{
|
{
|
||||||
return StartLine >= linePosition && EndLine <= linePosition && characterPosition >= StartPosition &&
|
if (StartLine == linePosition && StartPosition <= characterPosition) return true;
|
||||||
characterPosition <= EndPosition;
|
if (StartLine < linePosition && EndLine > linePosition) return true;
|
||||||
|
if (EndLine == linePosition && EndPosition >= characterPosition) return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue