Skip to content

Instantly share code, notes, and snippets.

@jbeard4
Created March 1, 2011 20:44
Show Gist options
  • Save jbeard4/849856 to your computer and use it in GitHub Desktop.
Save jbeard4/849856 to your computer and use it in GitHub Desktop.
procedure addStatesToEnter
procedure addStatesToEnter(s,root,statesToEnter,statesForDefaultEntry):
if isHistoryState(s):
if historyValue[s.id]:
for s0 in historyValue[s.id]:
addStatesToEnter(s0,getParent(s),statesToEnter,statesForDefaultEntry)
else:
for t in s.transition:
for s0 in getTargetStates(t.target):
addStatesToEnter(s0,getParent(s),statesToEnter,statesForDefaultEntry)
else:
statesToEnter.add(s)
if isParallelState(s):
for child in getChildStates(s):
addStatesToEnter(child,s,statesToEnter,statesForDefaultEntry)
elif isCompoundState(s):
statesForDefaultEntry.add(s)
for tState in getTargetStates(s.initial):
addStatesToEnter(tState, s, statesToEnter, statesForDefaultEntry)
for anc in getProperAncestors(s,root):
statesToEnter.add(anc)
if isParallelState(anc):
for pChild in getChildStates(anc):
if not statesToEnter.toList().some(lambda s2: isDescendant(s2,pChild)):
addStatesToEnter(pChild,anc,statesToEnter,statesForDefaultEntry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment