}
function safe_to_assign(tw, def, declare) {
- if (def.fixed === undefined) return declare || all(def.orig, function(sym) {
+ if (!(declare || all(def.orig, function(sym) {
return !(sym instanceof AST_SymbolConst);
- });
+ }))) return false;
+ if (def.fixed === undefined) return true;
if (def.fixed === null && def.safe_ids) {
def.safe_ids[def.id] = false;
delete def.safe_ids;
]).optimize(compressor);
}
}
- } else if (self.left instanceof AST_SymbolRef) {
+ } else if (self.left instanceof AST_SymbolRef && all(self.left.definition().orig, function(sym) {
+ return !(sym instanceof AST_SymbolConst);
+ })) {
var parent;
if (self.operator == "=" && self.left.equivalent_to(self.right)
&& !((parent = compressor.parent()) instanceof AST_UnaryPrefix && parent.operator == "delete")) {
function createAccessor(recurmax, stmtDepth, canThrow) {
var namesLenBefore = VAR_NAMES.length;
var s;
- var prop1 = getDotKey();
- if (rng(2) == 0) {
- s = [
- "get " + prop1 + "(){",
- strictMode(),
- createStatements(2, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth),
- createStatement(recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth, STMT_RETURN_ETC),
- "},"
- ];
- } else {
- var prop2;
- do {
- prop2 = getDotKey();
- } while (prop1 == prop2);
- createBlockVariables(recurmax, stmtDepth, canThrow, function(defns) {
+ createBlockVariables(recurmax, stmtDepth, canThrow, function(defns) {
+ var prop1 = getDotKey();
+ if (rng(2) == 0) {
+ s = [
+ "get " + prop1 + "(){",
+ strictMode(),
+ defns(),
+ _createStatements(2, recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth),
+ createStatement(recurmax, canThrow, CANNOT_BREAK, CANNOT_CONTINUE, CAN_RETURN, stmtDepth, STMT_RETURN_ETC),
+ "},"
+ ];
+ } else {
+ var prop2;
+ do {
+ prop2 = getDotKey();
+ } while (prop1 == prop2);
s = [
"set " + prop1 + "(" + createVarName(MANDATORY) + "){",
strictMode(),
"this." + prop2 + createAssignment() + _createBinaryExpr(recurmax, COMMA_OK, stmtDepth, canThrow) + ";",
"},"
];
- });
- }
+ }
+ });
VAR_NAMES.length = namesLenBefore;
return filterDirective(s).join("\n");
}