Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

iseq.h
Go to the documentation of this file.
1 /**********************************************************************
2
3 iseq.h -
4
5 $Author: nagachika $
6 created at: 04/01/01 23:36:57 JST
7
8 Copyright (C) 2004-2008 Koichi Sasada
9
10 **********************************************************************/
11
12 #ifndef RUBY_COMPILE_H
13 #define RUBY_COMPILE_H
14
15 #if defined __GNUC__ && __GNUC__ >= 4
16 #pragma GCC visibility push(default)
17 #endif
18
19 /* compile.c */
20 VALUE rb_iseq_compile_node(VALUE self, NODE *node);
21 int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
22 VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
23 VALUE exception, VALUE body);
24
25 /* iseq.c */
26 void rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj);
27 VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
28 VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
29 struct st_table *ruby_insn_make_insn_table(void);
30 unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
31
32 int rb_iseq_line_trace_each(VALUE iseqval, int (*func)(int line, rb_event_flag_t *events_ptr, void *d), void *data);
33 VALUE rb_iseq_line_trace_all(VALUE iseqval);
34 VALUE rb_iseq_line_trace_specify(VALUE iseqval, VALUE pos, VALUE set);
35
36 /* proc.c */
37 rb_iseq_t *rb_method_get_iseq(VALUE body);
38 rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
39
40 struct rb_compile_option_struct {
41 int inline_const_cache;
42 int peephole_optimization;
43 int tailcall_optimization;
44 int specialized_instruction;
45 int operands_unification;
46 int instructions_unification;
47 int stack_caching;
48 int trace_instruction;
49 int debug_level;
50 };
51
52 struct iseq_line_info_entry {
53 unsigned int position;
54 unsigned int line_no;
55 };
56
57 struct iseq_catch_table_entry {
58 enum catch_type {
59 CATCH_TYPE_RESCUE = INT2FIX(1),
60 CATCH_TYPE_ENSURE = INT2FIX(2),
61 CATCH_TYPE_RETRY = INT2FIX(3),
62 CATCH_TYPE_BREAK = INT2FIX(4),
63 CATCH_TYPE_REDO = INT2FIX(5),
64 CATCH_TYPE_NEXT = INT2FIX(6)
65 } type;
66 VALUE iseq;
67 unsigned long start;
68 unsigned long end;
69 unsigned long cont;
70 unsigned long sp;
71 };
72
73 #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
74
75 struct iseq_compile_data_storage {
76 struct iseq_compile_data_storage *next;
77 unsigned long pos;
78 unsigned long size;
79 char *buff;
80 };
81
82 struct iseq_compile_data {
83 /* GC is needed */
84 VALUE err_info;
85 VALUE mark_ary;
86 VALUE catch_table_ary; /* Array */
87
88 /* GC is not needed */
89 struct iseq_label_data *start_label;
90 struct iseq_label_data *end_label;
91 struct iseq_label_data *redo_label;
92 VALUE current_block;
93 VALUE ensure_node;
94 VALUE for_iseq;
95 struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
96 int loopval_popped; /* used by NODE_BREAK */
97 int cached_const;
98 struct iseq_compile_data_storage *storage_head;
99 struct iseq_compile_data_storage *storage_current;
100 int last_line;
101 int last_coverable_line;
102 int label_no;
103 int node_level;
104 const rb_compile_option_t *option;
105 #if SUPPORT_JOKE
106 st_table *labels_table;
107 #endif
108 };
109
110 /* defined? */
111
112 enum defined_type {
113 DEFINED_NIL = 1,
114 DEFINED_IVAR,
115 DEFINED_LVAR,
116 DEFINED_GVAR,
117 DEFINED_CVAR,
118 DEFINED_CONST,
119 DEFINED_METHOD,
120 DEFINED_YIELD,
121 DEFINED_ZSUPER,
122 DEFINED_SELF,
123 DEFINED_TRUE,
124 DEFINED_FALSE,
125 DEFINED_ASGN,
126 DEFINED_EXPR,
127 DEFINED_IVAR2,
128 DEFINED_REF,
129 DEFINED_FUNC
130 };
131
132 VALUE rb_iseq_defined_string(enum defined_type type);
133
134 #define DEFAULT_SPECIAL_VAR_COUNT 2
135
136 #if defined __GNUC__ && __GNUC__ >= 4
137 #pragma GCC visibility pop
138 #endif
139
140 #endif /* RUBY_COMPILE_H */
data
VALUE data
Definition: tcltklib.c:3368
DEFINED_IVAR2
Definition: iseq.h:127
rb_iseq_line_no
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos)
Definition: iseq.c:1110
iseq_catch_table_entry::catch_type
catch_type
Definition: iseq.h:58
iseq_compile_data_storage::size
unsigned long size
Definition: iseq.h:78
st_table
Definition: ripper.y:77
rb_iseq_line_trace_all
VALUE rb_iseq_line_trace_all(VALUE iseqval)
Definition: iseq.c:2147
DEFINED_ZSUPER
Definition: iseq.h:121
iseq_catch_table_entry::end
unsigned long end
Definition: iseq.h:68
DEFINED_ASGN
Definition: iseq.h:125
iseq_catch_table_entry::CATCH_TYPE_RETRY
Definition: iseq.h:61
DEFINED_YIELD
Definition: iseq.h:120
DEFINED_METHOD
Definition: iseq.h:119
rb_iseq_line_trace_each
int rb_iseq_line_trace_each(VALUE iseqval, int(*func)(int line, rb_event_flag_t *events_ptr, void *d), void *data)
Definition: iseq.c:2100
DEFINED_LVAR
Definition: iseq.h:115
proc
VALUE proc
Definition: tcltklib.c:2959
func
SSL_METHOD *(* func)(void)
Definition: ossl_ssl.c:108
rb_compile_option_struct::inline_const_cache
int inline_const_cache
Definition: iseq.h:41
iseq_compile_data::storage_head
struct iseq_compile_data_storage * storage_head
Definition: iseq.h:98
iseq_compile_data::catch_table_ary
VALUE catch_table_ary
Definition: iseq.h:86
DEFINED_FALSE
Definition: iseq.h:124
rb_compile_option_struct::stack_caching
int stack_caching
Definition: iseq.h:47
ruby_insn_make_insn_table
struct st_table * ruby_insn_make_insn_table(void)
rb_iseq_translate_threaded_code
int rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
Definition: compile.c:559
rb_iseq_defined_string
VALUE rb_iseq_defined_string(enum defined_type type)
Definition: iseq.c:2000
rb_compile_option_struct::operands_unification
int operands_unification
Definition: iseq.h:45
iseq_compile_data::start_label
struct iseq_label_data * start_label
Definition: iseq.h:89
iseq_compile_data_storage::next
struct iseq_compile_data_storage * next
Definition: iseq.h:76
rb_compile_option_struct::peephole_optimization
int peephole_optimization
Definition: iseq.h:42
rb_iseq_compile_node
VALUE rb_iseq_compile_node(VALUE self, NODE *node)
Definition: compile.c:461
iseq_compile_data::ensure_node_stack
struct iseq_compile_data_ensure_node_stack * ensure_node_stack
Definition: iseq.h:95
args
VALUE VALUE args
Definition: tcltklib.c:2561
d
d
Definition: strlcat.c:58
iseq_compile_data::current_block
VALUE current_block
Definition: iseq.h:92
rb_event_flag_t
unsigned long rb_event_flag_t
Definition: ripper.y:1603
iseq_compile_data::option
const rb_compile_option_t * option
Definition: iseq.h:104
rb_compile_option_struct::tailcall_optimization
int tailcall_optimization
Definition: iseq.h:43
RNode
Definition: ripper.y:240
iseq_catch_table_entry::type
enum iseq_catch_table_entry::catch_type type
iseq_compile_data_storage::pos
unsigned long pos
Definition: iseq.h:77
rb_compile_option_struct::specialized_instruction
int specialized_instruction
Definition: iseq.h:44
iseq_catch_table_entry::CATCH_TYPE_RESCUE
Definition: iseq.h:59
iseq_compile_data::mark_ary
VALUE mark_ary
Definition: iseq.h:85
rb_compile_option_struct::instructions_unification
int instructions_unification
Definition: iseq.h:46
iseq_compile_data::last_line
int last_line
Definition: iseq.h:100
obj
static VALUE VALUE obj
Definition: tcltklib.c:3158
INT2FIX
#define INT2FIX(i)
iseq_compile_data_storage
Definition: iseq.h:75
DEFINED_CVAR
Definition: iseq.h:117
iseq_catch_table_entry::start
unsigned long start
Definition: iseq.h:67
iseq_catch_table_entry::CATCH_TYPE_ENSURE
Definition: iseq.h:60
iseq_catch_table_entry::CATCH_TYPE_NEXT
Definition: iseq.h:64
DEFINED_TRUE
Definition: iseq.h:123
defined_type
defined_type
Definition: iseq.h:112
DEFINED_CONST
Definition: iseq.h:118
rb_iseq_build_from_ary
VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args, VALUE exception, VALUE body)
Definition: compile.c:5758
iseq_compile_data::redo_label
struct iseq_label_data * redo_label
Definition: iseq.h:91
rb_proc_get_iseq
rb_iseq_t * rb_proc_get_iseq(VALUE proc, int *is_proc)
Definition: proc.c:713
rb_compile_option_struct::debug_level
int debug_level
Definition: iseq.h:49
type
int type
Definition: tcltklib.c:111
iseq_compile_data
Definition: iseq.h:82
iseq_catch_table_entry
Definition: iseq.h:57
DEFINED_IVAR
Definition: iseq.h:114
rb_iseq_load
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt)
Definition: iseq.c:571
iseq_catch_table_entry::CATCH_TYPE_BREAK
Definition: iseq.h:62
iseq_compile_data::err_info
VALUE err_info
Definition: iseq.h:84
DEFINED_GVAR
Definition: iseq.h:116
iseq_compile_data_storage::buff
char * buff
Definition: iseq.h:79
iseq_catch_table_entry::CATCH_TYPE_REDO
Definition: iseq.h:63
rb_iseq_add_mark_object
void rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj)
Definition: iseq.c:244
rb_iseq_line_trace_specify
VALUE rb_iseq_line_trace_specify(VALUE iseqval, VALUE pos, VALUE set)
Definition: iseq.c:2194
iseq_catch_table_entry::sp
unsigned long sp
Definition: iseq.h:70
iseq_line_info_entry::position
unsigned int position
Definition: iseq.h:53
iseq_compile_data::ensure_node
VALUE ensure_node
Definition: iseq.h:93
rb_compile_option_struct::trace_instruction
int trace_instruction
Definition: iseq.h:48
iseq_compile_data::cached_const
int cached_const
Definition: iseq.h:97
iseq_compile_data::for_iseq
VALUE for_iseq
Definition: iseq.h:94
iseq_compile_data::storage_current
struct iseq_compile_data_storage * storage_current
Definition: iseq.h:99
DEFINED_FUNC
Definition: iseq.h:129
DEFINED_SELF
Definition: iseq.h:122
iseq_compile_data::last_coverable_line
int last_coverable_line
Definition: iseq.h:101
rb_method_get_iseq
rb_iseq_t * rb_method_get_iseq(VALUE body)
Definition: proc.c:1859
rb_compile_option_struct
Definition: iseq.h:40
rb_iseq_struct
Definition: vm_core.h:196
iseq_catch_table_entry::cont
unsigned long cont
Definition: iseq.h:69
iseq_compile_data::end_label
struct iseq_label_data * end_label
Definition: iseq.h:90
iseq_compile_data::loopval_popped
int loopval_popped
Definition: iseq.h:96
DEFINED_NIL
Definition: iseq.h:113
iseq_catch_table_entry::iseq
VALUE iseq
Definition: iseq.h:66
VALUE
unsigned long VALUE
Definition: ripper.y:104
iseq_compile_data::label_no
int label_no
Definition: iseq.h:102
iseq_line_info_entry
Definition: iseq.h:52
iseq_compile_data::node_level
int node_level
Definition: iseq.h:103
iseq_line_info_entry::line_no
unsigned int line_no
Definition: iseq.h:54
DEFINED_REF
Definition: iseq.h:128
rb_iseq_parameters
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
Definition: iseq.c:1926
DEFINED_EXPR
Definition: iseq.h:126
iseq_compile_data_ensure_node_stack
Definition: compile.c:72
iseq_label_data
Definition: compile.c:42