Search in sources :

Example 21 with ObjectRef

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

the class Xastore method aastore.

public static void aastore(final Frame frame) {
    ObjectRef value = frame.operandStack.popRef();
    int index = frame.operandStack.popInt();
    ObjectRef arrayRef = frame.operandStack.popRef();
    if (!frame.checkArray(arrayRef, index)) {
        return;
    }
    frame.heap.putArray(arrayRef, index, value);
// Log.result(frame.getCurrentOpCode(), arrayRef, index, value);
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef)

Example 22 with ObjectRef

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

the class Ldc method ldc.

public static void ldc(final Frame frame) {
    Object value = frame.ldcInsnNode().cst;
    if (value instanceof Integer) {
        frame.operandStack.pushInt((int) value);
    } else if (value instanceof Long) {
        frame.operandStack.pushLong((long) value);
    } else if (value instanceof Float) {
        frame.operandStack.pushFloat((float) value);
    } else if (value instanceof Double) {
        frame.operandStack.pushDouble((double) value);
    } else if (value instanceof String) {
        String str = (String) value;
        ObjectRef objectRef = frame.heap.newString(str);
        frame.operandStack.pushRef(objectRef);
    } else if (value instanceof Type) {
        Type type = (Type) value;
        String desc = type.getDescriptor();
        ObjectRef objectRef = frame.heap.getClassRef(desc);
        frame.operandStack.pushRef(objectRef);
    } else {
        throw new IllegalArgumentException("unknown ldc cst");
    }
}
Also used : Type(org.objectweb.asm.Type) ObjectRef(io.nuls.contract.vm.ObjectRef)

Example 23 with ObjectRef

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

the class Ifnull method ifnull.

public static void ifnull(final Frame frame) {
    ObjectRef value = frame.operandStack.popRef();
    boolean result = value == null;
    if (result) {
        frame.jump();
    }
// Log.result(frame.getCurrentOpCode(), result, value, "==", null);
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef)

Example 24 with ObjectRef

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

the class Return method areturn.

public static void areturn(final Frame frame) {
    ObjectRef result = frame.operandStack.popRef();
    frame.result.value(result);
// Log.result(frame.getCurrentOpCode(), result);
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef)

Example 25 with ObjectRef

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

the class Multianewarray method multianewarray.

public static void multianewarray(final Frame frame) {
    MultiANewArrayInsnNode multiANewArrayInsnNode = frame.multiANewArrayInsnNode();
    int[] dimensions = new int[multiANewArrayInsnNode.dims];
    for (int i = multiANewArrayInsnNode.dims - 1; i >= 0; i--) {
        int length = frame.operandStack.popInt();
        if (length < 0) {
            frame.throwNegativeArraySizeException();
            return;
        }
        dimensions[i] = length;
    }
    VariableType variableType = VariableType.valueOf(multiANewArrayInsnNode.desc);
    ObjectRef arrayRef = frame.heap.newArray(variableType, dimensions);
    frame.operandStack.pushRef(arrayRef);
// Log.result(frame.getCurrentOpCode(), arrayRef);
}
Also used : VariableType(io.nuls.contract.vm.code.VariableType) MultiANewArrayInsnNode(org.objectweb.asm.tree.MultiANewArrayInsnNode) ObjectRef(io.nuls.contract.vm.ObjectRef)

Aggregations

ObjectRef (io.nuls.contract.vm.ObjectRef)74 Result (io.nuls.contract.vm.Result)35 VariableType (io.nuls.contract.vm.code.VariableType)18 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 TypeInsnNode (org.objectweb.asm.tree.TypeInsnNode)3 Frame (io.nuls.contract.vm.Frame)2 FieldInsnNode (org.objectweb.asm.tree.FieldInsnNode)2 BiMap (com.google.common.collect.BiMap)1 BlockHeaderDto (io.nuls.contract.entity.BlockHeaderDto)1 VM (io.nuls.contract.vm.VM)1 ErrorException (io.nuls.contract.vm.exception.ErrorException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 AccountState (org.ethereum.core.AccountState)1 DataWord (org.ethereum.vm.DataWord)1 Type (org.objectweb.asm.Type)1