00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef RUBY_COMPILE_H
00013 #define RUBY_COMPILE_H
00014
00015 RUBY_SYMBOL_EXPORT_BEGIN
00016
00017
00018 VALUE rb_iseq_compile_node(VALUE self, NODE *node);
00019 int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
00020 VALUE rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
00021 VALUE exception, VALUE body);
00022
00023
00024 void rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj);
00025 VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
00026 VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
00027 struct st_table *ruby_insn_make_insn_table(void);
00028 unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
00029
00030 int rb_iseq_line_trace_each(VALUE iseqval, int (*func)(int line, rb_event_flag_t *events_ptr, void *d), void *data);
00031 VALUE rb_iseq_line_trace_all(VALUE iseqval);
00032 VALUE rb_iseq_line_trace_specify(VALUE iseqval, VALUE pos, VALUE set);
00033
00034
00035 rb_iseq_t *rb_method_get_iseq(VALUE body);
00036 rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
00037
00038 struct rb_compile_option_struct {
00039 int inline_const_cache;
00040 int peephole_optimization;
00041 int tailcall_optimization;
00042 int specialized_instruction;
00043 int operands_unification;
00044 int instructions_unification;
00045 int stack_caching;
00046 int trace_instruction;
00047 int debug_level;
00048 };
00049
00050 struct iseq_line_info_entry {
00051 unsigned int position;
00052 unsigned int line_no;
00053 };
00054
00055 struct iseq_catch_table_entry {
00056 enum catch_type {
00057 CATCH_TYPE_RESCUE = INT2FIX(1),
00058 CATCH_TYPE_ENSURE = INT2FIX(2),
00059 CATCH_TYPE_RETRY = INT2FIX(3),
00060 CATCH_TYPE_BREAK = INT2FIX(4),
00061 CATCH_TYPE_REDO = INT2FIX(5),
00062 CATCH_TYPE_NEXT = INT2FIX(6)
00063 } type;
00064 VALUE iseq;
00065 unsigned long start;
00066 unsigned long end;
00067 unsigned long cont;
00068 unsigned long sp;
00069 };
00070
00071 #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
00072
00073 struct iseq_compile_data_storage {
00074 struct iseq_compile_data_storage *next;
00075 unsigned long pos;
00076 unsigned long size;
00077 char *buff;
00078 };
00079
00080 struct iseq_compile_data {
00081
00082 const VALUE err_info;
00083 VALUE mark_ary;
00084 const VALUE catch_table_ary;
00085
00086
00087 struct iseq_label_data *start_label;
00088 struct iseq_label_data *end_label;
00089 struct iseq_label_data *redo_label;
00090 VALUE current_block;
00091 VALUE ensure_node;
00092 VALUE for_iseq;
00093 struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
00094 int loopval_popped;
00095 int cached_const;
00096 struct iseq_compile_data_storage *storage_head;
00097 struct iseq_compile_data_storage *storage_current;
00098 int last_line;
00099 int last_coverable_line;
00100 int label_no;
00101 int node_level;
00102 const rb_compile_option_t *option;
00103 #if SUPPORT_JOKE
00104 st_table *labels_table;
00105 #endif
00106 };
00107
00108
00109
00110 enum defined_type {
00111 DEFINED_NIL = 1,
00112 DEFINED_IVAR,
00113 DEFINED_LVAR,
00114 DEFINED_GVAR,
00115 DEFINED_CVAR,
00116 DEFINED_CONST,
00117 DEFINED_METHOD,
00118 DEFINED_YIELD,
00119 DEFINED_ZSUPER,
00120 DEFINED_SELF,
00121 DEFINED_TRUE,
00122 DEFINED_FALSE,
00123 DEFINED_ASGN,
00124 DEFINED_EXPR,
00125 DEFINED_IVAR2,
00126 DEFINED_REF,
00127 DEFINED_FUNC
00128 };
00129
00130 VALUE rb_iseq_defined_string(enum defined_type type);
00131
00132 #define DEFAULT_SPECIAL_VAR_COUNT 2
00133
00134 RUBY_SYMBOL_EXPORT_END
00135
00136 #endif
00137