use of org.powermock.api.mockito.repackaged.asm.Label in project powermock by powermock.
the class CodeEmitter method mark.
Label mark() {
Label label = make_label();
mv.visitLabel(label);
return label;
}
use of org.powermock.api.mockito.repackaged.asm.Label in project powermock by powermock.
the class CodeEmitter method unbox_or_zero.
/**
* Unboxes the object on the top of the stack. If the object is null, the
* unboxed primitive value becomes zero.
*/
public void unbox_or_zero(Type type) {
if (TypeUtils.isPrimitive(type)) {
if (type != Type.VOID_TYPE) {
Label nonNull = make_label();
Label end = make_label();
dup();
ifnonnull(nonNull);
pop();
zero_or_null(type);
goTo(end);
mark(nonNull);
unbox(type);
mark(end);
}
} else {
checkcast(type);
}
}
use of org.powermock.api.mockito.repackaged.asm.Label in project powermock by powermock.
the class FieldProviderTransformer method getField.
// TODO: if this is used to enhance class files SWITCH_STYLE_TRIE should be used
// to avoid JVM hashcode implementation incompatibilities
private void getField(String[] names) throws Exception {
final CodeEmitter e = begin_method(Constants.ACC_PUBLIC, PROVIDER_GET, null);
e.load_this();
e.load_arg(0);
EmitUtils.string_switch(e, names, Constants.SWITCH_STYLE_HASH, new ObjectSwitchCallback() {
public void processCase(Object key, Label end) {
Type type = (Type) fields.get(key);
e.getfield((String) key);
e.box(type);
e.return_value();
}
public void processDefault() {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field name");
}
});
e.end_method();
}
use of org.powermock.api.mockito.repackaged.asm.Label in project powermock by powermock.
the class FieldProviderTransformer method setByIndex.
private void setByIndex(final String[] names, final int[] indexes) throws Exception {
final CodeEmitter e = super.begin_method(Constants.ACC_PUBLIC, PROVIDER_SET_BY_INDEX, null);
e.load_this();
e.load_arg(1);
e.load_arg(0);
e.process_switch(indexes, new ProcessSwitchCallback() {
public void processCase(int key, Label end) throws Exception {
Type type = (Type) fields.get(names[key]);
e.unbox(type);
e.putfield(names[key]);
e.return_value();
}
public void processDefault() throws Exception {
e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Unknown field index");
}
});
e.end_method();
}
use of org.powermock.api.mockito.repackaged.asm.Label in project powermock by powermock.
the class InterceptFieldTransformer method addWriteMethod.
private void addWriteMethod(String name, Type type) {
CodeEmitter e = super.begin_method(Constants.ACC_PUBLIC, writeMethodSig(name, type.getDescriptor()), null);
e.load_this();
e.dup();
e.invoke_interface(ENABLED, ENABLED_GET);
Label skip = e.make_label();
e.ifnull(skip);
e.load_this();
e.invoke_interface(ENABLED, ENABLED_GET);
e.load_this();
e.push(name);
e.load_this();
e.getfield(name);
e.load_arg(0);
e.invoke_interface(CALLBACK, writeCallbackSig(type));
if (!TypeUtils.isPrimitive(type)) {
e.checkcast(type);
}
Label go = e.make_label();
e.goTo(go);
e.mark(skip);
e.load_arg(0);
e.mark(go);
e.putfield(name);
e.return_value();
e.end_method();
}
Aggregations