Ticket #5089: 5089_2.patch
File 5089_2.patch, 2.1 KB (added by , 13 years ago) |
---|
-
trunk/test/test.js
309 309 310 310 [ "var a=(1,2,3,4);" ], 311 311 312 [ "a=(1,2,3,4);" ] 312 [ "a=(1,2,3,4);" ], 313 314 [ "var A=function B(){var C=1;B();};", "var a=function c(){var b=1;c();};" ], 315 316 [ "var A={foo:function C(){}};", "var a={foo:function b(){}};" ], 317 318 [ "call(function A(){});", "call(function a(){});" ] 313 319 ]; 314 320 315 321 var tests = -
trunk/_source/includes/scriptcompressor.js
368 368 369 369 out( 'function' ); 370 370 371 if ( name.length() )372 out( ' ', scope.getNewName( name, true ) );373 374 371 var currentTree = tree, 375 372 fnIndex = node.getExistingIntProp( Node.FUNCTION_PROP ), 376 373 fn = tree.getFunctionNode(fnIndex); 377 374 375 if ( fn.functionType != 2 && name.length() ) 376 out( ' ', scope.getNewName( name, 1 ) ); 377 378 378 scope = new CKPACKAGER.scope( fn, scope ); 379 379 380 // Named function expression affects only inner scope. 381 if ( fn.functionType == 2 && name.length() ) 382 { 383 scope.declareName( name ); 384 out( ' ', scope.getNewName( name, 1 ) ); 385 } 386 380 387 out( '(' ); 381 388 382 389 for ( var i = 0, len = scope.args.length ; i < len ; i++ ) … … 394 401 out( 'var ', scope.getNewName( 'this' ), '=this;' ); 395 402 396 403 tree = fn; 397 writeNode( fn.getFirstChild(), { isFunction : true } );398 404 405 var funcBody = fn.getFirstChild(); 406 407 // Remove the "scope downcast" provided by Rhino. 408 if ( fn.functionType == 2 && name.length() ) 409 funcBody.removeChild( funcBody.getFirstChild() ); 410 411 writeNode( funcBody, { isFunction : true } ); 412 399 413 scope = scope.parent; 400 414 tree = currentTree; 401 415 402 416 out( '}' ); 403 417 404 if ( name.length() ) 418 // No trailing semicolon for function expression. 419 if ( fn.functionType != 2 && name.length() ) 405 420 out( ';' ); 406 421 break; 407 422