本文整理匯總了Java中org.objectweb.asm.Type.getMethodType方法的典型用法代碼示例。如果您正苦於以下問題:Java Type.getMethodType方法的具體用法?Java Type.getMethodType怎麽用?Java Type.getMethodType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.objectweb.asm.Type
的用法示例。
在下文中一共展示了Type.getMethodType方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: mapType
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type mapType(Type t) {
switch (t.getSort()) {
case Type.ARRAY:
String s = mapDesc(t.getElementType().getDescriptor());
for (int i = 0; i < t.getDimensions(); ++i) {
s = '[' + s;
}
return Type.getType(s);
case Type.OBJECT:
s = map(t.getInternalName());
return s != null ? Type.getObjectType(s) : t;
case Type.METHOD:
return Type.getMethodType(mapMethodDesc(t.getDescriptor()));
}
return t;
}
示例2: getMethodText
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private String getMethodText(MethodNode node) {
Type typeMethod = Type.getMethodType(node.desc);
// Args string
String args = "";
for (Type t : typeMethod.getArgumentTypes()) {
args += getTypeStr(t, options) + ", ";
}
if (args.endsWith(", ")) {
args = args.substring(0, args.length() - 2);
}
String s = italic(color(getTheme().memberReturnType, getTypeStr(typeMethod.getReturnType(), options))) + " ";
s += color(getTheme().memberName, escape(node.name)) + "(";
s += color(getTheme().memberParameterType, args);
s += ")";
return s;
}
示例3: visitMethod
import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if (importAborted()) {
return super.visitMethod(access, name, desc, signature, exceptions);
}
LOG.debug("Analysing method {}.{}:{}", className, name, desc);
accessHandler.setContext(new CodeUnit(name, namesOf(Type.getArgumentTypes(desc)), className));
DomainBuilders.JavaCodeUnitBuilder<?, ?> codeUnitBuilder = addCodeUnitBuilder(name);
Type methodType = Type.getMethodType(desc);
codeUnitBuilder
.withName(name)
.withModifiers(JavaModifier.getModifiersForMethod(access))
.withParameters(typesFrom(methodType.getArgumentTypes()))
.withReturnType(JavaTypeImporter.importAsmType(methodType.getReturnType()))
.withDescriptor(desc);
return new MethodProcessor(className, accessHandler, codeUnitBuilder);
}
示例4: getMethodDescriptorFQNMap
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public static Map<String, String> getMethodDescriptorFQNMap(String descriptor) {
Type type = Type.getMethodType(descriptor);
Set<String> classes = new HashSet<String>();
classes.add(type.getReturnType().getClassName());
Type[] arguments = type.getArgumentTypes();
if (arguments != null) {
for (Type arg : arguments) {
classes.add(arg.getClassName());
}
}
return fqnToMap(classes);
}
示例5: write
import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
void write(MethodWriter writer, Globals globals) {
writer.writeDebugInfo(location);
List<Type> parameterTypes = new ArrayList<>();
// first parameter is the receiver, we never know its type: always Object
parameterTypes.add(Definition.DEF_TYPE.type);
// append each argument
for (AExpression argument : arguments) {
parameterTypes.add(argument.actual.type);
if (argument instanceof ILambda) {
ILambda lambda = (ILambda) argument;
for (Type capture : lambda.getCaptures()) {
parameterTypes.add(capture);
}
}
argument.write(writer, globals);
}
// create method type from return value and arguments
Type methodType = Type.getMethodType(actual.type, parameterTypes.toArray(new Type[0]));
List<Object> args = new ArrayList<>();
args.add(recipe.toString());
args.addAll(pointers);
writer.invokeDefCall(name, methodType, DefBootstrap.METHOD_CALL, args.toArray());
}
示例6: write
import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
void write(MethodWriter writer, Globals globals) {
if (ref != null) {
writer.writeDebugInfo(location);
// convert MethodTypes to asm Type for the constant pool.
String invokedType = ref.invokedType.toMethodDescriptorString();
Type samMethodType = Type.getMethodType(ref.samMethodType.toMethodDescriptorString());
Type interfaceType = Type.getMethodType(ref.interfaceMethodType.toMethodDescriptorString());
if (ref.needsBridges()) {
writer.invokeDynamic(ref.invokedName,
invokedType,
LAMBDA_BOOTSTRAP_HANDLE,
samMethodType,
ref.implMethodASM,
samMethodType,
LambdaMetafactory.FLAG_BRIDGES,
1,
interfaceType);
} else {
writer.invokeDynamic(ref.invokedName,
invokedType,
LAMBDA_BOOTSTRAP_HANDLE,
samMethodType,
ref.implMethodASM,
samMethodType,
0);
}
} else {
// TODO: don't do this: its just to cutover :)
writer.push((String)null);
}
}
示例7: getMethodType
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public Type getMethodType() {
Type[] ts = new Type[args.length];
for (int i = 0; i < args.length; i++) {
ts[i] = Type.getType(args[i]);
}
return Type.getMethodType(
Type.getType(returnType),
ts);
}
示例8: snapshotMethodType
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type snapshotMethodType() {
ArrayList<Type> args = new ArrayList<>();
args.add(Type.INT_TYPE);
if (context.isVararg()) {
args.add(ASMUtils.arrayTypeFor(Object.class));
}
for (int i = 0; i < numOfRegisters(); i++) {
args.add(Type.getType(Object.class));
}
return Type.getMethodType(context.savedStateClassType(), args.toArray(new Type[0]));
}
示例9: methodType
import org.objectweb.asm.Type; //導入方法依賴的package包/類
private Type methodType(Type returnType) {
ArrayList<Type> args = new ArrayList<>();
args.add(Type.getType(ExecutionContext.class));
args.add(Type.INT_TYPE);
if (context.isVararg()) {
args.add(ASMUtils.arrayTypeFor(Object.class));
}
for (int i = 0; i < numOfRegisters(); i++) {
args.add(Type.getType(Object.class));
}
return Type.getMethodType(returnType, args.toArray(new Type[0]));
}
示例10: insertDefaultSectionStart
import org.objectweb.asm.Type; //導入方法依賴的package包/類
protected void insertDefaultSectionStart(String key, boolean inverted) throws CompilerException {
if(!builderLoaded && needLocal) {
mv.visitVarInsn(ALOAD, varBuilder);
builderLoaded = true;
}
if(data.getDataType() != DATA) {
throw new CompilerException("The default section generator can't be used within a custom data type");
}
String methodName = "lambda$render$" + compiler.getNextLambdaId();
mv.visitVarInsn(ALOAD, varData);
mv.visitLdcInsn(key);
Type methodType = Type.getMethodType(STRING, DATA);
Handle lambda = new Handle(H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", "metafactory",
"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;"
+ "Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;", false);
Handle method = new Handle(H_INVOKESTATIC, className, methodName, methodType.getDescriptor(), false);
mv.visitInvokeDynamicInsn("render", Type.getMethodDescriptor(SIMPLE_TEMPLATE), lambda, methodType, method, methodType);
mv.visitInsn(inverted ? ICONST_1 : ICONST_0);
mv.visitMethodInsn(INVOKESTATIC, UTILS.getInternalName(), "renderSection", "(" + BUILDER.getDescriptor() +
DATA.getDescriptor() + STRING.getDescriptor() + SIMPLE_TEMPLATE.getDescriptor() +"Z)" + BUILDER.getDescriptor(), false);
BytecodeGenerator gen = new BytecodeGenerator(compiler, this, key, cw, data, className, classDesc);
compiler.setGenerator(gen);
gen.insertMethodStart(methodName);
}
示例11: write
import org.objectweb.asm.Type; //導入方法依賴的package包/類
@Override
void write(MethodWriter writer, Globals globals) {
writer.writeDebugInfo(location);
if (defPointer != null) {
// dynamic interface: push captured parameter on stack
// TODO: don't do this: its just to cutover :)
writer.push((String)null);
writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.getSlot());
} else if (ref == null) {
// typed interface, dynamic implementation
writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.getSlot());
Type methodType = Type.getMethodType(expected.type, captured.type.type);
writer.invokeDefCall(call, methodType, DefBootstrap.REFERENCE, expected.name);
} else {
// typed interface, typed implementation
writer.visitVarInsn(captured.type.type.getOpcode(Opcodes.ILOAD), captured.getSlot());
// convert MethodTypes to asm Type for the constant pool.
String invokedType = ref.invokedType.toMethodDescriptorString();
Type samMethodType = Type.getMethodType(ref.samMethodType.toMethodDescriptorString());
Type interfaceType = Type.getMethodType(ref.interfaceMethodType.toMethodDescriptorString());
if (ref.needsBridges()) {
writer.invokeDynamic(ref.invokedName,
invokedType,
LAMBDA_BOOTSTRAP_HANDLE,
samMethodType,
ref.implMethodASM,
samMethodType,
LambdaMetafactory.FLAG_BRIDGES,
1,
interfaceType);
} else {
writer.invokeDynamic(ref.invokedName,
invokedType,
LAMBDA_BOOTSTRAP_HANDLE,
samMethodType,
ref.implMethodASM,
samMethodType,
0);
}
}
}
示例12: methodType
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public Type methodType() {
Type[] args = new Type[context.fn.upvals().size()];
Arrays.fill(args, Type.getType(Variable.class));
return Type.getMethodType(Type.VOID_TYPE, args);
}
示例13: translateMethodType
import org.objectweb.asm.Type; //導入方法依賴的package包/類
public Type translateMethodType(Type methodType) {
Type[] translated = translateTypes(mcClasses, Lists.asList(methodType.getReturnType(), methodType.getArgumentTypes()).toArray(new Type[] {}));
return Type.getMethodType(translated[0], Arrays.copyOfRange(translated, 1, translated.length));
}