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


C# IDecompiler.ResolveVariableReference方法代码示例

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


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

示例1: Rewrite

            public override bool Rewrite(CodeDescriptor decompilee, MethodBase callee, StackElement[] args, IDecompiler stack, IFunctionBuilder builder)
            {
                var ctx = stack.QueryAttribute<AsyncMethodDecompiler>();
                if (ctx == null)
                    throw new InvalidOperationException("Method must be decompiled using AsyncMethodDecompiler.");
                if (ctx.ImplStyle == EAsyncImplStyle.Sequential)
                    return true;

                var awaiterCallExpr = stack.ResolveVariableReference(stack.CurrentILIndex, args[1].Expr);
                var awaiterCall = awaiterCallExpr as FunctionCall;
                if (awaiterCall != null)
                {
                    var waitObject = awaiterCall.Arguments[0];
                    var asyncCall = waitObject as FunctionCall;
                    if (asyncCall != null)
                    {
                        var cspec = asyncCall.Callee as FunctionSpec;
                        if (cspec != null && 
                            cspec.CILRep != null &&
                            cspec.CILRep.HasCustomOrInjectedAttribute<TickAttribute>())
                        {
                            var si = ctx.ForkNextSI();
                            var pi = new ProceedWithStateInfo()
                            {
                                TargetState = si,
                                TargetWaitState = false,
                                LambdaTransition = false
                            };
                            var fspec = new FunctionSpec(typeof(void))
                            {
                                IntrinsicRep = IntrinsicFunctions.ProceedWithState(pi)
                            };
                            builder.Call(fspec, LiteralReference.CreateConstant(pi));
                            return true;
                        }
                    }
                }

                var awaiter = args[1].Sample;
                var task = ctx.GetTaskFromAwaiter(awaiter);

                if (task != null)
                {
                    if (!task.IsCompleted)
                        throw new InvalidOperationException("Task not completed - what are you awaiting for?");

                    var sin = ctx.ForkNextSI();
                    sin.HasWaitState = true;
                    var jp = new JoinParams()
                    {
                        JoinedTask = task,
                        Continuation = sin
                    };
                    sin.JP = jp;
                    ctx.ImplementJoin(jp, builder, sin);
                }

                return true;
            }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:59,代码来源:AsyncStateMachines.cs

示例2: ImplementAwait

 internal void ImplementAwait(CodeDescriptor decompilee, MethodBase callee, StackElement[] args, IDecompiler stack, IFunctionBuilder builder)
 {
     var awaiterCallExpr = stack.ResolveVariableReference(stack.CurrentILIndex, args[0].Expr);
     var awaiterCall = awaiterCallExpr as FunctionCall;
     if (awaiterCall == null)
         throw new InvalidOperationException("Unable to resolve awaited object.");
     var waitObject = awaiterCall.Arguments[0];
     var awaiterType = args[0].Expr.ResultType.CILType;
     var rw = awaiterType.GetCustomOrInjectedAttribute<RewriteAwait>();
     if (rw == null)
     {
         var fcall = waitObject as FunctionCall;
         if (fcall != null)
         {
             var fspec = fcall.Callee as FunctionSpec;
             if (fspec != null && fspec.CILRep != null)
                 rw = fspec.CILRep.GetCustomOrInjectedAttribute<RewriteAwait>();
         }
     }
     if (rw != null)
         rw.Rewrite(decompilee, waitObject, stack, builder);
     else
         throw new InvalidOperationException("Unable to find await implementor");
 }
开发者ID:venusdharan,项目名称:systemsharp,代码行数:24,代码来源:AsyncStateMachines.cs


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