コード例 #1
0
 public void Run(ICommandInteraction writer, PathToken path)
 {
     if (IncludeCommand.Run(writer, path))
     {
         EmulationManager.Instance.CurrentEmulation.StartAll();
     }
 }
コード例 #2
0
ファイル: StartCommand.cs プロジェクト: rte-se/emul8
 public void Run(ICommandInteraction writer, PathToken path)
 {
     if(IncludeCommand.Run(writer, path))
     {
         EmulationManager.Instance.CurrentEmulation.StartAll();
     }
 }
コード例 #3
0
ファイル: SetCommand.cs プロジェクト: rte-se/emul8
 public void Run(ICommandInteraction writer, LiteralToken variable, Token value)
 {
     var varName = variable.Value;
    
     varName = GetVariableName(varName);
     SetVariable(varName, value);
 }
コード例 #4
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine("- to trace only function call with a registered handler:");
     writer.WriteLine("{0} {1} cpuName \"functionName\"".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine();
     writer.WriteLine("- to trace function call and returned value with a registered handler:");
     writer.WriteLine("{0} {1} cpuName \"functionName\" true".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine();
     writer.WriteLine("- to trace function call without a handler, with or without return value:");
     writer.WriteLine("{0} {1} cpuName \"functionName\" [true|false] [number of parameters]".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine();
     writer.WriteLine("- to trace function call without a handler, with or without return value, with specified variable types:");
     writer.WriteLine("{0} {1} cpuName \"functionName\" [true|false] [list of parameter types]".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine("(Note, that if return value is expected, the last parameter type must relate to return value.");
     writer.WriteLine();
     writer.WriteLine("- to disable tracing of a function:");
     writer.WriteLine("{0} {1} cpuName \"functionName\"".FormatWith(Name, TraceDisableCommand));
     writer.WriteLine();
     writer.WriteLine("Handlers available for functions:");
     writer.WriteLine(handlers.Keys.Select(x => "- " + x).Stringify("\r\n"));
     writer.WriteLine();
     writer.WriteLine("Possible values for parameter types:");
     writer.WriteLine(Enum.GetNames(typeof(FunctionCallParameterType)).Where(x => !x.Contains("Array")).Select(x => "- " + x).Stringify("\r\n"));
 }
コード例 #5
0
 public void Run(ICommandInteraction writer, [Values("Noisy", "Debug", "Info", "Warning", "Error")] StringToken level, LiteralToken backendName, LiteralToken peripheralName)
 {
     if (!SetLogLevel(LogLevel.Parse(level.Value), backendName.Value, peripheralName.Value))
     {
         writer.WriteError(string.Format("Could not find emulation element or backend"));
     }
 }
コード例 #6
0
        public void Run(ICommandInteraction writer)
        {
            var currentMachine = GetCurrentMachine();

            if (currentMachine == null)
            {
                writer.WriteError("Select active machine.");
                return;
            }
            writer.WriteLine("Available peripherals:");
            writer.WriteLine();

            var peripheralEntries = currentMachine.GetPeripheralsWithAllRegistrationPoints();
            var sysbusEntry       = peripheralEntries.First(x => x.Key.Name == Machine.SystemBusName);
            var sysbusNode        = new PeripheralNode(sysbusEntry);
            var nodeQueue         = new Queue <PeripheralNode>(peripheralEntries.Where(x => x.Key != sysbusEntry.Key).Select(x => new PeripheralNode(x)));

            while (nodeQueue.Count > 0)
            {
                var x = nodeQueue.Dequeue();
                // Adding nodes to sysbusNode is successful only if the current node's parent was already added.
                // This code effectively sorts the nodes topologically.
                if (!sysbusNode.AddChild(x))
                {
                    nodeQueue.Enqueue(x);
                }
            }
            sysbusNode.PrintTree(writer);
        }
コード例 #7
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine(String.Format("{0} <<message to log>> <<log level>>", Name));
 }
コード例 #8
0
        public void Run(ICommandInteraction writer, StringToken command, DecimalIntegerToken delay)
        {
            var terminal = writer as CommandInteraction;

            if (terminal == null)
            {
                writer.WriteError("Watch command can be used on a full-featured terminal only");
                return;
            }

            var eater = new CommandInteractionEater();

            while (!terminal.HasNewInput)
            {
                terminal.SaveCursor();
                monitor.Parse(command.Value, eater);

                writer.Write(eater.GetContents());
                var error = eater.GetError();
                if (error.Length > 0)
                {
                    writer.WriteError(error);
                    break;
                }
                eater.Clear();

                System.Threading.Thread.Sleep((int)delay.Value);
                terminal.RestoreCursor();
                terminal.ClearToEnd();
            }
        }
コード例 #9
0
            public void PrintTree(ICommandInteraction writer, TreeViewBlock[] pattern = null)
            {
                if (pattern == null)
                {
                    pattern = new TreeViewBlock[0];
                }
                var indent = GetIndentString(pattern);

                writer.WriteLine(String.Format("{0}{1} ({2})", indent, PeripheralEntry.Name, PeripheralEntry.Type.Name));

                if (PeripheralEntry.Parent != null)
                {
                    var newIndent = GetIndentString(UpdatePattern(pattern, Children.Count > 0 ? TreeViewBlock.Straight : TreeViewBlock.Empty));
                    if (!(PeripheralEntry.RegistrationPoint is ITheOnlyPossibleRegistrationPoint))
                    {
                        foreach (var registerPlace in RegistrationPoints)
                        {
                            writer.WriteLine(String.Format("{0}{1}", newIndent, registerPlace.PrettyString));
                        }
                    }
                    writer.WriteLine(newIndent);
                }
                else
                {
                    writer.WriteLine(GetIndentString(new TreeViewBlock[] { TreeViewBlock.Straight }));
                }

                var lastChild = Children.LastOrDefault();

                foreach (var child in Children)
                {
                    child.PrintTree(writer, UpdatePattern(pattern, child != lastChild ? TreeViewBlock.Full : TreeViewBlock.End));
                }
            }
コード例 #10
0
        public bool ExecuteBuiltinCommand(Token[] command, ICommandInteraction writer)
        {
            var command_name = ((LiteralToken)command[0]).Value;

            if (!Scope.ContainsVariable("mc_" + command_name))
            {
                return(false);
            }

            object comm       = Scope.GetVariable("mc_" + command_name); // get a method
            var    parameters = command.Skip(1).Select(x => x.GetObjectValue()).ToArray();

            ConfigureOutput(writer);

            try
            {
                var result = Engine.Operations.Invoke(comm, parameters);
                if (result != null && (!(result is bool) || !(bool)result))
                {
                    writer.WriteError(String.Format("Command {0} failed, returning \"{1}\".", command_name, result));
                }
            }
            catch (Exception e)
            {
                throw new RecoverableException(e);
            }
            return(true);
        }
コード例 #11
0
        public override void PrintHelp(ICommandInteraction writer)
        {
            base.PrintHelp(writer);

            writer.WriteLine("\nUsage:");
            writer.WriteLine("watch \"<command>\" <refresh period in ms>");
        }
コード例 #12
0
        public void Run(ICommandInteraction writer)
        {
            var output = $"Current virtual time: {EmulationManager.Instance.CurrentEmulation.MasterTimeSource.ElapsedVirtualTime}\nCurrent real time: {EmulationManager.Instance.CurrentEmulation.MasterTimeSource.ElapsedHostTime}";

            writer.WriteLine(output);
            Logger.LogAs(monitor, LogLevel.Info, output);
        }
コード例 #13
0
        public bool Run(ICommandInteraction writer, PathToken path)
        {
            if (!File.Exists(path.Value))
            {
                writer.WriteError(String.Format("No such file {0}.", path.Value));
                return(false);
            }

            using (var progress = EmulationManager.Instance.ProgressMonitor.Start("Including script: " + path.Value))
            {
                bool result = false;
                switch (Path.GetExtension(path.Value))
                {
                case ".py":
                    result = PythonExecutor(path.Value, writer);
                    break;

                case ".cs":
                    result = CsharpExecutor(path.Value, writer);
                    break;

                default:
                    result = ScriptExecutor(path.Value);
                    break;
                }

                return(result);
            }
        }
コード例 #14
0
ファイル: HelloCommand.cs プロジェクト: rte-se/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine(String.Format("{0} \"name\"", Name));
 }
コード例 #15
0
ファイル: MachCommand.cs プロジェクト: krytarowski/emul8
        public void Run(ICommandInteraction writer, [Values("set", "add", "rem")] LiteralToken action, StringToken name)
        {
            switch (action.Value)
            {
            case "add":
                var machine = new Machine();
                EmulationManager.Instance.CurrentEmulation.AddMachine(machine, name.Value);
                if (GetCurrentMachine() == null)
                {
                    SetCurrentMachine(machine);
                }
                break;

            case "set":
                try
                {
                    SetCurrentMachine(EmulationManager.Instance.CurrentEmulation[name.Value]);
                }
                catch (KeyNotFoundException)
                {
                    writer.WriteError(string.Format("Machine {0} not found.", name.Value));
                }
                break;

            case "rem":
                var machineToRemove = EmulationManager.Instance.CurrentEmulation[name.Value];
                EmulationManager.Instance.CurrentEmulation.RemoveMachine(name.Value);
                if (GetCurrentMachine() == machineToRemove)
                {
                    SetCurrentMachine(null);
                }
                break;
            }
        }
コード例 #16
0
ファイル: IncludeFileCommand.cs プロジェクト: rte-se/emul8
        public bool Run(ICommandInteraction writer, PathToken path)
        {
            if(!File.Exists(path.Value))
            {
                writer.WriteError(String.Format("No such file {0}.", path.Value));
                return false;
            }

            using(var progress = EmulationManager.Instance.ProgressMonitor.Start("Including script: " + path.Value))
            {
                bool result = false;
                switch(Path.GetExtension(path.Value))
                {
                case ".py":
                    result = PythonExecutor(path.Value, writer);
                    break;
                case ".cs":
                    result = CsharpExecutor(path.Value, writer);
                    break;
                default:
                    result = ScriptExecutor(path.Value);
                    break;
                }

                return result;
            }
        }
コード例 #17
0
        public void Run(ICommandInteraction writer, LiteralToken peripheralName)
        {
            var         emu = EmulationManager.Instance.CurrentEmulation;
            IPeripheral p;

            try
            {
                p = (IPeripheral)monitor.ConvertValueOrThrowRecoverable(peripheralName.Value, typeof(IPeripheral));
            }
            catch (RecoverableException)
            {
                writer.WriteError(string.Format("Peripheral not found: {0}", peripheralName.Value));
                return;
            }

            IAnalyzableBackend backend;

            if (!emu.BackendManager.TryGetBackendFor(p, out backend))
            {
                writer.WriteError(string.Format("No backend found for {0}", peripheralName.Value));
                return;
            }

            var def = emu.BackendManager.GetPreferredAnalyzerFor(backend);

            foreach (var a in emu.BackendManager.GetAvailableAnalyzersFor(backend))
            {
                writer.WriteLine(String.Format("{0}{1}", a, a == def ? " (default)" : String.Empty));
            }
        }
コード例 #18
0
ファイル: AnalyzersCommand.cs プロジェクト: rasomc/emul8
        public void Run(ICommandInteraction writer, [Values("default")] LiteralToken @default, LiteralToken peripheralName)
        {
            var         emu = EmulationManager.Instance.CurrentEmulation;
            IPeripheral p;
            string      fake;

            var m = monitor.Machine;

            if (m == null || !m.TryGetByName(peripheralName.Value, out p, out fake))
            {
                writer.WriteError(string.Format("Peripheral not found: {0}", peripheralName.Value));
                return;
            }

            IAnalyzableBackend backend;

            if (!emu.BackendManager.TryGetBackendFor(p, out backend))
            {
                writer.WriteError(string.Format("No backend found for {0}", peripheralName.Value));
                return;
            }

            var def = emu.BackendManager.GetPreferredAnalyzerFor(backend);

            writer.WriteLine(def ?? "No default analyzer found.");
        }
コード例 #19
0
        private void PrintLastLogs(ICommandInteraction writer, int numberOfEntries = DefaultNumberOfEntries)
        {
            if (numberOfEntries > MemoryBackend.MaxCount)
            {
                throw new RecoverableException($"The number of entries cannot be larger than {MemoryBackend.MaxCount}");
            }

            if (!Logger.GetBackends().TryGetValue(MemoryBackend.Name, out var backend))
            {
                throw new RecoverableException("Could not get memory backend");
            }

            var memoryBackend = backend as MemoryBackend;

            if (memoryBackend == null)
            {
                throw new RecoverableException("Memory backend of unexpected type");
            }

            foreach (var entry in ((MemoryBackend)memoryBackend).GetMemoryLogEntries(numberOfEntries))
            {
                var count = entry.Count > 1 ? $"({entry.Count})" : string.Empty;
                writer.WriteLine($"{entry.DateTime:HH:mm:ss.ffff} [{entry.Type}] {entry.Message} {count}", entry.Type.Color);
            }
        }
コード例 #20
0
 public void Run(ICommandInteraction writer)
 {
     writer.WriteLine("Renode is quitting", ConsoleColor.Green);
     SetCurrentMachine(null);
     Quitted?.Invoke()?.Invoke();
     writer.QuitEnvironment = true;
 }
コード例 #21
0
ファイル: MachCommand.cs プロジェクト: rte-se/emul8
 public void Run(ICommandInteraction writer, [Values("set", "add", "rem")] LiteralToken action, StringToken name)
 {
     switch(action.Value)
     {
     case "add":       
         var machine = new Machine();
         EmulationManager.Instance.CurrentEmulation.AddMachine(machine, name.Value);
         if(GetCurrentMachine() == null)
         {
             SetCurrentMachine(machine);
         }
         break;
     case "set":
         try
         {
             SetCurrentMachine(EmulationManager.Instance.CurrentEmulation[name.Value]);
         }
         catch(KeyNotFoundException)
         {
             writer.WriteError(string.Format("Machine {0} not found.", name.Value));
         }
         break;
     case "rem":
         var machineToRemove = EmulationManager.Instance.CurrentEmulation[name.Value];
         EmulationManager.Instance.CurrentEmulation.RemoveMachine(name.Value);
         if(GetCurrentMachine() == machineToRemove)
         {
             SetCurrentMachine(null);
         }
         break;
     }
 }
コード例 #22
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine(String.Format("{0} \"name\"", Name));
 }
