Revision: 1950
          http://svn.sourceforge.net/vexi/?rev=1950&view=rev
Author:   mkpg2
Date:     2007-07-08 11:04:46 -0700 (Sun, 08 Jul 2007)

Log Message:
-----------
Fix. Can now return non-null before cascade in Children trap.

Modified Paths:
--------------
    core/trunk/org.ibex.js/src/org/ibex/js/Interpreter.jpp
    core/trunk/org.ibex.js/src/org/ibex/js/Thread.java
    core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp
    
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java
    
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/readNoCascade.t
    
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/writeNoCascade.t

Modified: core/trunk/org.ibex.js/src/org/ibex/js/Interpreter.jpp
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/Interpreter.jpp      2007-07-08 
16:38:07 UTC (rev 1949)
+++ core/trunk/org.ibex.js/src/org/ibex/js/Interpreter.jpp      2007-07-08 
18:04:46 UTC (rev 1950)
@@ -218,7 +218,6 @@
                         continue OUTER;
                     } else if (o instanceof CallMarker) {
                        boolean isWriteTrap = false;
-                        boolean didTrapPut = false;
                         if (o instanceof TrapMarker) { // handles return 
component of a write trap
                             TrapMarker tm = (TrapMarker) o;
                             isWriteTrap = tm.t.isWriteTrap();
@@ -232,13 +231,8 @@
                         scope = cm.scope;
                         pc = cm.pc - 1;
                         f = cm.f;
-                        if (didTrapPut) {
-                            if (((TrapMarker)cm).pauseOnCascade) { pc++; 
return ((TrapMarker)cm).val; }
-                            if (pausecount > 0) { pc++; return null; }   // we 
were paused
-                        } else {
-                               if(!isWriteTrap)
-                                       stack.push(retval);
-                        }
+                        if(!isWriteTrap)
+                               stack.push(retval);
                         if (f == null) return retval;
                         continue OUTER;
                     }

Modified: core/trunk/org.ibex.js/src/org/ibex/js/Thread.java
===================================================================
--- core/trunk/org.ibex.js/src/org/ibex/js/Thread.java  2007-07-08 16:38:07 UTC 
(rev 1949)
+++ core/trunk/org.ibex.js/src/org/ibex/js/Thread.java  2007-07-08 18:04:46 UTC 
(rev 1950)
@@ -107,7 +107,7 @@
        
        
        /** Execute read traps, part 1 */
-       public static void runBeforeGet(Trap t, JS trapname) throws JSExn{
+       public static JS runBeforeGet(Trap t, JS trapname) throws JSExn{
                if( current==null)      setCurrent(new 
Thread(t.function(),false,null));
                Interpreter old = current.currentInterpreter;
                current.currentInterpreter = new Interpreter(t, null, true, 
trapname);
@@ -116,7 +116,7 @@
                // cannot be interefered with by other js executions. Could be 
done in the
                // interpreter when returning instead of cascading as well.
                Thread.cascadedTo = null;
-               current.currentInterpreter.run(null);
+               return (JS) current.currentInterpreter.run(null);
                //
                //System.out.println("cascadedTo " + cascadedTo);
        }

Modified: core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp  2007-07-08 16:38:07 UTC 
(rev 1949)
+++ core/trunk/org.vexi.core/src/org/vexi/core/Box.jpp  2007-07-08 18:04:46 UTC 
(rev 1950)
@@ -1527,9 +1527,9 @@
         JS value = null;
        try{
                if(rangeTrap != null){
-                       Thread.runBeforeGet(rangeTrap, JSU.N(i));
+                       JS val = Thread.runBeforeGet(rangeTrap, JSU.N(i));
                        JS jsi = Thread.cascadedTo;
-                       if(jsi==null) return null;
+                       if(jsi==null) return val;
                        i = JSU.toInt(jsi);
                }
                if(redirect!=this){

Modified: 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java
===================================================================
--- 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java
 2007-07-08 16:38:07 UTC (rev 1949)
+++ 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/TestChildrenTrap.java
 2007-07-08 18:04:46 UTC (rev 1950)
@@ -28,7 +28,7 @@
     public static void main(String[] args) throws Throwable {
 
        CoreTestSuite cts = new TestChildrenTrap();
-       TestCase t = cts.createTestCase(cts.getResourceDirs(), "readJSExn.t");
+       TestCase t = cts.createTestCase(cts.getResourceDirs(), 
"readNoCascade.t");
        t.runBare();
        }
 }

Modified: 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/readNoCascade.t
===================================================================
--- 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/readNoCascade.t   
    2007-07-08 16:38:07 UTC (rev 1949)
+++ 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/readNoCascade.t   
    2007-07-08 18:04:46 UTC (rev 1950)
@@ -3,6 +3,10 @@
 
        var b = vexi.box;
        var entered = false;
+       var ca = lib..newBox("a");
+       var cb = lib..newBox("b");
+       var cc = lib..newBox("c");
+
        b.Children ++=function(){
                vexi.log.info("not here");
                entered = true;
@@ -12,17 +16,16 @@
                vexi.log.info("here " + (0 == trapname));
                // don't cascade
                if(0 == trapname) return null;
+               if(2 == trapname) return cc;
                return cascade;
        };
-       var ca = lib..newBox("a");
-       var cb = lib..newBox("b");
        b[0] = ca;
        b[1] = cb;
-       .util..assertEquals(null, b[0]);
-    assert(!entered);
-       .util..assertEquals(cb,b[1]);
-    assert(entered);
+       //.util..assertEquals(null, b[0]);
+    //assert(!entered);
+       //.util..assertEquals(cb,b[1]);
+    //assert(entered);
+    .util..assertEquals(cc,b[2]);
     
-    
     <ui:box/>
 </vexi>

Modified: 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/writeNoCascade.t
===================================================================
--- 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/writeNoCascade.t  
    2007-07-08 16:38:07 UTC (rev 1949)
+++ 
core/trunk/org.vexi.core/src_junit/test/core/box/childrentrap/writeNoCascade.t  
    2007-07-08 18:04:46 UTC (rev 1950)
@@ -15,11 +15,11 @@
                vexi.log.info("here");
                // don't cascade
                if(ca == v) return true;
-               
+               cascade = v;
        };
-       /*b[0] = ca;
+       b[0] = ca;
        .util..assertEquals(null,b[0]);
-    assert(!entered);*/
+    assert(!entered);
     b[1] = cb;
        .util..assertEquals(cb,b[0]);
     assert(entered);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to