diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index e21d08d..5bdd611 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.Linq; using System.Text; using Upsilon.BaseTypes; using Upsilon.BaseTypes.Number; @@ -252,7 +253,8 @@ namespace Upsilon.Binder if (assignment.Type == Type.Table) { var tableExpression = (BoundTableExpression) assignment; - variable = new TableVariableSymbol(name, tableExpression.ValueType, isLocal); + variable = new TableVariableSymbol(name, tableExpression.ValueType, isLocal, + tableExpression.Expressions.Values.ToArray()); } else { @@ -423,10 +425,7 @@ namespace Upsilon.Binder var commentData = new List(); if (e.CommentData != null) { - foreach (var comment in e.CommentData) - { - commentData.Add(comment); - } + commentData.AddRange(e.CommentData); } if (!Scope.TryGetVariable(name, !isLocal, out var variable)) @@ -483,12 +482,9 @@ namespace Upsilon.Binder statements.Add(bound); } - foreach (var variable in Scope.Variables) - { - dictionary.Add(variable.Key, true); - } + var innerVariables = Scope.Variables; Scope = s; - return new BoundTableExpression(keyType, valueType, dictionary, statements.ToImmutable(), e.Span); + return new BoundTableExpression(keyType, valueType, innerVariables, statements.ToImmutable(), e.Span); } private BoundExpression BindIndexExpression(IndexExpressionSyntax e) diff --git a/Upsilon/Binder/BoundExpressions/BoundTableExpression.cs b/Upsilon/Binder/BoundExpressions/BoundTableExpression.cs index 5c0f270..c901c9e 100644 --- a/Upsilon/Binder/BoundExpressions/BoundTableExpression.cs +++ b/Upsilon/Binder/BoundExpressions/BoundTableExpression.cs @@ -7,7 +7,7 @@ namespace Upsilon.Binder { public class BoundTableExpression : BoundExpression { - public BoundTableExpression(Type keyType, Type valueType, Dictionary expressions, + public BoundTableExpression(Type keyType, Type valueType, Dictionary expressions, ImmutableArray statements, TextSpan span) : base(span) { KeyType = keyType; @@ -33,7 +33,7 @@ namespace Upsilon.Binder public Type KeyType { get; } public Type ValueType { get; } - public Dictionary Expressions { get; } + public Dictionary Expressions { get; } public ImmutableArray Statements { get; } } } \ No newline at end of file diff --git a/Upsilon/Binder/VariableSymbol.cs b/Upsilon/Binder/VariableSymbol.cs index a7ce4ca..c50f81f 100644 --- a/Upsilon/Binder/VariableSymbol.cs +++ b/Upsilon/Binder/VariableSymbol.cs @@ -34,11 +34,13 @@ namespace Upsilon.Binder public class TableVariableSymbol : VariableSymbol { public Type OutType { get; } + public VariableSymbol[] Variables { get; } - public TableVariableSymbol(string name, Type outType, bool local) + public TableVariableSymbol(string name, Type outType, bool local, VariableSymbol[] variables) :base (name, Type.Table, local) { OutType = outType; + Variables = variables; } } } \ No newline at end of file