cleaned up some mess and started the actual compressor

This commit is contained in:
Mihai Bazon
2012-08-21 15:45:05 +03:00
parent 7ae1c600a2
commit ffe58a9961
7 changed files with 315 additions and 52 deletions

View File

@@ -138,19 +138,24 @@ AST_Toplevel.DEFMETHOD("scope_warnings", function(options){
col: node.start.col
});
}
if (options.assign_to_global
&& node instanceof AST_Assign
&& node.left instanceof AST_SymbolRef
&& (node.left.undeclared
|| (node.left.symbol.global
&& node.left.scope !== node.left.symbol.scope)))
if (options.assign_to_global)
{
AST_Node.warn("{msg}: {name} [{line},{col}]", {
msg: node.left.undeclared ? "Accidental global?" : "Assignment to global",
name: node.left.name,
line: node.start.line,
col: node.start.col
});
var sym = null;
if (node instanceof AST_Assign && node.left instanceof AST_SymbolRef)
sym = node.left;
else if (node instanceof AST_ForIn && node.init instanceof AST_SymbolRef)
sym = node.init;
if (sym
&& (sym.undeclared
|| (sym.symbol.global
&& sym.scope !== sym.symbol.scope))) {
AST_Node.warn("{msg}: {name} [{line},{col}]", {
msg: sym.undeclared ? "Accidental global?" : "Assignment to global",
name: sym.name,
line: sym.start.line,
col: sym.start.col
});
}
}
if (options.eval
&& node instanceof AST_SymbolRef