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