Revision: 3633
          http://vexi.svn.sourceforge.net/vexi/?rev=3633&view=rev
Author:   mkpg2
Date:     2009-08-30 00:32:13 +0000 (Sun, 30 Aug 2009)

Log Message:
-----------
Feature. Vexiscript niceties
  - destructurings  e.g. [a,b] = [b,a]
  - iterate values  for(var k,v in obj) 

Modified Paths:
--------------
    trunk/core/org.ibex.js/src/org/ibex/js/Interpreter.jpp
    trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp
    trunk/core/org.ibex.js/src/org/ibex/js/JSFunction.java
    trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp
    trunk/core/org.ibex.js/src/org/ibex/js/Methods.java
    trunk/core/org.ibex.js/src/org/ibex/js/Parser.java
    trunk/core/org.ibex.js/src_dev/org/ibex/js/DevUtil.java
    trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestCase.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestSuite.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/general/TestGeneral.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin.js
    trunk/core/org.ibex.js/src_junit/test/js/exec/interrupt/TestInterrupt.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java
    trunk/core/org.ibex.js/src_junit/test/js/exec/stream/TestStream.java
    trunk/core/org.ibex.js/src_junit/test/js/parse/TestParse.java
    trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java
    trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java
    trunk/core/org.vexi.core/src_junit/test/core/CoreTestSuite.java
    trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java
    trunk/core/org.vexi.core/src_junit/test/core/gut/TestGUT.java
    trunk/core/org.vexi.devl/src/org/vexi/devl/Main.java
    trunk/core/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java

Added Paths:
-----------
    trunk/core/org.ibex.js/src_dev/dev/IOUtil.java
    trunk/core/org.ibex.js/src_dev/dev/ParseFile.java
    trunk/core/org.ibex.js/src_dev/dev/statement.js
    trunk/core/org.ibex.js/src_junit/test/js/exec/general/destructuring.js
    trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin2.js

Property Changed:
----------------
    trunk/core/org.ibex.js/


Property changes on: trunk/core/org.ibex.js
___________________________________________________________________
Modified: svn:ignore
   - 
