public BaseState GetLastState() { BaseState res; if (states.Count == 0) { res = Controller.GetInstance().RuningState; } else { TemporaryState expectedValidState = states.Dequeue(); while ((Time.time - expectedValidState.startTime) > stateLifeTime) { if (states.Count >= 1) { expectedValidState = states.Dequeue(); } else { expectedValidState.state = new RuningState(Controller.GetInstance()); break; } } res = expectedValidState.state; } return(res); }
/// <summary> /// Used by the symbolic evaluator to obtain the symbolic value of <paramref name="id"/>. /// </summary> /// <param name="id"></param> /// <returns></returns> public Expression GetValue(Identifier id) { var reg = id.Storage as RegisterStorage; Expression value; if (reg != null && RegisterState.TryGetValue(reg, out value)) { return(value); } var tmp = id.Storage as TemporaryStorage; if (tmp != null && TemporaryState.TryGetValue(tmp, out value)) { return(value); } var local = id.Storage as StackLocalStorage; if (local != null) { return(GetStackValue(local.StackOffset, local.DataType)); } //$REVIEW: this is cheating a little; some flags could // actually have been set to 0 or 1. The problem is we // are doing "poor man's value propagation", and should // really be doing this after SSA transformation has been // done on the code. if (id.Storage is FlagGroupStorage) { return(Constant.Invalid); } return(id); }
public void PutState(BaseState newState) { int countValidStates = 0; foreach (TemporaryState one in states) { if ((Time.time - one.startTime) < stateLifeTime) { countValidStates++; } } if (countValidStates < maxStates) { TemporaryState containerNewState = new TemporaryState(newState, Time.time); bool existSameState = false; float timeOfExistedSame = 0f; foreach (TemporaryState one in states) { if (one.state.Equals(newState)) { existSameState = true; timeOfExistedSame = Time.time - one.startTime; break; } } if ((existSameState && (timeOfExistedSame > stateLifeTime)) || !existSameState) { states.Enqueue(containerNewState); } } }
void ITemporaryState.OnDeactivation(TemporaryState state) { freezableDelegate.OnUnfreeze(this); }
void ITemporaryState.OnActivation(TemporaryState state, float duration) { freezableDelegate.OnFreeze(this, duration); }
bool ITemporaryState.CanDeactivate(TemporaryState state) { return(freezableDelegate.CanUnfreeze(this)); }
bool ITemporaryState.CanActivate(TemporaryState state, ref float duration) { return(freezableDelegate.CanFreeze(this, ref duration)); }