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


C# Compiler.Make方法代码示例

本文整理汇总了C#中Compiler.Make方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.Make方法的具体用法?C# Compiler.Make怎么用?C# Compiler.Make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Compiler的用法示例。


在下文中一共展示了Compiler.Make方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMethod

 private IntPtr CreateMethod(IntPtr stub)
 {
     Compiler compiler = new Compiler();
     compiler.NewFunction(CallingConvention.Default, typeof(Func<int>));
     GPVar x = compiler.NewGP(VariableType.INT32);
     compiler.Mov(x, 2);
     compiler.Ret(x);
     compiler.EndFunction();
     return compiler.Make();
 }
开发者ID:modulexcite,项目名称:nasmjit,代码行数:10,代码来源:TestMethodStub.cs

示例2: Main

        private static void Main(string[] args)
        {
            TestExceptionHandling test = new TestExceptionHandling();
            test.RunTest();

            Compiler compiler = new Compiler();
            CallingConvention callingConvention = CallingConvention.Default;
            compiler.NewFunction(callingConvention, typeof(Func<int>));
            GPVar var = compiler.NewGP();
            compiler.Mov(var, 3);
            compiler.Ret(var);
            compiler.EndFunction();
            IntPtr ptr = compiler.Make();
            Method1 method = (Method1)Marshal.GetDelegateForFunctionPointer(ptr, typeof(Method1));
            int result = method();
            Console.WriteLine(result);

            IntPtr method2Ptr = CreateMethodStub();
            TestMethod method2 = (TestMethod)Marshal.GetDelegateForFunctionPointer(method2Ptr, typeof(TestMethod));
            Console.WriteLine(method2());
        }
开发者ID:modulexcite,项目名称:nasmjit,代码行数:21,代码来源:Program.cs

示例3: BuildCpuIdFunction

        private static CpuIdMethod BuildCpuIdFunction()
        {
            Compiler compiler = new Compiler();

            compiler.NewFunction(CallingConvention.Default, typeof(Action<IntPtr, IntPtr, IntPtr, IntPtr>));
            compiler.Function.SetHint(FunctionHints.Naked, true);

            GPVar eaxPtr = compiler.ArgGP(0);
            GPVar ebxPtr = compiler.ArgGP(1);
            GPVar ecxPtr = compiler.ArgGP(2);
            GPVar edxPtr = compiler.ArgGP(3);

            GPVar eax = compiler.NewGP();
            GPVar ebx = compiler.NewGP();
            GPVar ecx = compiler.NewGP();
            GPVar edx = compiler.NewGP();

            compiler.Mov(eax, Mem.dword_ptr(eaxPtr));
            compiler.Cpuid(eax, ebx, ecx, edx);
            compiler.Mov(Mem.dword_ptr(eaxPtr), eax);
            compiler.Mov(Mem.dword_ptr(ebxPtr), ebx);
            compiler.Mov(Mem.dword_ptr(ecxPtr), ecx);
            compiler.Mov(Mem.dword_ptr(edxPtr), edx);

            compiler.Ret();
            compiler.EndFunction();
            CpuIdMethod cpuId = (CpuIdMethod)Marshal.GetDelegateForFunctionPointer(compiler.Make(), typeof(CpuIdMethod));

            return cpuId;
        }
开发者ID:modulexcite,项目名称:nasmjit,代码行数:30,代码来源:CpuInfo.cs


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