本文整理汇总了Java中net.bytebuddy.implementation.bytecode.StackManipulation.Compound方法的典型用法代码示例。如果您正苦于以下问题:Java StackManipulation.Compound方法的具体用法?Java StackManipulation.Compound怎么用?Java StackManipulation.Compound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.bytebuddy.implementation.bytecode.StackManipulation
的用法示例。
在下文中一共展示了StackManipulation.Compound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SmtCombinedTest
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
public SmtCombinedTest() {
super(
new TestCase(
"combines two StackManipulation tokens into one",
new AssertTokenToRepresentExpectedStackManipulation(
new SmtCombined(
new SmtLoadReference(5),
new SmtLoadReference(6)
),
() -> new StackManipulation.Compound(
MethodVariableAccess.REFERENCE.loadFrom(5),
MethodVariableAccess.REFERENCE.loadFrom(6)
)
)
)
);
}
示例2: beforeDelegation
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
protected StackManipulation beforeDelegation(MethodDescription instrumentedMethod) {
// Parameters of the wrapper invoker method:
// DoFnInvoker.ArgumentProvider
// Parameters of the wrapped DoFn method:
// [DoFn.ProcessContext, BoundedWindow, InputProvider, OutputReceiver] in any order
ArrayList<StackManipulation> pushParameters = new ArrayList<>();
// To load the delegate, push `this` and then access the field
StackManipulation pushDelegate =
new StackManipulation.Compound(
MethodVariableAccess.REFERENCE.loadFrom(0),
FieldAccess.forField(delegateField).read());
StackManipulation pushExtraContextFactory = MethodVariableAccess.REFERENCE.loadFrom(1);
// Push the arguments in their actual order.
for (DoFnSignature.Parameter param : signature.extraParameters()) {
pushParameters.add(
new StackManipulation.Compound(
pushExtraContextFactory, getExtraContextParameter(param, pushDelegate)));
}
return new StackManipulation.Compound(pushParameters);
}
示例3: beforeDelegation
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
protected StackManipulation beforeDelegation(MethodDescription instrumentedMethod) {
// Parameters of the wrapper invoker method:
// DoFn.ArgumentProvider
// Parameters of the wrapped DoFn method:
// a dynamic set of allowed "extra" parameters in any order subject to
// validation prior to getting the DoFnSignature
ArrayList<StackManipulation> parameters = new ArrayList<>();
// To load the delegate, push `this` and then access the field
StackManipulation pushDelegate =
new StackManipulation.Compound(
MethodVariableAccess.REFERENCE.loadFrom(0),
FieldAccess.forField(delegateField).read());
StackManipulation pushExtraContextFactory = MethodVariableAccess.REFERENCE.loadFrom(1);
// Push the extra arguments in their actual order.
for (DoFnSignature.Parameter param : signature.extraParameters()) {
parameters.add(
new StackManipulation.Compound(
pushExtraContextFactory,
ByteBuddyDoFnInvokerFactory.getExtraContextParameter(param, pushDelegate)));
}
return new StackManipulation.Compound(parameters);
}
示例4: apply
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Context implementationContext, MethodDescription instrumentedMethod) {
FieldList<?> fieldList = instrumentedType.getDeclaredFields();
StackManipulation[] fieldLoading = new StackManipulation[fieldList.size()];
int index = 0;
for (FieldDescription fieldDescription : fieldList) {
fieldLoading[index] = new StackManipulation.Compound(
MethodVariableAccess.loadThis(),
MethodVariableAccess.load(instrumentedMethod.getParameters().get(index)),
FieldAccess.forField(fieldDescription).write()
);
index++;
}
StackManipulation.Size stackSize = new StackManipulation.Compound(
MethodVariableAccess.loadThis(),
MethodInvocation.invoke(ConstructorCall.INSTANCE.objectTypeDefaultConstructor),
new StackManipulation.Compound(fieldLoading),
MethodReturn.VOID
).apply(methodVisitor, implementationContext);
return new Size(stackSize.getMaximalSize(), instrumentedMethod.getStackSize());
}
示例5: apply
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Context implementationContext, MethodDescription instrumentedMethod) {
if (instrumentedMethod.getParameters().size() <= index) {
throw new IllegalStateException(instrumentedMethod + " does not define a parameter with index " + index);
}
ParameterDescription parameterDescription = instrumentedMethod.getParameters().get(index);
StackManipulation stackManipulation = new StackManipulation.Compound(
MethodVariableAccess.load(parameterDescription),
assigner.assign(parameterDescription.getType(), instrumentedMethod.getReturnType(), typing),
MethodReturn.of(instrumentedMethod.getReturnType())
);
if (!stackManipulation.isValid()) {
throw new IllegalStateException("Cannot assign " + instrumentedMethod.getReturnType() + " to " + parameterDescription);
}
return new Size(stackManipulation.apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize());
}
示例6: apply
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) {
if (!instrumentedMethod.isMethod()) {
throw new IllegalArgumentException(instrumentedMethod + " does not describe a field getter or setter");
}
FieldDescription fieldDescription = fieldLocation.resolve(instrumentedMethod);
StackManipulation implementation;
if (!instrumentedMethod.getReturnType().represents(void.class)) {
implementation = new StackManipulation.Compound(getter(fieldDescription, instrumentedMethod), MethodReturn.of(instrumentedMethod.getReturnType()));
} else if (instrumentedMethod.getReturnType().represents(void.class) && instrumentedMethod.getParameters().size() == 1) {
implementation = new StackManipulation.Compound(setter(fieldDescription, instrumentedMethod.getParameters().get(0)), MethodReturn.VOID);
} else {
throw new IllegalArgumentException("Method " + implementationContext + " is no bean property");
}
return new Size(implementation.apply(methodVisitor, implementationContext).getMaximalSize(), instrumentedMethod.getStackSize());
}
示例7: unbox
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
private StackManipulation unbox(ProtoFieldInfo field) {
switch (field.valueJavaType()) {
case INT:
case ENUM:
return new StackManipulation.Compound(
TypeCasting.to(new ForLoadedType(Integer.class)), PrimitiveUnboxingDelegate.INTEGER);
case LONG:
return new StackManipulation.Compound(
TypeCasting.to(new ForLoadedType(Long.class)), PrimitiveUnboxingDelegate.LONG);
case BOOLEAN:
return new StackManipulation.Compound(
TypeCasting.to(new ForLoadedType(Boolean.class)), PrimitiveUnboxingDelegate.BOOLEAN);
case FLOAT:
return new StackManipulation.Compound(
TypeCasting.to(new ForLoadedType(Float.class)), PrimitiveUnboxingDelegate.FLOAT);
case DOUBLE:
return new StackManipulation.Compound(
TypeCasting.to(new ForLoadedType(Double.class)), PrimitiveUnboxingDelegate.DOUBLE);
case STRING:
return TypeCasting.to(new ForLoadedType(String.class));
case BYTE_STRING:
return TypeCasting.to(new ForLoadedType(ByteString.class));
case MESSAGE:
return TypeCasting.to(new ForLoadedType(Message.class));
default:
throw new IllegalStateException("Unknown field type.");
}
}
示例8: checkPrimitiveDefault
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
private StackManipulation checkPrimitiveDefault(
StackManipulation getValue,
StackManipulation loadDefault,
Class<?> variableType,
Label afterPrint) {
return new StackManipulation.Compound(
getValue, loadDefault, new IfEqual(variableType, afterPrint));
}
示例9: setFieldValue
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
/**
* Returns the {@link StackManipulation} for setting the value of a field. This will be all the
* elements for a repeated field.
*
* @param info description of the field to set.
* @param beforeReadField jump target for before reading a field, used once this field is
* completed being set.
* @param locals the method local variables
* @param fieldsByName the instance fields
*/
private StackManipulation setFieldValue(
ProtoFieldInfo info,
Label beforeReadField,
LocalVariables<LocalVariable> locals,
Map<String, FieldDescription> fieldsByName) {
if (info.isMapField()) {
return setMapFieldValue(info, beforeReadField, locals, fieldsByName);
} else {
final StackManipulation setConcreteValue = invoke(info.setValueMethod());
final StackManipulation setSingleValue;
if (info.valueJavaType() == JavaType.MESSAGE) {
setSingleValue =
new StackManipulation.Compound(
TypeCasting.to(new ForLoadedType(info.javaClass())), setConcreteValue);
} else {
setSingleValue = setConcreteValue;
}
if (info.descriptor().isRepeated()) {
return setRepeatedFieldValue(info, beforeReadField, locals, fieldsByName, setSingleValue);
} else {
// Set a singular value, e.g.,
// builder.setFoo(readValue());
return new StackManipulation.Compound(
locals.load(LocalVariable.builder),
locals.load(LocalVariable.parser),
readValue(info, fieldsByName, locals),
setSingleValue,
Removal.SINGLE,
new Goto(beforeReadField));
}
}
}
示例10: setRepeatedFieldValue
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
/**
* Returns the {@link StackManipulation} for setting the value of a normal repeated field.
*
* <p>Roughly equivalent to:
*
* <pre>{@code
* ParseSupport.parseArrayStart(parser);
* while (!ParseSupport.checkArrayEnd(parser)) {
* builder.addFoo(readValue());
* }
* }</pre>
*/
private StackManipulation setRepeatedFieldValue(
ProtoFieldInfo info,
Label beforeReadField,
LocalVariables<LocalVariable> locals,
Map<String, FieldDescription> fieldsByName,
StackManipulation setSingleValue) {
Label arrayStart = new Label();
return new StackManipulation.Compound(
locals.load(LocalVariable.parser),
ParseSupport_parseArrayStart,
new SetJumpTargetLabel(arrayStart),
locals.load(LocalVariable.parser),
ParseSupport_throwIfRepeatedNull,
locals.load(LocalVariable.parser),
ParseSupport_checkArrayEnd,
new IfTrue(beforeReadField),
locals.load(LocalVariable.builder),
locals.load(LocalVariable.parser),
readValue(info, fieldsByName, locals),
setSingleValue,
Removal.SINGLE,
locals.load(LocalVariable.parser),
Parser_nextValue,
Removal.SINGLE,
new Goto(arrayStart));
}
示例11: setMapFieldValue
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
/**
* Returns the {@link StackManipulation} for setting the value of a map field.
*
* <p>Roughly equivalent to:
*
* <pre>{@code
* ParseSupport.parseObjectStart(parser);
* while (!ParseSupport.checkObjectEnd(parser.currentToken())) {
* builder.putFoo(readKey(), readValue());
* }
* }</pre>
*/
private StackManipulation setMapFieldValue(
ProtoFieldInfo info,
Label beforeReadField,
LocalVariables<LocalVariable> locals,
Map<String, FieldDescription> fieldsByName) {
final StackManipulation setConcreteValue = invoke(info.setValueMethod());
final StackManipulation setMapEntry;
if (info.valueJavaType() == JavaType.MESSAGE) {
setMapEntry =
new StackManipulation.Compound(
TypeCasting.to(new ForLoadedType(info.javaClass())), setConcreteValue);
} else {
setMapEntry = setConcreteValue;
}
Label mapStart = new Label();
return new StackManipulation.Compound(
locals.load(LocalVariable.parser),
ParseSupport_parseObjectStart,
new SetJumpTargetLabel(mapStart),
locals.load(LocalVariable.parser),
Parser_currentToken,
ParseSupport_checkObjectEnd,
new IfTrue(beforeReadField),
locals.load(LocalVariable.builder),
locals.load(LocalVariable.parser),
readValue(info.mapKeyField(), fieldsByName, locals),
locals.load(LocalVariable.parser),
Parser_nextToken,
Removal.SINGLE,
locals.load(LocalVariable.parser),
readValue(info, fieldsByName, locals),
setMapEntry,
Removal.SINGLE,
locals.load(LocalVariable.parser),
Parser_nextToken,
Removal.SINGLE,
new Goto(mapStart));
}
示例12: SmtInvokeObjectsHash
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
public SmtInvokeObjectsHash() {
super(
new StackManipulation.Compound(
MethodInvocation.invoke(new MethodDescription.ForLoadedMethod(OBJECTS_HASH)),
MethodReturn.INTEGER
)
);
}
示例13: result
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
public final Result<StackManipulation> result() {
return new RSuccess<>(
new StackManipulation.Compound(
IntegerConstant.forValue(index),
MethodReturn.INTEGER
)
);
}
示例14: SmtCombined
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
public SmtCombined(List<StackManipulationToken> subtasks) {
super(
((sm1, sm2) -> new StackManipulation.Compound(sm1, sm2)),
new StackManipulation.Compound(),
List.narrow(subtasks)
);
}
示例15: afterDelegation
import net.bytebuddy.implementation.bytecode.StackManipulation; //导入方法依赖的package包/类
@Override
protected StackManipulation afterDelegation(MethodDescription instrumentedMethod) {
if (TypeDescription.VOID.equals(targetMethod.getReturnType().asErasure())) {
return new StackManipulation.Compound(
MethodInvocation.invoke(PROCESS_CONTINUATION_STOP_METHOD), MethodReturn.REFERENCE);
} else {
return MethodReturn.of(targetMethod.getReturnType().asErasure());
}
}