當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。