Skip to content

Commit

Permalink
Fix mangling issues with safari
Browse files Browse the repository at this point in the history
Fixes mishoo#326 and mishoo#179

It isn't a really clean solution, but it works. The idea is to
"virtually" reference the function name inside the scope. But to be able
know it isn't *really* referenced, we add a `virtual` flag to
`AST_SymbolRef.reference`.
  • Loading branch information
rvanvelzen committed Oct 25, 2013
1 parent cfd5c61 commit 360628d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(){
func = node;
descend();
func = prev_func;

if (node instanceof AST_Function && node.name && node.argnames.length) {
var ref = new AST_SymbolRef({
scope: node.argnames[0].scope,
name: node.name.name,
thedef: node.name.thedef
});
ref.reference(true);
}

return true;
}
if (node instanceof AST_SymbolRef) {
Expand Down Expand Up @@ -199,9 +209,9 @@ AST_Lambda.DEFMETHOD("init_scope_vars", function(){
this.uses_arguments = false;
});

AST_SymbolRef.DEFMETHOD("reference", function() {
AST_SymbolRef.DEFMETHOD("reference", function(virtual) {
var def = this.definition();
def.references.push(this);
if (!virtual) def.references.push(this);
var s = this.scope;
while (s) {
push_uniq(s.enclosed, def);
Expand Down

0 comments on commit 360628d

Please sign in to comment.