Пример #1
0
        protected override object VisitSizeOf(Variable dest, TypeNode value_type, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            estate.AssignNonPointer(dest);
            return(arg);
        }
Пример #2
0
        protected override object VisitLoadFieldAddress(Variable dest, Variable source, Field field, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            CheckReceiver(stat, source, estate);
            return(arg);
        }
Пример #3
0
        public void ContractGerms(string germ_id)
        {
            ExposureState exposureState = GetExposureState(germ_id);

            DebugUtil.DevAssert(exposureState == ExposureState.Exposed, "Duplicant is contracting a sickness but was never exposed to it!");
            SetExposureState(germ_id, ExposureState.Contracted);
        }
Пример #4
0
        /// <summary>
        /// Perform 2 checks
        /// 1) array is non-null
        /// 2) if array element type is non-null type, then the new value written must be too.
        /// </summary>
        protected override object VisitStoreElement(Variable dest, Variable index, Variable source, TypeNode elementType, Statement stat, object arg)
        {
            ExposureState estate  = (ExposureState)arg;
            Indexer       indexer = (Indexer)((AssignmentStatement)stat).Target;

            return(arg);
        }
Пример #5
0
        /// <summary>
        /// It split exceptions for current handler and the next chained handler.
        ///
        /// It will:
        ///
        ///   If the exception is completely intercepted by current handler, the
        ///   exception will be consumed.
        ///
        ///   If the exception caught but not completely, both current handler and
        ///   the next handler will take the states.
        ///
        ///   If the exception is irrelevant to current caught, the next handler
        ///   will take over the state. Current handler is then bypassed.
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="currentHandlerState"></param>
        /// <param name="nextHandlerState"></param>
        protected override void SplitExceptions(CfgBlock handler, ref IDataFlowState currentHandlerState, out IDataFlowState nextHandlerState)
        {
            Debug.Assert(currentHandlerState != null, "Internal error in NonNull Analysis");

            ExposureState state = (ExposureState)currentHandlerState;

            if (handler == null || handler.Length == 0)
            {
                nextHandlerState = null;
                return;
            }

            if (handler[0] is Unwind)
            {
                nextHandlerState    = null;
                currentHandlerState = null;
                return;
            }

            Debug.Assert(handler[0] is Catch, "Exception Handler does not starts with Catch");

            Debug.Assert(state.currentException != null, "No current exception to handle");

            Catch c = (Catch)handler[0];

            if (handler.ExceptionHandler != null &&
                !state.currentException.IsAssignableTo(c.Type))
            {
                nextHandlerState = state;;
            }
            else
            {
                nextHandlerState = null;
            }

            // Compute what trickles through to the next handler
            //  and what sticks to this handler.
            if (state.currentException.IsAssignableTo(c.Type))
            {
                // everything sticks
                nextHandlerState = null;
            }
            else if (c.Type.IsAssignableTo(state.currentException))
            {
                // c sticks, rest goes to next handler
                nextHandlerState = state;

                // copy state to modify the currentException
                state = new ExposureState(state);
                state.currentException = c.Type;
                currentHandlerState    = state;
            }
            else
            {
                // nothing stick all goes to next handler
                nextHandlerState    = state;
                currentHandlerState = null;
            }
            return;
        }
Пример #6
0
        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);
        }
Пример #7
0
        protected override object VisitRethrow(Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            ExposureChecker.PushExceptionState(ExposureChecker.currBlock, estate);
            return(null);
        }
