source: EcnlProtoTool/trunk/mruby-2.1.1/include/mruby/irep.h@ 439

Last change on this file since 439 was 439, checked in by coas-nagasima, 4 years ago

mrubyを2.1.1に更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 2.0 KB
Line 
1/**
2** @file 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 */
16MRB_BEGIN_DECL
17
18enum irep_pool_type {
19 IREP_TT_STRING,
20 IREP_TT_FIXNUM,
21 IREP_TT_FLOAT,
22};
23
24struct mrb_locals {
25 mrb_sym name;
26 uint16_t r;
27};
28
29/* Program data array struct */
30typedef 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
50MRB_API mrb_irep *mrb_add_irep(mrb_state *mrb);
51
52/* @param [const uint8_t*] irep code, expected as a literal */
53MRB_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 */
59MRB_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 */
62MRB_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 */
68MRB_API mrb_value mrb_load_irep_buf_cxt(mrb_state*, const void*, size_t, mrbc_context*);
69
70void mrb_irep_free(mrb_state*, struct mrb_irep*);
71void mrb_irep_incref(mrb_state*, struct mrb_irep*);
72void mrb_irep_decref(mrb_state*, struct mrb_irep*);
73void mrb_irep_cutref(mrb_state*, struct mrb_irep*);
74void mrb_irep_remove_lv(mrb_state *mrb, mrb_irep *irep);
75
76struct mrb_insn_data {
77 uint8_t insn;
78 uint16_t a;
79 uint16_t b;
80 uint8_t c;
81};
82
83struct mrb_insn_data mrb_decode_insn(const mrb_code *pc);
84
85MRB_END_DECL
86
87#endif /* MRUBY_IREP_H */
Note: See TracBrowser for help on using the repository browser.