Rizin
unix-like reverse engineering framework and cli tools
opcode.h File Reference
#include <rz_types.h>
#include <rz_list.h>
#include <rz_util.h>
#include <rz_analysis.h>

Go to the source code of this file.

Classes

struct  pyc_opcode_object
 
struct  pyc_opcodes
 
struct  pyc_arg_fmt
 
struct  version_opcode
 
struct  op_analysis_func
 
struct  op_parameter
 

Macros

#define OBJECT_SIZE_ON_STACK   1
 
#define def_op(...)   def_opN((struct op_parameter){ .fallthrough = true, __VA_ARGS__ })
 
#define def_op0(...)   def_opN((struct op_parameter){ .pop = -2, .push = -2, .fallthrough = true, __VA_ARGS__ })
 
#define def_op00(...)   def_opN((struct op_parameter){ __VA_ARGS__ })
 
#define name_op0(...)   name_opN((struct op_parameter){ .pop = -2, .push = -2, __VA_ARGS__ })
 
#define name_op(...)   name_opN((struct op_parameter){ __VA_ARGS__ })
 
#define local_op0(...)   local_opN((struct op_parameter){ .pop = 0, .push = 1, __VA_ARGS__ })
 
#define local_op(...)   local_opN((struct op_parameter){ __VA_ARGS__ })
 
#define free_op0(...)   free_opN((struct op_parameter){ .pop = 0, .push = 1, __VA_ARGS__ })
 
#define free_op(...)   free_opN((struct op_parameter){ __VA_ARGS__ })
 
#define store_op00(...)   store_opN((struct op_parameter){ __VA_ARGS__ })
 
#define store_op(...)   store_opN((struct op_parameter){ .func = DEF_OP, __VA_ARGS__ })
 
#define store_op0(...)   store_opN((struct op_parameter){ .pop = 0, .push = 1, .func = DEF_OP, __VA_ARGS__ })
 
#define varargs_op(...)   varargs_op((struct op_parameter){ __VA_ARGS__ })
 
#define varargs_op0(...)   varargs_op((struct op_parameter){ .pop = -1, .push = 1, __VA_ARGS__ })
 
#define const_op(...)   const_opN((struct op_parameter){ .pop = 0, .push = 1, __VA_ARGS__ })
 
#define const_op00(...)   const_opN((struct op_parameter){ __VA_ARGS__ })
 
#define compare_op0(...)   compare_op((struct op_parameter){ .pop = 2, .push = 1, __VA_ARGS__ })
 
#define compare_op(...)   compare_op((struct op_parameter){ __VA_ARGS__ })
 
#define jabs_op00(...)   jabs_opN((struct op_parameter){ __VA_ARGS__ })
 
#define jabs_op0(...)   jabs_opN((struct op_parameter){ .pop = 0, .push = 0, .conditional = false, .fallthrough = true, __VA_ARGS__ })
 
#define jabs_op(...)   jabs_opN((struct op_parameter){ .fallthrough = true, __VA_ARGS__ })
 
#define jrel_op00(...)   jrel_opN((struct op_parameter){ __VA_ARGS__ })
 
#define jrel_op0(...)   jrel_opN((struct op_parameter){ .pop = 0, .push = 0, .conditional = false, .fallthrough = true, __VA_ARGS__ })
 
#define jrel_op(...)   jrel_opN((struct op_parameter){ .fallthrough = true, __VA_ARGS__ })
 
#define nargs_op(...)   nargs_op((struct op_parameter){ __VA_ARGS__ })
 
#define nargs_op0(...)   nargs_op((struct op_parameter){ .pop = -2, .push = -2, __VA_ARGS__ })
 
#define rm_op(...)   rm_op((struct op_parameter){ __VA_ARGS__ })
 

Enumerations

enum  pyc_opcode_type {
  HASCOMPARE = 0x1 , HASCONDITION = 0x2 , HASCONST = 0x4 , HASFREE = 0x8 ,
  HASJABS = 0x10 , HASJREL = 0x20 , HASLOCAL = 0x40 , HASNAME = 0x80 ,
  HASNARGS = 0x100 , HASSTORE = 0x200 , HASVARGS = 0x400 , NOFOLLOW = 0x800
}
 
enum  pyc_store_op_func { NAME_OP = 0x1 , LOCAL_OP = 0x2 , FREE_OP = 0x4 , DEF_OP = 0x8 }
 

Functions

void analysis_pyc_op (RzAnalysisOp *op, pyc_opcode_object *op_obj, ut32 oparg)
 
pyc_opcodesopcode_2x (void)
 
pyc_opcodesopcode_3x (void)
 
pyc_opcodesopcode_10 (void)
 
pyc_opcodesopcode_11 (void)
 
pyc_opcodesopcode_12 (void)
 
pyc_opcodesopcode_13 (void)
 
pyc_opcodesopcode_14 (void)
 
pyc_opcodesopcode_15 (void)
 
pyc_opcodesopcode_16 (void)
 
pyc_opcodesopcode_20 (void)
 
pyc_opcodesopcode_21 (void)
 
pyc_opcodesopcode_22 (void)
 
pyc_opcodesopcode_23 (void)
 
pyc_opcodesopcode_24 (void)
 
pyc_opcodesopcode_25 (void)
 
pyc_opcodesopcode_26 (void)
 
pyc_opcodesopcode_27 (void)
 
pyc_opcodesopcode_30 (void)
 
pyc_opcodesopcode_31 (void)
 
pyc_opcodesopcode_32 (void)
 
pyc_opcodesopcode_33 (void)
 
pyc_opcodesopcode_34 (void)
 
pyc_opcodesopcode_35 (void)
 
pyc_opcodesopcode_36 (void)
 
pyc_opcodesopcode_37 (void)
 
pyc_opcodesopcode_38 (void)
 
pyc_opcodesopcode_39 (void)
 
pyc_opcodesget_opcode_by_version (char *version)
 
pyc_opcodesnew_pyc_opcodes ()
 
void free_opcode (pyc_opcodes *opcodes)
 
bool pyc_opcodes_equal (pyc_opcodes *op, const char *version)
 
void add_arg_fmt (pyc_opcodes *ret, char *op_name, const char *(*formatter)(ut32 oparg))
 
const char * format_MAKE_FUNCTION_arg_3x (ut32 oparg)
 
const char * format_extended_arg (ut32 oparg)
 
const char * format_CALL_FUNCTION_pos_name_encoded (ut32 oparg)
 
const char * format_CALL_FUNCTION_KW_36 (ut32 oparg)
 
const char * format_CALL_FUNCTION_EX_36 (ut32 oparg)
 
const char * format_MAKE_FUNCTION_arg_36 (ut32 oparg)
 
const char * format_value_flags_36 (ut32 oparg)
 
const char * format_extended_arg_36 (ut32 oparg)
 
void() def_opN (struct op_parameter par)
 
void() name_opN (struct op_parameter par)
 
void() local_opN (struct op_parameter par)
 
void() free_opN (struct op_parameter par)
 
void() store_opN (struct op_parameter par)
 
void() varargs_op (struct op_parameter par)
 
void() const_opN (struct op_parameter par)
 
void() compare_op (struct op_parameter par)
 
void() jabs_opN (struct op_parameter par)
 
void() jrel_opN (struct op_parameter par)
 
void() nargs_op (struct op_parameter par)
 
void() rm_op (struct op_parameter par)
 

Macro Definition Documentation

◆ compare_op

#define compare_op (   ...)    compare_op((struct op_parameter){ __VA_ARGS__ })

Definition at line 158 of file opcode.h.

◆ compare_op0

#define compare_op0 (   ...)    compare_op((struct op_parameter){ .pop = 2, .push = 1, __VA_ARGS__ })

Definition at line 157 of file opcode.h.

◆ const_op

#define const_op (   ...)    const_opN((struct op_parameter){ .pop = 0, .push = 1, __VA_ARGS__ })

Definition at line 153 of file opcode.h.

◆ const_op00

#define const_op00 (   ...)    const_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 154 of file opcode.h.

◆ def_op

#define def_op (   ...)    def_opN((struct op_parameter){ .fallthrough = true, __VA_ARGS__ })

Definition at line 127 of file opcode.h.

◆ def_op0

#define def_op0 (   ...)    def_opN((struct op_parameter){ .pop = -2, .push = -2, .fallthrough = true, __VA_ARGS__ })

Definition at line 128 of file opcode.h.

◆ def_op00

#define def_op00 (   ...)    def_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 129 of file opcode.h.

◆ free_op

#define free_op (   ...)    free_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 141 of file opcode.h.

◆ free_op0

#define free_op0 (   ...)    free_opN((struct op_parameter){ .pop = 0, .push = 1, __VA_ARGS__ })

Definition at line 140 of file opcode.h.

◆ jabs_op

#define jabs_op (   ...)    jabs_opN((struct op_parameter){ .fallthrough = true, __VA_ARGS__ })

Definition at line 163 of file opcode.h.

◆ jabs_op0

#define jabs_op0 (   ...)    jabs_opN((struct op_parameter){ .pop = 0, .push = 0, .conditional = false, .fallthrough = true, __VA_ARGS__ })

Definition at line 162 of file opcode.h.

◆ jabs_op00

#define jabs_op00 (   ...)    jabs_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 161 of file opcode.h.

◆ jrel_op

#define jrel_op (   ...)    jrel_opN((struct op_parameter){ .fallthrough = true, __VA_ARGS__ })

Definition at line 168 of file opcode.h.

◆ jrel_op0

#define jrel_op0 (   ...)    jrel_opN((struct op_parameter){ .pop = 0, .push = 0, .conditional = false, .fallthrough = true, __VA_ARGS__ })

Definition at line 167 of file opcode.h.

◆ jrel_op00

#define jrel_op00 (   ...)    jrel_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 166 of file opcode.h.

◆ local_op

#define local_op (   ...)    local_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 137 of file opcode.h.

◆ local_op0

#define local_op0 (   ...)    local_opN((struct op_parameter){ .pop = 0, .push = 1, __VA_ARGS__ })

Definition at line 136 of file opcode.h.

◆ name_op

#define name_op (   ...)    name_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 133 of file opcode.h.

◆ name_op0

#define name_op0 (   ...)    name_opN((struct op_parameter){ .pop = -2, .push = -2, __VA_ARGS__ })

Definition at line 132 of file opcode.h.

◆ nargs_op

#define nargs_op (   ...)    nargs_op((struct op_parameter){ __VA_ARGS__ })

Definition at line 171 of file opcode.h.

◆ nargs_op0

#define nargs_op0 (   ...)    nargs_op((struct op_parameter){ .pop = -2, .push = -2, __VA_ARGS__ })

Definition at line 172 of file opcode.h.

◆ OBJECT_SIZE_ON_STACK

#define OBJECT_SIZE_ON_STACK   1

Definition at line 13 of file opcode.h.

◆ rm_op

#define rm_op (   ...)    rm_op((struct op_parameter){ __VA_ARGS__ })

Definition at line 175 of file opcode.h.

◆ store_op

#define store_op (   ...)    store_opN((struct op_parameter){ .func = DEF_OP, __VA_ARGS__ })

Definition at line 145 of file opcode.h.

◆ store_op0

#define store_op0 (   ...)    store_opN((struct op_parameter){ .pop = 0, .push = 1, .func = DEF_OP, __VA_ARGS__ })

Definition at line 146 of file opcode.h.

◆ store_op00

#define store_op00 (   ...)    store_opN((struct op_parameter){ __VA_ARGS__ })

Definition at line 144 of file opcode.h.

◆ varargs_op

#define varargs_op (   ...)    varargs_op((struct op_parameter){ __VA_ARGS__ })

Definition at line 149 of file opcode.h.

◆ varargs_op0

#define varargs_op0 (   ...)    varargs_op((struct op_parameter){ .pop = -1, .push = 1, __VA_ARGS__ })

Definition at line 150 of file opcode.h.

Enumeration Type Documentation

◆ pyc_opcode_type

Enumerator
HASCOMPARE 
HASCONDITION 
HASCONST 
HASFREE 
HASJABS 
HASJREL 
HASLOCAL 
HASNAME 
HASNARGS 
HASSTORE 
HASVARGS 
NOFOLLOW 

Definition at line 15 of file opcode.h.