コード例 #23
0
        public bool TryExecutePythonScript(string fileName, ICommandInteraction writer)
        {
            var script = Engine.CreateScriptSourceFromFile(fileName);

            ExecutePythonScriptInner(script, writer);
            return(true);
        }
コード例 #24
0
ファイル: MachCommand.cs プロジェクト: AntonKrug/emul8-modded
        public override void PrintHelp(ICommandInteraction writer)
        {
            base.PrintHelp(writer);
            writer.WriteLine();
            var currentMachine = GetCurrentMachine();

            if (currentMachine == null)
            {
                writer.WriteError("No machine selected.");
            }
            else
            {
                writer.WriteLine(string.Format("Current machine: {0}", EmulationManager.Instance.CurrentEmulation[currentMachine]));
            }
            if (EmulationManager.Instance.CurrentEmulation.MachinesCount > 0)
            {
                writer.WriteLine("Available machines:");
                var emu = EmulationManager.Instance.CurrentEmulation;
                var longestNameLength = emu.Machines.Max(m => emu[m].Length);
                var i = 0;
                foreach (var machine in emu.Machines)
                {
                    writer.WriteLine(string.Format("\t{2}: {0,-" + longestNameLength + "} {1}", emu[machine], machine.Platform != null ? string.Format("[{0}]", machine.Platform.Name) : string.Empty, i++));
                }
            }
            writer.WriteLine();
            writer.WriteLine("You can use the following commands:");
            writer.WriteLine("'mach set [\"name\"|number]'\tto enable the given machine");
            writer.WriteLine("'mach add \"name\"'\tto create a new machine with the specified name");
            writer.WriteLine("'mach rem \"name\"'\tto remove a machine");
            writer.WriteLine("'mach create'\tto create a new machine with generic name and switch to it");
            writer.WriteLine("'mach clear'\tto clear the current selection");
        }
