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


C# Resolver.ResolveMethodBody方法代码示例

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


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

示例1: EvalTacticApplication

    private MemberDecl EvalTacticApplication(MemberDecl target, Resolver r) {
      Contract.Requires(tcce.NonNull(target));
      // initialize new stack for variables
      _frame = new Stack<Dictionary<IVariable, Type>>();

      var method = target as Method;
      if(method != null) {
        _state.SetTopLevelClass(method.EnclosingClass?.Name);
        _state.TargetMethod = target;
        var dict = method.Ins.Concat(method.Outs)
          .ToDictionary<IVariable, IVariable, Type>(item => item, item => item.Type);
        _frame.Push(dict);

        var pre_res = _resultList.Keys.Copy();

        SearchBlockStmt(method.Body);
        dict = _frame.Pop();
        // sanity check
        Contract.Assert(_frame.Count == 0);

        var new_rets = _resultList.Where(kvp => !pre_res.Contains(kvp.Key)).ToDictionary(i => i.Key, i => i.Value);
        Contract.Assert(new_rets.Count != 0);
        var body = Util.InsertCode(_state, new_rets);
        method.Body.Body.Clear();
        if(body != null)
          method.Body.Body.AddRange(body.Body);

        // use the original resolver of the resoved program, as it contains all the necessary type info
        //TODO: how about pre and post ??
        method.CallsTactic = false; // set the tactic call lable to be false, no actual consequence
        // set the current class in the resolver, so that it can refer to the memberdecl correctly
        r.SetCurClass(method.EnclosingClass as ClassDecl);
        r.ResolveMethodBody(method);
        //Console.WriteLine("Errors: " + _program.reporter.Count(ErrorLevel.Error));

      }
      return method;
    }
开发者ID:ggrov,项目名称:tacny,代码行数:38,代码来源:Interpreter.cs


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