Author: jbeard
Date: Thu Mar 17 16:21:40 2011
New Revision: 1082575

URL: http://svn.apache.org/viewvc?rev=1082575&view=rev
Log:
Fixed bug where preempted basic states were not being generated correctly for 
each transition. The LCA of the transition was being used, but really this 
should have been the top-most parallel ancestor, which is still descendant of 
the lca.

Added:
    
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-js-code.properties
      - copied, changed from r1082574, 
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addNearestParallelDescendantOfLCAToTransition.xsl
   (contents, props changed)
      - copied, changed from r1082574, 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
Removed:
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
Modified:
    
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
    
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/backends/js/StateTableStatechartGenerator.xsl
    
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
    commons/sandbox/gsoc/2010/scxml-js/trunk/test/parallel/TestParallel.xml

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties?rev=1082575&r1=1082574&r2=1082575&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties
 Thu Mar 17 16:21:40 2011
@@ -1,4 +1,3 @@
-skip-javascript-generation=true
 skip-preprocessing-xsl=true
 skip-generating-modules=true
 skip-building-dependency-lists=true

Copied: 
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-js-code.properties
 (from r1082574, 
commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties)
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-js-code.properties?p2=commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-js-code.properties&p1=commons/sandbox/gsoc/2010/scxml-js/trunk/run-tests-without-generating-code.properties&r1=1082574&r2=1082575&rev=1082575&view=diff
==============================================================================
    (empty)

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=1082575&r1=1082574&r2=1082575&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
 Thu Mar 17 16:21:40 2011
@@ -302,10 +302,12 @@
 
        <template name="genPreemptedBasicStatesSet">
                <param name="t"/>