src_gen/*
bin
src_gen

_temp_

src_gen*

   + 
src_gen/*
bin
src_gen

_temp_

src_gen*

*.txt


Modified: trunk/core/org.ibex.js/src/org/ibex/js/Interpreter.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/Interpreter.jpp      2009-08-28 
14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src/org/ibex/js/Interpreter.jpp      2009-08-30 
00:32:13 UTC (rev 3633)
@@ -177,6 +177,10 @@
                 op = fd.op;
                 arg = fd.arg;
             }
+            
+            // DEBUG
+            // DevUtil.debugStack(this, op, arg);
+               
             switch(op) {
             case LITERAL: stack.push(arg); break;
             // GUT ought to fetch constructors
@@ -188,7 +192,10 @@
             case JMP: jump(JSU.toInt((JS)arg) - 1); break;
             case POP: stack.pop(); break;
             case SWAP: stack.swap(); break;
-            case DUP: stack.push(stack.peek()); break;
+            case DUP: 
+               if(arg==null) stack.push(stack.peek()); 
+               else stack.push(stack.peek(JSU.toInt((JS)arg)));
+               break;
             case NEWSCOPE: {
                 int n = JSU.toInt((JS)arg);
                 scope = new Scope(scope,(n>>>16)&0xffff,(n>>>0)&0xffff);
@@ -391,9 +398,14 @@
                     key = arg == null ? (JS)stack.pop() : (JS)arg;
                     target = (JS)stack.pop();
                 } else {
-                    key = (JS)stack.pop();
-                    target = (JS)stack.peek();
-                    stack.push(key);
+                       if(arg==null){
+                        key = (JS)stack.pop();
+                        target = (JS)stack.peek();
+                        stack.push(key);
+                       }else{
+                               key = (JS)arg;
+                               target = (JS)stack.peek();
+                       }
                 }
                 JS ret = null;
                 if (key == null) throw je("Tried to get the null key from " + 
JSU.toString(target));
@@ -871,7 +883,11 @@
         
         boolean empty() { return sp == 0; }
         void push(Object o) throws JSExn { if(sp == stack.length) grow(); 
stack[sp++] = o; }
-        Object peek() { if(sp == 0) throw new RuntimeException("stack 
underflow"); return stack[sp-1]; }
+        Object peek() { return peek(0); }
+        Object peek(int i) { 
+               if(sp -i <= 0) throw new RuntimeException("stack underflow"); 
+               return stack[sp-1-i]; 
+        }
         final Object pop() { if(sp == 0) throw new RuntimeException("stack 
underflow"); return stack[--sp]; }
         void swap() throws JSExn {
             if(sp < 2) throw new JSExn("stack overflow");
@@ -905,6 +921,9 @@
         
         void backtrace(JSExn e) {
                int i = sp;
+               // DEBUG (MAY add this to JSexn)
+               // e.addBacktrace("(Bytecode " + pc+")");
+                       
                boolean topcall = true;
                while( (i=previous(i))!=-1){
                        Backtraceable cm = (Backtraceable)stack[i];
@@ -932,6 +951,14 @@
                return null;
         }
         
+        public String toString(){
+               String r = "";
+               for(int i=0; i<sp; i++){
+                       r+= JSU.toString(stack[i]);
+                       r+=", ";
+               }
+               return r;
+        }
         /*
         void backtrace(JSExn e) {
                for(int i=sp-1;i>=0;i--) {

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp    2009-08-28 14:49:16 UTC 
(rev 3632)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSExn.jpp    2009-08-30 00:32:13 UTC 
(rev 3633)
@@ -23,18 +23,20 @@
 
     final Basket.List backtrace = new Basket.Array();
     final private ExnJSObj js ;
-    
     public JSExn(InterruptedException e) {
-       this(JSU.S("JS thread interrupted"), SC_interrupted); 
+       this("JS thread interrupted", SC_interrupted, e); 
     }
     public JSExn(Throwable e) {
        this("Unexpected Java exception thrown by the core\n" + 
e.getClass().getName() + ":" + e.getMessage(),e);
     }
     public JSExn(String msg, Throwable e) {
+       this(msg, SC_error, e);
+    }
+        
+    
+    public JSExn(String msg, JS type, Throwable e) {
        super(e);
-       this.js = new ExnJSObj(
-                       JSU.S(msg)
-                       , SC_error); 
+       this.js = new ExnJSObj(JSU.S(msg), type); 
        fill(null);
     }
     public JSExn(String s) { this(JSU.S(s)); }
@@ -68,7 +70,7 @@
                StringWriter sw = new StringWriter(1024);
                PrintWriter pw = new PrintWriter(sw);
                printStackTrace(pw,logger.getLevel());
-               logger.log(o, sw.toString(), level);
+               logger.log(o, sw.toString(), logger.getLevel());
        }
     }
     public void printStackTrace(PrintWriter pw, int level) {
@@ -84,7 +86,9 @@
         // java stack trace of the jsexn only gets printed when debug log 
level is set.
         if(level<=Logger.DEBUG) super.printStackTrace(pw);
         else if(getCause()!=null){
-               if(level<=Logger.WARN)  getCause().printStackTrace(pw);
+               if(level<=Logger.ERROR && js.getSafe(SC_type).equals(SC_error)) 
{
+                       getCause().printStackTrace(pw);
+               }
         }
         pw.flush();
     }

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSFunction.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSFunction.java      2009-08-28 
14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSFunction.java      2009-08-30 
00:32:13 UTC (rev 3633)
@@ -83,11 +83,16 @@
     int get(int pos) { return op[pos]; }
     Object getArg(int pos) { return arg[pos]; }
     void set(int pos, int op_, Object arg_) { op[pos] = op_; arg[pos] = arg_; }
-    void set(int pos, Object arg_) { arg[pos] = arg_; }
+    void set(int pos, Object arg_) {
+       if(arg_ instanceof Boolean)
+               System.err.println("!");
+       arg[pos] = arg_; 
+    }
     int pop() { size--; arg[size] = null; return op[size]; }
     void paste(JSFunction other) { for(int i=0; i<other.size; i++) 
add(other.line[i], other.op[i], other.arg[i]); }
     JSFunction add(int line, int op_) { return add(line, op_, null); }
     JSFunction add(int line, int op_, Object arg_) {
+
         if (size == op.length - 1) {
             int[] line2 = new int[op.length * 2]; System.arraycopy(this.line, 
0, line2, 0, op.length); this.line = line2;
             Object[] arg2 = new Object[op.length * 2]; System.arraycopy(arg, 
0, arg2, 0, arg.length); arg = arg2;
@@ -95,7 +100,7 @@
         }
         this.line[size] = line;
         op[size] = op_;
-        arg[size] = arg_;
+        set(size, arg_);
         size++;
         return this;
     }
@@ -114,7 +119,7 @@
             sb.append(i).append(" (").append(line[i]).append("): ");
             sb.append(JSU.opName(op[i]));
             sb.append(" ");
-            sb.append(a == null ? "(no arg)" : a instanceof JS ? 
JSU.toString((JS)a) : a);
+            sb.append(a == null ? "(no arg)" : JSU.toString(a));
             if((op[i] == JF || op[i] == JT || op[i] == JMP) && a != null && a 
instanceof Number) {
                 sb.append(" jump to ").append(i+((Number) a).intValue());
             } else  if(op[i] == TRY) {
@@ -138,9 +143,9 @@
        return "function:"+definedAt()+ "$" + Integer.toHexString(hashCode());
     }
 
-//    public String toString() {
-//     return dump();
-//    }
+    public String toString() {
+       return dump();
+    }
     
        /*public boolean checkEndsWell() {
                validTrap = (op[size-1]==RETURN) || (op[size-1]==THROW) || 
(op[size-2]==CASCADE);

Modified: trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp      2009-08-28 14:49:16 UTC 
(rev 3632)
+++ trunk/core/org.ibex.js/src/org/ibex/js/JSU.jpp      2009-08-30 00:32:13 UTC 
(rev 3633)
@@ -110,6 +110,11 @@
         if(o == null) return "null";
         return o.coerceToString();
     }
+    public static String toString(Object o) {
+        if(o == null) return "null";
+        else if(o instanceof JS) return ((JS)o).coerceToString();
+        return 
o.getClass().getSimpleName()+"@"+Integer.toHexString(o.hashCode());
+    }
 
     
     public static boolean isInt(JS o) {

Modified: trunk/core/org.ibex.js/src/org/ibex/js/Methods.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/Methods.java 2009-08-28 14:49:16 UTC 
(rev 3632)
+++ trunk/core/org.ibex.js/src/org/ibex/js/Methods.java 2009-08-30 00:32:13 UTC 
(rev 3633)
@@ -101,14 +101,10 @@
        JS arg = args[0];
        JS globalScope = args.length<2?new JS.Obj():args[1];
        String s = JSU.toString(arg);
-       try{
-               JSFunction f = Parser.fromReader("<eval>", 1, 
+       JSFunction f = Parser.fromReader("<eval>", 1, 
                                new StringReader(s), null);
 
-               return JSU.cloneWithNewGlobalScope(f, globalScope).apply(null, 
EMPTY_JS_ARRAY);
-       }catch(IOException e){
-               throw new JSExn(e);
-       }
+       return JSU.cloneWithNewGlobalScope(f, globalScope).apply(null, 
EMPTY_JS_ARRAY);
     }
     
     static public JS fromCharCode(JS[] args) throws JSExn{

Modified: trunk/core/org.ibex.js/src/org/ibex/js/Parser.java
===================================================================
--- trunk/core/org.ibex.js/src/org/ibex/js/Parser.java  2009-08-28 14:49:16 UTC 
(rev 3632)
+++ trunk/core/org.ibex.js/src/org/ibex/js/Parser.java  2009-08-30 00:32:13 UTC 
(rev 3633)
@@ -5,7 +5,6 @@
 package org.ibex.js;
 
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.io.Reader;
 import java.util.HashMap;
 import java.util.Map;
@@ -73,7 +72,7 @@
  *  need to move to a parse tree format.
  */
 public class Parser extends Lexer implements ByteCodes, Constants{
-    
+    static public boolean newfor = true;
        /** Special slots for special variables */
        static public final int SLOT_ARGUMENTS = -1;
        static public final int SLOT_TRAPNAME = -2;
@@ -85,13 +84,6 @@
 
     Parser(Reader r, String sourceName, int line, GlobalsChecker param) throws 
IOException { super(r, sourceName, line); this.param = param; }
 
-    /** for debugging */
-    public static void main(String[] s) throws IOException {
-        JS block = Parser.fromReader("stdin", 0, new 
InputStreamReader(System.in), null);
-        if (block == null) return;
-        System.out.println(block);
-    }
-
     // Statics ////////////////////////////////////////////////////////////
 
     static byte[] precedence = new byte[MAX_TOKEN + 1];
@@ -250,13 +242,54 @@
        f.validTrap = true;
     }
     
