mruby  2.0.1
mruby is the lightweight implementation of the Ruby language
irep.h
Go to the documentation of this file.
1 
7 #ifndef MRUBY_IREP_H
8 #define MRUBY_IREP_H
9 
10 #include "common.h"
11 #include <mruby/compile.h>
12 
17 
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  const 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 /*
56  * @param [const void*] irep code
57  * @param [size_t] size of irep buffer. If -1 is given, it is considered unrestricted.
58  */
59 MRB_API mrb_value mrb_load_irep_buf(mrb_state*, const void*, size_t);
60 
61 /* @param [const uint8_t*] irep code, expected as a literal */
62 MRB_API mrb_value mrb_load_irep_cxt(mrb_state*, const uint8_t*, mrbc_context*);
63 
64 /*
65  * @param [const void*] irep code
66  * @param [size_t] size of irep buffer. If -1 is given, it is considered unrestricted.
67  */
68 MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state*, const void*, size_t, mrbc_context*);
69 
70 void mrb_irep_free(mrb_state*, struct mrb_irep*);
71 void mrb_irep_incref(mrb_state*, struct mrb_irep*);
72 void mrb_irep_decref(mrb_state*, struct mrb_irep*);
73 void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
74 void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
75 
76 struct mrb_insn_data {
77  uint8_t insn;
78  uint16_t a;
79  uint16_t b;
80  uint8_t c;
81 };
82 
83 struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
84 
86 
87 #endif /* MRUBY_IREP_H */
mruby Symbol.
uint8_t mrb_code
MRuby C API entry point.
Definition: mruby.h:101
Definition: irep.h:24
irep_pool_type
Compiled mruby scripts.
Definition: irep.h:18
Definition: debug.h:39
Definition: compile.h:23
#define MRB_BEGIN_DECL
Start declarations in C mode.
Definition: common.h:26
Definition: irep.h:30
#define MRB_API
Declare a public MRuby API function.
Definition: common.h:73
Definition: irep.h:76
mruby parser
#define MRB_END_DECL
End declarations in C mode.
Definition: common.h:28
mruby common platform definition"
Definition: boxing_nan.h:39
Definition: mruby.h:215