use of io.nuls.contract.vm.code.VariableType in project nuls by nuls-io.
the class NativeClass method getName0.
/**
* native
*
* @see Class#getName0()
*/
private static Result getName0(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
ObjectRef objectRef = methodArgs.objectRef;
VariableType variableType;
if (objectRef.getVariableType().isArray()) {
variableType = objectRef.getVariableType();
} else {
variableType = VariableType.valueOf(objectRef.getRef());
}
String name;
if (variableType.isArray()) {
name = variableType.getDesc();
} else {
name = variableType.getType();
if (name.startsWith("L") && name.endsWith(";")) {
name = name.substring(1, name.length() - 1);
}
}
name = name.replace('/', '.');
ObjectRef ref = frame.heap.newString(name);
Result result = NativeMethod.result(methodCode, ref, frame);
return result;
}
use of io.nuls.contract.vm.code.VariableType in project nuls by nuls-io.
the class Instanceof method instanceof_.
public static void instanceof_(Frame frame) {
TypeInsnNode typeInsnNode = frame.typeInsnNode();
VariableType variableType = VariableType.valueOf(typeInsnNode.desc);
ObjectRef objectRef = frame.operandStack.popRef();
boolean result = instanceof_(objectRef, variableType, frame);
frame.operandStack.pushInt(result ? 1 : 0);
// Log.result(frame.getCurrentOpCode(), result, objectRef, variableType);
}
use of io.nuls.contract.vm.code.VariableType in project nuls by nuls-io.
the class Checkcast method checkcast.
public static void checkcast(Frame frame) {
TypeInsnNode typeInsnNode = frame.typeInsnNode();
String desc = typeInsnNode.desc;
VariableType variableType = VariableType.valueOf(desc);
ObjectRef objectRef = frame.operandStack.popRef();
if (objectRef == null || Instanceof.instanceof_(objectRef, variableType, frame)) {
frame.operandStack.pushRef(objectRef);
} else {
frame.throwClassCastException();
}
// Log.opcode(frame.getCurrentOpCode(), objectRef, desc);
}
use of io.nuls.contract.vm.code.VariableType in project nuls by nuls-io.
the class Multianewarray method multianewarray.
public static void multianewarray(final Frame frame) {
MultiANewArrayInsnNode multiANewArrayInsnNode = frame.multiANewArrayInsnNode();
int[] dimensions = new int[multiANewArrayInsnNode.dims];
for (int i = multiANewArrayInsnNode.dims - 1; i >= 0; i--) {
int length = frame.operandStack.popInt();
if (length < 0) {
frame.throwNegativeArraySizeException();
return;
}
dimensions[i] = length;
}
VariableType variableType = VariableType.valueOf(multiANewArrayInsnNode.desc);
ObjectRef arrayRef = frame.heap.newArray(variableType, dimensions);
frame.operandStack.pushRef(arrayRef);
// Log.result(frame.getCurrentOpCode(), arrayRef);
}
use of io.nuls.contract.vm.code.VariableType in project nuls by nuls-io.
the class Newarray method newarray.
public static void newarray(Frame frame) {
VariableType type;
int length = frame.operandStack.popInt();
if (length < 0) {
frame.throwNegativeArraySizeException();
return;
} else {
switch(frame.intInsnNode().operand) {
case Opcodes.T_BOOLEAN:
type = VariableType.BOOLEAN_ARRAY_TYPE;
break;
case Opcodes.T_CHAR:
type = VariableType.CHAR_ARRAY_TYPE;
break;
case Opcodes.T_FLOAT:
type = VariableType.FLOAT_ARRAY_TYPE;
break;
case Opcodes.T_DOUBLE:
type = VariableType.DOUBLE_ARRAY_TYPE;
break;
case Opcodes.T_BYTE:
type = VariableType.BYTE_ARRAY_TYPE;
break;
case Opcodes.T_SHORT:
type = VariableType.SHORT_ARRAY_TYPE;
break;
case Opcodes.T_INT:
type = VariableType.INT_ARRAY_TYPE;
break;
case Opcodes.T_LONG:
type = VariableType.LONG_ARRAY_TYPE;
break;
default:
throw new IllegalArgumentException("unknown operand");
}
}
ObjectRef arrayRef = frame.heap.newArray(type, length);
frame.operandStack.pushRef(arrayRef);
// Log.result(frame.getCurrentOpCode(), arrayRef);
}
Aggregations