Esempio n. 1
0
        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)));
        }
Esempio n. 2
0
        public Identifier Deserialize(SerializedSequence sq)
        {
            var      h = arch.GetRegister(sq.Registers[0].Name.Trim());
            var      t = arch.GetRegister(sq.Registers[1].Name.Trim());
            DataType dt;

            if (this.argCur.Type != null)
            {
                dt = this.argCur.Type.Accept(procSer.TypeLoader);
            }
            else
            {
                dt = PrimitiveType.CreateWord(h.DataType.BitSize + h.DataType.BitSize);
            }
            return(frame.EnsureSequence(h, t, dt));
        }
		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));
		}
Esempio n. 5
0
        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);
            DataType   dt;

            if (this.argCur.Type != null)
            {
                dt = this.argCur.Type.Accept(procSer.TypeLoader);
            }
            else
            {
                dt = PrimitiveType.CreateWord(head.DataType.Size + tail.DataType.Size);
            }
            return(frame.EnsureSequence(head.Storage, tail.Storage, dt));
        }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
 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);
     DataType dt;
     if (this.argCur.Type != null)
         dt = this.argCur.Type.Accept(procSer.TypeLoader);
     else 
         dt = PrimitiveType.CreateWord(head.DataType.Size + tail.DataType.Size);
     return frame.EnsureSequence(head.Storage, tail.Storage, dt);
 }
Esempio n. 9
0
 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));
 }