コード例 #25
0
        public void Run(ICommandInteraction writer, [Values(TraceEnableCommand)] LiteralToken enable, LiteralToken cpuToken, StringToken functionName, BooleanToken traceReturn, params LiteralToken[] types)
        {
            var cpu       = (Arm)monitor.ConvertValueOrThrowRecoverable(cpuToken.Value, typeof(Arm));
            var cpuTracer = EnsureTracer(cpu);
            var handler   = new DefaultFunctionHandler(cpu);
            var paramList = new List <FunctionCallParameter>();

            foreach (var parameter in types)
            {
                FunctionCallParameterType paramType;
                if (!Enum.TryParse(parameter.Value, out paramType))
                {
                    throw new RecoverableException("{0} is not a proper parameter type.".FormatWith(parameter.Value));
                }
                paramList.Add(new FunctionCallParameter {
                    Type = paramType
                });
            }
            handler.CallParameters  = paramList.Take(paramList.Count - (traceReturn.Value ? 1 : 0));
            handler.ReturnParameter = traceReturn.Value ? paramList.Last() : (FunctionCallParameter?)null;
            if (traceReturn.Value)
            {
                cpuTracer.TraceFunction(functionName.Value, handler.CallParameters, handler.CallHandler, handler.ReturnParameter, handler.ReturnHandler);
            }
            else
            {
                cpuTracer.TraceFunction(functionName.Value, handler.CallParameters, handler.CallHandler);
            }
        }
