예제 #1
0
파일: Command.cs 프로젝트: rte-se/emul8
        public static PacketData Execute(Command command, Packet packet)
        {
            var executeMethod = GetExecutingMethod(command, packet);
            var mnemonic = executeMethod.GetCustomAttribute<ExecuteAttribute>().Mnemonic;
            var parsingContext = new ParsingContext(packet, mnemonic.Length);
            var parameters = executeMethod.GetParameters().Select(x => HandleArgumentNotResolved(parsingContext, x)).ToArray();

            return (PacketData)executeMethod.Invoke(command, parameters);
        }
예제 #2
0
파일: Command.cs 프로젝트: rte-se/emul8
        private static MethodInfo GetExecutingMethod(Command command, Packet packet)
        {
            var interestingMethods = GetExecutingMethods(command.GetType());
            if(!interestingMethods.Any())
            {
                return null;
            }

            return interestingMethods.SingleOrDefault(x => packet.Data.DataAsString.StartsWith(x.GetCustomAttribute<ExecuteAttribute>().Mnemonic, StringComparison.Ordinal));
        }
예제 #3
0
        public bool TryGetCommand(Packet packet, out Command command)
        {
            var commandDescriptor = availableCommands.SingleOrDefault(x => packet.Data.DataAsString.StartsWith(x.Mnemonic, StringComparison.Ordinal));
            if(commandDescriptor == null)
            {
                command = null;
                return false;
            }

            command = GetOrCreateCommand(commandDescriptor.Method.DeclaringType);
            return true;
        }
예제 #4
0
파일: Command.cs 프로젝트: rte-se/emul8
 public ParsingContext(Packet packet, int currentPosition)
 {
     Packet = packet;
     CurrentPosition = currentPosition;
 }
예제 #5
0
파일: GdbStub.cs 프로젝트: emul8/emul8
 private void SendPacket(Packet packet)
 {
     cpu.Log(LogLevel.Debug, "Sending response to GDB: {0}", packet.Data.DataAsString);
     foreach(var b in packet.GetCompletePacket())
     {
         terminal.SendByte(b);
     }
 }
예제 #6
0
파일: Packet.cs 프로젝트: rte-se/emul8
 public static bool TryCreate(byte[] data, byte checksum, out Packet p)
 {
     p = new Packet(new PacketData(data));
     return p.CalculateChecksum() == checksum;
 }
예제 #7
0
 public Result(Packet packet = null, bool corruptedPacket = false, bool interrupt = false)
 {
     Packet = packet;
     Interrupt = interrupt;
     CorruptedPacket = corruptedPacket;
 }