public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, CfgOutboundEdge[] cfgEdgesArg) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; CfgEdgesArg = cfgEdgesArg; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, SsaRegister regArg2) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; RegArg2 = regArg2; }
public void get_token(string testval, OpcodeEnum result1, string result2) { var sourceLine = new SourceLine(testval); Assert.Equal(result1, sourceLine.OpCode); Assert.Equal(result2, sourceLine.Operand); }
public IntcodeInstruction(OpcodeEnum opcode, ParameterModesEnum firstParameterMode, ParameterModesEnum secondParameterMode, ParameterModesEnum thirdParameterMode) { Opcode = opcode; FirstParameterMode = firstParameterMode; SecondParameterMode = secondParameterMode; ThirdParameterMode = thirdParameterMode; }
public ushort?GetOpcode(OpcodeEnum opcode) { if (!ReverseKnownOpcode.ContainsKey(opcode)) { return(null); } return(ReverseKnownOpcode[opcode]); }
public KeyValuePair <long, ParsedMessage>?LastOccurrence(OpcodeEnum opcode) { if (!IsKnown(opcode)) { return(null); } return(AllPackets.Where(x => x.Value.OpCode == ReverseKnownOpcode[opcode]).Last()); }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, SsaRegister regArg2, string strArg, CLRTypeSpec typeSpecArg, CLRTypeSpec typeSpecArg2) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; RegArg2 = regArg2; StrArg = strArg; TypeSpecArg = typeSpecArg; TypeSpecArg2 = typeSpecArg2; }
/// <summary> /// Executes the command. /// </summary> /// <param name="code">The code.</param> /// <param name="command">The command.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool ExecCommand(OpcodeEnum code, string command) { if (!IsConnected) { return(false); } Client.SendPacket(new Packet(code, PacketTypeEnum.ExecCommand, command)); return(true); }
private static int[] TranslateBatchOfIntCode(OpcodeEnum opcode, int index, int[] testInput) { switch (opcode) { case OpcodeEnum.Add: return(AddBatchOfIntCode(index, testInput)); case OpcodeEnum.Multiply: return(MultiplyBatchOfIntCode(index, testInput)); default: throw new Exception("Invalid opcode upstream"); } }
private static int[] ProcessIntCode(int[] testInput) { for (int i = 0; i < testInput.Length; i += 4) { OpcodeEnum opcode = GetOpcode(i, testInput); if (opcode == OpcodeEnum.EndProgram) { return(testInput); } testInput = TranslateBatchOfIntCode(opcode, i, testInput); } return(testInput); }
// Once your module found a new opcode public void SetOpcode(OpcodeId opcode, OpcodeEnum opcodeName) { if (KnownOpcode.ContainsKey(opcode)) { KnownOpcode.TryGetValue(opcode, out var value); throw new Exception("opcode: " + opcode + " is already know = " + value + " . You try to add instead = " + Enum.GetName(typeof(OpcodeEnum), opcodeName)); } if (KnownOpcode.Values.Contains(opcodeName)) { throw new Exception("opcodename: " + Enum.GetName(typeof(OpcodeEnum), opcodeName) + " is already know = " + opcode); } Console.WriteLine(opcode + " => " + opcodeName); ReverseKnownOpcode.Add(opcodeName, opcode); KnownOpcode.Add(opcode, opcodeName); NetworkController.Instance.UiUpdateKnownOpcode.Add(opcode, opcodeName); }
// NOT TESTED public bool PacketSeenInTheLastXms(OpcodeEnum opcode, DateTime now, long ms) { if (!ReverseKnownOpcode.ContainsKey(opcode)) { return(false); } for (var i = PacketCount; i > 0; --i) { var packet = AllPackets[i]; if (packet.Time.Ticks < now.Ticks - TimeSpan.TicksPerMillisecond * ms) { return(false); } if (packet.OpCode == ReverseKnownOpcode[opcode]) { return(true); } } return(false); }
internal Opcode(byte code, OpcodeEnum @enum, AddressingMode mode, byte cycles) { Code = code; Enum = @enum; Mode = mode; Cycles = cycles; if (Mode == AddressingMode.Implied) { Length = 0; } else if (Mode == AddressingMode.Absolute || Mode == AddressingMode.AbsoluteX || Mode == AddressingMode.AbsoluteY || Mode == AddressingMode.Indirect) { Length = 2; } else { Length = 1; } }
/// <summary> /// Initializes a new instance of the <see cref="Packet"/> class. /// </summary> /// <param name="opcode">The opcode.</param> /// <param name="type">The type.</param> /// <param name="data">The data.</param> public Packet(OpcodeEnum opcode, PacketTypeEnum type, int data) : this(opcode, type, data.ToString()) { }
/// <summary> /// Initializes a new instance of the <see cref="Packet"/> class. /// </summary> /// <param name="opcode">The opcode.</param> /// <param name="type">The type.</param> /// <param name="data">The data.</param> public Packet(OpcodeEnum opcode, PacketTypeEnum type, string data) : this(opcode, type, Encoding.Default.GetBytes(data + "\0")) { }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, CfgOutboundEdge cfgEdgeArg) { Opcode = opcode; CodeLocation = codeLocation; CfgEdgeArg = cfgEdgeArg; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, VReg vRegArg, SsaRegister regArg) { Opcode = opcode; CodeLocation = codeLocation; VRegArg = vRegArg; RegArg = regArg; }
public bool IsKnown(OpcodeEnum opcode) => ReverseKnownOpcode.ContainsKey(opcode);
static async public Task<WebSocketPacket> ReadPacketFromStreamAsync(int Version, NodeBufferedStream Stream) { var Packet = default(WebSocketPacket); if (Version <= 0) { var PayloadBegin = await Stream.ReadBytesAsync(1); if (PayloadBegin[0] != 0x00) throw(new Exception("Invalid Packet")); Packet.Opcode = OpcodeEnum.TextFrame; Packet.Payload = await Stream.ReadBytesUntilByteAsync(0xFF); } else { var Header = new byte[2]; var Size = new byte[8]; var SizeSize = 0; var Mask = new byte[4]; var Data = new MemoryStream(); var Temp = new byte[128]; WebSocketPacket.OpcodeEnum Opcode; bool IsFinal; bool IsMasked; int PayloadLength; do { await Stream.ReadAsync(Header, 0, 2); IsFinal = (((Header[0] >> 7) & 0x1) != 0); Opcode = (WebSocketPacket.OpcodeEnum)((Header[0] >> 0) & 0x7); PayloadLength = (Header[1] >> 0) & 0x7F; IsMasked = ((Header[1] >> 7) & 0x1) != 0; if (Opcode != OpcodeEnum.ContinuationFrame) { Packet.Opcode = Opcode; } // EXTENDED PayloadLength if (PayloadLength >= 0x7E) { if (PayloadLength == 0x7E) { SizeSize = 2; } else if (PayloadLength == 0x7F) { SizeSize = 8; } await Stream.ReadAsync(Size, 0, SizeSize); PayloadLength = 0; for (int n = 0; n < SizeSize; n++) { PayloadLength <<= 8; PayloadLength |= Size[n]; } } // MASK if (IsMasked) { await Stream.ReadAsync(Mask, 0, 4); } // Read Payload await Stream.ReadAsync(Temp, 0, PayloadLength); // Perform unmasking if (IsMasked) { for (int n = 0; n < PayloadLength; n++) Temp[n] ^= Mask[n % 4]; } Data.Write(Temp, 0, PayloadLength); } while (!IsFinal); Packet.Payload = Data.ToArray(); } return Packet; }
public OpcodeDTO(OpcodeEnum type, ushort opcode, uint length, uint[] data) : this((ushort)type, opcode, length, data) { }
public MessageEventArgs(OpcodeEnum opcode, byte[] payload, bool more) { Opcode = opcode; Payload = payload; More = more; }
void Process(byte b) { switch (m_state) { case State.NewMessage: m_final = (b & FinalBit) != 0; m_opcode = (OpcodeEnum)(b & 0xF); m_state = State.SecondByte; break; case State.SecondByte: m_isMaksed = (b & MaskedBit) != 0; byte length = (byte)(b & 0x7F); if (length < 126) { m_payloadLength = length; m_state = NextState(); } else if (length == 126) { m_state = State.ShortSize; } else { m_state = State.LongSize; } break; case State.Mask: m_mask[0] = b; m_state = State.Mask2; break; case State.Mask2: m_mask[1] = b; m_state = State.Mask3; break; case State.Mask3: m_mask[2] = b; m_state = State.Mask4; break; case State.Mask4: m_mask[3] = b; m_state = NextState(); break; case State.ShortSize: m_payloadLength = b << 8; m_state = State.ShortSize2; break; case State.ShortSize2: m_payloadLength |= b; m_state = NextState(); break; case State.LongSize: m_payloadLength = 0; // must be zero, max message size is MaxInt Debug.Assert(b == 0); m_state = State.LongSize2; break; case State.LongSize2: // must be zero, max message size is MaxInt Debug.Assert(b == 0); m_state = State.LongSize3; break; case State.LongSize3: // must be zero, max message size is MaxInt Debug.Assert(b == 0); m_state = State.LongSize4; break; case State.LongSize4: // must be zero, max message size is MaxInt Debug.Assert(b == 0); m_state = State.LongSize5; break; case State.LongSize5: m_payloadLength |= b << 24; m_state = State.LongSize6; break; case State.LongSize6: m_payloadLength |= b << 16; m_state = State.LongSize7; break; case State.LongSize7: m_payloadLength |= b << 8; m_state = State.LongSize8; break; case State.LongSize8: m_payloadLength |= b; m_state = NextState(); break; case State.MoreByte: // The first byte of the payload is the more bit if (m_isMaksed) { m_more = (b ^ m_mask[0]) == 1; } else { m_more = b == 1; } m_payloadLength--; m_state = State.Payload; break; } }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, bool flagArg) { Opcode = opcode; CodeLocation = codeLocation; FlagArg = flagArg; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, uint uintArg) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; UIntArg = uintArg; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, SsaRegister regArg2, SsaRegister regArg3, bool flagArg) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; RegArg2 = regArg2; RegArg3 = regArg3; FlagArg = FlagArg; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, SsaRegister regArg2, ArithEnum arithArg) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; RegArg2 = regArg2; ArithArg = arithArg; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, uint uintArg) { Opcode = opcode; CodeLocation = codeLocation; UIntArg = uintArg; }
/// <summary> /// Initializes a new instance of the <see cref="Packet"/> class. /// </summary> /// <param name="opcode">The opcode.</param> /// <param name="type">The type.</param> public Packet(OpcodeEnum opcode, PacketTypeEnum type) : this(opcode, type, "") { }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, CLRTypeSpec typeSpec, string strArg, bool flagArg) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; TypeSpecArg = typeSpec; StrArg = strArg; FlagArg = flagArg; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, SsaRegister regArg2, CfgOutboundEdge cfgEdgeArg, bool flagArg) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; RegArg2 = regArg2; CfgEdgeArg = cfgEdgeArg; FlagArg = flagArg; }
public void Send(OpcodeEnum type, ushort opcode, uint length, uint[] data) { Send(new OpcodeDTO(type, opcode, length, data)); }
public void Execute(OpcodeEnum opcodeEnum, AddressingMode mode, ushort parameter = 0) { InnerExecute(_opcodes.Get(opcodeEnum, mode), parameter, 0, 0); }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation) { Opcode = opcode; CodeLocation = codeLocation; }
public void Execute(OpcodeEnum opcodeEnum, ushort parameter = 0) { InnerExecute(_opcodes.Get(opcodeEnum), parameter, 0, 0); }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, SsaRegister regArg, CLRTypeSpec typeSpec) { Opcode = opcode; CodeLocation = codeLocation; RegArg = regArg; TypeSpecArg = typeSpec; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, CppMethodSpec methodSpecArg, CLRTypeSpec typeSpecArg, SsaRegister regArg, SsaRegister regArg2, SsaRegister[] regArgs) { Opcode = opcode; CodeLocation = codeLocation; TypeSpecArg = typeSpecArg; MethodSpecArg = methodSpecArg; RegArg = regArg; RegArg2 = regArg2; RegArgs = regArgs; }
/// <summary> /// Initializes a new instance of the <see cref="Packet"/> class. /// </summary> /// <param name="opcode">The opcode.</param> /// <param name="type">The type.</param> /// <param name="data">The data.</param> public Packet(OpcodeEnum opcode, PacketTypeEnum type, byte[] data) : this() { Opcode = opcode; Type = type; Data = data; }
public MidInstruction(OpcodeEnum opcode, CodeLocationTag codeLocation, ExceptionHandlingCluster ehClusterArg) { Opcode = opcode; CodeLocation = codeLocation; EhClusterArg = ehClusterArg; }