コード例 #26
0
ファイル: AnalyzersCommand.cs プロジェクト: rte-se/emul8
        public void Run(ICommandInteraction writer, LiteralToken peripheralName)
        {
            var emu = EmulationManager.Instance.CurrentEmulation;
            IPeripheral p;
            string fake;

            var m = monitor.Machine;
            if(m == null || !m.TryGetByName(peripheralName.Value, out p, out fake))
            {
                writer.WriteError(string.Format("Peripheral not found: {0}", peripheralName.Value));
                return;
            }

            IAnalyzableBackend backend;
            if(!emu.BackendManager.TryGetBackendFor(p, out backend))
            {
                writer.WriteError(string.Format("No backend found for {0}", peripheralName.Value));
                return;
            }

            foreach(var a in emu.BackendManager.GetAvailableAnalyzersFor(backend))
            {
                writer.WriteLine(a);
            }
        }
コード例 #27
0
 public void Run(ICommandInteraction writer, [Values(-1L, 0L, 1L, 2L, 3L)] DecimalIntegerToken level, LiteralToken backendName, LiteralToken peripheralName)
 {
     if (!SetLogLevel((LogLevel)level.Value, backendName.Value, peripheralName.Value))
     {
         writer.WriteError(string.Format("Could not find emulation element or backend"));
     }
 }
コード例 #28
0
 public void Run(ICommandInteraction writer, [Values(-1L, 0L, 1L, 2L, 3L)] NumericToken level, LiteralToken backendName, LiteralToken peripheralName)
 {
     if(!SetLogLevel((LogLevel)level.Value, backendName.Value, peripheralName.Value))
     {
         writer.WriteError(string.Format("Could not find emulation element or backend"));
     }
 }
