use of io.nuls.contract.vm.Result in project nuls by nuls-io.
the class NativeAbstractStringBuilder method append.
/**
* override
*
* @see AbstractStringBuilder#append(float)
* @see AbstractStringBuilder#append(double)
*/
private static Result append(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
ObjectRef objectRef = methodArgs.objectRef;
Object a = methodArgs.invokeArgs[0];
ObjectRef ref = frame.heap.newString(a.toString());
MethodCode append = frame.methodArea.loadMethod(TYPE, "append", "(Ljava/lang/String;)Ljava/lang/AbstractStringBuilder;");
frame.vm.run(append, new Object[] { objectRef, ref }, false);
Result result = NativeMethod.result(methodCode, objectRef, frame);
return result;
}
use of io.nuls.contract.vm.Result in project nuls by nuls-io.
the class NativeClass method getInterfaces.
/**
* override
*
* @see Class#getInterfaces()
*/
private static Result getInterfaces(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 array;
if (!variableType.isPrimitiveType()) {
ClassCode classCode = frame.methodArea.loadClass(variableType.getType());
List<String> interfaces = classCode.interfaces;
int length = interfaces.size();
array = frame.heap.newArray(VariableType.valueOf("[Ljava/lang/Class;"), length);
for (int i = 0; i < length; i++) {
String interfaceName = interfaces.get(i);
VariableType interfaceType = VariableType.valueOf(interfaceName);
ObjectRef ref = frame.heap.getClassRef(interfaceType.getDesc());
frame.heap.putArray(array, i, ref);
}
} else {
array = frame.heap.newArray(VariableType.valueOf("[Ljava/lang/Class;"), 0);
}
Result result = NativeMethod.result(methodCode, array, frame);
return result;
}
use of io.nuls.contract.vm.Result in project nuls by nuls-io.
the class NativeClass method isInterface.
/**
* native
*
* @see Class#isInterface()
*/
private static Result isInterface(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());
}
boolean b = false;
if (!variableType.isArray() && !variableType.isPrimitiveType()) {
ClassCode classCode = frame.methodArea.loadClass(variableType.getType());
b = classCode.isInterface;
}
Result result = NativeMethod.result(methodCode, b, frame);
return result;
}
use of io.nuls.contract.vm.Result 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.Result 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;
}
Aggregations