public void SseqBuildSequence() { Frame f = arch.CreateFrame(); Identifier head = f.EnsureRegister(Registers.dx); Identifier tail = f.EnsureRegister(Registers.ax); Identifier seq = f.EnsureSequence(head, tail, PrimitiveType.Word32); SerializedSequence sq = new SerializedSequence((SequenceStorage) seq.Storage); Argument_v1 sa = new Argument_v1(); sa.Kind = sq; SerializedSignature ssig = new SerializedSignature(); ssig.Arguments = new Argument_v1[] { sa }; Given_X86ProcedureSerializer(); ProcedureSignature ps = ser.Deserialize(ssig, f); Assert.AreEqual("void foo(Sequence word32 dx_ax)", ps.ToString("foo")); }
public void SseqCreate() { Identifier head = new Identifier(Registers.dx.Name, Registers.dx.DataType, Registers.dx); Identifier tail = new Identifier(Registers.ax.Name, Registers.ax.DataType, Registers.ax); Identifier seq = new Identifier("dx_ax", PrimitiveType.Word32, new SequenceStorage(head, tail)); SerializedSequence sq = new SerializedSequence((SequenceStorage) seq.Storage); Assert.AreEqual("dx", sq.Registers[0].Name); Assert.AreEqual("ax", sq.Registers[1].Name); XmlSerializer ser = SerializedLibrary.CreateSerializer_v1(sq.GetType()); StringWriter sw = new StringWriter(); XmlTextWriter xml = new XmlTextWriter(sw); xml.Formatting = Formatting.None; ser.Serialize(xml, sq); string s = sw.ToString(); int i = s.IndexOf("<reg"); Assert.AreEqual("<reg>dx</reg><reg>ax</reg>", s.Substring(i, s.IndexOf("</Se") - i)); }
public Identifier Deserialize(SerializedSequence sq) { var h = arch.GetRegister(sq.Registers[0].Name.Trim()); var t = arch.GetRegister(sq.Registers[1].Name.Trim()); Identifier head = frame.EnsureRegister(h); Identifier tail = frame.EnsureRegister(t); return frame.EnsureSequence(head, tail, PrimitiveType.CreateWord(head.DataType.Size + tail.DataType.Size)); }
private Argument_v1 ParseRegisterSequence(RegisterStorage reg, string type) { ++idx; string w2 = GetNextWord(); if (w2 == null) return null; RegisterStorage reg2; if (!arch.TryGetRegister(w2, out reg2)) return null; var seqArgName = reg.Name + "_" + reg2.Name; var seqArgType = new SerializedTypeReference { TypeName = type }; var seqKind = new SerializedSequence(); seqKind.Registers = new Register_v1[]{ new Register_v1(reg.Name), new Register_v1(reg2.Name) }; return new Argument_v1(seqArgName, seqArgType, seqKind, false); }
private Argument_v1 ParseRegisterSequenceWithUnderscore(string w) { string[] subregs = w.Split('_'); var regs = new List<Register_v1>(); foreach (string subReg in subregs) { RegisterStorage r; if (!arch.TryGetRegister(subReg, out r)) return null; regs.Add(new Register_v1(r.Name)); } var seq = new SerializedSequence(); seq.Registers = regs.ToArray(); return new Argument_v1( w, null, seq, true); }