Apply PIE to nghttpx
[platform/upstream/nghttp2.git] / third-party / mruby / include / mruby / irep.h
1 /*
2 ** mruby/irep.h - mrb_irep structure
3 **
4 ** See Copyright Notice in mruby.h
5 */
6
7 #ifndef MRUBY_IREP_H
8 #define MRUBY_IREP_H
9
10 #include "common.h"
11 #include <mruby/compile.h>
12
13 /**
14  * Compiled mruby scripts.
15  */
16 MRB_BEGIN_DECL
17
18 enum irep_pool_type {
19   IREP_TT_STRING,
20   IREP_TT_FIXNUM,
21   IREP_TT_FLOAT,
22 };
23
24 struct mrb_locals {
25   mrb_sym name;
26   uint16_t r;
27 };
28
29 /* Program data array struct */
30 typedef struct mrb_irep {
31   uint16_t nlocals;        /* Number of local variables */
32   uint16_t nregs;          /* Number of register variables */
33   uint8_t flags;
34
35   mrb_code *iseq;
36   mrb_value *pool;
37   mrb_sym *syms;
38   struct mrb_irep **reps;
39
40   struct mrb_locals *lv;
41   /* debug info */
42   struct mrb_irep_debug_info* debug_info;
43
44   uint16_t ilen, plen, slen, rlen;
45   uint32_t refcnt;
46 } mrb_irep;
47
48 #define MRB_ISEQ_NO_FREE 1
49
50 MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb);
51
52 /* @param [const uint8_t*] irep code, expected as a literal */
53 MRB_API mrb_value mrb_load_irep(mrb_state*, const uint8_t*);
54
55 /* @param [const uint8_t*] irep code, expected as a literal */
56 MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
57
58 void mrb_irep_free(mrb_state*, struct mrb_irep*);
59 void mrb_irep_incref(mrb_state*, struct mrb_irep*);
60 void mrb_irep_decref(mrb_state*, struct mrb_irep*);
61 void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
62 void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
63
64 struct mrb_insn_data {
65   uint8_t insn;
66   uint16_t a;
67   uint16_t b;
68   uint8_t c;
69 };
70
71 struct mrb_insn_data mrb_decode_insn(mrb_code *pc);
72
73 MRB_END_DECL
74
75 #endif  /* MRUBY_IREP_H */