Make setting a script variable to nil remove that variable

This commit is contained in:
Deukhoofd committed 2018-12-09 19:02:35 +01:00
1 parent 0843c9b624
commit 1e1fa06d12
2 files changed
+16 -1

No files matched your search

+6 -1
View File
@@ -27,13 +27,18 @@ namespace Upsilon.BaseTypes.ScriptTable
{
return o;
}
diagnostics.LogError("Cannot find member 's' on Table", span);
diagnostics.LogError($"Cannot find member '{s}' on Table", span);
return new ScriptNull();
}
public void Set(Diagnostics diagnostics, TextSpan span, ScriptType index, ScriptType value)
{
var s = index.ToString();
if (value.Type == Type.Nil)
{
EvaluationScope.Delete(s);
return;
}
EvaluationScope.CreateLocal(new VariableSymbol(s, value.Type, false), value);
}
+10
View File
@@ -59,6 +59,16 @@ namespace Upsilon.Evaluator
Variables[symbol.Name] = value;
}
public void Delete(VariableSymbol symbol)
{
Variables.Remove(symbol.Name);
}
public void Delete(string name)
{
Variables.Remove(name);
}
public bool TryGet(VariableSymbol symbol, out ScriptType obj)
{