当前位置: 首页>>代码示例>>C#>>正文


C# Core.ProcedureSignature类代码示例

本文整理汇总了C#中Reko.Core.ProcedureSignature的典型用法代码示例。如果您正苦于以下问题:C# ProcedureSignature类的具体用法?C# ProcedureSignature怎么用?C# ProcedureSignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ProcedureSignature类属于Reko.Core命名空间,在下文中一共展示了ProcedureSignature类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

        public override ProcedureSignature Deserialize(SerializedSignature ss, Frame frame)
        {
            if (ss == null)
                return null;
            this.argser = new ArgumentSerializer(this, Architecture, frame, ss.Convention);
            Identifier ret = null;
            int fpuDelta = FpuStackOffset;

            FpuStackOffset = 0;
            if (ss.ReturnValue != null)
            {
                ret = argser.DeserializeReturnValue(ss.ReturnValue);
                fpuDelta += FpuStackOffset;
            }

            FpuStackOffset = 0;
            var args = new List<Identifier>();
            if (ss.Arguments != null)
            {
                for (int iArg = 0; iArg < ss.Arguments.Length; ++iArg)
                {
                    var sArg = ss.Arguments[iArg];
                    var arg = DeserializeArgument(sArg, iArg, ss.Convention);
                    args.Add(arg);
                }
                fpuDelta -= FpuStackOffset;
            }
            FpuStackOffset = fpuDelta;

            var sig = new ProcedureSignature(ret, args.ToArray());
            ApplyConvention(ss, sig);
            return sig;
        }
开发者ID:gh0std4ncer,项目名称:reko,代码行数:33,代码来源:X86ProcedureSerializer.cs

示例2: ApplySignatureToProcedure

        public void ApplySignatureToProcedure(Address addr, ProcedureSignature sig, Procedure proc)
        {
            proc.Signature = sig;

            int i = 0;
            var stmts = proc.EntryBlock.Succ[0].Statements;
            var linAddr = addr.ToLinear();
            foreach (var param in sig.Parameters)
            {
                var starg = param.Storage as StackArgumentStorage;
                if (starg != null)
                {
                    proc.Frame.EnsureStackArgument(
                        starg.StackOffset + sig.ReturnAddressOnStack,
                        param.DataType,
                        param.Name);
                }
                else
                {
                    var paramId = proc.Frame.EnsureIdentifier(param.Storage);
                    paramId.DataType = param.DataType;

                    // Need to take an extra step with parameters being passed
                    // in a register. It's perfectly possible for a user to 
                    // create a variable which they want to call 'r2' but which
                    // the calling convention of the machine wants to call 'r1'.
                    // To avoid this, we create a temporary identifier for 
                    // the formal parameter, and inject an copy statement in the
                    // entry block that moves the parameter value into the 
                    // register.
                    stmts.Insert(i, linAddr, NewMethod(param, paramId));
                    ++i;
                }
            }
        }
开发者ID:gitter-badger,项目名称:reko,代码行数:35,代码来源:UserSignatureBuilder.cs

示例3: Deserialize

        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;
        }
开发者ID:gitter-badger,项目名称:reko,代码行数:26,代码来源:M68kProcedureSerializer.cs

示例4: ApplyConvention

 public void ApplyConvention(SerializedSignature ssig, ProcedureSignature sig)
 {
     string d = ssig.Convention;
     if (d == null || d.Length == 0)
         d = DefaultConvention;
     sig.StackDelta = 0;
     sig.FpuStackDelta = FpuStackOffset;
 }
开发者ID:feelworld,项目名称:reko,代码行数:8,代码来源:X86_64ProcedureSerializer.cs

示例5: ApplyConvention

 public void ApplyConvention(SerializedSignature ssig, ProcedureSignature sig)
 {
     string d = ssig.Convention;
     if (d == null || d.Length == 0)
         d = DefaultConvention;
     if (d == "stdapi" || d == "__stdcall" || d == "pascal")
         sig.StackDelta = StackOffset;
     sig.FpuStackDelta = FpuStackOffset;
 }
