diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-06-08 09:01:43 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-06-08 09:01:43 +0200 |
commit | d1fa08fdc9cb11dccee76d668ff85df30458c295 (patch) | |
tree | 1d19df6405103577d872902486792e8c23bce711 /trunk/infrastructure/yuicompressor/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java | |
parent | d7c5ad7d6263fd1baf9bfdbaa4c50b70ef2fbdb2 (diff) | |
parent | 70d1f9d6fcaefe611e778b8dbf3bafea8934aa08 (diff) | |
download | etherpad-d1fa08fdc9cb11dccee76d668ff85df30458c295.tar.gz etherpad-d1fa08fdc9cb11dccee76d668ff85df30458c295.tar.bz2 etherpad-d1fa08fdc9cb11dccee76d668ff85df30458c295.zip |
Merge remote branch 'upstream/master'
Conflicts:
etherpad/src/etherpad/control/pro/admin/pro_admin_control.js
etherpad/src/etherpad/control/pro/pro_main_control.js
etherpad/src/etherpad/control/pro_help_control.js
etherpad/src/etherpad/globals.js
etherpad/src/etherpad/legacy_urls.js
etherpad/src/etherpad/pne/pne_utils.js
etherpad/src/etherpad/pro/pro_utils.js
etherpad/src/main.js
etherpad/src/plugins/fileUpload/templates/fileUpload.ejs
etherpad/src/plugins/testplugin/templates/page.ejs
etherpad/src/static/css/pad2_ejs.css
etherpad/src/static/css/pro-help.css
etherpad/src/static/img/jun09/pad/protop.gif
etherpad/src/static/js/store.js
etherpad/src/themes/default/templates/framed/framedheader-pro.ejs
etherpad/src/themes/default/templates/main/home.ejs
etherpad/src/themes/default/templates/pro-help/main.ejs
etherpad/src/themes/default/templates/pro-help/pro-help-template.ejs
infrastructure/com.etherpad/licensing.scala
trunk/etherpad/src/etherpad/collab/ace/contentcollector.js
trunk/etherpad/src/etherpad/collab/ace/linestylefilter.js
trunk/etherpad/src/static/css/home-opensource.css
trunk/etherpad/src/static/js/ace.js
trunk/etherpad/src/static/js/linestylefilter_client.js
trunk/etherpad/src/templates/email/eepnet_license_info.ejs
trunk/etherpad/src/templates/pad/pad_body2.ejs
trunk/etherpad/src/templates/pad/pad_content.ejs
trunk/etherpad/src/templates/pad/padfull_body.ejs
trunk/etherpad/src/templates/pro/admin/pne-license-manager.ejs
Diffstat (limited to 'trunk/infrastructure/yuicompressor/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java')
-rw-r--r-- | trunk/infrastructure/yuicompressor/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java | 169 |
1 files changed, 0 insertions, 169 deletions
diff --git a/trunk/infrastructure/yuicompressor/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java b/trunk/infrastructure/yuicompressor/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java deleted file mode 100644 index c1a2e47..0000000 --- a/trunk/infrastructure/yuicompressor/src/com/yahoo/platform/yui/compressor/ScriptOrFnScope.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * YUI Compressor - * Author: Julien Lecomte <jlecomte@yahoo-inc.com> - * Copyright (c) 2007, Yahoo! Inc. All rights reserved. - * Code licensed under the BSD License: - * http://developer.yahoo.net/yui/license.txt - */ - -package com.yahoo.platform.yui.compressor; - -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Hashtable; - -class ScriptOrFnScope { - - private int braceNesting; - private ScriptOrFnScope parentScope; - private ArrayList subScopes; - private Hashtable identifiers = new Hashtable(); - private Hashtable hints = new Hashtable(); - private boolean markedForMunging = true; - private int varcount = 0; - - ScriptOrFnScope(int braceNesting, ScriptOrFnScope parentScope) { - this.braceNesting = braceNesting; - this.parentScope = parentScope; - this.subScopes = new ArrayList(); - if (parentScope != null) { - parentScope.subScopes.add(this); - } - } - - int getBraceNesting() { - return braceNesting; - } - - ScriptOrFnScope getParentScope() { - return parentScope; - } - - JavaScriptIdentifier declareIdentifier(String symbol) { - JavaScriptIdentifier identifier = (JavaScriptIdentifier) identifiers.get(symbol); - if (identifier == null) { - identifier = new JavaScriptIdentifier(symbol, this); - identifiers.put(symbol, identifier); - } - return identifier; - } - - JavaScriptIdentifier getIdentifier(String symbol) { - return (JavaScriptIdentifier) identifiers.get(symbol); - } - - void addHint(String variableName, String variableType) { - hints.put(variableName, variableType); - } - - void preventMunging() { - if (parentScope != null) { - // The symbols in the global scope don't get munged, - // but the sub-scopes it contains do get munged. - markedForMunging = false; - } - } - - private ArrayList getUsedSymbols() { - ArrayList result = new ArrayList(); - Enumeration elements = identifiers.elements(); - while (elements.hasMoreElements()) { - JavaScriptIdentifier identifier = (JavaScriptIdentifier) elements.nextElement(); - String mungedValue = identifier.getMungedValue(); - if (mungedValue == null) { - mungedValue = identifier.getValue(); - } - result.add(mungedValue); - } - return result; - } - - private ArrayList getAllUsedSymbols() { - ArrayList result = new ArrayList(); - ScriptOrFnScope scope = this; - while (scope != null) { - result.addAll(scope.getUsedSymbols()); - scope = scope.parentScope; - } - return result; - } - - int incrementVarCount() { - varcount++; - return varcount; - } - - void munge() { - - if (!markedForMunging) { - // Stop right here if this scope was flagged as unsafe for munging. - return; - } - - int pickFromSet = 1; - - // Do not munge symbols in the global scope! - if (parentScope != null) { - - ArrayList freeSymbols = new ArrayList(); - - freeSymbols.addAll(JavaScriptCompressor.ones); - freeSymbols.removeAll(getAllUsedSymbols()); - if (freeSymbols.size() == 0) { - pickFromSet = 2; - freeSymbols.addAll(JavaScriptCompressor.twos); - freeSymbols.removeAll(getAllUsedSymbols()); - } - if (freeSymbols.size() == 0) { - pickFromSet = 3; - freeSymbols.addAll(JavaScriptCompressor.threes); - freeSymbols.removeAll(getAllUsedSymbols()); - } - if (freeSymbols.size() == 0) { - throw new IllegalStateException("The YUI Compressor ran out of symbols. Aborting..."); - } - - // APPJET: sort identifiers by popularity - JavaScriptIdentifier idArray[] = ((Hashtable<String,JavaScriptIdentifier>)identifiers).values().toArray(new JavaScriptIdentifier[0]); - java.util.Arrays.sort(idArray, new java.util.Comparator<JavaScriptIdentifier>() { - public int compare(JavaScriptIdentifier i1, JavaScriptIdentifier i2) { - return i2.getRefcount() - i1.getRefcount(); // positive if i2 is more popular, indicating i2 should come first - } - }); - java.util.Iterator<JavaScriptIdentifier> elements = java.util.Arrays.asList(idArray).iterator(); - - //Enumeration elements = identifiers.elements(); - while (elements.hasNext()) { - if (freeSymbols.size() == 0) { - pickFromSet++; - if (pickFromSet == 2) { - freeSymbols.addAll(JavaScriptCompressor.twos); - } else if (pickFromSet == 3) { - freeSymbols.addAll(JavaScriptCompressor.threes); - } else { - throw new IllegalStateException("The YUI Compressor ran out of symbols. Aborting..."); - } - // It is essential to remove the symbols already used in - // the containing scopes, or some of the variables declared - // in the containing scopes will be redeclared, which can - // lead to errors. - freeSymbols.removeAll(getAllUsedSymbols()); - } - - String mungedValue; - JavaScriptIdentifier identifier = (JavaScriptIdentifier) elements.next(); - if (identifier.isMarkedForMunging()) { - mungedValue = (String) freeSymbols.remove(0); - } else { - mungedValue = identifier.getValue(); - } - identifier.setMungedValue(mungedValue); - } - } - - for (int i = 0; i < subScopes.size(); i++) { - ScriptOrFnScope scope = (ScriptOrFnScope) subScopes.get(i); - scope.munge(); - } - } -} |