Lock Variables while adding to it to prevent threading issues
This commit is contained in:
parent
4062d2f140
commit
b743759146
|
@ -40,17 +40,20 @@ namespace Upsilon.Evaluator
|
|||
|
||||
public void AssignToNearest(VariableSymbol symbol, ScriptType value)
|
||||
{
|
||||
if (Variables.ContainsKey(symbol.Name))
|
||||
lock (Variables)
|
||||
{
|
||||
Variables[symbol.Name] = value;
|
||||
}
|
||||
else if (ParentScope != null)
|
||||
{
|
||||
ParentScope.AssignToNearest(symbol, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Variables.Add(symbol.Name, value);
|
||||
if (Variables.ContainsKey(symbol.Name))
|
||||
{
|
||||
Variables[symbol.Name] = value;
|
||||
}
|
||||
else if (ParentScope != null)
|
||||
{
|
||||
ParentScope.AssignToNearest(symbol, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Variables.Add(symbol.Name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue