Fixes for binding table contents when binder can't be aware of table contents, such as with CSharp calls
This commit is contained in:
parent
bbab802f2d
commit
f638c25483
|
@ -370,6 +370,10 @@ namespace Upsilon.Binder
|
||||||
((TableVariableSymbol) ((BoundVariableExpression) assignment).Variable.VariableSymbol)
|
((TableVariableSymbol) ((BoundVariableExpression) assignment).Variable.VariableSymbol)
|
||||||
.Variables);
|
.Variables);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
variable = new TableVariableSymbol(name, isLocal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -691,7 +695,12 @@ namespace Upsilon.Binder
|
||||||
var table = (BoundVariableExpression)expression;
|
var table = (BoundVariableExpression)expression;
|
||||||
var realTable = table.Variable;
|
var realTable = table.Variable;
|
||||||
var realIndex = (BoundLiteralExpression) index;
|
var realIndex = (BoundLiteralExpression) index;
|
||||||
var variableDic = ((TableVariableSymbol) realTable.VariableSymbol).Variables;
|
var tableSymbol = ((TableVariableSymbol) realTable.VariableSymbol);
|
||||||
|
if (!tableSymbol.ContentAware)
|
||||||
|
{
|
||||||
|
return new BoundIndexExpression(expression, index, Type.Unknown, e.Span);
|
||||||
|
}
|
||||||
|
var variableDic = tableSymbol.Variables;
|
||||||
if (variableDic.TryGetValue(realIndex.Value.ToString(), out var variable))
|
if (variableDic.TryGetValue(realIndex.Value.ToString(), out var variable))
|
||||||
{
|
{
|
||||||
return new BoundIndexExpression(expression, index, variable.Type, e.Span);
|
return new BoundIndexExpression(expression, index, variable.Type, e.Span);
|
||||||
|
|
|
@ -6,11 +6,19 @@ namespace Upsilon.Binder.VariableSymbols
|
||||||
public class TableVariableSymbol : VariableSymbol
|
public class TableVariableSymbol : VariableSymbol
|
||||||
{
|
{
|
||||||
public Dictionary<string, VariableSymbol> Variables { get; }
|
public Dictionary<string, VariableSymbol> Variables { get; }
|
||||||
|
public bool ContentAware { get; }
|
||||||
public TableVariableSymbol(string name, bool local, Dictionary<string, VariableSymbol> variables)
|
public TableVariableSymbol(string name, bool local, Dictionary<string, VariableSymbol> variables)
|
||||||
:base (name, Type.Table, local)
|
:base (name, Type.Table, local)
|
||||||
{
|
{
|
||||||
Variables = variables;
|
Variables = variables;
|
||||||
|
ContentAware = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableVariableSymbol(string name, bool local)
|
||||||
|
:base (name, Type.Table, local)
|
||||||
|
{
|
||||||
|
Variables = new Dictionary<string, VariableSymbol>();
|
||||||
|
ContentAware = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue