Beispiel #1
0
def translate_slice_idxs(vm, i, j, upper):
    i = translate_slice_idx(vm, i, upper)
    j = translate_slice_idx(vm, j, upper)
    if j < i:
        vm.raise_helper("Indices_Exception", \
          [Builtins.Con_Int(vm, i), Builtins.Con_Int(vm, j)])

    return i, j
Beispiel #2
0
def translate_slice_idx(vm, i, upper):
    if i < 0:
        i = upper + i

    if i < 0 or i > upper:
        vm.raise_helper("Bounds_Exception", \
          [Builtins.Con_Int(vm, i), Builtins.Con_Int(vm, upper)])

    return i
Beispiel #3
0
 def _instr_unpack_assign(self, instr, cf):
     o = cf.stack_get(cf.stackpe - 1)
     o = Builtins.type_check_list(self, o)
     ne = len(o.l)
     if ne != Target.unpack_unpack_assign(instr):
         self.raise_helper("Unpack_Exception", \
           [Builtins.Con_Int(self, Target.unpack_unpack_assign(instr)), \
            Builtins.Con_Int(self, ne)])
     for i in range(ne - 1, -1, -1):
         cf.stack_push(o.l[i])
     cf.bc_off += Target.INTSIZE