Пример #1
0
 public Instruction BuildInstruction(Expression callee, CallSite site)
 {
     var pc = callee as ProcedureConstant;
     if (pc != null)
         pc.Procedure.Signature = this.sig;
     var ab = CreateApplicationBuilder(callee, this.sig, site);
     return ab.CreateInstruction();
 }
Пример #2
0
        public void FrBindMixedParameters()
        {
            Frame f = new Frame(PrimitiveType.Word16);
            Identifier ax = f.EnsureRegister(Registers.ax);
            Identifier cx = f.EnsureRegister(Registers.cx);
            int stack = PrimitiveType.Word16.Size;
            Identifier arg1 = f.EnsureStackLocal(-stack, PrimitiveType.Word16);

            ProcedureSignature sig = new ProcedureSignature(
                ax,
                cx,
                new Identifier("arg0", PrimitiveType.Word16, new StackArgumentStorage(0, PrimitiveType.Word16)));

            var cs = new CallSite(stack, 0);
            ProcedureConstant fn = new ProcedureConstant(PrimitiveType.Pointer32, new PseudoProcedure("bar", sig));
            ApplicationBuilder ab = new ApplicationBuilder(arch, f, cs, fn, sig, true);
            Instruction instr = ab.CreateInstruction();
            using (FileUnitTester fut = new FileUnitTester("Core/FrBindMixedParameters.txt"))
            {
                f.Write(fut.TextWriter);
                fut.TextWriter.WriteLine(instr.ToString());
                fut.AssertFilesEqual();
            }
        }
Пример #3
0
 private ApplicationBuilder CreateApplicationBuilder(
     Expression callee,
     FunctionType sig,
     CallSite site)
 {
     var ab = new ApplicationBuilder(
         arch,
         frame,
         site,
         callee,
         sig,
         false);
     return ab;
 }
Пример #4
0
        public PrintfApplicationBuilder(
            IProcessorArchitecture arch, Frame frame, CallSite site, Expression callee, FunctionType sigCallee, bool ensureVariables) :
                    base(arch, frame, site, callee, sigCallee, ensureVariables)
        {

        }
Пример #5
0
        public void AppBld_BindToCallingFrame()
        {
            var caller = new Procedure("caller", new Frame(PrimitiveType.Word16));
            caller.Frame.EnsureStackLocal(-4, PrimitiveType.Word32, "bindToArg04");
            caller.Frame.EnsureStackLocal(-6, PrimitiveType.Word16, "bindToArg02");

            var callee = new Procedure("callee", new  Frame (PrimitiveType.Word16));
            var wArg = callee.Frame.EnsureStackArgument(0, PrimitiveType.Word16);
            var dwArg = callee.Frame.EnsureStackArgument(2, PrimitiveType.Word32);
            callee.Signature = new ProcedureSignature(
                null,
                wArg,
                dwArg);
            var cs = new CallSite(0, 0)
            {
                StackDepthOnEntry = 6
            };
            ab = new ApplicationBuilder(arch, caller.Frame, cs, new ProcedureConstant(PrimitiveType.Pointer32, callee), callee.Signature, true);
            var instr = ab.CreateInstruction();
            Assert.AreEqual("callee(bindToArg02, bindToArg04)", instr.ToString());
        }
Пример #6
0
		public void FrBindStackParameters()
		{
			Frame f = new Frame(PrimitiveType.Word16);
			f.ReturnAddressSize = 4;						// far call.
			int stack = 2;
			Identifier loc02 = f.EnsureStackLocal(-stack, PrimitiveType.Word16, "wLoc02");
			stack += loc02.DataType.Size;
			Identifier loc04 = f.EnsureStackLocal(-stack, PrimitiveType.Word16, "wLoc04");

			ProcedureSignature sig = new ProcedureSignature(
				null, new Identifier[] {
					new Identifier("arg0", PrimitiveType.Word16, new StackArgumentStorage(4, PrimitiveType.Word16)),
					new Identifier("arg1", PrimitiveType.Word16, new StackArgumentStorage(6, PrimitiveType.Word16)) });

			var cs = new CallSite(f.ReturnAddressSize + 2 * 4, 0);
			var fn = new ProcedureConstant(PrimitiveType.Pointer32, new PseudoProcedure("foo", sig));
			ApplicationBuilder ab = new ApplicationBuilder(arch, f, cs, fn, sig, true);
            Instruction instr = ab.CreateInstruction(); 
			using (FileUnitTester fut = new FileUnitTester("Core/FrBindStackParameters.txt"))
			{
				f.Write(fut.TextWriter);
				fut.TextWriter.WriteLine(instr.ToString());
				fut.AssertFilesEqual();
			}
		}