Commit c8a5c7b6 authored by Christian Hilden's avatar Christian Hilden
Browse files

Merge branch...

Merge branch '32-for-actors-without-states-the-enterhistory-function-is-generated-without-return-statement' into 'master'

Fix #32: Generate NO_STATE return enterHistory function for empty state machines

Closes #32

See merge request !7
parents aa8ceede 5fe4a618
Pipeline #3917 passed with stage
in 0 seconds
......@@ -281,6 +281,7 @@ abstract class AbstractStateMachineGenerator {
val state2node = newHashMap
nodes.forEach[state2node.put(stateGraphNode as State, it)]
val states = nodes.map[stateGraphNode].filter(typeof(State)).toList
val hasLeafStates = states.exists[isLeaf]
val transitionChains = gc.graph.allLinks.filter[isChainHead].toList.sortBy[transition.genChainId]
'''
/**
......@@ -349,54 +350,58 @@ abstract class AbstractStateMachineGenerator {
*/
IF generateImplementation
privAccessstateType opScopePriventerHistory(selfPtrstateType state__etIF usesHdlr, boolType handler__etENDIF) {
val needsSkipVar = !states.filter(s|s.hasEntryCode(true)).empty
IF needsSkipVar
boolType skip_entry__et = langExt.booleanConstant(false);
ENDIF
if (state__et >= STATE_MAX) {
state__et = IF !langExt.usesInheritance(stateType)ENDIF (state__et - STATE_MAX);
IF hasLeafStates
val needsSkipVar = !states.filter(s|s.hasEntryCode(true)).empty
IF needsSkipVar
skip_entry__et = langExt.booleanConstant(true);
boolType skip_entry__et = langExt.booleanConstant(false);
ENDIF
}
while (langExt.booleanConstant(true)) {
switch (state__et) {
FOR state : states
case state.genStateId:
IF state.hasEntryCode(true)if (!(skip_entry__etIF usesHdlr || handler__etENDIF)) state.entryCodeOperationName(langExt.selfPointer(false));ENDIF
IF state.isLeaf
/* in leaf state: return state id */
return state.getGenStateId;
ELSE
/* state has a sub graph */
var sub_initt = state2node.get(state).subgraph.initialTransition
IF sub_initt!==null
/* with init transition */
if (getHistory(state.genStateId)==NO_STATE) {
state__et = executeTransitionChain(langExt.selfPointer(true)chainIDScopesub_initt.genChainIdIF handleEvents, langExt.nullPointer, langExt.nullPointerENDIF);
}
else {
state__et = state.genStateId.history;
}
if (state__et >= STATE_MAX) {
state__et = IF !langExt.usesInheritance(stateType)ENDIF (state__et - STATE_MAX);
IF needsSkipVar
skip_entry__et = langExt.booleanConstant(true);
ENDIF
}
while (langExt.booleanConstant(true)) {
switch (state__et) {
FOR state : states
case state.genStateId:
IF state.hasEntryCode(true)if (!(skip_entry__etIF usesHdlr || handler__etENDIF)) state.entryCodeOperationName(langExt.selfPointer(false));ENDIF
IF state.isLeaf
/* in leaf state: return state id */
return state.getGenStateId;
ELSE
/* without init transition */
state__et = state.genStateId.history;
/* state has a sub graph */
var sub_initt = state2node.get(state).subgraph.initialTransition
IF sub_initt!==null
/* with init transition */
if (getHistory(state.genStateId)==NO_STATE) {
state__et = executeTransitionChain(langExt.selfPointer(true)chainIDScopesub_initt.genChainIdIF handleEvents, langExt.nullPointer, langExt.nullPointerENDIF);
}
else {
state__et = state.genStateId.history;
}
ELSE
/* without init transition */
state__et = state.genStateId.history;
ENDIF
break;
ENDIF
ENDFOR
case STATE_TOP:
state__et = getHistory("STATE_TOP");
break;
ENDIF
ENDFOR
case STATE_TOP:
state__et = getHistory("STATE_TOP");
break;
default:
/* should not occur */
break;
default:
/* should not occur */
break;
}
IF needsSkipVar
skip_entry__et = langExt.booleanConstant(false);
ENDIF
}
IF needsSkipVar
skip_entry__et = langExt.booleanConstant(false);
ENDIF
}
unreachableReturn
unreachableReturn
ELSE
noStateReturn
ENDIF
}
ELSE
stateType enterHistory(selfPtrstateType state__etIF usesHdlr, boolType handler__etENDIF);
......@@ -649,6 +654,15 @@ abstract class AbstractStateMachineGenerator {
def unreachableReturn() {
"/* return NO_STATE; // required by CDT but detected as unreachable by JDT because of while (true) */"
}
/**
* allow target language dependent generation of noState return in generated enterHistory method.
* The default is a simple enum return
* @return the generated code
*/
def noStateReturn() {
"return NO_STATE;"
}
/**
* type of (temporary) boolean variables (defaults to "boolean")
......
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