本文整理汇总了Java中org.objectweb.asm.tree.MultiANewArrayInsnNode类的典型用法代码示例。如果您正苦于以下问题:Java MultiANewArrayInsnNode类的具体用法?Java MultiANewArrayInsnNode怎么用?Java MultiANewArrayInsnNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MultiANewArrayInsnNode类属于org.objectweb.asm.tree包,在下文中一共展示了MultiANewArrayInsnNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformMultiANewArrayInsnNode
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
@Override
protected AbstractInsnNode transformMultiANewArrayInsnNode(MethodNode mn,
MultiANewArrayInsnNode arrayInsnNode) {
String new_desc = "";
Type t = Type.getType(arrayInsnNode.desc);
while (t.getSort() == Type.ARRAY) {
new_desc += "[";
t = t.getElementType();
}
if (t.equals(Type.BOOLEAN_TYPE))
new_desc += "I";
else
new_desc += t.getDescriptor();
arrayInsnNode.desc = new_desc;
return arrayInsnNode;
}
示例2: addArray
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
/**
* Adds the array to the last created method.
*
* @param desc
* the desc
* @param length
* the length
* @return the class node builder
*/
public ClassNodeBuilder addArray(final String desc, final int... length) {
if (isInterface) {
return this;
}
final Type elementType = Type.getType(desc).getElementType();
if (length.length == 1) {
addInsn(NodeHelper.getInsnNodeFor(Integer.valueOf(length[0])));
if (elementType.getDescriptor().startsWith("L")) {
addInsn(new TypeInsnNode(Opcodes.ANEWARRAY, elementType.getInternalName()));
} else {
addInsn(new IntInsnNode(Opcodes.NEWARRAY, getSort(elementType)));
}
} else {
for (final int currentLength : length) {
addInsn(NodeHelper.getInsnNodeFor(Integer.valueOf(currentLength)));
}
addInsn(new MultiANewArrayInsnNode(desc, length.length));
}
addInsn(new VarInsnNode(Opcodes.ASTORE, methodVarIndex));
lastMethodVarIndex = methodVarIndex;
lastVarElementType = elementType;
methodVarIndex++;
return this;
}
示例3: naryOperation
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
@Override
public BasicValue naryOperation(final AbstractInsnNode insn,
final List<? extends BasicValue> values) throws AnalyzerException {
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
} else if (opcode == INVOKEDYNAMIC) {
return newValue(Type
.getReturnType(((InvokeDynamicInsnNode) insn).desc));
} else {
return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
}
}
示例4: build
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
private void build(MultiANewArrayInsnNode insn, IRBuilder builder) {
// Type of the full array.
Type arrayType = Type.getObjectType(insn.desc);
DexType dexArrayType = application.getType(arrayType);
// Type of the members. Can itself be of array type, eg, 'int[]' for 'new int[x][y][]'
DexType memberType = application.getTypeFromDescriptor(insn.desc.substring(insn.dims));
// Push an array containing the dimensions of the desired multi-dimensional array.
DexType dimArrayType = application.getTypeFromDescriptor(INT_ARRAY_DESC);
Slot[] slots = state.popReverse(insn.dims, Type.INT_TYPE);
int[] dimensions = new int[insn.dims];
for (int i = 0; i < insn.dims; i++) {
dimensions[i] = slots[i].register;
}
builder.addInvokeNewArray(dimArrayType, insn.dims, dimensions);
int dimensionsDestTemp = state.push(INT_ARRAY_TYPE);
builder.addMoveResult(MoveType.OBJECT, dimensionsDestTemp);
// Push the class object for the member type of the array.
int classDestTemp = state.push(CLASS_TYPE);
builder.ensureBlockForThrowingInstruction();
builder.addConstClass(classDestTemp, memberType);
// Create the actual multi-dimensional array using java.lang.reflect.Array::newInstance
DexType reflectArrayClass = application.getTypeFromDescriptor(REFLECT_ARRAY_DESC);
DexMethod newInstance = application.getMethod(reflectArrayClass,
REFLECT_ARRAY_NEW_INSTANCE_NAME, REFLECT_ARRAY_NEW_INSTANCE_DESC);
List<MoveType> argumentTypes = Arrays.asList(moveType(CLASS_TYPE), moveType(INT_ARRAY_TYPE));
List<Integer> argumentRegisters = Arrays.asList(classDestTemp, dimensionsDestTemp);
builder.ensureBlockForThrowingInstruction();
builder.addInvoke(Invoke.Type.STATIC, newInstance, null, argumentTypes, argumentRegisters);
// Pop the temporaries and push the final result.
state.pop(); // classDestTemp.
state.pop(); // dimensionsDestTemp.
int result = state.push(arrayType);
builder.addMoveResult(moveType(arrayType), result);
// Insert cast check to satisfy verification.
builder.ensureBlockForThrowingInstruction();
builder.addCheckCast(result, dexArrayType);
}
示例5: naryOperation
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
public Value naryOperation(final AbstractInsnNode insn, final List values)
throws AnalyzerException
{
if (insn.getOpcode() == MULTIANEWARRAY) {
return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
} else {
return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
}
}
示例6: handle
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
@Override
public void handle(AbstractInsnNode node) throws IncorrectNodeException {
super.handle(node);
LOG.debug(logNode(node));
checkType(node, MultiANewArrayInsnNode.class);
String desc = ((MultiANewArrayInsnNode)node).desc;
int dims = ((MultiANewArrayInsnNode)node).dims;
mState.getActiveStack().push(new ArrayCreationExpression(node.getOpcode(), desc, dims));
}
示例7: naryOperation
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
@Override
public BasicValue naryOperation(final AbstractInsnNode insn,
final List<? extends BasicValue> values) throws AnalyzerException {
int opcode = insn.opcode();
if (opcode == MULTIANEWARRAY) {
return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
} else if (opcode == INVOKEDYNAMIC) {
return newValue(Type
.getReturnType(((InvokeDynamicInsnNode) insn).desc));
} else {
return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
}
}
示例8: interpret
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
private void interpret(MultiANewArrayInsnNode insn, FrameState frame, BBInfo block) {
assert insn.getOpcode() == Opcodes.MULTIANEWARRAY;
Klass k = getKlassByInternalName(insn.desc);
Value[] dims = new Value[insn.dims];
for (int i = dims.length-1; i >= 0; --i)
dims[i] = frame.stack.pop();
NewArrayInst nai = new NewArrayInst(typeFactory.getArrayType(k), dims);
block.block.instructions().add(nai);
frame.stack.push(nai);
}
示例9: emit
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
private void emit(NewArrayInst i, InsnList insns) {
ArrayType t = i.getType();
if (t.getDimensions() == 1) {
load(i.getOperand(0), insns);
RegularType ct = t.getComponentType();
if (ct instanceof PrimitiveType) {
if (ct.equals(booleanType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_BOOLEAN));
else if (ct.equals(byteType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_BYTE));
else if (ct.equals(charType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_CHAR));
else if (ct.equals(shortType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_SHORT));
else if (ct.equals(intType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_INT));
else if (ct.equals(longType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_LONG));
else if (ct.equals(floatType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_FLOAT));
else if (ct.equals(doubleType))
insns.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_DOUBLE));
} else {
insns.add(new TypeInsnNode(Opcodes.ANEWARRAY, internalName(ct.getKlass())));
}
} else {
for (Value v : i.operands())
load(v, insns);
insns.add(new MultiANewArrayInsnNode(t.getDescriptor(), i.getNumOperands()));
}
store(i, insns);
}
示例10: naryOperation
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
@Override
public BasicValue naryOperation(final AbstractInsnNode insn, final List<? extends BasicValue> values)
throws AnalyzerException
{
int opcode = insn.getOpcode();
if (opcode == MULTIANEWARRAY) {
return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
} else if (opcode == INVOKEDYNAMIC){
return newValue(Type.getReturnType(((InvokeDynamicInsnNode) insn).desc));
} else {
return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
}
}
示例11: registerAdditionalValues
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
/**
* Registers values for local arrays that are created via NEWARRAY / ANEWARRAY or MULTIANEWARRAY.
*
* @param currentNode
* the current node
* @param knownArrays
* the known arrays
* @return true, if successful
*/
@Override
protected int registerAdditionalValues(final AbstractInsnNode currentNode, //
final Map<Integer, Object> knownArrays) {
final int opcode = currentNode.getOpcode();
if (!((opcode == Opcodes.NEWARRAY) || (opcode == Opcodes.ANEWARRAY) || (opcode == Opcodes.MULTIANEWARRAY))) {
return 0;
}
int dims = 1;
if (currentNode.getOpcode() == Opcodes.MULTIANEWARRAY) {
final MultiANewArrayInsnNode node = (MultiANewArrayInsnNode) currentNode;
dims = node.dims;
}
final int sizes[] = new int[dims];
AbstractInsnNode previous = currentNode;
for (int i = 0; i < dims; ++i) {
previous = NodeHelper.getPrevious(previous);
if (!NodeHelper.isIntNode(previous)) {
return 0;
}
try {
final int value = NodeHelper.getNumberValue(previous).intValue();
sizes[i] = value;
} catch (final NotANumberException nane) {
return 0;
}
}
final AbstractInsnNode next = NodeHelper.getNext(currentNode);
if (!(next instanceof VarInsnNode)) {
return 0;
}
final int index = ((VarInsnNode) next).var;
knownArrays.put(Integer.valueOf(index), Array.newInstance(Object.class, sizes));
return 2;
}
示例12: updateState
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
private void updateState(AbstractInsnNode insn) {
switch (insn.getType()) {
case AbstractInsnNode.INSN:
updateState((InsnNode) insn);
break;
case AbstractInsnNode.INT_INSN:
updateState((IntInsnNode) insn);
break;
case AbstractInsnNode.VAR_INSN:
updateState((VarInsnNode) insn);
break;
case AbstractInsnNode.TYPE_INSN:
updateState((TypeInsnNode) insn);
break;
case AbstractInsnNode.FIELD_INSN:
updateState((FieldInsnNode) insn);
break;
case AbstractInsnNode.METHOD_INSN:
updateState((MethodInsnNode) insn);
break;
case AbstractInsnNode.INVOKE_DYNAMIC_INSN:
updateState((InvokeDynamicInsnNode) insn);
break;
case AbstractInsnNode.JUMP_INSN:
updateState((JumpInsnNode) insn);
break;
case AbstractInsnNode.LABEL:
updateState((LabelNode) insn);
break;
case AbstractInsnNode.LDC_INSN:
updateState((LdcInsnNode) insn);
break;
case AbstractInsnNode.IINC_INSN:
updateState((IincInsnNode) insn);
break;
case AbstractInsnNode.TABLESWITCH_INSN:
updateState((TableSwitchInsnNode) insn);
break;
case AbstractInsnNode.LOOKUPSWITCH_INSN:
updateState((LookupSwitchInsnNode) insn);
break;
case AbstractInsnNode.MULTIANEWARRAY_INSN:
updateState((MultiANewArrayInsnNode) insn);
break;
case AbstractInsnNode.LINE:
updateState((LineNumberNode) insn);
break;
default:
throw new Unreachable("Unexpected instruction " + insn);
}
}
示例13: AsmMultiANewArrayInsnReference
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
AsmMultiANewArrayInsnReference(AsmItem source, MultiANewArrayInsnNode insn, boolean isStrong) {
super(source, REF_FULL, isStrong);
this.insn = insn;
}
示例14: visitMultiANewArrayInsn
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
@Override
public final void visitMultiANewArrayInsn(String desc, int dims) {
MultiANewArrayInsnNode node = new MultiANewArrayInsnNode(desc, dims);
instructions.add(node);
addFrame(node);
}
示例15: transform
import org.objectweb.asm.tree.MultiANewArrayInsnNode; //导入依赖的package包/类
/**
* <p>transform</p>
*
* @param mn a {@link org.objectweb.asm.tree.MethodNode} object.
*/
public void transform(MethodNode mn) {
setupLocals(mn);
Set<AbstractInsnNode> originalNodes = new HashSet<AbstractInsnNode>();
AbstractInsnNode node = mn.instructions.getFirst();
while (node != mn.instructions.getLast()) {
originalNodes.add(node);
node = node.getNext();
}
//int currentIndex = 0;
node = mn.instructions.getFirst();
//while (currentIndex < mn.instructions.size()) {
boolean finished = false;
while (!finished) {
//while (node != mn.instructions.getLast()) {
//node = mn.instructions.get(currentIndex);
//int oldLength = mn.instructions.size();
// BytecodeInstruction insn = BytecodeInstructionPool.getInstruction(className,
// mn.name
// + mn.desc,
// node);
// if (insn == null) {
// // if (!originalNodes.contains(node)) {
// System.out.println("Node not present in original stuff " + node);
// // Only transform nodes present in original method
// } else
if (node instanceof MethodInsnNode) {
node = transformMethodInsnNode(mn, (MethodInsnNode) node);
} else if (node instanceof VarInsnNode) {
node = transformVarInsnNode(mn, (VarInsnNode) node);
} else if (node instanceof FieldInsnNode) {
node = transformFieldInsnNode(mn, (FieldInsnNode) node);
} else if (node instanceof InsnNode) {
node = transformInsnNode(mn, (InsnNode) node);
} else if (node instanceof TypeInsnNode) {
node = transformTypeInsnNode(mn, (TypeInsnNode) node);
} else if (node instanceof JumpInsnNode) {
node = transformJumpInsnNode(mn, (JumpInsnNode) node);
} else if (node instanceof LabelNode) {
node = transformLabelNode(mn, (LabelNode) node);
} else if (node instanceof IntInsnNode) {
node = transformIntInsnNode(mn, (IntInsnNode) node);
} else if (node instanceof MultiANewArrayInsnNode) {
node = transformMultiANewArrayInsnNode(mn, (MultiANewArrayInsnNode) node);
}
//currentIndex += mn.instructions.size() - oldLength;
//currentIndex++;
if (node == mn.instructions.getLast()) {
finished = true;
} else {
node = node.getNext();
}
}
}