Commit 645a410e authored by Bas Lijnse's avatar Bas Lijnse

Cleaned up some debugging and tracing code

parent 13420d5c
......@@ -139,7 +139,6 @@ sequenceLayouts :: [LayoutRule] -> LayoutRule
, hiddenAttributes :: Map UIAttributeKey (LUIEffectStage LUINo)
, additional :: LUIEffectStage LUINo
, hidden :: LUIEffectStage LUINo
// , moved :: LUIEffectStage LUINo
, wrapper :: LUIEffectStage LUINo
, unwrapped :: LUIEffectStage LUINo
}
......@@ -189,7 +188,6 @@ applyUpstreamChange :: UIChange (LUI,LUIMoves) -> (LUI,LUIMoves)
extractDownstreamChange :: (LUI,LUIMoves) -> (!UIChange,!(LUI,LUIMoves))
//Helper functions (exported for unit testing)
scanToPosition_ :: LUINo Int [LUI] LUIMoves -> (Int,Bool,Maybe LUI)
nodeExists_ :: !LUINo !LUI LUIMoves -> Bool
......@@ -202,5 +200,4 @@ overwriteAttribute_ :: LUINo UIAttribute (Map UIAttributeKey (LUIEffectStage (LU
hideAttribute_ :: LUINo (UIAttributeKey -> Bool) UIAttributeKey (Map UIAttributeKey (LUIEffectStage LUINo)) -> (Map UIAttributeKey (LUIEffectStage LUINo))
matchAttributeKey_ :: UIAttributeSelection UIAttributeKey -> Bool
extractUIWithEffects_ :: (LUI,LUIMoves) -> Maybe UI
fullyApplied_ :: (LUI,LUIMoves) -> Bool
isPartOf_ :: LUINo LUINo -> Bool
......@@ -1320,30 +1320,3 @@ confirmEffect_ (ESToBeApplied x) = ESApplied x
confirmEffect_ (ESToBeUpdated _ x) = ESApplied x
confirmEffect_ (ESToBeRemoved x) = ESNotApplied
confirmEffect_ es = es
//After downstream changes have been extracted there should be no pending changes
//and all effects are either ESNotApplied or ESApplied
fullyApplied_ :: (LUI,LUIMoves) -> Bool
fullyApplied_ _ = True
/*
fullyApplied_ (LUINode _ _ items c e, moves)
| c.toBeInserted || c.toBeRemoved || c.toBeReplaced =: (Just _) || c.toBeShifted =: (Just _) = False
| (not ('DM'.null c.setAttributes)) || (not ('DS'.null c.delAttributes)) = False
| not (all (\(_,a) -> (a =: (ESApplied _) || a =: (ESNotApplied))) ('DM'.toList e.overwrittenAttributes)) = False
| not (all (\(_,a) -> (a =: (ESApplied _) || a =: (ESNotApplied))) ('DM'.toList e.hiddenAttributes)) = False
| not (e.overwrittenType =: (ESApplied _) || e.overwrittenType =: (ESNotApplied)) = False
| not (e.additional =: (ESApplied _) || e.additional =: (ESNotApplied)) = False
| not (e.hidden =: (ESApplied _) || e.hidden =: (ESNotApplied)) = False
| not (e.moved =: (ESApplied _) || e.moved =: (ESNotApplied)) = False
| not (e.wrapper =: (ESApplied _) || e.wrapper =: (ESNotApplied)) = False
| not (e.unwrapped =: (ESApplied _) || e.unwrapped =: (ESNotApplied)) = False
| otherwise
= all (\l -> fullyApplied_ (l,moves)) items
fullyApplied_ (LUIMoveSource moveId, moves)
= maybe False (\l -> fullyApplied_ (l,moves)) ('DM'.get moveId moves)
fullyApplied_ (LUIMoveDestination moveId _, moves)
= maybe False (\l -> fullyApplied_ (l,moves)) ('DM'.get moveId moves)
fullyApplied_ (LUIShiftDestination _, moves) = False
*/
......@@ -31,7 +31,6 @@ where
tune (ApplyLayout l) task = applyLayout l task
applyLayout :: LayoutRule (Task a) -> Task a
//applyLayout rule task=:(Task evala) = task
applyLayout rule task=:(Task evala) = Task eval
where
ruleNo = LUINo [0]
......@@ -47,42 +46,19 @@ applyLayout rule task=:(Task evala) = Task eval
eval ResetEvent evalOpts (TCLayout _ tt) iworld = case evala ResetEvent evalOpts tt iworld of
(ValueResult value info (ReplaceUI ui) tt,iworld)
# (change,state) = extractResetChange (rule ruleNo (initLUI ui, initLUIMoves))
//| not (trace_tn ("STATE AFTER RESET: \n"+++toString (toJSON state))) = undef
= (ValueResult value info change (TCLayout state tt), iworld)
(res,iworld) = (res,iworld)
eval event evalOpts (TCLayout state1 tt) iworld = case evala event evalOpts tt iworld of
eval event evalOpts (TCLayout state tt) iworld = case evala event evalOpts tt iworld of
(ValueResult value info change tt,iworld)
//| not (trace_tn ("UPSTREAM CHANGE: \n"+++toString (toJSON change))) = undef
//| not (trace_tn ("STATE BEFORE CHANGE: \n"+++toString (toJSON state1))) = undef
# state2 = applyUpstreamChange change state1
//| not (trace_tn ("STATE AFTER CHANGE: \n"+++toString (toJSON state2))) = undef
# state3 = rule ruleNo state2
//| not (trace_tn ("STATE AFTER RULES: \n"+++toString (toJSON state3))) = undef
# (change,state4) = extractDownstreamChange state3
//| not (trace_tn ("STATE AFTER EXTRACT: \n"+++toString (toJSON state4))) = undef
//| not (trace_tn ("DOWNSTREAM CHANGE: \n"+++toString (toJSON change))) = undef
//| not (trace_tn "=====") = undef
| not (fullyApplied_ state4)
# iworld = traceState "state-before-change.txt" state1 iworld
# iworld = traceState "state-after-change.txt" state2 iworld
# iworld = traceState "state-after-rules.txt" state3 iworld
# iworld = traceState "state-after-extract.txt" state4 iworld
= (ExceptionResult (exception ("Corrupt layout state")), iworld)
| otherwise
= (ValueResult value info change (TCLayout state4 tt), iworld)
# state = applyUpstreamChange change state
# state = rule ruleNo state
# (change,state) = extractDownstreamChange state
= (ValueResult value info change (TCLayout state tt), iworld)
(res,iworld) = (res,iworld)
eval event evalOpts state iworld = evala event evalOpts state iworld //Catchall
traceState filename state iworld
# {IWorld|world} = iworld
# (_,world) = writeFile filename (jsonPrettyPrint (toJSON state)) world
= {IWorld|iworld & world = world}
import StdDebug, StdMisc, System.File, StdFile
import iTasks.Internal.IWorld
class toAttribute a where toAttribute :: a -> JSONNode
instance toAttribute String where toAttribute s = JSONString s
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment