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


C# Compiler.Variable类代码示例

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


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


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