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);
}
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");
}
}
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);
}
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);
}
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);
}
Aggregations