Fixes binder assigning values to static read only scope
This commit is contained in:
@@ -4,14 +4,13 @@ using System.Collections.Immutable;
|
||||
using Upsilon.BaseTypes;
|
||||
using Upsilon.BaseTypes.Number;
|
||||
using Upsilon.Parser;
|
||||
using Upsilon.Text;
|
||||
using Type = Upsilon.BaseTypes.Type;
|
||||
|
||||
namespace Upsilon.Binder
|
||||
{
|
||||
internal class Binder
|
||||
{
|
||||
private readonly Diagnostics _diagnostics;
|
||||
private Diagnostics _diagnostics;
|
||||
public BoundScope Scope { get; private set; }
|
||||
|
||||
private Dictionary<string, UnboundFunctionExpression> _unboundFunctions =
|
||||
@@ -23,6 +22,14 @@ namespace Upsilon.Binder
|
||||
Scope = new BoundScope(variables, null);
|
||||
}
|
||||
|
||||
private Binder(){}
|
||||
|
||||
internal static Binder CreateWithSetScope(Diagnostics diagnostics, BoundScope scope)
|
||||
{
|
||||
return new Binder {_diagnostics = diagnostics, Scope = scope};
|
||||
}
|
||||
|
||||
|
||||
public BoundScript BindScript(BlockStatementSyntax e)
|
||||
{
|
||||
var bound = BindStatement(e);
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Collections.Immutable;
|
||||
using Upsilon.BaseTypes;
|
||||
using Upsilon.Binder;
|
||||
using Upsilon.Parser;
|
||||
using Upsilon.StandardLibraries;
|
||||
using Upsilon.Text;
|
||||
using Upsilon.Utilities;
|
||||
|
||||
@@ -20,16 +19,16 @@ namespace Upsilon.Evaluator
|
||||
private Binder.Binder Binder { get; }
|
||||
private EvaluationScope Scope { get; }
|
||||
|
||||
public Script(string scriptString, Dictionary<string, VariableSymbol> boundStaticScope, Dictionary<string, LuaType> staticScope )
|
||||
public Script(string scriptString, BoundScope boundStaticScope, EvaluationScope staticScope )
|
||||
{
|
||||
ScriptString = new SourceText(scriptString);
|
||||
Diagnostics = new Diagnostics(ScriptString);
|
||||
_parsed = Parser.Parser.Parse(scriptString, Diagnostics);
|
||||
|
||||
var boundScope = new BoundScope(boundStaticScope, null);
|
||||
Binder = new Binder.Binder(Diagnostics, boundScope.Variables);
|
||||
var boundScope = BoundScope.WithReadOnlyScope(boundStaticScope);
|
||||
Binder = Upsilon.Binder.Binder.CreateWithSetScope(Diagnostics, boundScope);
|
||||
|
||||
Scope = EvaluationScope.CreateWithGetOnlyParent(new EvaluationScope(staticScope));
|
||||
Scope = EvaluationScope.CreateWithGetOnlyParent(staticScope);
|
||||
Evaluator = Evaluator.CreateWithSetScope(Diagnostics, Scope);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user