Exemplo n.º 1
0
 public override void Update(float time)
 {
     try
     {
         base.Update(time);
         EvaluateNextCommand();
     }
     catch (kOSException e)
     {
         if (ParentContext.FindClosestParentOfType <ContextRunProgram>() != null)
         {
             // Error occurs in a child of another running program
             StdOut("Error in '" + e.Program.Filename + "' on line " + e.LineNumber + ": " + e.Message);
             State = ExecutionState.DONE;
             return;
         }
         else
         {
             // Error occurs in the top level program
             StdOut("Error on line " + e.LineNumber + ": " + e.Message);
             State = ExecutionState.DONE;
             return;
         }
     }
     catch (Exception e)
     {
         // Non-kos exception! This is a bug, but no reason to kill the OS
         StdOut("Flagrant error on line " + executionLine);
         UnityEngine.Debug.Log("Program error");
         UnityEngine.Debug.Log(e);
         State = ExecutionState.DONE;
         return;
     }
 }
Exemplo n.º 2
0
        public T FindClosestParentOfType <T>() where T : class, IExecutionContext
        {
            var casted = this as T;

            if (casted != null)
            {
                return(casted);
            }

            return(ParentContext == null ? null : ParentContext.FindClosestParentOfType <T>());
        }
Exemplo n.º 3
0
        private void RunBlock(List <String> block)
        {
            foreach (String rawLine in block)
            {
                String line = stripComment(rawLine);
                commandBuffer += line + "\n";
            }

            string cmd;
            int    lineNumber       = 0;
            int    commandLineStart = 0;

            while (parseNext(ref commandBuffer, out cmd, ref lineNumber, out commandLineStart))
            {
                try
                {
                    Line = commandLineStart;
                    Command cmdObj = Command.Get(cmd, this, commandLineStart);
                    commands.Add(cmdObj);
                }
                catch (kOSException e)
                {
                    if (ParentContext.FindClosestParentOfType <ContextRunProgram>() != null)
                    {
                        // Error occurs in a child of another running program
                        StdOut("Error in '" + e.Program.Filename + "' on line " + e.LineNumber + ": " + e.Message);
                        State = ExecutionState.DONE;
                        return;
                    }
                    else
                    {
                        // Error occurs in the top level program
                        StdOut("Error on line " + e.LineNumber + ": " + e.Message);
                        State = ExecutionState.DONE;
                        return;
                    }
                }
                catch (Exception e)
                {
                    // Non-kos exception! This is a bug, but no reason to kill the OS
                    StdOut("Flagrant error on line " + lineNumber);
                    UnityEngine.Debug.Log("Program error");
                    UnityEngine.Debug.Log(e);
                    State = ExecutionState.DONE;
                    return;
                }
            }

            if (commandBuffer.Trim() != "")
            {
                StdOut("End of file reached inside unterminated statement");
                State = ExecutionState.DONE;
            }
        }
Exemplo n.º 4
0
 public override void Update(float time)
 {
     try
     {
         base.Update(time);
         if (SelectedVolume.CheckRange())
         {
             EvaluateNextCommand();
             signalLossWarning = false;
         }
         else
         if (!signalLossWarning)
         {
             StdOut("Selected Volume has gone out of range.");
             signalLossWarning = true;
         }
     }
     catch (KOSException e)
     {
         if (ParentContext.FindClosestParentOfType <IContextRunProgram>() != null)
         {
             // Error occurs in a child of another running program
             StdOut("Error in '" + e.Program.Filename + "' on line " + e.LineNumber + ": " + e.Message);
             State = ExecutionState.DONE;
         }
         else
         {
             // Error occurs in the top level program
             StdOut("Error on line " + e.LineNumber + ": " + e.Message);
             State = ExecutionState.DONE;
         }
     }
     catch (Exception e)
     {
         // Non-kos exception! This is a bug, but no reason to kill the OS
         StdOut("Flagrant error on line " + EXECUTION_LINE);
         UnityEngine.Debug.Log("Program error");
         UnityEngine.Debug.Log(e);
         State = ExecutionState.DONE;
     }
 }