Пример #8
0
        private IEnumerator Bop()
        {
            float oldExposure = RenderSettings.skybox.GetFloat("_Exposure");

            ArenaLoaderMod.CurrentSkyboxExposure = oldExposure;
            List <SongCues.Cue> cues = SongCues.I.mCues.cues.ToList();

            for (int i = cues.Count - 1; i >= 0; i--)
            {
                if (cues[i].tick < AudioDriver.I.mCachedTick || cues[i].behavior == Target.TargetBehavior.Dodge)
                {
                    cues.RemoveAt(i);
                }
            }
            ExposureState state = ExposureState.Light;

            while (defaultParams.active)
            {
                if (cues[0].tick <= AudioDriver.I.mCachedTick)
                {
                    if (cues[0].behavior != Target.TargetBehavior.Chain && cues[0].behavior != Target.TargetBehavior.ChainStart && cues[0].velocity == 2)
                    {
                        cues.RemoveAt(0);
                        continue;
                    }
                    if (cues[0].nextCue.tick == cues[0].tick)
                    {
                        if (cues[0].behavior == Target.TargetBehavior.Melee)
                        {
                            cues.RemoveAt(1);
                        }
                        else
                        {
                            cues.RemoveAt(0);
                        }
                    }
                    MelonCoroutines.Stop(fadeToken);
                    float diff    = cues[0].nextCue.tick - cues[0].tick;
                    float end     = cues[0].nextCue.tick - (diff / 4f);
                    bool  isLight = state == ExposureState.Light;
                    float target  = isLight ? 0f : (ModifierManager.originalExposure / 100f) * 80f;
                    if (diff >= 120f && cues[0].behavior != Target.TargetBehavior.Melee)
                    {
                        fadeToken = MelonCoroutines.Start(Fade(end, target));
                    }
                    else
                    {
                        RenderSettings.skybox.SetFloat("_Exposure", target);
                        RenderSettings.reflectionIntensity     = target;
                        ArenaLoaderMod.CurrentSkyboxReflection = 0f;
                        ArenaLoaderMod.ChangeReflectionStrength(target);
                    }
                    state = isLight ? ExposureState.Dark : ExposureState.Light;
                    cues.RemoveAt(0);
                }
                yield return(new WaitForSecondsRealtime(.01f));
            }
            yield return(null);
        }
Пример #9
0
        /// <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);
        }
Пример #10
0
        /// <summary>
        /// Copy the source to dest.
        ///
        /// If source is nonnull, no problem.
        /// If source is null and dest is nonnulltype, Error
        /// If source is possible null and dest is nonnulltype, warning.
        /// Else, nothing.
        ///
        /// Need to maintain proper heap transformation.
        /// </summary>
        /// <param name="dest"></param>
        /// <param name="source"></param>
        /// <param name="stat"></param>
        /// <param name="arg"></param>
        /// <returns></returns>
        protected override object VisitCopy(Variable dest, Variable source, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            estate.CopyVariable(source, dest);

            return(arg);
        }
Пример #11
0
        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);
        }
Пример #12
0
        protected override object VisitStoreIndirect(Variable pointer, Variable source, TypeNode targetType, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            // no need to check pointer, since managed code guarantees them not to be null.


            return(arg);
        }
Пример #13
0
        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);
        }
Пример #14
0
        protected override object VisitSwitch(Variable selector, BlockList targets, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            foreach (CfgBlock target in ExposureChecker.currBlock.NormalSuccessors)
            {
                ExposureChecker.PushState(ExposureChecker.currBlock, target, estate);
            }
            return(null);
        }
Пример #15
0
 void goMachineReady()
 {
     exposureState = ExposureState.running;
     comHandler.sendLaser(true);
     onMachineReady    = null;
     onMachineNotReady = exposurePause;
     elapsed_time      = 0;
     statusTimer.Stop();
     exposureTimer.Start();
 }
Пример #16
0
        public void RefineBranchInformation(Variable cond, out ExposureState trueState, out ExposureState falseState)
        {
            ISymValue cv = this.egraph[cond];

            trueState  = new ExposureState(this);
            falseState = new ExposureState(this);

            AssumeTrue(cv, ref trueState);
            AssumeFalse(cv, ref falseState);
        }
Пример #17
0
        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);
        }
Пример #18
0
        protected override object VisitLoadFunction(Variable dest, Variable source, Method method, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            if (method.IsVirtual)
            {
                // Check for Receiver non-nullness
                CheckReceiver(stat, source, estate);
            }

            return(arg);
        }
Пример #19
0
 void exposurePause()
 {
     if (exposureState == ExposureState.running)
     {
         exposureState = ExposureState.idle;
         exposureTimer.Stop();
         comHandler.sendLaser(false);
         comHandler.sendScanner(false);
         statusTimer.Start();
         continueButton.Text = "Continue";
         onMachineNotReady   = null;
     }
 }
Пример #20
0
        /// <summary>
        /// Returns null, if result of Join is the same as atMerge.
        /// </summary>
        public static ExposureState Join(ExposureState atMerge, ExposureState incoming, CfgBlock joinPoint)
        {
            bool    unchanged;
            IEGraph merged = atMerge.egraph.Join(incoming.egraph, joinPoint, out unchanged);

            TypeNode currentException = (atMerge.currentException != null)?
                                        ((incoming.currentException != null)? CciHelper.LeastCommonAncestor(atMerge.currentException, incoming.currentException) : null) : null;

            if (atMerge.currentException != currentException || !unchanged)
            {
                return(new ExposureState(merged, currentException, atMerge.typeSystem));
            }
            return(null);
        }
