* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
iseq.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: 04/01/01 23:36:57 JST
|
|
|
|
|
|
|
|
Copyright (C) 2004-2008 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2015-09-18 21:48:48 -04:00
|
|
|
#ifndef RUBY_ISEQ_H
|
|
|
|
#define RUBY_ISEQ_H 1
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
|
2018-10-13 12:21:06 -04:00
|
|
|
RUBY_EXTERN const int ruby_api_version[];
|
|
|
|
#define ISEQ_MAJOR_VERSION ((unsigned int)ruby_api_version[0])
|
|
|
|
#define ISEQ_MINOR_VERSION ((unsigned int)ruby_api_version[1])
|
2015-12-08 08:58:50 -05:00
|
|
|
|
2015-09-18 21:53:34 -04:00
|
|
|
#ifndef rb_iseq_t
|
|
|
|
typedef struct rb_iseq_struct rb_iseq_t;
|
|
|
|
#define rb_iseq_t rb_iseq_t
|
|
|
|
#endif
|
|
|
|
|
2015-08-13 04:43:32 -04:00
|
|
|
static inline size_t
|
|
|
|
rb_call_info_kw_arg_bytes(int keyword_len)
|
|
|
|
{
|
2015-09-19 13:59:58 -04:00
|
|
|
return sizeof(struct rb_call_info_kw_arg) + sizeof(VALUE) * (keyword_len - 1);
|
2015-08-13 04:43:32 -04:00
|
|
|
}
|
|
|
|
|
2018-03-19 14:21:54 -04:00
|
|
|
#define ISEQ_COVERAGE(iseq) iseq->body->variable.coverage
|
|
|
|
#define ISEQ_COVERAGE_SET(iseq, cov) RB_OBJ_WRITE(iseq, &iseq->body->variable.coverage, cov)
|
2017-09-03 10:26:06 -04:00
|
|
|
#define ISEQ_LINE_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_LINES)
|
|
|
|
#define ISEQ_BRANCH_COVERAGE(iseq) RARRAY_AREF(ISEQ_COVERAGE(iseq), COVERAGE_INDEX_BRANCHES)
|
2015-12-02 08:58:07 -05:00
|
|
|
|
2018-10-20 06:45:48 -04:00
|
|
|
#define ISEQ_PC2BRANCHINDEX(iseq) iseq->body->variable.pc2branchindex
|
|
|
|
#define ISEQ_PC2BRANCHINDEX_SET(iseq, h) RB_OBJ_WRITE(iseq, &iseq->body->variable.pc2branchindex, h)
|
|
|
|
|
2018-03-19 14:21:54 -04:00
|
|
|
#define ISEQ_FLIP_CNT(iseq) (iseq)->body->variable.flip_count
|
2015-12-08 08:58:50 -05:00
|
|
|
|
2018-03-19 14:21:54 -04:00
|
|
|
static inline rb_snum_t
|
2015-12-02 08:58:07 -05:00
|
|
|
ISEQ_FLIP_CNT_INCREMENT(const rb_iseq_t *iseq)
|
|
|
|
{
|
2018-03-19 14:21:54 -04:00
|
|
|
rb_snum_t cnt = iseq->body->variable.flip_count;
|
|
|
|
iseq->body->variable.flip_count += 1;
|
2015-12-02 08:58:07 -05:00
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE *
|
|
|
|
ISEQ_ORIGINAL_ISEQ(const rb_iseq_t *iseq)
|
|
|
|
{
|
2018-05-09 01:42:06 -04:00
|
|
|
return iseq->body->variable.original_iseq;
|
2015-12-02 08:58:07 -05:00
|
|
|
}
|
|
|
|
|
2017-11-14 07:58:36 -05:00
|
|
|
static inline void
|
|
|
|
ISEQ_ORIGINAL_ISEQ_CLEAR(const rb_iseq_t *iseq)
|
|
|
|
{
|
2018-05-09 01:42:06 -04:00
|
|
|
void *ptr = iseq->body->variable.original_iseq;
|
|
|
|
iseq->body->variable.original_iseq = NULL;
|
|
|
|
if (ptr) {
|
|
|
|
ruby_xfree(ptr);
|
|
|
|
}
|
2017-11-14 07:58:36 -05:00
|
|
|
}
|
|
|
|
|
2015-12-02 08:58:07 -05:00
|
|
|
static inline VALUE *
|
|
|
|
ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
|
|
|
|
{
|
2018-05-09 01:42:06 -04:00
|
|
|
return iseq->body->variable.original_iseq =
|
2018-05-09 12:12:41 -04:00
|
|
|
ruby_xmalloc2(size, sizeof(VALUE));
|
2015-12-02 08:58:07 -05:00
|
|
|
}
|
|
|
|
|
2017-11-18 04:39:41 -05:00
|
|
|
#define ISEQ_TRACE_EVENTS (RUBY_EVENT_LINE | \
|
|
|
|
RUBY_EVENT_CLASS | \
|
|
|
|
RUBY_EVENT_END | \
|
|
|
|
RUBY_EVENT_CALL | \
|
|
|
|
RUBY_EVENT_RETURN| \
|
|
|
|
RUBY_EVENT_B_CALL| \
|
2018-08-22 07:09:47 -04:00
|
|
|
RUBY_EVENT_B_RETURN| \
|
2018-10-20 06:45:55 -04:00
|
|
|
RUBY_EVENT_COVERAGE_LINE| \
|
|
|
|
RUBY_EVENT_COVERAGE_BRANCH)
|
2017-11-18 04:39:41 -05:00
|
|
|
|
|
|
|
#define ISEQ_NOT_LOADED_YET IMEMO_FL_USER1
|
|
|
|
#define ISEQ_USE_COMPILE_DATA IMEMO_FL_USER2
|
2018-03-19 14:21:54 -04:00
|
|
|
#define ISEQ_TRANSLATED IMEMO_FL_USER3
|
|
|
|
#define ISEQ_MARKABLE_ISEQ IMEMO_FL_USER4
|
2017-11-18 04:39:41 -05:00
|
|
|
|
|
|
|
struct iseq_compile_data {
|
|
|
|
/* GC is needed */
|
|
|
|
const VALUE err_info;
|
|
|
|
VALUE mark_ary;
|
|
|
|
const VALUE catch_table_ary; /* Array */
|
|
|
|
|
|
|
|
/* GC is not needed */
|
|
|
|
struct iseq_label_data *start_label;
|
|
|
|
struct iseq_label_data *end_label;
|
|
|
|
struct iseq_label_data *redo_label;
|
|
|
|
const rb_iseq_t *current_block;
|
|
|
|
VALUE ensure_node;
|
|
|
|
VALUE for_iseq;
|
|
|
|
struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
|
|
|
|
struct iseq_compile_data_storage *storage_head;
|
|
|
|
struct iseq_compile_data_storage *storage_current;
|
2018-07-28 21:32:37 -04:00
|
|
|
int loopval_popped; /* used by NODE_BREAK */
|
2017-11-18 04:39:41 -05:00
|
|
|
int last_line;
|
|
|
|
int label_no;
|
|
|
|
int node_level;
|
|
|
|
unsigned int ci_index;
|
|
|
|
unsigned int ci_kw_index;
|
|
|
|
const rb_compile_option_t *option;
|
|
|
|
struct rb_id_table *ivar_cache_table;
|
|
|
|
#if SUPPORT_JOKE
|
|
|
|
st_table *labels_table;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct iseq_compile_data *
|
|
|
|
ISEQ_COMPILE_DATA(const rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
if (iseq->flags & ISEQ_USE_COMPILE_DATA) {
|
|
|
|
return iseq->aux.compile_data;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
ISEQ_COMPILE_DATA_ALLOC(rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
iseq->flags |= ISEQ_USE_COMPILE_DATA;
|
|
|
|
iseq->aux.compile_data = ZALLOC(struct iseq_compile_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
ISEQ_COMPILE_DATA_CLEAR(rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
iseq->flags &= ~ISEQ_USE_COMPILE_DATA;
|
|
|
|
iseq->aux.compile_data = NULL;
|
|
|
|
}
|
2015-12-08 08:58:50 -05:00
|
|
|
|
|
|
|
static inline rb_iseq_t *
|
|
|
|
iseq_imemo_alloc(void)
|
|
|
|
{
|
|
|
|
return (rb_iseq_t *)rb_imemo_new(imemo_iseq, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2018-09-13 09:59:25 -04:00
|
|
|
VALUE rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
|
|
|
|
void rb_ibf_load_iseq_complete(rb_iseq_t *iseq);
|
|
|
|
const rb_iseq_t *rb_iseq_ibf_load(VALUE str);
|
|
|
|
VALUE rb_iseq_ibf_load_extra_data(VALUE str);
|
|
|
|
void rb_iseq_init_trace(rb_iseq_t *iseq);
|
2018-08-23 00:12:14 -04:00
|
|
|
|
2018-06-13 00:51:43 -04:00
|
|
|
#if VM_INSN_INFO_TABLE_IMPL == 2
|
2018-04-05 03:04:39 -04:00
|
|
|
unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
|
2018-06-13 00:51:43 -04:00
|
|
|
#endif
|
2015-12-02 03:20:35 -05:00
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2008-12-04 22:35:48 -05:00
|
|
|
/* compile.c */
|
2017-10-27 08:00:38 -04:00
|
|
|
VALUE rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node);
|
2018-01-04 02:07:49 -05:00
|
|
|
VALUE rb_iseq_compile_ifunc(rb_iseq_t *iseq, const struct vm_ifunc *ifunc);
|
2009-01-18 20:06:56 -05:00
|
|
|
int rb_iseq_translate_threaded_code(rb_iseq_t *iseq);
|
2015-07-21 18:52:59 -04:00
|
|
|
VALUE *rb_iseq_original_iseq(const rb_iseq_t *iseq);
|
|
|
|
void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc,
|
|
|
|
VALUE locals, VALUE args,
|
|
|
|
VALUE exception, VALUE body);
|
2008-12-04 22:35:48 -05:00
|
|
|
|
|
|
|
/* iseq.c */
|
* iseq.c (rb_iseq_load): renamed from ruby_iseq_load, since it is
for C extensions or the ruby core. [ruby-core:21407]
Index: compile.c
===================================================================
--- compile.c (revision 21649)
+++ compile.c (working copy)
@@ -5078,5 +5078,5 @@ iseq_build_exception(rb_iseq_t *iseq, st
}
else {
- eiseqval = ruby_iseq_load(ptr[1], iseq->self, Qnil);
+ eiseqval = rb_iseq_load(ptr[1], iseq->self, Qnil);
}
@@ -5162,5 +5162,5 @@ iseq_build_body(rb_iseq_t *iseq, LINK_AN
if (op != Qnil) {
if (TYPE(op) == T_ARRAY) {
- argv[j] = ruby_iseq_load(op, iseq->self, Qnil);
+ argv[j] = rb_iseq_load(op, iseq->self, Qnil);
}
else if (CLASS_OF(op) == rb_cISeq) {
Index: iseq.c
===================================================================
--- iseq.c (revision 21649)
+++ iseq.c (working copy)
@@ -448,5 +448,5 @@ iseq_s_load(int argc, VALUE *argv, VALUE
VALUE
-ruby_iseq_load(VALUE data, VALUE parent, VALUE opt)
+rb_iseq_load(VALUE data, VALUE parent, VALUE opt)
{
return iseq_load(rb_cISeq, data, parent, opt);
Index: iseq.h
===================================================================
--- iseq.h (revision 21649)
+++ iseq.h (working copy)
@@ -21,5 +21,5 @@ VALUE ruby_iseq_build_from_ary(rb_iseq_t
/* iseq.c */
-VALUE ruby_iseq_load(VALUE data, VALUE parent, VALUE opt);
+VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
struct st_table *ruby_insn_make_insn_table(void);
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-18 14:05:15 -05:00
|
|
|
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 18:43:38 -04:00
|
|
|
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
|
2008-12-04 22:35:48 -05:00
|
|
|
struct st_table *ruby_insn_make_insn_table(void);
|
2011-08-24 02:31:15 -04:00
|
|
|
unsigned int rb_iseq_line_no(const rb_iseq_t *iseq, size_t pos);
|
2017-11-17 01:24:55 -05:00
|
|
|
void rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events);
|
2017-11-14 07:58:36 -05:00
|
|
|
void rb_iseq_trace_set_all(rb_event_flag_t turnon_events);
|
|
|
|
void rb_iseq_trace_on_all(void);
|
2018-01-09 09:05:23 -05:00
|
|
|
void rb_iseq_insns_info_encode_positions(const rb_iseq_t *iseq);
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
|
2015-07-21 18:52:59 -04:00
|
|
|
VALUE rb_iseqw_new(const rb_iseq_t *iseq);
|
|
|
|
const rb_iseq_t *rb_iseqw_to_iseq(VALUE iseqw);
|
|
|
|
|
2017-05-31 20:05:33 -04:00
|
|
|
VALUE rb_iseq_absolute_path(const rb_iseq_t *iseq); /* obsolete */
|
2015-07-21 18:52:59 -04:00
|
|
|
VALUE rb_iseq_label(const rb_iseq_t *iseq);
|
|
|
|
VALUE rb_iseq_base_label(const rb_iseq_t *iseq);
|
|
|
|
VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq);
|
|
|
|
VALUE rb_iseq_method_name(const rb_iseq_t *iseq);
|
2018-01-09 03:45:35 -05:00
|
|
|
void rb_iseq_code_location(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
|
2012-11-30 12:00:30 -05:00
|
|
|
|
2018-08-22 06:22:02 -04:00
|
|
|
void rb_iseq_remove_coverage_all(void);
|
2018-08-22 01:24:50 -04:00
|
|
|
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 21:54:57 -04:00
|
|
|
/* proc.c */
|
2015-05-21 05:01:44 -04:00
|
|
|
const rb_iseq_t *rb_method_iseq(VALUE body);
|
|
|
|
const rb_iseq_t *rb_proc_get_iseq(VALUE proc, int *is_proc);
|
* internal.h: declare more internal functions.
* iseq.h (rb_method_get_iseq): declared.
* compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c,
ruby.c, time.c, util.c, vm.c: don't declare internal functions.
* eval.c, parse.y, thread_pthread.c: non-existing function declarations
removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 21:54:57 -04:00
|
|
|
|
2010-10-30 21:42:54 -04:00
|
|
|
struct rb_compile_option_struct {
|
2016-03-10 02:06:39 -05:00
|
|
|
unsigned int inline_const_cache: 1;
|
|
|
|
unsigned int peephole_optimization: 1;
|
|
|
|
unsigned int tailcall_optimization: 1;
|
|
|
|
unsigned int specialized_instruction: 1;
|
|
|
|
unsigned int operands_unification: 1;
|
|
|
|
unsigned int instructions_unification: 1;
|
|
|
|
unsigned int stack_caching: 1;
|
|
|
|
unsigned int frozen_string_literal: 1;
|
|
|
|
unsigned int debug_frozen_string_literal: 1;
|
2016-03-10 03:34:18 -05:00
|
|
|
unsigned int coverage_enabled: 1;
|
2010-10-30 21:42:54 -04:00
|
|
|
int debug_level;
|
|
|
|
};
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
|
2017-11-09 01:57:24 -05:00
|
|
|
struct iseq_insn_info_entry {
|
|
|
|
int line_no;
|
2017-11-14 07:58:36 -05:00
|
|
|
rb_event_flag_t events;
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iseq_catch_table_entry {
|
2010-10-30 21:42:54 -04:00
|
|
|
enum catch_type {
|
2012-12-03 05:03:25 -05:00
|
|
|
CATCH_TYPE_RESCUE = INT2FIX(1),
|
|
|
|
CATCH_TYPE_ENSURE = INT2FIX(2),
|
|
|
|
CATCH_TYPE_RETRY = INT2FIX(3),
|
|
|
|
CATCH_TYPE_BREAK = INT2FIX(4),
|
|
|
|
CATCH_TYPE_REDO = INT2FIX(5),
|
|
|
|
CATCH_TYPE_NEXT = INT2FIX(6)
|
2010-10-30 21:42:54 -04:00
|
|
|
} type;
|
2017-06-08 00:13:52 -04:00
|
|
|
|
2017-06-08 00:13:51 -04:00
|
|
|
/*
|
|
|
|
* iseq type:
|
|
|
|
* CATCH_TYPE_RESCUE, CATCH_TYPE_ENSURE:
|
|
|
|
* use iseq as continuation.
|
|
|
|
*
|
|
|
|
* CATCH_TYPE_BREAK (iter):
|
|
|
|
* use iseq as key.
|
|
|
|
*
|
|
|
|
* CATCH_TYPE_BREAK (while), CATCH_TYPE_RETRY,
|
|
|
|
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
|
|
|
|
* NULL.
|
|
|
|
*/
|
2015-07-21 18:52:59 -04:00
|
|
|
const rb_iseq_t *iseq;
|
2017-06-08 00:13:51 -04:00
|
|
|
|
2014-07-14 03:08:55 -04:00
|
|
|
unsigned int start;
|
|
|
|
unsigned int end;
|
|
|
|
unsigned int cont;
|
|
|
|
unsigned int sp;
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
};
|
|
|
|
|
2014-07-14 03:06:26 -04:00
|
|
|
PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
|
2015-07-24 17:44:14 -04:00
|
|
|
unsigned int size;
|
2018-01-13 07:44:17 -05:00
|
|
|
struct iseq_catch_table_entry entries[FLEX_ARY_LEN];
|
2014-07-14 03:06:26 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
iseq_catch_table_bytes(int n)
|
|
|
|
{
|
2014-07-17 12:54:59 -04:00
|
|
|
enum {
|
2018-01-14 06:19:18 -05:00
|
|
|
catch_table_entry_size = sizeof(struct iseq_catch_table_entry),
|
|
|
|
catch_table_entries_max = (INT_MAX - offsetof(struct iseq_catch_table, entries)) / catch_table_entry_size
|
2014-07-17 12:54:59 -04:00
|
|
|
};
|
|
|
|
if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n);
|
2018-01-14 06:19:18 -05:00
|
|
|
return (int)(offsetof(struct iseq_catch_table, entries) +
|
|
|
|
n * catch_table_entry_size);
|
2014-07-14 03:06:26 -04:00
|
|
|
}
|
|
|
|
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)
|
|
|
|
|
|
|
|
struct iseq_compile_data_storage {
|
|
|
|
struct iseq_compile_data_storage *next;
|
2014-07-26 03:57:44 -04:00
|
|
|
unsigned int pos;
|
|
|
|
unsigned int size;
|
2018-01-13 07:44:17 -05:00
|
|
|
char buff[FLEX_ARY_LEN];
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* defined? */
|
2010-10-30 21:42:54 -04:00
|
|
|
|
|
|
|
enum defined_type {
|
2018-01-19 00:18:18 -05:00
|
|
|
DEFINED_NOT_DEFINED,
|
2012-09-24 04:36:53 -04:00
|
|
|
DEFINED_NIL = 1,
|
|
|
|
DEFINED_IVAR,
|
|
|
|
DEFINED_LVAR,
|
2010-10-30 21:42:54 -04:00
|
|
|
DEFINED_GVAR,
|
|
|
|
DEFINED_CVAR,
|
|
|
|
DEFINED_CONST,
|
|
|
|
DEFINED_METHOD,
|
|
|
|
DEFINED_YIELD,
|
|
|
|
DEFINED_ZSUPER,
|
2012-09-24 04:36:53 -04:00
|
|
|
DEFINED_SELF,
|
|
|
|
DEFINED_TRUE,
|
|
|
|
DEFINED_FALSE,
|
|
|
|
DEFINED_ASGN,
|
|
|
|
DEFINED_EXPR,
|
|
|
|
DEFINED_IVAR2,
|
|
|
|
DEFINED_REF,
|
2010-12-09 21:42:06 -05:00
|
|
|
DEFINED_FUNC
|
2010-10-30 21:42:54 -04:00
|
|
|
};
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 03:49:45 -04:00
|
|
|
|
2012-09-24 04:36:53 -04:00
|
|
|
VALUE rb_iseq_defined_string(enum defined_type type);
|
2015-09-27 02:44:02 -04:00
|
|
|
void rb_iseq_make_compile_option(struct rb_compile_option_struct *option, VALUE opt);
|
2012-09-24 04:36:53 -04:00
|
|
|
|
2015-12-08 00:27:10 -05:00
|
|
|
/* vm.c */
|
|
|
|
VALUE rb_iseq_local_variables(const rb_iseq_t *iseq);
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2015-09-18 21:48:48 -04:00
|
|
|
#endif /* RUBY_ISEQ_H */
|