コード例 #29
0
ファイル: MachCommand.cs プロジェクト: rte-se/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     var currentMachine = GetCurrentMachine();
     if(currentMachine == null)
     {
         writer.WriteError("No machine selected.");
     }
     else
     {
         writer.WriteLine(string.Format("Current machine: {0}", EmulationManager.Instance.CurrentEmulation[currentMachine]));
     }
     if(EmulationManager.Instance.CurrentEmulation.MachinesCount > 0)
     {
         writer.WriteLine("Available machines:");
         var emu = EmulationManager.Instance.CurrentEmulation;
         var longestNameLength = emu.Machines.Max(m => emu[m].Length);
         var i = 0;
         foreach(var machine in emu.Machines)
         {
             writer.WriteLine(string.Format("\t{2}: {0,-" + longestNameLength + "} {1}", emu[machine], machine.Platform != null ? string.Format("[{0}]", machine.Platform.Name) : string.Empty, i++));
         }
     }
     writer.WriteLine();
     writer.WriteLine("You can use the following commands:");
     writer.WriteLine("'mach set [\"name\"|number]'\tto enable the given machine");
     writer.WriteLine("'mach add \"name\"'\tto create a new machine with the specified name");
     writer.WriteLine("'mach rem \"name\"'\tto remove a machine");
     writer.WriteLine("'mach create'\tto create a new machine with generic name and switch to it");
     writer.WriteLine("'mach clear'\tto clear the current selection");
 }
コード例 #30
0
ファイル: TraceCommand.cs プロジェクト: bhuvanchandra/emul8
 public void Run(ICommandInteraction writer, [Values(TraceEnableCommand)] LiteralToken enable, LiteralToken cpuToken, StringToken functionName, BooleanToken traceReturn, params LiteralToken[] types)
 {
     var cpu = (Arm)monitor.ConvertValueOrThrowRecoverable(cpuToken.Value, typeof(Arm));
     var cpuTracer = EnsureTracer(cpu);
     var handler = new DefaultFunctionHandler(cpu);
     var paramList = new List<FunctionCallParameter>();
     foreach(var parameter in types)
     {
         FunctionCallParameterType paramType;
         if(!Enum.TryParse(parameter.Value, out paramType))
         {
             throw new RecoverableException("{0} is not a proper parameter type.".FormatWith(parameter.Value));
         }
         paramList.Add(new FunctionCallParameter{ Type = paramType });
     }
     handler.CallParameters = paramList.Take(paramList.Count - (traceReturn.Value ? 1 : 0));
     handler.ReturnParameter = traceReturn.Value ? paramList.Last() : (FunctionCallParameter?)null;
     if(traceReturn.Value)
     {
         cpuTracer.TraceFunction(functionName.Value, handler.CallParameters, handler.CallHandler, handler.ReturnParameter, handler.ReturnHandler);
     }
     else
     {
         cpuTracer.TraceFunction(functionName.Value, handler.CallParameters, handler.CallHandler);
     }
     
 }
コード例 #31
0
        public void Run(ICommandInteraction writer)
        {
            var currentMachine = GetCurrentMachine();

            if (currentMachine == null)
            {
                writer.WriteError("Select active machine.");
                return;
            }
            writer.WriteLine("Available peripherals:");
            var peripheralEntries = currentMachine.GetPeripheralsWithAllRegistrationPoints();

            foreach (var entry in peripheralEntries)
            {
                var isInMachine = entry.Key.Parent == null;
                var description = (isInMachine || entry.Key.RegistrationPoint is ITheOnlyPossibleRegistrationPoint) ? "{0} ({1}) in {2}\n\r" : "{0} ({1}) in {2} at ";
                var parentName  = !isInMachine?peripheralEntries.First(x => x.Key.Peripheral == entry.Key.Parent).Key.Name
                                  : EmulationManager.Instance.CurrentEmulation[currentMachine];

                var peripheralName = entry.Key.Name ?? "<unnamed>";
                var nameAndParent  = string.Format(description, peripheralName, entry.Key.Type.Name, parentName);
                writer.Write(nameAndParent);
                if (!(entry.Key.RegistrationPoint is ITheOnlyPossibleRegistrationPoint || isInMachine))
                {
                    writer.WriteLine(entry.Key.RegistrationPoint.PrettyString);
                    if (entry.Value.Count() > 1)
                    {
                        foreach (var otherEntry in entry.Value.Skip(1))
                        {
                            writer.WriteLine(String.Format("{1}and at {0}", otherEntry.PrettyString, " ".PadLeft(nameAndParent.Length - "and at".Length - 1)));
                        }
                    }
                }
            }
        }
