Example #1
0
def arithmetic_op(vm, func, arity):
    if len(vm.stack) < arity:
        raise Exception("Not enought arguments")
    args = [cast_to_number(vm.stack.pop()) for _ in range(arity)]
    result = func(*reversed(args))
    vm.stack.append(valtype_from_number(result))
Example #2
0
def op_depth(vm, instr):
    vm.stack.append(valtype_from_number(len(vm.stack)))
Example #3
0
def push_bignum_instruction(bn):
    return push_data_instruction(valtype_from_number(bn))
Example #4
0
def op_size(vm, instr):
    if len(vm.stack) < 1:
        raise Exception("OP_SIZE: Not enought arguments")
    vm.stack.append(valtype_from_number(len(vm.stack[-1])))
Example #5
0
def op_size(vm, instr):
    if len(vm.stack) < 1:
        raise Exception("OP_SIZE: Not enought arguments")
    vm.stack.append(valtype_from_number(len(vm.stack[-1])))
Example #6
0
def push_bignum_instruction(bn):
    return push_data_instruction(valtype_from_number(bn))
Example #7
0
def op_1negate(vm, instr):
    vm.stack.append(valtype_from_number(-1))
Example #8
0
def op_push_1_16(vm, instr):
    vm.stack.append(valtype_from_number(instr.opcode - (OP_1 - 1)))
Example #9
0
def op_push_0(vm, instr):
    vm.stack.append(valtype_from_number(0))  # changed from ""
Example #10
0
def arithmetic_op(vm, func, arity):
    if len(vm.stack) < arity:
        raise Exception("Not enought arguments")
    args = [cast_to_number(vm.stack.pop()) for _ in range(arity)]
    result = func(*reversed(args))
    vm.stack.append(valtype_from_number(result))