SOURCES: custom_rhino.diff - from http://paiq.nl/custom_rhino_charset.diff ...

glen glen at pld-linux.org
Wed Jan 7 13:36:54 CET 2009


Author: glen                         Date: Wed Jan  7 12:36:54 2009 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- from http://paiq.nl/custom_rhino_charset.diff
  adds -E CHARSET support, to use like UTF8, from http://dojotoolkit.org/docs/shrinksafe

---- Files affected:
SOURCES:
   custom_rhino.diff (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/custom_rhino.diff
diff -u SOURCES/custom_rhino.diff:1.1 SOURCES/custom_rhino.diff:1.2
--- SOURCES/custom_rhino.diff:1.1	Wed Jan  7 13:35:51 2009
+++ SOURCES/custom_rhino.diff	Wed Jan  7 13:36:48 2009
@@ -1,16 +1,11 @@
 Index: src/org/mozilla/javascript/BaseFunction.java
 ===================================================================
 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/BaseFunction.java,v
-retrieving revision 1.63
-diff -u -8 -p -r1.63 BaseFunction.java
---- src/org/mozilla/javascript/BaseFunction.java	16 May 2007 12:41:00 -0000	1.63
-+++ src/org/mozilla/javascript/BaseFunction.java	19 Oct 2007 11:28:27 -0000
-@@ -371,16 +371,38 @@ public class BaseFunction extends IdScri
-         sb.append(getArity());
-         sb.append("]\n");
-         if (!justbody) {
-             sb.append("}\n");
-         }
+retrieving revision 1.57
+diff -u -r1.57 BaseFunction.java
+--- src/org/mozilla/javascript/BaseFunction.java	30 Aug 2005 10:05:42 -0000	1.57
++++ src/org/mozilla/javascript/BaseFunction.java	30 Jul 2007 17:13:21 -0000
+@@ -373,6 +373,28 @@
          return sb.toString();
      }
  
@@ -39,27 +34,17 @@
      public int getArity() { return 0; }
  
      public int getLength() { return 0; }
- 
-     public String getFunctionName()
-     {
-         return "";
-     }
 Index: src/org/mozilla/javascript/Context.java
 ===================================================================
 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Context.java,v
-retrieving revision 1.255.2.1
-diff -u -8 -p -r1.255.2.1 Context.java
---- src/org/mozilla/javascript/Context.java	6 Jun 2007 14:58:49 -0000	1.255.2.1
-+++ src/org/mozilla/javascript/Context.java	19 Oct 2007 11:28:27 -0000
-@@ -1211,16 +1211,43 @@ public class Context
-      * @param securityDomain an arbitrary object that specifies security
-      *        information about the origin or owner of the script. For
-      *        implementations that don't care about security, this value
-      *        may be null.
-      * @return the result of evaluating the source
-      *
-      * @exception IOException if an IOException was generated by the Reader
-      */
+retrieving revision 1.244
+diff -u -r1.244 Context.java
+--- src/org/mozilla/javascript/Context.java	4 Nov 2005 13:37:45 -0000	1.244
++++ src/org/mozilla/javascript/Context.java	30 Jul 2007 17:13:21 -0000
+@@ -1178,6 +1178,33 @@
+         }
+     }
+ 
 +        public final String decompileReader(Scriptable scope, Reader in,
 +    		                                       String sourceName, int lineno,
 +    		                                       Object securityDomain)
@@ -87,20 +72,10 @@
 +    	}
 +       
 +    		