コード例 #32
0
ファイル: TraceCommand.cs プロジェクト: bhuvanchandra/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine("- to trace only function call with a registered handler:");
     writer.WriteLine("{0} {1} cpuName \"functionName\"".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine();
     writer.WriteLine("- to trace function call and returned value with a registered handler:");
     writer.WriteLine("{0} {1} cpuName \"functionName\" true".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine();
     writer.WriteLine("- to trace function call without a handler, with or without return value:");
     writer.WriteLine("{0} {1} cpuName \"functionName\" [true|false] [number of parameters]".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine();
     writer.WriteLine("- to trace function call without a handler, with or without return value, with specified variable types:");
     writer.WriteLine("{0} {1} cpuName \"functionName\" [true|false] [list of parameter types]".FormatWith(Name, TraceEnableCommand));
     writer.WriteLine("(Note, that if return value is expected, the last parameter type must relate to return value.");
     writer.WriteLine();
     writer.WriteLine("- to disable tracing of a function:");
     writer.WriteLine("{0} {1} cpuName \"functionName\"".FormatWith(Name, TraceDisableCommand));
     writer.WriteLine();
     writer.WriteLine("Handlers available for functions:");
     writer.WriteLine(handlers.Keys.Select(x => "- " + x).Stringify("\r\n"));
     writer.WriteLine();
     writer.WriteLine("Possible values for parameter types:");
     writer.WriteLine(Enum.GetNames(typeof(FunctionCallParameterType)).Where(x => !x.Contains("Array")).Select(x => "- " + x).Stringify("\r\n"));
 }
コード例 #33
0
        public void Run(ICommandInteraction writer, LiteralToken variable, Token value)
        {
            var varName = variable.Value;

            varName = GetVariableName(varName);
            SetVariable(varName, value);
        }
コード例 #34
0
ファイル: LogCommand.cs プロジェクト: bhuvanchandra/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine(String.Format("{0} <<message to log>> <<log level>>", Name));
 }
コード例 #35
0
ファイル: PeripheralsCommand.cs プロジェクト: rte-se/emul8
 public void Run(ICommandInteraction writer)
 {
     var currentMachine = GetCurrentMachine();
     if( currentMachine == null)
     {
         writer.WriteError("Select active machine.");
         return;
     }
     writer.WriteLine("Available peripherals:");
     var peripheralEntries = currentMachine.GetPeripheralsWithAllRegistrationPoints();
     foreach(var entry in peripheralEntries)
     {
         var isInMachine = entry.Key.Parent == null;
         var description = (isInMachine || entry.Key.RegistrationPoint is ITheOnlyPossibleRegistrationPoint) ? "{0} ({1}) in {2}\n\r" : "{0} ({1}) in {2} at ";
         var parentName = !isInMachine ? peripheralEntries.First(x => x.Key.Peripheral == entry.Key.Parent).Key.Name
             : EmulationManager.Instance.CurrentEmulation[currentMachine];
         var peripheralName = entry.Key.Name ?? "<unnamed>";
         var nameAndParent = string.Format(description, peripheralName, entry.Key.Type.Name, parentName);
         writer.Write(nameAndParent);
         if(!(entry.Key.RegistrationPoint is ITheOnlyPossibleRegistrationPoint || isInMachine))
         {
             writer.WriteLine(entry.Key.RegistrationPoint.PrettyString);
             if(entry.Value.Count() > 1)
             {
                 foreach(var otherEntry in entry.Value.Skip(1))
                 {
                     writer.WriteLine(String.Format("{1}and at {0}", otherEntry.PrettyString, " ".PadLeft(nameAndParent.Length - "and at".Length-1 )));
                 }
             }
         }
     }
 }
コード例 #36
0
 public void Run(ICommandInteraction writer, [Values("Noisy", "Debug", "Info", "Warning", "Error")] StringToken level, LiteralToken backendName, LiteralToken peripheralName)
 {
     if(!SetLogLevel(LogLevel.Parse(level.Value), backendName.Value, peripheralName.Value))
     {
         writer.WriteError(string.Format("Could not find emulation element or backend"));
     }
 }
コード例 #37
0
ファイル: AnalyzersCommand.cs プロジェクト: rasomc/emul8
        public void Run(ICommandInteraction writer, LiteralToken peripheralName)
        {
            var         emu = EmulationManager.Instance.CurrentEmulation;
            IPeripheral p;
            string      fake;

            var m = monitor.Machine;

            if (m == null || !m.TryGetByName(peripheralName.Value, out p, out fake))
            {
                writer.WriteError(string.Format("Peripheral not found: {0}", peripheralName.Value));
                return;
            }

            IAnalyzableBackend backend;

            if (!emu.BackendManager.TryGetBackendFor(p, out backend))
            {
                writer.WriteError(string.Format("No backend found for {0}", peripheralName.Value));
                return;
            }

            foreach (var a in emu.BackendManager.GetAvailableAnalyzersFor(backend))
            {
                writer.WriteLine(a);
            }
        }
コード例 #38
0
ファイル: Monitor.cs プロジェクト: krytarowski/emul8
        private TokenizationResult Tokenize(string cmd, ICommandInteraction writer)
        {
            var result = tokenizer.Tokenize(cmd);

            if (result.UnmatchedCharactersLeft != 0)
            {
                if (result.Tokens.Any(x => x is VariableToken))
                {
                    var tokensAfter = ExpandVariables(result.Tokens);
                    var newString   = tokensAfter.Select(x => x.OriginalValue).Stringify() + cmd.Substring(cmd.Length - result.UnmatchedCharactersLeft);
                    return(Tokenize(newString, writer));
                }
                var messages = new StringBuilder();

                var message = "Could not tokenize here:";
                writer.WriteError(message);
                messages.AppendFormat("Monitor: {0}\n", message);

                writer.WriteError(cmd);
                messages.AppendLine(cmd);

                var matchedLength = cmd.Length - result.UnmatchedCharactersLeft;
                var padded        = "^".PadLeft(matchedLength + 1);
                writer.WriteError(padded);
                messages.AppendLine(padded);
                if (result.Exception != null)
                {
                    messages.AppendFormat("Encountered exception: {0}\n", result.Exception.Message);
                    writer.WriteError(result.Exception.Message);
                }
                Logger.Log(LogLevel.Warning, messages.ToString());
                return(null);
            }
            return(result);
        }
コード例 #39
0
ファイル: LogLevelCommand.cs プロジェクト: rte-se/emul8
 public void Run(ICommandInteraction writer, [Values(-1L, 0L, 1L, 2L, 3L)] DecimalIntegerToken level, LiteralToken peripheralOrBackendName)
 {
     if(!SetLogLevel((LogLevel)level.Value, null, peripheralOrBackendName.Value)
         && !SetLogLevel((LogLevel)level.Value, peripheralOrBackendName.Value, null))
     {
         writer.WriteError(string.Format("Could not find emulation element or backend named: {0}", peripheralOrBackendName.Value));
     }
 }
コード例 #40
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("You must provide the name of the {0}.".FormatWith(noun));
     writer.WriteLine();
     writer.WriteLine(String.Format("Usage:\n\r\t{0} {1} \"value\"\n\r\n\r\t{0} {1}\n\r\t^^^\n\r\t[multiline value]\n\r\t^^^", Name, noun));
 }
