public override void SetValue(Constant value) { if (value is VoidValue) { throw new ModelInterpreterException("Невозможно присвоить Void"); } ModelInterpreter.GetInstanse().variableTable[key] = value; }
//Done static public ModelInterpreter GetInstanse() { if (instance == null) { instance = new ModelInterpreter(); } return(instance); }
public override Constant GetRValue() { try { Constant obj = ModelInterpreter.GetInstanse().variableTable[key]; return(obj); } catch (KeyNotFoundException) { throw new Exception($"Неопределённая переменная \"{key}\""); } }
private static Constant Print(List <Constant> args) { string result = ""; try { foreach (var arg in args) { result += (arg as StringValue).Value; } } catch (TypeConversionError err) { throw new Exception($"Невозможно преобразовать аргумент в функции \"print\" из \"{err.Src}\" в \"{err.Dst}\""); } ModelInterpreter.GetInstanse().AddOutput(result); return(new VoidValue()); }