當前位置: 首頁>>代碼示例>>C#>>正文


C# Resolver.SetCurClass方法代碼示例

本文整理匯總了C#中System.Resolver.SetCurClass方法的典型用法代碼示例。如果您正苦於以下問題:C# Resolver.SetCurClass方法的具體用法?C# Resolver.SetCurClass怎麽用?C# Resolver.SetCurClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Resolver的用法示例。


在下文中一共展示了Resolver.SetCurClass方法的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.SetCurClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。