Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
 public void Run(ISplRuntime runtime)
 {
     runtime.Stopped = false;
     while (!runtime.Stopped) {
         StepOver (runtime);
     }
 }
Exemplo n.º 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];
            }
        }
Exemplo n.º 5
0
 public void Run(ISplRuntime runtime)
 {
     runtime.Stopped = false;
     while (!runtime.Stopped)
     {
         StepOver(runtime);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 17
0
 public void Execute(ISplRuntime runtime)
 {
 }
Exemplo n.º 18
0
 public void Execute(ISplRuntime runtime)
 {
 }