add AST_Accessor and AST_SymbolAccessor node types

AST_Accessor will represent the function for a setter or getter.  Since they
are not mangleable, and they should not introduce a name in scope, we have a
new node for their name (AST_SymbolAccessor) which doesn't inherit from
AST_SymbolDeclaration.

fix #37
This commit is contained in:
Mihai Bazon
2012-11-07 12:43:27 +02:00
parent a1ae0c8609
commit 5276a4a873
3 changed files with 19 additions and 7 deletions

View File

@@ -312,6 +312,11 @@ AST_Symbol.DEFMETHOD("unmangleable", function(options){
return this.definition().unmangleable(options);
});
// property accessors are not mangleable
AST_SymbolAccessor.DEFMETHOD("unmangleable", function(){
return true;
});
// labels are always mangleable
AST_Label.DEFMETHOD("unmangleable", function(){
return false;
@@ -363,12 +368,9 @@ AST_Toplevel.DEFMETHOD("mangle_names", function(options){
}
if (node instanceof AST_Scope) {
var p = tw.parent();
var is_setget = p instanceof AST_ObjectSetter || p instanceof AST_ObjectGetter;
node.variables.each(function(symbol){
if (!(is_setget && symbol instanceof AST_SymbolLambda)) {
if (options.except.indexOf(symbol.name) < 0) {
to_mangle.push(symbol);
}
if (options.except.indexOf(symbol.name) < 0) {
to_mangle.push(symbol);
}
});
return;