|
@@ -26,6 +26,8 @@ def make_chain(funcs): |
|
|
arg = co.co_consts[oparg] |
|
|
arg = co.co_consts[oparg] |
|
|
elif op in opcode.haslocal: |
|
|
elif op in opcode.haslocal: |
|
|
arg = co.co_varnames[oparg] |
|
|
arg = co.co_varnames[oparg] |
|
|
|
|
|
elif op in opcode.hascompare: |
|
|
|
|
|
arg = opcode.cmp_op[oparg] |
|
|
else: |
|
|
else: |
|
|
raise NotImplementedError(op, opcode.opname[op]) |
|
|
raise NotImplementedError(op, opcode.opname[op]) |
|
|
else: |
|
|
else: |
|
@@ -69,13 +71,17 @@ def _make_codes(chain): |
|
|
codes.append(op) |
|
|
codes.append(op) |
|
|
if op >= opcode.HAVE_ARGUMENT: |
|
|
if op >= opcode.HAVE_ARGUMENT: |
|
|
if op in opcode.hasconst: |
|
|
if op in opcode.hasconst: |
|
|
|
|
|
if arg not in constants: |
|
|
|
|
|
constants.append(arg) |
|
|
args = constants |
|
|
args = constants |
|
|
elif op in opcode.haslocal: |
|
|
elif op in opcode.haslocal: |
|
|
|
|
|
if arg not in varnames: |
|
|
|
|
|
varnames.append(arg) |
|
|
args = varnames |
|
|
args = varnames |
|
|
|
|
|
elif op in opcode.hascompare: |
|
|
|
|
|
args = opcode.cmp_op |
|
|
else: |
|
|
else: |
|
|
raise NotImplementedError(op, opcode.opname[op]) |
|
|
raise NotImplementedError(op, opcode.opname[op]) |
|
|
if arg not in args: |
|
|
|
|
|
args.append(arg) |
|
|
|
|
|
codes.append(args.index(arg)) |
|
|
codes.append(args.index(arg)) |
|
|
codes.append(0) |
|
|
codes.append(0) |
|
|
code = random.choice(chain[op]) |
|
|
code = random.choice(chain[op]) |
|
|