Search in sources :

Example 71 with ObjectRef

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

the class NativeString method intern.

/**
 * native
 *
 * @see String#intern()
 */
private static Result intern(MethodCode methodCode, MethodArgs methodArgs, Frame frame) {
    ObjectRef objectRef = methodArgs.objectRef;
    Result result = NativeMethod.result(methodCode, objectRef, frame);
    return result;
}
Also used : ObjectRef(io.nuls.contract.vm.ObjectRef) Result(io.nuls.contract.vm.Result)

Example 72 with ObjectRef

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

the class Invokevirtual method invokevirtual.

public static void invokevirtual(Frame frame) {
    MethodInsnNode methodInsnNode = frame.methodInsnNode();
    String className = methodInsnNode.owner;
    String methodName = methodInsnNode.name;
    String methodDesc = methodInsnNode.desc;
    List<VariableType> variableTypes = VariableType.parseArgs(methodDesc);
    MethodArgs methodArgs = new MethodArgs(variableTypes, frame.operandStack, false);
    ObjectRef objectRef = methodArgs.objectRef;
    if (objectRef == null) {
        frame.throwNullPointerException();
        return;
    }
    String type = objectRef.getVariableType().getType();
    if (!Objects.equals(className, type)) {
        if (objectRef.getVariableType().isPrimitiveType()) {
        } else {
            className = type;
        }
    }
    if (objectRef.isArray()) {
        className = Constants.OBJECT_CLASS_NAME;
    }
    MethodCode methodCode = frame.methodArea.loadMethod(className, methodName, methodDesc);
    // Log.opcode(frame.getCurrentOpCode(), objectRef, methodName, methodDesc);
    Result result = NativeMethod.run(methodCode, methodArgs, frame);
    if (result != null) {
        return;
    }
    frame.vm.run(methodCode, methodArgs.frameArgs, true);
}
Also used : VariableType(io.nuls.contract.vm.code.VariableType) MethodInsnNode(org.objectweb.asm.tree.MethodInsnNode) ObjectRef(io.nuls.contract.vm.ObjectRef) MethodCode(io.nuls.contract.vm.code.MethodCode) MethodArgs(io.nuls.contract.vm.MethodArgs) Result(io.nuls.contract.vm.Result)

Example 73 with ObjectRef

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

the class Xastore method iastore.

public static void iastore(final Frame frame) {
    int value = frame.operandStack.popInt();
    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 74 with ObjectRef

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

the class Xastore method lastore.

public static void lastore(final Frame frame) {
    long value = frame.operandStack.popLong();
    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)

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