Search in sources :

Example 36 with Result

use of io.nuls.contract.vm.Result in project nuls by nuls-io.

the class NativeStrictMath method cos.

/**
 * native
 *
 * @see StrictMath#cos(double)
 */
private static Result cos(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
    double a = (double) methodArgs.invokeArgs[0];
    double r = StrictMath.cos(a);
    Result result = NativeMethod.result(methodCode, r, frame);
    return result;
}
Also used : Result(io.nuls.contract.vm.Result)

Example 37 with Result

use of io.nuls.contract.vm.Result in project nuls by nuls-io.

the class NativeStrictMath method cosh.

/**
 * native
 *
 * @see StrictMath#cosh(double)
 */
private static Result cosh(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
    double x = (double) methodArgs.invokeArgs[0];
    double r = StrictMath.cosh(x);
    Result result = NativeMethod.result(methodCode, r, frame);
    return result;
}
Also used : Result(io.nuls.contract.vm.Result)

Example 38 with Result

use of io.nuls.contract.vm.Result in project nuls by nuls-io.

the class NativeSystem method identityHashCode.

/**
 * native
 *
 * @see System#identityHashCode(Object)
 */
private static Result identityHashCode(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
    ObjectRef objectRef = (ObjectRef) methodArgs.invokeArgs[0];
    int hashCode = identityHashCode(objectRef);
    Result result = NativeMethod.result(methodCode, hashCode, frame);
    return result;
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef) Result(io.nuls.contract.vm.Result)

Example 39 with Result

use of io.nuls.contract.vm.Result in project nuls by nuls-io.

the class NativeSystem method arraycopy.

/**
 * native
 *
 * @see System#arraycopy(Object, int, Object, int, int)
 */
private static Result arraycopy(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
    Object[] args = methodArgs.invokeArgs;
    ObjectRef srcObjectRef = (ObjectRef) args[0];
    int srcPos = (int) args[1];
    ObjectRef destObjectRef = (ObjectRef) args[2];
    int destPos = (int) args[3];
    int length = (int) args[4];
    if (length > 0 && frame.checkArray(srcObjectRef, srcPos) && frame.checkArray(srcObjectRef, srcPos + length - 1) && frame.checkArray(destObjectRef, destPos) && frame.checkArray(destObjectRef, destPos + length - 1)) {
        frame.heap.arraycopy(srcObjectRef, srcPos, destObjectRef, destPos, length);
    }
    Result result = NativeMethod.result(methodCode, null, frame);
    return result;
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef) Result(io.nuls.contract.vm.Result)

Example 40 with Result

use of io.nuls.contract.vm.Result in project nuls by nuls-io.

the class NativeClass method getSuperclass.

/**
 * native
 *
 * @see Class#getSuperclass()
 */
private static Result getSuperclass(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());
    }
    ClassCode classCode = frame.methodArea.loadClass(variableType.getType());
    VariableType superVariableType = VariableType.valueOf(classCode.superName);
    ObjectRef classRef = frame.heap.getClassRef(superVariableType.getDesc());
    Result result = NativeMethod.result(methodCode, classRef, frame);
    return result;
}
Also used : ClassCode(io.nuls.contract.vm.code.ClassCode) VariableType(io.nuls.contract.vm.code.VariableType) ObjectRef(io.nuls.contract.vm.ObjectRef) Result(io.nuls.contract.vm.Result)

Aggregations

Result (io.nuls.contract.vm.Result)63 ObjectRef (io.nuls.contract.vm.ObjectRef)35 VariableType (io.nuls.contract.vm.code.VariableType)12 MethodCode (io.nuls.contract.vm.code.MethodCode)6 ClassCode (io.nuls.contract.vm.code.ClassCode)5 MethodArgs (io.nuls.contract.vm.MethodArgs)3 MethodInsnNode (org.objectweb.asm.tree.MethodInsnNode)3 Frame (io.nuls.contract.vm.Frame)1 VM (io.nuls.contract.vm.VM)1 ErrorException (io.nuls.contract.vm.exception.ErrorException)1 ArrayList (java.util.ArrayList)1 AccountState (org.ethereum.core.AccountState)1 DataWord (org.ethereum.vm.DataWord)1