Пример #21
0
        protected override object VisitLoadIndirect(Variable dest, Variable pointer, TypeNode targetType, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            // no need to check pointer, since managed code guarantees them not to be null.

            // but we need to check pointer target type.

            // BUGBUG: temporary fix until we have better handling of address of
            //estate.SetAccordingToType(dest, targetType);
//      estate.AssignNonNull(dest);

            return(estate);
        }
Пример #22
0
        /// <summary>
        /// Merge the two states for current block.
        /// </summary>
        /// <param name="previous"></param>
        /// <param name="joinPoint"></param>
        /// <param name="atMerge"></param>
        /// <param name="incoming"></param>
        /// <param name="resultDiffersFromPreviousMerge"></param>
        /// <param name="mergeIsPrecise"></param>
        /// <returns></returns>
        protected override IDataFlowState Merge(CfgBlock previous, CfgBlock joinPoint, IDataFlowState atMerge, IDataFlowState incoming, out bool resultDiffersFromPreviousMerge, out bool mergeIsPrecise)
        {
            mergeIsPrecise = false;

            // No new states;
            if (incoming == null)
            {
                resultDiffersFromPreviousMerge = false;
                return(atMerge);
            }

            // Initialize states
            if (atMerge == null)
            {
                resultDiffersFromPreviousMerge = true;
                return(incoming);
            }

            if (Analyzer.Debug)
            {
                Console.WriteLine("Merge at Block {0}-----------------", (joinPoint).UniqueKey);
                Console.WriteLine("  State at merge");
                atMerge.Dump();
                Console.WriteLine("  Incoming");
                incoming.Dump();
            }

            // Merge the two.

            ExposureState newState = ExposureState.Join((ExposureState)atMerge, (ExposureState)incoming, joinPoint);

            if (newState != null)
            {
                if (Analyzer.Debug)
                {
                    Console.WriteLine("\n  Merged State");
                    newState.Dump();
                }
                resultDiffersFromPreviousMerge = true;
                return(newState);
            }

            if (Analyzer.Debug)
            {
                Console.WriteLine("Merged state same as old.");
            }
            resultDiffersFromPreviousMerge = false;
            return(atMerge);
        }
Пример #23
0
 void exposureContinue()
 {
     if (checkConnectionAndBmp())
     {
         if (exposureState == ExposureState.idle)
         {
             exposureTimer.Interval = (int)delayNumeric.Value;
             exposureState          = ExposureState.starting;
             currentLine            = (int)lineNumericUpDown.Value;
             comHandler.sendScanner(true);
             onMachineReady      = goMachineReady;
             continueButton.Text = "Pause";
         }
     }
 }
Пример #24
0
 void exposureGo()
 {
     if (checkConnectionAndBmp())
     {
         if (exposureState == ExposureState.idle)
         {
             exposureTimer.Interval = (int)delayNumeric.Value;
             resetThumbnail();
             exposureState = ExposureState.starting;
             currentLine   = 0;
             comHandler.sendScanner(true);
             comHandler.sendStepper(0);//go home
             onStepperReady      = stepperIsHome;
             continueButton.Text = "Pause";
         }
     }
 }
Пример #25
0
 void exposureReset()
 {
     if (comHandler.connected == false)
     {
         MessageBox.Show("Please connect first!");
         return;
     }
     exposureState = ExposureState.idle;
     exposureTimer.Stop();
     comHandler.sendLaser(false);
     comHandler.sendScanner(false);
     comHandler.sendStepper(0);//go home
     onStepperReady = null;
     onMachineReady = null;
     statusTimer.Start();
     continueButton.Text = "Continue";
 }
