use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class NativeDouble method parseDouble.
/**
* override
*
* @see Double#parseDouble(String)
*/
private static Result parseDouble(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
ObjectRef objectRef = (ObjectRef) methodArgs.invokeArgs[0];
String s = frame.heap.runToString(objectRef);
double d;
try {
d = Double.parseDouble(s);
} catch (Exception e) {
frame.throwNumberFormatException(e.getMessage());
return null;
}
Result result = NativeMethod.result(methodCode, d, frame);
return result;
}
use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class NativeDouble method toString.
/**
* override
*
* @see Double#toString(double)
*/
private static Result toString(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
double d = (double) methodArgs.invokeArgs[0];
String s = Double.toString(d);
ObjectRef ref = frame.heap.newString(s);
Result result = NativeMethod.result(methodCode, ref, frame);
return result;
}
use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class NativeFloat method toHexString.
/**
* override
*
* @see Float#toHexString(float)
*/
private static Result toHexString(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
float f = (float) methodArgs.invokeArgs[0];
String s = Float.toHexString(f);
ObjectRef ref = frame.heap.newString(s);
Result result = NativeMethod.result(methodCode, ref, frame);
return result;
}
use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class NativeArray method newArray.
/**
* native
*
* @see Array#newArray(Class, int)
*/
private static Result newArray(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
ObjectRef componentType = (ObjectRef) methodArgs.invokeArgs[0];
int length = (int) methodArgs.invokeArgs[1];
VariableType variableType = VariableType.valueOf("[" + componentType.getRef());
ObjectRef array = frame.heap.newArray(variableType, length);
Result result = NativeMethod.result(methodCode, array, frame);
return result;
}
use of io.nuls.contract.vm.ObjectRef in project nuls by nuls-io.
the class NativeString method getBytes.
/**
* override
*
* @see String#getBytes()
*/
private static Result getBytes(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
ObjectRef objectRef = methodArgs.objectRef;
ObjectRef ref = null;
if (objectRef != null) {
String str = frame.heap.runToString(objectRef);
if (str != null) {
byte[] bytes = str.getBytes();
ref = frame.heap.newArray(bytes);
}
}
Result result = NativeMethod.result(methodCode, ref, frame);
return result;
}
Aggregations