本文整理了Java中org.objectweb.asm.Type.getSize()
方法的一些代码示例,展示了Type.getSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Type.getSize()
方法的具体详情如下:
包路径:org.objectweb.asm.Type
类名称:Type
方法名:getSize
[英]Returns the size of values of this type. This method must not be used for method types.
[中]返回此类型值的大小。此方法不能用于方法类型。
代码示例来源:origin: cglib/cglib
public static int getStackSize(Type[] types) {
int size = 0;
for (int i = 0; i < types.length; i++) {
size += types[i].getSize();
}
return size;
}
代码示例来源:origin: cglib/cglib
private int skipArgs(int numArgs) {
int amount = 0;
for (int i = 0; i < numArgs; i++) {
amount += state.argumentTypes[i].getSize();
}
return amount;
}
代码示例来源:origin: JCTools/JCTools
private int newLocal(Type type) {
final int myIndex = nextLocalIndex;
nextLocalIndex += type.getSize();
return myIndex;
}
代码示例来源:origin: cglib/cglib
public static int getStackSize(Type[] types) {
int size = 0;
for (int i = 0; i < types.length; i++) {
size += types[i].getSize();
}
return size;
}
代码示例来源:origin: cglib/cglib
private int skipArgs(int numArgs) {
int amount = 0;
for (int i = 0; i < numArgs; i++) {
amount += state.argumentTypes[i].getSize();
}
return amount;
}
代码示例来源:origin: konsoletyper/teavm
private int countSignatureVariables(String desc) {
int count = 1;
for (Type paramType : Type.getArgumentTypes(desc)) {
count += paramType.getSize();
}
return count;
}
代码示例来源:origin: JCTools/JCTools
private static int parameterTypeUnsafe(MethodVisitor methodVisitor, Class<?> parameterType, boolean write) {
parameterType = parameterType.isPrimitive() ? parameterType : Object.class;
Type type = Type.getType(parameterType);
String boolDescriptor = parameterType == boolean.class ? "Ljava/lang/Object;" : "";
methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
Type.getInternalName(Unsafe.class),
(write ? "put" : "get") + Character.toUpperCase(type.getClassName().charAt(0)) + type.getClassName().substring(1),
write ? ("(" + boolDescriptor + "J" + type.getDescriptor() + ")V") : ("(" + boolDescriptor + "J)" + type.getDescriptor()),
false);
return type.getSize();
}
代码示例来源:origin: cglib/cglib
public LocalVariablesSorter(
final int access,
final String desc,
final MethodVisitor mv)
{
super(Constants.ASM_API, mv);
state = new State();
Type[] args = Type.getArgumentTypes(desc);
state.nextLocal = ((Opcodes.ACC_STATIC & access) != 0) ? 0 : 1;
for (int i = 0; i < args.length; i++) {
state.nextLocal += args[i].getSize();
}
firstLocal = state.nextLocal;
}
代码示例来源:origin: cglib/cglib
public LocalVariablesSorter(
final int access,
final String desc,
final MethodVisitor mv)
{
super(Constants.ASM_API, mv);
state = new State();
Type[] args = Type.getArgumentTypes(desc);
state.nextLocal = ((Opcodes.ACC_STATIC & access) != 0) ? 0 : 1;
for (int i = 0; i < args.length; i++) {
state.nextLocal += args[i].getSize();
}
firstLocal = state.nextLocal;
}
代码示例来源:origin: scouter-project/scouter
public static int getIdxByType(int access, String desc, Type type) {
Type[] t = Type.getArgumentTypes(desc);
int sidx = (AsmUtil.isStatic(access) ? 0 : 1);
for (int i = 0; t != null && i < t.length; i++) {
if (type.equals(t[i])) {
return sidx;
}
sidx += t[i].getSize();
}
return -1;
}
代码示例来源:origin: cglib/cglib
public void load_args(int fromArg, int count) {
int pos = state.localOffset + skipArgs(fromArg);
for (int i = 0; i < count; i++) {
Type t = state.argumentTypes[fromArg + i];
load_local(t, pos);
pos += t.getSize();
}
}
代码示例来源:origin: cglib/cglib
public Local make_local(Type type) {
return new Local(newLocal(type.getSize()), type);
}
代码示例来源:origin: cglib/cglib
public void load_args(int fromArg, int count) {
int pos = state.localOffset + skipArgs(fromArg);
for (int i = 0; i < count; i++) {
Type t = state.argumentTypes[fromArg + i];
load_local(t, pos);
pos += t.getSize();
}
}
代码示例来源:origin: cglib/cglib
public Local make_local(Type type) {
return new Local(newLocal(type.getSize()), type);
}
代码示例来源:origin: scouter-project/scouter
@Override
public void visitCode() {
AsmUtil.PUSH(mv, methodName);
boolean flag = false;
int sidx = isStatic ? 0 : 1;
for (int i = 0; i < paramTypes.length; i++) {
Type tp = paramTypes[i];
if ("java/lang/String".equals(tp.getInternalName())) {
mv.visitVarInsn(Opcodes.ALOAD, sidx);
flag = true;
break;
}
sidx += tp.getSize();
}
if (flag == false) {
AsmUtil.PUSH(mv, "");
}
mv.visitMethodInsn(Opcodes.INVOKESTATIC, CLASS, METHOD, SIGNATURE, false);
super.visitCode();
}
}
代码示例来源:origin: cglib/cglib
public void swap(Type prev, Type type) {
if (type.getSize() == 1) {
if (prev.getSize() == 1) {
swap(); // same as dup_x1(), pop();
} else {
dup_x2();
pop();
}
} else {
if (prev.getSize() == 1) {
dup2_x1();
pop2();
} else {
dup2_x2();
pop2();
}
}
}
代码示例来源:origin: cglib/cglib
public void swap(Type prev, Type type) {
if (type.getSize() == 1) {
if (prev.getSize() == 1) {
swap(); // same as dup_x1(), pop();
} else {
dup_x2();
pop();
}
} else {
if (prev.getSize() == 1) {
dup2_x1();
pop2();
} else {
dup2_x2();
pop2();
}
}
}
代码示例来源:origin: robolectric/robolectric
static void box(final Type type, ListIterator<AbstractInsnNode> instructions) {
if (type.getSort() == OBJECT || type.getSort() == ARRAY) {
return;
}
if (Type.VOID_TYPE.equals(type)) {
instructions.add(new InsnNode(Opcodes.ACONST_NULL));
} else {
Type boxed = getBoxedType(type);
instructions.add(new TypeInsnNode(Opcodes.NEW, boxed.getInternalName()));
if (type.getSize() == 2) {
// Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
instructions.add(new InsnNode(Opcodes.DUP_X2));
instructions.add(new InsnNode(Opcodes.DUP_X2));
instructions.add(new InsnNode(Opcodes.POP));
} else {
// p -> po -> opo -> oop -> o
instructions.add(new InsnNode(Opcodes.DUP_X1));
instructions.add(new InsnNode(Opcodes.SWAP));
}
instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, boxed.getInternalName(),
"<init>", "(" + type.getDescriptor() + ")V", false));
}
}
代码示例来源:origin: pxb1988/dex2jar
return null;
} else {
return b(Type.getReturnType(mi.desc).getSize(), v);
代码示例来源:origin: cglib/cglib
/**
* If the argument is a primitive class, replaces the primitive value
* on the top of the stack with the wrapped (Object) equivalent. For
* example, char -> Character.
* If the class is Void, a null is pushed onto the stack instead.
* @param type the class indicating the current type of the top stack value
*/
public void box(Type type) {
if (TypeUtils.isPrimitive(type)) {
if (type == Type.VOID_TYPE) {
aconst_null();
} else {
Type boxed = TypeUtils.getBoxedType(type);
new_instance(boxed);
if (type.getSize() == 2) {
// Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
dup_x2();
dup_x2();
pop();
} else {
// p -> po -> opo -> oop -> o
dup_x1();
swap();
}
invoke_constructor(boxed, new Signature(Constants.CONSTRUCTOR_NAME, Type.VOID_TYPE, new Type[]{ type }));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!