Ruby  2.0.0p481(2014-05-08revision45883)
iseq.h
Go to the documentation of this file.
00001 /**********************************************************************
00002 
00003   iseq.h -
00004 
00005   $Author: nagachika $
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 void rb_iseq_add_mark_object(rb_iseq_t *iseq, VALUE obj);
00027 VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
00028 VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
00029 struct st_table *ruby_insn_make_insn_table(void);
00030 unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
00031 
00032 int rb_iseq_line_trace_each(VALUE iseqval, int (*func)(int line, rb_event_flag_t *events_ptr, void *d), void *data);
00033 VALUE rb_iseq_line_trace_all(VALUE iseqval);
00034 VALUE rb_iseq_line_trace_specify(VALUE iseqval, VALUE pos, VALUE set);
00035 
00036 /* proc.c */
00037 rb_iseq_t *rb_method_get_iseq(VALUE body);
00038 rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
00039 
00040 struct rb_compile_option_struct {
00041     int inline_const_cache;
00042     int peephole_optimization;
00043     int tailcall_optimization;
00044     int specialized_instruction;
00045     int operands_unification;
00046     int instructions_unification;
00047     int stack_caching;
00048     int trace_instruction;
00049     int debug_level;
00050 };
00051 
00052 struct iseq_line_info_entry {
00053     unsigned int position;
00054     unsigned int line_no;
00055 };
00056 
00057 struct iseq_catch_table_entry {
00058     enum catch_type {
00059         CATCH_TYPE_RESCUE = INT2FIX(1),
00060         CATCH_TYPE_ENSURE = INT2FIX(2),
00061         CATCH_TYPE_RETRY  = INT2FIX(3),
00062         CATCH_TYPE_BREAK  = INT2FIX(4),
00063         CATCH_TYPE_REDO   = INT2FIX(5),
00064         CATCH_TYPE_NEXT   = INT2FIX(6)
00065     } type;
00066     VALUE iseq;
00067     unsigned long start;
00068     unsigned long end;
00069     unsigned long cont;
00070     unsigned long sp;
00071 };
00072 
00073 #define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
00074 
00075 struct iseq_compile_data_storage {
00076     struct iseq_compile_data_storage *next;
00077     unsigned long pos;
00078     unsigned long size;
00079     char *buff;
00080 };
00081 
00082 struct iseq_compile_data {
00083     /* GC is needed */
00084     VALUE err_info;
00085     VALUE mark_ary;
00086     VALUE catch_table_ary;      /* Array */
00087 
00088     /* GC is not needed */
00089     struct iseq_label_data *start_label;
00090     struct iseq_label_data *end_label;
00091     struct iseq_label_data *redo_label;
00092     VALUE current_block;
00093     VALUE ensure_node;
00094     VALUE for_iseq;
00095     struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
00096     int loopval_popped; /* used by NODE_BREAK */
00097     int cached_const;
00098     struct iseq_compile_data_storage *storage_head;
00099     struct iseq_compile_data_storage *storage_current;
00100     int last_line;
00101     int last_coverable_line;
00102     int label_no;
00103     int node_level;
00104     const rb_compile_option_t *option;
00105 #if SUPPORT_JOKE
00106     st_table *labels_table;
00107 #endif
00108 };
00109 
00110 /* defined? */
00111 
00112 enum defined_type {
00113     DEFINED_NIL = 1,
00114     DEFINED_IVAR,
00115     DEFINED_LVAR,
00116     DEFINED_GVAR,
00117     DEFINED_CVAR,
00118     DEFINED_CONST,
00119     DEFINED_METHOD,
00120     DEFINED_YIELD,
00121     DEFINED_ZSUPER,
00122     DEFINED_SELF,
00123     DEFINED_TRUE,
00124     DEFINED_FALSE,
00125     DEFINED_ASGN,
00126     DEFINED_EXPR,
00127     DEFINED_IVAR2,
00128     DEFINED_REF,
00129     DEFINED_FUNC
00130 };
00131 
00132 VALUE rb_iseq_defined_string(enum defined_type type);
00133 
00134 #define DEFAULT_SPECIAL_VAR_COUNT 2
00135 
00136 #if defined __GNUC__ && __GNUC__ >= 4
00137 #pragma GCC visibility pop
00138 #endif
00139 
00140 #endif /* RUBY_COMPILE_H */
00141