// [addedInVersion, removedInVersion[ public ParserAttribute(Opcode opcode, ClientVersionBuild addedInVersion, ClientVersionBuild removedInVersion) { if (ClientVersion.AddedInVersion(addedInVersion) && ClientVersion.RemovedInVersion(removedInVersion)) Opcode = Opcodes.GetOpcode(opcode); else Opcode = 0; }
}//Parens protected override void Literal( Opcode op, byte[] code, ref int at ) { if( op != Opcode.Ident ) { base.Literal( op, code, ref at ); return; } var n = code[at++]; var s = Encoding.UTF8.GetString( code, at, n ); at += n; if( Aliasing == Alias.None ) { if( s[0] == '$' ) { s = s.Substring( 1 ); } if( HasBuiltin( s ) ) { Write( '@' ); } Write( s ); return; } if( Inside == Opcode.Dot ) { Name.Append( s ); return; } Write( Unalias( s ) ); }//Literal
public AssemblerInstruction(int line, Opcode opcode, Operand left, Operand right) { Line = line; Opcode = opcode; Left = left; Right = right; }
}//Binary protected override void Unary( Opcode op, byte[] code, ref int at ) { var paren = Parens; if( paren ) { Write( '(' ); } var text = op.Text(); var post = op.Postfix(); if( !post ) { Write( text ); if( text.Length > 2 ) { Write( ' ' ); } } Expression( code, ref at ); if( post ) { Write( text ); } if( paren ) { Write( ')' ); } }//Unary
public Request() { _recursionDesired = true; Opcode = Opcode.StandardQuery; _questions = new List<Query>(); }
/// <summary> /// push simple value (this, null, false, ...) /// </summary> void Parser.IGenerator.Push( Opcode opcode ) { var start = ValsAt; Vneed( 5 ); Vpush( unchecked((byte)opcode) ); Vpush( start ); }//Parser.IGenerator.Push
public void Decode() { Opcode = (Opcode)_machine.Memory[_machine.IP++]; var b1 = _machine.Memory[_machine.IP++]; var b2 = _machine.Memory[_machine.IP++]; var b3 = _machine.Memory[_machine.IP++]; var left = b1 >> 4; var leftPtr = (b3 & 0x80) != 0; var leftOffset = (b3 & 0x40) != 0; var leftOffsetReg = b2 >> 4; var leftType = (b3 >> 4) & 0x03; var leftPayload = ReadPayload(left); var right = b1 & 0x0F; var rightPtr = (b3 & 0x08) != 0; var rightOffset = (b3 & 0x04) != 0; var rightOffsetReg = b2 & 0x0F; var rightType = b3 & 0x03; var rightPayload = ReadPayload(right); Left.Change(left, leftType, leftPtr, leftOffset, leftOffsetReg, leftPayload); Right.Change(right, rightType, rightPtr, rightOffset, rightOffsetReg, rightPayload); }
public Instruction(Location location, Opcode opcode) : this() { OperationCode = opcode; Argument = 0; Location = location; }
public IFrameBuilder WithOpcode(Opcode opcode) { switch(opcode) { case(Opcode.Binary): _opcode = new byte[] { 0, 0, 1, 0 }; break; case(Opcode.ConnectionClose): _opcode = new byte[] { 1, 0, 0, 0 }; break; case (Opcode.Continuation): _isFinal = 0; _opcode = new byte[] { 0, 0, 0, 0 }; break; case (Opcode.Ping): _opcode = new byte[] { 1, 0, 0, 1 }; break; case (Opcode.Pong): _opcode = new byte[] { 1, 0, 1, 0 }; break; case (Opcode.Text): _opcode = new byte[] { 0, 0, 0, 1 }; break; default: _isFinal = 1; break; } return this; }
}//Literal protected override void Binary( Opcode op, byte[] code, ref int at ) { var paren = Parens; if( paren ) { Write( '(' ); } if( op == Opcode.Cast ) { Typeref( code, ref at ); Write( "! " ); Expression( code, ref at ); if( paren ) { Write( ')' ); } return; } Expression( code, ref at ); Write( ' ' ); Write( op.Text() ); Write( ' ' ); if( (op == Opcode.LogicAnd) || (op == Opcode.LogicOr) ) { at += 4; } Expression( code, ref at ); if( paren ) { Write( ')' ); } }//Binary
public ShiftOperand(MachineOperand op, Opcode opcode, MachineOperand shAmt) : base(op.Width) { this.Operand = op; this.Opcode = opcode; this.Shift = shAmt; }
public Instruction (SourceLocation location, Opcode opcode, int arg) : this () { OperationCode = opcode; Argument = arg; Location = location; }
public AssemblerInstruction() { Line = -1; Opcode = Opcode.None; Left = null; Right = null; }
public StorageCommand(Opcode cmdType, string key, uint flags, long expirationTimeInSeconds, int dataSize) : base(cmdType) { _key = key; _flags = flags; _expirationTimeInSeconds = expirationTimeInSeconds; _dataSize = dataSize; }
}//Parser.IGenerator.Push /// <summary> /// push string value (string, identifier) /// </summary> void Parser.IGenerator.Push( Opcode opcode, string @string ) { var start = ValsAt; Vneed( 5 + Encoding.UTF8.GetByteCount( @string ) ); Vpush( @string ); Vpush( unchecked((byte)opcode) ); Vpush( start ); }//Parser.IGenerator.Push
public static bool IsServerMessage(Opcode opcode) { if ((ushort)opcode > 10000 && (ushort)opcode < 20000) { return true; } return false; }
private Opcode AddOpcode(Opcode opcode, string destinationLabel) { opcode.Label = GetNextLabel(true); opcode.DestinationLabel = destinationLabel; _currentCodeSection.Add(opcode); _addBranchDestination = false; return opcode; }
public StoreWordIndexedInstruction(int address, int rS, int rA, int rB, Opcode opcode) : base(address) { ByteCode = (31 << 26 | rS << 21 | rA << 16 | rB << 11 | (int)opcode << 1); if (opcode == Opcode.STWCX) ByteCode |= 1; }
public PowerPcInstruction(Opcode opcode, MachineOperand op1, MachineOperand op2, MachineOperand op3, bool setsCR0) { this.opcode = opcode; this.op1 = op1; this.op2 = op2; this.op3 = op3; this.setsCR0 = setsCR0; }
internal MessageEventArgs(Opcode opcode, byte[] rawData) { if ((ulong)rawData.LongLength > PayloadData.MaxLength) throw new WebSocketException(CloseStatusCode.TooBig); _opcode = opcode; _rawData = rawData; }
public InstructionDefinition Find(Opcode opcode) { var key = opcode & Opcode.LookupKey_Mask; foreach (var candidate in byOpcodeKey[key]) if (candidate.IsMatch(opcode)) return candidate; return null; }
public ObjResponse() { m_name = "Response"; m_opcode = Opcode.none; m_arguments = new ArrayList(); m_arguments.Add(""); m_arguments.Add(""); }
public static bool IsClientMessage(Opcode opcode) { if ((ushort)opcode > 0 && (ushort)opcode < 10000) { return true; } return false; }
public Packet(Opcode opc) { Opcode = opc; Length = 0; // whole packet size Buffer = new byte[4096]; currentByteCount = 4; currentReadIndex = 4; }
private void AddToBreakList(Opcode opcode) { if (_breakList.Count > 0) { List<Opcode> list = _breakList[_breakList.Count - 1]; list.Add(opcode); } }
public x86CPU(Config cfg) { _cfg = cfg; Registers = new Registers(); State = new CPUState(); Memmory = new Memmory(_cfg); _opcode = new Opcode(); }
private static Opcode[] GetOpcodes(string data) { // Regex + HTML, naughty :O Regex rows = new Regex(@"<tr>((.|\n)*?)</tr>"); Regex eachRow = new Regex(@"<td><abbr title=""(?<abbr>[^""]*?)"">(?<op>.*?)</abbr></td>"); // Working for numeric regexs. // 0_255: [,\s](2[0-5][0-5]|2[0-4]\d|1?\d?\d)[,\s] // -128_0: [,\s](-(1[0-2][0-8]|1[01]\d|\d?\d))[,\s] // 0_100h: ([0-9A-F]{1,2})h // Both: [,\s]((-(1[0-2][0-8]|1[01]\d|\d?\d))|(2[0-5][0-5]|2[0-4]\d|1?\d?\d))[,\s] // // 0_65535: [,\s](6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{1,3}|[0-5]?\d{1,4})[,\s] // -65536_0: [,\s](-(3276[0-8]|327[0-5]\d|32[0-6]\d\d|3[01]\d{1,3}|[0-2]?\d{1,4}))[,\s] // 0_10000h: [0-9A-F]h // Both: [,\s]((6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{1,3}|[0-5]?\d{1,4})|(-(3276[0-8]|327[0-5]\d|32[0-6]\d\d|3[01]\d{1,3}|[0-2]?\d{1,4})))[,\s] // Parens left off end so it can incorporate a \w+ for matching labels in JP and JR operations const string byteregex = @"([0-9A-F]{1,2}h|-(1[0-2][0-8]|1[01]\d|\d?\d)|(2[0-5][0-5]|2[0-4]\d|1?\d?\d)"; const string shortregex = @"([0-9A-F]{1,4}h|(6553[0-5]|655[0-2]\d|65[0-4]\d\d|6[0-4]\d{1,3}|[0-5]?\d{1,4})|(-(3276[0-8]|327[0-5]\d|32[0-6]\d\d|3[01]\d{1,3}|[0-2]?\d{1,4}))"; var opcodes = new Opcode[256]; MatchCollection rowmc = rows.Matches(data); for (int i = 0; i < rowmc.Count; i++) { string row = rowmc[i].Groups[1].Value; MatchCollection mc = eachRow.Matches(row); for (int j = 0; j < mc.Count; j++) { int b = (i << 4) + j; string op = mc[j].Groups["op"].Value; op = op.Replace('n', '#'); int bytesFollowing = op.Where(c => c == '#').Count(); // Dynamically create regexs for the opcodes, so it can match for whitespace/constants etc and escapes brackets (parens) string opregex = op.Replace(" ", @"\s+").Replace("(", @"\(").Replace(")", @"\)").Replace(",", @"\s*,\s*") .Replace("##", shortregex).Replace("#", byteregex); // Add on an option to match labels in jump commands var first2Chars = op.Substring(0, 2); if ((first2Chars == "JP" || first2Chars == "CA") && bytesFollowing > 0) opregex += @"|[_a-zA-Z]\w+"; // Close the right paren of the first capturing group if (bytesFollowing > 0) opregex += ")"; opregex += @"[\s;]"; opcodes[b] = new Opcode(op, opregex, (byte)b, bytesFollowing, mc[j].Groups["abbr"].Value); } } // Remove non-existant instructions and Extended operation ones (for now) return opcodes.Where(o => o.Op != "XX" && o.Op != "Ext ops").ToArray(); }
internal MessageEventArgs(Opcode opcode, byte[] data) { if ((ulong) data.LongLength > PayloadData.MaxLength) throw new WebSocketException (CloseStatusCode.TooBig); _opcode = opcode; _rawData = data; _data = convertToString (opcode, data); }
private static void AddHandler(Opcode opcode, Type type) { if (Lookup.ContainsKey(opcode) == true) { throw new InvalidOperationException(string.Format("handler collision for {0}", opcode)); } Lookup.Add(opcode, type); }
/// <summary> /// Construct this object with the default values and create an ArrayList to hold /// the questions as they are added /// </summary> public Request() { // default for a request is that recursion is desired and using standard query _recursionDesired = true; _opCode = Opcode.StandardQuery; // create an expandable list of questions _questions = new ArrayList(); }
public InstructionToken(Opcode opcode, int length, ShaderModel shaderModel) : base(opcode, length, shaderModel) { Operands = new List <Operand>(); }
internal WebSocketFrame(Fin fin, Opcode opcode, byte[] data, bool compressed, bool mask) : this(fin, opcode, new PayloadData(data), compressed, mask) { }
public A64OpRec(Opcode opcode, string format) { this.opcode = opcode; this.format = format; }
public PICInstructionNoOpnd(Opcode opcode) : base(opcode) { }
public PICInstructionImmedShort(Opcode opcode, short imm) : base(opcode, new PICOperandImmediate(imm, PrimitiveType.Int16)) { }
public PICInstructionMem2Mem(Opcode opcode, uint srcaddr, uint dstaddr) : base(opcode, new PICOperandDataMemoryAddress(srcaddr), new PICOperandDataMemoryAddress(dstaddr)) { }
private static bool isControl(Opcode opcode) { return(opcode == Opcode.Close || opcode == Opcode.Ping || opcode == Opcode.Pong); }
private void broadcastAsync(Opcode opcode, byte[] data, Action completed) { ThreadPool.QueueUserWorkItem( state => broadcast(opcode, data, completed) ); }
private void broadcastAsync(Opcode opcode, Stream stream, Action completed) { ThreadPool.QueueUserWorkItem( state => broadcast(opcode, stream, completed) ); }
internal void Add(Opcode op) { code.Add(op); jumpToLast = false; }
private void GetCommonCpuInformation(ref MachineInformation information) { information.OperatingSystem = Environment.OSVersion; information.Platform = Expression.Empty() switch { _ when RuntimeInformation.IsOSPlatform(OSPlatform.Windows) => MachineInformation.Platforms.Windows, _ when RuntimeInformation.IsOSPlatform(OSPlatform.Linux) => MachineInformation.Platforms.Linux, _ when RuntimeInformation.IsOSPlatform(OSPlatform.OSX) => MachineInformation.Platforms.OSX, _ => MachineInformation.Platforms.Unknown }; information.Cpu.LogicalCores = (uint)Environment.ProcessorCount; information.Cpu.LogicalCoresPerNode = information.Cpu.LogicalCores; information.Cpu.Nodes = 1; information.Cpu.Architecture = RuntimeInformation.ProcessArchitecture.ToString(); information.Cpu.Caption = Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER") ?? default; information.Cpu.Name = information.Cpu.Caption; var cores = new List <Core>(); for (var i = 0; i < information.Cpu.LogicalCores; i++) { cores.Add(new Core { Number = (uint)i }); } information.Cpu.Cores = cores.AsReadOnly(); if (RuntimeInformation.ProcessArchitecture != Architecture.X86 && RuntimeInformation.ProcessArchitecture != Architecture.X64) { return; } Opcode.Cpuid(out var result, 0, 0); var vendorString = string.Format("{0}{1}{2}", string.Join("", $"{result.ebx:X}".HexStringToString().Reverse()), string.Join("", $"{result.edx:X}".HexStringToString().Reverse()), string.Join("", $"{result.ecx:X}".HexStringToString().Reverse())); information.Cpu.Vendor = vendorString; information.Cpu.MaxCpuIdFeatureLevel = result.eax; if (information.Cpu.MaxCpuIdFeatureLevel >= 1) { Opcode.Cpuid(out result, 1, 0); information.Cpu.Stepping = result.eax & 0xF; var familyId = (result.eax & 0xF00) >> 8; if (familyId == 6 || familyId == 15) { information.Cpu.Model = (((result.eax & 0xF0000) >> 16) << 4) + ((result.eax & 0xF0) >> 4); } else { information.Cpu.Model = (result.eax & 0xF0) >> 4; } if (familyId == 15) { information.Cpu.Family = ((result.eax & 0xFF00000) >> 20) + familyId; } else { information.Cpu.Family = familyId; } information.Cpu.Type = (CPU.ProcessorType)((result.eax & 0b11000000000000) >> 12); information.Cpu.FeatureFlagsOne = (CPU.FeatureFlagEDX)result.edx; information.Cpu.FeatureFlagsTwo = (CPU.FeatureFlagECX)result.ecx; } if (information.Cpu.MaxCpuIdFeatureLevel >= 7) { Opcode.Cpuid(out result, 7, 0); information.Cpu.ExtendedFeatureFlagsF7One = (CPU.ExtendedFeatureFlagsF7EBX)result.ebx; information.Cpu.ExtendedFeatureFlagsF7Two = (CPU.ExtendedFeatureFlagsF7ECX)result.ecx; information.Cpu.ExtendedFeatureFlagsF7Three = (CPU.ExtendedFeatureFlagsF7EDX)result.edx; } Opcode.Cpuid(out result, 0x80000000, 0); information.Cpu.MaxCpuIdExtendedFeatureLevel = result.eax; }
private static bool isData(Opcode opcode) { return(opcode == Opcode.Text || opcode == Opcode.Binary); }
public WebSocketFrame(Opcode opcode, Mask mask, PayloadData payload) : this(Fin.Final, opcode, mask, payload, false) { }
public JumpInstruction(Opcode opcode, string target) : base(opcode) { _target = target; }
public PICInstructionMem2Mem(Opcode opcode, byte srcidx, uint dstaddr) : base(opcode, new PICOperandFSRIndexation(Constant.Byte(srcidx)), new PICOperandDataMemoryAddress(dstaddr)) { }
public void EmitInstruction(SourceLocation loc, Opcode opcode, IodineLabel label) { labelReferences [instructions.Count] = label; instructions.Add(new Instruction(loc, opcode, 0)); }
public override void Render(MachineInstructionWriter writer, MachineInstructionWriterOptions options) { writer.WriteOpcode(Opcode.ToString()); writer.Tab(); op1.Write(writer, options); }
public void EmitInstruction(SourceLocation loc, Opcode opcode, int arg) { instructions.Add(new Instruction(loc, opcode, arg)); }
public PICInstructionImmedByte(Opcode opcode, ushort imm) : base(opcode, new PICOperandImmediate(imm, PrimitiveType.Byte)) { }
public void EmitInstruction(Opcode opcode, int arg) { instructions.Add(new Instruction(new SourceLocation(0, 0, ""), opcode, arg)); }
static IParser <byte, InstructionParseState, InstructionParseState> SetOpcode(Opcode opcode, String pretty) { return(FunctionalParser.Create( (IParseState <byte, InstructionParseState> input) => { if (input == null) { return null; } var result = input.Result; result.Opcode = opcode; result.PrettyPrint = builder => builder.Append(pretty); return ParseState.Create(input.ConsumedInput, input.RemainingInput, result); }, (byte)0 )); }
public static string GetName(this Opcode opcode) => Marshal.PtrToStringAnsi((IntPtr)Native.GetOpcodeName(opcode));
public SllOprec(Opcode opcode, string format) : base(opcode, format) { }
public PICInstructionMemFB(Opcode opcode, ushort memaddr, byte bitno) : base(opcode, new PICOperandBankedMemory(memaddr), new PICOperandMemBitNo(bitno)) { }
public BcNRec(Opcode f, Opcode t) { this.opFalse = f; this.opTrue = t; }
public PICInstructionMemF(Opcode opcode, ushort memaddr) : base(opcode, new PICOperandBankedMemory(memaddr)) { }
internal WebSocketFrame(Opcode opcode, PayloadData payloadData, bool mask) : this(Fin.Final, opcode, payloadData, false, mask) { }
public PICInstructionMem2Mem(Opcode opcode, byte srcidx, byte dstidx) : base(opcode, new PICOperandFSRIndexation(Constant.Byte(srcidx)), new PICOperandFSRIndexation(Constant.Byte(dstidx))) { }
public WebSocketFrame(Fin fin, Opcode opcode, Mask mask, PayloadData payload) : this(fin, opcode, mask, payload, false) { }
public static WebSocketFrame CreateFrame( Fin fin, Opcode opcode, Mask mask, byte [] data, bool compressed) { return(new WebSocketFrame(fin, opcode, mask, new PayloadData(data), compressed)); }