public ProcedureSignature Deserialize(SerializedSignature ss, Frame frame) { ArgumentSerializer argser = new ArgumentSerializer(this, arch, frame); Identifier ret = null; if (ss.ReturnValue != null) { ret = argser.Deserialize(ss.ReturnValue); } ArrayList args = new ArrayList(); if (ss.Arguments != null) { foreach (SerializedArgument arg in ss.Arguments) { args.Add(argser.Deserialize(arg)); } } ProcedureSignature sig = new ProcedureSignature( ret, (Identifier [])args.ToArray(typeof(Identifier))); ApplyConvention(ss, sig); return(sig); }
/// <summary> /// Deserializes an argument. /// </summary> /// <param name="arg"></param> /// <param name="idx"></param> /// <param name="convention"></param> /// <returns></returns> public Identifier DeserializeArgument(Argument_v1 arg, int idx, string convention) { if (arg.Kind != null) { return(argser.Deserialize(arg, arg.Kind)); } if (convention == null) { return(argser.Deserialize(arg, new StackVariable_v1())); } switch (convention) { case "": case "stdapi": case "__cdecl": case "__stdcall": case "pascal": return(argser.Deserialize(arg, new StackVariable_v1 { })); case "__thiscall": if (idx == 0) { return(argser.Deserialize(arg, new Register_v1("ecx"))); } else { return(argser.Deserialize(arg, new StackVariable_v1())); } } throw new NotSupportedException(string.Format("Unsupported calling convention '{0}'.", convention)); }
public override ProcedureSignature Deserialize(SerializedSignature ss, Frame frame) { if (ss == null) { return(null); } var argser = new ArgumentSerializer(this, Architecture, frame, ss.Convention); Identifier ret = null; if (ss.ReturnValue != null) { ret = argser.DeserializeReturnValue(ss.ReturnValue); } var args = new List <Identifier>(); if (ss.Arguments != null) { for (int iArg = 0; iArg < ss.Arguments.Length; ++iArg) { var sArg = ss.Arguments[iArg]; Identifier arg = argser.Deserialize(sArg); args.Add(arg); } } var sig = new ProcedureSignature(ret, args.ToArray()); return(sig); }
public void Boolean_property_with_no_value_is_set_to_true_by_default() { var serializer = new ArgumentSerializer(); var result = serializer.Deserialize<TestArgs1>(@"-switch"); Assert.IsNotNull(result); Assert.IsTrue(result.Switch); }
public void Filename() { var serializer = new ArgumentSerializer(); var result = serializer.Deserialize<TestArgs1>(@"-switch -genericstring=blah C:\filename.txt"); Assert.IsNotNull(result); Assert.IsTrue(result.Switch); Assert.AreEqual("blah", result.GenericString); }
public void ArgSer_DeserializeRegister() { Register_v1 reg = new Register_v1("eax"); Argument_v1 arg = new Argument_v1 { Name = "eax", Kind = reg, }; Identifier id = argser.Deserialize(arg); Assert.AreEqual("eax", id.Name); Assert.AreEqual(32, id.DataType.BitSize); }
public void PCEFromClientCall() { string filePath = "C:\\workspace\\FX_Project\\MTM_test\\strip_test\\Strip2\\xxx.xml"; string outPath = "C:\\workspace\\FX_Project\\MTM_test\\strip_test\\Strip2\\blob.xml"; string result = null; ArgumentContainer <string, object> argumentList = new ArgumentContainer <string, object>(); try { //deserialize from file argumentList = ArgumentSerializer.Deserialize(LoadXMLFileToString(filePath)); var settleDates = ArrayOrItemToList <DateTime>((Array)argumentList["SettleDate"]); var recAmounts = ArrayOrItemToList <decimal>((Array)argumentList["RecAmount"]); var recCurrencies = ArrayOrItemToList <string>((Array)argumentList["RecCurrency"]); var payAmounts = ArrayOrItemToList <decimal>((Array)argumentList["PayAmount"]); var payCurrencies = ArrayOrItemToList <string>((Array)argumentList["PayCurrency"]); DateTime evaluationDate = (DateTime)argumentList["EvaluationDate"]; String pceCalculationCurrency = (string)argumentList["PCECalculationCurrency"]; ITrade[] trades = ToMultipleFxForwardTrades(settleDates.ToArray(), recAmounts.ToArray(), recCurrencies.ToArray(), payAmounts.ToArray(), payCurrencies.ToArray()); result = BrTradeBlobReaderHelper.SaveTradeBlob(trades); //save result //write output using (FileStream fs = new FileStream(outPath, FileMode.Create, FileAccess.Write)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(result); } } } catch (Exception e) { //do nothing } Assert.IsTrue(true); }
public Identifier DeserializeArgument(Argument_v1 sArg, int idx, string convention) { if (sArg.Kind != null) { return(argser.Deserialize(sArg, sArg.Kind)); } Identifier arg; var dtArg = sArg.Type.Accept(TypeLoader); var prim = dtArg as PrimitiveType; if (prim != null && prim.Domain == Domain.Real) { if (this.fr >= iregs.Length) { arg = argser.Deserialize(sArg, new StackVariable_v1()); } else { arg = argser.Deserialize(sArg, new Register_v1 { Name = fregs[fr] }); } ++this.fr; return(arg); } if (dtArg.Size <= 8) { if (this.ir >= iregs.Length) { arg = argser.Deserialize(sArg, new StackVariable_v1()); } else { arg = argser.Deserialize(sArg, new Register_v1 { Name = iregs[ir] }); } ++this.ir; return(arg); } int regsNeeded = (dtArg.Size + 7) / 8; if (regsNeeded > 4 || ir + regsNeeded >= iregs.Length) { return(argser.Deserialize(sArg, new StackVariable_v1())); } throw new NotImplementedException(); }
private Identifier DeserializeArgument(ArgumentSerializer argser, Argument_v1 sArg) { Identifier arg; if (sArg.Kind != null) { return(sArg.Kind.Accept(argser)); } var dtArg = sArg.Type.Accept(TypeLoader); var prim = dtArg as PrimitiveType; //if (prim != null && prim.Domain == Domain.Real) //{ // if (this.fr > 8) // { // arg = argser.Deserialize(sArg, new StackVariable_v1()); // } // else // { // arg = argser.Deserialize(sArg, new Register_v1("f" + this.fr)); // ++this.fr; // } // return arg; //} if (dtArg.Size <= 4) { if (this.gr > 3) { arg = argser.Deserialize(sArg, new StackVariable_v1()); } else { arg = argser.Deserialize(sArg, new Register_v1("r" + gr)); ++this.gr; } return(arg); } if (dtArg.Size <= 8) { if (this.gr > 9) { arg = argser.Deserialize(sArg, new StackVariable_v1()); } else { if ((gr & 1) == 0) { ++gr; } arg = argser.Deserialize(sArg, new SerializedSequence { Registers = new Register_v1[] { new Register_v1("r" + gr), new Register_v1("r" + (gr + 1)) } }); gr += 2; } return(arg); } throw new NotImplementedException(); }