예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 public void Run(ISplRuntime runtime)
 {
     runtime.Stopped = false;
     while (!runtime.Stopped) {
         StepOver (runtime);
     }
 }
예제 #4
0
        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];
            }
        }
예제 #5
0
 public void Run(ISplRuntime runtime)
 {
     runtime.Stopped = false;
     while (!runtime.Stopped)
     {
         StepOver(runtime);
     }
 }
예제 #6
0
 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;
 }
예제 #7
0
 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;
 }
예제 #8
0
        /// <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;
            }
        }
예제 #9
0
 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;
 }
예제 #10
0
 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;
     }
 }
예제 #11
0
        /// <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);
            }
        }
예제 #12
0
 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;
 }
예제 #13
0
        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;
            }
        }
예제 #14
0
        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;
            }
        }
예제 #15
0
        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;
            }
        }
예제 #16
0
        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;
            }
        }
예제 #17
0
 public void Execute(ISplRuntime runtime)
 {
 }
예제 #18
0
 public void Execute(ISplRuntime runtime)
 {
 }