开发者ID:feelworld,项目名称:reko,代码行数:9,代码来源:X86ProcedureSerializer.cs

示例6: ApplyConvention

 public void ApplyConvention(SerializedSignature ssig, ProcedureSignature sig)
 {
     string d = ssig.Convention;
     if (d == null || d.Length == 0)
         d = DefaultConvention;
     sig.StackDelta = Architecture.PointerType.Size;  //$BUG: far/near pointers?
     if (d == "stdapi" || d == "__stdcall" || d == "pascal")
         sig.StackDelta += StackOffset;
     sig.FpuStackDelta = FpuStackOffset;
     sig.ReturnAddressOnStack = Architecture.PointerType.Size;   //$BUG: x86 real mode?
 }
开发者ID:nemerle,项目名称:reko,代码行数:11,代码来源:X86ProcedureSerializer.cs

示例7: PsigValidArguments

		public void PsigValidArguments()
		{
			Identifier arg = new Identifier(Registers.eax.Name, Registers.eax.DataType, Registers.eax);
			ProcedureSignature sig = new ProcedureSignature(null, new Identifier[] { arg });
			Assert.IsTrue(sig.ParametersValid);

			sig = new ProcedureSignature(arg, null);
			Assert.IsTrue(sig.ParametersValid);

			sig = new ProcedureSignature();
			Assert.IsFalse(sig.ParametersValid);
		}
开发者ID:gitter-badger,项目名称:reko,代码行数:12,代码来源:ProcedureSignatureTests.cs

示例8: ApplicationBuilderTests

 public ApplicationBuilderTests()
 {
     arch = new IntelArchitecture(ProcessorMode.Protected32);
     frame = arch.CreateFrame();
     ret = frame.EnsureRegister(Registers.eax);
     arg04 = new Identifier("arg04",   PrimitiveType.Word32, new StackArgumentStorage(4, PrimitiveType.Word32));
     arg08 = new Identifier("arg08",   PrimitiveType.Word16, new StackArgumentStorage(8, PrimitiveType.Word16));
     arg0C = new Identifier("arg0C",   PrimitiveType.Byte, new StackArgumentStorage(0x0C, PrimitiveType.Byte));
     regOut = new Identifier("edxOut", PrimitiveType.Word32, new OutArgumentStorage(frame.EnsureRegister(Registers.edx)));
     sig = new ProcedureSignature(ret,
         new Identifier[] { arg04, arg08, arg0C, regOut });
 }
开发者ID:nemerle,项目名称:reko,代码行数:12,代码来源:ApplicationBuilderTests.cs

示例9: RewriteFormals

 private void RewriteFormals(ProcedureSignature sig)
 {
     if (sig.ReturnValue != null)
         sig.ReturnValue.DataType = sig.ReturnValue.TypeVariable.DataType;
     if (sig.Parameters != null)
     {
         foreach (Identifier formalArg in sig.Parameters)
         {
             if (formalArg.TypeVariable != null)
                 formalArg.DataType = formalArg.TypeVariable.DataType;
         }
     }
 }
开发者ID:gitter-badger,项目名称:reko,代码行数:13,代码来源:TypedExpressionRewriter.cs

示例10: EnsureSignatureTypeVariables

 public void EnsureSignatureTypeVariables(ProcedureSignature signature)
 {
     if (signature == null || !signature.ParametersValid)
         return;
     if (signature.ReturnValue != null)
     {
         signature.ReturnValue.Accept(this);
     }
     foreach (var param in signature.Parameters)
     {
         param.Accept(this);
     }
 }
开发者ID:gitter-badger,项目名称:reko,代码行数:13,代码来源:EquivalenceClassBuilder.cs

示例11: PpcPs_Serialize

        public void PpcPs_Serialize()
        {
            Given_ProcedureSerializer();
            ProcedureSignature sig = new ProcedureSignature(
                new Identifier("qax", PrimitiveType.Word32, arch.Registers[3]),
                new Identifier[] {
                    new Identifier("qbx", PrimitiveType.Word32, arch.Registers[3])
                });

            SerializedSignature ssig = ser.Serialize(sig);
            Assert.IsNotNull(ssig.ReturnValue);
            Assert.AreEqual("qax", ssig.ReturnValue.Name);
            Register_v1 sreg = (Register_v1)ssig.ReturnValue.Kind;
            Assert.AreEqual("r3", sreg.Name);
        }