-     public final Object evaluateReader(Scriptable scope, Reader in,
-                                        String sourceName, int lineno,
-                                        Object securityDomain)
-         throws IOException
-     {
-         Script script = compileReader(scope, in, sourceName, lineno,
-                                       securityDomain);
-         if (script != null) {
-@@ -1393,16 +1420,44 @@ public class Context
-         catch (IOException ioe) {
-             // Should never happen because we just made the reader
-             // from a String
-             throw new RuntimeException();
-         }
+     /**
+      * Check whether a string is ready to be compiled.
+      * <p>
+@@ -1361,6 +1388,33 @@
      }
  
      /**
@@ -129,59 +104,35 @@
 +        ScriptOrFnNode tree = parser.parse(source, null, lineno);
 + 
 +        return scriptImpl.compress( tree,indent, 0);
-+    }
-+
++    }   
 +    /**
-      * Decompile the script.
+      * Decompile a JavaScript Function.
       * <p>
-      * The canonical source of the script is returned.
-      *
-      * @param script the script to decompile
-      * @param indent the number of spaces to indent the result
-      * @return a string representing the script source
-      */
-@@ -2287,27 +2342,27 @@ public class Context
-                                Interpreter compiler,
-                                ErrorReporter compilationErrorReporter)
-         throws IOException
-     {
-         if (securityDomain != null && securityController == null) {
-             throw new IllegalArgumentException(
-                 "securityDomain should be null if setSecurityController() was never called");
+      * Decompiles a previously compiled JavaScript function object to
+@@ -2240,7 +2294,6 @@
+                 sourceReader = null;
+             }
          }
 -
-         // One of sourceReader or sourceString has to be null
-         if (!(sourceReader == null ^ sourceString == null)) Kit.codeBug();
-         // scope should be given if and only if compiling function
-         if (!(scope == null ^ returnFunction)) Kit.codeBug();
- 
-         CompilerEnvirons compilerEnv = new CompilerEnvirons();
-         compilerEnv.initFromContext(this);
-         if (compilationErrorReporter == null) {
-             compilationErrorReporter = compilerEnv.getErrorReporter();
+         Parser p = new Parser(compilerEnv, compilationErrorReporter);
+         if (returnFunction) {
+             p.calledByCompileFunction = true;
+@@ -2251,6 +2304,7 @@
+         } else {
+             tree = p.parse(sourceReader, sourceName, lineno);
          }
 +        
- 
-         if (debugger != null) {
-             if (sourceReader != null) {
-                 sourceString = Kit.readReader(sourceReader);
-                 sourceReader = null;
-             }
-         }
- 
+         if (returnFunction) {
+             if (!(tree.getFunctionCount() == 1
+                   && tree.getFirstChild() != null
 Index: src/org/mozilla/javascript/Decompiler.java
 ===================================================================
 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/Decompiler.java,v
-retrieving revision 1.23
-diff -u -8 -p -r1.23 Decompiler.java
---- src/org/mozilla/javascript/Decompiler.java	4 Apr 2007 20:52:09 -0000	1.23
-+++ src/org/mozilla/javascript/Decompiler.java	19 Oct 2007 11:28:28 -0000
-@@ -36,16 +36,21 @@
-  * them with the notice and other provisions required by the GPL. If you do
-  * not delete the provisions above, a recipient may use your version of this
-  * file under either the MPL or the GPL.
-  *
-  * ***** END LICENSE BLOCK ***** */
+retrieving revision 1.19
+diff -u -r1.19 Decompiler.java
+--- src/org/mozilla/javascript/Decompiler.java	28 Aug 2005 23:25:22 -0000	1.19
++++ src/org/mozilla/javascript/Decompiler.java	30 Jul 2007 17:13:21 -0000
+@@ -37,6 +37,11 @@
  
  package org.mozilla.javascript;
  
@@ -193,17 +144,7 @@
  /**
   * The following class save decompilation information about the source.
   * Source information is returned from the parser as a String
-  * associated with function nodes and with the toplevel script.  When
-  * saved in the constant pool of a class, this string will be UTF-8
-  * encoded, and token values will occupy a single byte.
- 
-  * Source is saved (mostly) as token numbers.  The tokens saved pretty
-@@ -69,16 +74,282 @@ package org.mozilla.javascript;
-  * followed by a character giving the length of the string (assumed to
-  * be less than 2^16), followed by the characters of the string
-  * inlined into the source string.  Changing this to some reference to
-  * to the string in the compiled class' constant pool would probably
-  * save a lot of space... but would require some method of deriving
+@@ -70,6 +75,272 @@
   * the final constant pool entry from information available at parse
   * time.
   */
@@ -476,17 +417,7 @@
  public class Decompiler
  {
      /**
-      * Flag to indicate that the decompilation should omit the
-      * function header and trailing brace.
-      */
-     public static final int ONLY_BODY_FLAG = 1 << 0;
- 
-@@ -265,16 +536,536 @@ public class Decompiler
-     }
- 
-     private String sourceToString(int offset)
-     {
-         if (offset < 0 || sourceTop < offset) Kit.codeBug();
+@@ -266,6 +537,515 @@
          return new String(sourceBuffer, offset, sourceTop - offset);
      }
  
@@ -548,10 +479,10 @@
 +         int braceNesting = 0;
 +         boolean afterFirstEOL = false;
 +         int i = 0;
-+         int prevToken = 0;
-+         boolean primeFunctionNesting = false;
-+         boolean inArgsList = false;
-+         boolean primeInArgsList = false;
++  	int prevToken = 0;
++  	boolean primeFunctionNesting = false;
++  	boolean inArgsList = false;
++  	boolean primeInArgsList = false;
 +         int topFunctionType;
 +         if (encodedSource.charAt(i) == Token.SCRIPT) {
 +             ++i;
@@ -565,27 +496,27 @@
 +             for (int j = 0; j < indent; j++){
 +                 // result.append(' ');
 +                 result.append("");
-+             }
++  		}
 +         } else {
 +             if (topFunctionType == FunctionNode.FUNCTION_EXPRESSION) {
 +                 result.append('(');
 +             }
 +         }
 +         while (i < length) {
-+           if(i>0){
-+               prevToken = encodedSource.charAt(i-1);
-+           }
-+           // System.out.println(Token.name(getNext(source, length, i)));
-+           switch(encodedSource.charAt(i)) {
++  		if(i>0){
++  			prevToken = encodedSource.charAt(i-1);
++  		}
++  		// System.out.println(Token.name(getNext(source, length, i)));
++             switch(encodedSource.charAt(i)) {
 +             case Token.NAME:
 +             case Token.REGEXP:  // re-wrapped in '/'s in parser...
-+                 int jumpPos = getSourceStringEnd(encodedSource, i+1);
-+                 if(Token.OBJECTLIT == encodedSource.charAt(jumpPos)){
-+                     i = printSourceString(encodedSource, i + 1, false, result);
-+                 }else{
-+                     i = tm.sourceCompress(	encodedSource, i + 1, false, result, prevToken, 
-+                                             inArgsList, braceNesting, parseTree);
-+                 }
++  			int jumpPos = getSourceStringEnd(encodedSource, i+1);
++  			if(Token.OBJECTLIT == encodedSource.charAt(jumpPos)){
++  				i = printSourceString(encodedSource, i + 1, false, result);
++  			}else{
++  				i = tm.sourceCompress(	encodedSource, i + 1, false, result, prevToken, 
++  										inArgsList, braceNesting, parseTree);
++  			}
 +                 continue;
 +             case Token.STRING:
 +                 i = printSourceString(encodedSource, i + 1, true, result);
@@ -608,8 +539,8 @@
 +             case Token.FUNCTION:
 +                 ++i; // skip function type
 +                 tm.functionNum++;
-+                 primeInArgsList = true;
-+                 primeFunctionNesting = true;
++  			primeInArgsList = true;
++  			primeFunctionNesting = true;
 +                 result.append("function");
 +                 if (Token.LP != getNext(encodedSource, length, i)) {
 +                     result.append(' ');
@@ -622,15 +553,15 @@
 +                 result.append(",");
 +                 break;
 +             case Token.LC:
-+                 ++braceNesting;
++  			++braceNesting;
 +                 if (Token.EOL == getNext(encodedSource, length, i)){
 +                     indent += indentGap;
-+                 }
++  			}
 +                 result.append('{');
 +                 // // result.append('\n');
 +                 break;
 +             case Token.RC: {
-+                tm.leaveNestingLevel(braceNesting);
++  			tm.leaveNestingLevel(braceNesting);
 +                 --braceNesting;
 +                 /* don't print the closing RC if it closes the
 +                  * toplevel function and we're called from
@@ -638,26 +569,13 @@
 +                  */
 +                 if(justFunctionBody && braceNesting == 0){
 +                     break;
-+                 }
++  			}
 +                 // // result.append('\n');
 +                 result.append('}');
 +                 // // result.append(' ');
 +                 switch (getNext(encodedSource, length, i)) {
 +                     case Token.EOL:
 +                     case FUNCTION_END:
-+                        if (
-+                            (getNext(encodedSource, length, i+1) != Token.SEMI) &&
-+                            (getNext(encodedSource, length, i+1) != Token.LP) &&
-+                            (getNext(encodedSource, length, i+1) != Token.RP) &&
-+                            (getNext(encodedSource, length, i+1) != Token.RB) &&
-+                            (getNext(encodedSource, length, i+1) != Token.RC) &&
-+                            (getNext(encodedSource, length, i+1) != Token.COMMA) &&
-+                            (getNext(encodedSource, length, i+1) != Token.COLON) &&
-+                            (getNext(encodedSource, length, i+1) != Token.DOT) &&
-+                            (getNext(encodedSource, length, i) == FUNCTION_END )
-+                         ){
-+						    result.append(';');
-+                         }
 +                         indent -= indentGap;
 +                         break;
 +                     case Token.WHILE:
@@ -670,25 +588,25 @@
 +                 break;
 +             }
 +             case Token.LP:
-+                 if(primeInArgsList){
-+                     inArgsList = true;
-+                     primeInArgsList = false;
-+                 }
-+                 if(primeFunctionNesting){
-+                     tm.enterNestingLevel(braceNesting);
-+                     primeFunctionNesting = false;
-+                 }
++  			if(primeInArgsList){
++  				inArgsList = true;
++  				primeInArgsList = false;
++  			}
++  			if(primeFunctionNesting){
++  				tm.enterNestingLevel(braceNesting);
++  				primeFunctionNesting = false;
++  			}
 +                 result.append('(');
 +                 break;
 +             case Token.RP:
-+			    if(inArgsList){
-+                    inArgsList = false;
-+				}
++  			if(inArgsList){
++  				inArgsList = false;
++  			}
 +                 result.append(')');
 +  			/*
 +                 if (Token.LC == getNext(source, length, i)){
 +                     result.append(' ');
-+                 }
++  			}
 +  			*/
 +                 break;
 +             case Token.LB:
@@ -714,6 +632,8 @@
 +                 if (newLine) {
 +                     result.append('\n');
 +                 }
++  			/*
++  			*/
 +                 /* add indent if any tokens remain,
 +                  * less setback if next token is
 +                  * a label, case or default.
@@ -739,7 +659,7 @@
 +                     for (; less < indent; less++){
 +                         // result.append(' ');
 +                         result.append("");
-+                     }
++  				}
 +                 }
 +                 break;
 +             }
@@ -810,7 +730,7 @@
 +                 result.append("return");
 +                 if(Token.SEMI != getNext(encodedSource, length, i)){
 +                     result.append(' ');
-+                 }
++  			}
 +                 break;
 +             case Token.VAR:
 +                 result.append("var ");
@@ -951,22 +871,22 @@
 +                 result.append('-');
 +                 break;
 +             case Token.INC:
-+                 if(Token.ADD == prevToken){
-+                    result.append(' ');
-+                 }
++  			if(Token.ADD == prevToken){
++  				result.append(' ');
++  			}
 +                 result.append("++");
 +                 if(Token.ADD == getNext(encodedSource, length, i)){
 +                     result.append(' ');
-+                 }
++  			}
 +                 break;
 +             case Token.DEC:
-+                 if(Token.SUB == prevToken){
-+                     result.append(' ');
-+                 }
++  			if(Token.SUB == prevToken){
++  				result.append(' ');
++  			}
 +                 result.append("--");
 +                 if(Token.SUB == getNext(encodedSource, length, i)){
 +                     result.append(' ');
-+                 }
++  			}
 +                 break;
 +             case Token.ADD:
 +                 result.append("+");
@@ -1013,24 +933,14 @@
      /**
       * Decompile the source information associated with this js
       * function/script back into a string.  For the most part, this
-      * just means translating tokens back to their string
-      * representations; there's a little bit of lookahead logic to
-      * decide the proper spacing/indentation.  Most of the work in
-      * mapping the original source to the prettyprinted decompiled
-      * version is done by the parser.
 Index: src/org/mozilla/javascript/NativeFunction.java
 ===================================================================
 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeFunction.java,v
-retrieving revision 1.65
-diff -u -8 -p -r1.65 NativeFunction.java
---- src/org/mozilla/javascript/NativeFunction.java	24 May 2007 14:47:01 -0000	1.65
-+++ src/org/mozilla/javascript/NativeFunction.java	19 Oct 2007 11:28:28 -0000
-@@ -69,16 +69,36 @@ public abstract class NativeFunction ext
-             return super.decompile(indent, flags);
-         } else {
-             UintMap properties = new UintMap(1);
-             properties.put(Decompiler.INITIAL_INDENT_PROP, indent);
-             return Decompiler.decompile(encodedSource, flags, properties);
+retrieving revision 1.62
+diff -u -r1.62 NativeFunction.java
+--- src/org/mozilla/javascript/NativeFunction.java	17 Jan 2005 13:06:33 -0000	1.62
++++ src/org/mozilla/javascript/NativeFunction.java	30 Jul 2007 17:13:21 -0000
+@@ -70,6 +70,26 @@
          }
      }
  
@@ -1057,67 +967,29 @@
      public int getLength()
      {
          int paramCount = getParamCount();
-         if (getLanguageVersion() != Context.VERSION_1_2) {
-             return paramCount;
-         }
-         Context cx = Context.getContext();
-         NativeCall activation = ScriptRuntime.findFunctionActivation(cx, this);
 Index: src/org/mozilla/javascript/ScriptRuntime.java
 ===================================================================
 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java,v
-retrieving revision 1.263.2.3
-diff -u -8 -p -r1.263.2.3 ScriptRuntime.java
---- src/org/mozilla/javascript/ScriptRuntime.java	18 Jul 2007 12:45:45 -0000	1.263.2.3
-+++ src/org/mozilla/javascript/ScriptRuntime.java	19 Oct 2007 11:28:28 -0000
-@@ -642,32 +642,35 @@ public class ScriptRuntime {
-             if (escape >= 0) {
-                 // an \escaped sort of character
-                 sb.append('\\');
-                 sb.append((char)escape);
-             } else if (c == escapeQuote) {
-                 sb.append('\\');
-                 sb.append(escapeQuote);
-             } else {
-+				sb.append((char)c);
-+				/*
-                 int hexSize;
-                 if (c < 256) {
-                     // 2-digit hex
-                     sb.append("\\x");
-                     hexSize = 2;
-                 } else {
-                     // Unicode.
-                     sb.append("\\u");
-                     hexSize = 4;
-                 }
-                 // append hexadecimal form of c left-padded with 0
-                 for (int shift = (hexSize - 1) * 4; shift >= 0; shift -= 4) {
-                     int digit = 0xf & (c >> shift);
-                     int hc = (digit < 10) ? '0' + digit : 'a' - 10 + digit;
-                     sb.append((char)hc);
-                 }
-+				*/
-             }
-         }
-         return (sb == null) ? s : sb.toString();
-     }
- 
-     static boolean isValidIdentifierName(String s)
+retrieving revision 1.250
+diff -u -r1.250 ScriptRuntime.java
+--- src/org/mozilla/javascript/ScriptRuntime.java	12 Jan 2006 06:32:57 -0000	1.250
++++ src/org/mozilla/javascript/ScriptRuntime.java	30 Jul 2007 17:13:21 -0000
+@@ -575,7 +575,6 @@
      {
-         int L = s.length();
+         if (!(escapeQuote == '"' || escapeQuote == '\'')) Kit.codeBug();
+         StringBuffer sb = null;
+-
+         for(int i = 0, L = s.length(); i != L; ++i) {
+             int c = s.charAt(i);
+ 
 Index: src/org/mozilla/javascript/TokenStream.java
 ===================================================================
 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/TokenStream.java,v
-retrieving revision 1.66
-diff -u -8 -p -r1.66 TokenStream.java
---- src/org/mozilla/javascript/TokenStream.java	4 Apr 2007 20:52:12 -0000	1.66
-+++ src/org/mozilla/javascript/TokenStream.java	19 Oct 2007 11:28:28 -0000
-@@ -63,19 +63,22 @@ class TokenStream
-     /*
-      * For chars - because we need something out-of-range
-      * to check.  (And checking EOF by exception is annoying.)
-      * Note distinction from EOF token type!
-      */
+retrieving revision 1.63
+diff -u -r1.63 TokenStream.java
+--- src/org/mozilla/javascript/TokenStream.java	31 Jul 2005 13:48:46 -0000	1.63
++++ src/org/mozilla/javascript/TokenStream.java	30 Jul 2007 17:13:21 -0000
+@@ -64,9 +64,12 @@
      private final static int
          EOF_CHAR = -1;
  
@@ -1130,17 +1002,7 @@
          this.parser = parser;
          this.lineno = lineno;
          if (sourceReader != null) {
-             if (sourceString != null) Kit.codeBug();
-             this.sourceReader = sourceReader;
-             this.sourceBuffer = new char[512];
-             this.sourceEnd = 0;
-         } else {
-@@ -735,16 +738,18 @@ class TokenStream
-                 if (matchChar('=')) {
-                     return Token.ASSIGN_MUL;
-                 } else {
-                     return Token.MUL;
-                 }
+@@ -736,6 +739,8 @@
  
              case '/':
                  // is it a // comment?
@@ -1149,72 +1011,46 @@
                  if (matchChar('/')) {
                      skipLine();
                      continue retry;
-                 }
-                 if (matchChar('*')) {
-                     boolean lookForSlash = false;
-                     for (;;) {
-                         c = getChar();
 Index: toolsrc/org/mozilla/javascript/tools/resources/Messages.properties
 ===================================================================
 RCS file: /cvsroot/mozilla/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties,v
-retrieving revision 1.27.2.2.2.1
-diff -u -8 -p -r1.27.2.2.2.1 Messages.properties
---- toolsrc/org/mozilla/javascript/tools/resources/Messages.properties	9 Aug 2007 13:17:37 -0000	1.27.2.2.2.1
-+++ toolsrc/org/mozilla/javascript/tools/resources/Messages.properties	19 Oct 2007 11:28:28 -0000
-@@ -60,16 +60,18 @@ msg.shell.usage =\
-     Valid options are:\n\
-     \    -?, -help          Displays help messages.\n\
-     \    -w                 Enable warnings.\n\
-     \    -version 100|110|120|130|140|150|160\n\
-     \                       Set a specific language version.\n\
-     \    -opt [-1|0-9]      Set optimization level.\n\
-     \    -f script-filename Execute script file.\n\
-     \    -e script-source   Evaluate inline script.\n\
-+    \    -o output-filename   File name for compressed output.\n\
-+    \    -c script-filename   File name for script to compress.\n\
-     \    -debug             Generate debug code.\n\
-     \    -strict            Enable strict mode warnings.\n\
-     \    -fatal-warnings    Treat warnings as errors.
+retrieving revision 1.22
+diff -u -r1.22 Messages.properties
+--- toolsrc/org/mozilla/javascript/tools/resources/Messages.properties	2 Sep 2005 14:18:40 -0000	1.22
++++ toolsrc/org/mozilla/javascript/tools/resources/Messages.properties	30 Jul 2007 17:13:21 -0000
+@@ -55,7 +55,10 @@
+     \    -version 100|110|120|130|140|150\n\
+     \    -opt [-1|0-9]\n\
+     \    -f script-filename\n\
+-    \    -e script-source
++    \    -e script-source\n\
++    \    -c compression-input-file\n\
++    \    -o compression-output-file\n\
++    \    -E input-character-set
  
  
  msg.help =\
-     \n\
-     Command                Description \n\
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/custom_rhino.diff?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list