Search in sources :

Example 16 with ObjectRef

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

the class Xaload method baload.

public static void baload(final Frame frame) {
    int index = frame.operandStack.popInt();
    ObjectRef arrayRef = frame.operandStack.popRef();
    if (!frame.checkArray(arrayRef, index)) {
        return;
    }
    Object result;
    if (arrayRef.getVariableType().getComponentType().isBoolean()) {
        boolean value = (boolean) frame.heap.getArray(arrayRef, index);
        frame.operandStack.pushBoolean(value);
        result = value;
    } else {
        byte value = (byte) frame.heap.getArray(arrayRef, index);
        frame.operandStack.pushByte(value);
        result = value;
    }
// Log.result(frame.getCurrentOpCode(), result, arrayRef, index);
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef)

Example 17 with ObjectRef

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

the class Xaload method faload.

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

Example 18 with ObjectRef

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

the class Xaload method caload.

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

Example 19 with ObjectRef

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

the class New method new_.

public static void new_(Frame frame) {
    String className = frame.typeInsnNode().desc;
    ObjectRef objectRef = frame.heap.newObject(className);
    frame.operandStack.pushRef(objectRef);
// Log.opcode(frame.getCurrentOpCode(), objectRef);
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef)

Example 20 with ObjectRef

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

the class Putfield method putfield.

public static void putfield(Frame frame) {
    FieldInsnNode fieldInsnNode = frame.fieldInsnNode();
    String fieldName = fieldInsnNode.name;
    String fieldDesc = fieldInsnNode.desc;
    Object value;
    if (Descriptors.LONG_DESC.equals(fieldDesc)) {
        value = frame.operandStack.popLong();
    } else if (Descriptors.DOUBLE_DESC.equals(fieldDesc)) {
        value = frame.operandStack.popDouble();
    } else {
        value = frame.operandStack.pop();
    }
    ObjectRef objectRef = frame.operandStack.popRef();
    if (objectRef == null) {
        frame.throwNullPointerException();
        return;
    }
    frame.heap.putField(objectRef, fieldName, value);
// Log.result(frame.getCurrentOpCode(), value, objectRef, fieldName);
}
Also used : FieldInsnNode(org.objectweb.asm.tree.FieldInsnNode) 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