开发者ID:melbcat,项目名称:reko,代码行数:15,代码来源:PowerPcProcedureSerializerTests.cs

示例12: Test

 public void Test()
 {
     Given_ProcedureSerializer("stdapi");
     ProcedureSignature sig = new ProcedureSignature(
         new Identifier("qax", PrimitiveType.Word32, Registers.eax),
         new Identifier[] {
             new Identifier("qbx", PrimitiveType.Word32, Registers.ebx)
         });
         
     SerializedSignature ssig = ser.Serialize(sig);
     Assert.IsNotNull(ssig.ReturnValue);
     Assert.AreEqual("qax", ssig.ReturnValue.Name);
     Register_v1 sreg = (Register_v1) ssig.ReturnValue.Kind;
     Assert.AreEqual("eax", sreg.Name);
 }
开发者ID:melbcat,项目名称:reko,代码行数:15,代码来源:X86ProcedureSerializerTests.cs

示例13: ExtpBind

 public void ExtpBind()
 {
     var sig = new ProcedureSignature(
         new Identifier(Registers.ax.Name, PrimitiveType.Word16, Registers.ax),
         new Identifier [] {
             new Identifier(Registers.bx.Name, PrimitiveType.Word16, Registers.bx),
             new Identifier(Registers.cl.Name, PrimitiveType.Byte, Registers.cl) } );
     var ep = new ExternalProcedure("foo", sig);
     Assert.AreEqual("Register word16 foo(Register word16 bx, Register byte cl)", ep.ToString());
     var fn = new ProcedureConstant(PrimitiveType.Pointer32, ep);
     var arch = new FakeArchitecture();
     var frame = arch.CreateFrame();
     var ab = new ApplicationBuilder(new FakeArchitecture(), frame, new CallSite(0, 0), fn, ep.Signature, false);
     var instr = ab.CreateInstruction();
     Assert.AreEqual("ax = foo(bx, cl)", instr.ToString());
 }
开发者ID:nemerle,项目名称:reko,代码行数:16,代码来源:ExternalProcedureTest.cs

示例14: SvAmdPs_Serialize

        public void SvAmdPs_Serialize()
        {
            Given_ProcedureSerializer();

            mr.ReplayAll();

            var sig = new ProcedureSignature(
                new Identifier("rbx", PrimitiveType.Word32, arch.GetRegister("rbx")),
                new Identifier[] {
                    new Identifier("rbx", PrimitiveType.Word32, arch.GetRegister("rbx"))
                });

            SerializedSignature ssig = ser.Serialize(sig);
            Assert.IsNotNull(ssig.ReturnValue);
            Assert.AreEqual("rbx", ssig.ReturnValue.Name);
            Register_v1 sreg = (Register_v1)ssig.ReturnValue.Kind;
            Assert.AreEqual("rbx", sreg.Name);
        }
开发者ID:gitter-badger,项目名称:reko,代码行数:18,代码来源:X86_64ProcedureSerializerTests.cs

示例15: BindArguments

 public override List<Expression> BindArguments(Frame frame, ProcedureSignature sigCallee)
 {
     var actuals = new List<Expression>();
     int i;
     for (i = 0; i < sigCallee.Parameters.Length-1; ++i)
     {
         var formalArg = sigCallee.Parameters[i];
         var actualArg = formalArg.Storage.Accept(this);
         if (formalArg.Storage is OutArgumentStorage)
         {
             actuals.Add(new OutArgument(frame.FramePointer.DataType, actualArg));
         }
         else
         {
             actuals.Add(actualArg);
         }
     }
     return actuals;
 }
开发者ID:melbcat,项目名称:reko,代码行数:19,代码来源:PrintfApplicationBuilder.cs


注:本文中的Reko.Core.ProcedureSignature类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。