public LocateCommand(TLine pl, NBInterpreter i) : base(pl, i) { KwLocate loc = (KwLocate)pl.Statement; _x = (IValue <double>)Interpreter.Make(pl.Clone(loc.X)); _y = (IValue <double>)Interpreter.Make(pl.Clone(loc.Y)); }
public BaseBinaryOperator(TLine line, NBInterpreter i) : base(line, i) { BinaryOperator sb = (BinaryOperator)line.Statement; Statement left = sb.Left; Statement right = sb.Right; _left = (IValue <T2>)Interpreter.Make(line.Clone(left)); _right = (IValue <T2>)Interpreter.Make(line.Clone(right)); }
public JumpIfNotTrueCommand(TLine pg, NBInterpreter i) : base(pg, i, -1) { var jmp = (KwrJumpIfNotTrue)pg.Statement; _condition = (IValue <bool>)Interpreter.Make(pg.Clone(jmp.Condition)); JumpPos = jmp.JumpPos; }
public PrintCommand(TLine pl, NBInterpreter i) : base(pl, i) { var print = (KwrPrint)pl.Statement; _value = (IValue)Interpreter.Make(pl.Clone(print.Statement)); _printLine = print.NewLine; }
public ReadCommand(TLine line, NBInterpreter i) : base(line, i) { KwRead read = (KwRead)line.Statement; if (read.Variable is NumVariable || read.Variable is NumArray) { IVariable <double> doubleVar = (IVariable <double>)Interpreter.Make(line.Clone((Statement)read.Variable)); _worker = c => { string next = Interpreter.ReadNextString(); if (next == null) { throw new InterpreterException(line, "READ overflow! Variable: " + doubleVar.Name); } double val; if (!double.TryParse(next, out val)) { throw new InterpreterException(line, "READ error! Variable: " + doubleVar.Name + " value: " + next); } doubleVar.Execute(c); doubleVar.SetValue(val); _read = val.ToString(); return(InterpreterStatus.Ok); }; } else { IVariable <string> stringVar = (IVariable <string>)Interpreter.Make(line.Clone((Statement)read.Variable)); _worker = c => { string next = Interpreter.ReadNextString(); if (next == null) { throw new InterpreterException(line, "READ overflow! Variable: " + stringVar.Name); } stringVar.Execute(c); stringVar.SetValue(next); _read = next; return(InterpreterStatus.Ok); }; } }
public PauseCommand(TLine pl, NBInterpreter i) : base(pl, i) { KwPause pause = (KwPause)pl.Statement; if (pause != null) { _interval = (IValue <double>)Interpreter.Make(pl.Clone(pause.Interval)); } }
public RandomizeCommand(TLine pl, NBInterpreter i) : base(pl, i) { KwRandomize rnd = (KwRandomize)pl.Statement; if (rnd.Statement != null) { _seed = (IValue <double>)Interpreter.Make(pl.Clone(rnd.Statement)); } }
public ArrayVariable(TLine pl, NBInterpreter i, Func <Statement, string> nameGetter) : base(pl, i) { Name = nameGetter(pl.Statement); VariableArray va = (VariableArray)pl.Statement; foreach (var dimension in va.Dimensions) { var coordinate = (IValue <double>)Interpreter.Make(pl.Clone(dimension)); _coordinates.Add(coordinate); } }
public InputCommand(TLine pg, NBInterpreter interpreter) : base(pg, interpreter) { string prompt = null; bool questionMark = true; KwInput i = (KwInput)pg.Statement; if (i.Prompt != null) { prompt = i.Prompt.Value; } if (i.Separator.HasValue && i.Separator.Value == ',') { questionMark = false; } _varName = i.Variable.Name; if (i.Variable is NumVariable || i.Variable is NumArray) { IVariable <double> variable = (IVariable <double>)Interpreter.Make(pg.Clone((Statement)i.Variable)); _worker = context => { variable.Execute(context); variable.SetValue(BNLib.InputDouble(context, prompt, questionMark)); }; } else { IVariable <string> variable = (IVariable <string>)Interpreter.Make(pg.Clone((Statement)i.Variable)); _worker = context => { variable.Execute(context); variable.SetValue(BNLib.InputString(context, prompt, questionMark)); }; } }
public UnaryOperator(TLine pl, NBInterpreter i, Func <Statement, Statement> getter, Func <T, T> worker) : base(pl, i) { _value = (IValue <T>)Interpreter.Make(pl.Clone(getter(pl.Statement))); _worker = worker; }
public RndCommand(TLine pl, NBInterpreter i) : base(pl, i) { _maxValue = (IValue <double>)Interpreter.Make(pl.Clone(((Function1)pl.Statement).Param1)); }