InstructionFactory fact = gen.getFactory();
setup.append(fact.createNew(new ObjectType(NameMangler.CFLOW_STACK_TYPE)));
- setup.append(fact.createDup(1));
+ setup.append(InstructionFactory.createDup(1));
setup.append(fact.createInvoke(
NameMangler.CFLOW_STACK_TYPE,
"<init>",
import org.apache.bcel.generic.INVOKESPECIAL;
import org.apache.bcel.generic.IndexedInstruction;
import org.apache.bcel.generic.Instruction;
+import org.apache.bcel.generic.InstructionConstants;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
boolean keepReturns)
{
InstructionList footer = new InstructionList();
- InstructionHandle end = footer.append(fact.NOP);
+ InstructionHandle end = footer.append(InstructionConstants.NOP);
InstructionList ret = new InstructionList();
InstructionList sourceList = donor.getBody();
// a computation leak... we're testing this LOTS of times. Sigh.
if (isAcrossClass) {
CPInstruction cpi = (CPInstruction) fresh;
- cpi.setIndex(recipientCpg.addConstant(donorCpg.getConstant(cpi.getIndex()), donorCpg));
+ cpi.setIndex(
+ recipientCpg.addConstant(
+ donorCpg.getConstant(cpi.getIndex()),
+ donorCpg));
}
}
if (src.getInstruction() == Range.RANGEINSTRUCTION) {
if (keepReturns) {
dest = ret.append(fresh);
} else {
- dest = ret.append(fact.createBranchInstruction(Constants.GOTO, end));
+ dest =
+ ret.append(InstructionFactory.createBranchInstruction(Constants.GOTO, end));
}
} else if (fresh instanceof BranchInstruction) {
dest = ret.append((BranchInstruction) fresh);
// writing ret back to front because we're popping.
if (! donor.isStatic()) {
int targetSlot = recipient.allocateLocal(Type.OBJECT);
- ret.insert(fact.createStore(Type.OBJECT, targetSlot));
+ ret.insert(InstructionFactory.createStore(Type.OBJECT, targetSlot));
frameEnv.put(donorFramePos, targetSlot);
donorFramePos += 1;
}
for (int i = 0, len = argTypes.length; i < len; i++) {
Type argType = argTypes[i];
int argSlot = recipient.allocateLocal(argType);
- ret.insert(fact.createStore(argType, argSlot));
+ ret.insert(InstructionFactory.createStore(argType, argSlot));
frameEnv.put(donorFramePos, argSlot);
donorFramePos += argType.getSize();
}
InstructionFactory fact = clazz.getFactory();
setup.append(fact.createNew(aspectType));
- setup.append(fact.createDup(1));
+ setup.append(InstructionFactory.createDup(1));
setup.append(fact.createInvoke(
aspectName,
"<init>",
Type.VOID,
new Type[0],
Constants.INVOKESPECIAL));
- setup.append(fact.createFieldAccess(aspectName, field.getName(), aspectType, Constants.PUTSTATIC));
+ setup.append(
+ fact.createFieldAccess(
+ aspectName,
+ field.getName(),
+ aspectType,
+ Constants.PUTSTATIC));
clinit.getBody().insert(setup);
}
curr,
ifaceInitSig);
if (match(cexecShadow, shadowAccumulator)) {
- cexecShadow.getRange().getBody().append(cexecShadow.getRange().getStart(), fact.NOP);
+ cexecShadow.getRange().getBody().append(
+ cexecShadow.getRange().getStart(),
+ InstructionConstants.NOP);
}
// generate the init jp around it
BcelShadow initShadow =
if (effective == null) {
enclosingShadow = BcelShadow.makeMethodExecution(world, mg);
} else if (effective.isWeaveBody()) {
- enclosingShadow = BcelShadow.makeShadowForMethod(world, mg, effective.getShadowKind(), effective.getEffectiveSignature());
+ enclosingShadow =
+ BcelShadow.makeShadowForMethod(
+ world,
+ mg,
+ effective.getShadowKind(),
+ effective.getEffectiveSignature());
} else {
return false;
}
ConcreteTypeMunger cmunger = (ConcreteTypeMunger) i.next();
NewFieldTypeMunger munger = (NewFieldTypeMunger) cmunger.getMunger();
ResolvedMember initMethod = munger.getInitMethod(cmunger.getAspectType());
- if (!isStatic) ret.append(fact.ALOAD_0);
+ if (!isStatic) ret.append(InstructionConstants.ALOAD_0);
ret.append(Utility.createInvoke(fact, world, initMethod));
}
return ret;
InstructionHandle prevHandle = ih.getPrev();
Instruction prevI = prevHandle.getInstruction();
if (Utility.isConstantPushInstruction(prevI)) {
- Member field = world.makeFieldSignature(clazz, (FieldInstruction) i);
+ Member field = BcelWorld.makeFieldSignature(clazz, (FieldInstruction) i);
ResolvedMember resolvedField = field.resolve(world);
if (resolvedField == null) {
// we can't find the field, so it's not a join point.
}
- private void matchSetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List shadowAccumulator) {
+ private void matchSetInstruction(
+ LazyMethodGen mg,
+ InstructionHandle ih,
+ BcelShadow enclosingShadow,
+ List shadowAccumulator) {
FieldInstruction fi = (FieldInstruction) ih.getInstruction();
- Member field = world.makeFieldSignature(clazz, fi);
+ Member field = BcelWorld.makeFieldSignature(clazz, fi);
ResolvedMember resolvedField = field.resolve(world);
if (resolvedField == null) {
// we can't find the field, so it's not a join point.
return;
- } else if (Modifier.isFinal(resolvedField.getModifiers()) &&
- Utility.isConstantPushInstruction(ih.getPrev().getInstruction()))
- {
+ } else if (
+ Modifier.isFinal(resolvedField.getModifiers())
+ && Utility.isConstantPushInstruction(ih.getPrev().getInstruction())) {
// it's the set of a final constant, so it's
// not a join point according to 1.0.6 and 1.1.
return;
// sets of synthetics aren't join points in 1.1
return;
} else {
- match(BcelShadow.makeFieldSet(world, mg, ih, enclosingShadow), shadowAccumulator);
+ match(
+ BcelShadow.makeFieldSet(world, mg, ih, enclosingShadow),
+ shadowAccumulator);
}
}
private void matchGetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List shadowAccumulator) {
FieldInstruction fi = (FieldInstruction) ih.getInstruction();
- Member field = world.makeFieldSignature(clazz, fi);
+ Member field = BcelWorld.makeFieldSignature(clazz, fi);
ResolvedMember resolvedField = field.resolve(world);
if (resolvedField == null) {
// we can't find the field, so it's not a join point.
String methodName = invoke.getName(cpg);
if (methodName.startsWith(NameMangler.PREFIX)) {
Member method =
- world.makeMethodSignature(clazz, invoke);
+ BcelWorld.makeMethodSignature(clazz, invoke);
ResolvedMember declaredSig = method.resolve(world);
//System.err.println(method + ", declaredSig: " +declaredSig);
if (declaredSig == null) return;
kind, declaredSig),
shadowAccumulator);
} else {
- AjAttribute.EffectiveSignatureAttribute effectiveSig = declaredSig.getEffectiveSignature();
+ AjAttribute.EffectiveSignatureAttribute effectiveSig =
+ declaredSig.getEffectiveSignature();
if (effectiveSig == null) return;
//System.err.println("call to inter-type member: " + effectiveSig);
if (effectiveSig.isWeaveBody()) return;
BcelRenderer renderer = new BcelRenderer(fact, world);
e.accept(renderer);
InstructionList il = renderer.instructions;
- il.append(Utility.createConversion(fact, world.makeBcelType(e.getType()), desiredType));
+ il.append(Utility.createConversion(fact, BcelWorld.makeBcelType(e.getType()), desiredType));
return il;
}
public void visit(Instanceof i) {
instructions.insert(createJumpBasedOnBooleanOnStack());
instructions.insert(
- Utility.createInstanceof(fact, (ReferenceType) world.makeBcelType(i.getType())));
+ Utility.createInstanceof(fact, (ReferenceType) BcelWorld.makeBcelType(i.getType())));
i.getVar().accept(this);
}
if (sk == fk) {
// don't bother generating if it doesn't matter
if (sk != next) {
- il.insert(fact.createBranchInstruction(Constants.GOTO, sk));
+ il.insert(InstructionFactory.createBranchInstruction(Constants.GOTO, sk));
}
return il;
}
if (fk == next) {
- il.insert(fact.createBranchInstruction(Constants.IFNE, sk));
+ il.insert(InstructionFactory.createBranchInstruction(Constants.IFNE, sk));
} else if (sk == next) {
- il.insert(fact.createBranchInstruction(Constants.IFEQ, fk));
+ il.insert(InstructionFactory.createBranchInstruction(Constants.IFEQ, fk));
} else {
- il.insert(fact.createBranchInstruction(Constants.GOTO, sk));
- il.insert(fact.createBranchInstruction(Constants.IFEQ, fk));
+ il.insert(InstructionFactory.createBranchInstruction(Constants.GOTO, sk));
+ il.insert(InstructionFactory.createBranchInstruction(Constants.IFEQ, fk));
}
return il;
}
import org.apache.bcel.generic.INVOKESPECIAL;
import org.apache.bcel.generic.INVOKESTATIC;
import org.apache.bcel.generic.Instruction;
+import org.apache.bcel.generic.InstructionConstants;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
retargetFrom(newHandle, nextHandle);
// add a POP here... we found a NEW w/o a dup or anything else, so
// we must be in statement context.
- getRange().insert(getFactory().POP, Range.OutsideAfter);
+ getRange().insert(InstructionConstants.POP, Range.OutsideAfter);
}
// assert (dupHandle.getInstruction() instanceof DUP);
ShadowRange range = getRange();
InstructionList body = range.getBody();
InstructionHandle start = range.getStart();
- InstructionHandle freshIh = body.insert(start, getFactory().NOP);
+ InstructionHandle freshIh = body.insert(start, InstructionConstants.NOP);
InstructionTargeter[] targeters = start.getTargeters();
for (int i = 0; i < targeters.length; i++) {
InstructionTargeter t = targeters[i];
Range.InsideBefore);
}
if (getKind() == ConstructorCall) {
- range.insert((Instruction) fact.createDup(1), Range.InsideBefore);
+ range.insert((Instruction) InstructionFactory.createDup(1), Range.InsideBefore);
range.insert(
fact.createNew(
(ObjectType) BcelWorld.makeBcelType(
InstructionHandle clinitStart = body.getStart();
if (clinitStart.getInstruction() instanceof InvokeInstruction) {
InvokeInstruction ii = (InvokeInstruction)clinitStart.getInstruction();
- if (ii.getName(enclosingMethod.getEnclosingClass().getConstantPoolGen()).equals(NameMangler.AJC_PRE_CLINIT_NAME)) {
- clinitStart = clinitStart.getNext();
- }
+ if (ii
+ .getName(enclosingMethod.getEnclosingClass().getConstantPoolGen())
+ .equals(NameMangler.AJC_PRE_CLINIT_NAME)) {
+ clinitStart = clinitStart.getNext();
+ }
}
InstructionHandle clinitEnd = body.getEnd();
{
final InstructionList body = enclosingMethod.getBody();
- Member sig = world.makeMethodSignature(
- enclosingMethod.getEnclosingClass(),
- (InvokeInstruction) callHandle.getInstruction());
+ Member sig = BcelWorld.makeMethodSignature(
+ enclosingMethod.getEnclosingClass(),
+ (InvokeInstruction) callHandle.getInstruction());
BcelShadow s =
new BcelShadow(
new BcelShadow(
world,
MethodCall,
- world.makeMethodSignature(
+ BcelWorld.makeMethodSignature(
enclosingMethod.getEnclosingClass(),
(InvokeInstruction) callHandle.getInstruction()),
enclosingMethod,
new BcelShadow(
world,
FieldGet,
- world.makeFieldSignature(
+ BcelWorld.makeFieldSignature(
enclosingMethod.getEnclosingClass(),
(FieldInstruction) getHandle.getInstruction()),
enclosingMethod,
new BcelShadow(
world,
FieldSet,
- world.makeFieldSignature(
+ BcelWorld.makeFieldSignature(
enclosingMethod.getEnclosingClass(),
(FieldInstruction) setHandle.getInstruction()),
enclosingMethod,
// ---- type access methods
private ObjectType getTargetBcelType() {
- return (ObjectType) world.makeBcelType(getTargetType());
+ return (ObjectType) BcelWorld.makeBcelType(getTargetType());
}
private Type getArgBcelType(int arg) {
- return world.makeBcelType(getArgType(arg));
+ return BcelWorld.makeBcelType(getArgType(arg));
}
// ---- kinding
retList = new InstructionList(ret);
afterAdvice = retList.getStart();
} else /* if (munger.hasDynamicTests()) */ {
- retList = new InstructionList(fact.NOP);
+ retList = new InstructionList(InstructionConstants.NOP);
afterAdvice = retList.getStart();
// } else {
// retList = new InstructionList();
TypeX tempVarType = getReturnType();
if (tempVarType.equals(ResolvedTypeX.VOID)) {
tempVar = genTempVar(TypeX.OBJECT);
- advice.append(getFactory().ACONST_NULL);
+ advice.append(InstructionConstants.ACONST_NULL);
tempVar.appendStore(advice, getFactory());
} else {
tempVar = genTempVar(tempVarType);
- advice.append(getFactory().createDup(tempVarType.getSize()));
+ advice.append(InstructionFactory.createDup(tempVarType.getSize()));
tempVar.appendStore(advice, getFactory());
}
}
if (ret != null) {
InstructionHandle gotoTarget = advice.getStart();
- for (Iterator i = returns.iterator(); i.hasNext(); ) {
- InstructionHandle ih = (InstructionHandle) i.next();
- Utility.replaceInstruction(ih, fact.createBranchInstruction(Constants.GOTO, gotoTarget), enclosingMethod);
- }
+ for (Iterator i = returns.iterator(); i.hasNext();) {
+ InstructionHandle ih = (InstructionHandle) i.next();
+ Utility.replaceInstruction(
+ ih,
+ InstructionFactory.createBranchInstruction(
+ Constants.GOTO,
+ gotoTarget),
+ enclosingMethod);
+ }
range.append(advice);
range.append(retList);
} else {
exceptionVar.createLoad(fact));
handler.append(munger.getAdviceInstructions(this, exceptionVar, endHandler.getStart()));
handler.append(endHandler);
- handler.append(fact.ATHROW);
+ handler.append(InstructionConstants.ATHROW);
InstructionHandle handlerStart = handler.getStart();
if (isFallsThrough()) {
- InstructionHandle jumpTarget = handler.append(fact.NOP);
- handler.insert(fact.createBranchInstruction(Constants.GOTO, jumpTarget));
+ InstructionHandle jumpTarget = handler.append(InstructionConstants.NOP);
+ handler.insert(InstructionFactory.createBranchInstruction(Constants.GOTO, jumpTarget));
}
InstructionHandle protectedEnd = handler.getStart();
range.insert(handler, Range.InsideAfter);
exceptionVar.appendStore(handler, fact);
handler.append(fact.createNew(NameMangler.SOFT_EXCEPTION_TYPE));
- handler.append(fact.createDup(1));
+ handler.append(InstructionFactory.createDup(1));
handler.append(exceptionVar.createLoad(fact));
handler.append(fact.createInvoke(NameMangler.SOFT_EXCEPTION_TYPE, "<init>",
Type.VOID, new Type[] { Type.THROWABLE }, Constants.INVOKESPECIAL)); //??? special
- handler.append(fact.ATHROW);
+ handler.append(InstructionConstants.ATHROW);
InstructionHandle handlerStart = handler.getStart();
if (isFallsThrough()) {
InstructionHandle jumpTarget = range.getEnd();//handler.append(fact.NOP);
- handler.insert(fact.createBranchInstruction(Constants.GOTO, jumpTarget));
+ handler.insert(InstructionFactory.createBranchInstruction(Constants.GOTO, jumpTarget));
}
InstructionHandle protectedEnd = handler.getStart();
range.insert(handler, Range.InsideAfter);
int alen = cflowStateVars.length;
entrySuccessInstructions.append(Utility.createConstant(fact, alen));
- entrySuccessInstructions.append((Instruction)fact.createNewArray(Type.OBJECT, (short)1));
+ entrySuccessInstructions.append(
+ (Instruction) fact.createNewArray(Type.OBJECT, (short) 1));
arrayVar.appendStore(entrySuccessInstructions, fact);
- for (int i = 0; i < alen; i++) {
- arrayVar.appendConvertableArrayStore(entrySuccessInstructions, fact, i, cflowStateVars[i]);
- }
+ for (int i = 0; i < alen; i++) {
+ arrayVar.appendConvertableArrayStore(
+ entrySuccessInstructions,
+ fact,
+ i,
+ cflowStateVars[i]);
+ }
entrySuccessInstructions.append(
Utility.createGet(fact, cflowStackField));
// this is the same for both per and non-per
weaveAfter(new BcelAdvice(null, null, null, 0, 0, 0, null, null) {
- public InstructionList getAdviceInstructions(BcelShadow s, BcelVar extraArgVar, InstructionHandle ifNoAdvice) {
- InstructionList exitInstructions = new InstructionList();
- if (munger.hasDynamicTests()) {
- testResult.appendLoad(exitInstructions, fact);
- exitInstructions.append(fact.createBranchInstruction(Constants.IFEQ, ifNoAdvice));
- }
- exitInstructions.append(
- Utility.createGet(fact, cflowStackField));
- exitInstructions.append(
- fact.createInvoke(NameMangler.CFLOW_STACK_TYPE, "pop", Type.VOID, new Type[] {}, Constants.INVOKEVIRTUAL));
+ public InstructionList getAdviceInstructions(
+ BcelShadow s,
+ BcelVar extraArgVar,
+ InstructionHandle ifNoAdvice) {
+ InstructionList exitInstructions = new InstructionList();
+ if (munger.hasDynamicTests()) {
+ testResult.appendLoad(exitInstructions, fact);
+ exitInstructions.append(
+ InstructionFactory.createBranchInstruction(
+ Constants.IFEQ,
+ ifNoAdvice));
+ }
+ exitInstructions.append(Utility.createGet(fact, cflowStackField));
+ exitInstructions
+ .append(
+ fact
+ .createInvoke(
+ NameMangler.CFLOW_STACK_TYPE,
+ "pop",
+ Type.VOID,
+ new Type[] {
+ }, Constants.INVOKEVIRTUAL));
return exitInstructions;
- }});
+ }
+ });
range.insert(entryInstructions, Range.InsideBefore);
Type[] adviceParameterTypes = adviceMethod.getArgumentTypes();
Type[] extractedMethodParameterTypes = extractedMethod.getArgumentTypes();
- Type[] parameterTypes = new Type[extractedMethodParameterTypes.length + adviceParameterTypes.length + 1];
+ Type[] parameterTypes =
+ new Type[extractedMethodParameterTypes.length
+ + adviceParameterTypes.length
+ + 1];
int parameterIndex = 0;
- System.arraycopy(extractedMethodParameterTypes, 0, parameterTypes, parameterIndex, extractedMethodParameterTypes.length);
+ System.arraycopy(
+ extractedMethodParameterTypes,
+ 0,
+ parameterTypes,
+ parameterIndex,
+ extractedMethodParameterTypes.length);
parameterIndex += extractedMethodParameterTypes.length;
- parameterTypes[parameterIndex++] =
- BcelWorld.makeBcelType(adviceMethod.getEnclosingClass().getType());
- System.arraycopy(adviceParameterTypes, 0, parameterTypes, parameterIndex, adviceParameterTypes.length);
+ parameterTypes[parameterIndex++] =
+ BcelWorld.makeBcelType(adviceMethod.getEnclosingClass().getType());
+ System.arraycopy(
+ adviceParameterTypes,
+ 0,
+ parameterTypes,
+ parameterIndex,
+ adviceParameterTypes.length);
LazyMethodGen localAdviceMethod =
new LazyMethodGen(
var.appendLoad(advice, fact);
}
// ??? we don't actually need to push NULL for the closure if we take care
- advice.append(munger.getAdviceArgSetup(this, null, new InstructionList(fact.ACONST_NULL)));
+ advice.append(
+ munger.getAdviceArgSetup(
+ this,
+ null,
+ new InstructionList(InstructionConstants.ACONST_NULL)));
adviceMethodInvocation =
advice.append(
Utility.createInvoke(fact, localAdviceMethod)); //(fact, getWorld(), munger.getSignature()));
advice.append(
Utility.createConversion(
getFactory(),
- world.makeBcelType(munger.getSignature().getReturnType()),
+ BcelWorld.makeBcelType(munger.getSignature().getReturnType()),
extractedMethod.getReturnType()));
if (! isFallsThrough()) {
- advice.append(fact.createReturn(extractedMethod.getReturnType()));
+ advice.append(InstructionFactory.createReturn(extractedMethod.getReturnType()));
}
}
if (! hasDynamicTest) {
range.append(advice);
} else {
- InstructionList afterThingie = new InstructionList(fact.NOP);
+ InstructionList afterThingie = new InstructionList(InstructionConstants.NOP);
InstructionList callback = makeCallToCallback(extractedMethod);
- if (terminatesWithReturn()) {
- callback.append(fact.createReturn(extractedMethod.getReturnType()));
- } else {
- //InstructionHandle endNop = range.insert(fact.NOP, Range.InsideAfter);
- advice.append(fact.createBranchInstruction(Constants.GOTO, afterThingie.getStart()));
- }
- range.append(munger.getTestInstructions(this, advice.getStart(), callback.getStart(), advice.getStart()));
+ if (terminatesWithReturn()) {
+ callback.append(
+ InstructionFactory.createReturn(extractedMethod.getReturnType()));
+ } else {
+ //InstructionHandle endNop = range.insert(fact.NOP, Range.InsideAfter);
+ advice.append(
+ InstructionFactory.createBranchInstruction(
+ Constants.GOTO,
+ afterThingie.getStart()));
+ }
+ range.append(
+ munger.getTestInstructions(
+ this,
+ advice.getStart(),
+ callback.getStart(),
+ advice.getStart()));
range.append(advice);
range.append(callback);
range.append(afterThingie);
InstructionHandle next = curr.getNext();
Instruction inst = curr.getInstruction();
if ((inst instanceof INVOKESTATIC)
- && proceedName.equals(((INVOKESTATIC) inst).getMethodName(cpg))) {
-
-
- localAdviceMethod.getBody().append(curr, getRedoneProceedCall(fact, extractedMethod, munger, localAdviceMethod, proceedVarList));
+ && proceedName.equals(((INVOKESTATIC) inst).getMethodName(cpg))) {
+
+ localAdviceMethod.getBody().append(
+ curr,
+ getRedoneProceedCall(
+ fact,
+ extractedMethod,
+ munger,
+ localAdviceMethod,
+ proceedVarList));
Utility.deleteInstruction(curr, localAdviceMethod);
}
curr = next;
// System.out.println(proceedMap + " for " + this);
// System.out.println(argVarList);
- ResolvedTypeX[] proceedParamTypes = world.resolve(munger.getSignature().getParameterTypes());
+ ResolvedTypeX[] proceedParamTypes =
+ world.resolve(munger.getSignature().getParameterTypes());
// remove this*JoinPoint* as arguments to proceed
if (munger.getBaseParameterCount()+1 < proceedParamTypes.length) {
int len = munger.getBaseParameterCount()+1;
Type[] stateTypes = getSuperConstructorParameterTypes();
- returnConversionCode.append(fact.ALOAD_0); // put "this" back on the stack
+ returnConversionCode.append(InstructionConstants.ALOAD_0); // put "this" back on the stack
for (int i = 0, len = stateTypes.length; i < len; i++) {
stateTempVar.appendConvertableArrayLoad(
returnConversionCode,
returnConversionCode =
Utility.createConversion(
getFactory(),
- world.makeBcelType(munger.getSignature().getReturnType()),
+ BcelWorld.makeBcelType(munger.getSignature().getReturnType()),
callbackMethod.getReturnType());
- if (! isFallsThrough()) {
- returnConversionCode.append(fact.createReturn(callbackMethod.getReturnType()));
- }
+ if (!isFallsThrough()) {
+ returnConversionCode.append(
+ InstructionFactory.createReturn(callbackMethod.getReturnType()));
+ }
}
InstructionList advice = new InstructionList();
advice.append(munger.getNonTestAdviceInstructions(this));
advice.append(returnConversionCode);
- if (! hasDynamicTest) {
- range.append(advice);
- } else {
- InstructionList callback = makeCallToCallback(callbackMethod);
- InstructionList postCallback = new InstructionList();
- if (terminatesWithReturn()) {
- callback.append(fact.createReturn(callbackMethod.getReturnType()));
- } else {
- advice.append(fact.createBranchInstruction(Constants.GOTO, postCallback.append(fact.NOP)));
- }
- range.append(munger.getTestInstructions(this, advice.getStart(), callback.getStart(), advice.getStart()));
- range.append(advice);
- range.append(callback);
- range.append(postCallback);
- }
+ if (!hasDynamicTest) {
+ range.append(advice);
+ } else {
+ InstructionList callback = makeCallToCallback(callbackMethod);
+ InstructionList postCallback = new InstructionList();
+ if (terminatesWithReturn()) {
+ callback.append(
+ InstructionFactory.createReturn(callbackMethod.getReturnType()));
+ } else {
+ advice.append(
+ InstructionFactory.createBranchInstruction(
+ Constants.GOTO,
+ postCallback.append(InstructionConstants.NOP)));
+ }
+ range.append(
+ munger.getTestInstructions(
+ this,
+ advice.getStart(),
+ callback.getStart(),
+ advice.getStart()));
+ range.append(advice);
+ range.append(callback);
+ range.append(postCallback);
+ }
}
// exposed for testing
InstructionFactory fact = getFactory();
InstructionList callback = new InstructionList();
if (thisVar != null) {
- callback.append(fact.ALOAD_0);
+ callback.append(InstructionConstants.ALOAD_0);
}
if (targetVar != null && targetVar != thisVar) {
callback.append(BcelRenderer.renderExpr(fact, world, targetVar));
arrayVar.appendLoad(il, fact);
il.append(Utility.createInvoke(fact, world, constructor));
if (getKind() == PreInitialization) {
- il.append(fact.DUP);
+ il.append(InstructionConstants.DUP);
holder.appendStore(il, fact);
}
return il;
new String[] {},
closureClass);
InstructionList cbody = constructor.getBody();
- cbody.append(fact.createLoad(Type.OBJECT, 0));
- cbody.append(fact.createLoad(objectArrayType, 1));
+ cbody.append(InstructionFactory.createLoad(Type.OBJECT, 0));
+ cbody.append(InstructionFactory.createLoad(objectArrayType, 1));
cbody.append(fact.createInvoke(superClassName, "<init>", Type.VOID,
new Type[] {objectArrayType}, Constants.INVOKESPECIAL));
- cbody.append(fact.createReturn(Type.VOID));
+ cbody.append(InstructionFactory.createReturn(Type.VOID));
closureClass.addMethodGen(constructor);
InstructionList mbody = runMethod.getBody();
BcelVar proceedVar = new BcelVar(TypeX.OBJECTARRAY.resolve(world), 1);
// int proceedVarIndex = 1;
- BcelVar stateVar = new BcelVar(TypeX.OBJECTARRAY.resolve(world), runMethod.allocateLocal(1));
+ BcelVar stateVar =
+ new BcelVar(TypeX.OBJECTARRAY.resolve(world), runMethod.allocateLocal(1));
// int stateVarIndex = runMethod.allocateLocal(1);
- mbody.append(fact.createThis());
+ mbody.append(InstructionFactory.createThis());
mbody.append(fact.createGetField(superClassName, "state", objectArrayType));
mbody.append(stateVar.createStore(fact));
// mbody.append(fact.createStore(objectArrayType, stateVarIndex));
mbody.append(Utility.createSet(
fact,
AjcMemberMaker.aroundClosurePreInitializationField()));
- mbody.append(fact.ACONST_NULL);
+ mbody.append(InstructionConstants.ACONST_NULL);
} else {
mbody.append(
Utility.createConversion(
callbackMethod.getReturnType(),
Type.OBJECT));
}
- mbody.append(fact.createReturn(Type.OBJECT));
+ mbody.append(InstructionFactory.createReturn(Type.OBJECT));
closureClass.addMethodGen(runMethod);
// push object array
arrayVar.appendLoad(body, fact);
// swap
- body.append(fact.SWAP);
+ body.append(InstructionConstants.SWAP);
// do object array store.
body.append(Utility.createConstant(fact, i));
- body.append(fact.SWAP);
- body.append(fact.createArrayStore(Type.OBJECT));
+ body.append(InstructionConstants.SWAP);
+ body.append(InstructionFactory.createArrayStore(Type.OBJECT));
}
arrayVar.appendLoad(body, fact);
- body.append(fact.ARETURN);
+ body.append(InstructionConstants.ARETURN);
}
private Type[] getSuperConstructorParameterTypes() {
* ??? rewrite this to do less array munging, please
*/
private LazyMethodGen createMethodGen(String newMethodName) {
- Type[] parameterTypes = world.makeBcelTypes(getArgTypes());
+ Type[] parameterTypes = BcelWorld.makeBcelTypes(getArgTypes());
int modifiers = Modifier.FINAL;
// XXX some bug
}
targetType = getThisType();
}
- parameterTypes = addType(world.makeBcelType(targetType), parameterTypes);
+ parameterTypes = addType(BcelWorld.makeBcelType(targetType), parameterTypes);
}
if (thisVar != null) {
TypeX thisType = getThisType();
- parameterTypes = addType(world.makeBcelType(thisType), parameterTypes);
+ parameterTypes = addType(BcelWorld.makeBcelType(thisType), parameterTypes);
}
// We always want to pass down thisJoinPoint in case we have already woven
return
new LazyMethodGen(
modifiers,
- world.makeBcelType(returnType),
+ BcelWorld.makeBcelType(returnType),
newMethodName,
parameterTypes,
new String[0],
import org.apache.bcel.Constants;
import org.apache.bcel.generic.FieldGen;
+import org.apache.bcel.generic.InstructionConstants;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.Type;
} else if (member.getKind() == Member.CONSTRUCTOR) {
for (Iterator i = gen.getMethodGens().iterator(); i.hasNext(); ) {
LazyMethodGen m = (LazyMethodGen)i.next();
- if (m.getMemberView() != null && m.getMemberView().getKind() == Member.CONSTRUCTOR) {
+ if (m.getMemberView() != null
+ && m.getMemberView().getKind() == Member.CONSTRUCTOR) {
// m.getMemberView().equals(member)) {
m.forcePublic();
//return true;
field.getName(),
BcelWorld.makeBcelType(field.getType()), Constants.GETSTATIC));
} else {
- il.append(fact.ALOAD_0);
+ il.append(InstructionConstants.ALOAD_0);
il.append(fact.createFieldAccess(
gen.getClassName(),
field.getName(),
BcelWorld.makeBcelType(field.getType()), Constants.GETFIELD));
}
- il.append(fact.createReturn(BcelWorld.makeBcelType(field.getType())));
+ il.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(field.getType())));
mg.getBody().insert(il);
gen.addMethodGen(mg);
Type fieldType = BcelWorld.makeBcelType(field.getType());
if (field.isStatic()) {
- il.append(fact.createLoad(fieldType, 0));
+ il.append(InstructionFactory.createLoad(fieldType, 0));
il.append(fact.createFieldAccess(
gen.getClassName(),
field.getName(),
fieldType, Constants.PUTSTATIC));
} else {
- il.append(fact.ALOAD_0);
- il.append(fact.createLoad(fieldType, 1));
+ il.append(InstructionConstants.ALOAD_0);
+ il.append(InstructionFactory.createLoad(fieldType, 1));
il.append(fact.createFieldAccess(
gen.getClassName(),
field.getName(),
fieldType, Constants.PUTFIELD));
}
- il.append(fact.createReturn(Type.VOID));
+ il.append(InstructionFactory.createReturn(Type.VOID));
mg.getBody().insert(il);
gen.addMethodGen(mg);
int pos = 0;
if (!method.isStatic()) {
- il.append(fact.ALOAD_0);
+ il.append(InstructionConstants.ALOAD_0);
pos++;
}
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
- il.append(fact.createLoad(paramType, pos));
+ il.append(InstructionFactory.createLoad(paramType, pos));
pos+=paramType.getSize();
}
il.append(Utility.createInvoke(fact, (BcelWorld)aspectType.getWorld(),
method));
- il.append(fact.createReturn(BcelWorld.makeBcelType(method.getReturnType())));
+ il.append(InstructionFactory.createReturn(BcelWorld.makeBcelType(method.getReturnType())));
mg.getBody().insert(il);
gen);
InstructionList il = new InstructionList();
InstructionFactory fact = gen.getFactory();
- il.append(fact.ALOAD_0);
+ il.append(InstructionConstants.ALOAD_0);
il.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.GETFIELD));
- il.append(fact.createReturn(fieldType));
+ il.append(InstructionFactory.createReturn(fieldType));
mg.getBody().insert(il);
gen.addMethodGen(mg);
new Type[]{fieldType,}, new String[0],
gen);
InstructionList il1 = new InstructionList();
- il1.append(fact.ALOAD_0);
- il1.append(fact.createLoad(fieldType, 1));
+ il1.append(InstructionConstants.ALOAD_0);
+ il1.append(InstructionFactory.createLoad(fieldType, 1));
il1.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.PUTFIELD));
- il1.append(fact.createReturn(Type.VOID));
+ il1.append(InstructionFactory.createReturn(Type.VOID));
mg1.getBody().insert(il1);
gen.addMethodGen(mg1);
int pos = 0;
if (!signature.isStatic()) {
- body.append(fact.createThis());
+ body.append(InstructionFactory.createThis());
pos++;
}
Type[] paramTypes = BcelWorld.makeBcelTypes(introMethod.getParameterTypes());
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
- body.append(fact.createLoad(paramType, pos));
+ body.append(InstructionFactory.createLoad(paramType, pos));
pos+=paramType.getSize();
}
body.append(Utility.createInvoke(fact, weaver.getWorld(), dispatchMethod));
- body.append(fact.createReturn(BcelWorld.makeBcelType(introMethod.getReturnType())));
+ body.append(
+ InstructionFactory.createReturn(
+ BcelWorld.makeBcelType(introMethod.getReturnType())));
} else {
//??? this is okay
//if (!(mg.getBody() == null)) throw new RuntimeException("bas");
int pos = 0;
if (!introMethod.isStatic()) {
- body.append(fact.createThis());
+ body.append(InstructionFactory.createThis());
pos++;
}
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
- body.append(fact.createLoad(paramType, pos));
+ body.append(InstructionFactory.createLoad(paramType, pos));
pos+=paramType.getSize();
}
body.append(Utility.createInvoke(fact, weaver.getWorld(), dispatchMethod));
- body.append(fact.createReturn(returnType));
+ body.append(InstructionFactory.createReturn(returnType));
mg.definingType = onType;
weaver.addOrReplaceLazyMethodGen(mg);
{
LazyClassGen gen = weaver.getLazyClassGen();
- for (Iterator iter = neededSuperCalls.iterator(); iter.hasNext(); ) {
+ for (Iterator iter = neededSuperCalls.iterator(); iter.hasNext();) {
ResolvedMember superMethod = (ResolvedMember) iter.next();
if (weaver.addDispatchTarget(superMethod)) {
//System.err.println("super type: " + superMethod.getDeclaringType() + ", " + gen.getType());
boolean isSuper = !superMethod.getDeclaringType().equals(gen.getType());
String dispatchName;
- if (isSuper) dispatchName = NameMangler.superDispatchMethod(onType, superMethod.getName());
- else dispatchName = NameMangler.protectedDispatchMethod(onType, superMethod.getName());
- LazyMethodGen dispatcher = makeDispatcher(gen, dispatchName, superMethod, weaver.getWorld(), isSuper);
-
+ if (isSuper)
+ dispatchName =
+ NameMangler.superDispatchMethod(onType, superMethod.getName());
+ else
+ dispatchName =
+ NameMangler.protectedDispatchMethod(
+ onType,
+ superMethod.getName());
+ LazyMethodGen dispatcher =
+ makeDispatcher(
+ gen,
+ dispatchName,
+ superMethod,
+ weaver.getWorld(),
+ isSuper);
+
weaver.addLazyMethodGen(dispatcher);
}
}
Type[] paramTypes = freshConstructor.getArgumentTypes();
int frameIndex = 1;
for (int i = 0, len = declaredParams.length; i < len; i++) {
- body.append(fact.createLoad(paramTypes[i], frameIndex));
+ body.append(InstructionFactory.createLoad(paramTypes[i], frameIndex));
frameIndex += paramTypes[i].getSize();
}
// do call to pre
- Member preMethod = AjcMemberMaker.preIntroducedConstructor(aspectType, onType, declaredParams);
+ Member preMethod =
+ AjcMemberMaker.preIntroducedConstructor(aspectType, onType, declaredParams);
body.append(Utility.createInvoke(fact, null, preMethod));
// create a local, and store return pre stuff into it.
int arraySlot = freshConstructor.allocateLocal(1);
- body.append(fact.createStore(Type.OBJECT, arraySlot));
+ body.append(InstructionFactory.createStore(Type.OBJECT, arraySlot));
// put this on the stack
- body.append(fact.ALOAD_0);
+ body.append(InstructionConstants.ALOAD_0);
// unpack pre args onto stack
TypeX[] superParamTypes = explicitConstructor.getParameterTypes();
for (int i = 0, len = superParamTypes.length; i < len; i++) {
- body.append(fact.createLoad(Type.OBJECT, arraySlot));
+ body.append(InstructionFactory.createLoad(Type.OBJECT, arraySlot));
body.append(Utility.createConstant(fact, i));
- body.append(fact.createArrayLoad(Type.OBJECT));
- body.append(Utility.createConversion(fact, Type.OBJECT, BcelWorld.makeBcelType(superParamTypes[i])));
+ body.append(InstructionFactory.createArrayLoad(Type.OBJECT));
+ body.append(
+ Utility.createConversion(
+ fact,
+ Type.OBJECT,
+ BcelWorld.makeBcelType(superParamTypes[i])));
}
// call super/this
// put this back on the stack
- body.append(fact.ALOAD_0);
+ body.append(InstructionConstants.ALOAD_0);
// unpack params onto stack
- Member postMethod = AjcMemberMaker.postIntroducedConstructor(aspectType, onType, declaredParams);
+ Member postMethod =
+ AjcMemberMaker.postIntroducedConstructor(aspectType, onType, declaredParams);
TypeX[] postParamTypes = postMethod.getParameterTypes();
for (int i = 1, len = postParamTypes.length; i < len; i++) {
- body.append(fact.createLoad(Type.OBJECT, arraySlot));
+ body.append(InstructionFactory.createLoad(Type.OBJECT, arraySlot));
body.append(Utility.createConstant(fact, superParamTypes.length + i-1));
- body.append(fact.createArrayLoad(Type.OBJECT));
- body.append(Utility.createConversion(fact, Type.OBJECT, BcelWorld.makeBcelType(postParamTypes[i])));
+ body.append(InstructionFactory.createArrayLoad(Type.OBJECT));
+ body.append(
+ Utility.createConversion(
+ fact,
+ Type.OBJECT,
+ BcelWorld.makeBcelType(postParamTypes[i])));
}
// call post
// don't forget to return!!
- body.append(fact.RETURN);
+ body.append(InstructionConstants.RETURN);
return true;
}
InstructionFactory fact = onGen.getFactory();
int pos = 0;
- body.append(fact.createThis());
+ body.append(InstructionFactory.createThis());
pos++;
for (int i = 0, len = paramTypes.length; i < len; i++) {
Type paramType = paramTypes[i];
- body.append(fact.createLoad(paramType, pos));
+ body.append(InstructionFactory.createLoad(paramType, pos));
pos+=paramType.getSize();
}
if (isSuper) {
} else {
body.append(Utility.createInvoke(fact, world, superMethod));
}
- body.append(fact.createReturn(returnType));
+ body.append(InstructionFactory.createReturn(returnType));
return mg;
}
fg.getName(),
fieldType, Constants.GETSTATIC));
} else {
- il.append(fact.ALOAD_0);
+ il.append(InstructionConstants.ALOAD_0);
il.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.GETFIELD));
}
- il.append(fact.createReturn(fieldType));
+ il.append(InstructionFactory.createReturn(fieldType));
mg.getBody().insert(il);
gen.addMethodGen(mg);
AjcMemberMaker.interFieldInterfaceSetter(field, gen.getType(), aspectType));
InstructionList il1 = new InstructionList();
if (field.isStatic()) {
- il1.append(fact.createLoad(fieldType, 0));
+ il1.append(InstructionFactory.createLoad(fieldType, 0));
il1.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.PUTSTATIC));
} else {
- il1.append(fact.ALOAD_0);
- il1.append(fact.createLoad(fieldType, 1));
+ il1.append(InstructionConstants.ALOAD_0);
+ il1.append(InstructionFactory.createLoad(fieldType, 1));
il1.append(fact.createFieldAccess(
gen.getClassName(),
fg.getName(),
fieldType, Constants.PUTFIELD));
}
- il1.append(fact.createReturn(Type.VOID));
+ il1.append(InstructionFactory.createReturn(Type.VOID));
mg1.getBody().insert(il1);
gen.addMethodGen(mg1);
public int getSlot() { return slot; }
public Instruction createLoad(InstructionFactory fact) {
- return fact.createLoad(BcelWorld.makeBcelType(getType()), slot);
+ // TODO: remove fact
+ return InstructionFactory.createLoad(BcelWorld.makeBcelType(getType()), slot);
}
public Instruction createStore(InstructionFactory fact) {
- return fact.createStore(BcelWorld.makeBcelType(getType()), slot);
+ // TODO: remove fact
+ return InstructionFactory.createStore(BcelWorld.makeBcelType(getType()), slot);
}
public void appendStore(InstructionList il, InstructionFactory fact) {
+ // TODO: remove fact
il.append(createStore(fact));
}
public void appendLoad(InstructionList il, InstructionFactory fact) {
+ // TODO: remove fact
il.append(createLoad(fact));
}
- public void appendLoadAndConvert(InstructionList il, InstructionFactory fact, ResolvedTypeX toType) {
- il.append(createLoad(fact));
- Utility.appendConversion(il, fact, getType(), toType);
- }
+ public void appendLoadAndConvert(
+ InstructionList il,
+ InstructionFactory fact,
+ ResolvedTypeX toType) {
+ il.append(createLoad(fact));
+ Utility.appendConversion(il, fact, getType(), toType);
+ }
public void insertLoad(InstructionList il, InstructionFactory fact) {
+ // TODO: remove fact
il.insert(createLoad(fact));
}
public InstructionList createCopyFrom(InstructionFactory fact, int oldSlot) {
+ // TODO: remove fact
InstructionList il = new InstructionList();
- il.append(fact.createLoad(BcelWorld.makeBcelType(getType()), oldSlot));
+ il.append(InstructionFactory.createLoad(BcelWorld.makeBcelType(getType()), oldSlot));
il.append(createStore(fact));
return il;
}
ResolvedTypeX convertFromType = getType().getResolvedComponentType();
appendLoad(il, fact);
il.append(Utility.createConstant(fact, index));
- il.append(fact.createArrayLoad(BcelWorld.makeBcelType(convertFromType)));
+ il.append(InstructionFactory.createArrayLoad(BcelWorld.makeBcelType(convertFromType)));
Utility.appendConversion(il, fact, convertFromType, convertTo);
}
il.append(Utility.createConstant(fact, index));
storee.appendLoad(il, fact);
Utility.appendConversion(il, fact, storee.getType(), convertToType);
- il.append(fact.createArrayStore(BcelWorld.makeBcelType(convertToType)));
+ il.append(InstructionFactory.createArrayStore(BcelWorld.makeBcelType(convertToType)));
}
InstructionList createConvertableArrayStore(
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.FieldGen;
+import org.apache.bcel.generic.InstructionConstants;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
new Type[0],
CollectionUtil.NO_STRINGS,
this);
- clinit.getBody().insert(getFactory().RETURN);
+ clinit.getBody().insert(InstructionConstants.RETURN);
methodGens.add(clinit);
return clinit;
}
new Type[0],
CollectionUtil.NO_STRINGS,
this);
- ajcClinit.getBody().insert(getFactory().RETURN);
+ ajcClinit.getBody().insert(InstructionConstants.RETURN);
methodGens.add(ajcClinit);
getStaticInitializer().getBody().insert(Utility.createInvoke(getFactory(), ajcClinit));
// make a new factory
list.append(fact.createNew(factoryType));
- list.append(fact.createDup(1));
+ list.append(InstructionFactory.createDup(1));
list.append(new PUSH(getConstantPoolGen(), getFileName()));
Type.VOID, new Type[] {Type.STRING, classType},
Constants.INVOKESPECIAL));
- list.append(fact.createStore(factoryType, 0));
+ list.append(InstructionFactory.createStore(factoryType, 0));
List entries = new ArrayList(tjpFields.entrySet());
Collections.sort(entries, new Comparator() {
//ResolvedMember mem = shadow.getSignature().resolve(shadow.getWorld());
// load the factory
- list.append(fact.createLoad(factoryType, 0));
+ list.append(InstructionFactory.createLoad(factoryType, 0));
// load the kind
list.append(new PUSH(getConstantPoolGen(), shadow.getKind().getName()));
// create the signature
- list.append(fact.createLoad(factoryType, 0));
+ list.append(InstructionFactory.createLoad(factoryType, 0));
list.append(new PUSH(getConstantPoolGen(), sig.getSignatureString(shadow.getWorld())));
list.append(fact.createInvoke(factoryType.getClassName(),
sig.getSignatureMakerName(),
}
public String toShortString() {
- org.apache.bcel.classfile.Utility util = null; // EVIL!
- String access = util.accessToString(getAccessFlags());
+ String access = org.apache.bcel.classfile.Utility.accessToString(getAccessFlags());
StringBuffer buf = new StringBuffer();
buf.append(access);
buf.append(" ");
}
- buf.append(util.signatureToString(getReturnType().getSignature(), true));
+ buf.append(
+ org.apache.bcel.classfile.Utility.signatureToString(
+ getReturnType().getSignature(),
+ true));
buf.append(" ");
buf.append(getName());
buf.append("(");
- {
- int len = argumentTypes.length;
- if (len > 0) {
- buf.append(util.signatureToString(argumentTypes[0].getSignature(), true));
- for (int i = 1; i < argumentTypes.length; i++) {
- buf.append(", ");
- buf.append(util.signatureToString(argumentTypes[i].getSignature(), true));
- }
- }
- }
+ {
+ int len = argumentTypes.length;
+ if (len > 0) {
+ buf.append(
+ org.apache.bcel.classfile.Utility.signatureToString(
+ argumentTypes[0].getSignature(),
+ true));
+ for (int i = 1; i < argumentTypes.length; i++) {
+ buf.append(", ");
+ buf.append(
+ org.apache.bcel.classfile.Utility.signatureToString(
+ argumentTypes[i].getSignature(),
+ true));
+ }
+ }
+ }
buf.append(")");
{
if (addReturn) {
// we really should pull this out somewhere...
ret = freshBody.append(
- new InstructionFactory(freshMethod.getEnclosingClass().getConstantPoolGen())
- .createReturn(freshMethod.getReturnType()));
+ InstructionFactory.createReturn(freshMethod.getReturnType()));
}
// and remap all the old targeters of the end handle of the range to the return.
InstructionTargeter[] ts = end.getTargeters();
//XXX this is an important optimization
if (getBytes() == null) {
System.out.println("no bytes for: " + getFilename());
- Thread.currentThread().dumpStack();
+ //Thread.currentThread().dumpStack();
+ Thread.dumpStack();
}
return Utility.makeJavaClass(filename, getBytes());
// if (javaClass == null) javaClass = Utility.makeJavaClass(filename, getBytes());
return fact.createInvoke(
signature.getDeclaringType().getName(),
signature.getName(),
- world.makeBcelType(signature.getReturnType()),
- world.makeBcelTypes(signature.getParameterTypes()),
+ BcelWorld.makeBcelType(signature.getReturnType()),
+ BcelWorld.makeBcelTypes(signature.getParameterTypes()),
kind);
}
if (toType.equals(ResolvedTypeX.VOID)) {
// assert fromType.equals(TypeX.OBJECT)
- il.append(fact.createPop(fromType.getSize()));
+ il.append(InstructionFactory.createPop(fromType.getSize()));
} else if (fromType.equals(ResolvedTypeX.VOID)) {
// assert toType.equals(TypeX.OBJECT)
- il.append(fact.createNull(Type.OBJECT));
+ il.append(InstructionFactory.createNull(Type.OBJECT));
return;
} else if (fromType.equals(TypeX.OBJECT)) {
Type to = BcelWorld.makeBcelType(toType);
if (fromType.equals(toType))
return il;
if (toType.equals(Type.VOID)) {
- il.append(fact.createPop(fromType.getSize()));
+ il.append(InstructionFactory.createPop(fromType.getSize()));
return il;
}
if (fromType.equals(Type.VOID)) {
if (toType instanceof BasicType)
throw new BCException("attempting to cast from void to basic type");
- il.append(fact.createNull(Type.OBJECT));
+ il.append(InstructionFactory.createNull(Type.OBJECT));
return il;
}
}
// Create a new select statement with the new targets array
- SWITCH switchStatement = new SWITCH(freshSelect.getMatchs(),targets,freshSelect.getTarget());
+ SWITCH switchStatement =
+ new SWITCH(freshSelect.getMatchs(), targets, freshSelect.getTarget());
return (Select)switchStatement.getInstruction();
} else {
return i.copy(); // Use clone for shallow copy...
Type type = BcelWorld.makeBcelType(typeX);
int local = enclosingMethod.allocateLocal(type);
- il.append(fact.createStore(type, local));
+ il.append(InstructionFactory.createStore(type, local));
ret[i] = new BcelVar(typeX, local);
}
return ret;
tokenSource.peek());
}
if (declaringType.toString().equals("")) {
- declaringType = declaringType.ANY;
+ declaringType = TypePattern.ANY;
}
}
}
} else {
name = tryToExtractName(declaringType);
if (declaringType.toString().equals("")) {
- declaringType = declaringType.ANY;
+ declaringType = TypePattern.ANY;
}
}
SignaturePattern ret = new SignaturePattern(Member.FIELD, modifiers, returnType,
import java.io.*;
+import org.apache.bcel.generic.InstructionFactory;
import org.aspectj.weaver.*;
public class MoveInstructionsWeaveTestCase extends WeaveTestCase {
super.specializeOn(s);
((BcelShadow) s).initializeForAroundClosure();
}
- public void implementOn(Shadow s) {
- BcelShadow shadow = (BcelShadow) s;
- LazyMethodGen newMethod = shadow.extractMethod(shadow.getSignature().getExtractableName() + "_extracted");
- shadow.getRange().append(shadow.makeCallToCallback(newMethod));
+ public void implementOn(Shadow s) {
+ BcelShadow shadow = (BcelShadow) s;
+ LazyMethodGen newMethod =
+ shadow.extractMethod(
+ shadow.getSignature().getExtractableName() + "_extracted");
+ shadow.getRange().append(shadow.makeCallToCallback(newMethod));
- if (! shadow.isFallsThrough()) {
- shadow.getRange().append(shadow.getFactory().createReturn(newMethod.getReturnType()));
- }
- }
+ if (!shadow.isFallsThrough()) {
+ shadow.getRange().append(
+ InstructionFactory.createReturn(newMethod.getReturnType()));
+ }
+ }
};
weaveTest("HelloWorld", "ExtractedHelloWorld", p);
shadow.getRange().append(shadow.makeCallToCallback(newMethod));
if (! shadow.isFallsThrough()) {
- shadow.getRange().append(shadow.getFactory().createReturn(newMethod.getReturnType()));
+ shadow.getRange().append(InstructionFactory.createReturn(newMethod.getReturnType()));
}
}
};