Exemplo n.º 1
0
        private SystemExecutionState ExecuteLine(string line, ImlacSystem system)
        {
            SystemExecutionState next = SystemExecutionState.Debugging;

            if (line.StartsWith("#"))
            {
                // Comments start with "#", just ignore them
            }
            else if (line.StartsWith("@"))
            {
                // A line beginning with an "@" indicates a script to execute.
                string scriptFile = line.Substring(1);

                next = ExecuteScript(system, scriptFile);
            }
            else
            {
                string[]        args    = null;
                DebuggerCommand command = GetDebuggerCommandFromCommandString(line, out args);

                if (command == null)
                {
                    // Not a command.
                    Console.WriteLine("Invalid command.");
                }
                else
                {
                    next = InvokeConsoleMethod(command, args, system);
                }
            }

            return(next);
        }
Exemplo n.º 2
0
        public SystemExecutionState Prompt(ImlacSystem system)
        {
            SystemExecutionState next = SystemExecutionState.Debugging;

            try
            {
                system.PrintProcessorStatus();

                // Get the command string from the prompt.
                string command = _consolePrompt.Prompt().Trim();

                if (string.IsNullOrEmpty(command))
                {
                    // Repeat the last command
                    command = _lastCommand;
                    Console.WriteLine(">> {0}", command);
                }

                next = ExecuteLine(command, system);

                _lastCommand = command;
            }
            catch (Exception e)
            {
                Console.WriteLine(
                    "Error: {0}",
                    e.InnerException != null ? e.InnerException.Message : e.Message);
            }

            return(next);
        }
Exemplo n.º 3
0
        public SystemExecutionState ExecuteScript(ImlacSystem system, string scriptFile)
        {
            SystemExecutionState state = SystemExecutionState.Halted;

            using (StreamReader sr = new StreamReader(scriptFile))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();

                    if (!string.IsNullOrWhiteSpace(line))
                    {
                        Console.WriteLine(line);
                        state = ExecuteLine(line, system);
                    }
                }
            }

            return(state);
        }