Search in sources :

Example 46 with Result

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

the class NativeCharacter method digit.

/**
 * override
 *
 * @see Character#digit(int, int)
 */
private static Result digit(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
    int codePoint = (int) methodArgs.invokeArgs[0];
    int radix = (int) methodArgs.invokeArgs[1];
    int i = Character.digit(codePoint, radix);
    Result result = NativeMethod.result(methodCode, i, frame);
    return result;
}
Also used : Result(io.nuls.contract.vm.Result)

Example 47 with Result

use of io.nuls.contract.vm.Result 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;
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef) Result(io.nuls.contract.vm.Result)

Example 48 with Result

use of io.nuls.contract.vm.Result 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;
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef) Result(io.nuls.contract.vm.Result)

Example 49 with Result

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

the class NativeDouble method doubleToRawLongBits.

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

Example 50 with Result

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

the class NativeFloat method floatToRawIntBits.

/**
 * native
 *
 * @see Float#floatToRawIntBits(float)
 */
private static Result floatToRawIntBits(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
    float value = (float) methodArgs.invokeArgs[0];
    int bits = Float.floatToRawIntBits(value);
    Result result = NativeMethod.result(methodCode, bits, frame);
    return result;
}
Also used : 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