• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Compiler.Variable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GenerateForLoop

        internal static Statement GenerateForLoop(Variable loopVariable, Expression lowerBound, Expression upperBound, Statement body)
        {
            Block bodyAsBlock = body as Block ?? new Block(new StatementList(body));
            Block init = new Block(new StatementList(2));
            Block increment = new Block(new StatementList(1));
            Block test = new Block(new StatementList(new Branch(
              new BinaryExpression(loopVariable, upperBound, NodeType.Lt), bodyAsBlock))); //, false, true, false)));

            init.Statements.Add(new AssignmentStatement(loopVariable, lowerBound));
            init.Statements.Add(new Branch(null, test));

            increment.Statements.Add(new AssignmentStatement(loopVariable, new BinaryExpression(loopVariable, Literal.Int32One, NodeType.Add)));

            Block forLoop = new Block(new StatementList(4));
            forLoop.Statements.Add(init);
            forLoop.Statements.Add(bodyAsBlock);
            forLoop.Statements.Add(increment);
            forLoop.Statements.Add(test);
            return forLoop;
        }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:20,代码来源:RewriteUtils.cs


示例2: SetToFalse

 public void SetToFalse(Variable v) {
   this.egraph[v] = this.False;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:3,代码来源:ExposureAnalysis.cs


示例3: Name

 public static string Name(Variable v) 
 {
   Identifier name = v.Name;
   string nstr = (name == null)?"":name.Name;
   return String.Format("{0}({1})", nstr, v.UniqueKey);
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:6,代码来源:CciUtils.cs


示例4: VisitSizeOf

 protected override object VisitSizeOf(Variable dest, TypeNode value_type, Statement stat, object arg) {
   ExposureState estate=(ExposureState)arg; 
   estate.AssignNonPointer(dest);
   return arg;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:5,代码来源:ExposureAnalysis.cs


示例5: VisitBinaryOperator

    protected override object VisitBinaryOperator(NodeType op, Variable dest, Variable operand1, Variable operand2, Statement stat, object arg) {
      ExposureState estate=(ExposureState)arg; 

//      estate.AssignBinary(dest, op, operand1, operand2);

      return arg;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:7,代码来源:ExposureAnalysis.cs


示例6: VisitReturn

    protected override object VisitReturn(Variable var, Statement stat, object arg) {
      ExposureState estate=(ExposureState)arg;

      // TODO: see if returned value is supposed to be exposed or not and then what do we know about it?
      return arg;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:6,代码来源:ExposureAnalysis.cs


示例7: VisitLoadField

    protected override object VisitLoadField(Variable dest, Variable source, Field field, Statement stat, object arg) {
      ExposureState estate=(ExposureState)arg;

      // Check the receiver here only if one needs to be unpacked for read access
      //CheckReceiver(stat,source,estate);

      return arg;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:8,代码来源:ExposureAnalysis.cs


示例8: VisitCall

    protected override object VisitCall(Variable dest, Variable receiver, Method callee, ExpressionList arguments, bool virtcall, Statement stat, object arg) {
      ExposureState estate=(ExposureState)arg;

      if (callee.CciKind == Cci.CciMemberKind.FrameGuardGetter){
        // associate dest with receiver, because unpack is going to happen with dest as receiver
        estate.AssignFrameFor(dest,receiver,callee.DeclaringType); // receiver could be a subtype of the type that the frame guard is for
      }else if (callee == UnpackMethod){
        if(estate.IsFrameExposable(receiver)) {
          // BUGBUG: Using CopyVariable encodes the assumption that StartWritingTransitively returns itself!!! It may not!
          estate.CopyVariable(receiver,dest);
          estate.AssignFrameForExposed(dest);
        }else{
          TypeNode t = estate.LowerBoundOfObjectPointedToByFrame(receiver);
          if (t == null){ // BUGBUG: is this the same as it being Top?
            HandleError(stat, stat, Error.DontKnowIfCanExposeObject);
          }else{
            HandleError(stat, stat, Error.ExposingExposedObject);
          }
          return null;
        }
      }else if (callee == PackMethod){
        estate.AssignFrameForNotExposed(receiver);
      }else if (callee == IsExposableMethod){
        estate.AssignFunctionLink(ExposureState.EqIsExposableId,dest,receiver);
      }else if (callee == IsExposedMethod){
        estate.AssignEqIsExposed(dest,receiver);
      }else if (callee == AssertMethod){
        Variable v = arguments[0] as Variable;
        if (v != null && estate.IsFalse(v))
          return null;
      }

      // Push possible exceptions to handlers.
      for(int i=0;i<callee.Contract.Ensures.Count;i++){
        EnsuresExceptional e=callee.Contract.Ensures[i] as EnsuresExceptional;
        if(e!=null){
          ExposureState newnn=new ExposureState(estate);
          newnn.currentException=e.Type;
          ExposureChecker.PushExceptionState(ExposureChecker.currBlock,newnn);
        }
      }

      return arg;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:44,代码来源:ExposureAnalysis.cs


示例9: AssignFrameForNotExposed

 public void AssignFrameForNotExposed(Variable guardVariable){
   ISymValue guard = this.egraph[guardVariable];
   ISymValue guardTypeObject = this.egraph[StaticTypeOf,guard];
   Lattice.AVal guardsType = (Lattice.AVal)this.egraph[guardTypeObject];
   ISymValue guardedObject = this.egraph[FrameFor, guard];
   this.egraph[guardedObject] = guardsType;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:7,代码来源:ExposureAnalysis.cs


示例10: IsFrameExposable

 public bool IsFrameExposable(Variable guardVariable){
   ISymValue guard = this.egraph[guardVariable];
   ISymValue guardedObject = this.egraph[FrameFor, guard];
   ISymValue guardTypeObject = this.egraph[StaticTypeOf,guard];
   Lattice.AVal guardsType = (Lattice.AVal)this.egraph[guardTypeObject];
   Lattice.AVal guardedObjectsType = (Lattice.AVal)this.egraph[guardedObject];
   return guardsType.lowerBound == guardedObjectsType.lowerBound;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:8,代码来源:ExposureAnalysis.cs


示例11: AssignFrameForExposable

 public void AssignFrameForExposable(Variable guardVariable){
   ISymValue guard = this.egraph[guardVariable];
   this.AssignFrameForExposable(guard);
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:4,代码来源:ExposureAnalysis.cs


示例12: AssignFrameFor

 public void AssignFrameFor(Variable dest, Variable source, TypeNode t) {
   ISymValue guard = this.egraph.FreshSymbol();
   ISymValue guardedObject = this.egraph[source];
   this.egraph[dest] = guard;
   this.egraph[FrameFor, guard] = guardedObject;
   ISymValue fresh = this.egraph.FreshSymbol();
   this.egraph[fresh] = new Lattice.AVal(t,t);
   this.egraph[StaticTypeOf, guard] = fresh;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:9,代码来源:ExposureAnalysis.cs


示例13: CopyVariable

 public void CopyVariable(Variable source, Variable dest) {
   this.egraph[dest] = this.egraph[source];
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:3,代码来源:ExposureAnalysis.cs


示例14: AssignNonPointer

 public void AssignNonPointer(Variable v) {
   this.egraph.Eliminate(v);
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:3,代码来源:ExposureAnalysis.cs


示例15: IsFalse

 public bool IsFalse(Variable v){
   return this.egraph[v] == this.False;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:3,代码来源:ExposureAnalysis.cs


示例16: VisitLoadConstant

    protected override object VisitLoadConstant(Variable dest, Literal source, Statement stat, object arg) 
    {
      ExposureState estate=(ExposureState)arg;

      if (source == Literal.False){
        estate.SetToFalse(dest);
      }

      return arg;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:10,代码来源:ExposureAnalysis.cs


示例17: VisitCastClass

    /// <summary>
    /// Note: casts don't require a non-null argument. null value casts always succeed.
    /// </summary>
    protected override object VisitCastClass(Variable dest, TypeNode type, Variable source, Statement stat, object arg) {
      ExposureState estate=(ExposureState)arg;

      // acts like a copy retaining null status
      estate.CopyVariable(source, dest);
      return arg;
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:10,代码来源:ExposureAnalysis.cs


示例18: AssignEqIsExposed

 public void AssignEqIsExposed(Variable dest, Variable operand) {
   ISymValue opval = this.egraph[operand];
   ISymValue sv = this.egraph.FreshSymbol();
   this.egraph[dest] = sv; // ?? Ask Manuel: Should it be the sv' that dest maps to that sv should be mapped to here?
   this.egraph[EqIsExposedId, opval] = sv;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:6,代码来源:ExposureAnalysis.cs


示例19: VisitConstrainedCall

    protected override object VisitConstrainedCall(Variable dest, Variable receiver, Method callee, ExpressionList arguments, TypeNode constraint, Statement stat, object arg) {
      Reference rtype = receiver.Type as Reference;
      if (rtype != null && rtype.ElementType != null && !rtype.ElementType.IsValueType) {
        // instance could be a reference type that could be null.

        // BUGBUG: when we track address of, we need to check here that target is indeed non-null
      }
      return VisitCall(dest, receiver, callee, arguments, true, stat, arg);
    }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:9,代码来源:ExposureAnalysis.cs


示例20: AssignFunctionLink

 public void AssignFunctionLink(Identifier func, Variable dest, Variable operand) {
   ISymValue opval = this.egraph[operand];
   ISymValue sv = this.egraph.FreshSymbol();
   this.egraph[dest] = sv; // ?? Ask Manuel: Should it be the sv' that dest maps to that sv should be mapped to here?
   this.egraph[func, opval] = sv;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:6,代码来源:ExposureAnalysis.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ComponentModel.AsyncCompletedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Compiler.TypeNode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap