return orig.length == 1 && orig[0] instanceof AST_SymbolFunarg;
}
+ function is_content_constant(ref, depth) {
+ var escaped = ref.definition().escaped;
+ switch (escaped.length) {
+ case 0:
+ return true;
+ case 1:
+ var found = false;
+ escaped[0].walk(new TreeWalker(function(node) {
+ if (found) return true;
+ if (node === ref) return found = true;
+ }));
+ return found;
+ default:
+ return depth <= escaped.depth;
+ }
+ }
+
(function(def) {
def(AST_Node, noop);
}
function to_value(def, sym, fixed) {
- if (fixed instanceof AST_Node) return fixed;
- if (typeof fixed == "function") return fixed();
- return make_node(AST_Undefined, sym);
+ if (fixed == null) {
+ fixed = make_node(AST_Undefined, sym);
+ } else if (typeof fixed == "function") {
+ fixed = fixed();
+ }
+ if (fixed instanceof AST_Array || fixed instanceof AST_Object) {
+ if (!is_content_constant(sym)) return false;
+ }
+ return fixed;
}
function ref_once(compressor, def) {
};
cached.push(fixed);
}
- if (value && typeof value == "object") {
- var escaped = this.definition().escaped;
- switch (escaped.length) {
- case 0:
- break;
- case 1:
- if (contains_ref(escaped[0], this)) break;
- default:
- if (depth > escaped.depth) return this;
- }
- }
+ if (value && typeof value == "object" && !is_content_constant(this, depth)) return this;
return value;
-
- function contains_ref(expr, ref) {
- var found = false;
- expr.walk(new TreeWalker(function(node) {
- if (found) return true;
- if (node === ref) return found = true;
- }));
- return found;
- }
});
var global_objs = {
Array: Array,