Hi,

I currently have this code fragment

*
Integer xyz = new Integer(foo);
manager.declareBean("foo", xyz, xyz.getClass());
*

Which I use BCELLifier on to get the following section of BCEL code:

InstructionHandle ih_14 = il.append(_factory.createNew("java.lang.Integer"));
il.append(InstructionConstants.DUP);
il.append(_factory.createLoad(Type.INT, 1));
il.append(_factory.createInvoke("java.lang.Integer", "<init>",Type.VOID,new Type[] { Type.INT }, Constants.INVOKESPECIAL));
il.append(_factory.createStore(Type.OBJECT, 3));
InstructionHandle ih_23 = il.append(_factory.createLoad(Type.OBJECT, 0));
il.append(_factory.createFieldAccess("org.apache.commons.jelly.tags.bcel.Test","manager",new ObjectType("com.ibm.bsf.BSFManager"), Constants.GETFIELD));
il.append(new PUSH(_cp, "foo"));
il.append(_factory.createLoad(Type.OBJECT, 3));
il.append(_factory.createLoad(Type.OBJECT, 3));
il.append(_factory.createInvoke("java.lang.Object", "getClass", new ObjectType("java.lang.Class"), Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(_factory.createInvoke("com.ibm.bsf.BSFManager", "declareBean",Type.VOID, new Type[] { Type.STRING, Type.OBJECT, new ObjectType("java.lang.Class") }, Constants.INVOKEVIRTUAL));


Specifically, I'm struggling with some issues where I don't quite understand what the indexes are for in situations like

_factory.createStore(Type.OBJECT, 3)

and

_factory.createLoad(Type.OBJECT, 3)

am I right in assuming that there are a set number of "indexes" representing positions in the InstructionList and that these above references represent the setting and getting of Object references in that list?

I'm struggling because I'm trying to make the code more "iterative" where I might iterate over a "set" of handlers/append statements to append repeatedly to the instruction list (as an Example):

for(int i = 0; i < argNames.length ; ){

InstructionHandle ih_14 = il.append(_factory.createNew(argClasses[i]));
...
il.append(_factory.createStore(Type.OBJECT, i));
...
il.append(new PUSH(_cp, argName[i]));
il.append(_factory.createLoad(Type.OBJECT, i));
il.append(_factory.createLoad(Type.OBJECT, i));
...

}

My problem is that I get actuall references that end up pointing to only the first argument. I'm hoping I understand what the indexes are for, but I'm hoping that you guy's can clarify this for me.

Thanks,
-Mark Diggory



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to