use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class NativeClass method getGenericSignature0.
/**
* native
*
* @see Class#getGenericSignature0()
*/
private static Result getGenericSignature0(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());
}
ObjectRef ref = null;
if (!variableType.isPrimitiveType()) {
ClassCode classCode = frame.methodArea.loadClass(variableType.getType());
String signature = classCode.signature;
ref = frame.heap.newString(signature);
}
Result result = NativeMethod.result(methodCode, ref, frame);
return result;
}
use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class NativeClass method getComponentType.
/**
* native
*
* @see Class#getComponentType()
*/
private static Result getComponentType(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());
}
ObjectRef classRef = null;
if (variableType.isArray()) {
classRef = frame.heap.getClassRef(variableType.getComponentType().getDesc());
}
Result result = NativeMethod.result(methodCode, classRef, frame);
return result;
}
use of io.nuls.contract.vm.ObjectRef 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.ObjectRef in project nuls by nuls-io.
the class Athrow method athrow.
public static void athrow(final Frame frame) {
ObjectRef objectRef = frame.operandStack.popRef();
if (objectRef == null) {
frame.throwNullPointerException();
return;
}
// Log.opcode(frame.getCurrentOpCode(), objectRef);
while (frame.vm.isNotEmptyFrame()) {
final Frame lastFrame = frame.vm.lastFrame();
TryCatchBlockNode tryCatchBlockNode = getTryCatchBlockNode(lastFrame, objectRef);
if (tryCatchBlockNode != null) {
lastFrame.operandStack.clear();
lastFrame.operandStack.pushRef(objectRef);
lastFrame.jump(tryCatchBlockNode.handler);
return;
} else {
frame.vm.popFrame();
}
}
frame.vm.getResult().exception(objectRef);
}
use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class Getfield method getfield.
public static void getfield(Frame frame) {
FieldInsnNode fieldInsnNode = frame.fieldInsnNode();
String fieldName = fieldInsnNode.name;
String fieldDesc = fieldInsnNode.desc;
ObjectRef objectRef = frame.operandStack.popRef();
if (objectRef == null) {
frame.throwNullPointerException();
return;
}
Object value = frame.heap.getField(objectRef, fieldName);
if (Descriptors.LONG_DESC.equals(fieldDesc)) {
frame.operandStack.pushLong((long) value);
} else if (Descriptors.DOUBLE_DESC.equals(fieldDesc)) {
frame.operandStack.pushDouble((double) value);
} else {
frame.operandStack.push(value);
}
// Log.result(frame.getCurrentOpCode(), value, objectRef, fieldName);
}
Aggregations