15  {
16  HASCOMPARE = 0x1,
17  HASCONDITION = 0x2, // conditional operator; has jump offset
18  HASCONST = 0x4,
19  HASFREE = 0x8,
20  HASJABS = 0x10, // Will appear with HASCONDITION sometimes
21  HASJREL = 0x20, // Will appear with HASCONDITION sometimes
22  HASLOCAL = 0x40,
23  HASNAME = 0x80,
24  HASNARGS = 0x100, // For function-like calls
25  HASSTORE = 0x200, // Some sort of store operation
26  HASVARGS = 0x400, // Similar but for operators BUILD_xxx
27  NOFOLLOW = 0x800, // Instruction doesn't fall to the next opcode
pyc_opcode_type
Definition: opcode.h:15
@ HASNAME
Definition: opcode.h:23
@ HASCONDITION
Definition: opcode.h:17
@ HASCOMPARE
Definition: opcode.h:16
@ HASLOCAL
Definition: opcode.h:22
@ HASSTORE
Definition: opcode.h:25
@ HASJREL
Definition: opcode.h:21
@ HASCONST
Definition: opcode.h:18
@ NOFOLLOW
Definition: opcode.h:27
@ HASNARGS
Definition: opcode.h:24
@ HASVARGS
Definition: opcode.h:26
@ HASFREE
Definition: opcode.h:19
@ HASJABS
Definition: opcode.h:20

◆ pyc_store_op_func

Enumerator
NAME_OP 
LOCAL_OP 
FREE_OP 
DEF_OP 

Definition at line 30 of file opcode.h.

30  {
31  NAME_OP = 0x1,
32  LOCAL_OP = 0x2,
33  FREE_OP = 0x4,
34  DEF_OP = 0x8,
pyc_store_op_func
Definition: opcode.h:30
@ LOCAL_OP
Definition: opcode.h:32
@ DEF_OP
Definition: opcode.h:34
@ FREE_OP
Definition: opcode.h:33
@ NAME_OP
Definition: opcode.h:31

Function Documentation

◆ add_arg_fmt()

void add_arg_fmt ( pyc_opcodes ret,
char *  op_name,
const char *(*)(ut32 oparg)  formatter 
)

Definition at line 234 of file opcode.c.

234  {
236  if (!fmt) {
237  return;
238  }
239  fmt->op_name = op_name;
240  fmt->formatter = formatter;
241  rz_list_append(ret->opcode_arg_fmt, fmt);
242 }
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
#define RZ_NEW0(x)
Definition: rz_types.h:284
char * op_name
Definition: opcode.h:55
const char *(* formatter)(ut32 oparg)
Definition: opcode.h:56
RzList * opcode_arg_fmt
Definition: opcode.h:50

References pyc_arg_fmt::formatter, pyc_arg_fmt::op_name, pyc_opcodes::opcode_arg_fmt, rz_list_append(), and RZ_NEW0.

Referenced by opcode_10(), opcode_11(), opcode_12(), opcode_13(), opcode_14(), opcode_15(), opcode_16(), opcode_20(), opcode_21(), opcode_22(), opcode_23(), opcode_24(), opcode_25(), opcode_26(), opcode_27(), opcode_30(), opcode_31(), opcode_32(), opcode_33(), opcode_34(), opcode_35(), opcode_36(), opcode_37(), opcode_38(), opcode_39(), and opcode_3x().

◆ analysis_pyc_op()

void analysis_pyc_op ( RzAnalysisOp op,
pyc_opcode_object op_obj,
ut32  oparg 
)

Definition at line 902 of file opcode_analysis.c.

902  {
903  size_t i;
904  for (i = 0; i < (sizeof(op_analysis) / sizeof(op_analysis_func)); i++) {
905  if (!strcmp(op_analysis[i].op_name, op_obj->op_name)) {
906  op_analysis[i].func(op, op_obj, oparg);
907  break;
908  }
909  }
910 }
lzma_index ** i
Definition: index.h:629
static op_analysis_func op_analysis[]
void(* func)(RzAnalysisOp *op, pyc_opcode_object *op_obj, ut32 oparg)
Definition: opcode.h:66
char * op_name
Definition: opcode.h:38
Definition: dis.c:32

References op_analysis_func::func, i, op_analysis, and pyc_opcode_object::op_name.

Referenced by pyc_op().

◆ compare_op()

void() compare_op ( struct op_parameter  par)

Definition at line 301 of file opcode.c.

301  {
302  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
303  par.op_obj[par.op_code].type |= HASCOMPARE;
304 }
#define def_op(...)
Definition: opcode.h:127
pyc_opcode_object * op_obj
Definition: opcode.h:117
ut8 op_code
Definition: opcode.h:119
const char * op_name
Definition: opcode.h:118
st8 push
Definition: opcode.h:121

References def_op, HASCOMPARE, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ const_opN()

void() const_opN ( struct op_parameter  par)

Definition at line 296 of file opcode.c.

296  {
297  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
298  par.op_obj[par.op_code].type |= HASCONST;
299 }

References def_op, HASCONST, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ def_opN()

void() def_opN ( struct op_parameter  par)

Definition at line 244 of file opcode.c.

244  {
245  free(par.op_obj[par.op_code].op_name);
246  par.op_obj[par.op_code].op_name = strdup(par.op_name);
247  par.op_obj[par.op_code].op_code = par.op_code;
248  par.op_obj[par.op_code].op_pop = par.pop;
249  par.op_obj[par.op_code].op_push = par.push;
250  if (!par.fallthrough) {
251  par.op_obj[par.op_code].type |= NOFOLLOW;
252  }
253 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
bool fallthrough
Definition: opcode.h:124

References free(), NOFOLLOW, and strdup().

Referenced by opcode_15().

◆ format_CALL_FUNCTION_EX_36()

const char* format_CALL_FUNCTION_EX_36 ( ut32  oparg)

Definition at line 27 of file opcode_arg_fmt.c.

27  {
28  return rz_str_new((oparg & 0x01) ? "keyword args" : "");
29 }
RZ_API char * rz_str_new(const char *str)
Definition: str.c:865

References rz_str_new().

Referenced by opcode_36(), opcode_37(), opcode_38(), and opcode_39().

◆ format_CALL_FUNCTION_KW_36()

const char* format_CALL_FUNCTION_KW_36 ( ut32  oparg)

Definition at line 23 of file opcode_arg_fmt.c.

23  {
24  return rz_str_newf("%u total positional and keyword args", oparg);
25 }
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1

References rz_str_newf().

Referenced by opcode_36(), opcode_37(), opcode_38(), and opcode_39().

◆ format_CALL_FUNCTION_pos_name_encoded()

const char* format_CALL_FUNCTION_pos_name_encoded ( ut32  oparg)

Definition at line 10 of file opcode_arg_fmt.c.

10  {
11  ut32 pos_args = oparg & 0xFF;
12  ut32 name = (oparg >> 8) & 0xFF;
13  return rz_str_newf("%u positional, %u named", pos_args, name);
14 }
uint32_t ut32
Definition: z80asm.h:102

References rz_str_newf().

Referenced by opcode_27().

◆ format_extended_arg()

◆ format_extended_arg_36()

const char* format_extended_arg_36 ( ut32  oparg)

Definition at line 69 of file opcode_arg_fmt.c.

69  {
70  return rz_str_newf("%u", oparg * (1 << 8));
71 }

References rz_str_newf().

Referenced by opcode_36(), opcode_37(), opcode_38(), and opcode_39().

◆ format_MAKE_FUNCTION_arg_36()

const char* format_MAKE_FUNCTION_arg_36 ( ut32  oparg)

Definition at line 33 of file opcode_arg_fmt.c.

33  {
34  size_t i;
35  char *ret = rz_str_new(" ");
36  for (i = 0; i < sizeof(MAKE_FUNCTION_FLAGS) / sizeof(char *); ++i) {
37  if (oparg & 0x1) {
38  rz_str_appendf(ret, ", %s", MAKE_FUNCTION_FLAGS[i]);
39  } else {
40  free(ret);
42  }
43  oparg >>= 1;
44  }
45  return ret;
46 }
static const char * MAKE_FUNCTION_FLAGS[]
RZ_API char * rz_str_appendf(char *ptr, const char *fmt,...) RZ_PRINTF_CHECK(2

References free(), i, MAKE_FUNCTION_FLAGS, rz_str_appendf(), and rz_str_new().

Referenced by opcode_36(), opcode_37(), opcode_38(), and opcode_39().

◆ format_MAKE_FUNCTION_arg_3x()

const char* format_MAKE_FUNCTION_arg_3x ( ut32  oparg)

Definition at line 16 of file opcode_arg_fmt.c.

16  {
17  ut32 pos_args = oparg & 0xFF;
18  ut32 name_default = (oparg >> 8) & 0xFF;
19  ut32 annotate_args = (oparg >> 16) & 0x7FFF;
20  return rz_str_newf("%u positional, %u name and default, %u annotations", pos_args, name_default, annotate_args);
21 }

References rz_str_newf().

Referenced by opcode_30(), opcode_31(), opcode_32(), opcode_33(), opcode_34(), and opcode_35().

◆ format_value_flags_36()

const char* format_value_flags_36 ( ut32  oparg)

Definition at line 48 of file opcode_arg_fmt.c.

48  {
49  const char *ret = "";
50  switch (oparg & 0x3) {
51  case 1:
52  ret = "!s";
53  break;
54  case 2:
55  ret = "!r";
56  break;
57  case 3:
58  ret = "!a";
59  break;
60  }
61  if ((oparg & 0x4) == 0x4) {
62  // pop fmt_spec from the stack and use it, else use an
63  // empty fmt_spec.
64  ret = "";
65  }
66  return rz_str_new(ret);
67 }

References rz_str_new().

Referenced by opcode_36(), opcode_37(), opcode_38(), and opcode_39().

◆ free_opcode()

void free_opcode ( pyc_opcodes opcodes)

Definition at line 217 of file opcode.c.

217  {
218  size_t i;
219  if (opcodes == NULL || opcodes->opcodes == NULL) {
220  return;
221  }
222  for (i = 0; i < 256; i++) {
223  if (opcodes->opcodes[i].op_name) {
224  free(opcodes->opcodes[i].op_name);
225  }
226  }
227  free(opcodes->opcodes);
228  if (opcodes->opcode_arg_fmt) {
229  rz_list_free(opcodes->opcode_arg_fmt);
230  }
231  free(opcodes);
232 }
OPCODE_DESC opcodes[]
Definition: avr_esil.c:1270
#define NULL
Definition: cris-opc.c:27
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137

References free(), i, NULL, opcodes, and rz_list_free().

Referenced by finish(), and pyc_op().

◆ free_opN()

void() free_opN ( struct op_parameter  par)

Definition at line 265 of file opcode.c.

265  {
266  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
267  par.op_obj[par.op_code].type |= HASFREE;
268 }

References def_op, HASFREE, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ get_opcode_by_version()

pyc_opcodes* get_opcode_by_version ( char *  version)

Definition at line 169 of file opcode.c.

169  {
170  if (version == NULL) {
171  return NULL;
172  }
173  version_opcode *vop = version_op;
174 
175  while (vop->version) {
176  if (!strcmp(vop->version, version)) {
177  return vop->opcode_func();
178  }
179  vop++;
180  }
181 
182  return NULL; // No match version
183 }
static version_opcode version_op[]
Definition: opcode.c:6
pyc_opcodes *(* opcode_func)()
Definition: opcode.h:61
char * version
Definition: opcode.h:60

References NULL, version_opcode::opcode_func, version_opcode::version, and version_op.

Referenced by disassemble(), and pyc_op().

◆ jabs_opN()

void() jabs_opN ( struct op_parameter  par)

Definition at line 306 of file opcode.c.

306  {
307  def_op00(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push, .fallthrough = par.fallthrough);
308  par.op_obj[par.op_code].type |= HASJABS;
309  if (par.conditional) {
310  par.op_obj[par.op_code].type |= HASCONDITION;
311  }
312 }
#define def_op00(...)
Definition: opcode.h:129
bool conditional
Definition: opcode.h:123

References def_op00, HASCONDITION, HASJABS, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ jrel_opN()

void() jrel_opN ( struct op_parameter  par)

Definition at line 314 of file opcode.c.

314  {
315  def_op00(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push, .fallthrough = par.fallthrough);
316  par.op_obj[par.op_code].type |= HASJREL;
317  if (par.conditional) {
318  par.op_obj[par.op_code].type |= HASCONDITION;
319  }
320 }

References def_op00, HASCONDITION, HASJREL, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ local_opN()

void() local_opN ( struct op_parameter  par)

Definition at line 260 of file opcode.c.

260  {
261  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
262  par.op_obj[par.op_code].type |= HASLOCAL;
263 }

References def_op, HASLOCAL, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ name_opN()

void() name_opN ( struct op_parameter  par)

Definition at line 255 of file opcode.c.

255  {
256  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
257  par.op_obj[par.op_code].type |= HASNAME;
258 }

References def_op, HASNAME, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ nargs_op()

void() nargs_op ( struct op_parameter  par)

Definition at line 322 of file opcode.c.

322  {
323  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
324  par.op_obj[par.op_code].type |= HASNARGS;
325 }

References def_op, HASNARGS, pyc_opcode_object::op_name, and op_parameter::op_obj.

◆ new_pyc_opcodes()

pyc_opcodes* new_pyc_opcodes ( )

Definition at line 185 of file opcode.c.

185  {
186  size_t i, j;
188  if (!ret) {
189  return NULL;
190  }
191  ret->have_argument = 90;
192  ret->opcodes = malloc(sizeof(pyc_opcode_object) * 256);
193  if (!ret->opcodes) {
194  free(ret);
195  return NULL;
196  }
197  for (i = 0; i < 256; i++) {
198  ret->opcodes[i].op_name = rz_str_newf("<%zu>", i);
199  if (!ret->opcodes[i].op_name) {
200  for (j = 0; j < i; j++) {
201  free(ret->opcodes[j].op_name);
202  }
203  free(ret->opcodes);
204  RZ_FREE(ret);
205  return NULL;
206  }
207  ret->opcodes[i].type = 0;
208  ret->opcodes[i].op_code = i;
209  ret->opcodes[i].op_push = 0;
210  ret->opcodes[i].op_pop = 0;
211  }
212 
214  return ret;
215 }
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
void * malloc(size_t size)
Definition: malloc.c:123
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_FREE(x)
Definition: rz_types.h:369
ut8 have_argument
Definition: opcode.h:47
pyc_opcode_object * opcodes
Definition: opcode.h:51

References free(), pyc_opcodes::have_argument, i, malloc(), NULL, pyc_opcode_object::op_code, pyc_opcode_object::op_name, pyc_opcode_object::op_pop, pyc_opcode_object::op_push, pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, RZ_FREE, rz_list_newf(), RZ_NEW0, rz_str_newf(), and pyc_opcode_object::type.

Referenced by opcode_15(), opcode_2x(), and opcode_3x().

◆ opcode_10()

pyc_opcodes* opcode_10 ( void  )

Definition at line 6 of file opcode_10.c.

6  {
7  pyc_opcodes *ret = opcode_11();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_10;
13 
14  // 1.0 - 1.1 bytecodes differences
15  rm_op(.op_obj = ret->opcodes, .op_name = "LOAD_GLOBALS", .op_code = 84);
16  rm_op(.op_obj = ret->opcodes, .op_name = "EXEC_STMT", .op_code = 85);
17 
19  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
20 
21  return ret;
22 }
RZ_API void rz_list_purge(RZ_NONNULL RzList *list)
Empties the list without freeing the list pointer.
Definition: list.c:120
void add_arg_fmt(pyc_opcodes *ret, char *op_name, const char *(*formatter)(ut32 oparg))
Definition: opcode.c:234
pyc_opcodes * opcode_10(void)
Definition: opcode_10.c:6
const char * format_extended_arg(ut32 oparg)
Definition: opcode_arg_fmt.c:6
pyc_opcodes * opcode_11(void)
Definition: opcode_11.c:6
#define rm_op(...)
Definition: opcode.h:175
void *(* version_sig)()
Definition: opcode.h:49

References add_arg_fmt(), format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_10(), opcode_11(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_10().

◆ opcode_11()

pyc_opcodes* opcode_11 ( void  )

Definition at line 6 of file opcode_11.c.

6  {
7  pyc_opcodes *ret = opcode_13();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_11;
13 
15  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
16 
17  return ret;
18 }
pyc_opcodes * opcode_11(void)
Definition: opcode_11.c:6
pyc_opcodes * opcode_13(void)
Definition: opcode_13.c:6

References add_arg_fmt(), format_extended_arg(), NULL, opcode_11(), opcode_13(), pyc_opcodes::opcode_arg_fmt, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_10(), and opcode_11().

◆ opcode_12()

pyc_opcodes* opcode_12 ( void  )

Definition at line 6 of file opcode_12.c.

6  {
7  pyc_opcodes *ret = opcode_13();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_12;
13 
15  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
16 
17  return ret;
18 }
pyc_opcodes * opcode_12(void)
Definition: opcode_12.c:6

References add_arg_fmt(), format_extended_arg(), NULL, opcode_12(), opcode_13(), pyc_opcodes::opcode_arg_fmt, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_12().

◆ opcode_13()

pyc_opcodes* opcode_13 ( void  )

Definition at line 6 of file opcode_13.c.

6  {
7  pyc_opcodes *ret = opcode_14();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_13;
13 
14  // 1.3 - 1.4 bytecodes differences
15  rm_op(.op_obj = ret->opcodes, .op_name = "BINARY_POWER", .op_code = 19);
16  def_op(.op_obj = ret->opcodes, .op_name = "LOAD_GLOBALS", .op_code = 84);
17 
19  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
20 
21  return ret;
22 }
pyc_opcodes * opcode_13(void)
Definition: opcode_13.c:6
pyc_opcodes * opcode_14(void)
Definition: opcode_14.c:6

References add_arg_fmt(), def_op, format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_13(), opcode_14(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_11(), opcode_12(), and opcode_13().

◆ opcode_14()

pyc_opcodes* opcode_14 ( void  )

Definition at line 6 of file opcode_14.c.

6  {
7  pyc_opcodes *ret = opcode_15();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_14;
13 
14  // 1.4 Bytecodes not in 1.5
15  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_CALL", .op_code = 14);
16  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_CALL", .op_code = 26);
17  def_op(.op_obj = ret->opcodes, .op_name = "RAISE_EXCEPTION", .op_code = 81);
18  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_FUNCTION", .op_code = 86);
19  varargs_op(.op_obj = ret->opcodes, .op_name = "UNPACK_ARG", .op_code = 94); // Number of arguments expected
20  varargs_op(.op_obj = ret->opcodes, .op_name = "UNPACK_VARARG", .op_code = 99); // Minimal number of arguments
21  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_LOCAL", .op_code = 115);
22  varargs_op(.op_obj = ret->opcodes, .op_name = "SET_FUNC_ARGS", .op_code = 117); // Argcount
23  varargs_op(.op_obj = ret->opcodes, .op_name = "RESERVE_FAST", .op_code = 123); // Number of local variables
24 
26  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
27 
28  return ret;
29 }
pyc_opcodes * opcode_14(void)
Definition: opcode_14.c:6
pyc_opcodes * opcode_15(void)
Definition: opcode_15.c:6
#define varargs_op(...)
Definition: opcode.h:149
#define name_op(...)
Definition: opcode.h:133

References add_arg_fmt(), def_op, format_extended_arg(), name_op, NULL, pyc_opcode_object::op_name, opcode_14(), opcode_15(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), varargs_op, and pyc_opcodes::version_sig.

Referenced by opcode_13(), and opcode_14().

◆ opcode_15()

pyc_opcodes* opcode_15 ( void  )

Definition at line 6 of file opcode_15.c.

6  {
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_15;
13 
14  def_opN((struct op_parameter){ .op_obj = ret->opcodes, .op_name = "STOP_CODE", .op_code = 0, .pop = 0, .push = 0, .fallthrough = false });
15  def_op(.op_obj = ret->opcodes, .op_name = "POP_TOP", .op_code = 1);
16  def_op(.op_obj = ret->opcodes, .op_name = "ROT_TWO", .op_code = 2);
17  def_op(.op_obj = ret->opcodes, .op_name = "ROT_THREE", .op_code = 3);
18  def_op(.op_obj = ret->opcodes, .op_name = "DUP_TOP", .op_code = 4);
19 
20  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_POSITIVE", .op_code = 10, .pop = 1, .push = 1);
21  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_NEGATIVE", .op_code = 11, .pop = 1, .push = 1);
22  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_NOT", .op_code = 12, .pop = 1, .push = 1);
23  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_CONVERT", .op_code = 13, .pop = 1, .push = 1);
24 
25  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_INVERT", .op_code = 15, .pop = 1, .push = 1);
26 
27  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_POWER", .op_code = 19, .pop = 1, .push = 1);
28  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_MULTIPLY", .op_code = 20, .pop = 2, .push = 1);
29  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_DIVIDE", .op_code = 21, .pop = 2, .push = 1);
30  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_MODULO", .op_code = 22, .pop = 2, .push = 1);
31  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_ADD", .op_code = 23, .pop = 2, .push = 1);
32  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_SUBTRACT", .op_code = 24, .pop = 2, .push = 1);
33  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_SUBSCR", .op_code = 25, .pop = 2, .push = 1);
34 
35  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_0", .op_code = 30, .pop = 1, .push = 1);
36  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_1", .op_code = 31, .pop = 2, .push = 1);
37  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_2", .op_code = 32, .pop = 2, .push = 1);
38  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_3", .op_code = 33, .pop = 3, .push = 1);
39 
40  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_0", .op_code = 40, .pop = 2, .push = 0);
41  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_1", .op_code = 41, .pop = 3, .push = 0);
42  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_2", .op_code = 42, .pop = 3, .push = 0);
43  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_3", .op_code = 43, .pop = 4, .push = 0);
44 
45  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_0", .op_code = 50, .pop = 1, .push = 0);
46  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_1", .op_code = 51, .pop = 2, .push = 0);
47  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_2", .op_code = 52, .pop = 2, .push = 0);
48  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_3", .op_code = 53, .pop = 3, .push = 0);
49 
50  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SUBSCR", .op_code = 60, .pop = 3, .push = 0); // Implements TOS1[TOS] = TOS2.
51  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SUBSCR", .op_code = 61, .pop = 2, .push = 0); // Implements del TOS1[TOS].
52 
53  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_LSHIFT", .op_code = 62, .pop = 2, .push = 1);
54  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_RSHIFT", .op_code = 63, .pop = 2, .push = 1);
55  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_AND", .op_code = 64, .pop = 2, .push = 1);
56  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_XOR", .op_code = 65, .pop = 2, .push = 1);
57  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_OR", .op_code = 66, .pop = 2, .push = 1);
58 
59  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_EXPR", .op_code = 70, .pop = 1, .push = 0);
60  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_ITEM", .op_code = 71, .pop = 1, .push = 0);
61  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_NEWLINE", .op_code = 72, .pop = 1, .push = 0);
62 
63  def_op(.op_obj = ret->opcodes, .op_name = "BREAK_LOOP", .op_code = 80, .pop = 0, .push = 0);
64 
65  def_op(.op_obj = ret->opcodes, .op_name = "LOAD_LOCALS", .op_code = 82, .pop = 0, .push = 1);
66  def_op00(.op_obj = ret->opcodes, .op_name = "RETURN_VALUE", .op_code = 83, .pop = 1, .push = 0, .fallthrough = false);
67 
68  def_op(.op_obj = ret->opcodes, .op_name = "EXEC_STMT", .op_code = 85, .pop = 3, .push = 0);
69 
70  def_op(.op_obj = ret->opcodes, .op_name = "POP_BLOCK", .op_code = 87, .pop = 0, .push = 0);
71  def_op(.op_obj = ret->opcodes, .op_name = "END_FINALLY", .op_code = 88, .pop = 1, .push = 0);
72  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_CLASS", .op_code = 89, .pop = 3, .push = 0);
73 
74  ret->have_argument = 90; // Opcodes from here have an argument:
75 
76  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_NAME", .op_code = 90, .pop = 1, .push = 0, .func = NAME_OP); // Operand is in name list
77  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_NAME", .op_code = 91, .pop = 0, .push = 0); // ""
78  varargs_op(.op_obj = ret->opcodes, .op_name = "UNPACK_TUPLE", .op_code = 92); // Number of tuple items
79  def_op(.op_obj = ret->opcodes, .op_name = "UNPACK_LIST", .op_code = 93); // Number of list items
80  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_ATTR", .op_code = 95, .pop = 2, .push = 0, .func = NAME_OP); // Operand is in name list
81  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_ATTR", .op_code = 96, .pop = 1, .push = 0); // ""
82  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_GLOBAL", .op_code = 97, .pop = 1, .push = 0, .func = NAME_OP); // ""
83  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_GLOBAL", .op_code = 98, .pop = 0, .push = 0); // ""
84 
85  const_op00(.op_obj = ret->opcodes, .op_name = "LOAD_CONST", .op_code = 100, .pop = 0, .push = 1); // Operand is in const list
86  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_NAME", .op_code = 101, .pop = 0, .push = 1); // Operand is in name list
87  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_TUPLE", .op_code = 102, .pop = -1, .push = 1); // Number of tuple items
88  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_LIST", .op_code = 103, .pop = -1, .push = 1); // Number of list items
89  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP", .op_code = 104, .pop = -1, .push = 1); // Always zero for now
90  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_ATTR", .op_code = 105, .pop = 1, .push = 1); // Operand is in name list
91  compare_op(.op_obj = ret->opcodes, .op_name = "COMPARE_OP", .op_code = 106, .pop = 2, .push = 1); // Comparison operator
92 
93  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_NAME", .op_code = 107, .pop = 2, .push = 1); // Operand is in name list
94  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_FROM", .op_code = 108, .pop = 0, .push = 1); // Operand is in name list
95 
96  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_FORWARD", .op_code = 110, .pop = 0, .push = 0); // Number of bytes to skip
97  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE", .op_code = 111, .pop = 1, .push = 1, .conditional = true); // ""
98  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE", .op_code = 112, .pop = 1, .push = 1, .conditional = true); // ""
99  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_ABSOLUTE", .op_code = 113, .pop = 0, .push = 0); // Target byte offset from beginning of code
100  def_op(.op_obj = ret->opcodes, .op_name = "FOR_LOOP", .op_code = 114); // Number of bytes to skip
101 
102  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_GLOBAL", .op_code = 116, .pop = 0, .push = 1); // Operand is in name list
103 
104  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_LOOP", .op_code = 120, .pop = 0, .push = 0, .conditional = true); // Distance to target address
105  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_EXCEPT", .op_code = 121, .pop = 0, .push = 0, .conditional = true); // ""
106  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_FINALLY", .op_code = 122, .pop = 0, .push = 0, .conditional = true); // ""
107 
108  local_op(.op_obj = ret->opcodes, .op_name = "LOAD_FAST", .op_code = 124, .pop = 0, .push = 1); // Local variable number
109  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_FAST", .op_code = 125, .pop = 1, .push = 0, .func = LOCAL_OP); // Local variable number
110  local_op0(.op_obj = ret->opcodes, .op_name = "DELETE_FAST", .op_code = 126); // Local variable number
111 
112  def_op(.op_obj = ret->opcodes, .op_name = "SET_LINENO", .op_code = 127); // Current line number
113 
114  def_op00(.op_obj = ret->opcodes, .op_name = "RAISE_VARARGS", .op_code = 130, .pop = -1, .push = 0, .fallthrough = false);
115  // Number of raise arguments (1, 2, or 3)
116  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION", .op_code = 131, .pop = -1, .push = 1); // //args + (//kwargs << 8)
117 
118  def_op(.op_obj = ret->opcodes, .op_name = "MAKE_FUNCTION", .op_code = 132, .pop = -1, .push = 1); // Number of args with default values
119  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_SLICE", .op_code = 133, .pop = -1, .push = 1); // Number of items
120 
121  def_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", .op_code = 143);
122  ret->extended_arg = 143;
123 
125  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
126 
127  return ret;
128 }
pyc_opcodes * new_pyc_opcodes()
Definition: opcode.c:185
void() def_opN(struct op_parameter par)
Definition: opcode.c:244
pyc_opcodes * opcode_15(void)
Definition: opcode_15.c:6
#define nargs_op(...)
Definition: opcode.h:171
#define store_op(...)
Definition: opcode.h:145
#define jabs_op(...)
Definition: opcode.h:163
#define local_op(...)
Definition: opcode.h:137
#define const_op00(...)
Definition: opcode.h:154
#define local_op0(...)
Definition: opcode.h:136
#define compare_op(...)
Definition: opcode.h:158
#define store_op00(...)
Definition: opcode.h:144
#define jrel_op(...)
Definition: opcode.h:168
ut8 extended_arg
Definition: opcode.h:46

References add_arg_fmt(), compare_op, const_op00, def_op, def_op00, def_opN(), pyc_opcodes::extended_arg, format_extended_arg(), pyc_opcodes::have_argument, jabs_op, jrel_op, LOCAL_OP, local_op, local_op0, NAME_OP, name_op, nargs_op, new_pyc_opcodes(), NULL, pyc_opcode_object::op_name, opcode_15(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), store_op, store_op00, varargs_op, and pyc_opcodes::version_sig.

Referenced by opcode_14(), opcode_15(), and opcode_16().

◆ opcode_16()

pyc_opcodes* opcode_16 ( void  )

Definition at line 6 of file opcode_16.c.

6  {
7  pyc_opcodes *ret = opcode_15();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_16;
13 
14  // 1.6 Bytecodes not in 1.5
15  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR", .op_code = 140, .pop = -1, .push = 1); // #args + (#kwargs << 8)
16  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_KW", .op_code = 141, .pop = -1, .push = 1); // #args + (#kwargs << 8)
17  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR_KW", .op_code = 142, .pop = -1, .push = 1); // #args + (#kwargs << 8)
18 
20  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
21 
22  return ret;
23 }
pyc_opcodes * opcode_16(void)
Definition: opcode_16.c:6

References add_arg_fmt(), format_extended_arg(), nargs_op, NULL, pyc_opcode_object::op_name, opcode_15(), opcode_16(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_16().

◆ opcode_20()

pyc_opcodes* opcode_20 ( void  )

Definition at line 6 of file opcode_20.c.

6  {
7  pyc_opcodes *ret = opcode_21();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_20;
13 
14  // 2.1 Bytecodes not in 2.0
15  rm_op(.op_obj = ret->opcodes, .op_name = "CONTINUE_LOOP", .op_code = 119);
16  rm_op(.op_obj = ret->opcodes, .op_name = "MAKE_CLOSURE", .op_code = 134);
17  rm_op(.op_obj = ret->opcodes, .op_name = "LOAD_CLOSURE", .op_code = 135);
18  rm_op(.op_obj = ret->opcodes, .op_name = "LOAD_DEREF", .op_code = 136);
19  rm_op(.op_obj = ret->opcodes, .op_name = "STORE_DEREF", .op_code = 137);
20 
22  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
23 
24  return ret;
25 }
pyc_opcodes * opcode_20(void)
Definition: opcode_20.c:6
pyc_opcodes * opcode_21(void)
Definition: opcode_21.c:6

References add_arg_fmt(), format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_20(), opcode_21(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_20().

◆ opcode_21()

pyc_opcodes* opcode_21 ( void  )

Definition at line 6 of file opcode_21.c.

6  {
7  pyc_opcodes *ret = opcode_22();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_21;
13 
14  // 2.1 bytecodes changes from 2.2
15  rm_op(.op_obj = ret->opcodes, .op_name = "BINARY_FLOOR_DIVIDE", .op_code = 26);
16  rm_op(.op_obj = ret->opcodes, .op_name = "BINARY_TRUE_DIVIDE", .op_code = 27);
17  rm_op(.op_obj = ret->opcodes, .op_name = "INPLACE_FLOOR_DIVIDE", .op_code = 28);
18  rm_op(.op_obj = ret->opcodes, .op_name = "INPLACE_TRUE_DIVIDE", .op_code = 29);
19  rm_op(.op_obj = ret->opcodes, .op_name = "GET_ITER", .op_code = 68);
20  rm_op(.op_obj = ret->opcodes, .op_name = "YIELD_VALUE", .op_code = 86);
21  rm_op(.op_obj = ret->opcodes, .op_name = "FOR_ITER", .op_code = 93);
22 
24  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
25 
26  return ret;
27 }
pyc_opcodes * opcode_21(void)
Definition: opcode_21.c:6
pyc_opcodes * opcode_22(void)
Definition: opcode_22.c:6

References add_arg_fmt(), format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_21(), opcode_22(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_20(), and opcode_21().

◆ opcode_22()

pyc_opcodes* opcode_22 ( void  )

Definition at line 6 of file opcode_22.c.

6  {
7  pyc_opcodes *ret = opcode_2x();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_22;
13 
14  // 2.2 Bytecodes not in 2.3
15  def_op(.op_obj = ret->opcodes, .op_name = "FOR_LOOP", .op_code = 114);
16  def_op(.op_obj = ret->opcodes, .op_name = "SET_LINENO", .op_code = 127, .pop = 0, .push = 0);
17 
19  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
20 
21  return ret;
22 }
pyc_opcodes * opcode_22(void)
Definition: opcode_22.c:6
pyc_opcodes * opcode_2x(void)
Definition: opcode_2x.c:6

References add_arg_fmt(), def_op, format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_22(), opcode_2x(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_21(), and opcode_22().

◆ opcode_23()

pyc_opcodes* opcode_23 ( void  )

Definition at line 6 of file opcode_23.c.

6  {
7  pyc_opcodes *ret = opcode_2x();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_23;
13 
15  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
16 
17  return ret;
18 }
pyc_opcodes * opcode_23(void)
Definition: opcode_23.c:6

References add_arg_fmt(), format_extended_arg(), NULL, opcode_23(), opcode_2x(), pyc_opcodes::opcode_arg_fmt, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_23().

◆ opcode_24()

pyc_opcodes* opcode_24 ( void  )

Definition at line 6 of file opcode_24.c.

6  {
7  pyc_opcodes *ret = opcode_2x();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_24;
13 
14  // Bytecodes added since 2.3
15  def_op(.op_obj = ret->opcodes, .op_name = "NOP", .op_code = 9, .pop = 0, .push = 0);
16  def_op(.op_obj = ret->opcodes, .op_name = "LIST_APPEND", .op_code = 18, .pop = 2, .push = 1); // Calls list.append(TOS[-i], TOS).
17  // Used to implement list comprehensions.
18  def_op(.op_obj = ret->opcodes, .op_name = "YIELD_VALUE", .op_code = 86, .pop = 1, .push = 0);
19 
21  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
22 
23  return ret;
24 }
pyc_opcodes * opcode_24(void)
Definition: opcode_24.c:6

References add_arg_fmt(), def_op, format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_24(), opcode_2x(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_24(), and opcode_25().

◆ opcode_25()

pyc_opcodes* opcode_25 ( void  )

Definition at line 6 of file opcode_25.c.

6  {
7  pyc_opcodes *ret = opcode_24();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_25;
13 
14  // Bytecodes added in 2.5 from 2.4
15  def_op(.op_obj = ret->opcodes, .op_name = "WITH_CLEANUP", .op_code = 81);
16 
18  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
19 
20  return ret;
21 }
pyc_opcodes * opcode_25(void)
Definition: opcode_25.c:6
pyc_opcodes * opcode_24(void)
Definition: opcode_24.c:6

References add_arg_fmt(), def_op, format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_24(), opcode_25(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_25(), and opcode_26().

◆ opcode_26()

pyc_opcodes* opcode_26 ( void  )

Definition at line 6 of file opcode_26.c.

6  {
7  pyc_opcodes *ret = opcode_25();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_26;
13 
14  // Below are opcode changes since Python 2.5
15  store_op(.op_obj = ret->opcodes, .op_name = "STORE_MAP", .op_code = 54, .pop = 3, .push = 1);
16 
18  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
19 
20  return ret;
21 }
pyc_opcodes * opcode_26(void)
Definition: opcode_26.c:6
pyc_opcodes * opcode_25(void)
Definition: opcode_25.c:6

References add_arg_fmt(), format_extended_arg(), NULL, pyc_opcode_object::op_name, opcode_25(), opcode_26(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), store_op, and pyc_opcodes::version_sig.

Referenced by opcode_26(), and opcode_27().

◆ opcode_27()

pyc_opcodes* opcode_27 ( void  )

Definition at line 6 of file opcode_27.c.

6  {
7  pyc_opcodes *ret = opcode_26();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_27;
13 
14  // Below are opcode changes since Python 2.6
15  rm_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP", .op_code = 104);
16  rm_op(.op_obj = ret->opcodes, .op_name = "LOAD_ATTR", .op_code = 105);
17  rm_op(.op_obj = ret->opcodes, .op_name = "COMPARE_OP", .op_code = 106);
18  rm_op(.op_obj = ret->opcodes, .op_name = "IMPORT_NAME", .op_code = 107);
19  rm_op(.op_obj = ret->opcodes, .op_name = "IMPORT_FROM", .op_code = 108);
20  rm_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE", .op_code = 111);
21  rm_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", .op_code = 143);
22  rm_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE", .op_code = 112);
23 
24  def_op(.op_obj = ret->opcodes, .op_name = "LIST_APPEND", .op_code = 94, .pop = 2, .push = 1); // Calls list.append(TOS[-i], TOS).
25  // Used to implement list comprehensions.
26  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_SET", .op_code = 104); // Number of set items
27  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP", .op_code = 105);
28  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_ATTR", .op_code = 106);
29  compare_op(.op_obj = ret->opcodes, .op_name = "COMPARE_OP", .op_code = 107);
30 
31  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_NAME", .op_code = 108, .pop = 2, .push = 1); // Index in name list
32  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_FROM", .op_code = 109, .pop = 0, .push = 1);
33 
34  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE_OR_POP", .op_code = 111, .conditional = true); // Target byte offset from beginning of code
35  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE_OR_POP", .op_code = 112, .conditional = true); // ""
36  jabs_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_FALSE", .op_code = 114, .conditional = true); // ""
37  jabs_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_TRUE", .op_code = 115, .conditional = true); // ""
38  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_WITH", .op_code = 143, .pop = 0, .push = 2);
39 
40  def_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", .op_code = 145);
41  def_op(.op_obj = ret->opcodes, .op_name = "SET_ADD", .op_code = 146, .pop = 1, .push = 0); // Calls set.add(TOS1[-i], TOS).
42  // Used to implement set comprehensions.
43  def_op(.op_obj = ret->opcodes, .op_name = "MAP_ADD", .op_code = 147, .pop = 2, .push = 1); // Calls dict.setitem(TOS1[-i], TOS, TOS1)
44  // Used to implement dict comprehensions.
45 
47  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
49 
50  return ret;
51 }
pyc_opcodes * opcode_27(void)
Definition: opcode_27.c:6
pyc_opcodes * opcode_26(void)
Definition: opcode_26.c:6
const char * format_CALL_FUNCTION_pos_name_encoded(ut32 oparg)

References add_arg_fmt(), compare_op, def_op, format_CALL_FUNCTION_pos_name_encoded(), format_extended_arg(), jabs_op, jrel_op, name_op, NULL, pyc_opcode_object::op_name, opcode_26(), opcode_27(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_27().

◆ opcode_2x()

pyc_opcodes* opcode_2x ( void  )

Definition at line 6 of file opcode_2x.c.

6  {
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_2x;
13 
14  def_op00(.op_obj = ret->opcodes, .op_name = "STOP_CODE", .op_code = 0, .pop = 0, .push = 0, .fallthrough = false);
15  def_op(.op_obj = ret->opcodes, .op_name = "POP_TOP", .op_code = 1, .pop = 1, .push = 0);
16  def_op(.op_obj = ret->opcodes, .op_name = "ROT_TWO", .op_code = 2, .pop = 2, .push = 2);
17  def_op(.op_obj = ret->opcodes, .op_name = "ROT_THREE", .op_code = 3, .pop = 3, .push = 3);
18  def_op(.op_obj = ret->opcodes, .op_name = "DUP_TOP", .op_code = 4, .pop = 0, .push = 1);
19  def_op(.op_obj = ret->opcodes, .op_name = "ROT_FOUR", .op_code = 5, .pop = 4, .push = 4);
20 
21  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_POSITIVE", .op_code = 10, .pop = 1, .push = 1);
22  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_NEGATIVE", .op_code = 11, .pop = 1, .push = 1);
23  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_NOT", .op_code = 12, .pop = 1, .push = 1);
24  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_CONVERT", .op_code = 13, .pop = 1, .push = 1);
25 
26  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_INVERT", .op_code = 15, .pop = 1, .push = 1);
27 
28  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_POWER", .op_code = 19, .pop = 2, .push = 1);
29 
30  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_MULTIPLY", .op_code = 20, .pop = 2, .push = 1);
31  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_DIVIDE", .op_code = 21, .pop = 2, .push = 1);
32  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_MODULO", .op_code = 22, .pop = 2, .push = 1);
33  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_ADD", .op_code = 23, .pop = 2, .push = 1);
34  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_SUBTRACT", .op_code = 24, .pop = 2, .push = 1);
35  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_SUBSCR", .op_code = 25, .pop = 2, .push = 1);
36  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_FLOOR_DIVIDE", .op_code = 26, .pop = 2, .push = 1);
37  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_TRUE_DIVIDE", .op_code = 27, .pop = 2, .push = 1);
38  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_FLOOR_DIVIDE", .op_code = 28, .pop = 2, .push = 1);
39  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_TRUE_DIVIDE", .op_code = 29, .pop = 2, .push = 1);
40 
41  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_0", .op_code = 30, .pop = 1, .push = 1);
42  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_1", .op_code = 31, .pop = 2, .push = 1);
43  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_2", .op_code = 32, .pop = 2, .push = 1);
44  def_op(.op_obj = ret->opcodes, .op_name = "SLICE_3", .op_code = 33, .pop = 3, .push = 1);
45 
46  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_0", .op_code = 40, .pop = 2, .push = 0);
47  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_1", .op_code = 41, .pop = 3, .push = 0);
48  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_2", .op_code = 42, .pop = 3, .push = 0);
49  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SLICE_3", .op_code = 43, .pop = 4, .push = 0);
50 
51  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_0", .op_code = 50, .pop = 1, .push = 0);
52  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_1", .op_code = 51, .pop = 2, .push = 0);
53  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_2", .op_code = 52, .pop = 2, .push = 0);
54  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SLICE_3", .op_code = 53, .pop = 3, .push = 0);
55 
56  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_ADD", .op_code = 55, .pop = 2, .push = 1);
57  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_SUBTRACT", .op_code = 56, .pop = 2, .push = 1);
58  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_MULTIPLY", .op_code = 57, .pop = 2, .push = 1);
59  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_DIVIDE", .op_code = 58, .pop = 2, .push = 1);
60  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_MODULO", .op_code = 59, .pop = 2, .push = 1);
61  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SUBSCR", .op_code = 60, .pop = 3, .push = 0); // Implements TOS1[TOS] = TOS2.
62  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SUBSCR", .op_code = 61, .pop = 2, .push = 0); // Implements del TOS1[TOS].
63 
64  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_LSHIFT", .op_code = 62, .pop = 2, .push = 1);
65  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_RSHIFT", .op_code = 63, .pop = 2, .push = 1);
66  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_AND", .op_code = 64, .pop = 2, .push = 1);
67  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_XOR", .op_code = 65, .pop = 2, .push = 1);
68  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_OR", .op_code = 66, .pop = 2, .push = 1);
69  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_POWER", .op_code = 67, .pop = 2, .push = 1);
70  def_op(.op_obj = ret->opcodes, .op_name = "GET_ITER", .op_code = 68, .pop = 1, .push = 1);
71 
72  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_EXPR", .op_code = 70, .pop = 1, .push = 0);
73  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_ITEM", .op_code = 71, .pop = 1, .push = 0);
74  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_NEWLINE", .op_code = 72, .pop = 1, .push = 0);
75  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_ITEM_TO", .op_code = 73, .pop = 1, .push = 0);
76  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_NEWLINE_TO", .op_code = 74, .pop = 1, .push = 0);
77  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_LSHIFT", .op_code = 75, .pop = 2, .push = 1);
78  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_RSHIFT", .op_code = 76, .pop = 2, .push = 1);
79  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_AND", .op_code = 77, .pop = 2, .push = 1);
80  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_XOR", .op_code = 78, .pop = 2, .push = 1);
81  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_OR", .op_code = 79, .pop = 2, .push = 1);
82  def_op(.op_obj = ret->opcodes, .op_name = "BREAK_LOOP", .op_code = 80, .pop = 0, .push = 0);
83 
84  def_op(.op_obj = ret->opcodes, .op_name = "LOAD_LOCALS", .op_code = 82, .pop = 0, .push = 1);
85  def_op00(.op_obj = ret->opcodes, .op_name = "RETURN_VALUE", .op_code = 83, .pop = 1, .push = 0, .fallthrough = false);
86  def_op(.op_obj = ret->opcodes, .op_name = "IMPORT_STAR", .op_code = 84, .pop = 1, .push = 0);
87  def_op(.op_obj = ret->opcodes, .op_name = "EXEC_STMT", .op_code = 85, .pop = 3, .push = 0);
88  def_op(.op_obj = ret->opcodes, .op_name = "YIELD_VALUE", .op_code = 86, .pop = 1, .push = 1);
89 
90  def_op(.op_obj = ret->opcodes, .op_name = "POP_BLOCK", .op_code = 87, .pop = 0, .push = 0);
91  def_op(.op_obj = ret->opcodes, .op_name = "END_FINALLY", .op_code = 88, .pop = 1, .push = 0);
92  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_CLASS", .op_code = 89, .pop = 3, .push = 0);
93 
94  ret->have_argument = 90; // Opcodes from here have an argument:
95 
96  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_NAME", .op_code = 90, .pop = 1, .push = 0, .func = NAME_OP); // Operand is in name list
97  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_NAME", .op_code = 91, .pop = 0, .push = 0); // ""
98  varargs_op(.op_obj = ret->opcodes, .op_name = "UNPACK_SEQUENCE", .op_code = 92, .pop = 9, .push = 1); // TOS is number of tuple items
99  jrel_op(.op_obj = ret->opcodes, .op_name = "FOR_ITER", .op_code = 93, .pop = 9, .push = 1); // TOS is read
100 
101  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_ATTR", .op_code = 95, .pop = 2, .push = 0, .func = NAME_OP); // Operand is in name list
102  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_ATTR", .op_code = 96, .pop = 1, .push = 0); // ""
103  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_GLOBAL", .op_code = 97, .pop = 1, .push = 0, .func = NAME_OP); // ""
104  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_GLOBAL", .op_code = 98, .pop = 0, .push = 0); // ""
105  def_op(.op_obj = ret->opcodes, .op_name = "DUP_TOPX", .op_code = 99, .pop = 1, .push = -1); // number of items to duplicate
106  const_op00(.op_obj = ret->opcodes, .op_name = "LOAD_CONST", .op_code = 100, .pop = 0, .push = 1); // Operand is in const list
107  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_NAME", .op_code = 101, .pop = 0, .push = 1); // Operand is in name list
108  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_TUPLE", .op_code = 102, .pop = 9, .push = 1); // TOS is number of tuple items
109  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_LIST", .op_code = 103, .pop = 9, .push = 1); // TOS is number of list items
110  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP", .op_code = 104, .pop = 0, .push = 1); // TOS is number of kwark items. Always zero for now
111  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_ATTR", .op_code = 105, .pop = 1, .push = 1); // Operand is in name list
112  compare_op(.op_obj = ret->opcodes, .op_name = "COMPARE_OP", .op_code = 106, .pop = 2, .push = 1); // Comparison operator
113 
114  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_NAME", .op_code = 107, .pop = 2, .push = 1); // Operand is in name list
115  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_FROM", .op_code = 108, .pop = 0, .push = 1); // Operand is in name list
116 
117  jrel_op00(.op_obj = ret->opcodes, .op_name = "JUMP_FORWARD", .op_code = 110, .pop = 0, .push = 0, .fallthrough = false); // Number of bytes to skip
118  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE", .op_code = 111, .pop = 1, .push = 1, .conditional = true); // ""
119 
120  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE", .op_code = 112, .pop = 1, .push = 1, .conditional = true); // ""
121  jabs_op00(.op_obj = ret->opcodes, .op_name = "JUMP_ABSOLUTE", .op_code = 113, .pop = 0, .push = 0, .fallthrough = false); // Target byte offset from beginning of code
122 
123  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_GLOBAL", .op_code = 116, .pop = 0, .push = 1); // Operand is in name list
124 
125  jabs_op00(.op_obj = ret->opcodes, .op_name = "CONTINUE_LOOP", .op_code = 119, .pop = 0, .push = 0, .fallthrough = false); // Target address
126  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_LOOP", .op_code = 120, .pop = 0, .push = 0, .conditional = true); // Distance to target address
127  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_EXCEPT", .op_code = 121, .pop = 0, .push = 6, .conditional = true); // ""
128  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_FINALLY", .op_code = 122, .pop = 0, .push = 7, .conditional = true); // ""
129 
130  local_op(.op_obj = ret->opcodes, .op_name = "LOAD_FAST", .op_code = 124, .pop = 0, .push = 1); // Local variable number
131  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_FAST", .op_code = 125, .pop = 1, .push = 0, .func = LOCAL_OP); // Local variable number
132  local_op(.op_obj = ret->opcodes, .op_name = "DELETE_FAST", .op_code = 126); // Local variable number
133 
134  def_op00(.op_obj = ret->opcodes, .op_name = "RAISE_VARARGS", .op_code = 130, .pop = 1, .push = 0, .fallthrough = false); // Number of raise arguments (1, 2, or 3)
135  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION", .op_code = 131, .pop = 9, .push = 1); // TOS is //args + (//kwargs << 8)
136 
137  def_op(.op_obj = ret->opcodes, .op_name = "MAKE_FUNCTION", .op_code = 132, .pop = 9, .push = 1); // TOS is number of args with default values
138  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_SLICE", .op_code = 133, .pop = 9, .push = 1); // TOS is number of items
139 
140  def_op(.op_obj = ret->opcodes, .op_name = "MAKE_CLOSURE", .op_code = 134, .pop = 9, .push = 1);
141  free_op(.op_obj = ret->opcodes, .op_name = "LOAD_CLOSURE", .op_code = 135, .pop = 0, .push = 1);
142  free_op(.op_obj = ret->opcodes, .op_name = "LOAD_DEREF", .op_code = 136, .pop = 0, .push = 1);
143  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_DEREF", .op_code = 137, .pop = 1, .push = 0, .func = FREE_OP);
144 
145  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR", .op_code = 140, .pop = -1, .push = 1); // #args + (#kwargs << 8)
146  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_KW", .op_code = 141, .pop = -1, .push = 1); // #args + (#kwargs << 8)
147  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR_KW", .op_code = 142, .pop = -1, .push = 1); // #args + (#kwargs << 8)
148 
149  def_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", 143);
150  ret->extended_arg = 143;
151 
153 
154  return ret;
155 }
pyc_opcodes * opcode_2x(void)
Definition: opcode_2x.c:6
#define free_op(...)
Definition: opcode.h:141
#define jrel_op00(...)
Definition: opcode.h:166
#define jabs_op00(...)
Definition: opcode.h:161

References compare_op, const_op00, def_op, def_op00, pyc_opcodes::extended_arg, FREE_OP, free_op, pyc_opcodes::have_argument, jabs_op00, jrel_op, jrel_op00, LOCAL_OP, local_op, NAME_OP, name_op, nargs_op, new_pyc_opcodes(), NULL, pyc_opcode_object::op_name, opcode_2x(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), store_op, store_op00, varargs_op, and pyc_opcodes::version_sig.

Referenced by opcode_22(), opcode_23(), opcode_24(), and opcode_2x().

◆ opcode_30()

pyc_opcodes* opcode_30 ( void  )

Definition at line 6 of file opcode_30.c.

6  {
7  pyc_opcodes *ret = opcode_31();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_30;
13 
14  // These are in Python 3.x but not in Python 3.0
15 
16  rm_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE_OR_POP", .op_code = 111);
17  rm_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE_OR_POP", .op_code = 112);
18  rm_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_FALSE", .op_code = 114);
19  rm_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_TRUE", .op_code = 115);
20  rm_op(.op_obj = ret->opcodes, .op_name = "LIST_APPEND", .op_code = 145);
21  rm_op(.op_obj = ret->opcodes, .op_name = "MAP_ADD", .op_code = 147);
22 
23  // These are are in 3.0 but are not in 3.1 or they have
24  // different opcode numbers. Note: As a result of opcode value
25  // changes, these have to be applied *after* removing ops (with
26  // the same name).
27 
28  def_op(.op_obj = ret->opcodes, .op_name = "SET_ADD", .op_code = 17, .pop = 1, .push = 0);
29  def_op(.op_obj = ret->opcodes, .op_name = "LIST_APPEND", .op_code = 18, .pop = 2, .push = 1);
30 
31  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE", .op_code = 111, .pop = 1, .push = 1, .conditional = true);
32  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE", .op_code = 112, .pop = 1, .push = 1, .conditional = true);
33 
35  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
36  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_3x);
37 
38  return ret;
39 }
pyc_opcodes * opcode_30(void)
Definition: opcode_30.c:6
const char * format_MAKE_FUNCTION_arg_3x(ut32 oparg)
pyc_opcodes * opcode_31(void)
Definition: opcode_31.c:6

References add_arg_fmt(), def_op, format_extended_arg(), format_MAKE_FUNCTION_arg_3x(), jrel_op, NULL, pyc_opcode_object::op_name, opcode_30(), opcode_31(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_30().

◆ opcode_31()

pyc_opcodes* opcode_31 ( void  )

Definition at line 6 of file opcode_31.c.

6  {
7  pyc_opcodes *ret = opcode_32();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_31;
13 
14  // These are in Python 3.2 but not in Python 3.1
15  rm_op(.op_obj = ret->opcodes, .op_name = "DUP_TOP_TWO", .op_code = 5);
16  rm_op(.op_obj = ret->opcodes, .op_name = "DELETE_DEREF", .op_code = 138);
17  rm_op(.op_obj = ret->opcodes, .op_name = "SETUP_WITH", .op_code = 143);
18 
19  // These are in Python 3.1 but not Python 3.2
20  def_op(.op_obj = ret->opcodes, .op_name = "ROT_FOUR", .op_code = 5);
21  def_op(.op_obj = ret->opcodes, .op_name = "DUP_TOPX", .op_code = 99);
22 
23  // This op is in 3.2 but its opcode is a 144 instead
24  def_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", .op_code = 143);
25 
27  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
28  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_3x);
29 
30  return ret;
31 }
pyc_opcodes * opcode_31(void)
Definition: opcode_31.c:6
pyc_opcodes * opcode_32(void)
Definition: opcode_32.c:6

References add_arg_fmt(), def_op, format_extended_arg(), format_MAKE_FUNCTION_arg_3x(), NULL, pyc_opcode_object::op_name, opcode_31(), opcode_32(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_30(), and opcode_31().

◆ opcode_32()

pyc_opcodes* opcode_32 ( void  )

Definition at line 6 of file opcode_32.c.

6  {
7  pyc_opcodes *ret = opcode_3x();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_32;
13 
14  // There are no opcodes to add or change.
15  // If there were, they'd be listed below.
16 
18  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
19  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_3x);
20 
21  return ret;
22 }
pyc_opcodes * opcode_32(void)
Definition: opcode_32.c:6
pyc_opcodes * opcode_3x(void)
Definition: opcode_3x.c:6

References add_arg_fmt(), format_extended_arg(), format_MAKE_FUNCTION_arg_3x(), NULL, opcode_32(), opcode_3x(), pyc_opcodes::opcode_arg_fmt, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_31(), and opcode_32().

◆ opcode_33()

pyc_opcodes* opcode_33 ( void  )

Definition at line 6 of file opcode_33.c.

6  {
7  pyc_opcodes *ret = opcode_3x();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_33;
13 
14  // Below are opcode changes since Python 3.2
15 
16  rm_op(.op_obj = ret->opcodes, .op_name = "STOP_CODE", .op_code = 0);
17  def_op(.op_obj = ret->opcodes, .op_name = "YIELD_FROM", .op_code = 72, .pop = 1, .push = 0);
18 
20  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
21  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_3x);
22 
23  return ret;
24 }
pyc_opcodes * opcode_33(void)
Definition: opcode_33.c:6

References add_arg_fmt(), def_op, format_extended_arg(), format_MAKE_FUNCTION_arg_3x(), NULL, pyc_opcode_object::op_name, opcode_33(), opcode_3x(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_33(), and opcode_34().

◆ opcode_34()

pyc_opcodes* opcode_34 ( void  )

Definition at line 6 of file opcode_34.c.

6  {
7  pyc_opcodes *ret = opcode_33();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_34;
13 
14  // These are removed since Python 3.3
15  rm_op(.op_obj = ret->opcodes, .op_name = "STORE_LOCALS", .op_code = 69);
16 
17  // These are new since Python 3.3
18  def_op(.op_obj = ret->opcodes, .op_name = "YIELD_FROM", .op_code = 72);
19  free_op(.op_obj = ret->opcodes, .op_name = "LOAD_CLASSDEREF", .op_code = 148);
20 
22  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
23  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_3x);
24 
25  return ret;
26 }
pyc_opcodes * opcode_34(void)
Definition: opcode_34.c:6
pyc_opcodes * opcode_33(void)
Definition: opcode_33.c:6

References add_arg_fmt(), def_op, format_extended_arg(), format_MAKE_FUNCTION_arg_3x(), free_op, NULL, pyc_opcode_object::op_name, opcode_33(), opcode_34(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_34(), and opcode_35().

◆ opcode_35()

pyc_opcodes* opcode_35 ( void  )

Definition at line 6 of file opcode_35.c.

6  {
7  pyc_opcodes *ret = opcode_34();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_35;
13 
14  // These are removed since Python 3.5.
15  // Removals happen before adds since
16  // some opcodes are reused
17  rm_op(.op_obj = ret->opcodes, .op_name = "STORE_MAP", .op_code = 54);
18  rm_op(.op_obj = ret->opcodes, .op_name = "WITH_CLEANUP", .op_code = 81);
19 
20  // These are new since Python 3.5
21  // OP NAME OPCODE POP PUSH
22  //---------------------------------------------------
23  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_MATRIX_MULTIPLY", .op_code = 16, .pop = 2, .push = 1);
24  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_MATRIX_MULTIPLY", .op_code = 17, .pop = 2, .push = 1);
25  def_op(.op_obj = ret->opcodes, .op_name = "GET_AITER", .op_code = 50, .pop = 1, .push = 1);
26  def_op(.op_obj = ret->opcodes, .op_name = "GET_ANEXT", .op_code = 51, .pop = 0, .push = 1);
27  def_op(.op_obj = ret->opcodes, .op_name = "BEFORE_ASYNC_WITH", .op_code = 52);
28  def_op(.op_obj = ret->opcodes, .op_name = "GET_YIELD_FROM_ITER", .op_code = 69, .pop = 0, .push = 1);
29  def_op(.op_obj = ret->opcodes, .op_name = "GET_AWAITABLE", .op_code = 73, .pop = 0, .push = 0);
30  def_op(.op_obj = ret->opcodes, .op_name = "WITH_CLEANUP_START", .op_code = 81, .pop = 0, .push = 1);
31  def_op(.op_obj = ret->opcodes, .op_name = "WITH_CLEANUP_FINISH", .op_code = 82, .pop = -1, .push = 1);
32 
33  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_LIST_UNPACK", .op_code = 149, .pop = -1, .push = 1);
34  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP_UNPACK", .op_code = 150, .pop = -1, .push = 1);
35  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP_UNPACK_WITH_CALL", .op_code = 151, .pop = -1, .push = 1);
36  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_TUPLE_UNPACK", .op_code = 152, .pop = -1, .push = 1);
37  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_SET_UNPACK", .op_code = 153, .pop = -1, .push = 1);
38 
39  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_ASYNC_WITH", .op_code = 154, .pop = 0, .push = 6);
40 
42  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
43  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_3x);
44 
45  return ret;
46 }
pyc_opcodes * opcode_35(void)
Definition: opcode_35.c:6
pyc_opcodes * opcode_34(void)
Definition: opcode_34.c:6

References add_arg_fmt(), def_op, format_extended_arg(), format_MAKE_FUNCTION_arg_3x(), jrel_op, NULL, pyc_opcode_object::op_name, opcode_34(), opcode_35(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), varargs_op, and pyc_opcodes::version_sig.

Referenced by opcode_35(), and opcode_36().

◆ opcode_36()

pyc_opcodes* opcode_36 ( void  )

Definition at line 6 of file opcode_36.c.

6  {
7  pyc_opcodes *ret = opcode_35();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_36;
13 
14  // These are removed since Python 3.6
15  rm_op(.op_obj = ret->opcodes, .op_name = "MAKE_CLOSURE", .op_code = 134);
16  rm_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR", .op_code = 140);
17  rm_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR_KW", .op_code = 142);
18 
19  // These are new since Python 3.6
20  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_ANNOTATION", .op_code = 127, .func = NAME_OP); // Index in name list
21  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_ASYNC_WITH", .op_code = 154);
22  def_op(.op_obj = ret->opcodes, .op_name = "FORMAT_VALUE", .op_code = 155);
23  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_CONST_KEY_MAP", .op_code = 156, .pop = -1, .push = 1); // TOS is count of kwargs
24  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_EX", .op_code = 142, .pop = -1, .push = 1);
25  def_op(.op_obj = ret->opcodes, .op_name = "SETUP_ANNOTATIONS", .op_code = 85);
26  def_op(.op_obj = ret->opcodes, .op_name = "BUILD_STRING", .op_code = 157);
27  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_TUPLE_UNPACK_WITH_CALL", .op_code = 158);
28 
30  add_arg_fmt(ret, "CALL_FUNCTION_KW", format_CALL_FUNCTION_KW_36);
31  add_arg_fmt(ret, "CALL_FUNCTION_EX", format_CALL_FUNCTION_EX_36);
32  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_36);
33  add_arg_fmt(ret, "FORMAT_VALUE", format_value_flags_36);
34  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg_36);
35 
36  return ret;
37 }
pyc_opcodes * opcode_36(void)
Definition: opcode_36.c:6
const char * format_MAKE_FUNCTION_arg_36(ut32 oparg)
const char * format_CALL_FUNCTION_KW_36(ut32 oparg)
const char * format_extended_arg_36(ut32 oparg)
pyc_opcodes * opcode_35(void)
Definition: opcode_35.c:6
const char * format_CALL_FUNCTION_EX_36(ut32 oparg)
const char * format_value_flags_36(ut32 oparg)

References add_arg_fmt(), def_op, format_CALL_FUNCTION_EX_36(), format_CALL_FUNCTION_KW_36(), format_extended_arg_36(), format_MAKE_FUNCTION_arg_36(), format_value_flags_36(), jrel_op, NAME_OP, nargs_op, NULL, pyc_opcode_object::op_name, opcode_35(), opcode_36(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), store_op00, varargs_op, and pyc_opcodes::version_sig.

Referenced by opcode_36(), and opcode_37().

◆ opcode_37()

pyc_opcodes* opcode_37 ( void  )

Definition at line 6 of file opcode_37.c.

6  {
7  pyc_opcodes *ret = opcode_36();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_37;
13 
14  // These are removed since 3.6...
15  // and STORE_ANNOTATION introduced in 3.6!
16  rm_op(.op_obj = ret->opcodes, .op_name = "STORE_ANNOTATION", .op_code = 127);
17 
18  // These are new since Python 3.7
19  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_METHOD", .op_code = 160);
20  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_METHOD", .op_code = 161);
21 
23  add_arg_fmt(ret, "CALL_FUNCTION_KW", format_CALL_FUNCTION_KW_36);
24  add_arg_fmt(ret, "CALL_FUNCTION_EX", format_CALL_FUNCTION_EX_36);
25  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_36);
26  add_arg_fmt(ret, "FORMAT_VALUE", format_value_flags_36);
27  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg_36);
28 
29  return ret;
30 }
pyc_opcodes * opcode_37(void)
Definition: opcode_37.c:6
pyc_opcodes * opcode_36(void)
Definition: opcode_36.c:6

References add_arg_fmt(), format_CALL_FUNCTION_EX_36(), format_CALL_FUNCTION_KW_36(), format_extended_arg_36(), format_MAKE_FUNCTION_arg_36(), format_value_flags_36(), name_op, nargs_op, NULL, pyc_opcode_object::op_name, opcode_36(), opcode_37(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_37(), and opcode_38().

◆ opcode_38()

pyc_opcodes* opcode_38 ( void  )

Definition at line 6 of file opcode_38.c.

6  {
7  pyc_opcodes *ret = opcode_37();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_38;
13 
14  // These are removed since 3.7...
15  rm_op(.op_obj = ret->opcodes, .op_name = "BREAK_LOOP", .op_code = 80);
16  rm_op(.op_obj = ret->opcodes, .op_name = "CONTINUE_LOOP", .op_code = 119);
17  rm_op(.op_obj = ret->opcodes, .op_name = "SETUP_LOOP", .op_code = 120);
18  rm_op(.op_obj = ret->opcodes, .op_name = "SETUP_EXCEPT", .op_code = 121);
19 
20  // These are new since Python 3.7
21 
22  // OP NAME OPCODE POP PUSH
23  // --------------------------------------------
24  def_op(.op_obj = ret->opcodes, .op_name = "ROT_FOUR", .op_code = 6, .pop = 4, .push = 4);
25  def_op(.op_obj = ret->opcodes, .op_name = "BEGIN_FINALLY", .op_code = 53, .pop = 0, .push = 1);
26  def_op(.op_obj = ret->opcodes, .op_name = "END_ASYNC_FOR", .op_code = 54, .pop = 7, .push = 0); // POP is 0, when not 7
27  def_op(.op_obj = ret->opcodes, .op_name = "END_FINALLY", .op_code = 88, .pop = 1, .push = 0); // POP is 6, when not 1
28  jrel_op(.op_obj = ret->opcodes, .op_name = "CALL_FINALLY", .op_code = 162, .pop = 0, .push = 1);
29  nargs_op(.op_obj = ret->opcodes, .op_name = "POP_FINALLY", .op_code = 163, .pop = 0, .push = 0); // PUSH/POP vary
30 
32  add_arg_fmt(ret, "CALL_FUNCTION_KW", format_CALL_FUNCTION_KW_36);
33  add_arg_fmt(ret, "CALL_FUNCTION_EX", format_CALL_FUNCTION_EX_36);
34  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_36);
35  add_arg_fmt(ret, "FORMAT_VALUE", format_value_flags_36);
36  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg_36);
37 
38  return ret;
39 }
pyc_opcodes * opcode_38(void)
Definition: opcode_38.c:6
pyc_opcodes * opcode_37(void)
Definition: opcode_37.c:6

References add_arg_fmt(), def_op, format_CALL_FUNCTION_EX_36(), format_CALL_FUNCTION_KW_36(), format_extended_arg_36(), format_MAKE_FUNCTION_arg_36(), format_value_flags_36(), jrel_op, nargs_op, NULL, pyc_opcode_object::op_name, opcode_37(), opcode_38(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_38(), and opcode_39().

◆ opcode_39()

pyc_opcodes* opcode_39 ( void  )

Definition at line 6 of file opcode_39.c.

6  {
7  pyc_opcodes *ret = opcode_38();
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_39;
13 
14  // These are removed since 3.8...
15  rm_op(.op_obj = ret->opcodes, .op_name = "BEGIN_FINALLY", .op_code = 53);
16  rm_op(.op_obj = ret->opcodes, .op_name = "WITH_CLEANUP_START", .op_code = 81);
17  rm_op(.op_obj = ret->opcodes, .op_name = "WITH_CLEANUP_FINISH", .op_code = 82);
18  rm_op(.op_obj = ret->opcodes, .op_name = "END_FINALLY", .op_code = 88);
19  rm_op(.op_obj = ret->opcodes, .op_name = "CALL_FINALLY", .op_code = 162);
20  rm_op(.op_obj = ret->opcodes, .op_name = "POP_FINALLY", .op_code = 163);
21 
22  // These are new since Python 3.9
23  // OP NAME OPCODE POP PUSH
24  def_op(.op_obj = ret->opcodes, .op_name = "RERAISE", .op_code = 48, .pop = 0, .push = 0);
25  def_op(.op_obj = ret->opcodes, .op_name = "WITH_EXCEPT_START", .op_code = 49, .pop = 3, .push = 0);
26  def_op(.op_obj = ret->opcodes, .op_name = "LOAD_ASSERTION_ERROR", .op_code = 74, .pop = 0, .push = 1);
27 
29  add_arg_fmt(ret, "CALL_FUNCTION_KW", format_CALL_FUNCTION_KW_36);
30  add_arg_fmt(ret, "CALL_FUNCTION_EX", format_CALL_FUNCTION_EX_36);
31  add_arg_fmt(ret, "MAKE_FUNCTION", format_MAKE_FUNCTION_arg_36);
32  add_arg_fmt(ret, "FORMAT_VALUE", format_value_flags_36);
33  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg_36);
34 
35  return ret;
36 }
pyc_opcodes * opcode_39(void)
Definition: opcode_39.c:6
pyc_opcodes * opcode_38(void)
Definition: opcode_38.c:6

References add_arg_fmt(), def_op, format_CALL_FUNCTION_EX_36(), format_CALL_FUNCTION_KW_36(), format_extended_arg_36(), format_MAKE_FUNCTION_arg_36(), format_value_flags_36(), NULL, pyc_opcode_object::op_name, opcode_38(), opcode_39(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rm_op, rz_list_purge(), and pyc_opcodes::version_sig.

Referenced by opcode_39().

◆ opcode_3x()

pyc_opcodes* opcode_3x ( void  )

Definition at line 6 of file opcode_3x.c.

6  {
8  if (!ret) {
9  return NULL;
10  }
11 
12  ret->version_sig = (void *(*)())opcode_3x;
13 
14  def_op00(.op_obj = ret->opcodes, .op_name = "STOP_CODE", .op_code = 0, .pop = 0, .push = 0, .fallthrough = false);
15  def_op(.op_obj = ret->opcodes, .op_name = "POP_TOP", .op_code = 1, .pop = 1, .push = 0);
16  def_op(.op_obj = ret->opcodes, .op_name = "ROT_TWO", .op_code = 2, .pop = 2, .push = 2);
17  def_op(.op_obj = ret->opcodes, .op_name = "ROT_THREE", .op_code = 3, .pop = 3, .push = 3);
18  def_op(.op_obj = ret->opcodes, .op_name = "DUP_TOP", .op_code = 4, .pop = 0, .push = 1);
19 
20  // Python 3.2+
21  def_op(.op_obj = ret->opcodes, .op_name = "DUP_TOP_TWO", .op_code = 5, .pop = 0, .push = 2);
22 
23  def_op(.op_obj = ret->opcodes, .op_name = "NOP", 9);
24  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_POSITIVE", .op_code = 10, .pop = 1, .push = 1);
25  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_NEGATIVE", .op_code = 11, .pop = 1, .push = 1);
26  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_NOT", .op_code = 12, .pop = 1, .push = 1);
27 
28  def_op(.op_obj = ret->opcodes, .op_name = "UNARY_INVERT", .op_code = 15, .pop = 1, .push = 1);
29 
30  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_POWER", .op_code = 19, .pop = 2, .push = 1);
31  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_MULTIPLY", .op_code = 20, .pop = 2, .push = 1);
32 
33  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_MODULO", .op_code = 22, .pop = 2, .push = 1);
34  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_ADD", .op_code = 23, .pop = 2, .push = 1);
35  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_SUBTRACT", .op_code = 24, .pop = 2, .push = 1);
36  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_SUBSCR", .op_code = 25, .pop = 2, .push = 1);
37  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_FLOOR_DIVIDE", .op_code = 26, .pop = 2, .push = 1);
38  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_TRUE_DIVIDE", .op_code = 27, .pop = 2, .push = 1);
39  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_FLOOR_DIVIDE", .op_code = 28, .pop = 2, .push = 1);
40  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_TRUE_DIVIDE", .op_code = 29, .pop = 2, .push = 1);
41 
42  // Gone from Python 3 are Python2's
43  // SLICE+0 .. SLICE+3
44  // STORE_SLICE+0 .. STORE_SLICE+3
45  // DELETE_SLICE+0 .. DELETE_SLICE+3
46 
47  store_op(.op_obj = ret->opcodes, .op_name = "STORE_MAP", .op_code = 54, .pop = 3, .push = 1);
48  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_ADD", .op_code = 55, .pop = 2, .push = 1);
49  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_SUBTRACT", .op_code = 56, .pop = 2, .push = 1);
50  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_MULTIPLY", .op_code = 57, .pop = 2, .push = 1);
51 
52  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_MODULO", .op_code = 59, .pop = 2, .push = 1);
53  store_op(.op_obj = ret->opcodes, .op_name = "STORE_SUBSCR", .op_code = 60, .pop = 3, .push = 0); // Implements TOS1[TOS] = TOS2.
54  def_op(.op_obj = ret->opcodes, .op_name = "DELETE_SUBSCR", .op_code = 61, .pop = 2, .push = 0); // Implements del TOS1[TOS].
55  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_LSHIFT", .op_code = 62, .pop = 2, .push = 1);
56  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_RSHIFT", .op_code = 63, .pop = 2, .push = 1);
57  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_AND", .op_code = 64, .pop = 2, .push = 1);
58  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_XOR", .op_code = 65, .pop = 2, .push = 1);
59  def_op(.op_obj = ret->opcodes, .op_name = "BINARY_OR", .op_code = 66, .pop = 2, .push = 1);
60  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_POWER", .op_code = 67, .pop = 2, .push = 1);
61  def_op(.op_obj = ret->opcodes, .op_name = "GET_ITER", .op_code = 68, .pop = 1, .push = 1);
62  store_op(.op_obj = ret->opcodes, .op_name = "STORE_LOCALS", .op_code = 69, .pop = 1, .push = 0);
63 
64  def_op(.op_obj = ret->opcodes, .op_name = "PRINT_EXPR", .op_code = 70, .pop = 1, .push = 0);
65  def_op(.op_obj = ret->opcodes, .op_name = "LOAD_BUILD_CLASS", .op_code = 71, .pop = 0, .push = 1);
66 
67  // Python3 drops/changes:
68  // def_op(.op_obj = ret->opcodes, .op_name = "PRINT_ITEM", 71)
69  // def_op(.op_obj = ret->opcodes, .op_name = "PRINT_NEWLINE", 72)
70  // def_op(.op_obj = ret->opcodes, .op_name = "PRINT_ITEM_TO", 73)
71  // def_op(.op_obj = ret->opcodes, .op_name = "PRINT_NEWLINE_TO", 74)
72 
73  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_LSHIFT", .op_code = 75, .pop = 2, .push = 1);
74  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_RSHIFT", .op_code = 76, .pop = 2, .push = 1);
75  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_AND", .op_code = 77, .pop = 2, .push = 1);
76  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_XOR", .op_code = 78, .pop = 2, .push = 1);
77  def_op(.op_obj = ret->opcodes, .op_name = "INPLACE_OR", .op_code = 79, .pop = 2, .push = 1);
78  def_op(.op_obj = ret->opcodes, .op_name = "BREAK_LOOP", .op_code = 80, .pop = 0, .push = 0);
79  def_op(.op_obj = ret->opcodes, .op_name = "WITH_CLEANUP", .op_code = 81, .pop = 1, .push = 0); // Cleans up the stack when a with statement
80  // block exits. Handle stack special
81 
82  def_op00(.op_obj = ret->opcodes, .op_name = "RETURN_VALUE", .op_code = 83, .pop = 1, .push = 0, .fallthrough = false);
83  def_op(.op_obj = ret->opcodes, .op_name = "IMPORT_STAR", .op_code = 84, .pop = 1, .push = 0);
84 
85  def_op(.op_obj = ret->opcodes, .op_name = "YIELD_VALUE", .op_code = 86, .pop = 1, .push = 1);
86  def_op(.op_obj = ret->opcodes, .op_name = "POP_BLOCK", .op_code = 87, .pop = 0, .push = 0);
87  def_op(.op_obj = ret->opcodes, .op_name = "END_FINALLY", .op_code = 88, .pop = 1, .push = 0);
88  def_op(.op_obj = ret->opcodes, .op_name = "POP_EXCEPT", .op_code = 89, .pop = 1, .push = -1);
89 
90  ret->have_argument = 90; // Opcodes from here have an argument:
91 
92  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_NAME", .op_code = 90, .pop = 1, .push = 0, .func = NAME_OP); // Operand is in name list
93  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_NAME", .op_code = 91, .pop = 0, .push = 0); // ""
94  varargs_op(.op_obj = ret->opcodes, .op_name = "UNPACK_SEQUENCE", .op_code = 92, .pop = 9, .push = 1); // TOS is number of tuple items
95  jrel_op(.op_obj = ret->opcodes, .op_name = "FOR_ITER", .op_code = 93, .pop = 9, .push = 1);
96 
97  def_op(.op_obj = ret->opcodes, .op_name = "UNPACK_EX", .op_code = 94, .pop = 9, .push = 1); // assignment with a starred target; TOS is #entries
98  // argument has a count
99  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_ATTR", .op_code = 95, .pop = 2, .push = 0, .func = NAME_OP); // Operand is in name list
100  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_ATTR", .op_code = 96, .pop = 1, .push = 0); // ""
101  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_GLOBAL", .op_code = 97, .pop = 1, .push = 0, .func = NAME_OP); // ""
102  name_op(.op_obj = ret->opcodes, .op_name = "DELETE_GLOBAL", .op_code = 98, .pop = 0, .push = 0); // ""
103 
104  // Python 2's DUP_TOPX is gone starting in Python 3.2
105 
106  const_op00(.op_obj = ret->opcodes, .op_name = "LOAD_CONST", .op_code = 100, .pop = 0, .push = 1); // Operand is in const list
107  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_NAME", .op_code = 101, .pop = 0, .push = 1); // Operand is in name list
108  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_TUPLE", .op_code = 102, .pop = 9, .push = 1); // TOS is count of tuple items
109  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_LIST", .op_code = 103, .pop = 9, .push = 1); // TOS is count of list items
110  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_SET", .op_code = 104, .pop = 9, .push = 1); // TOS is count of set items
111  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_MAP", .op_code = 105, .pop = 0, .push = 1); // TOS is count of kwarg items
112  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_ATTR", .op_code = 106, .pop = 1, .push = 1); // Operand is in name list
113  compare_op(.op_obj = ret->opcodes, .op_name = "COMPARE_OP", .op_code = 107, .pop = 2, .push = 1); // Comparison operator
114  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_NAME", .op_code = 108, .pop = 1, .push = 1); // Operand is in name list
115  name_op(.op_obj = ret->opcodes, .op_name = "IMPORT_FROM", .op_code = 109, .pop = 0, .push = 1); // Operand is in name list
116 
117  jrel_op(.op_obj = ret->opcodes, .op_name = "JUMP_FORWARD", .op_code = 110, .pop = 0, .push = 0); // Number of bytes to skip
118  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_FALSE_OR_POP", .op_code = 111, .conditional = true); // Target byte offset from beginning of code
119  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_IF_TRUE_OR_POP", .op_code = 112, .conditional = true); // ""
120  jabs_op(.op_obj = ret->opcodes, .op_name = "JUMP_ABSOLUTE", .op_code = 113, .pop = 0, .push = 0); // Target byte offset from beginning of code
121  jabs_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_FALSE", .op_code = 114, .pop = 9, .push = 1, .conditional = true); // ""
122  jabs_op(.op_obj = ret->opcodes, .op_name = "POP_JUMP_IF_TRUE", .op_code = 115, .pop = 9, .push = 1, .conditional = true); // ""
123 
124  name_op(.op_obj = ret->opcodes, .op_name = "LOAD_GLOBAL", .op_code = 116, .pop = 0, .push = 1); // Operand is in name list
125 
126  jabs_op(.op_obj = ret->opcodes, .op_name = "CONTINUE_LOOP", .op_code = 119, .pop = 0, .push = 0); // Target address
127  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_LOOP", .op_code = 120, .pop = 0, .push = 0, .conditional = true); // Distance to target address
128  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_EXCEPT", .op_code = 121, .pop = 0, .push = 6, .conditional = true); // ""
129  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_FINALLY", .op_code = 122, .pop = 0, .push = 6, .conditional = true); // ""
130 
131  local_op(.op_obj = ret->opcodes, .op_name = "LOAD_FAST", .op_code = 124, .pop = 0, .push = 1); // Local variable number
132  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_FAST", .op_code = 125, .pop = 1, .push = 0, .func = LOCAL_OP); // Local variable number
133  local_op(.op_obj = ret->opcodes, .op_name = "DELETE_FAST", .op_code = 126, .pop = 0, .push = 0); // Local variable number
134 
135  def_op00(.op_obj = ret->opcodes, .op_name = "RAISE_VARARGS", .op_code = 130, .pop = 9, .push = 1, .fallthrough = false);
136  // Number of raise arguments (1, 2, or 3)
137  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION", .op_code = 131, .pop = 9, .push = 1); // #args + (#kwargs << 8)
138 
139  def_op(.op_obj = ret->opcodes, .op_name = "MAKE_FUNCTION", .op_code = 132, .pop = 9, .push = 1); // TOS is number of args if < 3.6
140  varargs_op(.op_obj = ret->opcodes, .op_name = "BUILD_SLICE", .op_code = 133, .pop = 9, .push = 1); // TOS is number of items to pop
141 
142  def_op(.op_obj = ret->opcodes, .op_name = "MAKE_CLOSURE", .op_code = 134, .pop = 9, .push = 1); // TOS is number of items to pop
143  free_op(.op_obj = ret->opcodes, .op_name = "LOAD_CLOSURE", .op_code = 135, .pop = 0, .push = 1);
144  free_op(.op_obj = ret->opcodes, .op_name = "LOAD_DEREF", .op_code = 136, .pop = 0, .push = 1);
145  store_op00(.op_obj = ret->opcodes, .op_name = "STORE_DEREF", .op_code = 137, .pop = 1, .push = 0, .func = FREE_OP);
146  free_op(.op_obj = ret->opcodes, .op_name = "DELETE_DEREF", .op_code = 138, .pop = 0, .push = 0);
147 
148  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR", .op_code = 140, .pop = 9, .push = 1); // #args + (#kwargs << 8)
149  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_KW", .op_code = 141, .pop = 9, .push = 1); // #args + (#kwargs << 8)
150  nargs_op(.op_obj = ret->opcodes, .op_name = "CALL_FUNCTION_VAR_KW", .op_code = 142, .pop = 9, .push = 1); // #args + (#kwargs << 8)
151 
152  jrel_op(.op_obj = ret->opcodes, .op_name = "SETUP_WITH", .op_code = 143, .pop = 0, .push = 7);
153 
154  def_op(.op_obj = ret->opcodes, .op_name = "LIST_APPEND", .op_code = 145, .pop = 2, .push = 1); // Calls list.append(TOS[-i], TOS).
155  // Used to implement list comprehensions.
156  def_op(.op_obj = ret->opcodes, .op_name = "SET_ADD", .op_code = 146, .pop = 1, .push = 0); // Calls set.add(TOS1[-i], TOS).
157  // Used to implement set comprehensions.
158  def_op(.op_obj = ret->opcodes, .op_name = "MAP_ADD", .op_code = 147, .pop = 2, .push = 1); // Calls dict.setitem(TOS1[-i], TOS, TOS1)
159  // Used to implement dict comprehensions.
160 
161  def_op(.op_obj = ret->opcodes, .op_name = "EXTENDED_ARG", .op_code = 144);
162  ret->extended_arg = 144;
163 
165  add_arg_fmt(ret, "EXTENDED_ARG", format_extended_arg);
166 
167  return ret;
168 }
pyc_opcodes * opcode_3x(void)
Definition: opcode_3x.c:6

References add_arg_fmt(), compare_op, const_op00, def_op, def_op00, pyc_opcodes::extended_arg, format_extended_arg(), FREE_OP, free_op, pyc_opcodes::have_argument, jabs_op, jrel_op, LOCAL_OP, local_op, NAME_OP, name_op, nargs_op, new_pyc_opcodes(), NULL, pyc_opcode_object::op_name, opcode_3x(), pyc_opcodes::opcode_arg_fmt, pyc_opcodes::opcodes, rz_list_purge(), store_op, store_op00, varargs_op, and pyc_opcodes::version_sig.

Referenced by opcode_32(), opcode_33(), and opcode_3x().

◆ pyc_opcodes_equal()

bool pyc_opcodes_equal ( pyc_opcodes op,
const char *  version 
)

Definition at line 151 of file opcode.c.

151  {
152  if (version == NULL || op == NULL) {
153  return false;
154  }
155  version_opcode *vop = version_op;
156 
157  while (vop->version) {
158  if (!strcmp(vop->version, version)) {
159  if (vop->opcode_func == (pyc_opcodes * (*)())(op->version_sig)) {
160  return true;
161  }
162  }
163  vop++;
164  }
165 
166  return false;
167 }

References NULL, version_opcode::opcode_func, version_opcode::version, and version_op.

Referenced by disassemble(), and pyc_op().

◆ rm_op()

void() rm_op ( struct op_parameter  par)

Definition at line 327 of file opcode.c.

327  {
328  pyc_opcode_object *op_obj = &par.op_obj[par.op_code];
329  if (op_obj->op_code == par.op_code && !strcmp(op_obj->op_name, par.op_name)) {
330  free(op_obj->op_name);
331  op_obj->op_name = rz_str_newf("<%u>", par.op_code);
332  op_obj->type = op_obj->op_pop = op_obj->op_push = 0;
333  } else {
334  RZ_LOG_ERROR("Error in rm_op() while constructing opcodes for .pyc file: \n .op_code = %u, .op_name = %s", par.op_code, par.op_name);
335  }
336 }
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58

References free(), pyc_opcode_object::op_code, pyc_opcode_object::op_name, op_parameter::op_obj, pyc_opcode_object::op_pop, pyc_opcode_object::op_push, RZ_LOG_ERROR, rz_str_newf(), and pyc_opcode_object::type.

◆ store_opN()

void() store_opN ( struct op_parameter  par)

Definition at line 270 of file opcode.c.

270  {
271  switch (par.func) {
272  case NAME_OP:
273  name_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
274  break;
275  case LOCAL_OP:
276  local_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
277  break;
278  case FREE_OP:
279  free_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
280  break;
281  case DEF_OP:
282  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
283  break;
284  default:
285  RZ_LOG_ERROR("Error in store_op in pyc/opcode.c, call function %u.\n", par.func);
286  return;
287  }
288  par.op_obj[par.op_code].type |= HASSTORE;
289 }
pyc_store_op_func func
Definition: opcode.h:122

References DEF_OP, def_op, FREE_OP, free_op, HASSTORE, LOCAL_OP, local_op, NAME_OP, name_op, pyc_opcode_object::op_name, op_parameter::op_obj, and RZ_LOG_ERROR.

◆ varargs_op()

void() varargs_op ( struct op_parameter  par)

Definition at line 291 of file opcode.c.

291  {
292  def_op(.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push);
293  par.op_obj[par.op_code].type |= HASVARGS;
294 }

References def_op, HASVARGS, pyc_opcode_object::op_name, and op_parameter::op_obj.