예제 #1
0
    /**
     * @brief Checks if text is a global command that
     *        would affect the entire simulator.
     * @param text - The text to be checked.
     * @returns 'true' if the text is recognised as a
     *          global command.
     */
    public bool CheckForGlobalCommand(string text)
    {
        string[] content        = text.Split(' ');
        string   command        = content[0];
        string   additionalData = null;

        if (content.Length > 1)
        {
            additionalData = content[1];
        }

        switch (command)
        {
        case ("\\FETCH"):
            LogCommand(text);
            StartCoroutine(CU.FetchCycle());
            return(true);

        case ("\\DECODE"):
            LogCommand(text);
            StartCoroutine(CU.DecodeCycle());
            return(true);

        case ("\\EXECUTE"):
            LogCommand(text);
            StartCoroutine(CU.ExecuteCycle());
            return(true);

        case ("\\RESET"):
            LogCommand(text);
            CU.Reset();
            return(true);

        case ("\\RUN"):
            if (CU.IsRunning())
            {
                CONSOLE.LogError("CU is already running.");
            }
            else
            {
                LogCommand(text);
                StartCoroutine(CU.RunCycle());
            }
            return(true);

        case ("\\ASSEMBLE"):
            LogCommand(text);
            textEditor.Assemble();
            return(true);

        case ("\\LOAD"):
            LogCommand(text);
            textEditor.LoadIntoMemory();
            return(true);
        }
        return(false);
    }