Ruby 2.0.0p247(2013-06-27revision41674)

- 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: nobu $
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 VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
27 VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
28 struct st_table *ruby_insn_make_insn_table(void);
29 unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
30
31 int rb_iseq_line_trace_each(VALUE iseqval, int (*func)(int line, rb_event_flag_t *events_ptr, void *d), void *data);
32 VALUE rb_iseq_line_trace_all(VALUE iseqval);
33 VALUE rb_iseq_line_trace_specify(VALUE iseqval, VALUE pos, VALUE set);
34
35 /* proc.c */
36 rb_iseq_t *rb_method_get_iseq(VALUE body);
37 rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
38
39 struct rb_compile_option_struct {
40 int inline_const_cache;
41 int peephole_optimization;
42 int tailcall_optimization;
43 int specialized_instruction;
44 int operands_unification;
45 int instructions_unification;
46 int stack_caching;
47 int trace_instruction;
48 int debug_level;
49 };
50
51 struct iseq_line_info_entry {
52 unsigned int position;
53 unsigned int line_no;
54 };
55
56 struct iseq_catch_table_entry {
57 enum catch_type {
58 CATCH_TYPE_RESCUE = INT2FIX(1),
59 CATCH_TYPE_ENSURE = INT2FIX(2),
60 CATCH_TYPE_RETRY = INT2FIX(3),
61 CATCH_TYPE_BREAK = INT2FIX(4),
62 CATCH_TYPE_REDO = INT2FIX(5),
63 CATCH_TYPE_NEXT = INT2FIX(6)
64 } type;
65 VALUE iseq;
66 unsigned long start;
67 unsigned long end;
68 unsigned long cont;
69 unsigned long sp;
70 };
71
72 #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
73
74 struct iseq_compile_data_storage {
75 struct iseq_compile_data_storage *next;
76 unsigned long pos;
77 unsigned long size;
78 char *buff;
79 };
80
81 struct iseq_compile_data {
82 /* GC is needed */
83 VALUE err_info;
84 VALUE mark_ary;
85 VALUE catch_table_ary; /* Array */
86
87 /* GC is not needed */
88 struct iseq_label_data *start_label;
89 struct iseq_label_data *end_label;
90 struct iseq_label_data *redo_label;
91 VALUE current_block;
92 VALUE ensure_node;
93 VALUE for_iseq;
94 struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
95 int loopval_popped; /* used by NODE_BREAK */
96 int cached_const;
97 struct iseq_compile_data_storage *storage_head;
98 struct iseq_compile_data_storage *storage_current;
99 int last_line;
100 int last_coverable_line;
101 int label_no;
102 int node_level;
103 const rb_compile_option_t *option;
104 #if SUPPORT_JOKE
105 st_table *labels_table;
106 #endif
107 };
108
109 /* defined? */
110
111 enum defined_type {
112 DEFINED_NIL = 1,
113 DEFINED_IVAR,
114 DEFINED_LVAR,
115 DEFINED_GVAR,
116 DEFINED_CVAR,
117 DEFINED_CONST,
118 DEFINED_METHOD,
119 DEFINED_YIELD,
120 DEFINED_ZSUPER,
121 DEFINED_SELF,
122 DEFINED_TRUE,
123 DEFINED_FALSE,
124 DEFINED_ASGN,
125 DEFINED_EXPR,
126 DEFINED_IVAR2,
127 DEFINED_REF,
128 DEFINED_FUNC
129 };
130
131 VALUE rb_iseq_defined_string(enum defined_type type);
132
133 #define DEFAULT_SPECIAL_VAR_COUNT 2
134
135 #if defined __GNUC__ && __GNUC__ >= 4
136 #pragma GCC visibility pop
137 #endif
138
139 #endif /* RUBY_COMPILE_H */
140