(self, ctx)
must not change the database.

        args:
          ctx (object): has a `.insn` field.
must not change the database.
must not change the database .
def notify_out_insn(self, ctx):
        '''
        must not change the database.

        args:
          ctx (object): has a `.insn` field.
        '''
        insn = ctx.insn
        ea = insn.ea

        # if this is the start of a function, render the function prototype.
        # like::
        #
        #     code:082E $func8:
        #     code:082E (func $func8 (param $param0 i32) (param $param1 i32) (result i32))
        if ea in self.function_offsets:
            # use idaapi.rename_regvar and idaapi.find_regvar to resolve $local/$param names
            # ref: https://reverseengineering.stackexchange.com/q/3038/17194
            fn = self.function_offsets[ea]
            proto = self._render_function_prototype(fn)
            ctx.gen_printf(0, proto + '\n')

        # the instruction has a mnemonic, then zero or more operands.
        # if more than one operand, the operands are separated by commas.
        #
        # eg.
        #
        #     code:0E30    i32.store    0x1C,  align:2
        #                      ^         ^  ^ ^     ^
        #                  mnemonic      |  | |     |
        #                             op[0] | |     |
        #                               comma |     |
        #                                     space |
        #                                        op[1]

        ctx.out_mnemonic()
        ctx.out_one_operand(0)

        for i in range(1, 3):
            op = insn[i]

            if op.type == idaapi.o_void:
                break

            ctx.out_symbol(',')
            ctx.out_char(' ')
            ctx.out_one_operand(i)

        # if this is a block instruction, annotate the relevant block.
        #
        # eg.
        #
        #     code:0E84     block        $block2
        #     code:0E86     loop         $loop3
        #     code:0F3F     end          $loop3
        #                                   ^
        #                                 this name

        # TODO: resolve block names on conditionals.
        # right now they look like:
        #
        #     code:0E77     br_if        1
        #
        # but we want something like this:
        #
        #     code:0E77     br_if        $block2

        # TODO: even better, we should use the location name, rather than auto-generated $block name
        # from this:
        #
        #     code:0E77     br_if        $block2
        #
        # want:
        #
        #     code:0E77     br_if        loc_error

        if insn.itype in (self.itype_BLOCK, self.itype_LOOP, self.itype_END) \
           and ea in self.branch_targets:

            targets = self.branch_targets[ea]
            block = targets['block']
            if block['type'] in ('block', 'loop'):
                ctx.out_tagon(idaapi.COLOR_UNAME)
                for c in ("$" + block['type'] + str(block['index'])):
                    ctx.out_char(c)
                ctx.out_tagoff(idaapi.COLOR_UNAME)

        ctx.set_gen_cmt()
        ctx.flush_outbuf()
def notify_out_insn ( self , ctx ) : insn = ctx . insn ea = insn . ea # if this is the start of a function, render the function prototype. # like:: # #     code:082E $func8: #     code:082E (func $func8 (param $param0 i32) (param $param1 i32) (result i32)) if ea in self . function_offsets : # use idaapi.rename_regvar and idaapi.find_regvar to resolve $local/$param names # ref: https://reverseengineering.stackexchange.com/q/3038/17194 fn = self . function_offsets [ ea ] proto = self . _render_function_prototype ( fn ) ctx . gen_printf ( 0 , proto + '\n' ) # the instruction has a mnemonic, then zero or more operands. # if more than one operand, the operands are separated by commas. # # eg. # #     code:0E30    i32.store    0x1C,  align:2 #                      ^         ^  ^ ^     ^ #                  mnemonic      |  | |     | #                             op[0] | |     | #                               comma |     | #                                     space | #                                        op[1] ctx . out_mnemonic ( ) ctx . out_one_operand ( 0 ) for i in range ( 1 , 3 ) : op = insn [ i ] if op . type == idaapi . o_void : break ctx . out_symbol ( ',' ) ctx . out_char ( ' ' ) ctx . out_one_operand ( i ) # if this is a block instruction, annotate the relevant block. # # eg. # #     code:0E84     block        $block2 #     code:0E86     loop         $loop3 #     code:0F3F     end          $loop3 #                                   ^ #                                 this name # TODO: resolve block names on conditionals. # right now they look like: # #     code:0E77     br_if        1 # # but we want something like this: # #     code:0E77     br_if        $block2 # TODO: even better, we should use the location name, rather than auto-generated $block name # from this: # #     code:0E77     br_if        $block2 # # want: # #     code:0E77     br_if        loc_error if insn . itype in ( self . itype_BLOCK , self . itype_LOOP , self . itype_END ) and ea in self . branch_targets : targets = self . branch_targets [ ea ] block = targets [ 'block' ] if block [ 'type' ] in ( 'block' , 'loop' ) : ctx . out_tagon ( idaapi . COLOR_UNAME ) for c in ( "$" + block [ 'type' ] + str ( block [ 'index' ] ) ) : ctx . out_char ( c ) ctx . out_tagoff ( idaapi . COLOR_UNAME ) ctx . set_gen_cmt ( ) ctx . flush_outbuf ( )