2006-12-31 18:02:22 +03:00
|
|
|
/**********************************************************************
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
compile.c - ruby node tree -> VM instruction sequence
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: 04/01/01 03:42:15 JST
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 01:13:04 +03:00
|
|
|
Copyright (C) 2004-2007 Koichi Sasada
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2007-06-10 07:06:15 +04:00
|
|
|
#include "ruby/ruby.h"
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
#define USE_INSN_STACK_INCREASE 1
|
2009-07-13 13:30:23 +04:00
|
|
|
#define USE_INSN_ICLEN 1
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
#include "vm_core.h"
|
* 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 11:49:45 +04:00
|
|
|
#include "iseq.h"
|
2006-12-31 18:02:22 +03:00
|
|
|
#include "insns.inc"
|
|
|
|
#include "insns_info.inc"
|
|
|
|
|
2009-05-17 09:27:32 +04:00
|
|
|
#define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
|
2009-09-05 09:34:56 +04:00
|
|
|
#define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
|
2009-09-05 09:37:11 +04:00
|
|
|
#define FIXNUM_OR(n, i) ((n)|INT2FIX(i))
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
typedef struct iseq_link_element {
|
2008-04-20 09:58:59 +04:00
|
|
|
enum {
|
|
|
|
ISEQ_ELEMENT_NONE = INT2FIX(0x00),
|
|
|
|
ISEQ_ELEMENT_LABEL = INT2FIX(0x01),
|
|
|
|
ISEQ_ELEMENT_INSN = INT2FIX(0x02),
|
2008-07-01 12:27:58 +04:00
|
|
|
ISEQ_ELEMENT_ADJUST = INT2FIX(0x03)
|
2008-04-20 09:58:59 +04:00
|
|
|
} type;
|
2006-12-31 18:02:22 +03:00
|
|
|
struct iseq_link_element *next;
|
|
|
|
struct iseq_link_element *prev;
|
|
|
|
} LINK_ELEMENT;
|
|
|
|
|
|
|
|
typedef struct iseq_link_anchor {
|
|
|
|
LINK_ELEMENT anchor;
|
|
|
|
LINK_ELEMENT *last;
|
|
|
|
} LINK_ANCHOR;
|
|
|
|
|
|
|
|
typedef struct iseq_label_data {
|
|
|
|
LINK_ELEMENT link;
|
|
|
|
int label_no;
|
|
|
|
int position;
|
|
|
|
int sc_state;
|
|
|
|
int set;
|
|
|
|
int sp;
|
|
|
|
} LABEL;
|
|
|
|
|
|
|
|
typedef struct iseq_insn_data {
|
|
|
|
LINK_ELEMENT link;
|
2008-04-20 09:58:59 +04:00
|
|
|
enum ruby_vminsn_type insn_id;
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
int line_no;
|
2006-12-31 18:02:22 +03:00
|
|
|
int operand_size;
|
|
|
|
int sc_state;
|
|
|
|
VALUE *operands;
|
|
|
|
} INSN;
|
|
|
|
|
2008-01-25 21:02:01 +03:00
|
|
|
typedef struct iseq_adjust_data {
|
|
|
|
LINK_ELEMENT link;
|
|
|
|
LABEL *label;
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
int line_no;
|
2008-01-25 21:02:01 +03:00
|
|
|
} ADJUST;
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
struct ensure_range {
|
|
|
|
LABEL *begin;
|
|
|
|
LABEL *end;
|
|
|
|
struct ensure_range *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iseq_compile_data_ensure_node_stack {
|
|
|
|
NODE *ensure_node;
|
|
|
|
struct iseq_compile_data_ensure_node_stack *prev;
|
|
|
|
struct ensure_range *erange;
|
|
|
|
};
|
|
|
|
|
* 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 11:49:45 +04:00
|
|
|
/**
|
|
|
|
* debug function(macro) interface depend on CPDEBUG
|
|
|
|
* if it is less than 0, runtime option is in effect.
|
|
|
|
*
|
|
|
|
* debug level:
|
|
|
|
* 0: no debug output
|
|
|
|
* 1: show node type
|
|
|
|
* 2: show node important parameters
|
|
|
|
* ...
|
|
|
|
* 5: show other parameters
|
|
|
|
* 10: show every AST array
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CPDEBUG
|
|
|
|
#define CPDEBUG 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CPDEBUG >= 0
|
|
|
|
#define compile_debug CPDEBUG
|
|
|
|
#else
|
|
|
|
#define compile_debug iseq->compile_data->option->debug_level
|
|
|
|
#endif
|
|
|
|
|
|
|
|
NORETURN(PRINTF_ARGS(void rb_compile_bug(const char*, int, const char*, ...), 3, 4));
|
|
|
|
|
|
|
|
#if CPDEBUG
|
|
|
|
|
|
|
|
#define compile_debug_print_indent(level) \
|
|
|
|
ruby_debug_print_indent(level, compile_debug, gl_node_level * 2)
|
|
|
|
|
|
|
|
#define debugp(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
|
|
|
ruby_debug_print_value(1, compile_debug, header, value))
|
|
|
|
|
|
|
|
#define debugi(header, id) (void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
|
|
|
ruby_debug_print_id(1, compile_debug, header, id))
|
|
|
|
|
|
|
|
#define debugp_param(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
|
|
|
ruby_debug_print_value(1, compile_debug, header, value))
|
|
|
|
|
|
|
|
#define debugp_verbose(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(2) && \
|
|
|
|
ruby_debug_print_value(2, compile_debug, header, value))
|
|
|
|
|
|
|
|
#define debugp_verbose_node(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(10) && \
|
|
|
|
ruby_debug_print_value(10, compile_debug, header, value))
|
|
|
|
|
|
|
|
#define debug_node_start(node) ((void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
|
|
|
(ruby_debug_print_node(1, CPDEBUG, "", (NODE *)node), gl_node_level)), \
|
|
|
|
gl_node_level++)
|
|
|
|
|
|
|
|
#define debug_node_end() gl_node_level --;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static inline ID
|
|
|
|
r_id(ID id)
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
|
|
|
r_value(VALUE value)
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define debugi(header, id) r_id(id)
|
|
|
|
#define debugp(header, value) r_value(value)
|
|
|
|
#define debugp_verbose(header, value) r_value(value)
|
|
|
|
#define debugp_verbose_node(header, value) r_value(value)
|
|
|
|
#define debugp_param(header, value) r_value(value)
|
|
|
|
#define debug_node_start(node) ((void)0)
|
|
|
|
#define debug_node_end() ((void)0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CPDEBUG > 1 || CPDEBUG < 0
|
|
|
|
PRINTF_ARGS(void ruby_debug_printf(const char*, ...), 1, 2);
|
|
|
|
#define debugs if (compile_debug_print_indent(1)) ruby_debug_printf
|
|
|
|
#define debug_compile(msg, v) ((void)(compile_debug_print_indent(1) && fputs(msg, stderr)), (v))
|
|
|
|
#else
|
|
|
|
#define debugs if(0)printf
|
|
|
|
#define debug_compile(msg, v) (v)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* create new label */
|
|
|
|
#define NEW_LABEL(l) new_label_body(iseq, l)
|
|
|
|
|
|
|
|
#define iseq_filename(iseq) \
|
|
|
|
(((rb_iseq_t*)DATA_PTR(iseq))->filename)
|
|
|
|
|
2009-07-22 17:37:26 +04:00
|
|
|
#define NEW_ISEQVAL(node, name, type, line_no) \
|
|
|
|
new_child_iseq(iseq, node, name, 0, type, line_no)
|
* 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 11:49:45 +04:00
|
|
|
|
2009-07-22 17:37:26 +04:00
|
|
|
#define NEW_CHILD_ISEQVAL(node, name, type, line_no) \
|
|
|
|
new_child_iseq(iseq, node, name, iseq->self, type, line_no)
|
* 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 11:49:45 +04:00
|
|
|
|
|
|
|
/* add instructions */
|
|
|
|
#define ADD_SEQ(seq1, seq2) \
|
|
|
|
APPEND_LIST(seq1, seq2)
|
|
|
|
|
|
|
|
/* add an instruction */
|
|
|
|
#define ADD_INSN(seq, line, insn) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) new_insn_body(iseq, line, BIN(insn), 0))
|
|
|
|
|
|
|
|
/* add an instruction with label operand */
|
|
|
|
#define ADD_INSNL(seq, line, insn, label) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 1, (VALUE)label))
|
|
|
|
|
|
|
|
/* add an instruction with some operands (1, 2, 3, 5) */
|
|
|
|
#define ADD_INSN1(seq, line, insn, op1) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 1, (VALUE)op1))
|
|
|
|
|
|
|
|
#define ADD_INSN2(seq, line, insn, op1, op2) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 2, (VALUE)op1, (VALUE)op2))
|
|
|
|
|
|
|
|
#define ADD_INSN3(seq, line, insn, op1, op2, op3) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 3, (VALUE)op1, (VALUE)op2, (VALUE)op3))
|
|
|
|
|
|
|
|
/* Specific Insn factory */
|
|
|
|
#define ADD_SEND(seq, line, id, argc) \
|
|
|
|
ADD_SEND_R(seq, line, id, argc, (VALUE)Qfalse, (VALUE)INT2FIX(0))
|
|
|
|
|
|
|
|
#define ADD_CALL_RECEIVER(seq, line) \
|
|
|
|
ADD_INSN(seq, line, putnil)
|
|
|
|
|
|
|
|
#define ADD_CALL(seq, line, id, argc) \
|
|
|
|
ADD_SEND_R(seq, line, id, argc, (VALUE)Qfalse, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
|
|
|
|
|
|
|
|
#define ADD_CALL_WITH_BLOCK(seq, line, id, argc, block) \
|
|
|
|
ADD_SEND_R(seq, line, id, argc, block, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
|
|
|
|
|
|
|
|
#define ADD_SEND_R(seq, line, id, argc, block, flag) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_send(iseq, line, \
|
|
|
|
(VALUE)id, (VALUE)argc, (VALUE)block, (VALUE)flag))
|
|
|
|
|
|
|
|
#define ADD_TRACE(seq, line, event) \
|
|
|
|
do { \
|
|
|
|
if ((event) == RUBY_EVENT_LINE && iseq->coverage && \
|
2009-10-08 20:11:30 +04:00
|
|
|
(line) != iseq->compile_data->last_coverable_line) { \
|
* 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 11:49:45 +04:00
|
|
|
RARRAY_PTR(iseq->coverage)[(line) - 1] = INT2FIX(0); \
|
2009-10-08 20:11:30 +04:00
|
|
|
iseq->compile_data->last_coverable_line = (line); \
|
* 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 11:49:45 +04:00
|
|
|
ADD_INSN1(seq, line, trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
|
|
|
|
} \
|
|
|
|
if (iseq->compile_data->option->trace_instruction) { \
|
|
|
|
ADD_INSN1(seq, line, trace, INT2FIX(event)); \
|
|
|
|
} \
|
|
|
|
}while(0);
|
|
|
|
|
|
|
|
/* add label */
|
|
|
|
#define ADD_LABEL(seq, label) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) label)
|
|
|
|
|
|
|
|
#define ADD_ADJUST(seq, line, label) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) new_adjust_body(iseq, label, line))
|
|
|
|
|
|
|
|
#define ADD_ADJUST_RESTORE(seq, label) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) new_adjust_body(iseq, label, -1))
|
|
|
|
|
|
|
|
#define ADD_CATCH_ENTRY(type, ls, le, iseqv, lc) \
|
|
|
|
(rb_ary_push(iseq->compile_data->catch_table_ary, \
|
|
|
|
rb_ary_new3(5, type, \
|
|
|
|
(VALUE)(ls) | 1, (VALUE)(le) | 1, \
|
|
|
|
iseqv, (VALUE)(lc) | 1)))
|
|
|
|
|
|
|
|
/* compile node */
|
|
|
|
#define COMPILE(anchor, desc, node) \
|
|
|
|
(debug_compile("== " desc "\n", \
|
|
|
|
iseq_compile_each(iseq, anchor, node, 0)))
|
|
|
|
|
2009-11-03 20:46:28 +03:00
|
|
|
/* compile node, this node's value will be popped */
|
* 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 11:49:45 +04:00
|
|
|
#define COMPILE_POPED(anchor, desc, node) \
|
|
|
|
(debug_compile("== " desc "\n", \
|
|
|
|
iseq_compile_each(iseq, anchor, node, 1)))
|
|
|
|
|
2009-11-03 20:46:28 +03:00
|
|
|
/* compile node, which is popped when 'poped' is true */
|
* 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 11:49:45 +04:00
|
|
|
#define COMPILE_(anchor, desc, node, poped) \
|
|
|
|
(debug_compile("== " desc "\n", \
|
|
|
|
iseq_compile_each(iseq, anchor, node, poped)))
|
|
|
|
|
|
|
|
#define OPERAND_AT(insn, idx) \
|
|
|
|
(((INSN*)(insn))->operands[idx])
|
|
|
|
|
|
|
|
#define INSN_OF(insn) \
|
|
|
|
(((INSN*)(insn))->insn_id)
|
|
|
|
|
|
|
|
/* error */
|
|
|
|
#define COMPILE_ERROR(strs) \
|
|
|
|
{ \
|
|
|
|
VALUE tmp = GET_THREAD()->errinfo; \
|
|
|
|
if (compile_debug) rb_compile_bug strs; \
|
|
|
|
GET_THREAD()->errinfo = iseq->compile_data->err_info; \
|
|
|
|
rb_compile_error strs; \
|
|
|
|
iseq->compile_data->err_info = GET_THREAD()->errinfo; \
|
|
|
|
GET_THREAD()->errinfo = tmp; \
|
|
|
|
ret = 0; \
|
|
|
|
break; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ERROR_ARGS ruby_sourcefile, nd_line(node),
|
|
|
|
|
|
|
|
|
|
|
|
#define COMPILE_OK 1
|
|
|
|
#define COMPILE_NG 0
|
|
|
|
|
|
|
|
|
|
|
|
/* leave name uninitialized so that compiler warn if INIT_ANCHOR is
|
|
|
|
* missing */
|
|
|
|
#define DECL_ANCHOR(name) \
|
|
|
|
LINK_ANCHOR *name, name##_body__ = {{0,},}
|
|
|
|
#define INIT_ANCHOR(name) \
|
|
|
|
(name##_body__.last = &name##_body__.anchor, name = &name##_body__)
|
|
|
|
|
2009-02-12 16:51:19 +03:00
|
|
|
#define hide_obj(obj) do {OBJ_FREEZE(obj); RBASIC(obj)->klass = 0;} while (0)
|
* 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 11:49:45 +04:00
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
#include "optinsn.inc"
|
|
|
|
#if OPT_INSTRUCTIONS_UNIFICATION
|
|
|
|
#include "optunifs.inc"
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
/* for debug */
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define ISEQ_ARG iseq,
|
|
|
|
#define ISEQ_ARG_DECLARE rb_iseq_t *iseq,
|
|
|
|
#else
|
|
|
|
#define ISEQ_ARG
|
|
|
|
#define ISEQ_ARG_DECLARE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CPDEBUG
|
|
|
|
#define gl_node_level iseq->compile_data->node_level
|
|
|
|
#if 0
|
|
|
|
static void debug_list(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor);
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static void dump_disasm_list(LINK_ELEMENT *elem);
|
|
|
|
|
|
|
|
static int insn_data_length(INSN *iobj);
|
|
|
|
static int insn_data_line_no(INSN *iobj);
|
|
|
|
static int calc_sp_depth(int depth, INSN *iobj);
|
|
|
|
|
2008-04-14 09:34:04 +04:00
|
|
|
static void ADD_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor, LINK_ELEMENT *elem);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...);
|
2009-05-17 09:27:32 +04:00
|
|
|
static LABEL *new_label_body(rb_iseq_t *iseq, long line);
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
static ADJUST *new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
static int iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * n, int);
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
static int iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
|
|
|
|
static int iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
|
|
|
|
static int iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
static int iseq_set_local_table(rb_iseq_t *iseq, ID *tbl);
|
|
|
|
static int iseq_set_exception_local_table(rb_iseq_t *iseq);
|
|
|
|
static int iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *anchor, NODE * node);
|
|
|
|
|
|
|
|
static int iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
|
|
|
|
static int iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor);
|
|
|
|
static int iseq_set_exception_table(rb_iseq_t *iseq);
|
|
|
|
static int iseq_set_optargs_table(rb_iseq_t *iseq);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-04-14 09:34:04 +04:00
|
|
|
/*
|
|
|
|
* To make Array to LinkedList, use link_anchor
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
2008-05-31 13:28:20 +04:00
|
|
|
verify_list(ISEQ_ARG_DECLARE const char *info, LINK_ANCHOR *anchor)
|
2008-04-14 09:34:04 +04:00
|
|
|
{
|
|
|
|
#if CPDEBUG
|
|
|
|
int flag = 0;
|
|
|
|
LINK_ELEMENT *list, *plist;
|
|
|
|
|
|
|
|
if (!compile_debug) return;
|
|
|
|
|
|
|
|
list = anchor->anchor.next;
|
|
|
|
plist = &anchor->anchor;
|
|
|
|
while (list) {
|
|
|
|
if (plist != list->prev) {
|
|
|
|
flag += 1;
|
|
|
|
}
|
|
|
|
plist = list;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anchor->last != plist && anchor->last != 0) {
|
|
|
|
flag |= 0x70000;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag != 0) {
|
|
|
|
rb_bug("list verify error: %08x (%s)", flag, info);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define verify_list(info, anchor) verify_list(iseq, info, anchor)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* elem1, elem2 => elem1, elem2, elem
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ADD_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor, LINK_ELEMENT *elem)
|
|
|
|
{
|
|
|
|
elem->prev = anchor->last;
|
|
|
|
anchor->last->next = elem;
|
|
|
|
anchor->last = elem;
|
|
|
|
verify_list("add", anchor);
|
|
|
|
}
|
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define ADD_ELEM(anchor, elem) ADD_ELEM(iseq, anchor, elem)
|
|
|
|
#endif
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_add_mark_object(rb_iseq_t *iseq, VALUE v)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2007-07-01 22:16:02 +04:00
|
|
|
if (!SPECIAL_CONST_P(v)) {
|
|
|
|
rb_ary_push(iseq->mark_ary, v);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
* eval.c (ruby_exec_node, ruby_run_node), ruby.c (process_options):
use iseq instead of NODE.
* gc.c (source_filenames): removed.
* include/ruby/intern.h, parse.y (yycompile, parser_mark, parser_free,
ripper_initialize): rb_source_filename() is no longer used.
* compile.c, compile.h (ERROR_ARGS), parse.y (node_newnode, fixpos,
parser_warn, e_option_supplied, warn_unless_e_option, range_op,
cond0): nd_file is no longer used.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-12 07:41:51 +04:00
|
|
|
#define ruby_sourcefile RSTRING_PTR(iseq->filename)
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_add_mark_object_compile_time(rb_iseq_t *iseq, VALUE v)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2007-07-01 22:16:02 +04:00
|
|
|
if (!SPECIAL_CONST_P(v)) {
|
|
|
|
rb_ary_push(iseq->compile_data->mark_ary, v);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
2009-01-19 04:06:56 +03:00
|
|
|
rb_iseq_compile_node(VALUE self, NODE *node)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
DECL_ANCHOR(ret);
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_iseq_t *iseq;
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(ret);
|
2006-12-31 18:02:22 +03:00
|
|
|
GetISeqPtr(self, iseq);
|
|
|
|
|
2007-05-25 19:37:05 +04:00
|
|
|
if (node == 0) {
|
|
|
|
COMPILE(ret, "nil", node);
|
2007-12-24 23:27:10 +03:00
|
|
|
iseq_set_local_table(iseq, 0);
|
2007-05-25 19:37:05 +04:00
|
|
|
}
|
|
|
|
else if (nd_type(node) == NODE_SCOPE) {
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
/* iseq type of top, method, class, block */
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_local_table(iseq, node->nd_tbl);
|
|
|
|
iseq_set_arguments(iseq, ret, node->nd_args);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-10 11:52:03 +04:00
|
|
|
switch (iseq->type) {
|
|
|
|
case ISEQ_TYPE_BLOCK: {
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0);
|
|
|
|
LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0);
|
|
|
|
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_LABEL(ret, start);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
COMPILE(ret, "block body", node->nd_body);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_LABEL(ret, end);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
/* wide range catch handler must put at last */
|
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, 0, start);
|
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, start, end, 0, end);
|
2007-07-10 11:52:03 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ISEQ_TYPE_CLASS: {
|
2009-07-22 17:37:26 +04:00
|
|
|
ADD_TRACE(ret, FIX2INT(iseq->line_no), RUBY_EVENT_CLASS);
|
2007-07-10 11:52:03 +04:00
|
|
|
COMPILE(ret, "scoped node", node->nd_body);
|
|
|
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ISEQ_TYPE_METHOD: {
|
2009-07-22 17:37:26 +04:00
|
|
|
ADD_TRACE(ret, FIX2INT(iseq->line_no), RUBY_EVENT_CALL);
|
2007-07-10 11:52:03 +04:00
|
|
|
COMPILE(ret, "scoped node", node->nd_body);
|
|
|
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
COMPILE(ret, "scoped node", node->nd_body);
|
|
|
|
break;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
}
|
|
|
|
else {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
switch (iseq->type) {
|
|
|
|
case ISEQ_TYPE_METHOD:
|
|
|
|
case ISEQ_TYPE_CLASS:
|
|
|
|
case ISEQ_TYPE_BLOCK:
|
|
|
|
case ISEQ_TYPE_EVAL:
|
2008-12-27 08:58:23 +03:00
|
|
|
case ISEQ_TYPE_MAIN:
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
case ISEQ_TYPE_TOP:
|
|
|
|
rb_compile_error(ERROR_ARGS "compile/should not be reached: %s:%d",
|
|
|
|
__FILE__, __LINE__);
|
|
|
|
break;
|
|
|
|
case ISEQ_TYPE_RESCUE:
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_exception_local_table(iseq);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
COMPILE(ret, "rescue", node);
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
break;
|
|
|
|
case ISEQ_TYPE_ENSURE:
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_exception_local_table(iseq);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
COMPILE_POPED(ret, "ensure", node);
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
break;
|
|
|
|
case ISEQ_TYPE_DEFINED_GUARD:
|
2008-05-25 12:55:09 +04:00
|
|
|
iseq_set_local_table(iseq, 0);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
COMPILE(ret, "defined guard", node);
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
break;
|
|
|
|
default:
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("unknown scope");
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iseq->type == ISEQ_TYPE_RESCUE || iseq->type == ISEQ_TYPE_ENSURE) {
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
ADD_INSN2(ret, 0, getdynamic, INT2FIX(2), INT2FIX(0));
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
ADD_INSN1(ret, 0, throw, INT2FIX(0) /* continue throw */ );
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
ADD_INSN(ret, iseq->compile_data->last_line, leave);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
return iseq_setup(iseq, ret);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2007-07-02 16:49:35 +04:00
|
|
|
int
|
2009-01-19 04:06:56 +03:00
|
|
|
rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
|
* vm.c: add a prefix "rb_" to exposed functions
vm_get_ruby_level_next_cfp(), rb_vm_make_env_object(),
vm_stack_to_heap(), vm_make_proc(), vm_invoke_proc(),
vm_get_sourceline(), vm_cref(), vm_localjump_error(),
vm_make_jump_tag_but_local_jump(), vm_jump_tag_but_local_jump().
This changes may affect only core because most of renamed functions
require a pointer of not-exposed struct such as rb_thread_t or NODE.
In short, they are core functions.
* cont.c, eval.c, eval_intern.h, load.c, proc.c, thread.c,
vm_core.h, vm_dump.c, vm_eval.c, vm_exec.c, vm_insnhelper.c:
ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 05:38:11 +03:00
|
|
|
extern const void **rb_vm_get_insns_address_table(void);
|
2006-12-31 18:02:22 +03:00
|
|
|
#if OPT_DIRECT_THREADED_CODE
|
* vm.c: add a prefix "rb_" to exposed functions
vm_get_ruby_level_next_cfp(), rb_vm_make_env_object(),
vm_stack_to_heap(), vm_make_proc(), vm_invoke_proc(),
vm_get_sourceline(), vm_cref(), vm_localjump_error(),
vm_make_jump_tag_but_local_jump(), vm_jump_tag_but_local_jump().
This changes may affect only core because most of renamed functions
require a pointer of not-exposed struct such as rb_thread_t or NODE.
In short, they are core functions.
* cont.c, eval.c, eval_intern.h, load.c, proc.c, thread.c,
vm_core.h, vm_dump.c, vm_eval.c, vm_exec.c, vm_insnhelper.c:
ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 05:38:11 +03:00
|
|
|
const void * const *table = rb_vm_get_insns_address_table();
|
2006-12-31 18:02:22 +03:00
|
|
|
#else
|
* vm.c: add a prefix "rb_" to exposed functions
vm_get_ruby_level_next_cfp(), rb_vm_make_env_object(),
vm_stack_to_heap(), vm_make_proc(), vm_invoke_proc(),
vm_get_sourceline(), vm_cref(), vm_localjump_error(),
vm_make_jump_tag_but_local_jump(), vm_jump_tag_but_local_jump().
This changes may affect only core because most of renamed functions
require a pointer of not-exposed struct such as rb_thread_t or NODE.
In short, they are core functions.
* cont.c, eval.c, eval_intern.h, load.c, proc.c, thread.c,
vm_core.h, vm_dump.c, vm_eval.c, vm_exec.c, vm_insnhelper.c:
ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-19 05:38:11 +03:00
|
|
|
const void * const *table = rb_vm_get_insns_address_table();
|
2006-12-31 18:02:22 +03:00
|
|
|
#endif
|
2009-05-17 09:27:32 +04:00
|
|
|
unsigned long i;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-06-30 22:04:35 +04:00
|
|
|
iseq->iseq_encoded = ALLOC_N(VALUE, iseq->iseq_size);
|
|
|
|
MEMCPY(iseq->iseq_encoded, iseq->iseq, VALUE, iseq->iseq_size);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-06-30 22:04:35 +04:00
|
|
|
for (i = 0; i < iseq->iseq_size; /* */ ) {
|
2009-06-22 11:05:50 +04:00
|
|
|
int insn = (int)iseq->iseq_encoded[i];
|
2006-12-31 18:02:22 +03:00
|
|
|
int len = insn_len(insn);
|
|
|
|
iseq->iseq_encoded[i] = (VALUE)table[insn];
|
|
|
|
i += len;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
iseq->iseq_encoded = iseq->iseq;
|
|
|
|
#endif
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
/* definition of data structure for compiler */
|
|
|
|
/*********************************************/
|
|
|
|
|
|
|
|
static void *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
compile_data_alloc(rb_iseq_t *iseq, size_t size)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
void *ptr = 0;
|
|
|
|
struct iseq_compile_data_storage *storage =
|
|
|
|
iseq->compile_data->storage_current;
|
|
|
|
|
|
|
|
if (storage->pos + size > storage->size) {
|
|
|
|
unsigned long alloc_size = storage->size * 2;
|
|
|
|
|
|
|
|
retry:
|
|
|
|
if (alloc_size < size) {
|
|
|
|
alloc_size *= 2;
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
storage->next = (void *)ALLOC_N(char, alloc_size +
|
|
|
|
sizeof(struct
|
|
|
|
iseq_compile_data_storage));
|
|
|
|
storage = iseq->compile_data->storage_current = storage->next;
|
|
|
|
storage->next = 0;
|
|
|
|
storage->pos = 0;
|
|
|
|
storage->size = alloc_size;
|
|
|
|
storage->buff = (char *)(&storage->buff + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ptr = (void *)&storage->buff[storage->pos];
|
|
|
|
storage->pos += size;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INSN *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
compile_data_alloc_insn(rb_iseq_t *iseq)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
return (INSN *)compile_data_alloc(iseq, sizeof(INSN));
|
|
|
|
}
|
|
|
|
|
|
|
|
static LABEL *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
compile_data_alloc_label(rb_iseq_t *iseq)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
return (LABEL *)compile_data_alloc(iseq, sizeof(LABEL));
|
|
|
|
}
|
|
|
|
|
2008-01-25 21:02:01 +03:00
|
|
|
static ADJUST *
|
|
|
|
compile_data_alloc_adjust(rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
return (ADJUST *)compile_data_alloc(iseq, sizeof(ADJUST));
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/*
|
|
|
|
* elem1, elemX => elem1, elem2, elemX
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
INSERT_ELEM_NEXT(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
|
|
|
|
{
|
|
|
|
elem2->next = elem1->next;
|
|
|
|
elem2->prev = elem1;
|
|
|
|
elem1->next = elem2;
|
|
|
|
if (elem2->next) {
|
|
|
|
elem2->next->prev = elem2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 19:42:41 +04:00
|
|
|
#if 0 /* unused */
|
2006-12-31 18:02:22 +03:00
|
|
|
/*
|
|
|
|
* elemX, elem1 => elemX, elem2, elem1
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
INSERT_ELEM_PREV(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
|
|
|
|
{
|
|
|
|
elem2->prev = elem1->prev;
|
|
|
|
elem2->next = elem1;
|
|
|
|
elem1->prev = elem2;
|
|
|
|
if (elem2->prev) {
|
|
|
|
elem2->prev->next = elem2;
|
|
|
|
}
|
|
|
|
}
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 19:42:41 +04:00
|
|
|
#endif
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/*
|
|
|
|
* elemX, elem1, elemY => elemX, elem2, elemY
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
REPLACE_ELEM(LINK_ELEMENT *elem1, LINK_ELEMENT *elem2)
|
|
|
|
{
|
|
|
|
elem2->prev = elem1->prev;
|
|
|
|
elem2->next = elem1->next;
|
|
|
|
if (elem1->prev) {
|
|
|
|
elem1->prev->next = elem2;
|
|
|
|
}
|
|
|
|
if (elem1->next) {
|
|
|
|
elem1->next->prev = elem2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
REMOVE_ELEM(LINK_ELEMENT *elem)
|
|
|
|
{
|
|
|
|
elem->prev->next = elem->next;
|
|
|
|
if (elem->next) {
|
|
|
|
elem->next->prev = elem->prev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static LINK_ELEMENT *
|
|
|
|
FIRST_ELEMENT(LINK_ANCHOR *anchor)
|
|
|
|
{
|
|
|
|
return anchor->anchor.next;
|
|
|
|
}
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 01:13:04 +03:00
|
|
|
#if 0 /* unused */
|
2006-12-31 18:02:22 +03:00
|
|
|
static LINK_ELEMENT *
|
|
|
|
LAST_ELEMENT(LINK_ANCHOR *anchor)
|
|
|
|
{
|
|
|
|
return anchor->last;
|
|
|
|
}
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 01:13:04 +03:00
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
static LINK_ELEMENT *
|
2008-04-14 09:34:04 +04:00
|
|
|
POP_ELEMENT(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LINK_ELEMENT *elem = anchor->last;
|
|
|
|
anchor->last = anchor->last->prev;
|
|
|
|
anchor->last->next = 0;
|
|
|
|
verify_list("pop", anchor);
|
|
|
|
return elem;
|
|
|
|
}
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define POP_ELEMENT(anchor) POP_ELEMENT(iseq, anchor)
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 19:42:41 +04:00
|
|
|
#if 0 /* unused */
|
2006-12-31 18:02:22 +03:00
|
|
|
static LINK_ELEMENT *
|
|
|
|
SHIFT_ELEMENT(LINK_ANCHOR *anchor)
|
|
|
|
{
|
|
|
|
LINK_ELEMENT *elem = anchor->anchor.next;
|
|
|
|
if (elem) {
|
|
|
|
anchor->anchor.next = elem->next;
|
|
|
|
}
|
|
|
|
return elem;
|
|
|
|
}
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 19:42:41 +04:00
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 19:42:41 +04:00
|
|
|
#if 0 /* unused */
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
|
|
|
LIST_SIZE(LINK_ANCHOR *anchor)
|
|
|
|
{
|
|
|
|
LINK_ELEMENT *elem = anchor->anchor.next;
|
|
|
|
int size = 0;
|
|
|
|
while (elem) {
|
|
|
|
size += 1;
|
|
|
|
elem = elem->next;
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 19:42:41 +04:00
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
LIST_SIZE_ZERO(LINK_ANCHOR *anchor)
|
|
|
|
{
|
|
|
|
if (anchor->anchor.next == 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* anc1: e1, e2, e3
|
|
|
|
* anc2: e4, e5
|
|
|
|
*#=>
|
|
|
|
* anc1: e1, e2, e3, e4, e5
|
|
|
|
* anc2: e4, e5 (broken)
|
|
|
|
*/
|
|
|
|
static void
|
2008-04-14 09:34:04 +04:00
|
|
|
APPEND_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
if (anc2->anchor.next) {
|
|
|
|
anc1->last->next = anc2->anchor.next;
|
|
|
|
anc2->anchor.next->prev = anc1->last;
|
|
|
|
anc1->last = anc2->last;
|
|
|
|
}
|
|
|
|
verify_list("append", anc1);
|
|
|
|
}
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define APPEND_LIST(anc1, anc2) APPEND_LIST(iseq, anc1, anc2)
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* anc1: e1, e2, e3
|
|
|
|
* anc2: e4, e5
|
|
|
|
*#=>
|
|
|
|
* anc1: e4, e5, e1, e2, e3
|
|
|
|
* anc2: e4, e5 (broken)
|
|
|
|
*/
|
|
|
|
static void
|
2008-04-14 09:34:04 +04:00
|
|
|
INSERT_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
if (anc2->anchor.next) {
|
|
|
|
LINK_ELEMENT *first = anc1->anchor.next;
|
|
|
|
anc1->anchor.next = anc2->anchor.next;
|
|
|
|
anc1->anchor.next->prev = &anc1->anchor;
|
|
|
|
anc2->last->next = first;
|
|
|
|
if (first) {
|
|
|
|
first->prev = anc2->last;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
anc1->last = anc2->last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
verify_list("append", anc1);
|
|
|
|
}
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define INSERT_LIST(anc1, anc2) INSERT_LIST(iseq, anc1, anc2)
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-14 01:13:04 +03:00
|
|
|
#if 0 /* unused */
|
2006-12-31 18:02:22 +03:00
|
|
|
/*
|
|
|
|
* anc1: e1, e2, e3
|
|
|
|
* anc2: e4, e5
|
|
|
|
*#=>
|
|
|
|
* anc1: e4, e5
|
|
|
|
* anc2: e1, e2, e3
|
|
|
|
*/
|
|
|
|
static void
|
2008-04-14 09:34:04 +04:00
|
|
|
SWAP_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LINK_ANCHOR tmp = *anc2;
|
|
|
|
|
|
|
|
/* it has bug */
|
|
|
|
*anc2 = *anc1;
|
|
|
|
*anc1 = tmp;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
verify_list("swap1", anc1);
|
|
|
|
verify_list("swap2", anc2);
|
|
|
|
}
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define SWAP_LIST(anc1, anc2) SWAP_LIST(iseq, anc1, anc2)
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
static LINK_ANCHOR *
|
2008-04-14 09:34:04 +04:00
|
|
|
REVERSE_LIST(ISEQ_ARG_DECLARE LINK_ANCHOR *anc)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LINK_ELEMENT *first, *last, *elem, *e;
|
|
|
|
first = &anc->anchor;
|
|
|
|
elem = first->next;
|
|
|
|
last = anc->last;
|
|
|
|
|
|
|
|
if (elem != 0) {
|
|
|
|
anc->anchor.next = last;
|
|
|
|
anc->last = elem;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* null list */
|
|
|
|
return anc;
|
|
|
|
}
|
|
|
|
while (elem) {
|
|
|
|
e = elem->next;
|
|
|
|
elem->next = elem->prev;
|
|
|
|
elem->prev = e;
|
|
|
|
elem = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
first->next = last;
|
|
|
|
last->prev = first;
|
|
|
|
anc->last->next = 0;
|
|
|
|
|
|
|
|
verify_list("reverse", anc);
|
|
|
|
return anc;
|
|
|
|
}
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define REVERSE_LIST(anc) REVERSE_LIST(iseq, anc)
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
#endif
|
|
|
|
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG && 0
|
2006-12-31 18:02:22 +03:00
|
|
|
static void
|
2008-04-14 09:34:04 +04:00
|
|
|
debug_list(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LINK_ELEMENT *list = FIRST_ELEMENT(anchor);
|
|
|
|
printf("----\n");
|
|
|
|
printf("anch: %p, frst: %p, last: %p\n", &anchor->anchor,
|
|
|
|
anchor->anchor.next, anchor->last);
|
|
|
|
while (list) {
|
|
|
|
printf("curr: %p, next: %p, prev: %p, type: %d\n", list, list->next,
|
|
|
|
list->prev, FIX2INT(list->type));
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
printf("----\n");
|
|
|
|
|
|
|
|
dump_disasm_list(anchor->anchor.next);
|
|
|
|
verify_list("debug list", anchor);
|
|
|
|
}
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
|
|
|
#define debug_list(anc) debug_list(iseq, anc)
|
|
|
|
#endif
|
2006-12-31 18:02:22 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static LABEL *
|
2009-05-17 09:27:32 +04:00
|
|
|
new_label_body(rb_iseq_t *iseq, long line)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LABEL *labelobj = compile_data_alloc_label(iseq);
|
|
|
|
|
|
|
|
labelobj->link.type = ISEQ_ELEMENT_LABEL;
|
|
|
|
labelobj->link.next = 0;
|
|
|
|
|
2008-04-20 10:01:28 +04:00
|
|
|
labelobj->label_no = iseq->compile_data->label_no++;
|
2006-12-31 18:02:22 +03:00
|
|
|
labelobj->sc_state = 0;
|
|
|
|
labelobj->sp = -1;
|
|
|
|
return labelobj;
|
|
|
|
}
|
|
|
|
|
2008-01-25 21:02:01 +03:00
|
|
|
static ADJUST *
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line)
|
2008-01-25 21:02:01 +03:00
|
|
|
{
|
|
|
|
ADJUST *adjust = compile_data_alloc_adjust(iseq);
|
|
|
|
adjust->link.type = ISEQ_ELEMENT_ADJUST;
|
|
|
|
adjust->link.next = 0;
|
|
|
|
adjust->label = label;
|
|
|
|
adjust->line_no = line;
|
|
|
|
return adjust;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static INSN *
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
new_insn_core(rb_iseq_t *iseq, int line_no,
|
2006-12-31 18:02:22 +03:00
|
|
|
int insn_id, int argc, VALUE *argv)
|
|
|
|
{
|
|
|
|
INSN *iobj = compile_data_alloc_insn(iseq);
|
|
|
|
|
|
|
|
iobj->link.type = ISEQ_ELEMENT_INSN;
|
|
|
|
iobj->link.next = 0;
|
|
|
|
iobj->insn_id = insn_id;
|
|
|
|
iobj->line_no = line_no;
|
|
|
|
iobj->operands = argv;
|
|
|
|
iobj->operand_size = argc;
|
|
|
|
iobj->sc_state = 0;
|
|
|
|
return iobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static INSN *
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE *operands = 0;
|
|
|
|
va_list argv;
|
|
|
|
if (argc > 0) {
|
|
|
|
int i;
|
|
|
|
va_init_list(argv, argc);
|
|
|
|
operands = (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * argc);
|
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
VALUE v = va_arg(argv, VALUE);
|
|
|
|
operands[i] = v;
|
|
|
|
}
|
|
|
|
va_end(argv);
|
|
|
|
}
|
|
|
|
return new_insn_core(iseq, line_no, insn_id, argc, operands);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INSN *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
new_insn_send(rb_iseq_t *iseq, int line_no,
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE id, VALUE argc, VALUE block, VALUE flag)
|
|
|
|
{
|
|
|
|
INSN *iobj = 0;
|
|
|
|
VALUE *operands =
|
2009-07-13 08:44:20 +04:00
|
|
|
(VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * 4);
|
2006-12-31 18:02:22 +03:00
|
|
|
operands[0] = id;
|
|
|
|
operands[1] = argc;
|
|
|
|
operands[2] = block;
|
|
|
|
operands[3] = flag;
|
2009-07-13 08:44:20 +04:00
|
|
|
iobj = new_insn_core(iseq, line_no, BIN(send), 4, operands);
|
2006-12-31 18:02:22 +03:00
|
|
|
return iobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
new_child_iseq(rb_iseq_t *iseq, NODE *node,
|
2009-07-22 17:37:26 +04:00
|
|
|
VALUE name, VALUE parent, VALUE type, int line_no)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE ret;
|
|
|
|
|
|
|
|
debugs("[new_child_iseq]> ---------------------------------------\n");
|
2009-07-22 17:37:26 +04:00
|
|
|
ret = rb_iseq_new_with_opt(node, name, iseq_filename(iseq->self), INT2FIX(line_no),
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
parent, type, iseq->compile_data->option);
|
2006-12-31 18:02:22 +03:00
|
|
|
debugs("[new_child_iseq]< ---------------------------------------\n");
|
|
|
|
iseq_add_mark_object(iseq, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 19:26:04 +03:00
|
|
|
/* debugs("[compile step 2] (iseq_array_to_linkedlist)\n"); */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-04-14 09:34:04 +04:00
|
|
|
if (compile_debug > 5)
|
2006-12-31 18:02:22 +03:00
|
|
|
dump_disasm_list(FIRST_ELEMENT(anchor));
|
|
|
|
|
|
|
|
debugs("[compile step 3.1 (iseq_optimize)]\n");
|
|
|
|
iseq_optimize(iseq, anchor);
|
|
|
|
|
2008-04-14 09:34:04 +04:00
|
|
|
if (compile_debug > 5)
|
2006-12-31 18:02:22 +03:00
|
|
|
dump_disasm_list(FIRST_ELEMENT(anchor));
|
|
|
|
|
|
|
|
if (iseq->compile_data->option->instructions_unification) {
|
|
|
|
debugs("[compile step 3.2 (iseq_insns_unification)]\n");
|
|
|
|
iseq_insns_unification(iseq, anchor);
|
2008-04-14 09:34:04 +04:00
|
|
|
if (compile_debug > 5)
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
dump_disasm_list(FIRST_ELEMENT(anchor));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (iseq->compile_data->option->stack_caching) {
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
debugs("[compile step 3.3 (iseq_set_sequence_stackcaching)]\n");
|
|
|
|
iseq_set_sequence_stackcaching(iseq, anchor);
|
2008-04-14 09:34:04 +04:00
|
|
|
if (compile_debug > 5)
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
dump_disasm_list(FIRST_ELEMENT(anchor));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
debugs("[compile step 4.1 (iseq_set_sequence)]\n");
|
|
|
|
iseq_set_sequence(iseq, anchor);
|
2008-04-14 09:34:04 +04:00
|
|
|
if (compile_debug > 5)
|
2006-12-31 18:02:22 +03:00
|
|
|
dump_disasm_list(FIRST_ELEMENT(anchor));
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
debugs("[compile step 4.2 (iseq_set_exception_table)]\n");
|
|
|
|
iseq_set_exception_table(iseq);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
debugs("[compile step 4.3 (set_optargs_table)] \n");
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_optargs_table(iseq);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-02 16:49:35 +04:00
|
|
|
debugs("[compile step 5 (iseq_translate_threaded_code)] \n");
|
2009-01-19 04:06:56 +03:00
|
|
|
rb_iseq_translate_threaded_code(iseq);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-04-14 09:34:04 +04:00
|
|
|
if (compile_debug > 1) {
|
2009-01-19 04:06:56 +03:00
|
|
|
VALUE str = rb_iseq_disasm(iseq->self);
|
2006-12-31 18:02:22 +03:00
|
|
|
printf("%s\n", StringValueCStr(str));
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
debugs("[compile step: finish]\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
static int
|
|
|
|
iseq_set_exception_local_table(rb_iseq_t *iseq)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2008-06-09 13:25:32 +04:00
|
|
|
ID id_dollar_bang;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-06-09 13:25:32 +04:00
|
|
|
CONST_ID(id_dollar_bang, "#$!");
|
2007-02-25 04:34:33 +03:00
|
|
|
iseq->local_table = (ID *)ALLOC_N(ID *, 1);
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
iseq->local_table_size = 1;
|
|
|
|
iseq->local_size = iseq->local_table_size + 1;
|
2007-02-25 04:34:33 +03:00
|
|
|
iseq->local_table[0] = id_dollar_bang;
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
get_dyna_var_idx_at_raw(rb_iseq_t *iseq, ID id)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
int i;
|
2007-02-25 04:34:33 +03:00
|
|
|
|
|
|
|
for (i = 0; i < iseq->local_table_size; i++) {
|
|
|
|
if (iseq->local_table[i] == id) {
|
2006-12-31 18:02:22 +03:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-02-25 04:34:33 +03:00
|
|
|
static int
|
2007-07-07 12:14:00 +04:00
|
|
|
get_local_var_idx(rb_iseq_t *iseq, ID id)
|
2007-02-25 04:34:33 +03:00
|
|
|
{
|
|
|
|
int idx = get_dyna_var_idx_at_raw(iseq->local_iseq, id);
|
|
|
|
|
2007-07-07 12:14:00 +04:00
|
|
|
if (idx < 0) {
|
|
|
|
rb_bug("get_local_var_idx: %d", idx);
|
2007-02-25 04:34:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
2007-07-07 12:14:00 +04:00
|
|
|
get_dyna_var_idx(rb_iseq_t *iseq, ID id, int *level, int *ls)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2007-07-07 12:14:00 +04:00
|
|
|
int lv = 0, idx = -1;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-07 12:14:00 +04:00
|
|
|
while (iseq) {
|
|
|
|
idx = get_dyna_var_idx_at_raw(iseq, id);
|
|
|
|
if (idx >= 0) {
|
|
|
|
break;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
iseq = iseq->parent_iseq;
|
|
|
|
lv++;
|
|
|
|
}
|
2007-07-07 12:14:00 +04:00
|
|
|
|
|
|
|
if (idx < 0) {
|
|
|
|
rb_bug("get_dyna_var_idx: -1");
|
|
|
|
}
|
|
|
|
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
*level = lv;
|
|
|
|
*ls = iseq->local_size;
|
|
|
|
return idx;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:07:05 +03:00
|
|
|
static int
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *optargs, NODE *node_args)
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:07:05 +03:00
|
|
|
{
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
debugs("iseq_set_arguments: %s\n", node_args ? "" : "0");
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
|
|
|
|
if (node_args) {
|
|
|
|
NODE *node_aux = node_args->nd_next;
|
|
|
|
NODE *node_opt = node_args->nd_opt;
|
|
|
|
ID rest_id = 0;
|
2007-06-25 20:05:17 +04:00
|
|
|
int last_comma = 0;
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
ID block_id = 0;
|
|
|
|
NODE *node_init = 0;
|
|
|
|
|
|
|
|
if (nd_type(node_args) != NODE_ARGS) {
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
rb_bug("iseq_set_arguments: NODE_ARGS is expected, but %s",
|
2007-07-07 12:14:00 +04:00
|
|
|
ruby_node_name(nd_type(node_args)));
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:07:05 +03:00
|
|
|
}
|
|
|
|
|
2007-05-17 08:25:18 +04:00
|
|
|
/*
|
2009-11-03 20:46:28 +03:00
|
|
|
* new argument information:
|
2007-06-25 20:05:17 +04:00
|
|
|
* NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
|
|
|
|
* NODE_ARGS_AUX [r: ID, b: ID, ->]
|
|
|
|
* NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
|
2007-05-17 08:25:18 +04:00
|
|
|
* optarg information:
|
2007-06-25 20:05:17 +04:00
|
|
|
* NODE_OPT_ARGS [idx, expr, next ->]
|
2007-05-17 08:25:18 +04:00
|
|
|
* init arg:
|
|
|
|
* NODE_AND(m_init, p_init)
|
2007-06-25 20:05:17 +04:00
|
|
|
* if "r" is 1, it's means "{|x,|}" type block parameter.
|
2007-05-17 08:25:18 +04:00
|
|
|
*/
|
|
|
|
|
2009-06-22 11:05:50 +04:00
|
|
|
iseq->argc = (int)node_args->nd_frml;
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
debugs(" - argc: %d\n", iseq->argc);
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:07:05 +03:00
|
|
|
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
if (node_aux) {
|
|
|
|
rest_id = node_aux->nd_rest;
|
2007-06-25 20:05:17 +04:00
|
|
|
if (rest_id == 1) {
|
|
|
|
last_comma = 1;
|
|
|
|
rest_id = 0;
|
|
|
|
}
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
block_id = (ID)node_aux->nd_body;
|
|
|
|
node_aux = node_aux->nd_next;
|
|
|
|
|
|
|
|
if (node_aux) {
|
2007-06-24 11:29:21 +04:00
|
|
|
ID post_start_id = node_aux->nd_pid;
|
|
|
|
iseq->arg_post_start = get_dyna_var_idx_at_raw(iseq, post_start_id);
|
2009-06-22 11:05:50 +04:00
|
|
|
iseq->arg_post_len = (int)node_aux->nd_plen;
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
node_init = node_aux->nd_next;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
if (node_opt) {
|
|
|
|
NODE *node = node_opt;
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *label;
|
2009-06-22 11:14:32 +04:00
|
|
|
VALUE labels = rb_ary_tmp_new(1);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
int i = 0, j;
|
|
|
|
|
|
|
|
while (node) {
|
2006-12-31 18:02:22 +03:00
|
|
|
label = NEW_LABEL(nd_line(node));
|
|
|
|
rb_ary_push(labels, (VALUE)label | 1);
|
|
|
|
ADD_LABEL(optargs, label);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
COMPILE_POPED(optargs, "optarg", node->nd_body);
|
|
|
|
node = node->nd_next;
|
2006-12-31 18:02:22 +03:00
|
|
|
i += 1;
|
|
|
|
}
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/* last label */
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
label = NEW_LABEL(nd_line(node_args));
|
2006-12-31 18:02:22 +03:00
|
|
|
rb_ary_push(labels, (VALUE)label | 1);
|
|
|
|
ADD_LABEL(optargs, label);
|
|
|
|
i += 1;
|
|
|
|
|
|
|
|
iseq->arg_opts = i;
|
2007-07-01 22:16:02 +04:00
|
|
|
iseq->arg_opt_table = ALLOC_N(VALUE, i);
|
|
|
|
MEMCPY(iseq->arg_opt_table, RARRAY_PTR(labels), VALUE, i);
|
2006-12-31 18:02:22 +03:00
|
|
|
for (j = 0; j < i; j++) {
|
2007-07-01 22:16:02 +04:00
|
|
|
iseq->arg_opt_table[j] &= ~1;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2009-06-22 11:14:32 +04:00
|
|
|
rb_ary_clear(labels);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
iseq->arg_opts = 0;
|
|
|
|
}
|
|
|
|
|
2007-05-17 08:25:18 +04:00
|
|
|
if (node_init) {
|
|
|
|
if (node_init->nd_1st) { /* m_init */
|
|
|
|
COMPILE_POPED(optargs, "init arguments (m)", node_init->nd_1st);
|
|
|
|
}
|
|
|
|
if (node_init->nd_2nd) { /* p_init */
|
|
|
|
COMPILE_POPED(optargs, "init arguments (p)", node_init->nd_2nd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
if (rest_id) {
|
2007-06-24 11:29:21 +04:00
|
|
|
iseq->arg_rest = get_dyna_var_idx_at_raw(iseq, rest_id);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
|
|
|
|
if (iseq->arg_rest == -1) {
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("arg_rest: -1");
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
}
|
2007-05-01 08:35:58 +04:00
|
|
|
|
2007-06-24 11:29:21 +04:00
|
|
|
if (iseq->arg_post_start == 0) {
|
|
|
|
iseq->arg_post_start = iseq->arg_rest + 1;
|
2007-05-01 08:35:58 +04:00
|
|
|
}
|
2007-07-20 11:30:33 +04:00
|
|
|
}
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
|
|
|
|
if (block_id) {
|
2007-06-24 11:29:21 +04:00
|
|
|
iseq->arg_block = get_dyna_var_idx_at_raw(iseq, block_id);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
}
|
|
|
|
|
2007-06-24 11:29:21 +04:00
|
|
|
if (iseq->arg_opts != 0 || iseq->arg_post_len != 0 ||
|
|
|
|
iseq->arg_rest != -1 || iseq->arg_block != -1) {
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
iseq->arg_simple = 0;
|
2007-06-24 11:29:21 +04:00
|
|
|
|
|
|
|
/* set arg_size: size of arguments */
|
|
|
|
if (iseq->arg_block != -1) {
|
|
|
|
iseq->arg_size = iseq->arg_block + 1;
|
2007-08-16 20:29:11 +04:00
|
|
|
}
|
2007-06-24 11:29:21 +04:00
|
|
|
else if (iseq->arg_post_len) {
|
|
|
|
iseq->arg_size = iseq->arg_post_start + iseq->arg_post_len;
|
|
|
|
}
|
|
|
|
else if (iseq->arg_rest != -1) {
|
|
|
|
iseq->arg_size = iseq->arg_rest + 1;
|
|
|
|
}
|
|
|
|
else if (iseq->arg_opts) {
|
|
|
|
iseq->arg_size = iseq->argc + iseq->arg_opts - 1;
|
|
|
|
}
|
2007-08-16 20:29:11 +04:00
|
|
|
else {
|
2007-06-24 11:29:21 +04:00
|
|
|
iseq->arg_size = iseq->argc;
|
|
|
|
}
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
iseq->arg_simple = 1;
|
2007-06-24 11:29:21 +04:00
|
|
|
iseq->arg_size = iseq->argc;
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
}
|
2007-06-25 20:05:17 +04:00
|
|
|
|
|
|
|
if (iseq->type == ISEQ_TYPE_BLOCK) {
|
2007-08-16 20:29:11 +04:00
|
|
|
if (iseq->arg_opts == 0 && iseq->arg_post_len == 0 && iseq->arg_rest == -1) {
|
|
|
|
if (iseq->argc == 1 && last_comma == 0) {
|
|
|
|
/* {|a|} */
|
2007-08-18 06:48:13 +04:00
|
|
|
iseq->arg_simple |= 0x02;
|
2007-08-16 20:29:11 +04:00
|
|
|
}
|
2007-06-25 20:05:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iseq->arg_simple = 1;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-06-25 20:05:17 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_local_table(rb_iseq_t *iseq, ID *tbl)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
int size;
|
2007-02-25 04:34:33 +03:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
if (tbl) {
|
2009-06-22 11:05:50 +04:00
|
|
|
size = (int)*tbl;
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
tbl++;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
2007-02-25 04:34:33 +03:00
|
|
|
size = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-02-25 04:34:33 +03:00
|
|
|
|
|
|
|
if (size > 0) {
|
|
|
|
iseq->local_table = (ID *)ALLOC_N(ID *, size);
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
MEMCPY(iseq->local_table, tbl, ID *, size);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-02-25 04:34:33 +03:00
|
|
|
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
iseq->local_size = iseq->local_table_size = size;
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
iseq->local_size += 1;
|
|
|
|
/*
|
|
|
|
if (lfp == dfp ) { // top, class, method
|
|
|
|
dfp[-1]: svar
|
|
|
|
else { // block
|
|
|
|
dfp[-1]: cref
|
|
|
|
}
|
|
|
|
*/
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
debugs("iseq_set_local_table: %d, %d\n", iseq->local_size, iseq->local_table_size);
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2009-02-27 12:30:53 +03:00
|
|
|
static int
|
|
|
|
cdhash_cmp(VALUE val, VALUE lit)
|
|
|
|
{
|
|
|
|
if (val == lit) return 0;
|
|
|
|
if (SPECIAL_CONST_P(lit)) {
|
|
|
|
return val != lit;
|
|
|
|
}
|
|
|
|
if (SPECIAL_CONST_P(val) || BUILTIN_TYPE(val) != BUILTIN_TYPE(lit)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (BUILTIN_TYPE(lit) == T_STRING) {
|
|
|
|
return rb_str_hash_cmp(lit, val);
|
|
|
|
}
|
|
|
|
return !rb_eql(lit, val);
|
|
|
|
}
|
|
|
|
|
2009-09-08 17:10:04 +04:00
|
|
|
static st_index_t
|
2009-02-27 12:30:53 +03:00
|
|
|
cdhash_hash(VALUE a)
|
|
|
|
{
|
2009-09-08 17:10:04 +04:00
|
|
|
if (SPECIAL_CONST_P(a)) return (st_index_t)a;
|
2009-02-27 12:30:53 +03:00
|
|
|
if (TYPE(a) == T_STRING) return rb_str_hash(a);
|
|
|
|
{
|
|
|
|
VALUE hval = rb_hash(a);
|
2009-09-08 17:10:04 +04:00
|
|
|
return (st_index_t)FIX2LONG(hval);
|
2009-02-27 12:30:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct st_hash_type cdhash_type = {
|
|
|
|
cdhash_cmp,
|
|
|
|
cdhash_hash,
|
|
|
|
};
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/**
|
|
|
|
ruby insn object array -> raw instruction sequence
|
|
|
|
*/
|
|
|
|
static int
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LABEL *lobj;
|
|
|
|
INSN *iobj;
|
2007-07-01 22:16:02 +04:00
|
|
|
struct iseq_insn_info_entry *insn_info_table;
|
2006-12-31 18:02:22 +03:00
|
|
|
LINK_ELEMENT *list;
|
|
|
|
VALUE *generated_iseq;
|
2009-07-13 13:30:23 +04:00
|
|
|
int ic_size = 0;
|
|
|
|
int ic_index = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
int k, pos, sp, stack_max = 0, line = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
/* set label position */
|
|
|
|
list = FIRST_ELEMENT(anchor);
|
|
|
|
k = pos = 0;
|
|
|
|
while (list) {
|
|
|
|
switch (list->type) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_INSN:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
iobj = (INSN *)list;
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
line = iobj->line_no;
|
2008-01-25 21:02:01 +03:00
|
|
|
pos += insn_data_length(iobj);
|
2009-07-13 13:30:23 +04:00
|
|
|
ic_size += insn_iclen(iobj->insn_id);
|
2008-01-25 21:02:01 +03:00
|
|
|
k++;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_LABEL:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
lobj = (LABEL *)list;
|
|
|
|
lobj->position = pos;
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
lobj->set = TRUE;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_NONE:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
/* ignore */
|
|
|
|
break;
|
|
|
|
}
|
2008-01-25 21:02:01 +03:00
|
|
|
case ISEQ_ELEMENT_ADJUST:
|
|
|
|
{
|
2008-01-26 11:27:00 +03:00
|
|
|
ADJUST *adjust = (ADJUST *)list;
|
|
|
|
if (adjust->line_no != -1) {
|
|
|
|
pos += 2 /* insn + 1 operand */;
|
|
|
|
k++;
|
|
|
|
}
|
2008-01-25 21:02:01 +03:00
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:
|
2006-12-31 18:02:22 +03:00
|
|
|
dump_disasm_list(FIRST_ELEMENT(anchor));
|
|
|
|
dump_disasm_list(list);
|
2007-07-20 11:30:33 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), line,
|
|
|
|
"error: set_sequence");
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make instruction sequence */
|
|
|
|
generated_iseq = ALLOC_N(VALUE, pos);
|
2007-07-01 22:16:02 +04:00
|
|
|
insn_info_table = ALLOC_N(struct iseq_insn_info_entry, k);
|
2009-07-13 13:30:23 +04:00
|
|
|
iseq->ic_entries = ALLOC_N(struct iseq_inline_cache_entry, ic_size);
|
|
|
|
MEMZERO(iseq->ic_entries, struct iseq_inline_cache_entry, ic_size);
|
|
|
|
iseq->ic_size = ic_size;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
list = FIRST_ELEMENT(anchor);
|
|
|
|
k = pos = sp = 0;
|
|
|
|
|
|
|
|
while (list) {
|
|
|
|
switch (list->type) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_INSN:
|
|
|
|
{
|
2009-07-13 13:30:23 +04:00
|
|
|
int j, len, insn, iclen = 0;
|
2008-04-03 04:00:48 +04:00
|
|
|
const char *types;
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE *operands;
|
|
|
|
|
|
|
|
iobj = (INSN *)list;
|
|
|
|
|
2008-01-25 21:02:01 +03:00
|
|
|
/* update sp */
|
|
|
|
sp = calc_sp_depth(sp, iobj);
|
|
|
|
if (sp > stack_max) {
|
|
|
|
stack_max = sp;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 19:26:04 +03:00
|
|
|
/* fprintf(stderr, "insn: %-16s, sp: %d\n", insn_name(iobj->insn_id), sp); */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
operands = iobj->operands;
|
|
|
|
insn = iobj->insn_id;
|
|
|
|
generated_iseq[pos] = insn;
|
|
|
|
types = insn_op_types(insn);
|
|
|
|
len = insn_len(insn);
|
2009-07-13 13:30:23 +04:00
|
|
|
iclen = insn_iclen(insn);
|
2009-07-13 08:44:20 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/* operand check */
|
2009-07-13 08:44:20 +04:00
|
|
|
if (iobj->operand_size + iclen != len - 1) {
|
|
|
|
printf("%d, %d, %d\n", iobj->operand_size, iclen, len);
|
2006-12-31 18:02:22 +03:00
|
|
|
dump_disasm_list(list);
|
2007-07-20 11:30:33 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
|
|
|
|
"operand size miss! (%d for %d)",
|
2009-07-13 08:44:20 +04:00
|
|
|
iobj->operand_size + iclen, len - 1);
|
2008-10-16 18:38:08 +04:00
|
|
|
xfree(generated_iseq);
|
|
|
|
xfree(insn_info_table);
|
2006-12-31 18:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; types[j]; j++) {
|
|
|
|
char type = types[j];
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 19:26:04 +03:00
|
|
|
/* printf("--> [%c - (%d-%d)]\n", type, k, j); */
|
2006-12-31 18:02:22 +03:00
|
|
|
switch (type) {
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_OFFSET:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
/* label(destination position) */
|
|
|
|
lobj = (LABEL *)operands[j];
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
if (!lobj->set) {
|
2007-07-20 11:30:33 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
|
|
|
|
"unknown label");
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
if (lobj->sp == -1) {
|
|
|
|
lobj->sp = sp;
|
|
|
|
}
|
|
|
|
generated_iseq[pos + 1 + j] =
|
|
|
|
lobj->position - (pos + len);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_CDHASH:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
/*
|
|
|
|
* [obj, label, ...]
|
|
|
|
*/
|
|
|
|
int i;
|
|
|
|
VALUE lits = operands[j];
|
|
|
|
VALUE map = rb_hash_new();
|
2009-02-27 12:30:53 +03:00
|
|
|
RHASH_TBL(map)->type = &cdhash_type;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
for (i=0; i < RARRAY_LEN(lits); i+=2) {
|
|
|
|
VALUE obj = rb_ary_entry(lits, i);
|
|
|
|
VALUE lv = rb_ary_entry(lits, i+1);
|
|
|
|
lobj = (LABEL *)(lv & ~1);
|
2007-06-05 08:49:54 +04:00
|
|
|
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
if (!lobj->set) {
|
2007-07-20 11:30:33 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
|
|
|
|
"unknown label");
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2008-09-28 17:15:34 +04:00
|
|
|
if (!st_lookup(rb_hash_tbl(map), obj, 0)) {
|
|
|
|
rb_hash_aset(map, obj, INT2FIX(lobj->position - (pos+len)));
|
|
|
|
}
|
|
|
|
else {
|
2008-12-05 06:38:50 +03:00
|
|
|
rb_compile_warning(RSTRING_PTR(iseq->filename), iobj->line_no,
|
|
|
|
"duplicated when clause is ignored");
|
2008-09-28 17:15:34 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2009-02-12 19:29:17 +03:00
|
|
|
hide_obj(map);
|
2006-12-31 18:02:22 +03:00
|
|
|
generated_iseq[pos + 1 + j] = map;
|
|
|
|
iseq_add_mark_object(iseq, map);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_LINDEX:
|
|
|
|
case TS_DINDEX:
|
|
|
|
case TS_NUM: /* ulong */
|
2006-12-31 18:02:22 +03:00
|
|
|
generated_iseq[pos + 1 + j] = FIX2INT(operands[j]);
|
|
|
|
break;
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_ISEQ: /* iseq */
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE v = operands[j];
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_iseq_t *block = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
if (v) {
|
|
|
|
GetISeqPtr(v, block);
|
|
|
|
}
|
|
|
|
generated_iseq[pos + 1 + j] = (VALUE)block;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_VALUE: /* VALUE */
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE v = operands[j];
|
|
|
|
generated_iseq[pos + 1 + j] = v;
|
|
|
|
/* to mark ruby object */
|
2007-07-01 22:16:02 +04:00
|
|
|
iseq_add_mark_object(iseq, v);
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_IC: /* inline cache */
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2009-07-13 13:30:23 +04:00
|
|
|
IC ic = &iseq->ic_entries[ic_index++];
|
|
|
|
if (UNLIKELY(ic_index > ic_size)) {
|
|
|
|
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d",
|
|
|
|
ic_index, ic_size);
|
|
|
|
}
|
|
|
|
generated_iseq[pos + 1 + j] = (VALUE)ic;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_ID: /* ID */
|
2006-12-31 18:02:22 +03:00
|
|
|
generated_iseq[pos + 1 + j] = SYM2ID(operands[j]);
|
|
|
|
break;
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_GENTRY:
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2009-07-16 04:01:06 +04:00
|
|
|
struct rb_global_entry *entry =
|
|
|
|
(struct rb_global_entry *)(operands[j] & (~1));
|
2006-12-31 18:02:22 +03:00
|
|
|
generated_iseq[pos + 1 + j] = (VALUE)entry;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-05 08:49:54 +04:00
|
|
|
default:
|
2007-07-20 11:30:33 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
|
|
|
|
"unknown operand type: %c", type);
|
2008-10-16 18:38:08 +04:00
|
|
|
xfree(generated_iseq);
|
|
|
|
xfree(insn_info_table);
|
2006-12-31 18:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2007-06-30 22:04:35 +04:00
|
|
|
insn_info_table[k].line_no = iobj->line_no;
|
|
|
|
insn_info_table[k].position = pos;
|
2007-12-20 00:39:08 +03:00
|
|
|
insn_info_table[k].sp = sp;
|
2006-12-31 18:02:22 +03:00
|
|
|
pos += len;
|
|
|
|
k++;
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_LABEL:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
lobj = (LABEL *)list;
|
|
|
|
if (lobj->sp == -1) {
|
|
|
|
lobj->sp = sp;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sp = lobj->sp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-01-25 21:02:01 +03:00
|
|
|
case ISEQ_ELEMENT_ADJUST:
|
|
|
|
{
|
|
|
|
ADJUST *adjust = (ADJUST *)list;
|
|
|
|
int orig_sp = sp;
|
|
|
|
|
|
|
|
if (adjust->label) {
|
|
|
|
sp = adjust->label->sp;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sp = 0;
|
|
|
|
}
|
|
|
|
|
2008-01-26 11:27:00 +03:00
|
|
|
if (adjust->line_no != -1) {
|
|
|
|
if (orig_sp - sp > 0) {
|
|
|
|
insn_info_table[k].line_no = adjust->line_no;
|
|
|
|
insn_info_table[k].position = pos;
|
|
|
|
insn_info_table[k].sp = sp;
|
|
|
|
k++;
|
|
|
|
generated_iseq[pos++] = BIN(adjuststack);
|
|
|
|
generated_iseq[pos++] = orig_sp - sp;
|
|
|
|
}
|
|
|
|
else if (orig_sp - sp == 0) {
|
|
|
|
/* jump to next insn */
|
|
|
|
insn_info_table[k].line_no = adjust->line_no;
|
|
|
|
insn_info_table[k].position = pos;
|
|
|
|
insn_info_table[k].sp = sp;
|
|
|
|
k++;
|
|
|
|
generated_iseq[pos++] = BIN(jump);
|
|
|
|
generated_iseq[pos++] = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_bug("iseq_set_sequence: adjust bug");
|
|
|
|
}
|
2008-01-25 21:02:01 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:
|
2006-12-31 18:02:22 +03:00
|
|
|
/* ignore */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
2008-01-26 11:27:00 +03:00
|
|
|
#if 0 /* XXX */
|
2007-08-16 17:12:24 +04:00
|
|
|
/* this check need dead code elimination */
|
2008-01-25 21:02:01 +03:00
|
|
|
if (sp != 1) {
|
2007-08-16 17:12:24 +04:00
|
|
|
rb_bug("SP is not 0 on %s (%d)\n", RSTRING_PTR(iseq->name), sp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-06-30 22:04:35 +04:00
|
|
|
iseq->iseq = (void *)generated_iseq;
|
|
|
|
iseq->iseq_size = pos;
|
|
|
|
iseq->insn_info_table = insn_info_table;
|
|
|
|
iseq->insn_info_size = k;
|
|
|
|
iseq->stack_max = stack_max;
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
label_get_position(LABEL *lobj)
|
|
|
|
{
|
|
|
|
return lobj->position;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
label_get_sp(LABEL *lobj)
|
|
|
|
{
|
|
|
|
return lobj->sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_exception_table(rb_iseq_t *iseq)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE *tptr, *ptr;
|
|
|
|
int tlen, i;
|
2007-07-01 22:16:02 +04:00
|
|
|
struct iseq_catch_table_entry *entry;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2009-06-22 11:05:50 +04:00
|
|
|
tlen = (int)RARRAY_LEN(iseq->compile_data->catch_table_ary);
|
2006-12-31 18:02:22 +03:00
|
|
|
tptr = RARRAY_PTR(iseq->compile_data->catch_table_ary);
|
|
|
|
|
2008-04-20 10:00:51 +04:00
|
|
|
iseq->catch_table = tlen ? ALLOC_N(struct iseq_catch_table_entry, tlen) : 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
iseq->catch_table_size = tlen;
|
|
|
|
|
|
|
|
for (i = 0; i < tlen; i++) {
|
|
|
|
ptr = RARRAY_PTR(tptr[i]);
|
|
|
|
entry = &iseq->catch_table[i];
|
|
|
|
entry->type = ptr[0] & 0xffff;
|
|
|
|
entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
|
|
|
|
entry->end = label_get_position((LABEL *)(ptr[2] & ~1));
|
|
|
|
entry->iseq = ptr[3];
|
|
|
|
|
|
|
|
/* register iseq as mark object */
|
|
|
|
if (entry->iseq != 0) {
|
|
|
|
iseq_add_mark_object(iseq, entry->iseq);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stack depth */
|
|
|
|
if (ptr[4]) {
|
|
|
|
LABEL *lobj = (LABEL *)(ptr[4] & ~1);
|
|
|
|
entry->cont = label_get_position(lobj);
|
|
|
|
entry->sp = label_get_sp(lobj);
|
|
|
|
|
|
|
|
/* TODO: Dirty Hack! Fix me */
|
|
|
|
if (entry->type == CATCH_TYPE_RESCUE ||
|
|
|
|
entry->type == CATCH_TYPE_BREAK ||
|
2008-05-24 10:29:48 +04:00
|
|
|
entry->type == CATCH_TYPE_NEXT) {
|
2006-12-31 18:02:22 +03:00
|
|
|
entry->sp--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
entry->cont = 0;
|
|
|
|
}
|
|
|
|
}
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 19:26:04 +03:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
iseq->compile_data->catch_table_ary = 0; /* free */
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set optional argument table
|
|
|
|
* def foo(a, b=expr1, c=expr2)
|
|
|
|
* =>
|
|
|
|
* b:
|
|
|
|
* expr1
|
|
|
|
* c:
|
|
|
|
* expr2
|
|
|
|
*/
|
|
|
|
static int
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_optargs_table(rb_iseq_t *iseq)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (iseq->arg_opts != 0) {
|
|
|
|
for (i = 0; i < iseq->arg_opts; i++) {
|
2007-07-01 22:16:02 +04:00
|
|
|
iseq->arg_opt_table[i] =
|
|
|
|
label_get_position((LABEL *)iseq->arg_opt_table[i]);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LINK_ELEMENT *
|
|
|
|
get_destination_insn(INSN *iobj)
|
|
|
|
{
|
|
|
|
LABEL *lobj = (LABEL *)OPERAND_AT(iobj, 0);
|
|
|
|
LINK_ELEMENT *list;
|
|
|
|
|
|
|
|
list = lobj->link.next;
|
|
|
|
while (list) {
|
2008-05-22 18:45:54 +04:00
|
|
|
if (list->type == ISEQ_ELEMENT_INSN || list->type == ISEQ_ELEMENT_ADJUST) {
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LINK_ELEMENT *
|
|
|
|
get_next_insn(INSN *iobj)
|
|
|
|
{
|
|
|
|
LINK_ELEMENT *list = iobj->link.next;
|
|
|
|
|
|
|
|
while (list) {
|
2008-05-22 18:45:54 +04:00
|
|
|
if (list->type == ISEQ_ELEMENT_INSN || list->type == ISEQ_ELEMENT_ADJUST) {
|
2006-12-31 18:02:22 +03:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LINK_ELEMENT *
|
|
|
|
get_prev_insn(INSN *iobj)
|
|
|
|
{
|
|
|
|
LINK_ELEMENT *list = iobj->link.prev;
|
|
|
|
|
|
|
|
while (list) {
|
2008-05-22 18:45:54 +04:00
|
|
|
if (list->type == ISEQ_ELEMENT_INSN || list->type == ISEQ_ELEMENT_ADJUST) {
|
2006-12-31 18:02:22 +03:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
list = list->prev;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-05-21 08:46:51 +04:00
|
|
|
iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcallopt)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
INSN *iobj = (INSN *)list;
|
|
|
|
again:
|
|
|
|
if (iobj->insn_id == BIN(jump)) {
|
|
|
|
INSN *niobj, *diobj, *piobj;
|
|
|
|
/*
|
|
|
|
* useless jump elimination:
|
|
|
|
* jump LABEL1
|
|
|
|
* ...
|
|
|
|
* LABEL1:
|
|
|
|
* jump LABEL2
|
|
|
|
*
|
2008-12-24 16:01:09 +03:00
|
|
|
* => in this case, first jump instruction should jump to
|
2006-12-31 18:02:22 +03:00
|
|
|
* LABEL2 directly
|
|
|
|
*/
|
|
|
|
diobj = (INSN *)get_destination_insn(iobj);
|
|
|
|
niobj = (INSN *)get_next_insn(iobj);
|
|
|
|
|
|
|
|
if (diobj == niobj) {
|
2007-05-21 08:46:51 +04:00
|
|
|
/*
|
|
|
|
* jump LABEL
|
|
|
|
* LABEL:
|
|
|
|
* =>
|
|
|
|
* LABEL:
|
|
|
|
*/
|
2006-12-31 18:02:22 +03:00
|
|
|
REMOVE_ELEM(&iobj->link);
|
|
|
|
}
|
|
|
|
else if (iobj != diobj && diobj->insn_id == BIN(jump)) {
|
2007-08-12 23:37:16 +04:00
|
|
|
if (OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) {
|
|
|
|
OPERAND_AT(iobj, 0) = OPERAND_AT(diobj, 0);
|
|
|
|
goto again;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else if (diobj->insn_id == BIN(leave)) {
|
2007-05-21 08:46:51 +04:00
|
|
|
/*
|
|
|
|
* jump LABEL
|
|
|
|
* ...
|
|
|
|
* LABEL:
|
|
|
|
* leave
|
|
|
|
* =>
|
|
|
|
* leave
|
|
|
|
* ...
|
|
|
|
* LABEL:
|
|
|
|
* leave
|
|
|
|
*/
|
2006-12-31 18:02:22 +03:00
|
|
|
INSN *eiobj = new_insn_core(iseq, iobj->line_no, BIN(leave),
|
2008-01-26 11:27:00 +03:00
|
|
|
diobj->operand_size, diobj->operands);
|
|
|
|
INSN *popiobj = new_insn_core(iseq, iobj->line_no,
|
|
|
|
BIN(pop), 0, 0);
|
2006-12-31 18:02:22 +03:00
|
|
|
/* replace */
|
|
|
|
REPLACE_ELEM((LINK_ELEMENT *)iobj, (LINK_ELEMENT *)eiobj);
|
2008-01-26 11:27:00 +03:00
|
|
|
INSERT_ELEM_NEXT((LINK_ELEMENT *)eiobj, (LINK_ELEMENT *)popiobj);
|
|
|
|
iobj = popiobj;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* useless jump elimination (if/unless destination):
|
|
|
|
* if L1
|
|
|
|
* jump L2
|
|
|
|
* L1:
|
|
|
|
* ...
|
|
|
|
* L2:
|
|
|
|
*
|
|
|
|
* ==>
|
|
|
|
* unless L2
|
|
|
|
* L1:
|
|
|
|
* ...
|
|
|
|
* L2:
|
|
|
|
*/
|
|
|
|
else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&
|
|
|
|
(piobj->insn_id == BIN(branchif) ||
|
|
|
|
piobj->insn_id == BIN(branchunless))) {
|
|
|
|
if (niobj == (INSN *)get_destination_insn(piobj)) {
|
|
|
|
piobj->insn_id = (piobj->insn_id == BIN(branchif))
|
2007-04-05 12:58:46 +04:00
|
|
|
? BIN(branchunless) : BIN(branchif);
|
2006-12-31 18:02:22 +03:00
|
|
|
OPERAND_AT(piobj, 0) = OPERAND_AT(iobj, 0);
|
|
|
|
REMOVE_ELEM(&iobj->link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-21 08:46:51 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
if (iobj->insn_id == BIN(branchif) ||
|
|
|
|
iobj->insn_id == BIN(branchunless)) {
|
|
|
|
/*
|
|
|
|
* if L1
|
|
|
|
* ...
|
|
|
|
* L1:
|
|
|
|
* jump L2
|
|
|
|
* =>
|
|
|
|
* if L2
|
|
|
|
*/
|
|
|
|
INSN *nobj = (INSN *)get_destination_insn(iobj);
|
|
|
|
if (nobj->insn_id == BIN(jump)) {
|
|
|
|
OPERAND_AT(iobj, 0) = OPERAND_AT(nobj, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-21 08:46:51 +04:00
|
|
|
if (do_tailcallopt && iobj->insn_id == BIN(leave)) {
|
|
|
|
/*
|
|
|
|
* send ...
|
|
|
|
* leave
|
|
|
|
* =>
|
|
|
|
* send ..., ... | VM_CALL_TAILCALL_BIT, ...
|
|
|
|
* leave # unreachable
|
|
|
|
*/
|
2006-12-31 18:02:22 +03:00
|
|
|
INSN *piobj = (INSN *)get_prev_insn((INSN *)list);
|
2007-05-21 08:46:51 +04:00
|
|
|
|
|
|
|
if (piobj->insn_id == BIN(send) &&
|
|
|
|
piobj->operands[2] == 0 /* block */
|
|
|
|
) {
|
2009-09-05 09:34:56 +04:00
|
|
|
piobj->operands[3] = FIXNUM_OR(piobj->operands[3], VM_CALL_TAILCALL_BIT);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
insn_set_specialized_instruction(INSN *iobj, int insn_id)
|
|
|
|
{
|
|
|
|
iobj->insn_id = insn_id;
|
|
|
|
iobj->operand_size = 0;
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
if (iobj->insn_id == BIN(send)) {
|
|
|
|
ID mid = SYM2ID(OPERAND_AT(iobj, 0));
|
|
|
|
int argc = FIX2INT(OPERAND_AT(iobj, 1));
|
|
|
|
VALUE block = OPERAND_AT(iobj, 2);
|
|
|
|
VALUE flag = OPERAND_AT(iobj, 3);
|
|
|
|
|
|
|
|
/* TODO: should be more sophisticated search */
|
|
|
|
if (block == 0 && flag == INT2FIX(0)) {
|
|
|
|
if (argc == 0) {
|
|
|
|
if (mid == idLength) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_length));
|
|
|
|
}
|
2009-09-06 12:39:57 +04:00
|
|
|
else if (mid == idSize) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_size));
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
else if (mid == idSucc) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_succ));
|
|
|
|
}
|
2007-12-18 15:07:51 +03:00
|
|
|
else if (mid == idNot) {
|
2009-07-13 08:44:20 +04:00
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_not));
|
2007-12-18 15:07:51 +03:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else if (argc == 1) {
|
|
|
|
if (0) {
|
|
|
|
}
|
|
|
|
else if (mid == idPLUS) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_plus));
|
|
|
|
}
|
|
|
|
else if (mid == idMINUS) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_minus));
|
|
|
|
}
|
|
|
|
else if (mid == idMULT) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_mult));
|
|
|
|
}
|
|
|
|
else if (mid == idDIV) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_div));
|
|
|
|
}
|
|
|
|
else if (mid == idMOD) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_mod));
|
|
|
|
}
|
|
|
|
else if (mid == idEq) {
|
2009-07-13 08:44:20 +04:00
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_eq));
|
2007-12-18 15:07:51 +03:00
|
|
|
}
|
|
|
|
else if (mid == idNeq) {
|
2009-07-13 08:44:20 +04:00
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_neq));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else if (mid == idLT) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_lt));
|
|
|
|
}
|
|
|
|
else if (mid == idLE) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_le));
|
|
|
|
}
|
2007-05-21 08:46:51 +04:00
|
|
|
else if (mid == idGT) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_gt));
|
|
|
|
}
|
|
|
|
else if (mid == idGE) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_ge));
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
else if (mid == idLTLT) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_ltlt));
|
|
|
|
}
|
|
|
|
else if (mid == idAREF) {
|
|
|
|
insn_set_specialized_instruction(iobj, BIN(opt_aref));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LINK_ELEMENT *list;
|
2007-05-21 08:46:51 +04:00
|
|
|
const int do_peepholeopt = iseq->compile_data->option->peephole_optimization;
|
|
|
|
const int do_tailcallopt = iseq->compile_data->option->tailcall_optimization;
|
2006-12-31 18:02:22 +03:00
|
|
|
const int do_si = iseq->compile_data->option->specialized_instruction;
|
|
|
|
const int do_ou = iseq->compile_data->option->operands_unification;
|
|
|
|
list = FIRST_ELEMENT(anchor);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
while (list) {
|
|
|
|
if (list->type == ISEQ_ELEMENT_INSN) {
|
2007-05-21 08:46:51 +04:00
|
|
|
if (do_peepholeopt) {
|
|
|
|
iseq_peephole_optimize(iseq, list, do_tailcallopt);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
if (do_si) {
|
|
|
|
iseq_specialized_instruction(iseq, (INSN *)list);
|
|
|
|
}
|
|
|
|
if (do_ou) {
|
|
|
|
insn_operands_unification((INSN *)list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if OPT_INSTRUCTIONS_UNIFICATION
|
|
|
|
static INSN *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
new_unified_insn(rb_iseq_t *iseq,
|
2006-12-31 18:02:22 +03:00
|
|
|
int insn_id, int size, LINK_ELEMENT *seq_list)
|
|
|
|
{
|
|
|
|
INSN *iobj = 0;
|
|
|
|
LINK_ELEMENT *list = seq_list;
|
|
|
|
int i, argc = 0;
|
|
|
|
VALUE *operands = 0, *ptr = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* count argc */
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
iobj = (INSN *)list;
|
|
|
|
argc += iobj->operand_size;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
ptr = operands =
|
|
|
|
(VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * argc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy operands */
|
|
|
|
list = seq_list;
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
iobj = (INSN *)list;
|
|
|
|
MEMCPY(ptr, iobj->operands, VALUE, iobj->operand_size);
|
|
|
|
ptr += iobj->operand_size;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_insn_core(iseq, iobj->line_no, insn_id, argc, operands);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This scheme can get more performance if do this optimize with
|
|
|
|
* label address resolving.
|
|
|
|
* It's future work (if compile time was bottle neck).
|
|
|
|
*/
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
#if OPT_INSTRUCTIONS_UNIFICATION
|
|
|
|
LINK_ELEMENT *list;
|
|
|
|
INSN *iobj, *niobj;
|
|
|
|
int id, j, k;
|
|
|
|
|
|
|
|
list = FIRST_ELEMENT(anchor);
|
|
|
|
while (list) {
|
|
|
|
if (list->type == ISEQ_ELEMENT_INSN) {
|
|
|
|
iobj = (INSN *)list;
|
|
|
|
id = iobj->insn_id;
|
|
|
|
if (unified_insns_data[id] != 0) {
|
2008-04-03 04:00:48 +04:00
|
|
|
const int *const *entry = unified_insns_data[id];
|
2006-12-31 18:02:22 +03:00
|
|
|
for (j = 1; j < (int)entry[0]; j++) {
|
2008-04-03 04:00:48 +04:00
|
|
|
const int *unified = entry[j];
|
2006-12-31 18:02:22 +03:00
|
|
|
LINK_ELEMENT *li = list->next;
|
|
|
|
for (k = 2; k < unified[1]; k++) {
|
|
|
|
if (li->type != ISEQ_ELEMENT_INSN ||
|
|
|
|
((INSN *)li)->insn_id != unified[k]) {
|
|
|
|
goto miss;
|
|
|
|
}
|
|
|
|
li = li->next;
|
|
|
|
}
|
|
|
|
/* matched */
|
|
|
|
niobj =
|
|
|
|
new_unified_insn(iseq, unified[0], unified[1] - 1,
|
|
|
|
list);
|
|
|
|
|
|
|
|
/* insert to list */
|
|
|
|
niobj->link.prev = (LINK_ELEMENT *)iobj->link.prev;
|
|
|
|
niobj->link.next = li;
|
|
|
|
if (li) {
|
|
|
|
li->prev = (LINK_ELEMENT *)niobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
list->prev->next = (LINK_ELEMENT *)niobj;
|
|
|
|
list = (LINK_ELEMENT *)niobj;
|
|
|
|
break;
|
|
|
|
miss:;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if OPT_STACK_CACHING
|
|
|
|
|
|
|
|
#define SC_INSN(insn, stat) sc_insn_info[(insn)][(stat)]
|
|
|
|
#define SC_NEXT(insn) sc_insn_next[insn]
|
|
|
|
|
|
|
|
#include "opt_sc.inc"
|
|
|
|
|
|
|
|
static int
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
insn_set_sc_state(rb_iseq_t *iseq, INSN *iobj, int state)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
int nstate;
|
|
|
|
int insn_id;
|
|
|
|
|
|
|
|
insn_id = iobj->insn_id;
|
|
|
|
iobj->insn_id = SC_INSN(insn_id, state);
|
|
|
|
nstate = SC_NEXT(iobj->insn_id);
|
|
|
|
|
|
|
|
if (insn_id == BIN(jump) ||
|
|
|
|
insn_id == BIN(branchif) || insn_id == BIN(branchunless)) {
|
|
|
|
LABEL *lobj = (LABEL *)OPERAND_AT(iobj, 0);
|
|
|
|
|
|
|
|
if (lobj->sc_state != 0) {
|
|
|
|
if (lobj->sc_state != nstate) {
|
|
|
|
dump_disasm_list((LINK_ELEMENT *)iobj);
|
|
|
|
dump_disasm_list((LINK_ELEMENT *)lobj);
|
|
|
|
printf("\n-- %d, %d\n", lobj->sc_state, nstate);
|
2009-02-12 16:51:19 +03:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
|
2007-07-20 11:30:33 +04:00
|
|
|
"insn_set_sc_state error\n");
|
2006-12-31 18:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lobj->sc_state = nstate;
|
|
|
|
}
|
|
|
|
if (insn_id == BIN(jump)) {
|
|
|
|
nstate = SCS_XX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (insn_id == BIN(leave)) {
|
|
|
|
nstate = SCS_XX;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nstate;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
label_set_sc_state(LABEL *lobj, int state)
|
|
|
|
{
|
|
|
|
if (lobj->sc_state != 0) {
|
|
|
|
if (lobj->sc_state != state) {
|
|
|
|
state = lobj->sc_state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lobj->sc_state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c: remove "yarv" prefix.
* array.c, numeric.c: ditto.
* insnhelper.ci, insns.def, vm_evalbody.ci: ditto.
* yarvcore.c: removed.
* yarvcore.h: renamed to core.h.
* cont.c, debug.c, error.c, process.c, signal.c : ditto.
* ext/probeprofiler/probeprofiler.c: ditto.
* id.c, id.h: added.
* inits.c: ditto.
* compile.c: rename internal functions.
* compile.h: fix debug flag.
* eval.c, object.c, vm.c: remove ruby_top_self.
use rb_vm_top_self() instead.
* eval_intern.h, eval_load: ditto.
* gc.c: rename yarv_machine_stack_mark() to
rb_gc_mark_machine_stack().
* insnhelper.h: remove unused macros.
* iseq.c: add iseq_compile() to create iseq object
from source string.
* proc.c: rename a internal function.
* template/insns.inc.tmpl: remove YARV prefix.
* thread.c:
* vm.c (rb_iseq_eval): added.
* vm.c: move some functions from yarvcore.c.
* vm_dump.c: fix to remove compiler warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-12 08:25:46 +04:00
|
|
|
iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
#if OPT_STACK_CACHING
|
|
|
|
LINK_ELEMENT *list;
|
|
|
|
int state, insn_id;
|
|
|
|
|
|
|
|
/* initialize */
|
|
|
|
state = SCS_XX;
|
|
|
|
list = FIRST_ELEMENT(anchor);
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 19:26:04 +03:00
|
|
|
/* dump_disasm_list(list); */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
/* for each list element */
|
|
|
|
while (list) {
|
|
|
|
redo_point:
|
|
|
|
switch (list->type) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_INSN:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
INSN *iobj = (INSN *)list;
|
|
|
|
insn_id = iobj->insn_id;
|
|
|
|
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 19:26:04 +03:00
|
|
|
/* dump_disasm_list(list); */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
switch (insn_id) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case BIN(nop):
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
/* exception merge point */
|
|
|
|
if (state != SCS_AX) {
|
|
|
|
INSN *rpobj =
|
|
|
|
new_insn_body(iseq, 0, BIN(reput), 0);
|
|
|
|
|
|
|
|
/* replace this insn */
|
|
|
|
REPLACE_ELEM(list, (LINK_ELEMENT *)rpobj);
|
|
|
|
list = (LINK_ELEMENT *)rpobj;
|
|
|
|
goto redo_point;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case BIN(swap):
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
if (state == SCS_AB || state == SCS_BA) {
|
|
|
|
state = (state == SCS_AB ? SCS_BA : SCS_AB);
|
|
|
|
|
|
|
|
REMOVE_ELEM(list);
|
|
|
|
list = list->next;
|
|
|
|
goto redo_point;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case BIN(pop):
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
switch (state) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case SCS_AX:
|
|
|
|
case SCS_BX:
|
2006-12-31 18:02:22 +03:00
|
|
|
state = SCS_XX;
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case SCS_AB:
|
2006-12-31 18:02:22 +03:00
|
|
|
state = SCS_AX;
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case SCS_BA:
|
2006-12-31 18:02:22 +03:00
|
|
|
state = SCS_BX;
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case SCS_XX:
|
2006-12-31 18:02:22 +03:00
|
|
|
goto normal_insn;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:
|
2007-07-20 11:30:33 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), iobj->line_no,
|
|
|
|
"unreachable");
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
/* remove useless pop */
|
|
|
|
REMOVE_ELEM(list);
|
|
|
|
list = list->next;
|
|
|
|
goto redo_point;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:;
|
2006-12-31 18:02:22 +03:00
|
|
|
/* none */
|
|
|
|
} /* end of switch */
|
|
|
|
normal_insn:
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
state = insn_set_sc_state(iseq, iobj, state);
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_LABEL:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *lobj;
|
|
|
|
lobj = (LABEL *)list;
|
|
|
|
|
|
|
|
state = label_set_sc_state(lobj, state);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2008-01-29 11:03:51 +03:00
|
|
|
compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int *cntp)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
NODE *list = node->nd_next;
|
|
|
|
VALUE lit = node->nd_lit;
|
2009-07-20 14:01:05 +04:00
|
|
|
int cnt = 0;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
debugp_param("nd_lit", lit);
|
2009-07-20 14:01:05 +04:00
|
|
|
if (!NIL_P(lit)) {
|
|
|
|
hide_obj(lit);
|
|
|
|
cnt++;
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, lit);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
while (list) {
|
|
|
|
COMPILE(ret, "each string", list->nd_head);
|
|
|
|
cnt++;
|
|
|
|
list = list->nd_next;
|
|
|
|
}
|
2008-01-29 11:03:51 +03:00
|
|
|
*cntp = cnt;
|
|
|
|
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-01-29 11:03:51 +03:00
|
|
|
static int
|
|
|
|
compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node)
|
|
|
|
{
|
|
|
|
int cnt;
|
|
|
|
compile_dstr_fragments(iseq, ret, node, &cnt);
|
2006-12-31 18:02:22 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), concatstrings, INT2FIX(cnt));
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2008-01-29 11:03:51 +03:00
|
|
|
static int
|
|
|
|
compile_dregx(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node)
|
|
|
|
{
|
|
|
|
int cnt;
|
|
|
|
compile_dstr_fragments(iseq, ret, node, &cnt);
|
|
|
|
ADD_INSN2(ret, nd_line(node), toregexp, INT2FIX(node->nd_cflag), INT2FIX(cnt));
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * cond,
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *then_label, LABEL *else_label)
|
|
|
|
{
|
|
|
|
switch (nd_type(cond)) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case NODE_AND:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *label = NEW_LABEL(nd_line(cond));
|
|
|
|
compile_branch_condition(iseq, ret, cond->nd_1st, label,
|
|
|
|
else_label);
|
|
|
|
ADD_LABEL(ret, label);
|
|
|
|
compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
|
|
|
|
else_label);
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case NODE_OR:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *label = NEW_LABEL(nd_line(cond));
|
|
|
|
compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
|
|
|
|
label);
|
|
|
|
ADD_LABEL(ret, label);
|
|
|
|
compile_branch_condition(iseq, ret, cond->nd_2nd, then_label,
|
|
|
|
else_label);
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case NODE_LIT: /* NODE_LIT is always not true */
|
|
|
|
case NODE_TRUE:
|
|
|
|
case NODE_STR:
|
2009-11-03 20:46:28 +03:00
|
|
|
/* printf("useless condition eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
|
2006-12-31 18:02:22 +03:00
|
|
|
ADD_INSNL(ret, nd_line(cond), jump, then_label);
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case NODE_FALSE:
|
|
|
|
case NODE_NIL:
|
2009-11-03 20:46:28 +03:00
|
|
|
/* printf("useless condition eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
|
2006-12-31 18:02:22 +03:00
|
|
|
ADD_INSNL(ret, nd_line(cond), jump, else_label);
|
|
|
|
break;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:
|
2006-12-31 18:02:22 +03:00
|
|
|
COMPILE(ret, "branch condition", cond);
|
|
|
|
ADD_INSNL(ret, nd_line(cond), branchunless, else_label);
|
|
|
|
ADD_INSNL(ret, nd_line(cond), jump, then_label);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-07-03 23:35:09 +04:00
|
|
|
compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
|
|
|
|
VALUE opt_p, int poped)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
NODE *node = node_root;
|
2009-06-22 11:05:50 +04:00
|
|
|
int len = (int)node->nd_alen, line = (int)nd_line(node), i=0;
|
2006-12-31 18:02:22 +03:00
|
|
|
DECL_ANCHOR(anchor);
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(anchor);
|
2007-07-03 23:11:49 +04:00
|
|
|
if (nd_type(node) != NODE_ZARRAY) {
|
|
|
|
while (node) {
|
|
|
|
if (nd_type(node) != NODE_ARRAY) {
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("compile_array: This node is not NODE_ARRAY, but %s",
|
|
|
|
ruby_node_name(nd_type(node)));
|
2007-07-03 23:11:49 +04:00
|
|
|
}
|
2007-04-26 20:54:58 +04:00
|
|
|
|
2007-07-03 23:11:49 +04:00
|
|
|
i++;
|
|
|
|
if (opt_p && nd_type(node->nd_head) != NODE_LIT) {
|
|
|
|
opt_p = Qfalse;
|
|
|
|
}
|
2007-07-03 23:35:09 +04:00
|
|
|
COMPILE_(anchor, "array element", node->nd_head, poped);
|
2007-07-03 23:11:49 +04:00
|
|
|
node = node->nd_next;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len != i) {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
if (0) {
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("node error: compile_array (%d: %d-%d)",
|
|
|
|
(int)nd_line(node_root), len, i);
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
len = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opt_p == Qtrue) {
|
2007-07-03 23:35:09 +04:00
|
|
|
if (!poped) {
|
2009-02-12 13:42:36 +03:00
|
|
|
VALUE ary = rb_ary_tmp_new(len);
|
2007-07-03 23:35:09 +04:00
|
|
|
node = node_root;
|
|
|
|
while (node) {
|
|
|
|
rb_ary_push(ary, node->nd_head->nd_lit);
|
|
|
|
node = node->nd_next;
|
|
|
|
}
|
2009-02-12 19:29:17 +03:00
|
|
|
OBJ_FREEZE(ary);
|
2007-07-03 23:35:09 +04:00
|
|
|
iseq_add_mark_object_compile_time(iseq, ary);
|
|
|
|
ADD_INSN1(ret, nd_line(node_root), duparray, ary);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
2007-07-03 23:35:09 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(anchor, line, newarray, INT2FIX(len));
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
APPEND_LIST(ret, anchor);
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2007-07-03 23:35:09 +04:00
|
|
|
static VALUE
|
|
|
|
compile_array(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root, VALUE opt_p)
|
|
|
|
{
|
|
|
|
return compile_array_(iseq, ret, node_root, opt_p, 0);
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static VALUE
|
|
|
|
case_when_optimizable_literal(NODE * node)
|
|
|
|
{
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
switch (nd_type(node)) {
|
|
|
|
case NODE_LIT: {
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE v = node->nd_lit;
|
2007-02-02 16:19:44 +03:00
|
|
|
if (SYMBOL_P(v) || rb_obj_is_kind_of(v, rb_cNumeric)) {
|
2006-12-31 18:02:22 +03:00
|
|
|
return v;
|
|
|
|
}
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_STR:
|
2006-12-31 18:02:22 +03:00
|
|
|
return node->nd_lit;
|
|
|
|
}
|
|
|
|
return Qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
when_vals(rb_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, VALUE special_literals)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
while (vals) {
|
|
|
|
VALUE lit;
|
|
|
|
NODE* val;
|
|
|
|
|
|
|
|
val = vals->nd_head;
|
|
|
|
|
|
|
|
if (special_literals &&
|
|
|
|
(lit = case_when_optimizable_literal(val)) != Qfalse) {
|
|
|
|
rb_ary_push(special_literals, lit);
|
|
|
|
rb_ary_push(special_literals, (VALUE)(l1) | 1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
special_literals = Qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
COMPILE(cond_seq, "when cond", val);
|
|
|
|
ADD_INSN1(cond_seq, nd_line(val), topn, INT2FIX(1));
|
|
|
|
ADD_SEND(cond_seq, nd_line(val), ID2SYM(idEqq), INT2FIX(1));
|
|
|
|
ADD_INSNL(cond_seq, nd_line(val), branchif, l1);
|
|
|
|
vals = vals->nd_next;
|
|
|
|
}
|
|
|
|
return special_literals;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-08-23 11:10:56 +04:00
|
|
|
compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
switch (nd_type(node)) {
|
2007-06-26 22:56:15 +04:00
|
|
|
case NODE_ATTRASGN: {
|
2007-08-23 10:48:28 +04:00
|
|
|
INSN *iobj;
|
|
|
|
VALUE dupidx;
|
|
|
|
|
|
|
|
COMPILE_POPED(ret, "masgn lhs (NODE_ATTRASGN)", node);
|
|
|
|
POP_ELEMENT(ret); /* pop pop insn */
|
|
|
|
iobj = (INSN *)POP_ELEMENT(ret); /* pop send insn */
|
|
|
|
|
|
|
|
dupidx = iobj->operands[1];
|
2009-09-05 09:34:56 +04:00
|
|
|
dupidx = FIXNUM_INC(dupidx, 1);
|
2007-08-23 10:48:28 +04:00
|
|
|
iobj->operands[1] = dupidx;
|
|
|
|
|
|
|
|
ADD_INSN1(ret, nd_line(node), topn, dupidx);
|
|
|
|
ADD_ELEM(ret, (LINK_ELEMENT *)iobj);
|
|
|
|
ADD_INSN(ret, nd_line(node), pop); /* result */
|
|
|
|
ADD_INSN(ret, nd_line(node), pop); /* rhs */
|
|
|
|
break;
|
2007-06-26 22:56:15 +04:00
|
|
|
}
|
|
|
|
case NODE_MASGN: {
|
2007-08-23 11:10:56 +04:00
|
|
|
DECL_ANCHOR(anchor);
|
|
|
|
INIT_ANCHOR(anchor);
|
|
|
|
COMPILE_POPED(anchor, "nest masgn lhs", node);
|
|
|
|
REMOVE_ELEM(FIRST_ELEMENT(anchor));
|
|
|
|
ADD_SEQ(ret, anchor);
|
2007-08-23 10:48:28 +04:00
|
|
|
break;
|
2007-06-26 22:56:15 +04:00
|
|
|
}
|
|
|
|
default: {
|
2007-08-23 10:48:28 +04:00
|
|
|
DECL_ANCHOR(anchor);
|
|
|
|
INIT_ANCHOR(anchor);
|
|
|
|
COMPILE_POPED(anchor, "masgn lhs", node);
|
|
|
|
REMOVE_ELEM(FIRST_ELEMENT(anchor));
|
|
|
|
ADD_SEQ(ret, anchor);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2007-08-23 15:32:21 +04:00
|
|
|
static void
|
|
|
|
compile_massign_opt_lhs(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *lhsn)
|
|
|
|
{
|
|
|
|
if (lhsn) {
|
|
|
|
compile_massign_opt_lhs(iseq, ret, lhsn->nd_next);
|
|
|
|
compile_massign_lhs(iseq, ret, lhsn->nd_head);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *ret,
|
|
|
|
NODE *rhsn, NODE *orig_lhsn)
|
|
|
|
{
|
2008-03-25 09:09:38 +03:00
|
|
|
VALUE mem[64];
|
2009-05-17 09:27:32 +04:00
|
|
|
const int memsize = numberof(mem);
|
2007-08-23 15:32:21 +04:00
|
|
|
int memindex = 0;
|
|
|
|
int llen = 0, rlen = 0;
|
|
|
|
int i;
|
|
|
|
NODE *lhsn = orig_lhsn;
|
|
|
|
|
|
|
|
#define MEMORY(v) { \
|
|
|
|
int i; \
|
|
|
|
if (memindex == memsize) return 0; \
|
|
|
|
for (i=0; i<memindex; i++) { \
|
|
|
|
if (mem[i] == (v)) return 0; \
|
|
|
|
} \
|
|
|
|
mem[memindex++] = (v); \
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rhsn == 0 || nd_type(rhsn) != NODE_ARRAY) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (lhsn) {
|
|
|
|
NODE *ln = lhsn->nd_head;
|
|
|
|
switch (nd_type(ln)) {
|
|
|
|
case NODE_LASGN:
|
|
|
|
MEMORY(ln->nd_vid);
|
|
|
|
break;
|
|
|
|
case NODE_DASGN:
|
|
|
|
case NODE_DASGN_CURR:
|
|
|
|
case NODE_IASGN:
|
|
|
|
case NODE_IASGN2:
|
|
|
|
case NODE_CVASGN:
|
|
|
|
MEMORY(ln->nd_vid);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
lhsn = lhsn->nd_next;
|
|
|
|
llen++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (rhsn) {
|
|
|
|
if (llen <= rlen) {
|
2009-11-03 20:46:28 +03:00
|
|
|
COMPILE_POPED(ret, "masgn val (popped)", rhsn->nd_head);
|
2007-08-23 15:32:21 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(ret, "masgn val", rhsn->nd_head);
|
|
|
|
}
|
|
|
|
rhsn = rhsn->nd_next;
|
|
|
|
rlen++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (llen > rlen) {
|
|
|
|
for (i=0; i<llen-rlen; i++) {
|
|
|
|
ADD_INSN(ret, nd_line(orig_lhsn), putnil);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
compile_massign_opt_lhs(iseq, ret, orig_lhsn);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
2007-08-23 11:10:56 +04:00
|
|
|
compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *node, int poped)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2007-08-23 11:10:56 +04:00
|
|
|
NODE *rhsn = node->nd_value;
|
|
|
|
NODE *splatn = node->nd_args;
|
|
|
|
NODE *lhsn = node->nd_head;
|
|
|
|
int lhs_splat = (splatn && (VALUE)splatn != (VALUE)-1) ? 1 : 0;
|
|
|
|
|
2007-08-23 15:32:21 +04:00
|
|
|
if (!poped || splatn || !compile_massign_opt(iseq, ret, rhsn, lhsn)) {
|
2007-08-23 11:10:56 +04:00
|
|
|
int llen = 0;
|
2007-08-23 15:32:21 +04:00
|
|
|
DECL_ANCHOR(lhsseq);
|
|
|
|
|
2007-08-23 11:10:56 +04:00
|
|
|
INIT_ANCHOR(lhsseq);
|
2007-04-05 12:58:46 +04:00
|
|
|
|
2007-08-23 11:10:56 +04:00
|
|
|
while (lhsn) {
|
|
|
|
compile_massign_lhs(iseq, lhsseq, lhsn->nd_head);
|
|
|
|
llen += 1;
|
|
|
|
lhsn = lhsn->nd_next;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-08-23 11:10:56 +04:00
|
|
|
COMPILE(ret, "normal masgn rhs", rhsn);
|
2007-07-05 22:16:54 +04:00
|
|
|
|
2007-08-23 11:10:56 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2007-08-23 11:10:56 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), expandarray,
|
|
|
|
INT2FIX(llen), INT2FIX(lhs_splat));
|
|
|
|
ADD_SEQ(ret, lhsseq);
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
if (lhs_splat) {
|
2007-06-26 22:56:15 +04:00
|
|
|
if (nd_type(splatn) == NODE_POSTARG) {
|
2007-08-23 11:10:56 +04:00
|
|
|
/*a, b, *r, p1, p2 */
|
|
|
|
NODE *postn = splatn->nd_2nd;
|
|
|
|
NODE *restn = splatn->nd_1st;
|
2009-06-22 11:05:50 +04:00
|
|
|
int num = (int)postn->nd_alen;
|
2007-08-23 11:10:56 +04:00
|
|
|
int flag = 0x02 | (((VALUE)restn == (VALUE)-1) ? 0x00 : 0x01);
|
2007-06-26 22:56:15 +04:00
|
|
|
|
2007-08-23 11:10:56 +04:00
|
|
|
ADD_INSN2(ret, nd_line(splatn), expandarray,
|
|
|
|
INT2FIX(num), INT2FIX(flag));
|
2007-06-26 22:56:15 +04:00
|
|
|
|
2007-08-23 11:10:56 +04:00
|
|
|
if ((VALUE)restn != (VALUE)-1) {
|
|
|
|
compile_massign_lhs(iseq, ret, restn);
|
2007-07-03 22:50:28 +04:00
|
|
|
}
|
2007-08-23 11:10:56 +04:00
|
|
|
while (postn) {
|
|
|
|
compile_massign_lhs(iseq, ret, postn->nd_head);
|
|
|
|
postn = postn->nd_next;
|
2007-07-03 22:50:28 +04:00
|
|
|
}
|
2007-06-26 22:56:15 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-08-23 11:10:56 +04:00
|
|
|
/* a, b, *r */
|
|
|
|
compile_massign_lhs(iseq, ret, splatn);
|
2007-06-26 22:56:15 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
compile_colon2(rb_iseq_t *iseq, NODE * node,
|
2006-12-31 18:02:22 +03:00
|
|
|
LINK_ANCHOR *pref, LINK_ANCHOR *body)
|
|
|
|
{
|
|
|
|
switch (nd_type(node)) {
|
|
|
|
case NODE_CONST:
|
|
|
|
debugi("compile_colon2 - colon", node->nd_vid);
|
|
|
|
ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_vid));
|
|
|
|
break;
|
|
|
|
case NODE_COLON3:
|
|
|
|
debugi("compile_colon2 - colon3", node->nd_mid);
|
|
|
|
ADD_INSN(body, nd_line(node), pop);
|
|
|
|
ADD_INSN1(body, nd_line(node), putobject, rb_cObject);
|
|
|
|
ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
|
|
|
|
break;
|
|
|
|
case NODE_COLON2:
|
|
|
|
compile_colon2(iseq, node->nd_head, pref, body);
|
|
|
|
debugi("compile_colon2 - colon2", node->nd_mid);
|
|
|
|
ADD_INSN1(body, nd_line(node), getconstant, ID2SYM(node->nd_mid));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
COMPILE(pref, "const colon2 prefix", node);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2008-05-14 06:31:28 +04:00
|
|
|
static VALUE
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2008-05-05 06:27:29 +04:00
|
|
|
if (nd_type(cpath) == NODE_COLON3) {
|
|
|
|
/* toplevel class ::Foo */
|
|
|
|
ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject);
|
2008-05-14 06:31:28 +04:00
|
|
|
return Qfalse;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2008-05-05 06:27:29 +04:00
|
|
|
else if (cpath->nd_head) {
|
|
|
|
/* Bar::Foo */
|
|
|
|
COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
|
2008-05-14 06:31:28 +04:00
|
|
|
return Qfalse;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
2008-05-05 06:27:29 +04:00
|
|
|
/* class at cbase Foo */
|
2009-12-03 21:25:57 +03:00
|
|
|
ADD_INSN1(ret, nd_line(cpath), putspecialobject,
|
|
|
|
INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
|
2008-05-14 06:31:28 +04:00
|
|
|
return Qtrue;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
|
2008-03-25 09:26:32 +03:00
|
|
|
NODE *node, LABEL **lfinish, VALUE needstr)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2008-05-31 13:28:20 +04:00
|
|
|
const char *estr = 0;
|
2007-04-08 08:27:41 +04:00
|
|
|
enum node_type type;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-04-08 08:27:41 +04:00
|
|
|
switch (type = nd_type(node)) {
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
/* easy literals */
|
|
|
|
case NODE_NIL:
|
|
|
|
estr = "nil";
|
|
|
|
break;
|
|
|
|
case NODE_SELF:
|
|
|
|
estr = "self";
|
|
|
|
break;
|
|
|
|
case NODE_TRUE:
|
|
|
|
estr = "true";
|
|
|
|
break;
|
|
|
|
case NODE_FALSE:
|
|
|
|
estr = "false";
|
|
|
|
break;
|
2007-04-05 12:58:46 +04:00
|
|
|
|
|
|
|
case NODE_ARRAY:{
|
|
|
|
NODE *vals = node;
|
|
|
|
|
|
|
|
do {
|
|
|
|
defined_expr(iseq, ret, vals->nd_head, lfinish, Qfalse);
|
* vm.c: some refactoring.
* rename th_* to vm_*.
* remove unused variables functions.
* add prototypes.
* blockinlining.c, compile.c, cont.c, eval.c, eval_intern.h,
eval_jump.h, eval_load.c, inits.c, insns.def, iseq.c, parse.y,
proc.c, process.c, signal.c, thread.c, vm.c, vm_dump.c,
vm_evalbody.ci, yarvcore.c, yarvcore.h: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-24 19:42:41 +04:00
|
|
|
|
2008-05-30 17:15:03 +04:00
|
|
|
if (!lfinish[1]) {
|
2008-03-25 09:26:32 +03:00
|
|
|
lfinish[1] = NEW_LABEL(nd_line(node));
|
2007-04-05 12:58:46 +04:00
|
|
|
}
|
2008-05-30 17:15:03 +04:00
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
} while ((vals = vals->nd_next) != NULL);
|
2007-04-05 12:58:46 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
case NODE_STR:
|
|
|
|
case NODE_LIT:
|
2007-04-05 12:58:46 +04:00
|
|
|
case NODE_ZARRAY:
|
2008-08-25 14:06:12 +04:00
|
|
|
case NODE_AND:
|
|
|
|
case NODE_OR:
|
2008-08-25 18:04:09 +04:00
|
|
|
default:
|
2006-12-31 18:02:22 +03:00
|
|
|
estr = "expression";
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* variables */
|
|
|
|
case NODE_LVAR:
|
|
|
|
case NODE_DVAR:
|
2007-02-14 03:08:45 +03:00
|
|
|
estr = "local-variable";
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NODE_IVAR:
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_IVAR),
|
|
|
|
ID2SYM(node->nd_vid), needstr);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case NODE_GVAR:
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_GVAR),
|
|
|
|
((VALUE)node->nd_entry) | 1, needstr);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case NODE_CVAR:
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CVAR),
|
|
|
|
ID2SYM(node->nd_vid), needstr);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case NODE_CONST:
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CONST),
|
|
|
|
ID2SYM(node->nd_vid), needstr);
|
|
|
|
return 1;
|
|
|
|
case NODE_COLON2:
|
2008-03-25 09:26:32 +03:00
|
|
|
if (!lfinish[1]) {
|
|
|
|
lfinish[1] = NEW_LABEL(nd_line(node));
|
|
|
|
}
|
|
|
|
defined_expr(iseq, ret, node->nd_head, lfinish, Qfalse);
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-03-25 09:26:32 +03:00
|
|
|
if (rb_is_const_id(node->nd_mid)) {
|
2006-12-31 18:02:22 +03:00
|
|
|
COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_CONST),
|
|
|
|
ID2SYM(node->nd_mid), needstr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(ret, "defined/colon2#nd_head", node->nd_head);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_METHOD),
|
|
|
|
ID2SYM(node->nd_mid), needstr);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
case NODE_COLON3:
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, rb_cObject);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined,
|
|
|
|
INT2FIX(DEFINED_CONST), ID2SYM(node->nd_mid), needstr);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* method dispatch */
|
|
|
|
case NODE_CALL:
|
|
|
|
case NODE_VCALL:
|
|
|
|
case NODE_FCALL:
|
2007-04-05 12:58:46 +04:00
|
|
|
case NODE_ATTRASGN:{
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
int self = TRUE;
|
2007-04-05 12:58:46 +04:00
|
|
|
|
2007-04-08 08:27:41 +04:00
|
|
|
switch (type) {
|
2007-04-05 12:58:46 +04:00
|
|
|
case NODE_ATTRASGN:
|
|
|
|
if (node->nd_recv == (NODE *)1) break;
|
|
|
|
case NODE_CALL:
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
self = FALSE;
|
2007-04-05 12:58:46 +04:00
|
|
|
break;
|
2007-06-28 14:41:39 +04:00
|
|
|
default:
|
|
|
|
/* through */;
|
2007-04-05 12:58:46 +04:00
|
|
|
}
|
2008-03-25 09:26:32 +03:00
|
|
|
if (!lfinish[1]) {
|
|
|
|
lfinish[1] = NEW_LABEL(nd_line(node));
|
|
|
|
}
|
2007-04-08 08:27:41 +04:00
|
|
|
if (node->nd_args) {
|
|
|
|
defined_expr(iseq, ret, node->nd_args, lfinish, Qfalse);
|
2008-03-25 09:26:32 +03:00
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
|
2007-04-08 08:27:41 +04:00
|
|
|
}
|
2007-04-05 12:58:46 +04:00
|
|
|
if (!self) {
|
2008-04-21 06:02:26 +04:00
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
|
|
|
VALUE rescue = NEW_CHILD_ISEQVAL(NEW_NIL(),
|
|
|
|
rb_str_concat(rb_str_new2
|
|
|
|
("defined guard in "),
|
|
|
|
iseq->name),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_DEFINED_GUARD, 0);
|
2008-04-21 06:02:26 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
defined_expr(iseq, ret, node->nd_recv, lfinish, Qfalse);
|
2008-03-25 09:26:32 +03:00
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lfinish[1]);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-04-21 06:02:26 +04:00
|
|
|
ADD_LABEL(ret, lstart);
|
2006-12-31 18:02:22 +03:00
|
|
|
COMPILE(ret, "defined/recv", node->nd_recv);
|
2008-04-21 06:02:26 +04:00
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lfinish[1]);
|
2006-12-31 18:02:22 +03:00
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_METHOD),
|
|
|
|
ID2SYM(node->nd_mid), needstr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(ret, nd_line(node), putself);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_FUNC),
|
|
|
|
ID2SYM(node->nd_mid), needstr);
|
|
|
|
}
|
|
|
|
return 1;
|
2007-04-05 12:58:46 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
case NODE_YIELD:
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_YIELD), 0,
|
|
|
|
needstr);
|
|
|
|
return 1;
|
|
|
|
|
2007-11-27 07:43:54 +03:00
|
|
|
case NODE_BACK_REF:
|
2006-12-31 18:02:22 +03:00
|
|
|
case NODE_NTH_REF:
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_REF),
|
2008-03-25 09:09:38 +03:00
|
|
|
INT2FIX((node->nd_nth << 1) | (type == NODE_BACK_REF)),
|
2007-11-27 07:43:54 +03:00
|
|
|
needstr);
|
2006-12-31 18:02:22 +03:00
|
|
|
return 1;
|
|
|
|
|
2008-05-05 15:01:10 +04:00
|
|
|
case NODE_SUPER:
|
2006-12-31 18:02:22 +03:00
|
|
|
case NODE_ZSUPER:
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_ZSUPER), 0,
|
|
|
|
needstr);
|
|
|
|
return 1;
|
|
|
|
|
2007-04-05 12:58:46 +04:00
|
|
|
case NODE_OP_ASGN1:
|
|
|
|
case NODE_OP_ASGN2:
|
2008-05-12 09:05:50 +04:00
|
|
|
case NODE_OP_ASGN_OR:
|
|
|
|
case NODE_OP_ASGN_AND:
|
2007-04-05 12:58:46 +04:00
|
|
|
case NODE_MASGN:
|
|
|
|
case NODE_LASGN:
|
|
|
|
case NODE_DASGN:
|
|
|
|
case NODE_DASGN_CURR:
|
|
|
|
case NODE_GASGN:
|
|
|
|
case NODE_IASGN:
|
|
|
|
case NODE_CDECL:
|
|
|
|
case NODE_CVDECL:
|
|
|
|
case NODE_CVASGN:
|
|
|
|
estr = "assignment";
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (estr != 0) {
|
|
|
|
if (needstr != Qfalse) {
|
|
|
|
VALUE str = rb_str_new2(estr);
|
2009-02-12 13:42:36 +03:00
|
|
|
hide_obj(str);
|
2006-12-31 18:02:22 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), putstring, str);
|
|
|
|
iseq_add_mark_object_compile_time(iseq, str);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BUFSIZE 0x100
|
|
|
|
|
|
|
|
static VALUE
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
make_name_for_block(rb_iseq_t *iseq)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2008-12-27 04:15:56 +03:00
|
|
|
int level = 1;
|
|
|
|
rb_iseq_t *ip = iseq;
|
|
|
|
|
|
|
|
if (iseq->parent_iseq != 0) {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
while (ip->local_iseq != ip) {
|
2008-12-27 04:15:56 +03:00
|
|
|
if (ip->type == ISEQ_TYPE_BLOCK) {
|
|
|
|
level++;
|
|
|
|
}
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
ip = ip->parent_iseq;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2008-12-27 04:15:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (level == 1) {
|
|
|
|
return rb_sprintf("block in %s", RSTRING_PTR(ip->name));
|
|
|
|
}
|
|
|
|
else {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->name));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-16 23:54:58 +03:00
|
|
|
static void
|
|
|
|
push_ensure_entry(rb_iseq_t *iseq,
|
|
|
|
struct iseq_compile_data_ensure_node_stack *enl,
|
|
|
|
struct ensure_range *er, NODE *node)
|
|
|
|
{
|
|
|
|
enl->ensure_node = node;
|
|
|
|
enl->prev = iseq->compile_data->ensure_node_stack; /* prev */
|
|
|
|
enl->erange = er;
|
|
|
|
iseq->compile_data->ensure_node_stack = enl;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static void
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
add_ensure_range(rb_iseq_t *iseq, struct ensure_range *erange,
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *lstart, LABEL *lend)
|
|
|
|
{
|
|
|
|
struct ensure_range *ne =
|
|
|
|
compile_data_alloc(iseq, sizeof(struct ensure_range));
|
|
|
|
|
|
|
|
while (erange->next != 0) {
|
|
|
|
erange = erange->next;
|
|
|
|
}
|
|
|
|
ne->next = 0;
|
|
|
|
ne->begin = lend;
|
|
|
|
ne->end = erange->end;
|
|
|
|
erange->end = lstart;
|
|
|
|
|
|
|
|
erange->next = ne;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(LINK_ANCHOR *ret, rb_iseq_t *iseq, int is_return)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
struct iseq_compile_data_ensure_node_stack *enlp =
|
|
|
|
iseq->compile_data->ensure_node_stack;
|
|
|
|
struct iseq_compile_data_ensure_node_stack *prev_enlp = enlp;
|
|
|
|
DECL_ANCHOR(ensure);
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(ensure);
|
2006-12-31 18:02:22 +03:00
|
|
|
while (enlp) {
|
2009-02-16 23:54:58 +03:00
|
|
|
if (enlp->erange != 0) {
|
|
|
|
DECL_ANCHOR(ensure_part);
|
|
|
|
LABEL *lstart = NEW_LABEL(0);
|
|
|
|
LABEL *lend = NEW_LABEL(0);
|
|
|
|
INIT_ANCHOR(ensure_part);
|
2007-07-20 11:11:35 +04:00
|
|
|
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_range(iseq, enlp->erange, lstart, lend);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2009-02-16 23:54:58 +03:00
|
|
|
iseq->compile_data->ensure_node_stack = enlp->prev;
|
|
|
|
ADD_LABEL(ensure_part, lstart);
|
|
|
|
COMPILE_POPED(ensure_part, "ensure part", enlp->ensure_node);
|
|
|
|
ADD_LABEL(ensure_part, lend);
|
|
|
|
ADD_SEQ(ensure, ensure_part);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!is_return) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
enlp = enlp->prev;
|
|
|
|
}
|
|
|
|
iseq->compile_data->ensure_node_stack = prev_enlp;
|
|
|
|
ADD_SEQ(ret, ensure);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
2007-06-27 21:13:13 +04:00
|
|
|
setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, unsigned long *flag)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE argc = INT2FIX(0);
|
2007-04-26 20:54:58 +04:00
|
|
|
int nsplat = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
DECL_ANCHOR(arg_block);
|
2007-04-26 20:54:58 +04:00
|
|
|
DECL_ANCHOR(args_splat);
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(arg_block);
|
|
|
|
INIT_ANCHOR(args_splat);
|
2006-12-31 18:02:22 +03:00
|
|
|
if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
|
|
|
|
COMPILE(arg_block, "block", argn->nd_body);
|
|
|
|
*flag |= VM_CALL_ARGS_BLOCKARG_BIT;
|
|
|
|
argn = argn->nd_head;
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_argn:
|
|
|
|
if (argn) {
|
|
|
|
switch (nd_type(argn)) {
|
|
|
|
case NODE_SPLAT: {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(args, "args (splat)", argn->nd_head);
|
|
|
|
argc = INT2FIX(1);
|
2007-06-25 21:52:33 +04:00
|
|
|
nsplat++;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
*flag |= VM_CALL_ARGS_SPLAT_BIT;
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-04-26 20:54:58 +04:00
|
|
|
case NODE_ARGSCAT:
|
|
|
|
case NODE_ARGSPUSH: {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
int next_is_array = (nd_type(argn->nd_head) == NODE_ARRAY);
|
|
|
|
DECL_ANCHOR(tmp);
|
2007-04-26 20:54:58 +04:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(tmp);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(tmp, "args (cat: splat)", argn->nd_body);
|
|
|
|
if (next_is_array && nsplat == 0) {
|
|
|
|
/* none */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (nd_type(argn) == NODE_ARGSCAT) {
|
|
|
|
ADD_INSN1(tmp, nd_line(argn), splatarray, Qfalse);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN1(tmp, nd_line(argn), newarray, INT2FIX(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
INSERT_LIST(args_splat, tmp);
|
|
|
|
nsplat++;
|
|
|
|
*flag |= VM_CALL_ARGS_SPLAT_BIT;
|
2007-04-26 20:54:58 +04:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (next_is_array) {
|
|
|
|
argc = INT2FIX(compile_array(iseq, args, argn->nd_head, Qfalse) + 1);
|
|
|
|
POP_ELEMENT(args);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
argn = argn->nd_head;
|
|
|
|
goto setup_argn;
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-04-26 20:54:58 +04:00
|
|
|
case NODE_ARRAY: {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
argc = INT2FIX(compile_array(iseq, args, argn, Qfalse));
|
|
|
|
POP_ELEMENT(args);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-04-26 20:54:58 +04:00
|
|
|
default: {
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("setup_arg: unknown node: %s\n", ruby_node_name(nd_type(argn)));
|
2007-04-26 20:54:58 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-26 20:54:58 +04:00
|
|
|
if (nsplat > 1) {
|
|
|
|
int i;
|
|
|
|
for (i=1; i<nsplat; i++) {
|
|
|
|
ADD_INSN(args_splat, nd_line(args), concatarray);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!LIST_SIZE_ZERO(args_splat)) {
|
|
|
|
ADD_SEQ(args, args_splat);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*flag & VM_CALL_ARGS_BLOCKARG_BIT) {
|
|
|
|
ADD_SEQ(args, arg_block);
|
|
|
|
}
|
|
|
|
return argc;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
compile each node
|
|
|
|
|
|
|
|
self: InstructionSequence
|
|
|
|
node: Ruby compiled node
|
|
|
|
poped: This node will be poped
|
|
|
|
*/
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
enum node_type type;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
if (node == 0) {
|
|
|
|
if (!poped) {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
debugs("node: NODE_NIL(implicit)\n");
|
|
|
|
ADD_INSN(ret, iseq->compile_data->last_line, putnil);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-22 11:05:50 +04:00
|
|
|
iseq->compile_data->last_line = (int)nd_line(node);
|
2007-06-26 22:56:15 +04:00
|
|
|
debug_node_start(node);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
type = nd_type(node);
|
|
|
|
|
2008-02-18 08:33:01 +03:00
|
|
|
if (node->flags & NODE_FL_NEWLINE) {
|
2007-04-19 14:37:08 +04:00
|
|
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_LINE);
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
switch (type) {
|
|
|
|
case NODE_BLOCK:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
while (node && nd_type(node) == NODE_BLOCK) {
|
|
|
|
COMPILE_(ret, "BLOCK body", node->nd_head,
|
|
|
|
(node->nd_next == 0 && poped == 0) ? 0 : 1);
|
|
|
|
node = node->nd_next;
|
|
|
|
}
|
|
|
|
if (node) {
|
|
|
|
COMPILE_(ret, "BLOCK next", node->nd_next, poped);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_IF:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
DECL_ANCHOR(cond_seq);
|
|
|
|
DECL_ANCHOR(then_seq);
|
|
|
|
DECL_ANCHOR(else_seq);
|
|
|
|
LABEL *then_label, *else_label, *end_label;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(cond_seq);
|
|
|
|
INIT_ANCHOR(then_seq);
|
|
|
|
INIT_ANCHOR(else_seq);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
then_label = NEW_LABEL(nd_line(node));
|
|
|
|
else_label = NEW_LABEL(nd_line(node));
|
|
|
|
end_label = NEW_LABEL(nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
compile_branch_condition(iseq, cond_seq, node->nd_cond,
|
|
|
|
then_label, else_label);
|
|
|
|
COMPILE_(then_seq, "then", node->nd_body, poped);
|
|
|
|
COMPILE_(else_seq, "else", node->nd_else, poped);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEQ(ret, cond_seq);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, then_label);
|
|
|
|
ADD_SEQ(ret, then_seq);
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, end_label);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, else_label);
|
|
|
|
ADD_SEQ(ret, else_seq);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, end_label);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_CASE:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
NODE *vals;
|
|
|
|
NODE *tempnode = node;
|
|
|
|
LABEL *endlabel, *elselabel;
|
|
|
|
DECL_ANCHOR(head);
|
|
|
|
DECL_ANCHOR(body_seq);
|
|
|
|
DECL_ANCHOR(cond_seq);
|
2009-06-22 11:14:32 +04:00
|
|
|
VALUE special_literals = rb_ary_tmp_new(1);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(head);
|
|
|
|
INIT_ANCHOR(body_seq);
|
|
|
|
INIT_ANCHOR(cond_seq);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (node->nd_head == 0) {
|
|
|
|
COMPILE_(ret, "when", node->nd_body, poped);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
COMPILE(head, "case base", node->nd_head);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
node = node->nd_body;
|
|
|
|
type = nd_type(node);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (type != NODE_WHEN) {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "NODE_CASE: unexpected node. must be NODE_WHEN, but %s", ruby_node_name(type)));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
endlabel = NEW_LABEL(nd_line(node));
|
|
|
|
elselabel = NEW_LABEL(nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEQ(ret, head); /* case VAL */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
while (type == NODE_WHEN) {
|
|
|
|
LABEL *l1;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
l1 = NEW_LABEL(nd_line(node));
|
|
|
|
ADD_LABEL(body_seq, l1);
|
|
|
|
ADD_INSN(body_seq, nd_line(node), pop);
|
|
|
|
COMPILE_(body_seq, "when body", node->nd_body, poped);
|
|
|
|
ADD_INSNL(body_seq, nd_line(node), jump, endlabel);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
vals = node->nd_head;
|
|
|
|
if (vals) {
|
2008-04-20 09:44:47 +04:00
|
|
|
switch (nd_type(vals)) {
|
|
|
|
case NODE_ARRAY:
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
special_literals = when_vals(iseq, cond_seq, vals, l1, special_literals);
|
2008-04-20 09:44:47 +04:00
|
|
|
break;
|
|
|
|
case NODE_SPLAT:
|
|
|
|
case NODE_ARGSCAT:
|
|
|
|
case NODE_ARGSPUSH:
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
special_literals = 0;
|
2008-04-20 09:44:47 +04:00
|
|
|
COMPILE(cond_seq, "when/cond splat", vals);
|
|
|
|
ADD_INSN1(cond_seq, nd_line(vals), checkincludearray, Qtrue);
|
|
|
|
ADD_INSNL(cond_seq, nd_line(vals), branchif, l1);
|
|
|
|
break;
|
|
|
|
default:
|
2007-11-27 09:54:58 +03:00
|
|
|
rb_bug("NODE_CASE: unknown node (%s)",
|
2007-07-07 12:14:00 +04:00
|
|
|
ruby_node_name(nd_type(vals)));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2007-11-27 09:54:58 +03:00
|
|
|
rb_bug("NODE_CASE: must be NODE_ARRAY, but 0");
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
node = node->nd_next;
|
|
|
|
if (!node) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
type = nd_type(node);
|
|
|
|
}
|
|
|
|
/* else */
|
|
|
|
if (node) {
|
|
|
|
ADD_LABEL(cond_seq, elselabel);
|
|
|
|
ADD_INSN(cond_seq, nd_line(node), pop);
|
|
|
|
COMPILE_(cond_seq, "else", node, poped);
|
|
|
|
ADD_INSNL(cond_seq, nd_line(node), jump, endlabel);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
debugs("== else (implicit)\n");
|
|
|
|
ADD_LABEL(cond_seq, elselabel);
|
|
|
|
ADD_INSN(cond_seq, nd_line(tempnode), pop);
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(cond_seq, nd_line(tempnode), putnil);
|
|
|
|
}
|
|
|
|
ADD_INSNL(cond_seq, nd_line(tempnode), jump, endlabel);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (special_literals) {
|
|
|
|
ADD_INSN(ret, nd_line(tempnode), dup);
|
|
|
|
ADD_INSN2(ret, nd_line(tempnode), opt_case_dispatch,
|
|
|
|
special_literals, elselabel);
|
|
|
|
iseq_add_mark_object_compile_time(iseq, special_literals);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEQ(ret, cond_seq);
|
|
|
|
ADD_SEQ(ret, body_seq);
|
|
|
|
ADD_LABEL(ret, endlabel);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_WHEN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
NODE *vals;
|
|
|
|
NODE *val;
|
|
|
|
NODE *orig_node = node;
|
|
|
|
LABEL *endlabel;
|
|
|
|
DECL_ANCHOR(body_seq);
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(body_seq);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
endlabel = NEW_LABEL(nd_line(node));
|
|
|
|
|
|
|
|
while (node && nd_type(node) == NODE_WHEN) {
|
|
|
|
LABEL *l1 = NEW_LABEL(nd_line(node));
|
|
|
|
ADD_LABEL(body_seq, l1);
|
|
|
|
COMPILE_(body_seq, "when", node->nd_body, poped);
|
|
|
|
ADD_INSNL(body_seq, nd_line(node), jump, endlabel);
|
|
|
|
|
|
|
|
vals = node->nd_head;
|
|
|
|
if (vals && nd_type(vals) == NODE_ARRAY) {
|
|
|
|
while (vals) {
|
|
|
|
val = vals->nd_head;
|
|
|
|
COMPILE(ret, "when2", val);
|
|
|
|
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
|
|
|
vals = vals->nd_next;
|
|
|
|
}
|
|
|
|
}
|
2007-11-27 09:54:58 +03:00
|
|
|
else if (nd_type(vals) == NODE_SPLAT ||
|
|
|
|
nd_type(vals) == NODE_ARGSCAT ||
|
|
|
|
nd_type(vals) == NODE_ARGSPUSH) {
|
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
NODE *val = vals->nd_head;
|
2007-06-05 08:49:54 +04:00
|
|
|
|
2007-11-27 09:54:58 +03:00
|
|
|
if (nd_type(vals) == NODE_ARGSCAT || nd_type(vals) == NODE_ARGSPUSH) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
NODE *vs = vals->nd_head;
|
|
|
|
val = vals->nd_body;
|
|
|
|
|
|
|
|
while (vs) {
|
|
|
|
NODE* val = vs->nd_head;
|
|
|
|
COMPILE(ret, "when/argscat", val);
|
|
|
|
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
|
|
|
vs = vs->nd_next;
|
|
|
|
}
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(val), putnil);
|
|
|
|
COMPILE(ret, "when2/splat", val);
|
|
|
|
ADD_INSN1(ret, nd_line(val), checkincludearray, Qfalse);
|
|
|
|
ADD_INSN(ret, nd_line(val), pop);
|
|
|
|
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
|
|
|
}
|
|
|
|
else {
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("err");
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
node = node->nd_next;
|
|
|
|
}
|
|
|
|
/* else */
|
|
|
|
COMPILE_(ret, "else", node, poped);
|
|
|
|
ADD_INSNL(ret, nd_line(orig_node), jump, endlabel);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEQ(ret, body_seq);
|
|
|
|
ADD_LABEL(ret, endlabel);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_OPT_N:
|
|
|
|
case NODE_WHILE:
|
|
|
|
case NODE_UNTIL:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *prev_start_label = iseq->compile_data->start_label;
|
|
|
|
LABEL *prev_end_label = iseq->compile_data->end_label;
|
|
|
|
LABEL *prev_redo_label = iseq->compile_data->redo_label;
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
int prev_loopval_popped = iseq->compile_data->loopval_popped;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2009-02-16 23:54:58 +03:00
|
|
|
struct iseq_compile_data_ensure_node_stack enl;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *next_label = iseq->compile_data->start_label = NEW_LABEL(nd_line(node)); /* next */
|
|
|
|
LABEL *redo_label = iseq->compile_data->redo_label = NEW_LABEL(nd_line(node)); /* redo */
|
|
|
|
LABEL *break_label = iseq->compile_data->end_label = NEW_LABEL(nd_line(node)); /* break */
|
|
|
|
LABEL *end_label = NEW_LABEL(nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-05-24 10:29:48 +04:00
|
|
|
LABEL *next_catch_label = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *tmp_label = NULL;
|
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
iseq->compile_data->loopval_popped = 0;
|
2009-02-16 23:54:58 +03:00
|
|
|
push_ensure_entry(iseq, &enl, 0, 0);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (type == NODE_OPT_N || node->nd_state == 1) {
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, next_label);
|
|
|
|
}
|
2008-05-24 10:29:48 +04:00
|
|
|
else {
|
|
|
|
tmp_label = NEW_LABEL(nd_line(node));
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, tmp_label);
|
|
|
|
}
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_LABEL(ret, next_catch_label);
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, next_label);
|
|
|
|
if (tmp_label) ADD_LABEL(ret, tmp_label);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, redo_label);
|
|
|
|
COMPILE_POPED(ret, "while body", node->nd_body);
|
|
|
|
ADD_LABEL(ret, next_label); /* next */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (type == NODE_WHILE) {
|
|
|
|
compile_branch_condition(iseq, ret, node->nd_cond,
|
|
|
|
redo_label, end_label);
|
|
|
|
}
|
|
|
|
else if (type == NODE_UNTIL) {
|
|
|
|
/* untile */
|
|
|
|
compile_branch_condition(iseq, ret, node->nd_cond,
|
|
|
|
end_label, redo_label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_CALL_RECEIVER(ret, nd_line(node));
|
|
|
|
ADD_CALL(ret, nd_line(node), ID2SYM(idGets), INT2FIX(0));
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, redo_label);
|
|
|
|
/* opt_n */
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, end_label);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (node->nd_state == Qundef) {
|
2007-06-26 10:14:44 +04:00
|
|
|
/* ADD_INSN(ret, nd_line(node), putundef); */
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("unsupported: putundef");
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-05-24 10:29:48 +04:00
|
|
|
ADD_LABEL(ret, break_label); /* break */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
|
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, redo_label, break_label,
|
|
|
|
0, break_label);
|
2008-05-24 10:29:48 +04:00
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_NEXT, redo_label, break_label, 0,
|
|
|
|
next_catch_label);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_REDO, redo_label, break_label, 0,
|
|
|
|
iseq->compile_data->redo_label);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
iseq->compile_data->start_label = prev_start_label;
|
|
|
|
iseq->compile_data->end_label = prev_end_label;
|
|
|
|
iseq->compile_data->redo_label = prev_redo_label;
|
|
|
|
iseq->compile_data->loopval_popped = prev_loopval_popped;
|
2009-02-16 23:54:58 +03:00
|
|
|
iseq->compile_data->ensure_node_stack = iseq->compile_data->ensure_node_stack->prev;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ITER:
|
|
|
|
case NODE_FOR:{
|
2007-08-23 10:48:28 +04:00
|
|
|
VALUE prevblock = iseq->compile_data->current_block;
|
|
|
|
LABEL *retry_label = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *retry_end_l = NEW_LABEL(nd_line(node));
|
|
|
|
ID mid = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
ADD_LABEL(ret, retry_label);
|
|
|
|
if (nd_type(node) == NODE_FOR) {
|
|
|
|
COMPILE(ret, "iter caller (for)", node->nd_iter);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
iseq->compile_data->current_block =
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_BLOCK, nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
mid = idEach;
|
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0),
|
|
|
|
iseq->compile_data->current_block, INT2FIX(0));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iseq->compile_data->current_block =
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 14:15:15 +03:00
|
|
|
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_BLOCK, nd_line(node));
|
2007-08-23 10:48:28 +04:00
|
|
|
COMPILE(ret, "iter caller", node->nd_iter);
|
|
|
|
}
|
|
|
|
ADD_LABEL(ret, retry_end_l);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
2007-07-05 14:04:56 +04:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
iseq->compile_data->current_block = prevblock;
|
2007-07-05 14:04:56 +04:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, 0, retry_end_l);
|
2007-07-05 14:04:56 +04:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_BREAK:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
unsigned long level = 0;
|
|
|
|
|
|
|
|
if (iseq->compile_data->redo_label != 0) {
|
|
|
|
/* while/until */
|
2008-01-26 11:27:00 +03:00
|
|
|
LABEL *splabel = NEW_LABEL(0);
|
|
|
|
ADD_LABEL(ret, splabel);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_ADJUST(ret, nd_line(node), iseq->compile_data->redo_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
COMPILE_(ret, "break val (while/until)", node->nd_stts, iseq->compile_data->loopval_popped);
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(ret, iseq, 0);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->end_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else if (iseq->type == ISEQ_TYPE_BLOCK) {
|
|
|
|
break_by_insn:
|
|
|
|
/* escape from block */
|
|
|
|
COMPILE(ret, "break val (block)", node->nd_stts);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x02) /* TAG_BREAK */ );
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else if (iseq->type == ISEQ_TYPE_EVAL) {
|
2007-12-19 19:10:54 +03:00
|
|
|
break_in_eval:
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with break"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_iseq_t *ip = iseq->parent_iseq;
|
2007-12-19 19:10:54 +03:00
|
|
|
while (ip) {
|
2008-12-27 08:58:23 +03:00
|
|
|
if (!ip->compile_data) {
|
|
|
|
ip = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
level++;
|
|
|
|
if (ip->compile_data->redo_label != 0) {
|
|
|
|
level = 0x8000;
|
|
|
|
if (ip->compile_data->loopval_popped == 0) {
|
|
|
|
/* need value */
|
|
|
|
level |= 0x4000;
|
|
|
|
}
|
|
|
|
goto break_by_insn;
|
|
|
|
}
|
|
|
|
else if (ip->type == ISEQ_TYPE_BLOCK) {
|
|
|
|
level <<= 16;
|
|
|
|
goto break_by_insn;
|
|
|
|
}
|
2007-12-19 19:10:54 +03:00
|
|
|
else if (ip->type == ISEQ_TYPE_EVAL) {
|
|
|
|
goto break_in_eval;
|
|
|
|
}
|
2008-12-27 08:58:23 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ip = ip->parent_iseq;
|
|
|
|
}
|
2007-12-21 06:27:31 +03:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Invalid break"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_NEXT:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
unsigned long level = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (iseq->compile_data->redo_label != 0) {
|
2008-01-26 11:27:00 +03:00
|
|
|
LABEL *splabel = NEW_LABEL(0);
|
2008-01-25 21:02:01 +03:00
|
|
|
debugs("next in while loop\n");
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_LABEL(ret, splabel);
|
2008-01-26 11:44:43 +03:00
|
|
|
COMPILE(ret, "next val/valid syntax?", node->nd_stts);
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(ret, iseq, 0);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST(ret, nd_line(node), iseq->compile_data->redo_label);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->start_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else if (iseq->compile_data->end_label) {
|
2008-01-26 11:27:00 +03:00
|
|
|
LABEL *splabel = NEW_LABEL(0);
|
2007-08-16 17:12:24 +04:00
|
|
|
debugs("next in block\n");
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_LABEL(ret, splabel);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_ADJUST(ret, nd_line(node), iseq->compile_data->start_label);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "next val", node->nd_stts);
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(ret, iseq, 0);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->end_label);
|
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else if (iseq->type == ISEQ_TYPE_EVAL) {
|
2007-12-19 19:10:54 +03:00
|
|
|
next_in_eval:
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with next"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-08-16 17:12:24 +04:00
|
|
|
rb_iseq_t *ip;
|
|
|
|
ip = iseq;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
while (ip) {
|
2008-12-27 08:58:23 +03:00
|
|
|
if (!ip->compile_data) {
|
|
|
|
ip = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-05-24 10:29:48 +04:00
|
|
|
level = 0x8000 | 0x4000;
|
2007-08-16 22:12:02 +04:00
|
|
|
if (ip->compile_data->redo_label != 0) {
|
|
|
|
/* while loop */
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
|
|
|
}
|
2007-08-16 22:12:02 +04:00
|
|
|
else if (ip->type == ISEQ_TYPE_BLOCK) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
|
|
|
}
|
2007-12-19 19:10:54 +03:00
|
|
|
else if (ip->type == ISEQ_TYPE_EVAL) {
|
|
|
|
goto next_in_eval;
|
|
|
|
}
|
2008-12-27 08:58:23 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ip = ip->parent_iseq;
|
|
|
|
}
|
|
|
|
if (ip != 0) {
|
|
|
|
COMPILE(ret, "next val", node->nd_stts);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x03) /* TAG_NEXT */ );
|
|
|
|
|
|
|
|
if (poped) {
|
2007-08-16 17:12:24 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-12-21 06:27:31 +03:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Invalid next"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_REDO:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (iseq->compile_data->redo_label) {
|
2008-01-26 11:27:00 +03:00
|
|
|
LABEL *splabel = NEW_LABEL(0);
|
2007-08-16 17:12:24 +04:00
|
|
|
debugs("redo in while");
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_LABEL(ret, splabel);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_ADJUST(ret, nd_line(node), iseq->compile_data->redo_label);
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(ret, iseq, 0);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->redo_label);
|
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else if (iseq->type == ISEQ_TYPE_EVAL) {
|
2007-12-19 19:10:54 +03:00
|
|
|
redo_in_eval:
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with redo"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else if (iseq->compile_data->start_label) {
|
2008-01-26 11:27:00 +03:00
|
|
|
LABEL *splabel = NEW_LABEL(0);
|
|
|
|
|
|
|
|
debugs("redo in block");
|
|
|
|
ADD_LABEL(ret, splabel);
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(ret, iseq, 0);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_ADJUST(ret, nd_line(node), iseq->compile_data->start_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_INSNL(ret, nd_line(node), jump, iseq->compile_data->start_label);
|
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2007-08-16 17:12:24 +04:00
|
|
|
rb_iseq_t *ip;
|
|
|
|
unsigned long level;
|
|
|
|
level = 0x8000 | 0x4000;
|
|
|
|
ip = iseq;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
while (ip) {
|
2008-12-27 08:58:23 +03:00
|
|
|
if (!ip->compile_data) {
|
|
|
|
ip = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-08-16 17:12:24 +04:00
|
|
|
if (ip->compile_data->redo_label != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (ip->type == ISEQ_TYPE_BLOCK) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (ip->type == ISEQ_TYPE_EVAL) {
|
2007-12-19 19:10:54 +03:00
|
|
|
goto redo_in_eval;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2008-12-27 08:58:23 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ip = ip->parent_iseq;
|
|
|
|
}
|
|
|
|
if (ip != 0) {
|
2007-12-25 05:24:12 +03:00
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), throw, INT2FIX(level | 0x05) /* TAG_REDO */ );
|
|
|
|
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-12-21 06:27:31 +03:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Invalid redo"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_RETRY:{
|
2007-12-19 11:46:49 +03:00
|
|
|
if (iseq->type == ISEQ_TYPE_RESCUE) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x04) /* TAG_RETRY */ );
|
2007-12-25 15:37:16 +03:00
|
|
|
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-12-21 06:27:31 +03:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Invalid retry"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_BEGIN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE_(ret, "NODE_BEGIN", node->nd_body, poped);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_RESCUE:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lcont = NEW_LABEL(nd_line(node));
|
2008-01-26 11:27:00 +03:00
|
|
|
VALUE rescue = NEW_CHILD_ISEQVAL(
|
|
|
|
node->nd_resq,
|
|
|
|
rb_str_concat(rb_str_new2("rescue in "), iseq->name),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_RESCUE, nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, lstart);
|
|
|
|
COMPILE(ret, "rescue head", node->nd_head);
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
if (node->nd_else) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
COMPILE(ret, "rescue else", node->nd_else);
|
|
|
|
}
|
|
|
|
ADD_INSN(ret, nd_line(node), nop);
|
|
|
|
ADD_LABEL(ret, lcont);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
|
2009-11-03 20:46:28 +03:00
|
|
|
/* register catch entry */
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lcont);
|
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, lend, lcont, 0, lstart);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_RESBODY:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
NODE *resq = node;
|
|
|
|
NODE *narg;
|
|
|
|
LABEL *label_miss, *label_hit;
|
|
|
|
|
|
|
|
while (resq) {
|
|
|
|
label_miss = NEW_LABEL(nd_line(node));
|
|
|
|
label_hit = NEW_LABEL(nd_line(node));
|
|
|
|
|
|
|
|
narg = resq->nd_args;
|
2008-04-20 09:44:47 +04:00
|
|
|
if (narg) {
|
|
|
|
switch (nd_type(narg)) {
|
|
|
|
case NODE_ARRAY:
|
|
|
|
while (narg) {
|
|
|
|
COMPILE(ret, "rescue arg", narg->nd_head);
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(2), INT2FIX(0));
|
2008-04-20 09:44:47 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(idEqq), INT2FIX(1));
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, label_hit);
|
|
|
|
narg = narg->nd_next;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NODE_SPLAT:
|
|
|
|
case NODE_ARGSCAT:
|
|
|
|
case NODE_ARGSPUSH:
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(2), INT2FIX(0));
|
2008-04-20 09:44:47 +04:00
|
|
|
COMPILE(ret, "rescue/cond splat", narg);
|
|
|
|
ADD_INSN1(ret, nd_line(node), checkincludearray, Qtrue);
|
|
|
|
ADD_INSN(ret, nd_line(node), swap);
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, label_hit);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rb_bug("NODE_RESBODY: unknown node (%s)",
|
|
|
|
ruby_node_name(nd_type(narg)));
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2008-04-20 09:44:47 +04:00
|
|
|
else {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putobject,
|
|
|
|
rb_eStandardError);
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(2), INT2FIX(0));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(idEqq), INT2FIX(1));
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, label_hit);
|
|
|
|
}
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, label_miss);
|
|
|
|
ADD_LABEL(ret, label_hit);
|
|
|
|
COMPILE(ret, "resbody body", resq->nd_body);
|
2007-08-19 08:16:13 +04:00
|
|
|
if (iseq->compile_data->option->tailcall_optimization) {
|
|
|
|
ADD_INSN(ret, nd_line(node), nop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), leave);
|
|
|
|
ADD_LABEL(ret, label_miss);
|
|
|
|
resq = resq->nd_head;
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ENSURE:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
DECL_ANCHOR(ensr);
|
|
|
|
VALUE ensure = NEW_CHILD_ISEQVAL(node->nd_ensr,
|
|
|
|
rb_str_concat(rb_str_new2
|
|
|
|
("ensure in "),
|
|
|
|
iseq->name),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_ENSURE, nd_line(node));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lcont = NEW_LABEL(nd_line(node));
|
2009-02-16 23:54:58 +03:00
|
|
|
struct ensure_range er;
|
2007-07-20 11:11:35 +04:00
|
|
|
struct iseq_compile_data_ensure_node_stack enl;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
struct ensure_range *erange;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(ensr);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE_POPED(ensr, "ensure ensr", node->nd_ensr);
|
|
|
|
|
2009-02-16 23:54:58 +03:00
|
|
|
er.begin = lstart;
|
|
|
|
er.end = lend;
|
|
|
|
er.next = 0;
|
|
|
|
push_ensure_entry(iseq, &enl, &er, node->nd_ensr);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
|
|
|
ADD_LABEL(ret, lstart);
|
|
|
|
COMPILE_(ret, "ensure head", node->nd_head, poped);
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
if (ensr->anchor.next == 0) {
|
|
|
|
ADD_INSN(ret, nd_line(node), nop);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEQ(ret, ensr);
|
|
|
|
}
|
|
|
|
ADD_LABEL(ret, lcont);
|
|
|
|
|
|
|
|
erange = iseq->compile_data->ensure_node_stack->erange;
|
|
|
|
while (erange) {
|
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_ENSURE, erange->begin, erange->end,
|
|
|
|
ensure, lcont);
|
|
|
|
erange = erange->next;
|
|
|
|
}
|
2009-02-16 23:54:58 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
iseq->compile_data->ensure_node_stack = enl.prev;
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
case NODE_AND:
|
|
|
|
case NODE_OR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *end_label = NEW_LABEL(nd_line(node));
|
|
|
|
COMPILE(ret, "nd_1st", node->nd_1st);
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
}
|
|
|
|
if (type == NODE_AND) {
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, end_label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, end_label);
|
|
|
|
}
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
COMPILE_(ret, "nd_2nd", node->nd_2nd, poped);
|
|
|
|
ADD_LABEL(ret, end_label);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
case NODE_MASGN:{
|
2008-10-12 05:18:49 +04:00
|
|
|
compile_massign(iseq, ret, node, poped);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
case NODE_LASGN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ID id = node->nd_vid;
|
2007-07-07 12:14:00 +04:00
|
|
|
int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
|
2007-02-25 04:34:33 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugs("lvar: %s idx: %d\n", rb_id2name(id), idx);
|
|
|
|
COMPILE(ret, "rvalue", node->nd_value);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
}
|
|
|
|
ADD_INSN1(ret, nd_line(node), setlocal, INT2FIX(idx));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DASGN:
|
|
|
|
case NODE_DASGN_CURR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
int idx, lv, ls;
|
|
|
|
COMPILE(ret, "dvalue", node->nd_value);
|
2007-06-15 07:27:33 +04:00
|
|
|
debugp_param("dassn id", rb_str_new2(rb_id2name(node->nd_vid) ? rb_id2name(node->nd_vid) : "*"));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-07 12:14:00 +04:00
|
|
|
idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (idx < 0) {
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("NODE_DASGN(_CURR): unknown id (%s)", rb_id2name(node->nd_vid));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2007-06-27 20:21:57 +04:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), setdynamic,
|
|
|
|
INT2FIX(ls - idx), INT2FIX(lv));
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_GASGN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "lvalue", node->nd_value);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
}
|
|
|
|
ADD_INSN1(ret, nd_line(node), setglobal,
|
|
|
|
(((long)node->nd_entry) | 1));
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-02-06 08:22:17 +03:00
|
|
|
case NODE_IASGN:
|
2007-02-04 22:17:33 +03:00
|
|
|
case NODE_IASGN2:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "lvalue", node->nd_value);
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
}
|
|
|
|
ADD_INSN1(ret, nd_line(node), setinstancevariable,
|
|
|
|
ID2SYM(node->nd_vid));
|
|
|
|
break;
|
2007-02-04 22:17:33 +03:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
case NODE_CDECL:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "lvalue", node->nd_value);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (node->nd_vid) {
|
2009-12-03 21:25:57 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject,
|
|
|
|
INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
|
2008-05-14 06:31:28 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setconstant, ID2SYM(node->nd_vid));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
compile_cpath(ret, iseq, node->nd_else);
|
2008-05-14 06:31:28 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setconstant, ID2SYM(node->nd_else->nd_mid));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-02-02 13:24:06 +03:00
|
|
|
case NODE_CVASGN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "cvasgn val", node->nd_value);
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
}
|
|
|
|
ADD_INSN1(ret, nd_line(node), setclassvariable,
|
|
|
|
ID2SYM(node->nd_vid));
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-11-27 09:45:01 +03:00
|
|
|
case NODE_OP_ASGN1: {
|
2008-10-12 05:18:49 +04:00
|
|
|
DECL_ANCHOR(args);
|
|
|
|
VALUE argc;
|
|
|
|
unsigned long flag = 0;
|
|
|
|
ID id = node->nd_mid;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* a[x] (op)= y
|
|
|
|
*
|
2009-09-05 10:21:15 +04:00
|
|
|
* nil # nil
|
|
|
|
* eval a # nil a
|
|
|
|
* eval x # nil a x
|
|
|
|
* dupn 2 # nil a x a x
|
|
|
|
* send :[] # nil a x a[x]
|
|
|
|
* eval y # nil a x a[x] y
|
|
|
|
* send op # nil a x ret
|
|
|
|
* setn 3 # ret a x ret
|
|
|
|
* send []= # ret ?
|
|
|
|
* pop # ret
|
2008-10-12 05:18:49 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* nd_recv[nd_args->nd_body] (nd_mid)= nd_args->nd_head;
|
|
|
|
* NODE_OP_ASGN nd_recv
|
|
|
|
* nd_args->nd_head
|
|
|
|
* nd_args->nd_body
|
|
|
|
* nd_mid
|
|
|
|
*/
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2009-09-05 10:21:15 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
2008-10-12 05:18:49 +04:00
|
|
|
COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv);
|
2009-09-18 11:15:06 +04:00
|
|
|
if (nd_type(node->nd_args->nd_head) != NODE_ZARRAY) {
|
2008-10-12 05:18:49 +04:00
|
|
|
INIT_ANCHOR(args);
|
2009-09-18 11:15:06 +04:00
|
|
|
argc = setup_args(iseq, args, node->nd_args->nd_head, &flag);
|
2008-10-12 05:18:49 +04:00
|
|
|
ADD_SEQ(ret, args);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
argc = INT2FIX(0);
|
|
|
|
}
|
2009-09-05 09:34:56 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1));
|
2008-10-12 05:18:49 +04:00
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
|
|
|
|
|
|
|
|
if (id == 0 || id == 1) {
|
|
|
|
/* 0: or, 1: and
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
a[x] ||= y
|
|
|
|
|
|
|
|
unless/if a[x]
|
|
|
|
a[x]= y
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
2008-10-12 05:18:49 +04:00
|
|
|
*/
|
|
|
|
LABEL *label = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lfin = NEW_LABEL(nd_line(node));
|
|
|
|
|
2009-09-05 10:21:15 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
2008-10-12 05:18:49 +04:00
|
|
|
if (id == 0) {
|
|
|
|
/* or */
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* and */
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, label);
|
|
|
|
}
|
2009-09-05 10:21:15 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2009-09-18 11:15:06 +04:00
|
|
|
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
2009-09-05 10:21:15 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
|
|
|
}
|
2008-10-12 05:18:49 +04:00
|
|
|
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
|
|
|
ADD_INSN(ret, nd_line(node), concatarray);
|
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
|
|
|
argc, Qfalse, LONG2FIX(flag));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
2009-09-05 09:34:56 +04:00
|
|
|
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
2008-10-12 05:18:49 +04:00
|
|
|
}
|
2009-09-05 10:21:15 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
2008-10-12 05:18:49 +04:00
|
|
|
ADD_INSNL(ret, nd_line(node), jump, lfin);
|
|
|
|
ADD_LABEL(ret, label);
|
2009-09-05 10:21:15 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
|
|
|
}
|
|
|
|
ADD_INSN1(ret, nd_line(node), adjuststack, FIXNUM_INC(argc, 2));
|
2008-10-12 05:18:49 +04:00
|
|
|
ADD_LABEL(ret, lfin);
|
|
|
|
}
|
|
|
|
else {
|
2009-09-18 11:15:06 +04:00
|
|
|
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
2008-10-12 05:18:49 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(id), INT2FIX(1));
|
2009-09-05 10:21:15 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
|
|
|
}
|
2008-10-12 05:18:49 +04:00
|
|
|
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
|
|
|
ADD_INSN(ret, nd_line(node), concatarray);
|
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
|
|
|
argc, Qfalse, LONG2FIX(flag));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
2009-09-05 09:34:56 +04:00
|
|
|
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
2008-10-12 05:18:49 +04:00
|
|
|
}
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2008-10-12 05:18:49 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_OP_ASGN2:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ID atype = node->nd_next->nd_mid;
|
|
|
|
LABEL *lfin = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lcfin = NEW_LABEL(nd_line(node));
|
|
|
|
/*
|
|
|
|
class C; attr_accessor :c; end
|
|
|
|
r = C.new
|
|
|
|
r.a &&= v # asgn2
|
|
|
|
|
|
|
|
eval r # r
|
|
|
|
dup # r r
|
|
|
|
eval r.a # r o
|
|
|
|
|
|
|
|
# or
|
|
|
|
dup # r o o
|
|
|
|
if lcfin # r o
|
|
|
|
pop # r
|
|
|
|
eval v # r v
|
2009-09-05 05:38:47 +04:00
|
|
|
swap # v r
|
|
|
|
topn 1 # v r v
|
|
|
|
send a= # v ?
|
|
|
|
jump lfin # v ?
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
|
|
|
lcfin: # r o
|
|
|
|
swap # o r
|
|
|
|
|
2009-09-05 05:38:47 +04:00
|
|
|
lfin: # o ?
|
|
|
|
pop # o
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
|
|
|
# and
|
|
|
|
dup # r o o
|
|
|
|
unless lcfin
|
|
|
|
pop # r
|
|
|
|
eval v # r v
|
2009-09-05 05:38:47 +04:00
|
|
|
swap # v r
|
|
|
|
topn 1 # v r v
|
|
|
|
send a= # v ?
|
|
|
|
jump lfin # v ?
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
|
|
|
# others
|
|
|
|
eval v # r o v
|
|
|
|
send ?? # r w
|
|
|
|
send a= # w
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
COMPILE(ret, "NODE_OP_ASGN2#recv", node->nd_recv);
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_vid),
|
|
|
|
INT2FIX(0));
|
|
|
|
|
|
|
|
if (atype == 0 || atype == 1) { /* 0: OR or 1: AND */
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
if (atype == 0) {
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, lcfin);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lcfin);
|
|
|
|
}
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value);
|
2009-09-05 05:38:47 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), swap);
|
|
|
|
ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_aid),
|
|
|
|
INT2FIX(1));
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, lfin);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, lcfin);
|
|
|
|
ADD_INSN(ret, nd_line(node), swap);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, lfin);
|
2009-09-05 05:38:47 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
if (poped) {
|
|
|
|
/* we can apply more optimize */
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value);
|
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_mid),
|
|
|
|
INT2FIX(1));
|
2009-09-05 05:38:47 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), swap);
|
|
|
|
ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_next->nd_aid),
|
|
|
|
INT2FIX(1));
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_OP_ASGN_AND:
|
|
|
|
case NODE_OP_ASGN_OR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *lfin = NEW_LABEL(nd_line(node));
|
2008-03-25 09:26:32 +03:00
|
|
|
LABEL *lassign;
|
2007-06-05 08:49:54 +04:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (nd_type(node) == NODE_OP_ASGN_OR) {
|
2008-03-25 09:26:32 +03:00
|
|
|
LABEL *lfinish[2];
|
|
|
|
lfinish[0] = lfin;
|
|
|
|
lfinish[1] = 0;
|
|
|
|
defined_expr(iseq, ret, node->nd_head, lfinish, Qfalse);
|
|
|
|
lassign = lfinish[1];
|
|
|
|
if (!lassign) {
|
|
|
|
lassign = NEW_LABEL(nd_line(node));
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lassign);
|
|
|
|
}
|
2008-03-25 09:26:32 +03:00
|
|
|
else {
|
|
|
|
lassign = NEW_LABEL(nd_line(node));
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_head", node->nd_head);
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
2007-06-05 08:49:54 +04:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (nd_type(node) == NODE_OP_ASGN_AND) {
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lfin);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, lfin);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
ADD_LABEL(ret, lassign);
|
|
|
|
COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_value", node->nd_value);
|
|
|
|
ADD_LABEL(ret, lfin);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
/* we can apply more optimize */
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_CALL:
|
|
|
|
case NODE_FCALL:
|
|
|
|
case NODE_VCALL:{ /* VCALL: variable or call */
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/*
|
|
|
|
call: obj.method(...)
|
|
|
|
fcall: func(...)
|
|
|
|
vcall: func
|
|
|
|
*/
|
|
|
|
DECL_ANCHOR(recv);
|
|
|
|
DECL_ANCHOR(args);
|
|
|
|
ID mid = node->nd_mid;
|
|
|
|
VALUE argc;
|
2007-06-27 21:13:13 +04:00
|
|
|
unsigned long flag = 0;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE parent_block = iseq->compile_data->current_block;
|
|
|
|
iseq->compile_data->current_block = Qfalse;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(recv);
|
|
|
|
INIT_ANCHOR(args);
|
2006-12-31 18:02:22 +03:00
|
|
|
#if SUPPORT_JOKE
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (nd_type(node) == NODE_VCALL) {
|
|
|
|
if (mid == idBitblt) {
|
|
|
|
ADD_INSN(ret, nd_line(node), bitblt);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (mid == idAnswer) {
|
|
|
|
ADD_INSN(ret, nd_line(node), answer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* only joke */
|
|
|
|
{
|
2008-06-09 13:25:32 +04:00
|
|
|
ID goto_id;
|
|
|
|
ID label_id;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE label;
|
|
|
|
VALUE label_sym;
|
|
|
|
|
2008-06-09 13:25:32 +04:00
|
|
|
CONST_ID(goto_id, "__goto__");
|
|
|
|
CONST_ID(label_id, "__label__");
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (nd_type(node) == NODE_FCALL &&
|
|
|
|
(mid == goto_id || mid == label_id)) {
|
|
|
|
if (nd_type(node->nd_args->nd_head) == NODE_LIT &&
|
|
|
|
SYMBOL_P(node->nd_args->nd_head->nd_lit)) {
|
|
|
|
|
|
|
|
label_sym = label = node->nd_args->nd_head->nd_lit;
|
|
|
|
if ((label =
|
|
|
|
rb_hash_aref(iseq->compile_data,
|
|
|
|
label_sym)) == Qnil) {
|
|
|
|
rb_hash_aset(iseq->compile_data, label_sym,
|
|
|
|
label = NEW_LABEL(nd_line(node)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
* regerror.c, string.c, io.c, lib/getoptlong.rb, lib/net/imap.rb,
compile.c, sprintf.c, parse.y, ext/win32ole/win32ole.c,
ext/tk/sample/demos-en/entry3.rb, ext/tk/lib/tcltk.rb,
ext/openssl/ossl_bn.c, numeric.c, vm.c,
benchmark/bm_so_meteor_contest.rb, bignum.c, ruby.c: don't "illegal"
for non law violation context.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 05:31:11 +03:00
|
|
|
rb_bug("invalid goto/label format");
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mid == goto_id) {
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_LABEL(ret, label);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
#endif
|
2009-11-03 20:46:28 +03:00
|
|
|
/* receiver */
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (type == NODE_CALL) {
|
|
|
|
COMPILE(recv, "recv", node->nd_recv);
|
|
|
|
}
|
|
|
|
else if (type == NODE_FCALL || type == NODE_VCALL) {
|
|
|
|
ADD_CALL_RECEIVER(recv, nd_line(node));
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/* args */
|
|
|
|
if (nd_type(node) != NODE_VCALL) {
|
2007-06-25 22:23:35 +04:00
|
|
|
argc = setup_args(iseq, args, node->nd_args, &flag);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
argc = INT2FIX(0);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, args);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugp_param("call args argc", argc);
|
|
|
|
debugp_param("call method", ID2SYM(mid));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
switch (nd_type(node)) {
|
|
|
|
case NODE_VCALL:
|
|
|
|
flag |= VM_CALL_VCALL_BIT;
|
|
|
|
/* VCALL is funcall, so fall through */
|
|
|
|
case NODE_FCALL:
|
|
|
|
flag |= VM_CALL_FCALL_BIT;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(mid),
|
2007-06-27 21:13:13 +04:00
|
|
|
argc, parent_block, LONG2FIX(flag));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_SUPER:
|
|
|
|
case NODE_ZSUPER:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
DECL_ANCHOR(args);
|
|
|
|
VALUE argc;
|
2007-06-27 21:13:13 +04:00
|
|
|
unsigned long flag = 0;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE parent_block = iseq->compile_data->current_block;
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(args);
|
|
|
|
iseq->compile_data->current_block = Qfalse;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (nd_type(node) == NODE_SUPER) {
|
2007-06-25 22:23:35 +04:00
|
|
|
argc = setup_args(iseq, args, node->nd_args, &flag);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* NODE_ZSUPER */
|
|
|
|
int i;
|
|
|
|
rb_iseq_t *liseq = iseq->local_iseq;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
argc = INT2FIX(liseq->argc);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/* normal arguments */
|
|
|
|
for (i = 0; i < liseq->argc; i++) {
|
|
|
|
int idx = liseq->local_size - i;
|
|
|
|
ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
|
|
|
|
}
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:07:05 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!liseq->arg_simple) {
|
|
|
|
if (liseq->arg_opts) {
|
|
|
|
/* optional arguments */
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < liseq->arg_opts - 1; j++) {
|
|
|
|
int idx = liseq->local_size - (i + j);
|
2007-06-24 11:29:21 +04:00
|
|
|
ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
i += j;
|
|
|
|
argc = INT2FIX(i);
|
|
|
|
}
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:07:05 +03:00
|
|
|
|
2007-06-24 11:29:21 +04:00
|
|
|
if (liseq->arg_rest != -1) {
|
|
|
|
/* rest argument */
|
|
|
|
int idx = liseq->local_size - liseq->arg_rest;
|
|
|
|
ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
|
|
|
|
argc = INT2FIX(liseq->arg_rest + 1);
|
|
|
|
flag |= VM_CALL_ARGS_SPLAT_BIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (liseq->arg_post_len) {
|
|
|
|
/* post arguments */
|
|
|
|
int post_len = liseq->arg_post_len;
|
|
|
|
int post_start = liseq->arg_post_start;
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-24 05:07:05 +03:00
|
|
|
|
2007-06-24 11:29:21 +04:00
|
|
|
if (liseq->arg_rest != -1) {
|
|
|
|
int j;
|
|
|
|
for (j=0; j<post_len; j++) {
|
|
|
|
int idx = liseq->local_size - (post_start + j);
|
|
|
|
ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
|
2007-11-27 09:45:01 +03:00
|
|
|
}
|
2007-06-24 11:29:21 +04:00
|
|
|
ADD_INSN1(args, nd_line(node), newarray, INT2FIX(j));
|
|
|
|
ADD_INSN (args, nd_line(node), concatarray);
|
|
|
|
/* argc is setteled at above */
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-06-24 11:29:21 +04:00
|
|
|
int j;
|
|
|
|
for (j=0; j<post_len; j++) {
|
|
|
|
int idx = liseq->local_size - (post_start + j);
|
|
|
|
ADD_INSN1(args, nd_line(node), getlocal, INT2FIX(idx));
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
2007-06-24 11:29:21 +04:00
|
|
|
argc = INT2FIX(post_len + post_start);
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2009-11-03 20:46:28 +03:00
|
|
|
/* dummy receiver */
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putobject,
|
|
|
|
nd_type(node) == NODE_ZSUPER ? Qfalse : Qtrue);
|
|
|
|
ADD_SEQ(ret, args);
|
|
|
|
ADD_INSN3(ret, nd_line(node), invokesuper,
|
2007-06-27 21:13:13 +04:00
|
|
|
argc, parent_block, LONG2FIX(flag));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ARRAY:{
|
2007-07-03 23:35:09 +04:00
|
|
|
compile_array_(iseq, ret, node, Qtrue, poped);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ZARRAY:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(0));
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_VALUES:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
NODE *n = node;
|
|
|
|
while (n) {
|
|
|
|
COMPILE(ret, "values item", n->nd_head);
|
|
|
|
n = n->nd_next;
|
|
|
|
}
|
|
|
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(node->nd_alen));
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_HASH:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
DECL_ANCHOR(list);
|
|
|
|
VALUE size = 0;
|
|
|
|
int type = node->nd_head ? nd_type(node->nd_head) : NODE_ZARRAY;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(list);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
switch (type) {
|
|
|
|
case NODE_ARRAY:{
|
|
|
|
compile_array(iseq, list, node->nd_head, Qfalse);
|
|
|
|
size = OPERAND_AT(POP_ELEMENT(list), 0);
|
|
|
|
ADD_SEQ(ret, list);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case NODE_ZARRAY:
|
|
|
|
size = INT2FIX(0);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("can't make hash with this node: %s", ruby_node_name(type));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), newhash, size);
|
|
|
|
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_RETURN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
rb_iseq_t *is = iseq;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2009-07-31 06:48:10 +04:00
|
|
|
if (is) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (is->type == ISEQ_TYPE_TOP || is->type == ISEQ_TYPE_CLASS) {
|
2007-12-21 06:27:31 +03:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Invalid return"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2008-01-26 11:27:00 +03:00
|
|
|
LABEL *splabel = 0;
|
2008-01-25 21:02:01 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (is->type == ISEQ_TYPE_METHOD) {
|
2008-01-26 11:27:00 +03:00
|
|
|
splabel = NEW_LABEL(0);
|
|
|
|
ADD_LABEL(ret, splabel);
|
2008-01-25 21:02:01 +03:00
|
|
|
ADD_ADJUST(ret, nd_line(node), 0);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
|
2007-08-16 17:12:24 +04:00
|
|
|
COMPILE(ret, "return nd_stts (return val)", node->nd_stts);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (is->type == ISEQ_TYPE_METHOD) {
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(ret, iseq, 1);
|
2009-08-18 20:15:29 +04:00
|
|
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), leave);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
2008-01-25 21:02:01 +03:00
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-12-20 00:39:08 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), throw, INT2FIX(0x01) /* TAG_RETURN */ );
|
2007-12-20 03:46:12 +03:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_YIELD:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
DECL_ANCHOR(args);
|
2007-06-26 23:24:40 +04:00
|
|
|
VALUE argc;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
unsigned long flag = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(args);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (iseq->type == ISEQ_TYPE_TOP || iseq->type == ISEQ_TYPE_CLASS) {
|
2007-12-21 06:27:31 +03:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "Invalid yield"));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (node->nd_head) {
|
2007-06-25 22:23:35 +04:00
|
|
|
argc = setup_args(iseq, args, node->nd_head, &flag);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
2007-06-26 23:24:40 +04:00
|
|
|
argc = INT2FIX(0);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2007-06-25 22:23:35 +04:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_SEQ(ret, args);
|
2007-06-27 21:13:13 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), invokeblock, argc, LONG2FIX(flag));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_LVAR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ID id = node->nd_vid;
|
2007-07-07 12:14:00 +04:00
|
|
|
int idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
|
2007-02-25 04:34:33 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugs("id: %s idx: %d\n", rb_id2name(id), idx);
|
|
|
|
ADD_INSN1(ret, nd_line(node), getlocal, INT2FIX(idx));
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DVAR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
int lv, idx, ls;
|
|
|
|
debugi("nd_vid", node->nd_vid);
|
|
|
|
if (!poped) {
|
2007-07-07 12:14:00 +04:00
|
|
|
idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (idx < 0) {
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("unknown dvar (%s)", rb_id2name(node->nd_vid));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(ls - idx), INT2FIX(lv));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_GVAR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), getglobal,
|
|
|
|
(((long)node->nd_entry) | 1));
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private
instance variable feature, which is postponed until next major
release.
* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
8th version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 05:49:41 +03:00
|
|
|
case NODE_IVAR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugi("nd_vid", node->nd_vid);
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), getinstancevariable,
|
|
|
|
ID2SYM(node->nd_vid));
|
|
|
|
}
|
|
|
|
break;
|
2007-02-04 22:17:33 +03:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
case NODE_CONST:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugi("nd_vid", node->nd_vid);
|
|
|
|
|
|
|
|
if (iseq->compile_data->option->inline_const_cache) {
|
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
|
|
|
|
|
|
|
ADD_LABEL(ret, lstart);
|
2009-07-13 08:44:20 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), getinlinecache, lend);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), getconstant, ID2SYM(node->nd_vid));
|
|
|
|
ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_INSN1(ret, nd_line(node), getconstant, ID2SYM(node->nd_vid));
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_CVAR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), getclassvariable,
|
|
|
|
ID2SYM(node->nd_vid));
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_NTH_REF:{
|
2007-06-27 20:21:57 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN2(ret, nd_line(node), getspecial, INT2FIX(1) /* '~' */,
|
|
|
|
INT2FIX(node->nd_nth << 1));
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_BACK_REF:{
|
2007-06-27 20:21:57 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN2(ret, nd_line(node), getspecial, INT2FIX(1) /* '~' */,
|
|
|
|
INT2FIX(0x01 | (node->nd_nth << 1)));
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_MATCH:
|
|
|
|
case NODE_MATCH2:
|
|
|
|
case NODE_MATCH3:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
DECL_ANCHOR(recv);
|
|
|
|
DECL_ANCHOR(val);
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(recv);
|
|
|
|
INIT_ANCHOR(val);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
switch(nd_type(node)) {
|
|
|
|
case NODE_MATCH:
|
|
|
|
ADD_INSN1(recv, nd_line(node), putobject, node->nd_lit);
|
|
|
|
ADD_INSN2(val, nd_line(node), getspecial, INT2FIX(0),
|
|
|
|
INT2FIX(0));
|
|
|
|
break;
|
|
|
|
case NODE_MATCH2:
|
2009-11-03 20:46:28 +03:00
|
|
|
COMPILE(recv, "receiver", node->nd_recv);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(val, "value", node->nd_value);
|
|
|
|
break;
|
|
|
|
case NODE_MATCH3:
|
2009-11-03 20:46:28 +03:00
|
|
|
COMPILE(recv, "receiver", node->nd_value);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(val, "value", node->nd_recv);
|
|
|
|
break;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (iseq->compile_data->option->specialized_instruction) {
|
|
|
|
/* TODO: detect by node */
|
|
|
|
if (recv->last == recv->anchor.next &&
|
|
|
|
INSN_OF(recv->last) == BIN(putobject) &&
|
|
|
|
nd_type(node) == NODE_MATCH2) {
|
|
|
|
ADD_SEQ(ret, val);
|
|
|
|
ADD_INSN1(ret, nd_line(node), opt_regexpmatch1,
|
|
|
|
OPERAND_AT(recv->last, 0));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, val);
|
|
|
|
ADD_INSN(ret, nd_line(node), opt_regexpmatch2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, val);
|
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(idEqTilde), INT2FIX(1));
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_LIT:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugp_param("lit", node->nd_lit);
|
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_STR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugp_param("nd_lit", node->nd_lit);
|
|
|
|
if (!poped) {
|
2009-02-12 13:42:36 +03:00
|
|
|
hide_obj(node->nd_lit);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putstring, node->nd_lit);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DSTR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
compile_dstr(iseq, ret, node);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_XSTR:{
|
2009-02-12 19:45:18 +03:00
|
|
|
OBJ_FREEZE(node->nd_lit);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_CALL_RECEIVER(ret, nd_line(node));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
|
|
|
|
ADD_CALL(ret, nd_line(node), ID2SYM(idBackquote), INT2FIX(1));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DXSTR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_CALL_RECEIVER(ret, nd_line(node));
|
|
|
|
compile_dstr(iseq, ret, node);
|
|
|
|
ADD_CALL(ret, nd_line(node), ID2SYM(idBackquote), INT2FIX(1));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_EVSTR:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "nd_body", node->nd_body);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(ret, nd_line(node), tostring);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DREGX:{
|
2008-01-29 11:03:51 +03:00
|
|
|
compile_dregx(iseq, ret, node);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DREGX_ONCE:{
|
2007-06-27 20:21:57 +04:00
|
|
|
/* TODO: once? */
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, lstart);
|
2009-07-13 08:44:20 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), onceinlinecache, lend);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-01-29 11:03:51 +03:00
|
|
|
compile_dregx(iseq, ret, node);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
|
|
|
|
ADD_LABEL(ret, lend);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ARGSCAT:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "argscat head", node->nd_head);
|
|
|
|
COMPILE(ret, "argscat body", node->nd_body);
|
|
|
|
ADD_INSN(ret, nd_line(node), concatarray);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ARGSPUSH:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "arsgpush head", node->nd_head);
|
|
|
|
COMPILE(ret, "argspush body", node->nd_body);
|
|
|
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
|
|
|
ADD_INSN(ret, nd_line(node), concatarray);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_SPLAT:{
|
2008-10-12 05:18:49 +04:00
|
|
|
COMPILE(ret, "splat", node->nd_head);
|
|
|
|
ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
|
2007-07-05 22:16:54 +04:00
|
|
|
|
2008-10-12 05:18:49 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DEFN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
|
2007-12-24 19:38:44 +03:00
|
|
|
rb_str_dup(rb_id2str(node->nd_mid)),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_METHOD, nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugp_param("defn/iseq", iseqval);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->nd_mid));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putiseq, iseqval);
|
|
|
|
ADD_SEND (ret, nd_line(node), ID2SYM(id_core_define_method), INT2FIX(3));
|
|
|
|
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2008-07-01 07:05:58 +04:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugp_param("defn", iseqval);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DEFS:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE iseqval = NEW_ISEQVAL(node->nd_defn,
|
2007-12-24 19:38:44 +03:00
|
|
|
rb_str_dup(rb_id2str(node->nd_mid)),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_METHOD, nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugp_param("defs/iseq", iseqval);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "defs: recv", node->nd_recv);
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->nd_mid));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putiseq, iseqval);
|
|
|
|
ADD_SEND (ret, nd_line(node), ID2SYM(id_core_define_singleton_method), INT2FIX(3));
|
|
|
|
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ALIAS:{
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
|
2008-03-25 09:09:38 +03:00
|
|
|
COMPILE(ret, "alias arg1", node->u1.node);
|
|
|
|
COMPILE(ret, "alias arg2", node->u2.node);
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(id_core_set_method_alias), INT2FIX(3));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2008-07-01 07:05:58 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_VALIAS:{
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
2008-03-25 09:09:38 +03:00
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u1.id));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u2.id));
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(id_core_set_variable_alias), INT2FIX(2));
|
2007-11-27 04:02:30 +03:00
|
|
|
|
2008-07-01 07:05:58 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_UNDEF:{
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
|
2008-03-25 09:09:38 +03:00
|
|
|
COMPILE(ret, "undef arg", node->u2.node);
|
2008-07-01 07:05:58 +04:00
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(id_core_undef_method), INT2FIX(2));
|
2007-11-27 04:02:30 +03:00
|
|
|
|
2008-07-01 07:05:58 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_CLASS:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE iseqval =
|
2006-12-31 18:02:22 +03:00
|
|
|
NEW_CHILD_ISEQVAL(
|
|
|
|
node->nd_body,
|
2007-06-28 14:41:39 +04:00
|
|
|
rb_sprintf("<class:%s>", rb_id2name(node->nd_cpath->nd_mid)),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_CLASS, nd_line(node));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
compile_cpath(ret, iseq, node->nd_cpath);
|
|
|
|
COMPILE(ret, "super", node->nd_super);
|
|
|
|
ADD_INSN3(ret, nd_line(node), defineclass,
|
|
|
|
ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(0));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_MODULE:{
|
2007-06-28 14:41:39 +04:00
|
|
|
VALUE iseqval = NEW_CHILD_ISEQVAL(
|
|
|
|
node->nd_body,
|
|
|
|
rb_sprintf("<module:%s>", rb_id2name(node->nd_cpath->nd_mid)),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_CLASS, nd_line(node));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2008-05-05 19:01:42 +04:00
|
|
|
compile_cpath(ret, iseq, node->nd_cpath);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN (ret, nd_line(node), putnil); /* dummy */
|
|
|
|
ADD_INSN3(ret, nd_line(node), defineclass,
|
|
|
|
ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(2));
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_SCLASS:{
|
2008-06-09 13:25:32 +04:00
|
|
|
ID singletonclass;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE iseqval =
|
2006-12-31 18:02:22 +03:00
|
|
|
NEW_ISEQVAL(node->nd_body, rb_str_new2("singletonclass"),
|
2009-07-22 17:37:26 +04:00
|
|
|
ISEQ_TYPE_CLASS, nd_line(node));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "sclass#recv", node->nd_recv);
|
|
|
|
ADD_INSN (ret, nd_line(node), putnil);
|
2008-06-09 13:25:32 +04:00
|
|
|
CONST_ID(singletonclass, "singletonclass");
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN3(ret, nd_line(node), defineclass,
|
2008-06-09 13:25:32 +04:00
|
|
|
ID2SYM(singletonclass), iseqval, INT2FIX(1));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_COLON2:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (rb_is_const_id(node->nd_mid)) {
|
|
|
|
/* constant */
|
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
|
|
|
DECL_ANCHOR(pref);
|
|
|
|
DECL_ANCHOR(body);
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(pref);
|
|
|
|
INIT_ANCHOR(body);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
compile_colon2(iseq, node, pref, body);
|
|
|
|
if (LIST_SIZE_ZERO(pref)) {
|
|
|
|
if (iseq->compile_data->option->inline_const_cache) {
|
|
|
|
ADD_LABEL(ret, lstart);
|
2009-07-13 08:44:20 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), getinlinecache, lend);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
|
|
|
|
|
|
|
ADD_SEQ(ret, body);
|
|
|
|
|
|
|
|
if (iseq->compile_data->option->inline_const_cache) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEQ(ret, pref);
|
|
|
|
ADD_SEQ(ret, body);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* function call */
|
|
|
|
ADD_CALL_RECEIVER(ret, nd_line(node));
|
|
|
|
COMPILE(ret, "colon2#nd_head", node->nd_head);
|
|
|
|
ADD_CALL(ret, nd_line(node), ID2SYM(node->nd_mid),
|
|
|
|
INT2FIX(1));
|
|
|
|
}
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_COLON3:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
|
|
|
debugi("colon3#nd_mid", node->nd_mid);
|
|
|
|
|
|
|
|
/* add cache insn */
|
|
|
|
if (iseq->compile_data->option->inline_const_cache) {
|
|
|
|
ADD_LABEL(ret, lstart);
|
2009-07-13 08:44:20 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), getinlinecache, lend);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, rb_cObject);
|
|
|
|
ADD_INSN1(ret, nd_line(node), getconstant, ID2SYM(node->nd_mid));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (iseq->compile_data->option->inline_const_cache) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DOT2:
|
|
|
|
case NODE_DOT3:{
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
VALUE flag = type == NODE_DOT2 ? INT2FIX(0) : INT2FIX(1);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE(ret, "min", (NODE *) node->nd_beg);
|
|
|
|
COMPILE(ret, "max", (NODE *) node->nd_end);
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN1(ret, nd_line(node), newrange, flag);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_FLIP2:
|
|
|
|
case NODE_FLIP3:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lfin = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *ltrue = NEW_LABEL(nd_line(node));
|
2007-07-10 12:04:52 +04:00
|
|
|
VALUE key = rb_sprintf("flipflag/%s-%p-%d",
|
* compile.c (iseq_compile_each), gc.c (assign_heap_slot),
(gc_mark_children), parse.y (vtable_alloc, vtable_free, vtable_add),
proc.c (proc_to_s), thread.c (terminate_i, rb_thread_terminate_all),
(thread_start_func_2, blocking_region_begin, blocking_region_end),
(rb_thread_kill), thread_pthread.c (native_thread_create),
(ubf_pthread_cond_signal), vm.c (check_env, thread_free), vm_dump.c
(vm_env_dump_raw, vm_stack_dump_each, vm_thread_dump_state),
(vm_call0): use void pointer for %p.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-09 07:33:55 +03:00
|
|
|
RSTRING_PTR(iseq->name), (void *)iseq,
|
2007-07-10 12:04:52 +04:00
|
|
|
iseq->compile_data->flip_cnt++);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2009-02-12 19:29:17 +03:00
|
|
|
hide_obj(key);
|
2007-07-10 12:04:52 +04:00
|
|
|
iseq_add_mark_object_compile_time(iseq, key);
|
|
|
|
ADD_INSN2(ret, nd_line(node), getspecial, key, INT2FIX(0));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSNL(ret, nd_line(node), branchif, lend);
|
|
|
|
|
|
|
|
/* *flip == 0 */
|
|
|
|
COMPILE(ret, "flip2 beg", node->nd_beg);
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, lfin);
|
|
|
|
if (nd_type(node) == NODE_FLIP3) {
|
|
|
|
ADD_INSN(ret, nd_line(node), dup);
|
2007-07-10 12:04:52 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setspecial, key);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSNL(ret, nd_line(node), jump, lfin);
|
|
|
|
}
|
|
|
|
else {
|
2007-07-10 12:04:52 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setspecial, key);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/* *flip == 1 */
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
COMPILE(ret, "flip2 end", node->nd_end);
|
|
|
|
ADD_INSNL(ret, nd_line(node), branchunless, ltrue);
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, Qfalse);
|
2007-07-10 12:04:52 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setspecial, key);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, ltrue);
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_LABEL(ret, lfin);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_SELF:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), putself);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_NIL:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_TRUE:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_FALSE:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, Qfalse);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ERRINFO:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
if (iseq->type == ISEQ_TYPE_RESCUE) {
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(2), INT2FIX(0));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_iseq_t *ip = iseq;
|
|
|
|
int level = 0;
|
|
|
|
while (ip) {
|
|
|
|
if (ip->type == ISEQ_TYPE_RESCUE) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ip = ip->parent_iseq;
|
|
|
|
level++;
|
|
|
|
}
|
|
|
|
if (ip) {
|
* vm.c, insns.def, eval.c, vm_insnhelper.c: fix CREF handling.
VM value stack frame of block contains cref information.
(dfp[-1] points CREF)
* compile.c, eval_intern.h, eval_method.c, load.c, proc.c,
vm_dump.h, vm_core.h: ditto.
* include/ruby/ruby.h, gc.c: remove T_VALUES because of above
changes.
* bootstraptest/test_eval.rb, test_knownbug.rb: move solved test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-19 07:08:50 +04:00
|
|
|
ADD_INSN2(ret, nd_line(node), getdynamic, INT2FIX(2), INT2FIX(level));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DEFINED:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
2008-03-25 09:26:32 +03:00
|
|
|
LABEL *lfinish[2];
|
|
|
|
lfinish[0] = NEW_LABEL(nd_line(node));
|
|
|
|
lfinish[1] = 0;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
defined_expr(iseq, ret, node->nd_head, lfinish, Qtrue);
|
2008-03-25 09:26:32 +03:00
|
|
|
if (lfinish[1]) {
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, lfinish[0]);
|
|
|
|
ADD_LABEL(ret, lfinish[1]);
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
}
|
|
|
|
ADD_LABEL(ret, lfinish[0]);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_POSTEXE:{
|
2008-07-20 17:50:14 +04:00
|
|
|
LABEL *lstart = NEW_LABEL(nd_line(node));
|
|
|
|
LABEL *lend = NEW_LABEL(nd_line(node));
|
2009-07-22 17:37:26 +04:00
|
|
|
VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(node));
|
2008-07-01 16:19:00 +04:00
|
|
|
|
2008-07-20 17:50:14 +04:00
|
|
|
ADD_LABEL(ret, lstart);
|
2009-07-13 08:44:20 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), onceinlinecache, lend);
|
2008-07-20 17:50:14 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
|
2008-07-01 16:19:00 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, nd_line(node), putiseq, block);
|
|
|
|
ADD_SEND (ret, nd_line(node), ID2SYM(id_core_set_postexe), INT2FIX(1));
|
|
|
|
|
2008-07-20 17:50:14 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
|
2008-07-01 16:19:00 +04:00
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DSYM:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
compile_dstr(iseq, ret, node);
|
|
|
|
if (!poped) {
|
|
|
|
ADD_SEND(ret, nd_line(node), ID2SYM(idIntern), INT2FIX(0));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ATTRASGN:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
DECL_ANCHOR(recv);
|
|
|
|
DECL_ANCHOR(args);
|
2007-06-27 21:13:13 +04:00
|
|
|
unsigned long flag = 0;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE argc;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(recv);
|
|
|
|
INIT_ANCHOR(args);
|
2007-06-25 22:23:35 +04:00
|
|
|
argc = setup_args(iseq, args, node->nd_args, &flag);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (node->nd_recv == (NODE *) 1) {
|
2007-08-18 09:07:07 +04:00
|
|
|
flag |= VM_CALL_FCALL_BIT;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(recv, nd_line(node), putself);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(recv, "recv", node->nd_recv);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
debugp_param("argc", argc);
|
|
|
|
debugp_param("nd_mid", ID2SYM(node->nd_mid));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), putnil);
|
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, args);
|
2007-07-03 22:58:42 +04:00
|
|
|
|
|
|
|
if (flag & VM_CALL_ARGS_BLOCKARG_BIT) {
|
|
|
|
ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
|
2009-09-05 09:34:56 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 3));
|
2007-07-03 22:58:42 +04:00
|
|
|
ADD_INSN (ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
else {
|
2009-09-05 09:34:56 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 1));
|
|
|
|
}
|
2007-07-03 22:58:42 +04:00
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
else {
|
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, args);
|
|
|
|
}
|
2007-06-27 21:13:13 +04:00
|
|
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(node->nd_mid), argc, 0, LONG2FIX(flag));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_OPTBLOCK:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/* for optimize */
|
|
|
|
LABEL *redo_label = NEW_LABEL(0);
|
|
|
|
LABEL *next_label = NEW_LABEL(0);
|
|
|
|
|
|
|
|
iseq->compile_data->start_label = next_label;
|
|
|
|
iseq->compile_data->redo_label = redo_label;
|
|
|
|
|
|
|
|
ADD_LABEL(ret, redo_label);
|
|
|
|
COMPILE_(ret, "optblock body", node->nd_head, 1 /* pop */ );
|
|
|
|
ADD_LABEL(ret, next_label);
|
|
|
|
ADD_INSN(ret, 0, opt_checkenv);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_PRELUDE:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
COMPILE_POPED(ret, "prelude", node->nd_head);
|
|
|
|
COMPILE_(ret, "body", node->nd_body, poped);
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-01-05 06:43:12 +03:00
|
|
|
case NODE_LAMBDA:{
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/* compile same as lambda{...} */
|
2009-07-22 17:37:26 +04:00
|
|
|
VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(node));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
VALUE argc = INT2FIX(0);
|
|
|
|
ADD_CALL_RECEIVER(ret, nd_line(node));
|
|
|
|
ADD_CALL_WITH_BLOCK(ret, nd_line(node), ID2SYM(idLambda), argc, block);
|
|
|
|
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, nd_line(node), pop);
|
|
|
|
}
|
|
|
|
break;
|
2007-01-05 06:43:12 +03:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
default:
|
2007-07-07 12:14:00 +04:00
|
|
|
rb_bug("iseq_compile_each: unknown node: %s", ruby_node_name(type));
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
return COMPILE_NG;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2007-06-26 22:56:15 +04:00
|
|
|
debug_node_end();
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************/
|
|
|
|
/* instruction information */
|
|
|
|
/***************************/
|
|
|
|
|
|
|
|
static int
|
|
|
|
insn_data_length(INSN *iobj)
|
|
|
|
{
|
|
|
|
return insn_len(iobj->insn_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
calc_sp_depth(int depth, INSN *insn)
|
|
|
|
{
|
|
|
|
return insn_stack_increase(depth, insn->insn_id, insn->operands);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
insn_data_line_no(INSN *iobj)
|
|
|
|
{
|
|
|
|
return insn_len(iobj->line_no);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
insn_data_to_s_detail(INSN *iobj)
|
|
|
|
{
|
|
|
|
VALUE str = rb_str_new(0, 0);
|
|
|
|
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
str = rb_sprintf("%-16s", insn_name(iobj->insn_id));
|
2006-12-31 18:02:22 +03:00
|
|
|
if (iobj->operands) {
|
2008-04-03 04:00:48 +04:00
|
|
|
const char *types = insn_op_types(iobj->insn_id);
|
2006-12-31 18:02:22 +03:00
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 0; types[j]; j++) {
|
|
|
|
char type = types[j];
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case TS_OFFSET: /* label(destination position) */
|
|
|
|
{
|
|
|
|
LABEL *lobj = (LABEL *)OPERAND_AT(iobj, j);
|
* compile.c (insn_data_to_s_detail), file.c (rb_stat_inspect),
iseq.c (ruby_iseq_disasm_insn, ruby_iseq_disasm),
process.c (pst_message), re.c (match_inspect): use rb_str_catf.
* dir.c (dir_inspect), iseq.c (iseq_inspect, insn_operand_intern): use
rb_sprintf.
* error.c (rb_name_error, rb_raise, rb_loaderror, rb_fatal): use
rb_vsprintf.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-22 12:53:34 +04:00
|
|
|
rb_str_catf(str, "<L%03d>", lobj->label_no);
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TS_ISEQ: /* iseq */
|
|
|
|
{
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
rb_iseq_t *iseq = (rb_iseq_t *)OPERAND_AT(iobj, j);
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE val = Qnil;
|
|
|
|
if (iseq) {
|
|
|
|
val = iseq->self;
|
|
|
|
}
|
|
|
|
rb_str_concat(str, rb_inspect(val));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TS_LINDEX:
|
|
|
|
case TS_DINDEX:
|
|
|
|
case TS_NUM: /* ulong */
|
|
|
|
case TS_VALUE: /* VALUE */
|
|
|
|
rb_str_concat(str, rb_inspect(OPERAND_AT(iobj, j)));
|
|
|
|
break;
|
|
|
|
case TS_ID: /* ID */
|
|
|
|
rb_str_concat(str, rb_inspect(OPERAND_AT(iobj, j)));
|
|
|
|
break;
|
|
|
|
case TS_GENTRY:
|
|
|
|
{
|
2009-07-16 04:01:06 +04:00
|
|
|
struct rb_global_entry *entry = (struct rb_global_entry *)
|
2006-12-31 18:02:22 +03:00
|
|
|
(OPERAND_AT(iobj, j) & (~1));
|
|
|
|
rb_str_cat2(str, rb_id2name(entry->id));
|
|
|
|
}
|
|
|
|
case TS_IC: /* method cache */
|
|
|
|
rb_str_cat2(str, "<ic>");
|
|
|
|
break;
|
|
|
|
case TS_CDHASH: /* case/when condition cache */
|
|
|
|
rb_str_cat2(str, "<ch>");
|
|
|
|
break;
|
|
|
|
default:{
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
rb_raise(rb_eSyntaxError, "unknown operand type: %c", type);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (types[j + 1]) {
|
|
|
|
rb_str_cat2(str, ", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dump_disasm_list(struct iseq_link_element *link)
|
|
|
|
{
|
|
|
|
int pos = 0;
|
|
|
|
INSN *iobj;
|
|
|
|
LABEL *lobj;
|
|
|
|
VALUE str;
|
|
|
|
|
|
|
|
printf("-- raw disasm--------\n");
|
|
|
|
|
|
|
|
while (link) {
|
|
|
|
switch (link->type) {
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_INSN:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
iobj = (INSN *)link;
|
|
|
|
str = insn_data_to_s_detail(iobj);
|
|
|
|
printf("%04d %-65s(%4d)\n", pos, StringValueCStr(str),
|
|
|
|
insn_data_line_no(iobj));
|
|
|
|
pos += insn_data_length(iobj);
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_LABEL:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
lobj = (LABEL *)link;
|
|
|
|
printf("<L%03d>\n", lobj->label_no);
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
case ISEQ_ELEMENT_NONE:
|
|
|
|
{
|
2006-12-31 18:02:22 +03:00
|
|
|
printf("[none]\n");
|
|
|
|
break;
|
|
|
|
}
|
2008-01-26 11:27:00 +03:00
|
|
|
case ISEQ_ELEMENT_ADJUST:
|
|
|
|
{
|
|
|
|
ADJUST *adjust = (ADJUST *)link;
|
|
|
|
printf("adjust: [label: %d]\n", adjust->label->label_no);
|
|
|
|
break;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
default:
|
2006-12-31 18:02:22 +03:00
|
|
|
/* ignore */
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
rb_raise(rb_eSyntaxError, "dump_disasm_list error: %ld\n", FIX2LONG(link->type));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
link = link->next;
|
|
|
|
}
|
|
|
|
printf("---------------------\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
2009-01-19 04:06:56 +03:00
|
|
|
rb_insns_name_array(void)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE ary = rb_ary_new();
|
|
|
|
int i;
|
2009-05-17 09:27:32 +04:00
|
|
|
for (i = 0; i < numberof(insn_name_info); i++) {
|
2008-12-05 06:35:48 +03:00
|
|
|
rb_ary_push(ary, rb_obj_freeze(rb_str_new2(insn_name_info[i])));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2008-12-05 06:35:48 +03:00
|
|
|
return rb_obj_freeze(ary);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static LABEL *
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
register_label(rb_iseq_t *iseq, struct st_table *labels_table, VALUE obj)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LABEL *label = 0;
|
2007-06-28 14:41:39 +04:00
|
|
|
st_data_t tmp;
|
2006-12-31 18:02:22 +03:00
|
|
|
obj = rb_convert_type(obj, T_SYMBOL, "Symbol", "to_sym");
|
|
|
|
|
2007-06-28 14:41:39 +04:00
|
|
|
if (st_lookup(labels_table, obj, &tmp) == 0) {
|
2006-12-31 18:02:22 +03:00
|
|
|
label = NEW_LABEL(0);
|
|
|
|
st_insert(labels_table, obj, (st_data_t)label);
|
|
|
|
}
|
2007-06-28 14:41:39 +04:00
|
|
|
else {
|
|
|
|
label = (LABEL *)tmp;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
get_exception_sym2type(VALUE sym)
|
|
|
|
{
|
2008-06-09 13:25:32 +04:00
|
|
|
#undef rb_intern
|
2008-08-16 04:20:31 +04:00
|
|
|
#define rb_intern(str) rb_intern_const(str)
|
2006-12-31 18:02:22 +03:00
|
|
|
static VALUE symRescue, symEnsure, symRetry;
|
|
|
|
static VALUE symBreak, symRedo, symNext;
|
|
|
|
|
|
|
|
if (symRescue == 0) {
|
|
|
|
symRescue = ID2SYM(rb_intern("rescue"));
|
|
|
|
symEnsure = ID2SYM(rb_intern("ensure"));
|
|
|
|
symRetry = ID2SYM(rb_intern("retry"));
|
|
|
|
symBreak = ID2SYM(rb_intern("break"));
|
|
|
|
symRedo = ID2SYM(rb_intern("redo"));
|
|
|
|
symNext = ID2SYM(rb_intern("next"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sym == symRescue) return CATCH_TYPE_RESCUE;
|
|
|
|
if (sym == symEnsure) return CATCH_TYPE_ENSURE;
|
|
|
|
if (sym == symRetry) return CATCH_TYPE_RETRY;
|
|
|
|
if (sym == symBreak) return CATCH_TYPE_BREAK;
|
|
|
|
if (sym == symRedo) return CATCH_TYPE_REDO;
|
|
|
|
if (sym == symNext) return CATCH_TYPE_NEXT;
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
rb_raise(rb_eSyntaxError, "invalid exception symbol: %s",
|
|
|
|
RSTRING_PTR(rb_inspect(sym)));
|
2006-12-31 18:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_build_exception(rb_iseq_t *iseq, struct st_table *labels_table,
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE exception)
|
|
|
|
{
|
|
|
|
int i;
|
2007-04-05 12:58:46 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
for (i=0; i<RARRAY_LEN(exception); i++) {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
VALUE v, type, *ptr, eiseqval;
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *lstart, *lend, *lcont;
|
|
|
|
int sp;
|
|
|
|
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
RB_GC_GUARD(v) = rb_convert_type(RARRAY_PTR(exception)[i], T_ARRAY,
|
|
|
|
"Array", "to_ary");
|
|
|
|
if (RARRAY_LEN(v) != 6) {
|
|
|
|
rb_raise(rb_eSyntaxError, "wrong exception entry");
|
|
|
|
}
|
|
|
|
ptr = RARRAY_PTR(v);
|
|
|
|
type = get_exception_sym2type(ptr[0]);
|
2006-12-31 18:02:22 +03:00
|
|
|
if (ptr[1] == Qnil) {
|
|
|
|
eiseqval = 0;
|
|
|
|
}
|
|
|
|
else {
|
* 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 22:05:15 +03:00
|
|
|
eiseqval = rb_iseq_load(ptr[1], iseq->self, Qnil);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
lstart = register_label(iseq, labels_table, ptr[2]);
|
|
|
|
lend = register_label(iseq, labels_table, ptr[3]);
|
|
|
|
lcont = register_label(iseq, labels_table, ptr[4]);
|
|
|
|
sp = NUM2INT(ptr[5]);
|
|
|
|
|
|
|
|
ADD_CATCH_ENTRY(type, lstart, lend, eiseqval, lcont);
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2009-01-19 04:06:56 +03:00
|
|
|
static struct st_table *
|
|
|
|
insn_make_insn_table(void)
|
|
|
|
{
|
|
|
|
struct st_table *table;
|
|
|
|
int i;
|
|
|
|
table = st_init_numtable();
|
|
|
|
|
|
|
|
for (i=0; i<VM_INSTRUCTION_SIZE; i++) {
|
|
|
|
st_insert(table, ID2SYM(rb_intern(insn_name(i))), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 22:00:03 +03:00
|
|
|
iseq_build_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
|
2007-07-02 01:43:30 +04:00
|
|
|
VALUE body, struct st_table *labels_table)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2009-11-03 20:46:28 +03:00
|
|
|
/* TODO: body should be frozen */
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE *ptr = RARRAY_PTR(body);
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
long i, len = RARRAY_LEN(body);
|
|
|
|
int j;
|
2006-12-31 18:02:22 +03:00
|
|
|
int line_no = 0;
|
|
|
|
/*
|
|
|
|
* index -> LABEL *label
|
|
|
|
*/
|
|
|
|
static struct st_table *insn_table;
|
|
|
|
|
|
|
|
if (insn_table == 0) {
|
2009-01-19 04:06:56 +03:00
|
|
|
insn_table = insn_make_insn_table();
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<len; i++) {
|
|
|
|
VALUE obj = ptr[i];
|
|
|
|
|
|
|
|
if (SYMBOL_P(obj)) {
|
|
|
|
LABEL *label = register_label(iseq, labels_table, obj);
|
|
|
|
ADD_LABEL(anchor, label);
|
|
|
|
}
|
|
|
|
else if (FIXNUM_P(obj)) {
|
|
|
|
line_no = NUM2INT(obj);
|
|
|
|
}
|
|
|
|
else if (TYPE(obj) == T_ARRAY) {
|
|
|
|
VALUE *argv = 0;
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
int argc = RARRAY_LENINT(obj) - 1;
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE insn_id;
|
2007-07-02 01:43:30 +04:00
|
|
|
VALUE insn;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
insn = (argc < 0) ? Qnil : RARRAY_PTR(obj)[0];
|
2007-07-02 01:43:30 +04:00
|
|
|
if (st_lookup(insn_table, insn, &insn_id) == 0) {
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 19:26:04 +03:00
|
|
|
/* TODO: exception */
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
RB_GC_GUARD(insn) = rb_inspect(insn);
|
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), line_no,
|
|
|
|
"unknown instruction: %s", RSTRING_PTR(insn));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (argc != insn_len(insn_id)-1) {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->filename), line_no,
|
|
|
|
"operand size mismatch");
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (argc > 0) {
|
|
|
|
argv = compile_data_alloc(iseq, sizeof(VALUE) * argc);
|
|
|
|
for (j=0; j<argc; j++) {
|
|
|
|
VALUE op = rb_ary_entry(obj, j+1);
|
|
|
|
switch (insn_op_type(insn_id, j)) {
|
|
|
|
case TS_OFFSET: {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
LABEL *label = register_label(iseq, labels_table, op);
|
|
|
|
argv[j] = (VALUE)label;
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case TS_LINDEX:
|
|
|
|
case TS_DINDEX:
|
|
|
|
case TS_NUM:
|
2008-08-23 11:01:57 +04:00
|
|
|
(void)NUM2INT(op);
|
|
|
|
argv[j] = op;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
case TS_VALUE:
|
|
|
|
argv[j] = op;
|
2007-07-01 22:16:02 +04:00
|
|
|
iseq_add_mark_object(iseq, op);
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
case TS_ISEQ:
|
|
|
|
{
|
|
|
|
if (op != Qnil) {
|
|
|
|
if (TYPE(op) == T_ARRAY) {
|
* 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 22:05:15 +03:00
|
|
|
argv[j] = rb_iseq_load(op, iseq->self, Qnil);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2007-01-17 11:48:52 +03:00
|
|
|
else if (CLASS_OF(op) == rb_cISeq) {
|
2006-12-31 18:02:22 +03:00
|
|
|
argv[j] = op;
|
|
|
|
}
|
|
|
|
else {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
rb_raise(rb_eSyntaxError, "ISEQ is required");
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
iseq_add_mark_object(iseq, argv[j]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
argv[j] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TS_GENTRY:
|
|
|
|
op = rb_convert_type(op, T_SYMBOL, "Symbol", "to_sym");
|
|
|
|
argv[j] = (VALUE)rb_global_entry(SYM2ID(op));
|
|
|
|
break;
|
|
|
|
case TS_IC:
|
|
|
|
break;
|
|
|
|
case TS_ID:
|
|
|
|
argv[j] = rb_convert_type(op, T_SYMBOL,
|
|
|
|
"Symbol", "to_sym");
|
|
|
|
break;
|
|
|
|
case TS_CDHASH:
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
op = rb_convert_type(op, T_ARRAY, "Array", "to_ary");
|
2008-05-25 12:52:57 +04:00
|
|
|
op = rb_ary_dup(op);
|
2006-12-31 18:02:22 +03:00
|
|
|
for (i=0; i<RARRAY_LEN(op); i+=2) {
|
|
|
|
VALUE sym = rb_ary_entry(op, i+1);
|
|
|
|
LABEL *label =
|
|
|
|
register_label(iseq, labels_table, sym);
|
|
|
|
rb_ary_store(op, i+1, (VALUE)label | 1);
|
|
|
|
}
|
|
|
|
argv[j] = op;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
rb_raise(rb_eSyntaxError, "unknown operand: %c", insn_op_type(insn_id, j));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ADD_ELEM(anchor,
|
|
|
|
(LINK_ELEMENT*)new_insn_core(iseq, line_no,
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
(enum ruby_vminsn_type)insn_id, argc, argv));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_raise(rb_eTypeError, "unexpected object for instruction");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
st_free_table(labels_table);
|
|
|
|
iseq_setup(iseq, anchor);
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2007-07-02 01:43:30 +04:00
|
|
|
#define CHECK_ARRAY(v) rb_convert_type(v, T_ARRAY, "Array", "to_ary")
|
|
|
|
#define CHECK_STRING(v) rb_convert_type(v, T_STRING, "String", "to_str")
|
|
|
|
#define CHECK_SYMBOL(v) rb_convert_type(v, T_SYMBOL, "Symbol", "to_sym")
|
2008-01-08 07:05:59 +03:00
|
|
|
static inline VALUE CHECK_INTEGER(VALUE v) {NUM2LONG(v); return v;}
|
2007-07-02 01:43:30 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
VALUE
|
2009-01-19 04:06:56 +03:00
|
|
|
rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE locals, VALUE args,
|
2008-12-05 06:35:48 +03:00
|
|
|
VALUE exception, VALUE body)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ID *tbl;
|
|
|
|
struct st_table *labels_table = st_init_numtable();
|
|
|
|
|
|
|
|
DECL_ANCHOR(anchor);
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(anchor);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
iseq->local_table_size = RARRAY_LENINT(locals);
|
2007-07-02 01:43:30 +04:00
|
|
|
iseq->local_table = tbl = (ID *)ALLOC_N(ID *, iseq->local_table_size);
|
2008-06-23 19:12:29 +04:00
|
|
|
iseq->local_size = iseq->local_table_size + 1;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
for (i=0; i<RARRAY_LEN(locals); i++) {
|
* include/ruby/{intern,ruby}.h, compile.[ch], error.c, eval.c,
eval_load.c, gc.c, iseq.c, main.c, parse.y, re.c, ruby.c,
yarvcore.[ch] (ruby_eval_tree, ruby_sourcefile, ruby_sourceline,
ruby_nerrs): purge global variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-05 12:12:18 +04:00
|
|
|
VALUE lv = RARRAY_PTR(locals)[i];
|
2009-05-17 09:27:32 +04:00
|
|
|
tbl[i] = FIXNUM_P(lv) ? (ID)FIX2LONG(lv) : SYM2ID(CHECK_SYMBOL(lv));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/* args */
|
|
|
|
if (FIXNUM_P(args)) {
|
2007-07-02 01:43:30 +04:00
|
|
|
iseq->arg_size = iseq->argc = FIX2INT(args);
|
2006-12-31 18:02:22 +03:00
|
|
|
iseq->arg_simple = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int i = 0;
|
2007-07-02 01:43:30 +04:00
|
|
|
VALUE argc = CHECK_INTEGER(rb_ary_entry(args, i++));
|
|
|
|
VALUE arg_opt_labels = CHECK_ARRAY(rb_ary_entry(args, i++));
|
|
|
|
VALUE arg_post_len = CHECK_INTEGER(rb_ary_entry(args, i++));
|
|
|
|
VALUE arg_post_start = CHECK_INTEGER(rb_ary_entry(args, i++));
|
|
|
|
VALUE arg_rest = CHECK_INTEGER(rb_ary_entry(args, i++));
|
|
|
|
VALUE arg_block = CHECK_INTEGER(rb_ary_entry(args, i++));
|
2008-01-08 07:05:59 +03:00
|
|
|
VALUE arg_simple = CHECK_INTEGER(rb_ary_entry(args, i++));
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
iseq->argc = FIX2INT(argc);
|
|
|
|
iseq->arg_rest = FIX2INT(arg_rest);
|
2007-07-02 01:43:30 +04:00
|
|
|
iseq->arg_post_len = FIX2INT(arg_post_len);
|
|
|
|
iseq->arg_post_start = FIX2INT(arg_post_start);
|
2006-12-31 18:02:22 +03:00
|
|
|
iseq->arg_block = FIX2INT(arg_block);
|
* compile.c, cont.c, gc.c, insns.def, iseq.c, iseq.h, process.c,
thread.c, vm.c, vm_core.h, vm_dump.c, vm_eval.c,
vm_insnhelper.c, vm_method.c, template/insns_info.inc.tmpl,
tool/instruction.rb: fixed types.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-22 00:58:26 +04:00
|
|
|
iseq->arg_opts = RARRAY_LENINT(arg_opt_labels);
|
2008-06-23 19:23:12 +04:00
|
|
|
iseq->arg_opt_table = (VALUE *)ALLOC_N(VALUE, iseq->arg_opts);
|
2007-06-05 08:49:54 +04:00
|
|
|
|
2007-07-02 01:43:30 +04:00
|
|
|
if (iseq->arg_block != -1) {
|
|
|
|
iseq->arg_size = iseq->arg_block + 1;
|
|
|
|
}
|
|
|
|
else if (iseq->arg_post_len) {
|
|
|
|
iseq->arg_size = iseq->arg_post_start + iseq->arg_post_len;
|
|
|
|
}
|
|
|
|
else if (iseq->arg_rest != -1) {
|
|
|
|
iseq->arg_size = iseq->arg_rest + 1;
|
|
|
|
}
|
|
|
|
else {
|
2008-06-23 19:23:12 +04:00
|
|
|
iseq->arg_size = iseq->argc + (iseq->arg_opts ? iseq->arg_opts - 1 : 0);
|
2007-07-02 01:43:30 +04:00
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
for (i=0; i<RARRAY_LEN(arg_opt_labels); i++) {
|
2007-07-01 22:16:02 +04:00
|
|
|
iseq->arg_opt_table[i] =
|
2006-12-31 18:02:22 +03:00
|
|
|
(VALUE)register_label(iseq, labels_table,
|
|
|
|
rb_ary_entry(arg_opt_labels, i));
|
|
|
|
}
|
2008-01-08 07:05:59 +03:00
|
|
|
|
|
|
|
iseq->arg_simple = NUM2INT(arg_simple);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* exception */
|
|
|
|
iseq_build_exception(iseq, labels_table, exception);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/* body */
|
2007-07-02 01:43:30 +04:00
|
|
|
iseq_build_body(iseq, anchor, body, labels_table);
|
2006-12-31 18:02:22 +03:00
|
|
|
return iseq->self;
|
|
|
|
}
|
* 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 11:49:45 +04:00
|
|
|
|
|
|
|
/* for parser */
|
|
|
|
|
|
|
|
int
|
|
|
|
rb_dvar_defined(ID id)
|
|
|
|
{
|
|
|
|
rb_thread_t *th = GET_THREAD();
|
|
|
|
rb_iseq_t *iseq;
|
|
|
|
if (th->base_block && (iseq = th->base_block->iseq)) {
|
|
|
|
while (iseq->type == ISEQ_TYPE_BLOCK ||
|
|
|
|
iseq->type == ISEQ_TYPE_RESCUE ||
|
|
|
|
iseq->type == ISEQ_TYPE_ENSURE ||
|
2008-12-27 08:58:23 +03:00
|
|
|
iseq->type == ISEQ_TYPE_EVAL ||
|
|
|
|
iseq->type == ISEQ_TYPE_MAIN
|
|
|
|
) {
|
* 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 11:49:45 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < iseq->local_table_size; i++) {
|
|
|
|
if (iseq->local_table[i] == id) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iseq = iseq->parent_iseq;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rb_local_defined(ID id)
|
|
|
|
{
|
|
|
|
rb_thread_t *th = GET_THREAD();
|
|
|
|
rb_iseq_t *iseq;
|
|
|
|
|
|
|
|
if (th->base_block && th->base_block->iseq) {
|
|
|
|
int i;
|
|
|
|
iseq = th->base_block->iseq->local_iseq;
|
|
|
|
|
|
|
|
for (i=0; i<iseq->local_table_size; i++) {
|
|
|
|
if (iseq->local_table[i] == id) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
rb_parse_in_eval(void)
|
|
|
|
{
|
2009-05-17 09:23:10 +04:00
|
|
|
return GET_THREAD()->parse_in_eval > 0;
|
* 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 11:49:45 +04:00
|
|
|
}
|
2009-01-15 19:14:43 +03:00
|
|
|
|
|
|
|
int
|
|
|
|
rb_parse_in_main(void)
|
|
|
|
{
|
|
|
|
return GET_THREAD()->parse_in_eval < 0;
|
|
|
|
}
|