+    JS scopeAccess(JSFunction b, String name) throws IOException{
+       ScopeEntry entry = scopeEntry(name);
+        JS varKey = null;
+        if(entry == null) {
+            b.add(parserLine, GLOBALSCOPE);
+            b.add(parserLine, LITERAL, JSString.intern(name));
+        }else{
+               if(entry.isConst) {
+                       String varname = name;
+                       int peek = peekToken();
+                       switch(peek){
+                       case ASSIGN_BITOR: case ASSIGN_BITXOR: case 
ASSIGN_BITAND: case ASSIGN_LSH: case ASSIGN_RSH: case ASSIGN_URSH:
+                       case ASSIGN_MUL: case ASSIGN_DIV: case ASSIGN_MOD: case 
ASSIGN_ADD: case ASSIGN_SUB:
+                       case INC: case DEC: case ASSIGN:
+                               throw pe("const assignment after declaration: 
"+varname);
+                       default:
+                       }
+               }
+               varKey = entry.slot;
+        }
+       return varKey;
+    }
+    
+    private void outputAssign(JSFunction b, Object varKey){
+        if(varKey == null) {
+               b.add(parserLine, PUT);
+               b.add(parserLine, SWAP);
+               b.add(parserLine, POP);
+           } else {
+               b.add(parserLine, SCOPEPUT, varKey);
+           }
+    }
+    
     // Parsing Logic /////////////////////////////////////////////////////////
     
     /** parse and compile a function */
-    public static JSFunction fromReader(String sourceName, int firstLine, 
Reader sourceCode, GlobalsChecker param) throws IOException {
-        if (sourceCode == null) return new JSFunction(sourceName, firstLine, 
null);
-        Parser p = new Parser(sourceCode, sourceName, firstLine, param);
-        return p.parseScript(null);
+    public static JSFunction fromReader(String sourceName, int firstLine, 
Reader sourceCode, GlobalsChecker param) throws JSExn {
+       try{
+               if (sourceCode == null) return new JSFunction(sourceName, 
firstLine, null);
+               Parser p = new Parser(sourceCode, sourceName, firstLine, param);
+               return p.parseScript(null);
+       } catch(SourceException e) {
+               // FEATURE create JSExn constructor that takes a 
SourceException -
+               // and so pass on more information as exception properties.
+               throw new JSExn("Could not parse script, " + sourceName + ":" + 
firstLine+"\n"+e.getMessageSig()+ " " + e.getWhere()+ e.getMessage(), 
JSU.S("parse"), e);
+       } catch (Exception e) {
+               throw new JSExn("Unexpected error parsing " + sourceName + ":" 
+ firstLine, e);
+       }
     }
     
     public JSFunction parseScript(Scope scope) throws IOException{
@@ -379,13 +412,16 @@
             if(!sg) b.add(parserLine, GET_PRESERVE, Boolean.TRUE);
             b.add(parserLine, LITERAL, NC_1);
             b.add(parserLine, tok == INC ? ADD : SUB, NC_2);
-            if(sg) {
-                b.add(parserLine, SCOPEPUT, b.getArg(prev));
-            } else {
-                b.add(parserLine, PUT, null);
-                b.add(parserLine, SWAP, null);
-                b.add(parserLine, POP, null);
-            }
+            
+            Object varKey = sg?b.getArg(prev):null;
+            outputAssign(b, varKey);
+//            if(sg) {
+//                b.add(parserLine, SCOPEPUT, b.getArg(prev));
+//            } else {
+//                b.add(parserLine, PUT, null);
+//                b.add(parserLine, SWAP, null);
+//                b.add(parserLine, POP, null);
+//            }
             break;
         }
         case BANG: case BITNOT: case TYPEOF:{
@@ -420,25 +456,7 @@
             break;
         }
         case NAME: {
-            ScopeEntry entry = scopeEntry(string);
-            JS varKey = null;
-            if(entry == null) {
-                b.add(parserLine, GLOBALSCOPE);
-                b.add(parserLine, LITERAL, JSString.intern(string));
-            }else{
-               if(entry.isConst) {
-                       String varname = string;
-                       int peek = peekToken();
-                       switch(peek){
-                       case ASSIGN_BITOR: case ASSIGN_BITXOR: case 
ASSIGN_BITAND: case ASSIGN_LSH: case ASSIGN_RSH: case ASSIGN_URSH:
-                       case ASSIGN_MUL: case ASSIGN_DIV: case ASSIGN_MOD: case 
ASSIGN_ADD: case ASSIGN_SUB:
-                       case INC: case DEC: case ASSIGN:
-                               throw pe("const assignment after declaration: 
"+varname);
-                       default:
-                       }
-               }
-               varKey = entry.slot;
-            }
+            JS varKey = scopeAccess(b,string);
             continueExprAfterAssignable(b,minPrecedence,varKey);
             break;
         }
@@ -559,7 +577,7 @@
         }
         case INC: case DEC: { // postfix
             if(varKey == null) {
-                b.add(parserLine, GET_PRESERVE, Boolean.TRUE);
+                b.add(parserLine, GET_PRESERVE);
                 b.add(parserLine, LITERAL, NC_1);
                 b.add(parserLine, tok == INC ? ADD : SUB, NC_2);
                 b.add(parserLine, PUT, null);
@@ -579,13 +597,7 @@
         }
         case ASSIGN: {
             startExpr(b, precedence[tok]);
-            if(varKey == null) {
-                b.add(parserLine, PUT);
-                b.add(parserLine, SWAP);
-                b.add(parserLine, POP);
-            } else {
-                b.add(parserLine, SCOPEPUT, varKey);
-            }
+            outputAssign(b, varKey);
             break;
         }
         case LP: {
@@ -1024,57 +1036,77 @@
             
         case FOR: {
             consume(LP);
+//            
+//            if(newfor){
+            boolean hadVar = false;                                     
+            String name1 = null;
+            String name2 = null;
             
-            tok = getToken();
-            boolean hadVar = false;                                      // if 
it's a for..in, we ignore the VAR
-            if (tok == VAR) { hadVar = true; tok = getToken(); }
-            String varName = string;
-            boolean forIn = peekToken() == IN;                           // 
determine if this is a for..in loop or not
-            pushBackToken(tok, varName);
-            
-            if (forIn) {
-                consume(NAME);
-                consume(IN);
-                startExpr(b,-1);
+            if (peekToken() == VAR) { consume(VAR); hadVar = true;  }
+            if (peekToken() == NAME) { consume(NAME); name1 = string; }
+            if (peekToken() == COMMA) { consume(COMMA); consume(NAME); name2 = 
string; }
+            if (peekToken() == IN){
+                // for( ... in ...)    
+               consume(IN);
+               startExpr(b,-1);
                 consume(RP);
                 
-                b.add(parserLine, PUSHKEYS);
-                b.add(parserLine, LITERAL, SC_iterator);
-                b.add(parserLine, GET_PRESERVE);
-                b.add(parserLine, CALLMETHOD, NC_0);                
+                b.add(parserLine, PUSHKEYS);              // o,k
+                b.add(parserLine, LITERAL, SC_iterator);  // o,k,"iterator"
+                b.add(parserLine, GET_PRESERVE);          // 
o,k,"iterator",Stub
+                b.add(parserLine, CALLMETHOD, NC_0);      // o,k,I           
                 int size = b.size;
-                b.add(parserLine, LOOP);
-                b.add(parserLine, POP);
-                
-                b.add(parserLine,SWAP); // get the keys enumeration object on 
top
-                b.add(parserLine,DUP);
-                b.add(parserLine,GET,SC_hasNext);
+                b.add(parserLine, LOOP);                  // o,k,I,LM,true
+                b.add(parserLine, POP);                   // o,k,I,LM
+                // get the keys enumeration object on top
+                b.add(parserLine,SWAP);                   // o,k,LM,I
+                b.add(parserLine,DUP);                    // o,k,LM,I,I
+                b.add(parserLine,GET,SC_hasNext);         // o,k,LM,I,bool
                 int size2 = b.size;
-                b.add(parserLine,JT);
+                b.add(parserLine,JT);                     // o,k,LM,I
                 b.add(parserLine,SWAP);
                 b.add(parserLine,BREAK);
                 b.set(size2, JSU.N(b.size - size2));
-                b.add(parserLine,DUP);
-                b.add(parserLine,GET,SC_next);
+                b.add(parserLine,DUP);                    // o,k,LM,I,I
+                b.add(parserLine,GET,SC_next);            // o,k,LM,I,key
 
                 scopePush(b);
                 
-                if(hadVar) scopeDeclare(varName, false);
-                JS varKey = scopeKey(varName);
-                
-                if(varKey == null) {
+                if(hadVar) scopeDeclare(name1, false);
+                JS varKey1 = scopeKey(name1);
+                if(varKey1 == null) {
                     b.add(parserLine,GLOBALSCOPE);
                     b.add(parserLine,SWAP);
-                    b.add(parserLine, LITERAL, JSString.intern(varName));
+                    b.add(parserLine, LITERAL, JSString.intern(name1));
                     b.add(parserLine,SWAP);
                     b.add(parserLine,PUT);
                     b.add(parserLine,POP);
                 } else {
-                    b.add(parserLine, SCOPEPUT, varKey);
+                    b.add(parserLine, SCOPEPUT, varKey1);  // o,k,LM,I,key
                 }
-                b.add(parserLine,POP);  // pop the put'ed value
-                b.add(parserLine,SWAP); // put CallMarker back into place
+                // pop the put'ed value & put CallMarker back into place
+                       
+                if(name2!=null){
+                       b.add(parserLine,DUP,NC_3);   // o,k,I,LM,k,o 
+                       b.add(parserLine,SWAP);       // o,k,I,LM,o,k
+                       b.add(parserLine,GET);        // o,k,I,LM,v
+                       if(hadVar) scopeDeclare(name2, false);
+                    JS varKey2 = scopeKey(name2);
+                       if(varKey2 == null) {
+                        b.add(parserLine,GLOBALSCOPE);
+                        b.add(parserLine,SWAP);
+                        b.add(parserLine, LITERAL, JSString.intern(name2));
+                        b.add(parserLine,SWAP);
+                        b.add(parserLine,PUT);
+                        b.add(parserLine,POP);
+                       } else {
+                        b.add(parserLine, SCOPEPUT, varKey2);  // o,k,LM,I,v
+                    }
+                }
+                b.add(parserLine,POP);                     // o,k,LM,I
+                b.add(parserLine,SWAP);                    // o,k,I,LM 
                 
+                
                 parseStatement(b, null);
                 
                 scopePop(b);
@@ -1083,11 +1115,15 @@
                 b.set(size, JSU.N(b.size - size));
                 
                 b.add(parserLine, POP);
-            } else {
-                if (hadVar) pushBackToken(VAR, null);                    // 
yeah, this actually matters
-                scopePush(b);                             // grab a fresh scope
-                    
-                parseStatement(b, null);                                 // 
initializer
+            }else{
+               // for( ... ; ... ; ...) 
+               if(name2!=null) { pushBackToken(NAME, name2);  
pushBackToken(COMMA,null); }
+               if(name1!=null) { pushBackToken(NAME, name1); }
+               if (hadVar)     { pushBackToken(VAR, null); }      // yeah, 
this actually matters
+               
+                scopePush(b);                                      // grab a 
fresh scope
+                
+                parseStatement(b, null);                           // 
initializer
                 JSFunction e2 =                                    // we need 
to put the incrementor before the test
                     new JSFunction(sourceName, parserLine, null);  // so we 
save the test here
                 if (peekToken() != SEMI)
@@ -1116,7 +1152,104 @@
                 b.set(size2 - 1, JSU.N(b.size - size2 + 1));     // end of the 
loop
                     
                 scopePop(b);                            // get our scope back
+               
             }
+               
+//            }else{
+//            
+//                 tok = getToken();
+//                 boolean hadVar = false;                                     
 // if it's a for..in, we ignore the VAR
+//                 if (tok == VAR) { hadVar = true; tok = getToken(); }
+//                 String varName = string;
+//                 boolean forIn = peekToken() == IN;                          
 // determine if this is a for..in loop or not
+//                 pushBackToken(tok, varName);
+//                 
+//                 if (forIn) {
+//                     consume(NAME);
+//                     consume(IN);
+//                     startExpr(b,-1);
+//                     consume(RP);
+//                     
+//                     b.add(parserLine, PUSHKEYS);
+//                     b.add(parserLine, LITERAL, SC_iterator);
+//                     b.add(parserLine, GET_PRESERVE);
+//                     b.add(parserLine, CALLMETHOD, NC_0);                
+//                     int size = b.size;
+//                     b.add(parserLine, LOOP);
+//                     b.add(parserLine, POP);
+//                     
+//                     b.add(parserLine,SWAP); // get the keys enumeration 
object on top
+//                     b.add(parserLine,DUP);
+//                     b.add(parserLine,GET,SC_hasNext);
+//                     int size2 = b.size;
+//                     b.add(parserLine,JT);
+//                     b.add(parserLine,SWAP);
+//                     b.add(parserLine,BREAK);
+//                     b.set(size2, JSU.N(b.size - size2));
+//                     b.add(parserLine,DUP);
+//                     b.add(parserLine,GET,SC_next);
+//     
+//                     scopePush(b);
+//                     
+//                     if(hadVar) scopeDeclare(varName, false);
+//                     JS varKey = scopeKey(varName);
+//                     
+//                     if(varKey == null) {
+//                         b.add(parserLine,GLOBALSCOPE);
+//                         b.add(parserLine,SWAP);
+//                         b.add(parserLine, LITERAL, 
JSString.intern(varName));
+//                         b.add(parserLine,SWAP);
+//                         b.add(parserLine,PUT);
+//                         b.add(parserLine,POP);
+//                     } else {
+//                         b.add(parserLine, SCOPEPUT, varKey);
+//                     }
+//                     b.add(parserLine,POP);  // pop the put'ed value
+//                     b.add(parserLine,SWAP); // put CallMarker back into 
place
+//                     
+//                     parseStatement(b, null);
+//                     
+//                     scopePop(b);
+//                     b.add(parserLine, CONTINUE);
+//                     // jump here on break
+//                     b.set(size, JSU.N(b.size - size));
+//                     
+//                     b.add(parserLine, POP);
+//                 } else {
+//                     if (hadVar) pushBackToken(VAR, null);                   
 // yeah, this actually matters
+//                     scopePush(b);                             // grab a 
fresh scope
+//                         
+//                     parseStatement(b, null);                                
 // initializer
+//                     JSFunction e2 =                                    // 
we need to put the incrementor before the test
+//                         new JSFunction(sourceName, parserLine, null);  // 
so we save the test here
+//                     if (peekToken() != SEMI)
+//                         startExpr(e2, -1);
+//                     else
+//                         e2.add(parserLine, JSFunction.LITERAL, JSU.T);      
   // handle the for(foo;;foo) case
+//                     consume(SEMI);
+//                     if (label != null) b.add(parserLine, LABEL, label);
+//                     b.add(parserLine, LOOP);
+//                     int size2 = b.size;
+//                         
+//                     b.add(parserLine, JT, NC_0);                   // if 
we're on the first iteration, jump over the incrementor
+//                     int size = b.size;
+//                     if (peekToken() != RP) {                                
 // do the increment thing
+//                         startExpr(b, -1);
+//                         b.add(parserLine, POP);
+//                     }
+//                     b.set(size - 1, JSU.N(b.size - size + 1));
+//                     consume(RP);
+//                         
+//                     b.paste(e2);                                            
 // ok, *now* test if we're done yet
+//                     b.add(parserLine, JT, NC_2);                   // break 
out if we don't meet the test
+//                     b.add(parserLine, BREAK);
+//                     parseStatement(b, null);
+//                     b.add(parserLine, CONTINUE);                            
 // if we fall out the bottom, CONTINUE
+//                     b.set(size2 - 1, JSU.N(b.size - size2 + 1));     // end 
of the loop
+//                         
+//                     scopePop(b);                            // get our 
scope back
+//                 }
+//            }
             break;
         }
                 
@@ -1145,6 +1278,38 @@
             scopePop(b);
             break;
         }
+        case LB: {  
+               // probable destructuring, alternatively it could be an array 
by itself
+               // SHOULD handle case of array statement
+               // MAY share this array, destructuring cannot be nested
+               final Basket.Array list = new Basket.Array();
+               consume(NAME);
+               list.push(string);
+               while(true){
+                       if (peekToken() == RB) break;
+                       consume(COMMA);
+                       consume(NAME);
+                       list.push(string);
+               }
+               consume(RB);
+               consume(ASSIGN);
+               startExpr(b, NO_COMMA);
+               // push items onto stack [a,b,c]->c,b,a
+               for(int i=list.size()-1; i>=0; i--){
+               b.add(parserLine, GET_PRESERVE, JSU.N(i));
+                       b.add(parserLine, SWAP);
+               }
+               // pop the array 
+               b.add(parserLine, POP);
+               
+               for(int i=0; i<list.size(); i++){
+                       String varname = (String) list.get(i);
+                       JS varKey = scopeAccess(b,varname);
+                       outputAssign(b, varKey);
+                       b.add(parserLine, POP); 
+               }
+               break;
+        }
 
         default: {  // hope that it's an expression
             pushBackToken();

Added: trunk/core/org.ibex.js/src_dev/dev/IOUtil.java
===================================================================
--- trunk/core/org.ibex.js/src_dev/dev/IOUtil.java                              
(rev 0)
+++ trunk/core/org.ibex.js/src_dev/dev/IOUtil.java      2009-08-30 00:32:13 UTC 
(rev 3633)
@@ -0,0 +1,98 @@
+package dev;
+
+import java.io.*;
+
+
+public class IOUtil {
+
+       static public void pipe(InputStream in, OutputStream out) throws 
IOException {
+       try{
+               byte[] buff = new byte[16 * 1024];
+               while (true) {
+                       int bytesRead = in.read(buff);
+                       if (bytesRead == -1) break;
+                       out.write(buff, 0, bytesRead);
+                       
+               }
+       }finally{
+               out.close();
+       }
+       }
+       
+       static public void pipe(Reader in, Writer out) throws IOException {
+       try{
+               char[] buff = new char[16 * 1024];
+               while (true) {
+                       int bytesRead = in.read(buff);
+                       if (bytesRead == -1) break;
+                       out.write(buff, 0, bytesRead);
+                       
+               }
+       }finally{
+               out.close();
+       }
+       }
+       
+
+
+       static public synchronized byte[] inputStreamToBytes(InputStream is) 
throws IOException {
+               return inputStreamToBytes(is, 32);
+       }
+
+       static public synchronized byte[] inputStreamToBytes(InputStream is, 
int size) throws IOException {
+               ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
+               pipe(is, baos);
+               return baos.toByteArray();
+    }
+       
+       
+       static public void stringToWriter(String s, Writer w) throws 
IOException{
+               pipe(new StringReader(s),w);
+       }
+       
+       static public String readerToString(Reader r) throws IOException{
+               CharArrayWriter w = new CharArrayWriter();
+               pipe(r,w);
+               return w.toString();
+       }
+       
+       static public String readerToString(Reader r, int length) throws 
IOException{
+               CharArrayWriter w = new CharArrayWriter(length);
+               pipe(r,w);
+               return w.toString();
+       }
+
+       
+       static public void stringToFile(String s, File f, String charset) 
throws IOException{
+               FileOutputStream out = new FileOutputStream(f);
+               ByteArrayInputStream in = new 
ByteArrayInputStream(s.getBytes(charset));
+               pipe(in,out);
+       }
+       
+       static public void stringToFile(String s, File f) throws IOException{
+               stringToFile(s,f,"UTF-8");
+       }
+       
+       static public String fileToString(File f) throws IOException{
+               FileInputStream in = new FileInputStream(f);
+               ByteArrayOutputStream out = new ByteArrayOutputStream();
+               pipe(in,out);
+               return new String(out.toByteArray(),"UTF-8");
+       }
+       
+    static public boolean deleteDir(File dir) {
+               if (!dir.exists()) return true;
+               if (dir.isDirectory()) {
+                       String[] children = dir.list();
+                       for (int i=0; i<children.length; i++) {
+                               boolean success = deleteDir(new File(dir, 
children[i]));
+                               if (!success) {
+                                   
+                                       return false;
+                               }
+                       }
+               }
+               // The directory is now empty so delete it
+               return dir.delete();
+       }
+}


Property changes on: trunk/core/org.ibex.js/src_dev/dev/IOUtil.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/core/org.ibex.js/src_dev/dev/ParseFile.java
===================================================================
--- trunk/core/org.ibex.js/src_dev/dev/ParseFile.java                           
(rev 0)
+++ trunk/core/org.ibex.js/src_dev/dev/ParseFile.java   2009-08-30 00:32:13 UTC 
(rev 3633)
@@ -0,0 +1,35 @@
+package dev;
+
+import java.io.*;
+
+import org.ibex.js.*;
+
+
+public class ParseFile {
+       static String resourceDir = ParseFile.class.getResource(".").getPath();
+       static String filename = "statement.js"; 
+       
+       static public void main(String[] args) throws Exception {
+//             Parser.newfor = false;
+//             parseAndDump();
+               Parser.newfor = true;
+               parseAndDump();
+
+       }
+       
+       static void parseAndDump() throws Exception{
+               JSFunction f = DevUtil.parseFile(new File(resourceDir, 
filename),filename);
+               String dump = f.dump();
+               System.err.println(dump);
+               IOUtil.stringToFile(dump, new File("1.txt"));
+       }
+       
+       // redundant bytecode sequences (for future reference)
+       //SCOPEPUT x
+       //POP (no arg)
+       //SCOPEGET x
+       
+       //SWAP
+       //POP
+       //POP
+}


Property changes on: trunk/core/org.ibex.js/src_dev/dev/ParseFile.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: trunk/core/org.ibex.js/src_dev/dev/statement.js
===================================================================
--- trunk/core/org.ibex.js/src_dev/dev/statement.js                             
(rev 0)
+++ trunk/core/org.ibex.js/src_dev/dev/statement.js     2009-08-30 00:32:13 UTC 
(rev 3633)
@@ -0,0 +1,10 @@
+
+var obj = {a:"x", y:"b", c:"z"};
+var rec = {};
+for(var k,v in obj){
+       sys.log.info(k +":" + v);
+       rec[k] = v;
+};
+assert(rec.a=="x");
+assert(rec.y=="b");
+assert(rec.c=="z");
\ No newline at end of file

Modified: trunk/core/org.ibex.js/src_dev/org/ibex/js/DevUtil.java
===================================================================
--- trunk/core/org.ibex.js/src_dev/org/ibex/js/DevUtil.java     2009-08-28 
14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_dev/org/ibex/js/DevUtil.java     2009-08-30 
00:32:13 UTC (rev 3633)
@@ -1,9 +1,7 @@
 package org.ibex.js;
 
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.HashSet;
-import java.util.Set;
+import java.io.*;
+import java.util.*;
 
 import org.ibex.js.Parser.ScopeInfo;
 
@@ -145,5 +143,32 @@
            return ret;
        }
 
-
+       
+       static InputStream getInputStreamForFile(File f) throws 
FileNotFoundException{
+               if(f.exists())
+                       return new FileInputStream(f);
+               return null;
+       }       
+       
+       
+    static public JSFunction parseFile(File file, String filename) throws 
JSExn{
+       try{
+               InputStream is = getInputStreamForFile(file);
+               if(is==null)
+                       throw new JSExn("Could not find file in path: " +  
filename);
+               InputStreamReader isr = new InputStreamReader(is);
+               JSFunction f = Parser.fromReader(filename,1,isr,null);
+               return f;
+       } catch(IOException e){
+               throw new JSExn(e);
+       }
+    }
+    
+    static private String l = "                              ";
+    
+    static public void debugStack(Interpreter i, int op, Object arg) {
+       System.err.println(l + " | "+ i.stack);
+       l = i.pc+": "+DevUtil.opName(op) + " " + (arg == null ? "(no arg)" : 
JSU.toString(arg));
+       while(l.length()< 30) l+=" ";
+       }
 }

Modified: trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java
===================================================================
--- trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java       2009-08-28 
14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_dev/org/ibex/js/RunJS.java       2009-08-30 
00:32:13 UTC (rev 3633)
@@ -4,10 +4,7 @@
 
 package org.ibex.js;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
 import java.util.HashMap;
 import java.util.Iterator;
 
@@ -95,26 +92,26 @@
                
        }
        
+       public Reader getReaderForFile(String filename) throws JSExn, 
IOException{
+               InputStream is = getFountainForFile(filename).getInputStream();
+               if(is==null)
+                       throw new JSExn("Could not find file in path: " +  
filename);
+               InputStreamReader isr = new InputStreamReader(is);
+               return isr;
+       }
+       
+       
        private JSFunction prepareRun(String filename, JS export) throws JSExn{
                try{
-                       InputStream is = 
getFountainForFile(filename).getInputStream();
-                       if(is==null)
-                               throw new JSExn("Could not find file in path: " 
+  filename);
-                       InputStreamReader isr = new InputStreamReader(is);
+                       Reader isr = getReaderForFile(filename);
                        JSFunction f = Parser.fromReader(filename,1,isr,null);
                        global = new GlobalObj(sysObj,export);
                        //System.out.println(((JSFunction)f).dump());
                        f = JSU.cloneWithNewGlobalScope(f,global);
                        return (JSFunction)f;
-               }catch(SourceException e){
-                       throw new JSExn("Couldn't read file: " + 
e.getMessageSig() +" " + e.getWhere() + "\n" + e.getMessage());
-               }catch(JSExn e){
-                       throw e;
+               } catch(IOException e){
+                       throw new JSExn(e);
                }
-               catch(Exception e){
-                       e.printStackTrace();
-                       throw new JSExn(e.getMessage());
-               }
                
        };
        

Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestCase.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestCase.java       
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestCase.java       
2009-08-30 00:32:13 UTC (rev 3633)
@@ -1,7 +1,6 @@
 package test.js.exec;
 
-import java.io.PrintStream;
-import java.io.PrintWriter;
+import java.io.*;
 
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
@@ -12,10 +11,7 @@
  * @author mike
  */
 public class JSTestCase extends TestCase{
-
-
        
-       
        ////////////
        // test case implementation (js file -> JUnit test case) 
        ///
@@ -37,13 +33,19 @@
                try{
                        RunJS.runJSFile(resourceDirs, main, props);
                }catch(JSExn e){
-                       RunJS.LOG.warn(JSTestCase.class, e);
+                       //RunJS.LOG.warn(JSTestCase.class, e);
                        throw new AssertJSExn(e);
                        /*e.printStackTrace();
                        fail(e.getMessage());*/
                }
        }
        
+       public void printByteCode() throws Exception{
+               Reader r = new RunJS(resourceDirs).getReaderForFile(main);
+               JSFunction f = Parser.fromReader(main,1,r,null);
+               System.err.println(f.dump());
+       }
+       
     public String getName() {
        return main;
     }

Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestSuite.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestSuite.java      
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/JSTestSuite.java      
2009-08-30 00:32:13 UTC (rev 3633)
@@ -4,7 +4,6 @@
 import java.io.FilenameFilter;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
 import junit.framework.TestSuite;
 import test.Util;
 
@@ -19,7 +18,7 @@
                this.suiteClass = suiteClass; 
        }
        
-       public TestCase createTestCase(String[] resourceDirs, String fileName){
+       public JSTestCase createTestCase(String[] resourceDirs, String 
fileName){
                return new JSTestCase(resourceDirs, fileName);
        }
        

Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/general/TestGeneral.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/general/TestGeneral.java      
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/general/TestGeneral.java      
2009-08-30 00:32:13 UTC (rev 3633)
@@ -1,8 +1,7 @@
 package test.js.exec.general;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
-import test.js.exec.JSTestSuite;
+import test.js.exec.*;
 
 /**
  * @author mike
@@ -15,7 +14,8 @@
     
     public static void main(String[] args) throws Throwable {
        JSTestSuite jts = new JSTestSuite(TestGeneral.class);
-       TestCase t = jts.createTestCase(jts.getResourceDirs(), "uri_encode.js");
+       JSTestCase t = jts.createTestCase(jts.getResourceDirs(), "forin2.js");
+       t.printByteCode();
        t.runBare();
     }
 }

Added: trunk/core/org.ibex.js/src_junit/test/js/exec/general/destructuring.js
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/general/destructuring.js      
                        (rev 0)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/general/destructuring.js      
2009-08-30 00:32:13 UTC (rev 3633)
@@ -0,0 +1,16 @@
+
+sys.import("shared");
+
+var a;
+var b;
+[a,b] = [1,2];
+assertEquals(1,a);
+assertEquals(2,b);
+
+[a, b] = [b, a];
+assertEquals(2,a);
+assertEquals(1,b);
+
+[a, b] = function(x,y){ return [y,x]; }(a,b);
+assertEquals(1,a);
+assertEquals(2,b);

Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin.js
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin.js      
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin.js      
2009-08-30 00:32:13 UTC (rev 3633)
@@ -1,7 +1,7 @@
 
 var obj = {a:"x", y:"b", c:"z"};
 var rec = {};
-for(var x in obj){
+for(var x,y in obj){
        sys.log.info(x +":" + obj[x]);
        rec[x] = obj[x];
 };

Added: trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin2.js
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin2.js             
                (rev 0)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/general/forin2.js     
2009-08-30 00:32:13 UTC (rev 3633)
@@ -0,0 +1,10 @@
+
+var obj = {a:"x", y:"b", c:"z"};
+var rec = {};
+for(var k,v in obj){
+       sys.log.info(k +":" + v);
+       rec[k] = v;
+};
+assert(rec.a=="x");
+assert(rec.y=="b");
+assert(rec.c=="z");
\ No newline at end of file

Modified: 
trunk/core/org.ibex.js/src_junit/test/js/exec/interrupt/TestInterrupt.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/interrupt/TestInterrupt.java  
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/interrupt/TestInterrupt.java  
2009-08-30 00:32:13 UTC (rev 3633)
@@ -19,7 +19,7 @@
        return suite(new TestInterrupt());
     }
     
-    public TestCase createTestCase(String[] resourceDirs, String fileName) {
+    public JSTestCase createTestCase(String[] resourceDirs, String fileName) {
        return new JSTestCase(resourceDirs, fileName){
                boolean finished = false;
                public void runTest() throws Throwable {

Modified: 
trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java    
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/rpc/xmlrpc/TestXmlRpc.java    
2009-08-30 00:32:13 UTC (rev 3633)
@@ -68,7 +68,7 @@
                }
        }
        
-       public TestCase createTestCase(String[] resourceDirs, String fileName) {
+       public JSTestCase createTestCase(String[] resourceDirs, String 
fileName) {
                return new XmlRpcTestCase(resourceDirs, fileName);
        }
     

Modified: trunk/core/org.ibex.js/src_junit/test/js/exec/stream/TestStream.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/exec/stream/TestStream.java        
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/exec/stream/TestStream.java        
2009-08-30 00:32:13 UTC (rev 3633)
@@ -21,7 +21,7 @@
        return suite(new TestStream());
     }
     
-    public TestCase createTestCase(String[] resourceDirs, String fileName) {
+    public JSTestCase createTestCase(String[] resourceDirs, String fileName) {
                try {
                        File tmpDir = test.Util.createTmpDir();
                        File save_ = new File(tmpDir,"save.txt");

Modified: trunk/core/org.ibex.js/src_junit/test/js/parse/TestParse.java
===================================================================
--- trunk/core/org.ibex.js/src_junit/test/js/parse/TestParse.java       
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.ibex.js/src_junit/test/js/parse/TestParse.java       
2009-08-30 00:32:13 UTC (rev 3633)
@@ -1,18 +1,12 @@
 package test.js.parse;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.regex.*;
 
-import org.ibex.js.*;
-import org.ibex.util.SourceException;
-
 import junit.framework.TestCase;
 
+import org.ibex.js.*;
+
 public class TestParse extends TestCase {
 
        public static void main(String[] args) throws Exception {
@@ -31,6 +25,11 @@
                resourceDir = TestParse.class.getResource(".").getPath();
        }
        
+       
+       private JS parseFile(String filename) throws JSExn {
+               return DevUtil.parseFile(new File(resourceDir,filename), 
filename);
+       }
+       
        public void testWierd() throws Throwable{
                JS f = parseFile("wierd.js");
                String[] lines = DevUtil.dump(f).split("\n");
@@ -47,7 +46,10 @@
                        }               
                }
        }
-       
+
+
+
+
        public void testUnterminated() throws Throwable{
                JS f = parseFile("unterminated.js");
                String[] lines = DevUtil.dump(f).split("\n");
@@ -96,32 +98,6 @@
                        assertTrue(e.getMessage().endsWith("3"));
                }
        }
-       
-       InputStream getInputStreamForFile(String fileName) throws 
FileNotFoundException{
-               File f = new File(resourceDir, fileName);
-               if(f.exists())
-                       return new FileInputStream(f);
-               return null;
-       }       
-       
-    
-    JS parseFile(String filename) throws JSExn{
-       try{
-               InputStream is = getInputStreamForFile(filename);
-               if(is==null)
-                       throw new JSExn("Could not find file in path: " +  
filename);
-               InputStreamReader isr = new InputStreamReader(is);
-               JS f = Parser.fromReader(filename,1,isr,null);
-               return f;
-       }catch(SourceException e){
-               System.err.println(e.getMessageSig() +" " + e.getWhere() + "\n" 
+ e.getMessage());
-               throw new JSExn("Couldn't read file: " + e.getMessageSig() +" " 
+ e.getWhere() + "\n" + e.getMessage());
-       }catch(JSExn e){
-               throw e;
-       }
-       catch(Exception e){
-               e.printStackTrace();
-               throw new JSExn(e.getMessage());
-       }
-    }
+
+
 }

Modified: trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java     
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java     
2009-08-30 00:32:13 UTC (rev 3633)
@@ -154,23 +154,10 @@
     }
     
     static JSFunction parseScript(StringBuffer content, int content_start,  
String sourceName, GlobalsChecker parserParam) throws JSExn {
-        try {
-            if (content == null) {
-                return null;
-            }
-            String contentString = content.toString();
-            if (contentString.trim().length() > 0) {
-                return Parser.fromReader(sourceName, content_start, new 
StringReader(contentString), parserParam);
-            }
-            return null;
-        } catch(SourceException e) {
-            Log.error(e.getMessageSig(), e.getWhere() + "\n- "+ 
e.getMessage());
-            // FEATURE create JSExn constructor that takes a SourceException -
-            // and so pass on more information as exception properties.
-            throw new JSExn("Could not parse script, " + sourceName + ":" + 
content_start);
-        } catch (Exception e) {
-            throw new JSExn("Unexpected error when parsing, " + sourceName + 
":" + content_start, e);
-        }
+        if (content == null) return null;
+        String contentString = content.toString();
+        if (contentString.trim().length() > 0) return 
Parser.fromReader(sourceName, content_start, new StringReader(contentString), 
parserParam);
+        return null;
     }
     
     private static final int STATE_INITIAL = 0;

Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java    2009-08-28 
14:49:16 UTC (rev 3632)
+++ trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java    2009-08-30 
00:32:13 UTC (rev 3633)
@@ -54,8 +54,8 @@
 
     // REMARK - Basket.Array is an inefficient queue(see dequeue). Using 
java.util
     static final LinkedList glyphsToBeCached = new LinkedList();
-    // FIXME - have this as a priority task
-    static final Queue glyphsToBeDisplayed = new LinkedList();
+    // SHOULD - have this as a priority task
+    //static final Queue glyphsToBeDisplayed = new LinkedList();
     
     // REMARK - to keep things simple we have the weak reference
     // only in one place, pointing to the font. We can guarantee

Modified: trunk/core/org.vexi.core/src_junit/test/core/CoreTestSuite.java
===================================================================
--- trunk/core/org.vexi.core/src_junit/test/core/CoreTestSuite.java     
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.vexi.core/src_junit/test/core/CoreTestSuite.java     
2009-08-30 00:32:13 UTC (rev 3633)
@@ -1,8 +1,7 @@
 package test.core;
 
 import junit.framework.Test;
-import junit.framework.TestCase;
-import test.js.exec.JSTestSuite;
+import test.js.exec.*;
 
 
 public class CoreTestSuite extends JSTestSuite{
@@ -11,7 +10,7 @@
                super(klass);
        }
        
-       public TestCase createTestCase(String[] resourceDirs, String fileName){
+       public JSTestCase createTestCase(String[] resourceDirs, String 
fileName){
                return new CoreTestCase(resourceDirs, fileName);
        }
        

Modified: 
trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java
===================================================================
--- trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java     
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java     
2009-08-30 00:32:13 UTC (rev 3633)
@@ -11,7 +11,7 @@
 import junit.framework.TestCase;
 import test.core.CoreTestCase;
 import test.core.CoreTestSuite;
-import test.js.exec.JSTestSuite;
+import test.js.exec.*;
 import testdeployment.NanoHTTPD;
 
 /**
@@ -33,7 +33,7 @@
        t.runBare();
        }
 
-    public TestCase createTestCase(String[] resourceDirs, String fileName) {
+    public JSTestCase createTestCase(String[] resourceDirs, String fileName) {
        return new CoreTestCase(resourceDirs, fileName){
                protected void setUp() throws Exception {
                        createDotVexi(new 
File(NanoHTTPD.class.getResource(".").getPath()));

Modified: trunk/core/org.vexi.core/src_junit/test/core/gut/TestGUT.java
===================================================================
--- trunk/core/org.vexi.core/src_junit/test/core/gut/TestGUT.java       
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.vexi.core/src_junit/test/core/gut/TestGUT.java       
2009-08-30 00:32:13 UTC (rev 3633)
@@ -15,7 +15,7 @@
     
     public static void main(String[] args) throws Throwable {
        CoreTestSuite cts = new CoreTestSuite(TestGUT.class);
-       TestCase t = cts.createTestCase(cts.getResourceDirs(), "virtualize.t");
+       TestCase t = cts.createTestCase(cts.getResourceDirs(), 
"dontvirtualize.t");
        t.runBare();
        }
 }

Modified: trunk/core/org.vexi.devl/src/org/vexi/devl/Main.java
===================================================================
--- trunk/core/org.vexi.devl/src/org/vexi/devl/Main.java        2009-08-28 
14:49:16 UTC (rev 3632)
+++ trunk/core/org.vexi.devl/src/org/vexi/devl/Main.java        2009-08-30 
00:32:13 UTC (rev 3633)
@@ -34,7 +34,7 @@
     protected void printUsage() {
         Log.info(Main.class, "Usage: vexi [debugger|debuggee|memory|profile] 
[options] [ url | file | directory ]");
         Log.info(Main.class, "");
-        Log.info(Main.class, org.vexi.core.Main.CORE_OPTIONS);
+        Log.info(Main.class, org.vexi.core.Main.CORE_OPTIONS());
         Log.info(Main.class, "");
         Log.info(Main.class, INSTRUMENTATION_OPTIONS);
         Runtime.getRuntime().exit(-1);

Modified: trunk/core/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java
===================================================================
--- trunk/core/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java        
2009-08-28 14:49:16 UTC (rev 3632)
+++ trunk/core/org.vexi.devl/src_junit/test/debug/DebuggerTestSuite.java        
2009-08-30 00:32:13 UTC (rev 3633)
@@ -5,6 +5,7 @@
 import org.vexi.instrument.debug.Constants;
 
 import test.core.CoreTestSuite;
+import test.js.exec.JSTestCase;
 
 
 
@@ -16,7 +17,7 @@
                super(klass);
        }
        
-       public TestCase createTestCase(String[] resourceDirs, String fileName) {
+       public JSTestCase createTestCase(String[] resourceDirs, String 
fileName) {
                return new DebuggerTestCase(resourceDirs, fileName);
        }
        


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to