}
}
ClassGen cg = new ClassGen( jc );
ConstantPoolGen cp = cg.getConstantPool();
InstructionFactory _factory = new InstructionFactory( cg, cp );
Method[] methods = cg.getMethods();
for ( Method method : methods )
{
Type[] types = method.getArgumentTypes();
if ( method.getName().equals( "setLogger" ) && types.length == 1
&& types[0].equals( Type.getType( "Lflex2/compiler/Logger;" ) ) )
{
InstructionList il = new InstructionList();
MethodGen mg =
new MethodGen( method.getAccessFlags(), method.getReturnType(), method.getArgumentTypes(), null,
method.getName(), null, il, cp );
il.append( InstructionFactory.createLoad( Type.OBJECT, 0 ) );
il.append( _factory.createInvoke( FLEXMOJOS_HELPER, "fixLogger",
new ObjectType( "flex2.compiler.Logger" ),
new Type[] { new ObjectType( "flex2.compiler.Logger" ) },
Constants.INVOKESTATIC ) );
il.append( InstructionFactory.createStore( Type.OBJECT, 0 ) );
il.append( _factory.createFieldAccess( THREAD_LOCAL_TOOLKIT, "logger",
new ObjectType( "java.lang.ThreadLocal" ), Constants.GETSTATIC ) );
il.append( InstructionFactory.createLoad( Type.OBJECT, 0 ) );
il.append( _factory.createInvoke( "java.lang.ThreadLocal", "set", Type.VOID,
new Type[] { Type.OBJECT }, Constants.INVOKEVIRTUAL ) );
il.append( InstructionFactory.createLoad( Type.OBJECT, 0 ) );
BranchInstruction ifnull_13 = InstructionFactory.createBranchInstruction( Constants.IFNULL, null );
il.append( ifnull_13 );
il.append( InstructionFactory.createLoad( Type.OBJECT, 0 ) );
il.append( _factory.createInvoke( THREAD_LOCAL_TOOLKIT, "getLocalizationManager",
new ObjectType( "flash.localization.LocalizationManager" ),
Type.NO_ARGS, Constants.INVOKESTATIC ) );
il.append( _factory.createInvoke( "flex2.compiler.Logger",
"setLocalizationManager",
Type.VOID,
new Type[] { new ObjectType( "flash.localization.LocalizationManager" ) },
Constants.INVOKEINTERFACE ) );
InstructionHandle ih_25 = il.append( InstructionFactory.createReturn( Type.VOID ) );
ifnull_13.setTarget( ih_25 );
mg.setMaxStack();
mg.setMaxLocals();
cg.removeMethod( method );
cg.addMethod( mg.getMethod() );
il.dispose();
}
else if ( method.getName().equals( "setPathResolver" ) && types.length == 1
&& types[0].equals( new ObjectType( "flex2.compiler.common.PathResolver" ) ) )
{
InstructionList il = new InstructionList();
MethodGen mg =
new MethodGen( method.getAccessFlags(), method.getReturnType(), method.getArgumentTypes(), null,
method.getName(), null, il, cp );
il.append( InstructionFactory.createLoad( Type.OBJECT, 0 ) );
il.append( _factory.createInvoke( FLEXMOJOS_HELPER,
"fixPathResolver",
new ObjectType( "flex2.compiler.common.PathResolver" ),
new Type[] { new ObjectType( "flex2.compiler.common.PathResolver" ) },
Constants.INVOKESTATIC ) );
il.append( InstructionFactory.createStore( Type.OBJECT, 0 ) );
il.append( _factory.createFieldAccess( THREAD_LOCAL_TOOLKIT, "resolver",
new ObjectType( "java.lang.ThreadLocal" ), Constants.GETSTATIC ) );
il.append( InstructionFactory.createLoad( Type.OBJECT, 0 ) );
il.append( _factory.createInvoke( "java.lang.ThreadLocal", "set", Type.VOID,
new Type[] { Type.OBJECT }, Constants.INVOKEVIRTUAL ) );
il.append( InstructionFactory.createReturn( Type.VOID ) );
mg.setMaxStack();
mg.setMaxLocals();