// [addedInVersion, removedInVersion[
 public ParserAttribute(Opcode opcode, ClientVersionBuild addedInVersion, ClientVersionBuild removedInVersion)
 {
     if (ClientVersion.AddedInVersion(addedInVersion) && ClientVersion.RemovedInVersion(removedInVersion))
         Opcode = Opcodes.GetOpcode(opcode);
     else
         Opcode = 0;
 }
示例#2
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
示例#3
0
 public AssemblerInstruction(int line, Opcode opcode, Operand left, Operand right)
 {
     Line = line;
     Opcode = opcode;
     Left = left;
     Right = right;
 }
示例#4
0
		}//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
示例#5
0
        public Request()
        {
            _recursionDesired = true;
            Opcode = Opcode.StandardQuery;

            _questions = new List<Query>();
        }
示例#6
0
		/// <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
示例#7
0
        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);
        }
示例#8
0
 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;
        }
示例#10
0
		}//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
示例#11
0
 public ShiftOperand(MachineOperand op, Opcode opcode, MachineOperand shAmt)
     : base(op.Width)
 {
     this.Operand = op;
     this.Opcode = opcode;
     this.Shift = shAmt;
 }
示例#12
0
		public Instruction (SourceLocation location, Opcode opcode, int arg)
			: this ()
		{
			OperationCode = opcode;
			Argument = arg;
			Location = location;
		}
示例#13
0
 public AssemblerInstruction()
 {
     Line = -1;
     Opcode = Opcode.None;
     Left = null;
     Right = null;
 }
示例#14
0
 public StorageCommand(Opcode cmdType, string key, uint flags, long expirationTimeInSeconds, int dataSize)
     : base(cmdType)
 {
     _key = key;
     _flags = flags;
     _expirationTimeInSeconds = expirationTimeInSeconds;
     _dataSize = dataSize;
 }
示例#15
0
		}//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
示例#16
0
		public static bool IsServerMessage(Opcode opcode)
		{
			if ((ushort)opcode > 10000 && (ushort)opcode < 20000)
			{
				return true;
			}
			return false;
		}
示例#17
0
 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;
        }
示例#19
0
 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;
 }
示例#20
0
        internal MessageEventArgs(Opcode opcode, byte[] rawData)
        {
            if ((ulong)rawData.LongLength > PayloadData.MaxLength)
                throw new WebSocketException(CloseStatusCode.TooBig);

            _opcode = opcode;
            _rawData = rawData;
        }
示例#21
0
		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("");
 }
示例#23
0
		public static bool IsClientMessage(Opcode opcode)
		{
			if ((ushort)opcode > 0 && (ushort)opcode < 10000)
			{
				return true;
			}
			return false;
		}
示例#24
0
 public Packet(Opcode opc)
 {
     Opcode = opc;
     Length = 0;  // whole packet size
     Buffer  = new byte[4096];
     currentByteCount = 4;
     currentReadIndex = 4;
 }
示例#25
0
 private void AddToBreakList(Opcode opcode)
 {
     if (_breakList.Count > 0)
     {
         List<Opcode> list = _breakList[_breakList.Count - 1];
         list.Add(opcode);
     }
 }
示例#26
0
文件: x86CPU.cs 项目: Myvar/MyvarVM
 public x86CPU(Config cfg)
 {
     _cfg = cfg;
     Registers = new Registers();
     State = new CPUState();
     Memmory = new Memmory(_cfg);
     _opcode = new Opcode();
 }
示例#27
0
        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);
        }
示例#30
0
        /// <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();
        }
示例#31
0
 public InstructionToken(Opcode opcode, int length, ShaderModel shaderModel) : base(opcode, length, shaderModel)
 {
     Operands = new List <Operand>();
 }
示例#32
0
 internal WebSocketFrame(Fin fin, Opcode opcode, byte[] data, bool compressed, bool mask)
     : this(fin, opcode, new PayloadData(data), compressed, mask)
 {
 }
示例#33
0
 public A64OpRec(Opcode opcode, string format)
 {
     this.opcode = opcode;
     this.format = format;
 }
示例#34
0
 public PICInstructionNoOpnd(Opcode opcode) : base(opcode)
 {
 }
示例#35
0
 public PICInstructionImmedShort(Opcode opcode, short imm)
     : base(opcode,
            new PICOperandImmediate(imm, PrimitiveType.Int16))
 {
 }
示例#36
0
 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);
 }
示例#38
0
 private void broadcastAsync(Opcode opcode, byte[] data, Action completed)
 {
     ThreadPool.QueueUserWorkItem(
         state => broadcast(opcode, data, completed)
         );
 }
示例#39
0
 private void broadcastAsync(Opcode opcode, Stream stream, Action completed)
 {
     ThreadPool.QueueUserWorkItem(
         state => broadcast(opcode, stream, completed)
         );
 }
示例#40
0
 internal void Add(Opcode op)
 {
     code.Add(op);
     jumpToLast = false;
 }
示例#41
0
        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;
 }
示例#45
0
 public PICInstructionMem2Mem(Opcode opcode, byte srcidx, uint dstaddr)
     : base(opcode,
            new PICOperandFSRIndexation(Constant.Byte(srcidx)),
            new PICOperandDataMemoryAddress(dstaddr))
 {
 }
示例#46
0
 public void EmitInstruction(SourceLocation loc, Opcode opcode, IodineLabel label)
 {
     labelReferences [instructions.Count] = label;
     instructions.Add(new Instruction(loc, opcode, 0));
 }
示例#47
0
 public override void Render(MachineInstructionWriter writer, MachineInstructionWriterOptions options)
 {
     writer.WriteOpcode(Opcode.ToString());
     writer.Tab();
     op1.Write(writer, options);
 }
示例#48
0
 public void EmitInstruction(SourceLocation loc, Opcode opcode, int arg)
 {
     instructions.Add(new Instruction(loc, opcode, arg));
 }
示例#49
0
 public PICInstructionImmedByte(Opcode opcode, ushort imm)
     : base(opcode, new PICOperandImmediate(imm, PrimitiveType.Byte))
 {
 }
示例#50
0
 public void EmitInstruction(Opcode opcode, int arg)
 {
     instructions.Add(new Instruction(new SourceLocation(0, 0, ""), opcode, arg));
 }
示例#51
0
 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
                ));
 }
示例#52
0
 public static string GetName(this Opcode opcode)
 => Marshal.PtrToStringAnsi((IntPtr)Native.GetOpcodeName(opcode));
示例#53
0
 public SllOprec(Opcode opcode, string format) : base(opcode, format)
 {
 }
示例#54
0
 public PICInstructionMemFB(Opcode opcode, ushort memaddr, byte bitno)
     : base(opcode, new PICOperandBankedMemory(memaddr), new PICOperandMemBitNo(bitno))
 {
 }
示例#55
0
 public BcNRec(Opcode f, Opcode t)
 {
     this.opFalse = f;
     this.opTrue  = t;
 }
示例#56
0
 public PICInstructionMemF(Opcode opcode, ushort memaddr)
     : base(opcode, new PICOperandBankedMemory(memaddr))
 {
 }
示例#57
0
 internal WebSocketFrame(Opcode opcode, PayloadData payloadData, bool mask)
     : this(Fin.Final, opcode, payloadData, false, mask)
 {
 }
示例#58
0
 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));
 }