+
+               <!-- this should map parallel state id to set of preempted 
basic state descendants --> 
                
                {
                        <!-- TODO: move this out into subclasses -->
-                       <for-each 
select="$t/c:basicStateDescendantsOfLCA/c:basicStateDescendant">
+                       <for-each 
select="$t/c:basicStateDescendantsOfNearestParallelDescendentOfLCA/c:basicStateDescendant">
                                <variable name="basicStateDescendantId" 
select="text()"/>
                                <variable name="descendantState" 
select="$allStates[@id=$basicStateDescendantId]"/>
                                <value-of select="$descendantState/@c:stateNum 
- 1"/> : true

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=1082575&r1=1082574&r2=1082575&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
 Thu Mar 17 16:21:40 2011
@@ -837,6 +837,9 @@
                <param name="t"/>
 
                <variable name="isDeep" select="$s/@type = 'deep'"/>
+
+               <!--<variable name="isChildOfParallel" 
select="$s/../self::s:parallel"/>-->
+
                <variable name="isChildOfParallel" select="local-name($s/..) = 
'parallel'"/>
 
                <variable name="historyStateReference">
@@ -976,7 +979,7 @@
                var statesEntered = [<value-of 
select="$genHistoryTriggerDispatcherInnerForEachStateReference"/>]; 
 
                for(var parent = <value-of 
select="$genHistoryTriggerDispatcherInnerForEachStateReference"/>.parent; 
-                       parent != null &amp;&amp;
+                       parent != <value-of select="$abstractStateName"/> 
&amp;&amp;
                        <choose>
                                <when test="$isChildOfParallel">
                                        <call-template name="genIndexOf">

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=1082575&r1=1082574&r2=1082575&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
 Thu Mar 17 16:21:40 2011
@@ -24,7 +24,7 @@
 
        <c:dependencies>
                <c:dependency 
path="ir-compiler/addDefaultTransitionToHistoryStates.xsl"/>
-               <c:dependency 
path="ir-compiler/addBasicDescendantsToTransitions.xsl"/>
+               <c:dependency 
path="ir-compiler/addNearestParallelDescendantOfLCAToTransition.xsl"/>
                <c:dependency 
path="ir-compiler/addEventRegularExpressions.xsl"/>
                <c:dependency 
path="ir-compiler/appendBasicStateInformation.xsl"/>
                <c:dependency path="ir-compiler/appendStateInformation.xsl"/>
@@ -217,7 +217,7 @@
                <param name="t"/>
                
                {
-                       <for-each 
select="$t/c:basicStateDescendantsOfLCA/c:basicStateDescendant">
+                       <for-each 
select="$t/c:basicStateDescendantsOfNearestParallelDescendentOfLCA/c:basicStateDescendant">
                                <value-of select="text()"/> : true
                                <if test="position() != last()">,</if>
                        </for-each>

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl?rev=1082575&r1=1082574&r2=1082575&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/StateTableStatechartGenerator.xsl
 Thu Mar 17 16:21:40 2011
@@ -30,7 +30,7 @@
        <c:dependencies>
                <c:dependency 
path="ir-compiler/addDefaultTransitionToHistoryStates.xsl"/>
                <c:dependency path="ir-compiler/splitTransitionTargets.xsl"/>
-               <c:dependency 
path="ir-compiler/addBasicDescendantsToTransitions.xsl"/>
+               <c:dependency 
path="ir-compiler/addNearestParallelDescendantOfLCAToTransition.xsl"/>
                <c:dependency 
path="ir-compiler/addEventRegularExpressions.xsl"/>
                <c:dependency 
path="ir-compiler/appendBasicStateInformation.xsl"/>
                <c:dependency path="ir-compiler/appendStateInformation.xsl"/>

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl?rev=1082575&r1=1082574&r2=1082575&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/SwitchyardStatechartGenerator.xsl
 Thu Mar 17 16:21:40 2011
@@ -29,7 +29,7 @@
        <c:dependencies>
                <c:dependency 
path="ir-compiler/addDefaultTransitionToHistoryStates.xsl"/>
                <c:dependency path="ir-compiler/splitTransitionTargets.xsl"/>
-               <c:dependency 
path="ir-compiler/addBasicDescendantsToTransitions.xsl"/>
+               <c:dependency 
path="ir-compiler/addNearestParallelDescendantOfLCAToTransition.xsl"/>
                <c:dependency 
path="ir-compiler/addEventRegularExpressions.xsl"/>
                <c:dependency 
path="ir-compiler/appendBasicStateInformation.xsl"/>
                <c:dependency path="ir-compiler/appendStateInformation.xsl"/>

Copied: 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addNearestParallelDescendantOfLCAToTransition.xsl
 (from r1082574, 
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/addNearestParallelDescendantOfLCAToTransition.xsl?p2=commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addNearestParallelDescendantOfLCAToTransition.xsl&p1=commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl&r1=1082574&r2=1082575&rev=1082575&view=diff
==============================================================================
--- 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addBasicDescendantsToTransitions.xsl
 (original)
+++ 
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/ir-compiler/addNearestParallelDescendantOfLCAToTransition.xsl
 Thu Mar 17 16:21:40 2011
@@ -39,7 +39,14 @@
 
        <xsl:template match="s:transition[@target]">
                <xsl:variable name="lca-id" select="c:lca/text()"/>
-               <xsl:variable name="lca-descendant-basic-states" 
select="$states[@id=$lca-id]//s:state[@c:isBasic='true']"/>
+               <!-- select the paralellel ancestor of target state with least 
depth, up to, but not including the lca-->
+               <xsl:variable name="lca" select="$states[@id=$lca-id]"/>
+
+               <xsl:variable name="lca-parallel-descendants" 
select="$lca//s:parallel"/>
+               <xsl:variable name="target-parallel-ancestors" 
select="./ancestor::s:parallel"/>
+
+               <!-- intersection idiom: 
http://www.dpawson.co.uk/xsl/sect2/N4486.html#d5509e1351 -->
+               <xsl:variable 
name="target-parallel-ancestors-and-lca-descendants" 
select="$lca-parallel-descendants[count(.|$target-parallel-ancestors) = 
count($target-parallel-ancestors)]"/>
                <!--
                <xsl:message>
                        lca-id: <xsl:value-of select="$lca-id"/>
@@ -49,11 +56,18 @@
 
                <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:if 
test="$target-parallel-ancestors-and-lca-descendants">
+                               <xsl:variable 
name="nearest-parallel-descendent-of-lca" 
select="$target-parallel-ancestors-and-lca-descendants[1]"/>
+                               <xsl:variable 
name="basic-state-descendants-of-nearest-parallel-descendent-of-lca" 
select="$nearest-parallel-descendent-of-lca//*[@c:isBasic]"/>
+
+                               <c:nearestParallelDescendantOfLCA><xsl:value-of 
select="$nearest-parallel-descendent-of-lca/@id"/></c:nearestParallelDescendantOfLCA>
+                               
<c:basicStateDescendantsOfNearestParallelDescendentOfLCA>
+                                       <xsl:for-each 
select="$basic-state-descendants-of-nearest-parallel-descendent-of-lca">
+                                               
<c:basicStateDescendant><xsl:value-of select="@id"/></c:basicStateDescendant>
+                                       </xsl:for-each>
+                               
</c:basicStateDescendantsOfNearestParallelDescendentOfLCA>
+                       </xsl:if>
                </xsl:copy>
        </xsl:template>
 
@@ -62,3 +76,4 @@
 
 
 
+

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

Modified: 
commons/sandbox/gsoc/2010/scxml-js/trunk/test/parallel/TestParallel.xml
URL: 
http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/test/parallel/TestParallel.xml?rev=1082575&r1=1082574&r2=1082575&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/test/parallel/TestParallel.xml 
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/test/parallel/TestParallel.xml Thu 
Mar 17 16:21:40 2011
@@ -71,7 +71,7 @@ This is to test the use of the In() pred
                <transition target="p3" event="t6_10"/>
        </parallel>
 
-       <parallel id="p3">
+       <parallel id="p3" initial="deep_history">
                <history type="deep" id="deep_history">
                        <transition target="c1 c2"/>
                </history>


Reply via email to