コード例 #41
0
ファイル: SetCommand.cs プロジェクト: rte-se/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("You must provide the name of the {0}.".FormatWith(noun));
     writer.WriteLine();
     writer.WriteLine(String.Format("Usage:\n\r\t{0} {1} \"value\"\n\r\n\r\t{0} {1}\n\r\t^^^\n\r\t[multiline value]\n\r\t^^^", Name, noun));
 }
コード例 #42
0
 public void Run(ICommandInteraction writer, [Values(-1L, 0L, 1L, 2L, 3L)] NumericToken level, LiteralToken peripheralOrBackendName)
 {
     if (!SetLogLevel((LogLevel)level.Value, null, peripheralOrBackendName.Value) &&
         !SetLogLevel((LogLevel)level.Value, peripheralOrBackendName.Value, null))
     {
         writer.WriteError(string.Format("Could not find emulation element or backend named: {0}", peripheralOrBackendName.Value));
     }
 }
コード例 #43
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine(Name);
     writer.WriteLine($"{Name} <<numberOfEntries>>");
 }
コード例 #44
0
ファイル: AllowPrivatesCommand.cs プロジェクト: rte-se/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     var allowed = (monitor.CurrentBindingFlags & BindingFlags.NonPublic) > 0;
     writer.WriteLine();
     writer.WriteLine(allowed ? "Private fields are available":"Private fields are not available");
     return;
 }
コード例 #45
0
ファイル: StartCommand.cs プロジェクト: rte-se/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine(String.Format("{0} - starts the current machine", Name));
     writer.WriteLine(String.Format("{0} @path - executes the script and starts the emulation", Name));
 }
コード例 #46
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Usage:");
     writer.WriteLine(String.Format("{0} - starts the whole emulation", Name));
     writer.WriteLine(String.Format("{0} @path - executes the script and starts the emulation", Name));
 }
コード例 #47
0
        public override void PrintHelp(ICommandInteraction writer)
        {
            base.PrintHelp(writer);
            var allowed = (monitor.CurrentBindingFlags & BindingFlags.NonPublic) > 0;

            writer.WriteLine();
            writer.WriteLine(allowed ? "Private fields are available":"Private fields are not available");
            return;
        }
コード例 #48
0
 public void Run(ICommandInteraction writer, [Values("Noisy", "Debug", "Info", "Warning", "Error")] StringToken level, LiteralToken peripheralOrBackendName)
 {
     var logLevel = LogLevel.Parse(level.Value);
     if(!SetLogLevel(logLevel, null, peripheralOrBackendName.Value)
         && !SetLogLevel(logLevel, peripheralOrBackendName.Value, null))
     {
         writer.WriteError(string.Format("Could not find emulation element or backend named: {0}", peripheralOrBackendName.Value));
     }
 }
コード例 #49
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     writer.WriteLine("Usage:");
     writer.WriteLine("------");
     writer.WriteLine("showAnalyzer ([externalName]) [peripheral] ([typeName])");
     writer.WriteLine("\tshows analyzer for [peripheral]");
     writer.WriteLine("");
     writer.WriteLine("[externalName] (optional) - if set, command will create external named [externalName]; this can be used only for analyzers implementing IExternal interface");
     writer.WriteLine("[typeName] (optional) - if set, command will select analyzer provided in class [typeName]; this must be used when there are more than one analyzers available and no default is set"); 
 }
コード例 #50
0
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine("\nOptions:");
     writer.WriteLine("===========================");
     foreach(var item in PlatformsProvider.GetAvailablePlatforms().OrderBy(x=>x.Name))
     {
         writer.WriteLine(item.Name);
     }
 }
