public static void AssertIs(this ConsistencyState state, ConsistencyState expectedState)
 {
     if (state != expectedState)
     {
         throw Errors.WrongComputedState(expectedState, state);
     }
 }
 public static void AssertIsNot(this ConsistencyState state, ConsistencyState unexpectedState)
 {
     if (state == unexpectedState)
     {
         throw Errors.WrongComputedState(state);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///  Inclusion check for two PointsToAndWriteEffects
        /// </summary>
        /// <param name="ptgWe"></param>

        public override bool Includes(PointsToState cState2)
        {
            bool             includes = base.Includes(cState2);
            ConsistencyState pE       = (ConsistencyState)cState2;

            includes = includes && IncludesConsistency(pE.consistency);
            return(includes);
        }
Exemplo n.º 4
0
        public ConsistencyState(ConsistencyState exp)
            : base(exp)
        {
            this.consistency = new Dictionary <IPTAnalysisNode, AbstractValue>(exp.consistency);


            exposedNodes      = new Set <IPTAnalysisNode>(exp.exposedNodes);
            this.nonNullState = exp.nonNullState;
        }
Exemplo n.º 5
0
        protected override object VisitCall(Variable dest, Variable receiver, Method callee, ExpressionList arguments, bool virtcall, Statement stat, object arg)
        {
            ConsistencyState exp = (ConsistencyState)arg;
            Label            lb  = new Label(stat, exp.Method);

            // Console.Out.WriteLine("Calling: {0}", callee.FullName);

            if (exp.IsUnPackMethod(callee))
            {
                Variable varToExpose = null;
                if (receiver != null)
                {
                    varToExpose = receiver;
                }
                else
                {
                    if (arguments != null && arguments.Count > 0 && arguments[0] is Variable)
                    {
                        varToExpose = (Variable)arguments[0];
                    }
                }
                if (varToExpose != null)
                {
                    exp.ApplyExpose(varToExpose, lb);
                    //
                    if (dest != null)
                    {
                        exp.pointsToGraph.CopyLocVar(dest, varToExpose);
                    }
                }
                return(exp);
            }
            if (exp.IsPackMethod(callee))
            {
                Variable varToExpose = null;
                if (receiver != null)
                {
                    varToExpose = receiver;
                }
                else
                {
                    if (arguments != null && arguments.Count > 0 && arguments[0] is Variable)
                    {
                        varToExpose = (Variable)arguments[0];
                    }
                }
                if (varToExpose != null)
                {
                    exp.ApplyUnExpose(varToExpose, lb);
                }
                return(exp);
            }
            return(base.VisitCall(dest, receiver, callee, arguments, virtcall, stat, arg));
        }
Exemplo n.º 6
0
        /// <summary>
        ///  Join two PointsToAndWriteEffects
        /// </summary>
        /// <param name="ptgWe"></param>
        public override void Join(PointsToState ptg)
        {
            base.Join(ptg);
            if (ptg != null)
            {
                ConsistencyState ptgE = (ConsistencyState)ptg;
                if (consistency != ptgE.consistency)
                {
                    JoinConsistencyNodes(ptgE.consistency);
                }



                //if (exposedNodes != ptgE.exposedNodes)
                //    exposedNodes.AddRange(ptgE.exposedNodes);
            }
        }
Exemplo n.º 7
0
 public static Exception WrongComputedState(ConsistencyState state)
 => new InvalidOperationException(
     $"Wrong Computed.State: {state}.");
Exemplo n.º 8
0
 public static Exception WrongComputedState(
     ConsistencyState expectedState, ConsistencyState state)
 => new InvalidOperationException(
     $"Wrong Computed.State: expected {expectedState}, was {state}.");
Exemplo n.º 9
0
 protected virtual void CheckExposure(ConsistencyState exp, Variable v)
 {
 }
 public static void AssertConsistencyStateIsNot(this IHasConsistencyState hasConsistencyState, ConsistencyState unexpectedState)
 {
     if (hasConsistencyState.ConsistencyState == unexpectedState)
     {
         throw Errors.WrongComputedState(hasConsistencyState.ConsistencyState);
     }
 }
 public static void AssertConsistencyStateIs(this IHasConsistencyState hasConsistencyState, ConsistencyState expectedState)
 {
     if (hasConsistencyState.ConsistencyState != expectedState)
     {
         throw Errors.WrongComputedState(expectedState, hasConsistencyState.ConsistencyState);
     }
 }
 public static bool IsConsistentOrComputing(this ConsistencyState state)
 => state != ConsistencyState.Invalidated;
 public static bool IsConsistent(this ConsistencyState state)
 => state == ConsistencyState.Consistent;
 public static bool IsInvalidated(this ConsistencyState state)
 => state == ConsistencyState.Invalidated;
Exemplo n.º 15
0
 public ConsistencyState(ConsistencyState exp)
     : base(exp)
 {
     this.consistency = new Dictionary<IPTAnalysisNode, AbstractValue>(exp.consistency);
     
     
     exposedNodes = new Set<IPTAnalysisNode>(exp.exposedNodes);
     this.nonNullState = exp.nonNullState;
 }
Exemplo n.º 16
0
 protected virtual void CheckExposure(ConsistencyState exp, Variable v)
 {
     
 }