Rizin
unix-like reverse engineering framework and cli tools
opcode_arg_fmt.c File Reference
#include "opcode.h"

Go to the source code of this file.

Functions

const char * format_extended_arg (ut32 oparg)
 
const char * format_CALL_FUNCTION_pos_name_encoded (ut32 oparg)
 
const char * format_MAKE_FUNCTION_arg_3x (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)
 

Variables

static const char * MAKE_FUNCTION_FLAGS [] = { "default", "keyword-only", "annotation", "closure" }
 

Function Documentation

◆ 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 }
lzma_index ** i
Definition: index.h:629
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
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().

Variable Documentation

◆ MAKE_FUNCTION_FLAGS

const char* MAKE_FUNCTION_FLAGS[] = { "default", "keyword-only", "annotation", "closure" }
static

Definition at line 31 of file opcode_arg_fmt.c.

Referenced by format_MAKE_FUNCTION_arg_36().