Changeset 7907
- Timestamp:
- 04/02/07 15:33:56 (22 months ago)
- Location:
- branches/0.4/buildscripts
- Files:
-
- 6 modified
-
build.xml (modified) (2 diffs)
-
buildUtil.js (modified) (2 diffs)
-
lib/custom_rhino.diff (modified) (15 diffs)
-
lib/custom_rhino.jar (modified) (previous)
-
makeDojoJs.js (modified) (1 diff)
-
stripComments.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/buildscripts/build.xml
r7574 r7907 39 39 <property name="release_website_dir" value="/srv/www/htdocs"/> 40 40 <property name="profile" value=""/> 41 <property name="strip_and_compress" value="false"/> 41 42 <property name="locales" value="en-gb,en-us,de-de,es-es,fr-fr,it-it,pt-br,ko-kr,zh-tw,zh-cn,ja-jp"/> 42 43 <!-- FIXME: where should this list come from? --> … … 284 285 logerror="true"> 285 286 <arg value="stripComments.js" /> 286 <arg value="${release_dir}"/> 287 <arg value="${release_dir}/src"/> 288 <arg value="false"/> 289 <arg value="${strip_and_compress}"/> 287 290 </java> 288 291 </target> -
branches/0.4/buildscripts/buildUtil.js
r7803 r7907 1004 1004 } 1005 1005 1006 buildUtil.stripComments = function(/*String*/startDir, /*boolean*/suppressDojoCopyright ){1006 buildUtil.stripComments = function(/*String*/startDir, /*boolean*/suppressDojoCopyright, /*boolean*/doCompress){ 1007 1007 //summary: strips the JS comments from all the files in "startDir", and all subdirectories. 1008 1008 var copyright = suppressDojoCopyright ? "" : (new String(buildUtil.readFile("copyright.txt")) + buildUtil.getLineSeparator()); … … 1024 1024 //Do comment removal. 1025 1025 try{ 1026 fileContents = buildUtil.optimizeJs(fileList[i], fileContents, copyright, false);1026 fileContents = buildUtil.optimizeJs(fileList[i], fileContents, copyright, doCompress); 1027 1027 }catch(e){ 1028 1028 print("Could not strip comments for file: " + fileList[i] + ", error: " + e); -
branches/0.4/buildscripts/lib/custom_rhino.diff
r5877 r7907 1 ### Eclipse Workspace Patch 1.0 2 #P rhino 1 3 Index: src/org/mozilla/javascript/BaseFunction.java 2 4 =================================================================== … … 5 7 diff -u -r1.57 BaseFunction.java 6 8 --- src/org/mozilla/javascript/BaseFunction.java 30 Aug 2005 10:05:42 -0000 1.57 7 +++ src/org/mozilla/javascript/BaseFunction.java 2 Jun 2006 09:19:22-00009 +++ src/org/mozilla/javascript/BaseFunction.java 2 Apr 2007 22:06:50 -0000 8 10 @@ -373,6 +373,28 @@ 9 11 return sb.toString(); … … 35 37 36 38 public int getLength() { return 0; } 39 Index: src/org/mozilla/javascript/NativeFunction.java 40 =================================================================== 41 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeFunction.java,v 42 retrieving revision 1.62 43 diff -u -r1.62 NativeFunction.java 44 --- src/org/mozilla/javascript/NativeFunction.java 17 Jan 2005 13:06:33 -0000 1.62 45 +++ src/org/mozilla/javascript/NativeFunction.java 2 Apr 2007 22:06:50 -0000 46 @@ -70,6 +70,26 @@ 47 } 48 } 49 50 + /** 51 + * Compress the script. 52 + * <p> 53 + * 54 + * @param parseTree Mapping for each function node and corresponding parameters & variables names 55 + * @param indent How much to indent the decompiled result 56 + * @param flags Flags specifying format of decompilation output 57 + * @return compressed script 58 + */ 59 + final String compress(ScriptOrFnNode parseTree, int indent, int flags) 60 + { 61 + String encodedSource = getEncodedSource(); 62 + if (encodedSource == null) { 63 + return super.compress(indent, flags); 64 + } else { 65 + UintMap properties = new UintMap(1); 66 + properties.put(Decompiler.INITIAL_INDENT_PROP, indent); 67 + return Decompiler.compress(encodedSource, flags, properties, parseTree); 68 + } 69 + } 70 public int getLength() 71 { 72 int paramCount = getParamCount(); 73 Index: src/org/mozilla/javascript/TokenStream.java 74 =================================================================== 75 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/TokenStream.java,v 76 retrieving revision 1.63 77 diff -u -r1.63 TokenStream.java 78 --- src/org/mozilla/javascript/TokenStream.java 31 Jul 2005 13:48:46 -0000 1.63 79 +++ src/org/mozilla/javascript/TokenStream.java 2 Apr 2007 22:06:50 -0000 80 @@ -64,9 +64,12 @@ 81 private final static int 82 EOF_CHAR = -1; 83 84 + public StringBuffer lastComment; 85 + 86 TokenStream(Parser parser, Reader sourceReader, String sourceString, 87 int lineno) 88 { 89 + this.lastComment = new StringBuffer(); 90 this.parser = parser; 91 this.lineno = lineno; 92 if (sourceReader != null) { 93 @@ -736,6 +739,8 @@ 94 95 case '/': 96 // is it a // comment? 97 + // FIXME: RAR: comment, need to set config to optionally keep 98 + // instead of skipping! 99 if (matchChar('/')) { 100 skipLine(); 101 continue retry; 37 102 Index: src/org/mozilla/javascript/Context.java 38 103 =================================================================== … … 41 106 diff -u -r1.244 Context.java 42 107 --- src/org/mozilla/javascript/Context.java 4 Nov 2005 13:37:45 -0000 1.244 43 +++ src/org/mozilla/javascript/Context.java 2 Jun 2006 09:19:26-0000108 +++ src/org/mozilla/javascript/Context.java 2 Apr 2007 22:06:50 -0000 44 109 @@ -1178,6 +1178,33 @@ 45 110 } … … 76 141 * Check whether a string is ready to be compiled. 77 142 * <p> 78 @@ -1361,6 +1388, 27@@143 @@ -1361,6 +1388,33 @@ 79 144 } 80 145 … … 90 155 + public final String compressScript(Script script, int indent, String source,int lineno) 91 156 + { 157 + //Make sure to clear out the TokenMapper state before running. 158 + //This allows for more than one script to be compressed. 159 + //However, this is not a very clean way to do the reset. 160 + TokenMapper.reset(); 161 + Decompiler.tm = new TokenMapper(); 162 + 92 163 + NativeFunction scriptImpl = (NativeFunction) script; 93 164 + … … 104 175 * <p> 105 176 * Decompiles a previously compiled JavaScript function object to 106 @@ -2240,7 +22 88,6 @@177 @@ -2240,7 +2294,6 @@ 107 178 sourceReader = null; 108 179 } … … 112 183 if (returnFunction) { 113 184 p.calledByCompileFunction = true; 114 @@ -2251,6 +2 298,7 @@185 @@ -2251,6 +2304,7 @@ 115 186 } else { 116 187 tree = p.parse(sourceReader, sourceName, lineno); … … 126 197 diff -u -r1.19 Decompiler.java 127 198 --- src/org/mozilla/javascript/Decompiler.java 28 Aug 2005 23:25:22 -0000 1.19 128 +++ src/org/mozilla/javascript/Decompiler.java 2 Jun 2006 09:19:28-0000199 +++ src/org/mozilla/javascript/Decompiler.java 2 Apr 2007 22:06:50 -0000 129 200 @@ -37,6 +37,11 @@ 130 201 … … 139 210 * The following class save decompilation information about the source. 140 211 * Source information is returned from the parser as a String 141 @@ -70,6 +75,2 64@@212 @@ -70,6 +75,272 @@ 142 213 * the final constant pool entry from information available at parse 143 214 * time. … … 169 240 + 170 241 + private int lastTokenCount = 0; 242 + 243 + /** 244 + * Reset the static members for the TokenMapper. 245 + */ 246 + public static void reset() { 247 + funcObjects = new ObjArray(); 248 + functionVarMappings = new ArrayList(); 249 + } 171 250 + 172 251 + /** … … 404 483 { 405 484 /** 406 @@ -266,6 +5 29,512@@485 @@ -266,6 +537,515 @@ 407 486 return new String(sourceBuffer, offset, sourceTop - offset); 408 487 } 409 488 410 + private static TokenMapper tm = new TokenMapper(); 489 + //Used to be private, but making it public so we 490 + //can reset the token state between compression runs. 491 + //Not very pretty. 492 + public static TokenMapper tm = new TokenMapper(); 411 493 + 412 494 + /** … … 917 999 * Decompile the source information associated with this js 918 1000 * function/script back into a string. For the most part, this 919 Index: src/org/mozilla/javascript/NativeFunction.java920 ===================================================================921 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeFunction.java,v922 retrieving revision 1.62923 diff -u -r1.62 NativeFunction.java924 --- src/org/mozilla/javascript/NativeFunction.java 17 Jan 2005 13:06:33 -0000 1.62925 +++ src/org/mozilla/javascript/NativeFunction.java 2 Jun 2006 09:19:28 -0000926 @@ -70,6 +70,26 @@927 }928 }929 930 + /**931 + * Compress the script.932 + * <p>933 + *934 + * @param parseTree Mapping for each function node and corresponding parameters & variables names935 + * @param indent How much to indent the decompiled result936 + * @param flags Flags specifying format of decompilation output937 + * @return compressed script938 + */939 + final String compress(ScriptOrFnNode parseTree, int indent, int flags)940 + {941 + String encodedSource = getEncodedSource();942 + if (encodedSource == null) {943 + return super.compress(indent, flags);944 + } else {945 + UintMap properties = new UintMap(1);946 + properties.put(Decompiler.INITIAL_INDENT_PROP, indent);947 + return Decompiler.compress(encodedSource, flags, properties, parseTree);948 + }949 + }950 public int getLength()951 {952 int paramCount = getParamCount();953 Index: src/org/mozilla/javascript/TokenStream.java954 ===================================================================955 RCS file: /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/TokenStream.java,v956 retrieving revision 1.63957 diff -u -r1.63 TokenStream.java958 --- src/org/mozilla/javascript/TokenStream.java 31 Jul 2005 13:48:46 -0000 1.63959 +++ src/org/mozilla/javascript/TokenStream.java 2 Jun 2006 09:19:29 -0000960 @@ -64,9 +64,12 @@961 private final static int962 EOF_CHAR = -1;963 964 + public StringBuffer lastComment;965 +966 TokenStream(Parser parser, Reader sourceReader, String sourceString,967 int lineno)968 {969 + this.lastComment = new StringBuffer();970 this.parser = parser;971 this.lineno = lineno;972 if (sourceReader != null) {973 @@ -736,6 +739,8 @@974 975 case '/':976 // is it a // comment?977 + // FIXME: RAR: comment, need to set config to optionally keep978 + // instead of skipping!979 if (matchChar('/')) {980 skipLine();981 continue retry;982 1001 Index: toolsrc/org/mozilla/javascript/tools/resources/Messages.properties 983 1002 =================================================================== … … 986 1005 diff -u -r1.22 Messages.properties 987 1006 --- toolsrc/org/mozilla/javascript/tools/resources/Messages.properties 2 Sep 2005 14:18:40 -0000 1.22 988 +++ toolsrc/org/mozilla/javascript/tools/resources/Messages.properties 2 Jun 2006 09:19:30 -00001007 +++ toolsrc/org/mozilla/javascript/tools/resources/Messages.properties 2 Apr 2007 22:06:50 -0000 989 1008 @@ -55,7 +55,9 @@ 990 1009 \ -version 100|110|120|130|140|150\n\ … … 1004 1023 diff -u -r1.65 Main.java 1005 1024 --- toolsrc/org/mozilla/javascript/tools/shell/Main.java 30 Sep 2005 08:28:51 -0000 1.65 1006 +++ toolsrc/org/mozilla/javascript/tools/shell/Main.java 2 Jun 2006 09:19:31-00001025 +++ toolsrc/org/mozilla/javascript/tools/shell/Main.java 2 Apr 2007 22:06:50 -0000 1007 1026 @@ -66,6 +66,11 @@ 1008 1027 static private final int EXITCODE_RUNTIME_ERROR = 3; -
branches/0.4/buildscripts/makeDojoJs.js
r7738 r7907 16 16 //Save the other layers, if there are any. 17 17 for(var i = 1; i < result.length; i++){ 18 buildUtil.saveFile(releaseDir + "/" + result[i].layerName, result[i].contents); 18 var layerName = releaseDir + "/" + result[i].layerName; 19 var uncompressedLayerName = layerName + ".uncompressed.js"; 20 21 buildUtil.saveFile(uncompressedLayerName, result[i].contents); 22 23 //Compress the layer files. It is clunky to do it here and have dojo.js 24 //compression done elsewhere. This will be fixed in 0.9 re-org. 25 print("Compressing file: " + layerName); 26 27 var copyright = new String(buildUtil.readFile("copyright.txt")); 28 29 //Load the file contents and optimize. 30 var fileContents = new String(buildUtil.readFile(uncompressedLayerName)); 31 fileContents = buildUtil.optimizeJs(uncompressedLayerName, fileContents, copyright, true); 32 33 //Save the optimized file. 34 buildUtil.saveFile(layerName, fileContents); 19 35 } 20 36 -
branches/0.4/buildscripts/stripComments.js
r7308 r7907 1 1 load("buildUtil.js"); 2 buildUtil.stripComments(arguments[0], arguments[1]); 2 3 var startDir = arguments[0]; 4 5 var suppressDojoCopyright = arguments[1]; 6 if(suppressDojoCopyright == "true"){ 7 suppressDojoCopyright = true; 8 }else{ 9 suppressDojoCopyright = false; 10 } 11 12 var doCompress = arguments[2]; 13 if(doCompress == "true"){ 14 doCompress = true; 15 }else{ 16 doCompress = false; 17 } 18 19 print(suppressDojoCopyright + ", " + doCompress); 20 21 buildUtil.stripComments(startDir, suppressDojoCopyright, doCompress);