Author: jbeard
Date: Sun Nov  7 09:40:10 2010
New Revision: 1032246

URL: http://svn.apache.org/viewvc?rev=1032246&view=rev
Log:
Fixed a problem with the way parallel states and preemption was being handled. 
Refactored implementation to make it closer to the algorithm in the SCXML spec. 
Now a set of transitions are selected, keeping preemption in mind, then 
afterwards each transition is taken.
All tests pass for state pattern. Others strategies still need a bit more work, 
but this should be minimal.

Added:
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
   (with props)
Modified:
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js?rev=1032246&r1=1032245&r2=1032246&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
 Sun Nov  7 09:40:10 2010
@@ -11,7 +11,8 @@ require.def(
                "text!src/xslt/ir-compiler/computeLCA.xsl",
                "text!src/xslt/ir-compiler/transformIf.xsl",
                "text!src/xslt/ir-compiler/appendStateInformation.xsl",
-               "text!src/xslt/ir-compiler/appendBasicStateInformation.xsl" ],
+               "text!src/xslt/ir-compiler/appendBasicStateInformation.xsl", 
+               
"text!src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl" ],
        function(
                normalizeInitialStates,
                generateUniqueStateIds,
@@ -21,7 +22,8 @@ require.def(
                computeLCA,
                transformIf,
                appendStateInformation,
-               appendBasicStateInformation
+               appendBasicStateInformation,
+               addBasicDescendantsToTransitions
        ){
 
                return {
@@ -34,7 +36,8 @@ require.def(
                                computeLCA,
                                transformIf,
                                appendStateInformation,
-                               appendBasicStateInformation
+                               appendBasicStateInformation,
+                               addBasicDescendantsToTransitions
                        ]
                };
 

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl?rev=1032246&r1=1032245&r2=1032246&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractEnumeratedStatechartGenerator.xsl
 Sun Nov  7 09:40:10 2010
@@ -277,6 +277,7 @@
                }
        </template>
 
+       <!-- FIXME: this can now be taken out/consolidated, as it no longer 
needds to be parameterized -->
        <template name="genHistoryTriggerDispatcherHistoryStateReference">
                <param name="s"/>
 

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=1032246&r1=1032245&r2=1032246&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
 Sun Nov  7 09:40:10 2010
@@ -643,7 +643,6 @@
                var innerEventQueue = []; //inner event queue
                var outerEventQueue = []; //outer event queue
                var isInStableState = true;
-               var isPreempted = false;
                var hasTakenDefaultTransition = false;
                var destroyed = false;
                var mainLoopCallback = null;
@@ -697,20 +696,30 @@
                }
 
                function microstep(e,data,isEnumeratedEvent){
+                       var enabledTransitions = [], transition = null, 
preemptedBasicStates = {};
+
+                       //we set the event as a global, rather than passing it 
into the function invocation as a parameter,
+                       //because in cases of default events, the event object 
will be populated with previous event's data
+                       if(e !== <value-of select="$defaultEventLiteral"/> ){
+                               _event.name= isEnumeratedEvent ? <value-of 
select="$eventToNameMap"/> : e;
+                               _event.data=data;
+                       }
+
                        if(isEnumeratedEvent){
                                //e does not contain a dot, so dispatch as an 
enumerated event
                                <call-template name="genForEach">
                                        <with-param name="var" 
select="'state'"/>
                                        <with-param name="in" 
select="'currentConfiguration'"/>
                                        <with-param name="do">
-                                               if(!isPreempted){ 
-                                                       //we set the event as a 
global, rather than passing it into the function invocation as a parameter,
-                                                       //because in cases of 
default events, the event object will be populated with previous event's data
-                                                       if(e !== <value-of 
select="$defaultEventLiteral"/> ){
-                                                               
_event.name=<value-of select="$eventToNameMap"/>;
-                                                               
_event.data=data;
+                                               <!-- TODO: move duplicate code 
out -->
+                                               //check to make sure he is not 
preempted
+                                               if(!(state in 
preemptedBasicStates)){
+                                                       //lookup the transition
+                                                       var transition = 
<value-of select="$enumeratedEventDispatchInvocation"/>
+                                                       if(transition){ 
+                                                               
enabledTransitions.push(transition.action);
+                                                               
mixin(transition.preemptedBasicStates,preemptedBasicStates);
                                                        }
-                                                       <value-of 
select="$enumeratedEventDispatchInvocation"/>
                                                }
                                        </with-param>
                                </call-template>
@@ -720,24 +729,35 @@
                                        <with-param name="var" 
select="'state'"/>
                                        <with-param name="in" 
select="'currentConfiguration'"/>
                                        <with-param name="do">
-                                               if(!isPreempted){ 
-                                                       //we set the event as a 
global, rather than passing it into the function invocation as a parameter,
-                                                       //because in cases of 
default events, the event object will be populated with previous event's data
-                                                       //NOTE: e will always 
be a string here, even in enumerated techniques
-                                                       if(e !== <value-of 
select="$defaultEventLiteral"/> ){
-                                                               _event.name=e;
-                                                               
_event.data=data;
+                                               <!-- TODO: move duplicate code 
out -->
+                                               //check to make sure he is not 
preempted
+                                               if(!(state in 
preemptedBasicStates)){
+                                                       //lookup the transition
+                                                       var transition = 
<value-of select="$prefixEventDispatchInvocation"/>
+ 
+                                                       if(transition){ 
+                                                               
enabledTransitions.push(transition.action);
+                                                               
mixin(transition.preemptedBasicStates,preemptedBasicStates);
                                                        }
-                                                       <value-of 
select="$prefixEventDispatchInvocation"/>
                                                }
                                        </with-param>
                                </call-template>
                        }
 
-                       //reset the isPreempted flag
-                       isPreempted = false;
+                       //invoke selected transitions
+                       <call-template name="genForEach">
+                               <with-param name="var" select="'t'"/>
+                               <with-param name="in" 
select="'enabledTransitions'"/>
+                               <with-param name="do"> t(); </with-param>
+                       </call-template>
+
                }
 
+               function mixin(from,to){
+                       for(var prop in from){
+                               to[prop] = from[prop]
+                       }
+               }
 
                this.destroy = function(){
                        //right now, this only disables timer and sets global 
destroyed variable to prevent future callbacks
@@ -786,111 +806,117 @@
                //history state semantics
                if(<value-of 
select="$historyStateReference"/>.lastConfiguration){
 
-                       //transition action
-                       <if test="$log">
-                               <choose>
-                                       <when test="$isDeep">
-                                               console.log("return to last 
deep configuration");
-                                       </when>
-                                       <otherwise>
-                                               console.log("return to last 
shallow configuration");
-                                       </otherwise>
-                               </choose>
-                       </if>
-                                       
-                               
-                       <!--gen executable content for t-->
-                       <apply-templates select="$t/*[self::s:if or 
self::s:raise or self::s:log or self::s:script or self::s:send or 
self::s:cancel or self::s:invoke or self::s:finalize or self::s:assign or 
self::s:validate ]"/>
-
-                       <if test="$genListenerHooks">
-                               <call-template name="genForEach">
-                                       <with-param name="var" select="'l'"/>
-                                       <with-param name="in" 
select="'listeners'"/>
-                                       <with-param name="do">
-                                               //transition id
-                                               <for-each 
select="$t/c:targets/c:target">
-                                                       l.onTransition(
-                                                               "<value-of 
select="../../../@id"/>",
-                                                               "<value-of 
select="c:targetState"/>",
-                                                               "<value-of 
select="@c:id"/>" );
-                                               </for-each>
-                                       </with-param>
-                               </call-template>
-                       </if>
+                       return {
+                               preemptedBasicStates: <call-template 
name="genPreemptedBasicStatesSet"><with-param name="t" 
select="$t"/></call-template>,
+                               action: function(){
+                                       //transition action
+                                       <if test="$log">
+                                               <choose>
+                                                       <when test="$isDeep">
+                                                               
console.log("return to last deep configuration");
+                                                       </when>
+                                                       <otherwise>
+                                                               
console.log("return to last shallow configuration");
+                                                       </otherwise>
+                                               </choose>
+                                       </if>
+                                                       
+                                               
+                                       <!--gen executable content for t-->
+                                       <apply-templates 
select="$t/*[self::s:if or self::s:raise or self::s:log or self::s:script or 
self::s:send or self::s:cancel or self::s:invoke or self::s:finalize or 
self::s:assign or self::s:validate ]"/>
+
+                                       <if test="$genListenerHooks">
+                                               <call-template 
name="genForEach">
+                                                       <with-param name="var" 
select="'l'"/>
+                                                       <with-param name="in" 
select="'listeners'"/>
+                                                       <with-param name="do">
+                                                               //transition id
+                                                               <for-each 
select="$t/c:targets/c:target">
+                                                                       
l.onTransition(
+                                                                               
"<value-of select="../../../@id"/>",
+                                                                               
"<value-of select="c:targetState"/>",
+                                                                               
"<value-of select="@c:id"/>" );
+                                                               </for-each>
+                                                       </with-param>
+                                               </call-template>
+                                       </if>
 
 
 
-                       var historyState = <value-of 
select="$historyStateReference"/>;
+                                       var historyState = <value-of 
select="$historyStateReference"/>;
 
-                       <if test="not($isDeep)">
-                               var newConfiguration = [];
-                       </if>
+                                       <if test="not($isDeep)">
+                                               var newConfiguration = [];
+                                       </if>
 
-                       <if test="$isChildOfParallel">
-                               <variable name="siblingStates" 
select="$s/../s:state | $s/../s:parallel"/>
+                                       <if test="$isChildOfParallel">
+                                               <variable name="siblingStates" 
select="$s/../s:state | $s/../s:parallel"/>
 
-                               var siblingStates = [
-                                       <for-each select="$siblingStates">
+                                               var siblingStates = [
+                                                       <for-each 
select="$siblingStates">
 
-                                               <value-of select="@id"/>
+                                                               <value-of 
select="@id"/>
 
-                                               <if 
test="not(position()=last())">
-                                               ,
-                                               </if>
-                                       </for-each>
-                               ];
-                               
-                       </if>
+                                                               <if 
test="not(position()=last())">
+                                                               ,
+                                                               </if>
+                                                       </for-each>
+                                               ];
+                                               
+                                       </if>
 
-                       var historyStateParent = <value-of 
select="$historyStateReference"/>.parent;
+                                       var historyStateParent = <value-of 
select="$historyStateReference"/>.parent;
 
-                       <call-template name="genForEach">
-                               <with-param name="var" select="'state'"/>
-                               <with-param name="in">
-                                       <value-of 
select="$historyStateReference"/>.lastConfiguration
-                               </with-param>
-                               <with-param name="do">
-                                       <call-template 
name="genHistoryTriggerDispatcherInnerForEach">
-                                               <with-param name="isDeep" 
select="$isDeep"/>
-                                               <with-param 
name="isChildOfParallel" select="$isChildOfParallel"/>
-                                       </call-template>
-                               </with-param>
-                               <with-param name="when">
-                                       <call-template name="genIndexOf">
+                                       <call-template name="genForEach">
+                                               <with-param name="var" 
select="'state'"/>
                                                <with-param name="in">
-                                                       <value-of 
select="$genHistoryTriggerDispatcherInnerForEachStateReference"/>.ancestors
+                                                       <value-of 
select="$historyStateReference"/>.lastConfiguration
+                                               </with-param>
+                                               <with-param name="do">
+                                                       <call-template 
name="genHistoryTriggerDispatcherInnerForEach">
+                                                               <with-param 
name="isDeep" select="$isDeep"/>
+                                                               <with-param 
name="isChildOfParallel" select="$isChildOfParallel"/>
+                                                       </call-template>
                                                </with-param>
-                                               <with-param name="var" 
select="'historyStateParent'"/>
-                                        </call-template> !=-1
-                               </with-param>
-                       </call-template>
-                       
-                       <choose>
-                               <when test="$isDeep">
-                                       currentConfiguration =  <value-of 
select="$historyStateReference"/>.lastConfiguration.slice();
-                               </when>
-                               <otherwise>
-                                       <call-template name="genFilter">
-                                               <with-param 
name="returnArrayVarName" select="'filteredConfiguration'"/>
-                                               <with-param name="var" 
select="'state'"/>
-                                               <with-param name="in" 
select="'currentConfiguration'"/>
                                                <with-param name="when">
                                                        <call-template 
name="genIndexOf">
                                                                <with-param 
name="in">
                                                                        
<value-of 
select="$genHistoryTriggerDispatcherInnerForEachStateReference"/>.ancestors
                                                                </with-param>
                                                                <with-param 
name="var" select="'historyStateParent'"/>
-                                                        </call-template> == -1
+                                                        </call-template> !=-1
                                                </with-param>
                                        </call-template>
+                                       
+                                       <choose>
+                                               <when test="$isDeep">
+                                                       currentConfiguration =  
<value-of select="$historyStateReference"/>.lastConfiguration.slice();
+                                               </when>
+                                               <otherwise>
+                                                       <call-template 
name="genFilter">
+                                                               <with-param 
name="returnArrayVarName" select="'filteredConfiguration'"/>
+                                                               <with-param 
name="var" select="'state'"/>
+                                                               <with-param 
name="in" select="'currentConfiguration'"/>
+                                                               <with-param 
name="when">
+                                                                       
<call-template name="genIndexOf">
+                                                                               
<with-param name="in">
+                                                                               
        <value-of 
select="$genHistoryTriggerDispatcherInnerForEachStateReference"/>.ancestors
+                                                                               
</with-param>
+                                                                               
<with-param name="var" select="'historyStateParent'"/>
+                                                                        
</call-template> == -1
+                                                               </with-param>
+                                                       </call-template>
 
-                                       newConfiguration = 
newConfiguration.concat(filteredConfiguration)
+                                                       newConfiguration = 
newConfiguration.concat(filteredConfiguration)
+
+                                                       <!-- TODO: refactor 
this name to be genHistoryTriggerDispatcherCurrentConfigurationAssignment -->
+                                                       <value-of 
select="$genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"/>
+                                                       currentConfiguration = 
historyTriggerDispatcherCurrentConfigurationAssignmentRHS;
+                                               </otherwise>
+                                       </choose>
+                               }
+                       }
 
-                                       <!-- TODO: refactor this name to be 
genHistoryTriggerDispatcherCurrentConfigurationAssignment -->
-                                       <value-of 
select="$genHistoryTriggerDispatcherCurrentConfigurationAssignmentRHS"/>
-                                       currentConfiguration = 
historyTriggerDispatcherCurrentConfigurationAssignmentRHS;
-                               </otherwise>
-                       </choose>
                        
                }else{
                        <call-template 
name="genTriggerDispatcherGuardConditionBlockContents">
@@ -1048,110 +1074,121 @@
                </choose>
        </template>
 
+       <template name="genPreemptedBasicStatesSet">
+               <param name="t"/>
+               
+               {
+                       <for-each 
select="$t/c:basicStateDescendantsOfLCA/c:basicStateDescendant">
+                               <value-of select="text()"/> : true
+                               <if test="position() != last()">,</if>
+                       </for-each>
+               }
+       </template>
+
        <template name="genTriggerDispatcherInnerContents">
                <param name="s"/>
                <param name="t"/>
 
-               <if test="not($t/@event)">
-                       hasTakenDefaultTransition = true;
-               </if>
+               <!-- TODO: wrap this in a return function -->
+               <!-- TODO: deal with history -->
+               return {
+                       preemptedBasicStates : <call-template 
name="genPreemptedBasicStatesSet"><with-param name="t" 
select="$t"/></call-template>,
+                       action : function(){
+                               <if test="not($t/@event)">
+                                       hasTakenDefaultTransition = true;
+                               </if>
 
-               <variable name="precomputeExit" 
-                       select="local-name($s) = 'initial' or local-name($s) = 
'history' or 
-                                       ( $s/@c:isBasic and 
-                                               ( not($s/@c:isParallelSubstate) 
or 
-                                                       
($s/@c:isParallelSubstate and not($t/@c:exitsParallelRegion))))"/>
+                               <variable name="precomputeExit" 
+                                       select="local-name($s) = 'initial' or 
local-name($s) = 'history' or 
+                                                       ( $s/@c:isBasic and 
+                                                               ( 
not($s/@c:isParallelSubstate) or 
+                                                                       
($s/@c:isParallelSubstate and not($t/@c:exitsParallelRegion))))"/>
 
-               //exit states
-               <choose>
-                       <when test="$precomputeExit">
-                               <for-each select="$t/c:exitpath/c:state">
-                                       <value-of select="."/>.exitAction();
+                               //exit states
+                               <choose>
+                                       <when test="$precomputeExit">
+                                               <for-each 
select="$t/c:exitpath/c:state">
+                                                       <value-of 
select="."/>.exitAction();
+
+                                                       <call-template 
name="genForEach">
+                                                               <with-param 
name="var" select="'listener'"/>
+                                                               <with-param 
name="in" select="'listeners'"/>
+                                                               <with-param 
name="do">
+                                                                       //from
+                                                                       
listener.onExit("<value-of select="."/>");
+                                                               </with-param>
+                                                       </call-template>
+                                               </for-each>
+                                       </when>
+                                       <otherwise>
+                                               <call-template 
name="genNonBasicTriggerDispatcherExitBlock">
+                                                       <with-param name="t" 
select="$t"/>
+                                               </call-template>
+                                       </otherwise>
+                               </choose>
+
+                               //transition action
+                               <apply-templates select="$t/*[self::s:if or 
self::s:raise or self::s:log or self::s:script or self::s:send or 
self::s:cancel or self::s:invoke or self::s:finalize or self::s:assign or 
self::s:validate ]"/>
+                               <if test="$genListenerHooks">
 
                                        <call-template name="genForEach">
                                                <with-param name="var" 
select="'listener'"/>
                                                <with-param name="in" 
select="'listeners'"/>
                                                <with-param name="do">
-                                                       //from
-                                                       
listener.onExit("<value-of select="."/>");
+                                                       //transition id
+                                                       <for-each 
select="$t/c:targets/c:target">
+                                                               
listener.onTransition(
+                                                                       
"<value-of select="../../../@id"/>",
+                                                                       
"<value-of select="c:targetState"/>",
+                                                                       
"<value-of select="@c:id"/>" );
+                                                       </for-each>
                                                </with-param>
                                        </call-template>
-                               </for-each>
-                       </when>
-                       <otherwise>
-                               <call-template 
name="genNonBasicTriggerDispatcherExitBlock">
-                                       <with-param name="t" select="$t"/>
-                               </call-template>
-                       </otherwise>
-               </choose>
-
-               //transition action
-               <apply-templates select="$t/*[self::s:if or self::s:raise or 
self::s:log or self::s:script or self::s:send or self::s:cancel or 
self::s:invoke or self::s:finalize or self::s:assign or self::s:validate ]"/>
-               <if test="$genListenerHooks">
-
-                       <call-template name="genForEach">
-                               <with-param name="var" select="'listener'"/>
-                               <with-param name="in" select="'listeners'"/>
-                               <with-param name="do">
-                                       //transition id
-                                       <for-each 
select="$t/c:targets/c:target">
-                                               listener.onTransition(
-                                                       "<value-of 
select="../../../@id"/>",
-                                                       "<value-of 
select="c:targetState"/>",
-                                                       "<value-of 
select="@c:id"/>" );
-                                       </for-each>
-                               </with-param>
-                       </call-template>
-               </if>
+                               </if>
 
-               //enter states
-               <for-each select="$t/c:targets/c:target/c:enterpath/c:state"> 
-                       <!-- iterate in reverse order -->
-                       <sort select="position()" data-type="number" 
order="descending"/>
-                       <value-of select="."/>.enterAction();
+                               //enter states
+                               <for-each 
select="$t/c:targets/c:target/c:enterpath/c:state"> 
+                                       <!-- iterate in reverse order -->
+                                       <sort select="position()" 
data-type="number" order="descending"/>
+                                       <value-of select="."/>.enterAction();
 
-                       <if test="$genListenerHooks">
-
-                               <call-template name="genForEach">
-                                       <with-param name="var" 
select="'listener'"/>
-                                       <with-param name="in" 
select="'listeners'"/>
-                                       <with-param name="do">
-                                               //to
-                                               listener.onEntry("<value-of 
select="."/>");
-                                       </with-param>
-                               </call-template>
-                       </if>
-               </for-each>
-
-               //update configuration
-               <choose>
-                       <when test="$s/@c:isParallelSubstate and 
not($t/@c:exitsParallelRegion) and not($s/@c:isBasic)">
-                               <call-template 
name="genParallelSubstateAndCompositeConfigurationSetString">
-                                       <with-param name="s" select="$s"/>
-                                       <with-param name="t" select="$t"/>
-                               </call-template>
-                       </when>
-                       <when test="$s/@c:isParallelSubstate and 
not($t/@c:exitsParallelRegion) and $s/@c:isBasic">
-                               <call-template 
name="genParallelSubstateConfigurationSetString">
-                                       <with-param name="s" select="$s"/>
-                                       <with-param name="t" select="$t"/>
-                               </call-template>
-                       </when>
-                       <otherwise>
-                               <call-template 
name="genNonParallelSubstateConfigurationSetString">
-                                       <with-param name="s" select="$s"/>
-                                       <with-param name="t" select="$t"/>
-                               </call-template>
-                       </otherwise>
-               </choose>
+                                       <if test="$genListenerHooks">
 
+                                               <call-template 
name="genForEach">
+                                                       <with-param name="var" 
select="'listener'"/>
+                                                       <with-param name="in" 
select="'listeners'"/>
+                                                       <with-param name="do">
+                                                               //to
+                                                               
listener.onEntry("<value-of select="."/>");
+                                                       </with-param>
+                                               </call-template>
+                                       </if>
+                               </for-each>
 
-               //set whether preempted
-               <if test="$t/@c:isPreempted">
-                       isPreempted = true;
-               </if>
+                               //update configuration
+                               <choose>
+                                       <when test="$s/@c:isParallelSubstate 
and not($t/@c:exitsParallelRegion) and not($s/@c:isBasic)">
+                                               <call-template 
name="genParallelSubstateAndCompositeConfigurationSetString">
+                                                       <with-param name="s" 
select="$s"/>
+                                                       <with-param name="t" 
select="$t"/>
+                                               </call-template>
+                                       </when>
+                                       <when test="$s/@c:isParallelSubstate 
and not($t/@c:exitsParallelRegion) and $s/@c:isBasic">
+                                               <call-template 
name="genParallelSubstateConfigurationSetString">
+                                                       <with-param name="s" 
select="$s"/>
+                                                       <with-param name="t" 
select="$t"/>
+                                               </call-template>
+                                       </when>
+                                       <otherwise>
+                                               <call-template 
name="genNonParallelSubstateConfigurationSetString">
+                                                       <with-param name="s" 
select="$s"/>
+                                                       <with-param name="t" 
select="$t"/>
+                                               </call-template>
+                                       </otherwise>
+                               </choose>
+                       }
+               }
 
-               return;
        </template>
 
        <variable name="genInPredicateFunction">

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl?rev=1032246&r1=1032245&r2=1032246&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StatePatternStatechartGenerator.xsl
 Sun Nov  7 09:40:10 2010
@@ -22,6 +22,7 @@
 
        <import href="AbstractStatechartGenerator.xsl"/>
 
+       <!-- TODO: refactor name of enumeratedEventDispatchInvocation variable. 
it is no longer an invocation -->
        <variable name="enumeratedEventDispatchInvocation" 
select="'state[e]();'"/>
        <variable name="prefixEventDispatchInvocation" 
select="'state.$dispatchPrefixEvent(e)'"/>
        <variable name="defaultEventLiteral" select="'&quot;$default&quot;'"/>
@@ -92,7 +93,7 @@
                                </call-template>
                        </variable>     
 
-                       <value-of 
select="$parentName"/>.$dispatchPrefixEvent(e);
+                       return <value-of 
select="$parentName"/>.$dispatchPrefixEvent(e);
                }
                
        </template>
@@ -121,7 +122,7 @@
                currentConfiguration.splice(
                        <call-template name="genIndexOf">
                                <with-param name="in" 
select="'currentConfiguration'"/>
-                               <with-param name="var" select="'this'"/>
+                               <with-param name="var" select="$s/@id"/>
                        </call-template>
                        ,1,
                        <for-each select="$t/c:targets/c:target/c:targetState">
@@ -178,14 +179,15 @@
                                </call-template>
                        </variable>     
 
-                       <value-of select="$parentName"/>['<value-of 
select="$eventName"/>']();
+                       return <value-of select="$parentName"/>['<value-of 
select="$eventName"/>']();
                }
        </template>
 
+       <!-- FIXME: this can now be taken out/consolidated, as it no longer 
needds to be parameterized -->
        <template name="genHistoryTriggerDispatcherHistoryStateReference">
                <param name="s"/>
 
-               <text>this</text>
+               <value-of select="$s/@id"/>
        </template> 
 
        <template name="genExternalTriggerDispatcherRunToCompletionEventValue">

Added: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl?rev=1032246&view=auto
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
 (added)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
 Sun Nov  7 09:40:10 2010
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
+       xmlns:s="http://www.w3.org/2005/07/scxml";
+       xmlns="http://www.w3.org/2005/07/scxml";
+       xmlns:c="http://commons.apache.org/scxml-js";
+       version="1.0">
+       <xsl:output method="xml"/>
+
+       <xsl:variable name="states" select="//*[self::s:state or 
self::s:parallel or self::s:scxml]"/>
+
+       <!-- identity transform -->
+       <xsl:template match="@*|node()">
+               <xsl:copy>
+                       <xsl:apply-templates select="@*|node()"/>
+               </xsl:copy>
+       </xsl:template>
+
+
+       <xsl:template match="s:transition">
+               <xsl:variable name="lca-id" select="c:lca/text()"/>
+               <xsl:variable name="lca-descendant-basic-states" 
select="$stat...@id=$lca-id]//s:sta...@c:isBasic='true']"/>
+               <!--
+               <xsl:message>
+                       lca-id: <xsl:value-of select="$lca-id"/>
+                       lca-descendant-basic-states id: <xsl:value-of 
select="$lca-descendant-basic-states"/>
+               </xsl:message>
+               -->
+
+               <xsl:copy>
+                       <xsl:apply-templates select="@*|node()"/>
+                       <c:basicStateDescendantsOfLCA>
+                               <xsl:for-each 
select="$lca-descendant-basic-states">
+                                       <c:basicStateDescendant><xsl:value-of 
select="@id"/></c:basicStateDescendant>
+                               </xsl:for-each>
+                       </c:basicStateDescendantsOfLCA>
+               </xsl:copy>
+       </xsl:template>
+
+
+</xsl:stylesheet>
+
+
+

Propchange: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl?rev=1032246&r1=1032245&r2=1032246&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/appendTransitionInformation.xsl
 Sun Nov  7 09:40:10 2010
@@ -22,9 +22,6 @@ conditionally adds the following attribu
 @exitsParallelRegion: if the souce state of a transition is inside a parallel
 region (a child of <parallel>), and the target state is outside of that region
 
-...@ispreempted: if the source is a parallel state or one of his descendants, 
and
-the target is outside of the parallel state that most closely wraps the source
-state
 -->
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
        xmlns:s="http://www.w3.org/2005/07/scxml";
@@ -66,18 +63,6 @@ state
                                        <xsl:value-of select="'true'"/>
                                </xsl:attribute> 
                        </xsl:if>
-
-                       <!-- if the source is a parallel state or one of his 
descendants, 
-                               and the target is outside of the parallel state 
that most closely wraps the source state, 
-                               then we we say he is preempted -->
-                       <xsl:variable name="sourceParallel" 
select="$sourceState/ancestor-or-self::s:parallel[1]"/>
-                       <xsl:variable name="targetParallel" 
select="$targetState/ancestor-or-self::s:parallel[1]"/>
-
-                       <xsl:if test="$sourceParallel and not($sourceParallel = 
$targetParallel)">
-                               <xsl:attribute name="isPreempted" 
namespace="http://commons.apache.org/scxml-js";>
-                                       <xsl:value-of select="'true'"/>
-                               </xsl:attribute> 
-                       </xsl:if>
        
                        <!--
                        <xsl:message>


Reply via email to