public void Execute(ISplRuntime runtime) { if (Parameter.Value >= runtime.Memory.Length) { runtime.ShowErrorMessage("Error: Memory Index Out Of Bounds"); runtime.Stopped = true; } if (runtime.Current == null) { runtime.ShowErrorMessage("Error: NULL Value In Current"); runtime.Stopped = true; } if (Parameter.IsPointer) { int pointTo = Convert.ToInt32(runtime.Memory[Parameter.Value]); if (pointTo >= runtime.Memory.Length) { runtime.ShowErrorMessage("Error: Memory Index Out Of Bounds"); runtime.Stopped = true; return; } runtime.Memory[pointTo] = runtime.Current; } else { runtime.Memory[Parameter.Value] = runtime.Current; } }
private bool ReadFromInput(ISplRuntime runtime, out int i) { char stuffRead = (char)runtime.Input.Peek(); if (stuffRead == ' ') { i = 0; runtime.Input.Read(); return(true); } if (char.IsNumber(stuffRead)) { string numberString = ""; while (char.IsNumber(stuffRead)) { stuffRead = (char)runtime.Input.Read(); numberString += stuffRead; } i = Convert.ToInt32(numberString.Replace(unchecked ((char)-1), ' ').Trim()); return(true); } else { i = 0; return(false); } }
public void Run(ISplRuntime runtime) { runtime.Stopped = false; while (!runtime.Stopped) { StepOver (runtime); } }
public void Execute(ISplRuntime runtime) { if (Parameter.Value >= runtime.Memory.Length) { runtime.ShowErrorMessage ("Error: Memory Index Out Of Bounds"); runtime.Stopped = true; } if (runtime.Memory[Parameter.Value] == null) { runtime.ShowErrorMessage ("Error: NULL Value In Memory"); runtime.Stopped = true; } if (Parameter.IsPointer) { int pointTo = Convert.ToInt32 (runtime.Memory[Parameter.Value]); if (pointTo >= runtime.Memory.Length) { runtime.ShowErrorMessage ("Error: Memory Index Out Of Bounds"); runtime.Stopped = true; return; } if (runtime.Memory[pointTo] == null) { runtime.ShowErrorMessage ("Error: NULL Value In Memory"); runtime.Stopped = true; return; } runtime.Current = runtime.Memory[pointTo]; } else { runtime.Current = runtime.Memory[Parameter.Value]; } }
public void Run(ISplRuntime runtime) { runtime.Stopped = false; while (!runtime.Stopped) { StepOver(runtime); } }
public void Execute(ISplRuntime runtime) { if (Parameter1 >= runtime.Memory.Length) { runtime.ShowErrorMessage ("Error: Memory Index Out Of Bounds"); runtime.Stopped = true; return; } runtime.Memory[Parameter1] = Parameter2; }
public void Execute(ISplRuntime runtime) { if (Parameter1 >= runtime.Memory.Length) { runtime.ShowErrorMessage("Error: Memory Index Out Of Bounds"); runtime.Stopped = true; return; } runtime.Memory[Parameter1] = Parameter2; }
/// <summary> /// Reads a character from the runtime input. /// </summary> /// <param name="runtime">The provided runtime for providing input</param> /// <param name="c">The character read</param> /// <returns>True if the method successfully reads a character, false otherwise</returns> private bool ReadFromInput(ISplRuntime runtime, out char c) { char stuffRead = (char)runtime.Input.Peek (); if (char.IsLetter (stuffRead)) { c = (char)runtime.Input.Read (); return true; } /*else if (stuffRead == 65535) { }*/ else { c = '\0'; return false; } }
public void Execute(ISplRuntime runtime) { if (runtime.Current == null) { runtime.ShowErrorMessage ("Error: NULL Value Used"); runtime.Stopped = true; return; } if (runtime.Current is int) { runtime.Output.Write (runtime.Current + " "); } else { runtime.Output.Write (runtime.Current); } runtime.Current = null; }
public void Execute(ISplRuntime runtime) { char c; int i; if (ReadFromInput (runtime, out c)) { runtime.Current = c; } else if (ReadFromInput (runtime, out i)) { runtime.Current = i; } else if (runtime.Input.Peek() == -1) { runtime.Stopped = true; } else { runtime.ShowErrorMessage ("Error: Input Invalid"); runtime.Stopped = true; } }
/// <summary> /// Reads a character from the runtime input. /// </summary> /// <param name="runtime">The provided runtime for providing input</param> /// <param name="c">The character read</param> /// <returns>True if the method successfully reads a character, false otherwise</returns> private bool ReadFromInput(ISplRuntime runtime, out char c) { char stuffRead = (char)runtime.Input.Peek(); if (char.IsLetter(stuffRead)) { c = (char)runtime.Input.Read(); return(true); } /*else if (stuffRead == 65535) { * * }*/ else { c = '\0'; return(false); } }
public void Execute(ISplRuntime runtime) { if (runtime.Current == null) { runtime.ShowErrorMessage("Error: NULL Value Used"); runtime.Stopped = true; return; } if (runtime.Current is int) { runtime.Output.Write(runtime.Current + " "); } else { runtime.Output.Write(runtime.Current); } runtime.Current = null; }
public void StepOver(ISplRuntime runtime) { if (runtime.Stopped) return; try { CurrentCommand.Execute (runtime); if (CurrentCommand is IGotoCommand) { IGotoCommand gotoCommand = CurrentCommand as IGotoCommand; if (gotoCommand.GotoCondition (runtime)) { CurrentLineNumber = gotoCommand.JumpTo.LineNumber - 1; return; } } CurrentLineNumber++; } catch (IndexOutOfRangeException) { runtime.Stopped = true; } }
private bool ReadFromInput(ISplRuntime runtime, out int i) { char stuffRead = (char)runtime.Input.Peek (); if (stuffRead == ' ') { i = 0; runtime.Input.Read (); return true; } if (char.IsNumber (stuffRead)) { string numberString = ""; while (char.IsNumber (stuffRead)) { stuffRead = (char)runtime.Input.Read (); numberString += stuffRead; } i = Convert.ToInt32 (numberString.Replace(unchecked((char)-1), ' ').Trim()); return true; } else { i = 0; return false; } }
public void Execute(ISplRuntime runtime) { char c; int i; if (ReadFromInput(runtime, out c)) { runtime.Current = c; } else if (ReadFromInput(runtime, out i)) { runtime.Current = i; } else if (runtime.Input.Peek() == -1) { runtime.Stopped = true; } else { runtime.ShowErrorMessage("Error: Input Invalid"); runtime.Stopped = true; } }
public void StepOver(ISplRuntime runtime) { if (runtime.Stopped) { return; } try { CurrentCommand.Execute(runtime); if (CurrentCommand is IGotoCommand) { IGotoCommand gotoCommand = CurrentCommand as IGotoCommand; if (gotoCommand.GotoCondition(runtime)) { CurrentLineNumber = gotoCommand.JumpTo.LineNumber - 1; return; } } CurrentLineNumber++; } catch (IndexOutOfRangeException) { runtime.Stopped = true; } }
public void Execute(ISplRuntime runtime) { }