Пример #26
0
        protected override object VisitStoreField(Variable dest, Field field, Variable source, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            // static Fields
            if (field.IsStatic)
            {
            }

            // BUGBUG!!
            // It seems that it would be better to start off ctors with the method's "this" object
            // in the Exposed state, but I'm not sure how to do that.
            This        t  = null;
            ThisBinding tb = dest as ThisBinding;

            if (tb != null)
            {
                t = tb.BoundThis;
            }
            else
            {
                t = dest as This;
            }
            if (t != null &&
                this.ExposureChecker.currentMethod.NodeType == NodeType.InstanceInitializer &&
                this.ExposureChecker.currentMethod.ThisParameter == t)
            {
                ; // skip
            }
            else
            {
                ExposureState.Lattice.AVal valueOfdest = estate.GetAVal(dest);
                if (valueOfdest.lowerBound == null || valueOfdest.upperBound == null)
                {
                    HandleError(stat, stat, Error.WritingPackedObject, dest.Name.Name);
                    return(arg);
                }
                if (valueOfdest.lowerBound.IsAssignableTo(field.DeclaringType))
                {
                    HandleError(stat, stat, Error.WritingPackedObject, dest.Name.Name);
                    return(arg);
                }
            }

            return(arg);
        }
Пример #27
0
        /// <summary>
        /// Refines the given state according to the knowledge stored in the egraph about sv
        ///
        /// In addition, the state can be null when the knowledge is inconsistent.
        /// </summary>
        /// <param name="cv">symbolic value we assume to be false</param>
        private static void AssumeFalse(ISymValue cv, ref ExposureState state)
        {
            if (state == null)
            {
                return;
            }

            foreach (EGraphTerm t in state.egraph.EqTerms(cv))
            {
                if (t.Function == ExposureState.EqIsExposedId)
                {
                    // EqIsExposed(op) == false, therefore op is *not* exposed
                    ISymValue op = t.Args[0];

//          state.AssignFrameForNotExposed(op);
                    ISymValue guardedObject = state.egraph[FrameFor, op];
                    state.egraph[guardedObject] = Lattice.AVal.Top; // BUGBUG?? If it isn't exposed at this frame, then what is it?
                }
            }
        }
Пример #28
0
        /// <summary>
        /// For the possible receiver v, check if it is nonnull. if no, file an proper
        /// error/warning.
        /// </summary>
        private void CheckReceiver(Statement stat, Variable v, ExposureState estate)
        {
            Node offendingNode = v;

            if (v == null)
            {
                return;
            }

            if (estate.IsNotExposed(v))
            {
                HandleError(stat, offendingNode, Error.WritingPackedObject, v.Name.Name);
                //estate.AssignExposed(v);
            }
            else if (!estate.IsExposed(v))
            {
                HandleError(stat, offendingNode, Error.WritingPackedObject, v.Name.Name);
                //estate.AssumeNonNull(v);
            }
        }
Пример #29
0
        /// <summary>
        /// Method entry. Need to add This pointer.
        ///
        /// Does not have to deal with parameters.
        /// </summary>
        /// <param name="method"></param>
        /// <param name="parameters"></param>
        /// <param name="stat"></param>
        /// <param name="arg"></param>
        /// <returns></returns>
        protected override object VisitMethodEntry(Method method, IEnumerable parameters, Statement stat, object arg)
        {
            ExposureState estate = (ExposureState)arg;

            foreach (Parameter p in parameters)
            {
                // TODO: look at attributes or somewhere else (??) to see if parameter is exposed or not.
//        estate.AssignAccordingToType(p, p.Type);
                if (p == null)
                {
                    continue;
                }
            }
            if (!method.IsStatic)
            {
                // TODO: decide whether "this" is exposed or not
//        estate.AssignNonNull(CciHelper.GetThis(method));
            }
            return(arg);
        }
Пример #30
0
        /// <summary>
        /// Refines the given state according to the knowledge stored in the egraph about sv
        ///
        /// In addition, the state can be null when the knowledge is inconsistent.
        /// </summary>
        /// <param name="cv">symbolic value we assume to be non-null (true)</param>
        /// <param name="state">state if sv is non-null (true)</param>
        private static void AssumeTrue(ISymValue cv, ref ExposureState state)
        {
            if (state == null)
            {
                return;
            }

            foreach (EGraphTerm t in state.egraph.EqTerms(cv))
            {
                ISymValue op = t.Args[0];
                if (t.Function == ExposureState.EqIsExposedId)
                {
                    // EqIsExposed(op) == true, therefore op *is* exposed
                    state.AssignFrameForExposed(op);
                }
                else if (t.Function == ExposureState.EqIsExposableId)
                {
                    state.AssignFrameForExposable(op);
                }
            }
        }