public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += RType.ToString("X").PadLeft(2, '0'); UserDataAll += IsSend.ToString("X").PadLeft(2, '0'); //kqz 2016-12-31 增加 UserDataAll += NumAuthenType.ToString("X").PadLeft(2, '0'); //kqz 2016-12-31 增加 byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
/// <summary> /// Mark this low register as in use by the given original register. /// </summary> public void SetInUseBy(Register originalRegister, RType type) { if (OriginalRegister != null) { throw new InvalidOperationException("Register state is still in use"); } if (type == RType.Wide) { if (next == null) { throw new InvalidOperationException("Register state cannot hold a wide"); } if (next.OriginalRegister != null) { throw new InvalidOperationException("Register state.next is still in use"); } } OriginalRegister = originalRegister; isWide = (type == RType.Wide); this.type = type; if (isWide) { next.isWide = false; next.OriginalRegister = originalRegister; next.type = RType.Wide2; next.wideStart = this; } Mapping = new RegisterSpillingMapping(OriginalRegister, LowRegister); }
/// <summary> /// Create a move instruction. /// </summary> private static Instruction CreateMove(Register from, Register to, RType type) { if (from == null) { throw new ArgumentNullException("from"); } if (to == null) { throw new ArgumentNullException("to"); } OpCodes opcode; switch (type) { case RType.Value: opcode = OpCodes.Move; break; case RType.Wide: opcode = OpCodes.Move_wide; break; case RType.Wide2: return(new Instruction(OpCodes.Nop)); case RType.Object: opcode = OpCodes.Move_object; break; default: throw new ArgumentException("Unknown type: " + (int)type); } return(new Instruction(opcode, to, @from)); }
/// <summary> /// Allocate a single register. /// </summary> public Register AllocateRegister(RCategory category, RType type) { // Allow an additional register var result = new Register(lastRegisterIndex++, category, type); registers.Add(result); return result; }
public static extern int RegGetValueW( IntPtr hkey, string lpSubKey, string lpValue, RFlags dwFlags, out RType pdwType, IntPtr pvData, ref int pcbData);
/// <summary> /// Allocate a single register. /// </summary> public Register AllocateRegister(RCategory category, RType type) { // Allow an additional register var result = new Register(lastRegisterIndex++, category, type); registers.Add(result); return(result); }
public void GoGetResource(RType type) { if (resources.CurrentTotal >= resources.MaxAmt) { GoToBank(); return; } if (rm.GetNearbyR(type, transform.position) != null) { SetDestination(rm.GetNearbyR(type, transform.position).transform, true); } }
/// <summary> /// Is this low register currently available for the given type of register? /// </summary> public bool IsFreeFor(RType type) { if (OriginalRegister != null) { return(false); } if (type == RType.Wide) { return((next != null) && (next.OriginalRegister == null)); } return(true); }
/// <summary> /// Mark this low register state as no longer in use. /// </summary> private void Clear() { if (isWide) { next.Clear(); } OriginalRegister = null; SaveToOriginalNeeded = false; isWide = false; type = RType.Value; wideStart = null; Mapping = null; }
//kqz 2016-12-31 增加 public string WriteMsg() { UserData = ""; UserData += SerialNumber.ToString("X").PadLeft(4, '0'); UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserData += RType.ToString("X").PadLeft(2, '0'); UserData += IsSend.ToString("X").PadLeft(2, '0'); //kqz 2016-12-31 增加 UserData += NumAuthenType.ToString("X").PadLeft(2, '0'); //kqz 2016-12-31 增加 UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); return(WriteMsgBase()); }
/// <summary>Write text to the <seealso cref="SessionManager"/> console</summary> /// <param name="InboundText">The text to be written</param> /// <param name="ReportType">How to mark the text displayed using <seealso cref="RType"/></param> /// <param name="color">The color of the text to be displayed</param> /// <param name="imp">Display regardless of report type or debug status</param> public static void Report(string InboundText, RType ReportType = (RType)2, Color color = new Color(), bool imp = false) { //if (SessionManager.SMptr.InvokeRequired) { // SessionManager.SMptr.Invoke((MethodInvoker)delegate { // ReportEx(InboundText, ReportType, color); // }); // return; //} if (Debug || ReportType == RType.ERROR) { if (ReportType == RType.DEBUG && advd != true) { return; } ReportEx(InboundText, ReportType, color); } }
public Resource GetNearbyR(RType type, Vector3 point) { Resource[] rs = FindObjectsOfType <Resource>(); Resource closest = null; for (int i = 0; i < rs.Length; i++) { Resource ri = rs[i]; if (ri.ResourceType == type) { if (closest == null || master.IsResourceEmpty(ri) && closest != null && Vector3.Distance(closest.transform.position, point) > Vector3.Distance(point, ri.transform.position)) { closest = ri; } } } return(closest); }
public static void ReportEx(string InboundText, RType ReportType = (RType)2, Color BaseColor = new Color(), bool Time = true, bool Tag = true, bool Append = false, bool IgnoreError = false) { //initialize RichTextBox stdout = SessionManager.SMptr.Log; DateTime reporttime = DateTime.Now; if (ReportType == RType.ERROR && IgnoreError == false) { EC ecn = new EC { EDesc = InboundText, ETime = reporttime, EType = "Error" }; EDict.Add(ecn); SessionManager.SMptr.ErrorDisplay.Text = EDict.Count + " Errors"; } stdout.SuspendLayout(); //begin print if (Append == false) { stdout.AppendText(Environment.NewLine); } //PRINT TIME if (Time) { stdout.SelectionColor = RTC[1]; stdout.AppendText("[" + reporttime.ToString("H:mm:ss") + "] "); } //PRINT REPORT TYPE if (Tag) { stdout.SelectionColor = (int)ReportType == -1 ? Color.Purple : RTC[Math.Abs((int)ReportType)]; stdout.AppendText("[" + ReportType.ToString() + "] "); } stdout.SelectionColor = (BaseColor.IsEmpty) ? RTC[1] : BaseColor; stdout.AppendText(InboundText); stdout.ScrollToCaret(); stdout.ResumeLayout(); Console.WriteLine(InboundText); }
public async Task <dynamic> Availability(DateTime start, DateTime end, RType resourceType, string[] resourceSubTypes, IEnumerable <DateTime> occurrences) { var reservations = new List <Reservation>(); if (occurrences == null) { reservations = await _reservationRepository.GetReservationsByInterval(start, end); } else { foreach (var startTime in occurrences) { var endTime = new DateTime(startTime.Year, startTime.Month, startTime.Day, end.Hour, end.Minute, 0); var tempResources = await _reservationRepository.GetReservationsByInterval(startTime, endTime); reservations.AddRange(tempResources); } } var resourceIds = reservations.Where(reservation => reservation.ResourceType == resourceType).Select(reservation => reservation.ResourceId).ToList(); if (resourceType == RType.Space) { var spaces = await _spaceRepository.GetAll(); var freeSpaces = spaces.Where(space => !resourceIds.Contains(space.Id)).ToList(); if (resourceSubTypes.Any() && freeSpaces.Any()) { freeSpaces = freeSpaces.Where(space => resourceSubTypes.Contains(space.SpaceTypeId)).ToList(); } return(freeSpaces); } else { var assets = await _assetRepository.GetAll(); var freeAssets = assets.Where(asset => !resourceIds.Contains(asset.Id)).ToList(); if (resourceSubTypes.Any() && freeAssets.Any()) { freeAssets = freeAssets.Where(asset => resourceSubTypes.Contains(asset.AssetTypeId)).ToList(); } return(freeAssets); } }
public Object restApiCall(string baseUrl, string postUrl, RType requestType, object values) { if (requestType.Equals(RType.POST)) { var client = new RestClient(baseUrl); var request = new RestRequest(postUrl, Method.POST); request.RequestFormat = DataFormat.Json; request.AddHeader("Content-Type", "application/json; charset=utf-8"); request.AddJsonBody(values); IRestResponse response = client.Execute(request); var content = JsonConvert.DeserializeObject <object>(response.Content); return(content); } else { return(null); } }
public List <object> IPORequest(SmsPdu pdu) { List <object> resultList = new List <object>(); //=================================================== try { if (pdu is SmsDeliverPdu) { SmsDeliverPdu dpdu = (SmsDeliverPdu)pdu; String Text = dpdu.UserDataText.ToLower(); string SMSCode = string.Empty; string output_PaymentType = string.Empty; string output_RefundType = string.Empty; string output_CompanyCode = string.Empty; string ErrorMsg = string.Empty; string[] output_CustCode = null; string output_Message = dpdu.UserDataText; string output_PnoneNumber = dpdu.OriginatingAddress; if (dpdu.OriginatingAddress.Length > 11 || dpdu.OriginatingAddress.Length == 11) { dpdu.OriginatingAddress = dpdu.OriginatingAddress.Replace("+880", "0"); } var RegCode = (objData.GetCustCodeMultipleFromPhoneNo(dpdu.OriginatingAddress)); string Output_RegCustCode = string.Join(",", RegCode.ToArray()); if (Output_RegCustCode != "") { SMSCode = SMSCode + SMSCommadCode.IPORegCust_Code + "-"; } else { SMSCode = SMSCode + SMSCommadCode.IPODefault_Code + "-"; } char[] delimiterChars = { ' ', ',', '.', ':', '\t', '/', '_', ';', '.', }; string[] Word = Text.Split(delimiterChars); List <string> listCustCodeforMessage = new List <string>(); string[] Input_CustCode = null; var listtmp = new List <string>(Regex.Split(Text, @"\D+")); Input_CustCode = listtmp.Where(t => !string.IsNullOrEmpty(Convert.ToString(t))).ToArray(); string[] RegCodeforarray = Output_RegCustCode.Split(','); #region NewWork var listRegCustCode = string.Join(",", RegCodeforarray); var listMessageplaceCustCode = string.Join(",", Input_CustCode); if (listRegCustCode.Contains(listMessageplaceCustCode)) { output_CustCode = Input_CustCode; SMSCode = SMSCode + SMSCommadCode.IPOCustomerFound + "-"; } else if (listRegCustCode.Length == listMessageplaceCustCode.Length) { List <string> ValidationRegCode = new List <string>(); foreach (string value in Input_CustCode) { if (!RegCodeforarray.Contains(value)) { ValidationRegCode.Add((value).ToString()); } } if (ValidationRegCode.Count == 0) { output_CustCode = Input_CustCode; SMSCode = SMSCode + SMSCommadCode.IPOCustomerFound + "-"; } } else { string[] RegCodeforParentAndChildCode = null; //---------- Parent Child ------------------------ List <KeyValuePair <string, string[]> > objectsGot = new List <KeyValuePair <string, string[]> >(); foreach (string Rreg in RegCodeforarray) { var PRegcode = (objData.GetParentChildCheckFormCustCode(Rreg.ToString())); RegCodeforParentAndChildCode = PRegcode.ToArray(); objectsGot.Add(new KeyValuePair <string, string[]>(Rreg.ToString(), (string[])RegCodeforParentAndChildCode)); } string Code = string.Empty; if (RegCodeforParentAndChildCode.Length != 0) { foreach (var tmp in objectsGot) { DataSqlQuery objdataSqlQuery = new DataSqlQuery(); string ErrorMsg_Tmp = MessageGenerate.IPORegErrorMessage(tmp.Key); int l = 1; int invalidFound = 0; foreach (string value in Input_CustCode) { if (!tmp.Value.Contains(value) && l < Input_CustCode.Length) { ErrorMsg_Tmp = ErrorMsg_Tmp + value + ","; invalidFound++; } else if (!tmp.Value.Contains(value)) { ErrorMsg_Tmp = ErrorMsg_Tmp + value; invalidFound++; } l++; } if (invalidFound == 0) { output_CustCode = Input_CustCode; SMSCode = SMSCode + SMSCommadCode.IPOCustomerFound + "-"; Output_RegCustCode = tmp.Key; break; } else { string SMSCodelastPart = "SMS07"; string sMessage = objdataSqlQuery.GetNotRegisterMessage(SMSCodelastPart); ErrorMsg = ErrorMsg_Tmp + sMessage; } } } else { output_CustCode = Input_CustCode; SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-"; } } resultList.Add(Output_RegCustCode); if (ErrorMsg != "") { output_CustCode = Input_CustCode; SMSCode = SMSCode + SMSCommadCode.DefaultCode + "-"; } //---------- End Parent Child ------------------- #endregion //- ---------- IPO Company Select ------------------ string Comapnt_ShortCode = ""; string IpoCompanyShortCode = string.Empty; Comapnt_ShortCode = Word[0].ToLower(); if (Comapnt_ShortCode != "") { IpoCompanyShortCode = GetCompany_Short_Code_FromReg(Comapnt_ShortCode); } if (IpoCompanyShortCode != "") { output_CompanyCode = Comapnt_ShortCode; resultList.Add(output_CompanyCode); SMSCode = SMSCode + SMSCommadCode.IPOCompanyFound + "-"; } else if (IpoCompanyShortCode == "") { SMSCode = SMSCode + SMSCommadCode.IPODefault_Code + "-"; } //-------------------- End Company Select ----------------- if (ErrorMsg == "") { resultList.Add(Input_CustCode); } else { resultList.Add(Input_CustCode); } string IPO_PaymentType = "pIPO,ptrade,pmIPO,PmTrade"; string[] IPO_paymenttype = IPO_PaymentType.Split(','); foreach (string PType in IPO_paymenttype) { if (Word.Contains(PType.ToLower())) { output_PaymentType = PType.ToLower(); } } resultList.Add(output_PaymentType); if (output_PaymentType != "") { SMSCode = SMSCode + SMSCommadCode.IPOPaymentType + "-"; } else if (output_PaymentType == "") { SMSCode = SMSCode + SMSCommadCode.IPODefault_Code + "-"; } string IPO_RefundType = "rIPO,rtrade,rEFT,rmIPO,rmTrade"; string[] IPO_refundtype = IPO_RefundType.Split(','); foreach (string RType in IPO_refundtype) { if (Word.Contains(RType.ToLower())) { output_RefundType = RType.ToLower(); } } resultList.Add(output_RefundType); if (output_RefundType != "") { SMSCode = SMSCode + SMSCommadCode.IPORefundType; } else if (output_RefundType == "") { SMSCode = SMSCode + SMSCommadCode.IPODefault_Code; } string ReceiveID = objData.ReceiveID(); resultList.Add(output_Message); resultList.Add(output_PnoneNumber); resultList.Add(ReceiveID); resultList.Add(ErrorMsg); resultList.Add(SMSCode); } } catch (Exception ex) { throw new Exception(ex.Message); } //======================== return(resultList); }
public static extern uint RegQueryValueEx(IntPtr hKey, string lpValueName, int lpReserved, ref RType lpType, byte[] pvData, ref uint pcbData);
public void compileRTypeStruct(string str, RType inst) { }
public Relationship (RType type, string id, string target) { Id = id; Target = target; Type = type; }
public string RTypeToString(RType repType) { return rTypeTo [repType]; }
Test_InRange( RType< IReal > t, IReal min, IReal max, bool skipout ) { Print( "null passes" ); t.Check( null ); Print( "Smaller fails" ); if( !skipout ) Expect( e => RTypeException.Match( e, (vr,f) => vr.Equals( f.Down().Parameter( "item" ) ), rt => rt.Equals( t ) ), () => t.Check( min.Minus( Real.Create( 1m ) ) ) ); Print( "Min passes" ); t.Check( min ); Print( "In range passes" ); t.Check( Real.Create( 10 ) ); Print( "Max passes" ); t.Check( max ); Print( "Bigger fails" ); if( !skipout ) Expect( e => RTypeException.Match( e, (vr,f) => vr.Equals( f.Down().Parameter( "item" ) ), rt => rt.Equals( t ) ), () => t.Check( max.Plus( Real.Create( 1m ) ) ) ); }
private static extern int RegGetValue(HKEY hkey, string lpSubKey, string lpValue, RFlags dwFlags, out RType pdwType, IntPtr pvData, ref int pcbData);
public Record(RType type, int weight) { this.type = type; this.weight = weight; }
/// <summary> /// Mark this low register as in use by the given original register. /// </summary> public void SetInUseBy(Register originalRegister, RType type) { if (OriginalRegister != null) throw new InvalidOperationException("Register state is still in use"); if (type == RType.Wide) { if (next == null) throw new InvalidOperationException("Register state cannot hold a wide"); if (next.OriginalRegister != null) throw new InvalidOperationException("Register state.next is still in use"); } OriginalRegister = originalRegister; isWide = (type == RType.Wide); this.type = type; if (isWide) { next.isWide = false; next.OriginalRegister = originalRegister; next.type = RType.Wide2; next.wideStart = this; } Mapping = new RegisterSpillingMapping(OriginalRegister, LowRegister); }
/// <summary> /// Mark this low register state as no longer in use. /// </summary> private void Clear() { if (isWide) next.Clear(); OriginalRegister = null; SaveToOriginalNeeded = false; isWide = false; type = RType.Value; wideStart = null; Mapping = null; }
// read one package private async Task <Pair <ResourcePackage, PackageHeader> > readPackage(PackageHeader packageHeader) { Pair <ResourcePackage, PackageHeader> pair = new Pair <ResourcePackage, PackageHeader>(); //read packageHeader ResourcePackage resourcePackage = new ResourcePackage(packageHeader); pair.setLeft(resourcePackage); //= new Pair<ResourcePackage, PackageHeader>(resourcePackage, null); //pair. = resourcePackage; //.setLeft(resourcePackage); long beginPos = buffer.position(); // read type string pool if (packageHeader.getTypeStrings() > 0) { buffer.position((int)(beginPos + packageHeader.getTypeStrings() - packageHeader.getHeaderSize())); resourcePackage.setTypeStringPool(await ParseUtils.readStringPool(buffer, (StringPoolHeader)await readChunkHeader())); } //read key string pool if (packageHeader.getKeyStrings() > 0) { buffer.position((int)(beginPos + packageHeader.getKeyStrings() - packageHeader.getHeaderSize())); resourcePackage.setKeyStringPool(await ParseUtils.readStringPool(buffer, (StringPoolHeader)await readChunkHeader())); } //outer: while (buffer.hasRemaining()) { ChunkHeader chunkHeader = await readChunkHeader(); long chunkBegin = buffer.position(); switch (chunkHeader.getChunkType()) { case ChunkType.TABLE_TYPE_SPEC: TypeSpecHeader typeSpecHeader = (TypeSpecHeader)chunkHeader; long[] entryFlags = new long[(int)typeSpecHeader.getEntryCount()]; for (int i = 0; i < typeSpecHeader.getEntryCount(); i++) { entryFlags[i] = Buffers.readUInt(buffer); } TypeSpec typeSpec = new TypeSpec(typeSpecHeader); typeSpec.setEntryFlags(entryFlags); //id start from 1 typeSpec.setName(resourcePackage.getTypeStringPool() .get(typeSpecHeader.getId() - 1)); resourcePackage.addTypeSpec(typeSpec); buffer.position((int)(chunkBegin + typeSpecHeader.getBodySize())); break; case ChunkType.TABLE_TYPE: TypeHeader typeHeader = (TypeHeader)chunkHeader; // read offsets table long[] offsets = new long[(int)typeHeader.getEntryCount()]; for (int i = 0; i < typeHeader.getEntryCount(); i++) { offsets[i] = Buffers.readUInt(buffer); } RType type = new RType(typeHeader); type.setName(resourcePackage.getTypeStringPool().get(typeHeader.getId() - 1)); long entryPos = chunkBegin + typeHeader.getEntriesStart() - typeHeader.getHeaderSize(); buffer.position((int)entryPos); ByteBuffer b = await buffer.slice(); await b.order(byteOrder); type.setBuffer(b); type.setKeyStringPool(resourcePackage.getKeyStringPool()); type.setOffsets(offsets); type.setStringPool(stringPool); resourcePackage.addType(type); locales.Add(type.getLocale()); buffer.position((int)(chunkBegin + typeHeader.getBodySize())); break; case ChunkType.TABLE_PACKAGE: // another package. we should read next package here //pair = new Pair<ResourcePackage, PackageHeader>(pair.Key, (PackageHeader)chunkHeader); pair.setRight((PackageHeader)chunkHeader); //break outer; return(pair); case ChunkType.TABLE_LIBRARY: // read entries LibraryHeader libraryHeader = (LibraryHeader)chunkHeader; for (long i = 0; i < libraryHeader.getCount(); i++) { int packageId = buffer.getInt(); string name = await Buffers.readZeroTerminatedString(buffer, 128); LibraryEntry entry = new LibraryEntry(packageId, name); //TODO: now just skip it.. } buffer.position((int)(chunkBegin + chunkHeader.getBodySize())); break; default: throw new Exception("unexpected chunk type: 0x" + chunkHeader.getChunkType()); } } return(pair); }
internal static extern uint RegGetValue(IntPtr hkey, string lpSubKey, string lpValue, RFlags dwFlags, out RType pdwType, IntPtr pvData, ref uint pcbData);
public void ExecuteInstruction(int instr) { //MonoBehaviour.print(pc); //MonoBehaviour.print(System.Convert.ToString(instr, 16)); //MonoBehaviour.print(System.Convert.ToString(instr, 2)); int opcode = instr & 0x7f; if (opcode == 0x37) // LUI { UType args = new UType(instr); WriteReg(args.rd, (args.imm << 12) | (ReadReg(args.rd) & 0xfff)); } else if (opcode == 0x17) // AUIPC { UType args = new UType(instr); WriteReg(args.rd, (args.imm << 12) + pc); } else if (opcode == 0x6f) // JAL { JType args = new JType(instr); WriteReg(args.rd, pc + 4); pc += SignExtend(args.imm, 20) / 4 - 1; } else if (opcode == 0x67) // JALR { IType args = new IType(instr); WriteReg(args.rd, pc + 4); pc = ((ReadReg(args.rs1) + pc) >> 1) << 1; } else if (opcode == 0x63) // branch { BType args = new BType(instr); /*MonoBehaviour.print("branch"); * MonoBehaviour.print(args.imm); * MonoBehaviour.print(SignExtend(args.imm, 12));*/ bool jump; if (args.funct3 == 0x0) // BEQ { jump = (ReadReg(args.rs1) == ReadReg(args.rs2)); } else if (args.funct3 == 0x1) // BNE { jump = (ReadReg(args.rs1) != ReadReg(args.rs2)); } else if (args.funct3 == 0x4) // BLT { jump = (ReadReg(args.rs1) < ReadReg(args.rs2)); } else if (args.funct3 == 0x5) // BGE { jump = (ReadReg(args.rs1) >= ReadReg(args.rs2)); } else if (args.funct3 == 0x6) // BLTU { jump = (((uint)ReadReg(args.rs1)) < ((uint)ReadReg(args.rs2))); } else if (args.funct3 == 0x7) // BGEU { jump = (((uint)ReadReg(args.rs1)) >= ((uint)ReadReg(args.rs2))); } else // unrecognized { jump = false; } if (jump) { pc += SignExtend(args.imm, 12) / 4 - 1; } } else if (opcode == 0x03) // load { IType args = new IType(instr); if (args.funct3 == 0x0) // LB { // unimplemented } else if (args.funct3 == 0x1) // LH { // unimplemented } else if (args.funct3 == 0x2) // LW { WriteReg(args.rd, LoadMemory(SignExtend(args.imm, 12) + ReadReg(args.rs1))); } else if (args.funct3 == 0x4) // LBU { // unimplemented } else if (args.funct3 == 0x5) // LHU { // unimplemented } else { // unrecognized } } else if (opcode == 0x23) // store { SType args = new SType(instr); if (args.funct3 == 0x0) // SB { // unimplemented } else if (args.funct3 == 0x1) // SH { // unimplemented } else if (args.funct3 == 0x2) // SW { StoreMemory(SignExtend(args.imm, 12) + ReadReg(args.rs1), ReadReg(args.rs2)); } else { // unrecognized } } else if (opcode == 0x13) // immediate { IType args = new IType(instr); args.imm = SignExtend(args.imm, 11); int value; if (args.funct3 == 0x0) // ADDI { value = ReadReg(args.rs1) + args.imm; } else if (args.funct3 == 0x2) // SLTI { value = (ReadReg(args.rs1) < args.imm) ? 1 : 0; } else if (args.funct3 == 0x3) // SLTIU { value = (((uint)ReadReg(args.rs1)) < ((uint)args.imm)) ? 1 : 0; } else if (args.funct3 == 0x4) // XORI { value = ReadReg(args.rs1) ^ args.imm; } else if (args.funct3 == 0x6) // ORI { value = ReadReg(args.rs1) | args.imm; } else if (args.funct3 == 0x7) // ANDI { value = ReadReg(args.rs1) & args.imm; } else // unrecognized { value = 0; } WriteReg(args.rd, value); } else if (opcode == 0x33) // arithmetic { RType args = new RType(instr); int value; int rs1 = ReadReg(args.rs1); int rs2 = ReadReg(args.rs2); if (args.funct3 == 0x0) { if (args.funct7 == 0x00) // ADD { value = rs1 + rs2; } else if (args.funct7 == 0x20) // SUB { value = rs1 - rs2; } else // unrecognized { value = 0; } } else if (args.funct3 == 0x1) { if (args.funct7 == 0x00) // SLL { value = rs1 << rs2; } else { value = 0; } } else if (args.funct3 == 0x2) { if (args.funct7 == 0x00) // SLT { value = (rs1 < rs2) ? 1 : 0; } else { value = 0; } } else if (args.funct3 == 0x3) { if (args.funct7 == 0x00) // SLTU { value = (((uint)rs1) < ((uint)rs2)) ? 1 : 0; } else { value = 0; } } else if (args.funct3 == 0x4) { if (args.funct7 == 0x00) // XOR { value = rs1 ^ rs2; } else { value = 0; } } else if (args.funct3 == 0x5) { if (args.funct7 == 0x00) // SRL { value = (int)(((uint)rs1) >> rs2); } else if (args.funct7 == 0x20) // SRA { value = rs1 >> rs2; } else { value = 0; } } else if (args.funct3 == 0x6) { if (args.funct7 == 0x00) // OR { value = rs1 | rs2; } else { value = 0; } } else if (args.funct3 == 0x7) { if (args.funct7 == 0x00) // AND { value = rs1 & rs2; } else { value = 0; } } else { value = 0; } WriteReg(args.rd, value); } else if (opcode == 0x0f) // fence { // unimplemented } else if (opcode == 0x73) // environment { IType args = new IType(instr); if (args.funct3 == 0x0) // system { if (args.imm == 0x000) { if (instr == 0x00000073) // ECALL { // unimplemented } else { // unrecognized } } else if (args.imm == 0x001) { if (instr == 0x00100073) // EBREAK { isRunning = false; } else { // unrecognized } } else { // unrecognized } } else if (args.funct3 == 0x1) // CSRRW { WriteReg(args.imm, controller.ReadCSR(args.rd)); controller.WriteCSR(args.imm, ReadReg(args.rs1)); } else if (args.funct3 == 0x2) // CSRRS { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = ReadReg(args.rs1); controller.WriteCSR(args.imm, mask | csr); } else if (args.funct3 == 0x3) // CSRRC { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = ~ReadReg(args.rs1); controller.WriteCSR(args.imm, mask & csr); } else if (args.funct3 == 0x5) // CSRRWI { WriteReg(args.imm, controller.ReadCSR(args.rd)); controller.WriteCSR(args.imm, args.rs1); } else if (args.funct3 == 0x6) // CSRRSI { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = args.rs1; controller.WriteCSR(args.imm, mask | csr); } else if (args.funct3 == 0x7) // CSRRCI { int csr = controller.ReadCSR(args.rd); WriteReg(args.imm, csr); int mask = ~args.rs1; controller.WriteCSR(args.imm, mask & csr); } else { // unrecognized } } else // unrecognized { if (instr != 0) // nop { MonoBehaviour.print("Unrecognized instruction:"); MonoBehaviour.print(System.Convert.ToString(instr, 16)); } } pc++; }
/// <summary> /// Create a move instruction. /// </summary> private static Instruction CreateMove(Register from, Register to, RType type) { if (from == null) throw new ArgumentNullException("from"); if (to == null) throw new ArgumentNullException("to"); OpCodes opcode; switch (type) { case RType.Value: opcode = OpCodes.Move; break; case RType.Wide: opcode = OpCodes.Move_wide; break; case RType.Wide2: return new Instruction(OpCodes.Nop); case RType.Object: opcode = OpCodes.Move_object; break; default: throw new ArgumentException("Unknown type: " + (int)type); } return new Instruction(opcode, to, @from); }
/// <summary> /// Is this low register currently available for the given type of register? /// </summary> public bool IsFreeFor(RType type) { if (OriginalRegister != null) return false; if (type == RType.Wide) return (next != null) && (next.OriginalRegister == null); return true; }
/// <summary> /// Default ctor /// </summary> public Register(int index, RCategory category, RType type) { this.index = index; this.category = category; this.type = type; }
public Relationship(RType type, string id, string target) { Id = id; Target = target; Type = type; }