コード例 #51
0
ファイル: TerminalCommand.cs プロジェクト: rte-se/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Available terminals:");
     foreach(var key in console.Keys)
     {
         writer.WriteLine(string.Format("\t{0}", key));
     }
 }
コード例 #52
0
ファイル: HelpCommand.cs プロジェクト: rte-se/emul8
 public void CommandHelp(ICommandInteraction writer, LiteralToken commandName)
 {
     if(!GetCommands().Any(x => x.Name == commandName.Value))
     {
         writer.WriteError(String.Format("No such command: {0}.", commandName.Value));
         return;
     }
     var command = GetCommands().First(x => x.Name == commandName.Value);
     command.PrintHelp(writer);
 }
コード例 #53
0
ファイル: IncludeFileCommand.cs プロジェクト: rte-se/emul8
        public override void PrintHelp(ICommandInteraction writer)
        {
            base.PrintHelp(writer);

            writer.WriteLine("\nTo load a script you have to provide an existing file name.");
            writer.WriteLine();
            writer.WriteLine("Supported file formats:");
            writer.WriteLine("*.cs  - plugin file");
            writer.WriteLine("*.py  - python script");
            writer.WriteLine("other - monitor script");
        }
コード例 #54
0
ファイル: AllowPrivatesCommand.cs プロジェクト: rte-se/emul8
 public void RunnableAttribute(ICommandInteraction writer, BooleanToken allow)
 {
     if(allow.Value)
     {
         monitor.CurrentBindingFlags |= BindingFlags.NonPublic;
     }
     else
     {
         monitor.CurrentBindingFlags &= ~BindingFlags.NonPublic;
     }
 }
コード例 #55
0
ファイル: StartCommand.cs プロジェクト: rte-se/emul8
 public void Run(ICommandInteraction writer)
 {
     var currentMachine = GetCurrentMachine();
     if(currentMachine == null)
     {
         writer.WriteError("Select active machine.");
         return;
     }
     writer.WriteLine("Starting emulation...");
     currentMachine.Start();        
 }
コード例 #56
0
ファイル: ExecuteCommand.cs プロジェクト: rte-se/emul8
 public override void PrintHelp(ICommandInteraction writer)
 {
     base.PrintHelp(writer);
     writer.WriteLine();
     writer.WriteLine("Provide a command or {0} to execute.".FormatWith(noun));
     writer.WriteLine();
     writer.WriteLine("Available {0}s:".FormatWith(noun));
     foreach(var variable in GetVariables())
     {
         writer.WriteLine("\t{0}".FormatWith(variable));
     }
 }
コード例 #57
0
ファイル: NumbersModeCommand.cs プロジェクト: rte-se/emul8
        public override void PrintHelp(ICommandInteraction writer)
        {
            base.PrintHelp(writer);
            writer.WriteLine();

            writer.WriteLine(string.Format("Current mode: {0}", monitor.CurrentNumberFormat));
            writer.WriteLine();
            writer.WriteLine("Options:");
            foreach(var item in typeof(Monitor.NumberModes).GetEnumNames())
            {
                writer.WriteLine(item);
            }
        }
コード例 #58
0
ファイル: HelpCommand.cs プロジェクト: rte-se/emul8
 public void GeneralHelp(ICommandInteraction writer)
 {
     writer.WriteLine("Available commands:");
     writer.WriteLine(string.Format("{0,-18}| {1}", "Name", "Description"));
     writer.WriteLine("================================================================================");
     foreach(var item in GetCommands().OrderBy(x=>x.Name))
     {
         writer.WriteLine(string.Format("{0,-18}: {1}", item.Name, item.Description));    
     }
     writer.WriteLine();
     writer.WriteLine("You can also provide a device name to access its methods.");
     writer.WriteLine("Use <TAB> for auto-completion.");
 }
コード例 #59
0
ファイル: TraceCommand.cs プロジェクト: bhuvanchandra/emul8
 public void Run(ICommandInteraction writer, [Values(TraceEnableCommand, TraceDisableCommand)] LiteralToken enable, LiteralToken cpuToken, StringToken functionName)
 {
     if(enable.Value == TraceEnableCommand)
     {
         Execute(writer, cpuToken, functionName.Value, false, null);
     }
     else
     {
         var cpu = (Arm)monitor.ConvertValueOrThrowRecoverable(cpuToken.Value, typeof(Arm));
         var cpuTracer = EnsureTracer(cpu);
         cpuTracer.RemoveTracing(functionName.Value);
     }
 }
コード例 #60
0
ファイル: MachCommand.cs プロジェクト: rte-se/emul8
        public void Run(ICommandInteraction writer, [Values("set")] LiteralToken action, DecimalIntegerToken number)
        {
            var machines = EmulationManager.Instance.CurrentEmulation.Machines.ToArray();
            if(machines.Length > number.Value && number.Value >= 0)
            {
                SetCurrentMachine(machines[number.Value]);
            }
            else
            {
                writer.WriteError("Wrong machine number. Type {0} to show a list of available machines.".FormatWith(Name));
            }

        }