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"
|
* internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.
* iseq.h: declare rb_iseq_t dependent internal functions here.
* vm_core.h: declare rb_thread_t dependent internal functions here.
* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
thread.c, time.c, transcode.c, variable.c, vm.c,
tool/compile_prelude.rb: don't declare internal functions declared
in above headers. include above headers if required.
Note that rb_thread_mark() was declared as
void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
void rb_thread_mark(void *ptr) in vm.c. Now it is declared as
the later in internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 02:43:38 +04:00
|
|
|
#include "internal.h"
|
2010-09-10 09:03:40 +04:00
|
|
|
#include <math.h>
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
#define USE_INSN_STACK_INCREASE 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-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 {
|
2010-10-31 04:42:54 +03:00
|
|
|
ISEQ_ELEMENT_NONE,
|
|
|
|
ISEQ_ELEMENT_LABEL,
|
|
|
|
ISEQ_ELEMENT_INSN,
|
2010-12-10 05:42:06 +03:00
|
|
|
ISEQ_ELEMENT_ADJUST
|
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;
|
2011-08-24 10:31:15 +04:00
|
|
|
unsigned 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
|
|
|
|
|
|
|
|
#if CPDEBUG
|
|
|
|
|
|
|
|
#define compile_debug_print_indent(level) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ruby_debug_print_indent((level), compile_debug, gl_node_level * 2)
|
* 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 debugp(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
2010-12-03 00:53:08 +03:00
|
|
|
ruby_debug_print_value(1, compile_debug, (header), (value)))
|
* 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 debugi(header, id) (void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
2010-12-03 00:53:08 +03:00
|
|
|
ruby_debug_print_id(1, compile_debug, (header), (id)))
|
* 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 debugp_param(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
2010-12-03 00:53:08 +03:00
|
|
|
ruby_debug_print_value(1, compile_debug, (header), (value)))
|
* 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 debugp_verbose(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(2) && \
|
2010-12-03 00:53:08 +03:00
|
|
|
ruby_debug_print_value(2, compile_debug, (header), (value)))
|
* 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 debugp_verbose_node(header, value) (void) \
|
|
|
|
(compile_debug_print_indent(10) && \
|
2010-12-03 00:53:08 +03:00
|
|
|
ruby_debug_print_value(10, compile_debug, (header), (value)))
|
* 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 debug_node_start(node) ((void) \
|
|
|
|
(compile_debug_print_indent(1) && \
|
2010-12-03 00:53:08 +03:00
|
|
|
(ruby_debug_print_node(1, CPDEBUG, "", (NODE *)(node)), gl_node_level)), \
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
gl_node_level++)
|
|
|
|
|
2012-11-21 16:42:11 +04:00
|
|
|
#define debug_node_end() gl_node_level --
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
|
|
|
#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
|
|
|
|
#define debugs if (compile_debug_print_indent(1)) ruby_debug_printf
|
2010-12-03 00:53:08 +03:00
|
|
|
#define debug_compile(msg, v) ((void)(compile_debug_print_indent(1) && fputs((msg), stderr)), (v))
|
* 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
|
|
|
#else
|
|
|
|
#define debugs if(0)printf
|
|
|
|
#define debug_compile(msg, v) (v)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* create new label */
|
2010-12-03 00:53:08 +03:00
|
|
|
#define NEW_LABEL(l) new_label_body(iseq, (l))
|
* 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
|
|
|
|
2012-06-04 06:49:37 +04:00
|
|
|
#define iseq_path(iseq) \
|
|
|
|
(((rb_iseq_t*)DATA_PTR(iseq))->location.path)
|
* 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
|
|
|
|
2012-06-04 06:49:37 +04:00
|
|
|
#define iseq_absolute_path(iseq) \
|
|
|
|
(((rb_iseq_t*)DATA_PTR(iseq))->location.absolute_path)
|
2010-03-16 20:40:00 +03:00
|
|
|
|
2009-07-22 17:37:26 +04:00
|
|
|
#define NEW_ISEQVAL(node, name, type, line_no) \
|
2013-11-27 03:30:25 +04:00
|
|
|
new_child_iseq(iseq, (node), rb_fstring(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) \
|
2013-11-27 03:30:25 +04:00
|
|
|
new_child_iseq(iseq, (node), rb_fstring(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) \
|
2010-12-03 00:53:08 +03:00
|
|
|
APPEND_LIST((seq1), (seq2))
|
* 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 an instruction */
|
|
|
|
#define ADD_INSN(seq, line, insn) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 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
|
|
|
|
|
|
|
/* add an instruction with some operands (1, 2, 3, 5) */
|
|
|
|
#define ADD_INSN1(seq, line, insn, op1) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
|
* 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
|
|
|
|
2012-08-08 12:12:24 +04:00
|
|
|
/* add an instruction with label operand (alias of ADD_INSN1) */
|
|
|
|
#define ADD_INSNL(seq, line, insn, label) ADD_INSN1(seq, line, insn, label)
|
|
|
|
|
* 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 ADD_INSN2(seq, line, insn, op1, op2) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, (line), BIN(insn), 2, (VALUE)(op1), (VALUE)(op2)))
|
* 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 ADD_INSN3(seq, line, insn, op1, op2, op3) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, (line), BIN(insn), 3, (VALUE)(op1), (VALUE)(op2), (VALUE)(op3)))
|
* 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
|
|
|
|
|
|
|
/* Specific Insn factory */
|
|
|
|
#define ADD_SEND(seq, line, id, argc) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_SEND_R((seq), (line), (id), (argc), (VALUE)Qfalse, (VALUE)INT2FIX(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
|
|
|
|
|
|
|
#define ADD_CALL_RECEIVER(seq, line) \
|
2012-02-26 06:26:49 +04:00
|
|
|
ADD_INSN((seq), (line), putself)
|
* 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 ADD_CALL(seq, line, id, argc) \
|
2012-10-15 21:22:57 +04:00
|
|
|
ADD_SEND_R((seq), (line), (id), (argc), (VALUE)Qfalse, (VALUE)INT2FIX(VM_CALL_FCALL))
|
* 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 ADD_CALL_WITH_BLOCK(seq, line, id, argc, block) \
|
2012-10-15 21:22:57 +04:00
|
|
|
ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(VM_CALL_FCALL))
|
* 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 ADD_SEND_R(seq, line, id, argc, block, flag) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) \
|
|
|
|
new_insn_send(iseq, (line), \
|
|
|
|
(VALUE)(id), (VALUE)(argc), (VALUE)(block), (VALUE)(flag)))
|
* 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 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) { \
|
2013-05-13 13:56:22 +04:00
|
|
|
RARRAY_ASET(iseq->coverage, (line) - 1, INT2FIX(0)); \
|
2009-10-08 20:11:30 +04:00
|
|
|
iseq->compile_data->last_coverable_line = (line); \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_INSN1((seq), (line), trace, INT2FIX(RUBY_EVENT_COVERAGE)); \
|
* 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
|
|
|
} \
|
|
|
|
if (iseq->compile_data->option->trace_instruction) { \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_INSN1((seq), (line), trace, INT2FIX(event)); \
|
* 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
|
|
|
} \
|
2012-12-29 16:21:58 +04:00
|
|
|
} 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
|
|
|
|
|
|
|
/* add label */
|
|
|
|
#define ADD_LABEL(seq, label) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) (label))
|
* 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
|
|
|
|
2012-02-11 07:04:23 +04:00
|
|
|
#define APPEND_LABEL(seq, before, label) \
|
|
|
|
APPEND_ELEM((seq), (before), (LINK_ELEMENT *) (label))
|
|
|
|
|
* 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 ADD_ADJUST(seq, line, label) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), (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
|
|
|
|
|
|
|
#define ADD_ADJUST_RESTORE(seq, label) \
|
2010-12-03 00:53:08 +03:00
|
|
|
ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), -1))
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
|
|
|
#define ADD_CATCH_ENTRY(type, ls, le, iseqv, lc) \
|
|
|
|
(rb_ary_push(iseq->compile_data->catch_table_ary, \
|
2010-12-03 00:53:08 +03:00
|
|
|
rb_ary_new3(5, (type), \
|
* 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
|
|
|
(VALUE)(ls) | 1, (VALUE)(le) | 1, \
|
2012-12-01 02:29:13 +04:00
|
|
|
(VALUE)(iseqv), (VALUE)(lc) | 1)))
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
|
|
|
/* compile node */
|
|
|
|
#define COMPILE(anchor, desc, node) \
|
|
|
|
(debug_compile("== " desc "\n", \
|
2010-12-03 00:53:08 +03:00
|
|
|
iseq_compile_each(iseq, (anchor), (node), 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-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", \
|
2010-12-03 00:53:08 +03:00
|
|
|
iseq_compile_each(iseq, (anchor), (node), 1)))
|
* include/ruby/node.h, vm_core.h: move definition of
RUBY_VM_METHOD_NODE to node.h.
* class.c, common.mk: remove useless inclusion.
* compile.h, iseq.h, vm_core.h: rename compile.h to iseq.h.
move some definitions from vm_core.h to iseq.h.
* compile.c, iseq.c, vm.c: ditto.
* eval.c, compile.c: move some functions for parser
from eval.c to compile.c.
* eval_intern.h, vm_core.h: move va_init_list() macro to
vm_core.h.
* iseq.c (rb_iseq_new_top, rb_iseq_first_lineno): added.
* load.c, ruby.c: use rb_iseq_new_top() instead of
rb_iseq_new() with ISEQ_TYPE_TOP constant directly.
* proc.c: use rb_iseq_first_lineno() instead of accessing
iseq structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 11:49:45 +04:00
|
|
|
|
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", \
|
2010-12-03 00:53:08 +03:00
|
|
|
iseq_compile_each(iseq, (anchor), (node), (poped))))
|
* 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
|
|
|
|
2014-06-06 12:07:13 +04:00
|
|
|
#define COMPILE_RECV(anchor, desc, node) \
|
|
|
|
(private_recv_p(node) ? \
|
|
|
|
(ADD_INSN(anchor, nd_line(node), putself), VM_CALL_FCALL) : \
|
|
|
|
(COMPILE(anchor, desc, node->nd_recv), 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
|
|
|
#define OPERAND_AT(insn, idx) \
|
2010-12-03 00:53:08 +03:00
|
|
|
(((INSN*)(insn))->operands[(idx)])
|
* 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 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; \
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 12:07:47 +04:00
|
|
|
RB_OBJ_WRITE(iseq->self, &iseq->compile_data->err_info, GET_THREAD()->errinfo); \
|
* 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
|
|
|
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__)
|
|
|
|
|
* include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
This function reveal interal (hidden) object by rb_obj_hide().
Note that do not change class before and after hiding.
Only permitted example is:
klass = RBASIC_CLASS(obj);
rb_obj_hide(obj);
....
rb_obj_reveal(obj, klass);
TODO: API design. rb_obj_reveal() should be replaced with others.
TODO: modify constified variables using cast may be harmful for
compiler's analysis and optimizaton.
Any idea to prohibt inserting RBasic::klass directly?
If rename RBasic::klass and force to use RBASIC_CLASS(obj),
then all codes such as `RBASIC(obj)->klass' will be
compilation error. Is it acceptable? (We have similar
experience at Ruby 1.9,
for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 14:49:11 +04:00
|
|
|
#define hide_obj(obj) do {OBJ_FREEZE(obj); RBASIC_CLEAR_CLASS(obj);} 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 calc_sp_depth(int depth, INSN *iobj);
|
|
|
|
|
* 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
|
2010-12-03 00:53:08 +03:00
|
|
|
#define verify_list(info, anchor) verify_list(iseq, (info), (anchor))
|
2008-04-14 09:34:04 +04:00
|
|
|
#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);
|
|
|
|
}
|
2012-02-11 07:04:23 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* elem1, before, elem2 => elem1, before, elem, elem2
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
APPEND_ELEM(ISEQ_ARG_DECLARE LINK_ANCHOR *anchor, LINK_ELEMENT *before, LINK_ELEMENT *elem)
|
|
|
|
{
|
|
|
|
elem->prev = before;
|
|
|
|
elem->next = before->next;
|
|
|
|
elem->next->prev = elem;
|
|
|
|
before->next = elem;
|
|
|
|
if (before == anchor->last) anchor->last = elem;
|
|
|
|
verify_list("add", anchor);
|
|
|
|
}
|
2008-04-14 09:34:04 +04:00
|
|
|
#if CPDEBUG < 0
|
2010-12-03 00:53:08 +03:00
|
|
|
#define ADD_ELEM(anchor, elem) ADD_ELEM(iseq, (anchor), (elem))
|
2012-02-11 07:04:23 +04:00
|
|
|
#define APPEND_ELEM(anchor, before, elem) ADD_ELEM(iseq, (anchor), (before), (elem))
|
2008-04-14 09:34:04 +04:00
|
|
|
#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)) {
|
2013-04-17 15:20:23 +04:00
|
|
|
rb_iseq_add_mark_object(iseq, v);
|
2007-07-01 22:16:02 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2012-06-04 06:49:37 +04:00
|
|
|
#define ruby_sourcefile RSTRING_PTR(iseq->location.path)
|
* 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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-12-12 17:45:30 +03:00
|
|
|
static int
|
|
|
|
validate_label(st_data_t name, st_data_t label, st_data_t arg)
|
|
|
|
{
|
|
|
|
rb_iseq_t *iseq = (rb_iseq_t *)arg;
|
|
|
|
LABEL *lobj = (LABEL *)label;
|
|
|
|
if (!lobj->link.next) {
|
|
|
|
do {
|
|
|
|
int ret;
|
|
|
|
COMPILE_ERROR((ruby_sourcefile, lobj->position,
|
|
|
|
"%s: undefined label", rb_id2name((ID)name)));
|
* bignum.c (big_rshift), compile.c (validate_label,
iseq_build_from_ary_exception), cont.c (cont_capture), dir.c
(dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open)
(rb_io_advise), parse.y (parser_compile_string)
(rb_parser_compile_file), proc.c (binding_free), process.c
(rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core)
(p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null),
signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main),
vm_insnhelper.c (vm_expandarray): suppress
unused-but-set-variable warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 13:57:00 +04:00
|
|
|
if (ret) break;
|
2010-12-12 17:45:30 +03:00
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
return ST_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
validate_labels(rb_iseq_t *iseq, st_table *labels_table)
|
|
|
|
{
|
|
|
|
st_foreach(labels_table, validate_label, (st_data_t)iseq);
|
|
|
|
if (!NIL_P(iseq->compile_data->err_info)) {
|
|
|
|
rb_exc_raise(iseq->compile_data->err_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
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) {
|
2012-11-30 02:28:16 +04:00
|
|
|
case ISEQ_TYPE_BLOCK:
|
|
|
|
{
|
|
|
|
LABEL *start = iseq->compile_data->start_label = NEW_LABEL(0);
|
|
|
|
LABEL *end = iseq->compile_data->end_label = NEW_LABEL(0);
|
|
|
|
|
|
|
|
ADD_LABEL(ret, start);
|
|
|
|
ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_B_CALL);
|
|
|
|
COMPILE(ret, "block body", node->nd_body);
|
|
|
|
ADD_LABEL(ret, end);
|
2013-06-14 13:54:58 +04:00
|
|
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_B_RETURN);
|
2012-11-30 02:28:16 +04: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);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ISEQ_TYPE_CLASS:
|
|
|
|
{
|
|
|
|
ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_CLASS);
|
|
|
|
COMPILE(ret, "scoped node", node->nd_body);
|
|
|
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_END);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ISEQ_TYPE_METHOD:
|
|
|
|
{
|
|
|
|
ADD_TRACE(ret, FIX2INT(iseq->location.first_lineno), RUBY_EVENT_CALL);
|
|
|
|
COMPILE(ret, "scoped node", node->nd_body);
|
|
|
|
ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
|
|
|
|
break;
|
|
|
|
}
|
2007-07-10 11:52:03 +04:00
|
|
|
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
|
|
|
}
|
2013-08-22 10:50:42 +04:00
|
|
|
else if (nd_type(node) == NODE_IFUNC) {
|
|
|
|
/* user callback */
|
|
|
|
(*node->nd_cfnc)(iseq, ret, node->nd_tval);
|
|
|
|
}
|
* 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) {
|
2012-10-04 17:52:20 +04:00
|
|
|
ADD_INSN2(ret, 0, getlocal, 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
|
|
|
}
|
|
|
|
|
2010-12-12 17:45:30 +03:00
|
|
|
#if SUPPORT_JOKE
|
|
|
|
if (iseq->compile_data->labels_table) {
|
|
|
|
validate_labels(iseq, iseq->compile_data->labels_table);
|
|
|
|
}
|
|
|
|
#endif
|
* 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
|
|
|
const void * const *table = rb_vm_get_insns_address_table();
|
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
|
2010-12-03 00:53:08 +03:00
|
|
|
#define POP_ELEMENT(anchor) POP_ELEMENT(iseq, (anchor))
|
2008-04-14 09:34:04 +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 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
|
2010-12-03 00:53:08 +03:00
|
|
|
#define APPEND_LIST(anc1, anc2) APPEND_LIST(iseq, (anc1), (anc2))
|
2008-04-14 09:34:04 +04:00
|
|
|
#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
|
2010-12-03 00:53:08 +03:00
|
|
|
#define INSERT_LIST(anc1, anc2) INSERT_LIST(iseq, (anc1), (anc2))
|
2008-04-14 09:34:04 +04:00
|
|
|
#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
|
2010-12-03 00:53:08 +03:00
|
|
|
#define SWAP_LIST(anc1, anc2) SWAP_LIST(iseq, (anc1), (anc2))
|
2008-04-14 09:34:04 +04:00
|
|
|
#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
|
2010-12-03 00:53:08 +03:00
|
|
|
#define REVERSE_LIST(anc) REVERSE_LIST(iseq, (anc))
|
2008-04-14 09:34:04 +04:00
|
|
|
#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
|
2010-12-03 00:53:08 +03:00
|
|
|
#define debug_list(anc) debug_list(iseq, (anc))
|
2008-04-14 09:34:04 +04:00
|
|
|
#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);
|
2010-02-24 20:06:15 +03:00
|
|
|
/* printf("insn_id: %d, line: %d\n", insn_id, line_no); */
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
static rb_call_info_t *
|
|
|
|
new_callinfo(rb_iseq_t *iseq, ID mid, int argc, VALUE block, unsigned long flag)
|
|
|
|
{
|
|
|
|
rb_call_info_t *ci = (rb_call_info_t *)compile_data_alloc(iseq, sizeof(rb_call_info_t));
|
|
|
|
ci->mid = mid;
|
|
|
|
ci->flag = flag;
|
|
|
|
ci->orig_argc = argc;
|
2012-10-18 09:33:31 +04:00
|
|
|
ci->argc = argc;
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
|
|
|
if (block) {
|
|
|
|
GetISeqPtr(block, ci->blockiseq);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ci->blockiseq = 0;
|
2012-10-15 21:22:57 +04:00
|
|
|
if (!(ci->flag & (VM_CALL_ARGS_SPLAT | VM_CALL_ARGS_BLOCKARG))) {
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
ci->flag |= VM_CALL_ARGS_SKIP_SETUP;
|
|
|
|
}
|
|
|
|
}
|
2013-12-09 14:51:02 +04:00
|
|
|
ci->method_state = 0;
|
2013-11-09 07:34:49 +04:00
|
|
|
ci->class_serial = 0;
|
2012-10-18 12:35:19 +04:00
|
|
|
ci->blockptr = 0;
|
|
|
|
ci->recv = Qundef;
|
|
|
|
ci->call = 0; /* TODO: should set default function? */
|
|
|
|
|
2012-10-18 09:33:31 +04:00
|
|
|
ci->aux.index = iseq->callinfo_size++;
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
|
|
|
return ci;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static INSN *
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
new_insn_send(rb_iseq_t *iseq, int line_no, VALUE id, VALUE argc, VALUE block, VALUE flag)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
VALUE *operands = (VALUE *)compile_data_alloc(iseq, sizeof(VALUE) * 1);
|
|
|
|
operands[0] = (VALUE)new_callinfo(iseq, SYM2ID(id), FIX2INT(argc), block, FIX2INT(flag));
|
|
|
|
return new_insn_core(iseq, line_no, BIN(send), 1, operands);
|
2006-12-31 18:02:22 +03: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
|
|
|
new_child_iseq(rb_iseq_t *iseq, NODE *node,
|
2010-10-31 16:11:02 +03:00
|
|
|
VALUE name, VALUE parent, enum iseq_type type, int line_no)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
VALUE ret;
|
|
|
|
|
|
|
|
debugs("[new_child_iseq]> ---------------------------------------\n");
|
2012-06-04 06:49:37 +04:00
|
|
|
ret = rb_iseq_new_with_opt(node, name,
|
|
|
|
iseq_path(iseq->self), iseq_absolute_path(iseq->self),
|
|
|
|
INT2FIX(line_no), 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, "#$!");
|
2010-11-15 17:44:19 +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;
|
|
|
|
}
|
|
|
|
|
2012-10-04 17:52:20 +04:00
|
|
|
static int
|
|
|
|
get_lvar_level(rb_iseq_t *iseq)
|
|
|
|
{
|
|
|
|
int lev = 0;
|
|
|
|
while (iseq != iseq->local_iseq) {
|
|
|
|
lev++;
|
|
|
|
iseq = iseq->parent_iseq;
|
|
|
|
}
|
|
|
|
return lev;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
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) {
|
2011-12-26 18:19:58 +04:00
|
|
|
struct rb_args_info *args = node_args->nd_ainfo;
|
* 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 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;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-12-26 18:19:58 +04:00
|
|
|
|
|
|
|
iseq->argc = (int)args->pre_args_num;
|
* 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
|
|
|
|
2011-12-26 18:19:58 +04:00
|
|
|
rest_id = args->rest_arg;
|
|
|
|
if (rest_id == 1) {
|
|
|
|
last_comma = 1;
|
|
|
|
rest_id = 0;
|
|
|
|
}
|
|
|
|
block_id = args->block_arg;
|
|
|
|
|
|
|
|
if (args->first_post_arg) {
|
|
|
|
iseq->arg_post_start = get_dyna_var_idx_at_raw(iseq, args->first_post_arg);
|
|
|
|
iseq->arg_post_len = args->post_args_num;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2011-12-26 18:19:58 +04:00
|
|
|
if (args->opt_args) {
|
|
|
|
NODE *node = args->opt_args;
|
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);
|
* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
usecase of this macro is not acquire raw pointer, but acquire
read-only pointer. So we rename to better name.
RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
(I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 12:24:34 +04:00
|
|
|
MEMCPY(iseq->arg_opt_table, RARRAY_CONST_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;
|
|
|
|
}
|
|
|
|
|
2011-12-26 18:20:09 +04:00
|
|
|
if (args->kw_args) {
|
|
|
|
NODE *node = args->kw_args;
|
|
|
|
VALUE keywords = rb_ary_tmp_new(1);
|
2013-03-12 17:20:50 +04:00
|
|
|
VALUE required = 0;
|
|
|
|
int i = 0, j, r = 0;
|
2011-12-26 18:20:09 +04:00
|
|
|
|
|
|
|
iseq->arg_keyword = get_dyna_var_idx_at_raw(iseq, args->kw_rest_arg->nd_vid);
|
|
|
|
COMPILE(optargs, "kwarg", args->kw_rest_arg);
|
|
|
|
while (node) {
|
2013-03-12 17:20:50 +04:00
|
|
|
VALUE list = keywords;
|
|
|
|
if (node->nd_body->nd_value == (NODE *)-1) {
|
|
|
|
++r;
|
|
|
|
if (!required) required = rb_ary_tmp_new(1);
|
|
|
|
list = required;
|
|
|
|
}
|
|
|
|
rb_ary_push(list, INT2FIX(node->nd_body->nd_vid));
|
2011-12-26 18:20:09 +04:00
|
|
|
COMPILE_POPED(optargs, "kwarg", node); /* nd_type(node) == NODE_KW_ARG */
|
|
|
|
node = node->nd_next;
|
|
|
|
i += 1;
|
|
|
|
}
|
2013-12-25 18:02:18 +04:00
|
|
|
iseq->arg_keyword_check = args->kw_rest_arg->nd_cflag != 0;
|
2011-12-26 18:20:15 +04:00
|
|
|
iseq->arg_keywords = i;
|
2013-03-12 17:20:50 +04:00
|
|
|
iseq->arg_keyword_required = r;
|
2011-12-26 18:20:15 +04:00
|
|
|
iseq->arg_keyword_table = ALLOC_N(ID, i);
|
2013-03-12 17:20:50 +04:00
|
|
|
if (r) {
|
|
|
|
rb_ary_concat(required, keywords);
|
|
|
|
keywords = required;
|
|
|
|
}
|
2011-12-26 18:20:15 +04:00
|
|
|
for (j = 0; j < i; j++) {
|
2013-05-13 13:56:22 +04:00
|
|
|
iseq->arg_keyword_table[j] = FIX2INT(RARRAY_AREF(keywords, j));
|
2011-12-26 18:20:09 +04:00
|
|
|
}
|
|
|
|
ADD_INSN(optargs, nd_line(args->kw_args), pop);
|
|
|
|
}
|
2012-03-13 17:00:17 +04:00
|
|
|
else if (args->kw_rest_arg) {
|
|
|
|
iseq->arg_keyword = get_dyna_var_idx_at_raw(iseq, args->kw_rest_arg->nd_vid);
|
|
|
|
COMPILE(optargs, "kwarg", args->kw_rest_arg);
|
|
|
|
ADD_INSN(optargs, nd_line(args->kw_rest_arg), pop);
|
|
|
|
}
|
2011-12-26 18:20:09 +04:00
|
|
|
else {
|
|
|
|
iseq->arg_keyword = -1;
|
|
|
|
}
|
|
|
|
|
2011-12-26 18:19:58 +04:00
|
|
|
if (args->pre_init) { /* m_init */
|
|
|
|
COMPILE_POPED(optargs, "init arguments (m)", args->pre_init);
|
|
|
|
}
|
|
|
|
if (args->post_init) { /* p_init */
|
|
|
|
COMPILE_POPED(optargs, "init arguments (p)", args->post_init);
|
2007-05-17 08:25:18 +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 (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 ||
|
2011-12-26 18:20:09 +04:00
|
|
|
iseq->arg_rest != -1 || iseq->arg_block != -1 ||
|
|
|
|
iseq->arg_keyword != -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 */
|
2011-12-26 18:20:09 +04:00
|
|
|
if (iseq->arg_keyword != -1) {
|
|
|
|
iseq->arg_size = iseq->arg_keyword + 1;
|
|
|
|
}
|
|
|
|
else if (iseq->arg_block != -1) {
|
2007-06-24 11:29:21 +04:00
|
|
|
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) {
|
2013-06-01 12:25:05 +04:00
|
|
|
if (iseq->arg_opts == 0 && iseq->arg_post_len == 0 &&
|
|
|
|
iseq->arg_rest == -1 && iseq->arg_keyword == -1) {
|
2007-08-16 20:29:11 +04:00
|
|
|
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) {
|
2010-11-15 17:44:19 +03:00
|
|
|
iseq->local_table = (ID *)ALLOC_N(ID, size);
|
|
|
|
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;
|
2011-09-29 15:07:45 +04:00
|
|
|
if (RB_TYPE_P(a, T_STRING)) return rb_str_hash(a);
|
2009-02-27 12:30:53 +03:00
|
|
|
{
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2012-04-24 13:20:42 +04:00
|
|
|
struct cdhash_set_label_struct {
|
|
|
|
VALUE hash;
|
|
|
|
int pos;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
cdhash_set_label_i(VALUE key, VALUE val, void *ptr)
|
|
|
|
{
|
|
|
|
struct cdhash_set_label_struct *data = (struct cdhash_set_label_struct *)ptr;
|
|
|
|
LABEL *lobj = (LABEL *)(val & ~1);
|
|
|
|
rb_hash_aset(data->hash, key, INT2FIX(lobj->position - (data->pos+data->len)));
|
|
|
|
return ST_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/**
|
2010-10-31 04:42:54 +03:00
|
|
|
ruby insn object list -> raw instruction sequence
|
2006-12-31 18:02:22 +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_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
LABEL *lobj;
|
|
|
|
INSN *iobj;
|
2011-08-24 10:31:15 +04:00
|
|
|
struct iseq_line_info_entry *line_info_table;
|
|
|
|
unsigned int last_line = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
LINK_ELEMENT *list;
|
|
|
|
VALUE *generated_iseq;
|
|
|
|
|
* 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);
|
|
|
|
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);
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), line,
|
2007-07-20 11:30:33 +04:00
|
|
|
"error: set_sequence");
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make instruction sequence */
|
|
|
|
generated_iseq = ALLOC_N(VALUE, pos);
|
2011-08-24 10:31:15 +04:00
|
|
|
line_info_table = ALLOC_N(struct iseq_line_info_entry, k);
|
2013-08-20 21:41:13 +04:00
|
|
|
iseq->is_entries = ALLOC_N(union iseq_inline_storage_entry, iseq->is_size);
|
|
|
|
MEMZERO(iseq->is_entries, union iseq_inline_storage_entry, iseq->is_size);
|
2012-10-09 09:33:54 +04:00
|
|
|
iseq->callinfo_entries = ALLOC_N(rb_call_info_t, iseq->callinfo_size);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
/* MEMZERO(iseq->callinfo_entries, rb_call_info_t, iseq->callinfo_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:
|
|
|
|
{
|
2010-02-24 20:06:15 +03:00
|
|
|
int j, len, insn;
|
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 08:44:20 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/* operand check */
|
2010-02-24 20:06:15 +03:00
|
|
|
if (iobj->operand_size != len - 1) {
|
|
|
|
/* printf("operand size miss! (%d, %d)\n", iobj->operand_size, len); */
|
2006-12-31 18:02:22 +03:00
|
|
|
dump_disasm_list(list);
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
|
2007-07-20 11:30:33 +04:00
|
|
|
"operand size miss! (%d for %d)",
|
2010-02-24 20:06:15 +03:00
|
|
|
iobj->operand_size, len - 1);
|
2008-10-16 18:38:08 +04:00
|
|
|
xfree(generated_iseq);
|
2011-08-24 10:31:15 +04:00
|
|
|
xfree(line_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) {
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
|
2007-07-20 11:30:33 +04:00
|
|
|
"unknown label");
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
if (lobj->sp == -1) {
|
|
|
|
lobj->sp = sp;
|
|
|
|
}
|
2012-04-24 13:20:42 +04:00
|
|
|
generated_iseq[pos + 1 + j] = lobj->position - (pos + len);
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_CDHASH:
|
|
|
|
{
|
2012-04-24 13:20:42 +04:00
|
|
|
VALUE map = operands[j];
|
2012-06-11 06:57:02 +04:00
|
|
|
struct cdhash_set_label_struct data;
|
|
|
|
data.hash = map;
|
|
|
|
data.pos = pos;
|
|
|
|
data.len = len;
|
2012-04-24 13:20:42 +04:00
|
|
|
rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data);
|
|
|
|
|
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;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 08:49:54 +04:00
|
|
|
case TS_LINDEX:
|
|
|
|
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
|
|
|
{
|
2010-02-24 20:06:15 +03:00
|
|
|
int ic_index = FIX2INT(operands[j]);
|
2013-08-20 21:41:13 +04:00
|
|
|
IC ic = (IC)&iseq->is_entries[ic_index];
|
|
|
|
if (UNLIKELY(ic_index >= iseq->is_size)) {
|
|
|
|
rb_bug("iseq_set_sequence: ic_index overflow: index: %d, size: %d", ic_index, iseq->is_size);
|
2009-07-13 13:30:23 +04:00
|
|
|
}
|
|
|
|
generated_iseq[pos + 1 + j] = (VALUE)ic;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
}
|
2012-10-09 09:33:54 +04:00
|
|
|
case TS_CALLINFO: /* call info */
|
|
|
|
{
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
rb_call_info_t *base_ci = (rb_call_info_t *)operands[j];
|
2012-10-18 09:33:31 +04:00
|
|
|
rb_call_info_t *ci = &iseq->callinfo_entries[base_ci->aux.index];
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
*ci = *base_ci;
|
|
|
|
|
2012-10-18 09:33:31 +04:00
|
|
|
if (UNLIKELY(base_ci->aux.index >= iseq->callinfo_size)) {
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
rb_bug("iseq_set_sequence: ci_index overflow: index: %d, size: %d", base_ci->argc, iseq->callinfo_size);
|
2012-10-09 09:33:54 +04:00
|
|
|
}
|
|
|
|
generated_iseq[pos + 1 + j] = (VALUE)ci;
|
|
|
|
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:
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
|
2007-07-20 11:30:33 +04:00
|
|
|
"unknown operand type: %c", type);
|
2008-10-16 18:38:08 +04:00
|
|
|
xfree(generated_iseq);
|
2011-08-24 10:31:15 +04:00
|
|
|
xfree(line_info_table);
|
2006-12-31 18:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2011-08-24 10:31:15 +04:00
|
|
|
if (last_line != iobj->line_no) {
|
|
|
|
line_info_table[k].line_no = last_line = iobj->line_no;
|
|
|
|
line_info_table[k].position = pos;
|
2012-01-14 17:16:29 +04:00
|
|
|
k++;
|
2011-08-24 10:31:15 +04:00
|
|
|
}
|
|
|
|
pos += len;
|
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;
|
|
|
|
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) {
|
2011-08-24 10:31:15 +04:00
|
|
|
if (last_line != (unsigned int)adjust->line_no) {
|
|
|
|
line_info_table[k].line_no = last_line = adjust->line_no;
|
|
|
|
line_info_table[k].position = pos;
|
2012-01-14 17:16:29 +04:00
|
|
|
k++;
|
2011-08-24 10:31:15 +04:00
|
|
|
}
|
2008-01-26 11:27:00 +03:00
|
|
|
generated_iseq[pos++] = BIN(adjuststack);
|
|
|
|
generated_iseq[pos++] = orig_sp - sp;
|
|
|
|
}
|
|
|
|
else if (orig_sp - sp == 0) {
|
|
|
|
/* jump to next insn */
|
2011-08-24 10:31:15 +04:00
|
|
|
if (last_line != (unsigned int)adjust->line_no) {
|
|
|
|
line_info_table[k].line_no = last_line = adjust->line_no;
|
|
|
|
line_info_table[k].position = pos;
|
2012-01-14 17:16:29 +04:00
|
|
|
k++;
|
2011-08-24 10:31:15 +04:00
|
|
|
}
|
2008-01-26 11:27:00 +03:00
|
|
|
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->stack_max = stack_max;
|
|
|
|
|
2011-08-24 10:31:15 +04:00
|
|
|
line_info_table = ruby_xrealloc(line_info_table, k * sizeof(struct iseq_line_info_entry));
|
|
|
|
iseq->line_info_table = line_info_table;
|
|
|
|
iseq->line_info_size = k;
|
|
|
|
|
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
|
|
|
{
|
2013-07-24 15:59:44 +04:00
|
|
|
const VALUE *tptr, *ptr;
|
2006-12-31 18:02:22 +03:00
|
|
|
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);
|
* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
usecase of this macro is not acquire raw pointer, but acquire
read-only pointer. So we rename to better name.
RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
(I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 12:24:34 +04:00
|
|
|
tptr = RARRAY_CONST_PTR(iseq->compile_data->catch_table_ary);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
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++) {
|
* include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
usecase of this macro is not acquire raw pointer, but acquire
read-only pointer. So we rename to better name.
RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
(I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 12:24:34 +04:00
|
|
|
ptr = RARRAY_CONST_PTR(tptr[i]);
|
2006-12-31 18:02:22 +03:00
|
|
|
entry = &iseq->catch_table[i];
|
2010-10-31 16:11:02 +03:00
|
|
|
entry->type = (enum catch_type)(ptr[0] & 0xffff);
|
2006-12-31 18:02:22 +03:00
|
|
|
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
|
|
|
|
* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
proc.c, process.c, re.c, string.c, variable.c, vm.c,
vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
vm_method.c: catch up this change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 12:07:47 +04:00
|
|
|
RB_OBJ_WRITE(iseq->self, &iseq->compile_data->catch_table_ary, 0); /* free */
|
2006-12-31 18:02:22 +03:00
|
|
|
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
|
|
|
|
* =>
|
2012-10-15 21:22:57 +04:00
|
|
|
* send ..., ... | VM_CALL_TAILCALL, ...
|
2007-05-21 08:46:51 +04:00
|
|
|
* leave # unreachable
|
|
|
|
*/
|
2006-12-31 18:02:22 +03:00
|
|
|
INSN *piobj = (INSN *)get_prev_insn((INSN *)list);
|
2013-11-17 18:34:30 +04:00
|
|
|
enum ruby_vminsn_type previ = piobj->insn_id;
|
2007-05-21 08:46:51 +04:00
|
|
|
|
2013-11-17 18:34:30 +04:00
|
|
|
if (previ == BIN(send) || previ == BIN(opt_send_simple) || previ == BIN(invokesuper)) {
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
rb_call_info_t *ci = (rb_call_info_t *)piobj->operands[0];
|
|
|
|
if (ci->blockiseq == 0) {
|
2012-10-15 21:22:57 +04:00
|
|
|
ci->flag |= VM_CALL_TAILCALL;
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-02-24 20:06:15 +03:00
|
|
|
insn_set_specialized_instruction(rb_iseq_t *iseq, INSN *iobj, int insn_id)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
int old_opsize = iobj->operand_size;
|
2006-12-31 18:02:22 +03:00
|
|
|
iobj->insn_id = insn_id;
|
2010-02-24 20:06:15 +03:00
|
|
|
iobj->operand_size = insn_len(insn_id) - 1;
|
|
|
|
|
|
|
|
if (iobj->operand_size > old_opsize) {
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
VALUE *old_operands = iobj->operands;
|
|
|
|
if (insn_id != BIN(opt_neq)) {
|
|
|
|
rb_bug("insn_set_specialized_instruction: unknown insn: %d", insn_id);
|
|
|
|
}
|
|
|
|
iobj->operands = (VALUE *)compile_data_alloc(iseq, iobj->operand_size * sizeof(VALUE));
|
|
|
|
iobj->operands[0] = old_operands[0];
|
|
|
|
iobj->operands[1] = (VALUE)new_callinfo(iseq, idEq, 1, 0, 0);
|
2010-02-24 20:06:15 +03: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
|
|
|
iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
if (iobj->insn_id == BIN(send)) {
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
rb_call_info_t *ci = (rb_call_info_t *)OPERAND_AT(iobj, 0);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2012-03-19 10:20:55 +04:00
|
|
|
#define SP_INSN(opt) insn_set_specialized_instruction(iseq, iobj, BIN(opt_##opt))
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
if (ci->blockiseq == 0 && (ci->flag & ~VM_CALL_ARGS_SKIP_SETUP) == 0) {
|
|
|
|
switch (ci->orig_argc) {
|
2012-03-19 10:20:55 +04:00
|
|
|
case 0:
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
switch (ci->mid) {
|
2012-10-18 12:35:19 +04:00
|
|
|
case idLength: SP_INSN(length); return COMPILE_OK;
|
|
|
|
case idSize: SP_INSN(size); return COMPILE_OK;
|
|
|
|
case idEmptyP: SP_INSN(empty_p);return COMPILE_OK;
|
|
|
|
case idSucc: SP_INSN(succ); return COMPILE_OK;
|
|
|
|
case idNot: SP_INSN(not); return COMPILE_OK;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2012-03-19 10:20:55 +04:00
|
|
|
break;
|
|
|
|
case 1:
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
switch (ci->mid) {
|
2012-10-18 12:35:19 +04:00
|
|
|
case idPLUS: SP_INSN(plus); return COMPILE_OK;
|
|
|
|
case idMINUS: SP_INSN(minus); return COMPILE_OK;
|
|
|
|
case idMULT: SP_INSN(mult); return COMPILE_OK;
|
|
|
|
case idDIV: SP_INSN(div); return COMPILE_OK;
|
|
|
|
case idMOD: SP_INSN(mod); return COMPILE_OK;
|
|
|
|
case idEq: SP_INSN(eq); return COMPILE_OK;
|
|
|
|
case idNeq: SP_INSN(neq); return COMPILE_OK;
|
|
|
|
case idLT: SP_INSN(lt); return COMPILE_OK;
|
|
|
|
case idLE: SP_INSN(le); return COMPILE_OK;
|
|
|
|
case idGT: SP_INSN(gt); return COMPILE_OK;
|
|
|
|
case idGE: SP_INSN(ge); return COMPILE_OK;
|
|
|
|
case idLTLT: SP_INSN(ltlt); return COMPILE_OK;
|
|
|
|
case idAREF: SP_INSN(aref); return COMPILE_OK;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2012-03-19 10:20:55 +04:00
|
|
|
break;
|
2013-12-11 10:38:42 +04:00
|
|
|
case 2:
|
|
|
|
switch (ci->mid) {
|
|
|
|
case idASET: SP_INSN(aset); return COMPILE_OK;
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2012-12-03 15:33:09 +04:00
|
|
|
}
|
|
|
|
if (ci->flag & VM_CALL_ARGS_SKIP_SETUP) {
|
2012-10-18 12:35:19 +04:00
|
|
|
iobj->insn_id = BIN(opt_send_simple);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
2012-03-19 10:20:55 +04:00
|
|
|
#undef SP_INSN
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
|
|
|
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
|
|
|
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;
|
2010-01-20 10:12:16 +03:00
|
|
|
int id, k;
|
|
|
|
intptr_t j;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
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];
|
2010-01-20 10:12:16 +03:00
|
|
|
for (j = 1; j < (intptr_t)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)]
|
2010-12-03 00:53:08 +03:00
|
|
|
#define SC_NEXT(insn) sc_insn_next[(insn)]
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
#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);
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), 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:
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), iobj->line_no,
|
2007-07-20 11:30:33 +04:00
|
|
|
"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
|
2012-10-17 03:38:58 +04: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)) {
|
|
|
|
cnt++;
|
2013-11-27 03:30:25 +04:00
|
|
|
if (RB_TYPE_P(lit, T_STRING))
|
|
|
|
lit = node->nd_lit = rb_fstring(node->nd_lit);
|
2009-07-20 14:01:05 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, lit);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
while (list) {
|
2012-10-17 03:38:58 +04:00
|
|
|
node = list->nd_head;
|
|
|
|
if (nd_type(node) == NODE_STR) {
|
2013-11-27 03:30:25 +04:00
|
|
|
node->nd_lit = rb_fstring(node->nd_lit);
|
2012-10-17 03:38:58 +04:00
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(ret, "each string", node);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-04-12 05:33:34 +04:00
|
|
|
enum compile_array_type_t {
|
|
|
|
COMPILE_ARRAY_TYPE_ARRAY,
|
|
|
|
COMPILE_ARRAY_TYPE_HASH,
|
2012-06-11 06:57:02 +04:00
|
|
|
COMPILE_ARRAY_TYPE_ARGS
|
2012-04-12 05:33:34 +04:00
|
|
|
};
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
2007-07-03 23:35:09 +04:00
|
|
|
compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
|
2012-04-12 05:33:34 +04:00
|
|
|
enum compile_array_type_t type, int poped)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
NODE *node = node_root;
|
2012-04-12 05:33:34 +04:00
|
|
|
int line = (int)nd_line(node);
|
|
|
|
int len = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2012-04-12 05:33:34 +04:00
|
|
|
if (nd_type(node) == NODE_ZARRAY) {
|
|
|
|
if (!poped) {
|
|
|
|
switch (type) {
|
|
|
|
case COMPILE_ARRAY_TYPE_ARRAY: ADD_INSN1(ret, line, newarray, INT2FIX(0)); break;
|
|
|
|
case COMPILE_ARRAY_TYPE_HASH: ADD_INSN1(ret, line, newhash, INT2FIX(0)); break;
|
|
|
|
case COMPILE_ARRAY_TYPE_ARGS: /* do nothing */ break;
|
2007-07-03 23:11:49 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
}
|
2012-04-12 05:33:34 +04:00
|
|
|
else {
|
|
|
|
int opt_p = 1;
|
|
|
|
int first = 1, i;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2012-04-12 05:33:34 +04:00
|
|
|
while (node) {
|
|
|
|
NODE *start_node = node, *end_node;
|
2012-04-29 01:12:05 +04:00
|
|
|
NODE *kw = 0;
|
2012-04-12 05:33:34 +04:00
|
|
|
const int max = 0x100;
|
|
|
|
DECL_ANCHOR(anchor);
|
|
|
|
INIT_ANCHOR(anchor);
|
|
|
|
|
2012-04-29 01:12:05 +04:00
|
|
|
for (i=0; i<max && node; i++, len++, node = node->nd_next) {
|
2012-04-12 05:33:34 +04:00
|
|
|
if (CPDEBUG > 0 && nd_type(node) != NODE_ARRAY) {
|
|
|
|
rb_bug("compile_array: This node is not NODE_ARRAY, but %s", ruby_node_name(nd_type(node)));
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2012-04-29 01:12:05 +04:00
|
|
|
if (type == COMPILE_ARRAY_TYPE_HASH && !node->nd_head) {
|
|
|
|
opt_p = 0;
|
|
|
|
kw = node->nd_next;
|
|
|
|
node = kw->nd_next;
|
|
|
|
kw = kw->nd_head;
|
|
|
|
break;
|
|
|
|
}
|
2012-04-12 05:33:34 +04:00
|
|
|
if (opt_p && nd_type(node->nd_head) != NODE_LIT) {
|
|
|
|
opt_p = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
COMPILE_(anchor, "array element", node->nd_head, poped);
|
2007-07-03 23:35:09 +04:00
|
|
|
}
|
2012-04-12 05:33:34 +04:00
|
|
|
|
|
|
|
if (opt_p && type != COMPILE_ARRAY_TYPE_ARGS) {
|
|
|
|
if (!poped) {
|
|
|
|
VALUE ary = rb_ary_tmp_new(i);
|
|
|
|
|
|
|
|
end_node = node;
|
|
|
|
node = start_node;
|
|
|
|
|
|
|
|
while (node != end_node) {
|
|
|
|
rb_ary_push(ary, node->nd_head->nd_lit);
|
|
|
|
node = node->nd_next;
|
|
|
|
}
|
2012-11-29 21:35:29 +04:00
|
|
|
while (node && nd_type(node->nd_head) == NODE_LIT &&
|
|
|
|
node->nd_next && nd_type(node->nd_next->nd_head) == NODE_LIT) {
|
|
|
|
rb_ary_push(ary, node->nd_head->nd_lit);
|
|
|
|
node = node->nd_next;
|
2012-04-12 05:33:34 +04:00
|
|
|
rb_ary_push(ary, node->nd_head->nd_lit);
|
|
|
|
node = node->nd_next;
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
OBJ_FREEZE(ary);
|
|
|
|
|
|
|
|
iseq_add_mark_object_compile_time(iseq, ary);
|
|
|
|
|
|
|
|
if (first) {
|
|
|
|
first = 0;
|
|
|
|
if (type == COMPILE_ARRAY_TYPE_ARRAY) {
|
|
|
|
ADD_INSN1(ret, line, duparray, ary);
|
|
|
|
}
|
|
|
|
else { /* COMPILE_ARRAY_TYPE_HASH */
|
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, line, putobject, ary);
|
|
|
|
ADD_SEND(ret, line, ID2SYM(id_core_hash_from_ary), INT2FIX(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (type == COMPILE_ARRAY_TYPE_ARRAY) {
|
|
|
|
ADD_INSN1(ret, line, putobject, ary);
|
|
|
|
ADD_INSN(ret, line, concatarray);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, line, putobject, ary);
|
|
|
|
ADD_SEND(ret, line, ID2SYM(id_core_hash_merge_ary), INT2FIX(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!poped) {
|
|
|
|
switch (type) {
|
|
|
|
case COMPILE_ARRAY_TYPE_ARRAY:
|
|
|
|
ADD_INSN1(anchor, line, newarray, INT2FIX(i));
|
|
|
|
|
|
|
|
if (first) {
|
|
|
|
first = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN(anchor, line, concatarray);
|
|
|
|
}
|
2013-01-09 22:38:41 +04:00
|
|
|
|
2012-04-12 05:33:34 +04:00
|
|
|
APPEND_LIST(ret, anchor);
|
|
|
|
break;
|
|
|
|
case COMPILE_ARRAY_TYPE_HASH:
|
2013-10-13 07:16:54 +04:00
|
|
|
if (i > 0) {
|
|
|
|
if (first) {
|
|
|
|
ADD_INSN1(anchor, line, newhash, INT2FIX(i));
|
|
|
|
APPEND_LIST(ret, anchor);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
APPEND_LIST(ret, anchor);
|
|
|
|
ADD_SEND(ret, line, ID2SYM(id_core_hash_merge_ptr), INT2FIX(i + 1));
|
|
|
|
}
|
2012-04-12 05:33:34 +04:00
|
|
|
}
|
2012-04-29 01:12:05 +04:00
|
|
|
if (kw) {
|
2013-10-13 07:16:54 +04:00
|
|
|
VALUE nhash = (i > 0 || !first) ? INT2FIX(2) : INT2FIX(1);
|
2012-04-29 01:12:05 +04:00
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
2013-10-13 07:16:54 +04:00
|
|
|
if (i > 0 || !first) ADD_INSN(ret, line, swap);
|
2012-04-29 01:12:05 +04:00
|
|
|
COMPILE(ret, "keyword splat", kw);
|
2013-10-13 07:16:54 +04:00
|
|
|
ADD_SEND(ret, line, ID2SYM(id_core_hash_merge_kwd), nhash);
|
2014-04-26 05:55:34 +04:00
|
|
|
if (nhash == INT2FIX(1)) ADD_SEND(ret, line, ID2SYM(rb_intern("dup")), INT2FIX(0));
|
2012-04-29 01:12:05 +04:00
|
|
|
}
|
2013-10-13 07:16:54 +04:00
|
|
|
first = 0;
|
2012-04-12 05:33:34 +04:00
|
|
|
break;
|
|
|
|
case COMPILE_ARRAY_TYPE_ARGS:
|
|
|
|
APPEND_LIST(ret, anchor);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-09 22:38:41 +04:00
|
|
|
else {
|
|
|
|
/* poped */
|
|
|
|
APPEND_LIST(ret, anchor);
|
|
|
|
}
|
2012-04-12 05:33:34 +04:00
|
|
|
}
|
2007-07-03 23:35:09 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2007-07-03 23:35:09 +04:00
|
|
|
static VALUE
|
2012-04-12 05:33:34 +04:00
|
|
|
compile_array(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root, enum compile_array_type_t type)
|
2007-07-03 23:35:09 +04:00
|
|
|
{
|
2012-04-12 05:33:34 +04:00
|
|
|
return compile_array_(iseq, ret, node_root, type, 0);
|
2007-07-03 23:35:09 +04:00
|
|
|
}
|
|
|
|
|
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;
|
2010-09-09 17:40:14 +04:00
|
|
|
double ival;
|
2011-09-29 15:07:45 +04:00
|
|
|
if (RB_TYPE_P(v, T_FLOAT) &&
|
2010-09-09 17:40:14 +04:00
|
|
|
modf(RFLOAT_VALUE(v), &ival) == 0.0) {
|
|
|
|
return FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival);
|
|
|
|
}
|
2013-11-10 10:13:02 +04: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:
|
2013-11-27 03:30:25 +04:00
|
|
|
return node->nd_lit = rb_fstring(node->nd_lit);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2012-04-24 13:20:42 +04:00
|
|
|
return Qundef;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2012-04-24 13:20:42 +04:00
|
|
|
static int
|
|
|
|
when_vals(rb_iseq_t *iseq, LINK_ANCHOR *cond_seq, NODE *vals, LABEL *l1, int only_special_literals, VALUE literals)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
|
|
|
while (vals) {
|
2012-04-24 13:20:42 +04:00
|
|
|
NODE* val = vals->nd_head;
|
|
|
|
VALUE lit = case_when_optimizable_literal(val);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2012-04-24 13:20:42 +04:00
|
|
|
if (lit == Qundef) {
|
|
|
|
only_special_literals = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
2012-04-24 13:20:42 +04:00
|
|
|
if (rb_hash_lookup(literals, lit) != Qnil) {
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_warning(RSTRING_PTR(iseq->location.path), nd_line(val), "duplicated when clause is ignored");
|
2012-04-24 13:20:42 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_hash_aset(literals, lit, (VALUE)(l1) | 1);
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2012-08-08 11:52:19 +04:00
|
|
|
ADD_INSN(cond_seq, nd_line(val), dup); /* dup target */
|
|
|
|
|
2011-07-10 07:11:52 +04:00
|
|
|
if (nd_type(val) == NODE_STR) {
|
2013-11-27 03:30:25 +04:00
|
|
|
val->nd_lit = rb_fstring(val->nd_lit);
|
2011-07-10 07:11:52 +04:00
|
|
|
debugp_param("nd_lit", val->nd_lit);
|
|
|
|
ADD_INSN1(cond_seq, nd_line(val), putobject, val->nd_lit);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(cond_seq, "when cond", val);
|
|
|
|
}
|
2012-08-08 11:52:19 +04:00
|
|
|
|
|
|
|
ADD_INSN1(cond_seq, nd_line(vals), checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
|
2006-12-31 18:02:22 +03:00
|
|
|
ADD_INSNL(cond_seq, nd_line(val), branchif, l1);
|
|
|
|
vals = vals->nd_next;
|
|
|
|
}
|
2012-04-24 13:20:42 +04:00
|
|
|
return only_special_literals;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
rb_call_info_t *ci;
|
2007-08-23 10:48:28 +04:00
|
|
|
VALUE dupidx;
|
|
|
|
|
|
|
|
COMPILE_POPED(ret, "masgn lhs (NODE_ATTRASGN)", node);
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
2007-08-23 10:48:28 +04:00
|
|
|
POP_ELEMENT(ret); /* pop pop insn */
|
|
|
|
iobj = (INSN *)POP_ELEMENT(ret); /* pop send insn */
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
ci = (rb_call_info_t *)iobj->operands[0];
|
2012-10-18 12:35:19 +04:00
|
|
|
ci->orig_argc += 1; ci->argc = ci->orig_argc;
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
dupidx = INT2FIX(ci->orig_argc);
|
2007-08-23 10:48:28 +04:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-06 17:19:31 +04:00
|
|
|
#define private_recv_p(node) (nd_type((node)->nd_recv) == NODE_SELF)
|
2014-06-06 10:05:19 +04:00
|
|
|
|
2012-02-11 07:04:23 +04:00
|
|
|
#define defined_expr defined_expr0
|
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
|
|
|
{
|
2012-09-24 12:36:53 +04:00
|
|
|
enum defined_type expr_type = 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:
|
2012-09-24 12:36:53 +04:00
|
|
|
expr_type = DEFINED_NIL;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
case NODE_SELF:
|
2012-09-24 12:36:53 +04:00
|
|
|
expr_type = DEFINED_SELF;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
case NODE_TRUE:
|
2012-09-24 12:36:53 +04:00
|
|
|
expr_type = DEFINED_TRUE;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
case NODE_FALSE:
|
2012-09-24 12:36:53 +04:00
|
|
|
expr_type = DEFINED_FALSE;
|
2006-12-31 18:02:22 +03:00
|
|
|
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:
|
2012-09-24 12:36:53 +04:00
|
|
|
expr_type = DEFINED_EXPR;
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* variables */
|
|
|
|
case NODE_LVAR:
|
|
|
|
case NODE_DVAR:
|
2012-09-24 12:36:53 +04:00
|
|
|
expr_type = DEFINED_LVAR;
|
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),
|
2010-03-09 22:21:37 +03:00
|
|
|
ID2SYM(node->nd_entry->id), needstr);
|
2006-12-31 18:02:22 +03:00
|
|
|
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:
|
2014-06-06 10:05:19 +04:00
|
|
|
if (private_recv_p(node)) break;
|
2007-04-05 12:58:46 +04:00
|
|
|
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) {
|
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
|
|
|
COMPILE(ret, "defined/recv", node->nd_recv);
|
|
|
|
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:
|
2012-09-24 12:36:53 +04:00
|
|
|
expr_type = DEFINED_ASGN;
|
2007-04-05 12:58:46 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2012-09-24 12:36:53 +04:00
|
|
|
if (expr_type) {
|
2006-12-31 18:02:22 +03:00
|
|
|
if (needstr != Qfalse) {
|
2012-09-24 12:36:53 +04:00
|
|
|
VALUE str = rb_iseq_defined_string(expr_type);
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, str);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, Qtrue);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-02-11 07:04:23 +04:00
|
|
|
#undef defined_expr
|
|
|
|
|
|
|
|
static int
|
|
|
|
defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
|
|
|
|
NODE *node, LABEL **lfinish, VALUE needstr)
|
|
|
|
{
|
|
|
|
LINK_ELEMENT *lcur = ret->last;
|
|
|
|
int done = defined_expr0(iseq, ret, node, lfinish, needstr);
|
|
|
|
if (lfinish[1]) {
|
|
|
|
int line = nd_line(node);
|
|
|
|
LABEL *lstart = NEW_LABEL(line);
|
|
|
|
LABEL *lend = NEW_LABEL(line);
|
|
|
|
VALUE rescue = NEW_CHILD_ISEQVAL(NEW_NIL(),
|
|
|
|
rb_str_concat(rb_str_new2
|
|
|
|
("defined guard in "),
|
2012-06-04 06:49:37 +04:00
|
|
|
iseq->location.label),
|
2012-02-11 07:04:23 +04:00
|
|
|
ISEQ_TYPE_DEFINED_GUARD, 0);
|
|
|
|
APPEND_LABEL(ret, lcur, lstart);
|
|
|
|
ADD_LABEL(ret, lend);
|
|
|
|
ADD_CATCH_ENTRY(CATCH_TYPE_RESCUE, lstart, lend, rescue, lfinish[1]);
|
|
|
|
}
|
|
|
|
return done;
|
|
|
|
}
|
2006-12-31 18:02:22 +03: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
|
|
|
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) {
|
2013-06-24 15:31:21 +04:00
|
|
|
return rb_sprintf("block in %"PRIsVALUE, ip->location.label);
|
2008-12-27 04:15:56 +03:00
|
|
|
}
|
|
|
|
else {
|
2013-06-24 15:31:21 +04:00
|
|
|
return rb_sprintf("block (%d levels) in %"PRIsVALUE, level, ip->location.label);
|
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
|
2010-12-21 00:10:24 +03:00
|
|
|
setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *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) {
|
2010-12-21 00:10:24 +03:00
|
|
|
COMPILE(arg_block, "block", argn->nd_body);
|
2012-10-15 21:22:57 +04:00
|
|
|
*flag |= VM_CALL_ARGS_BLOCKARG;
|
2006-12-31 18:02:22 +03:00
|
|
|
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++;
|
2012-10-15 21:22:57 +04:00
|
|
|
*flag |= VM_CALL_ARGS_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
|
|
|
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++;
|
2012-10-15 21:22:57 +04:00
|
|
|
*flag |= VM_CALL_ARGS_SPLAT;
|
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) {
|
2012-04-12 05:33:34 +04:00
|
|
|
argc = INT2FIX(compile_array(iseq, args, argn->nd_head, COMPILE_ARRAY_TYPE_ARGS) + 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
|
|
|
}
|
|
|
|
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: {
|
2012-04-12 05:33:34 +04:00
|
|
|
argc = INT2FIX(compile_array(iseq, args, argn, COMPILE_ARRAY_TYPE_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
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-10-15 21:22:57 +04:00
|
|
|
if (*flag & VM_CALL_ARGS_BLOCKARG) {
|
2006-12-31 18:02:22 +03:00
|
|
|
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
|
|
|
|
2013-08-22 10:50:42 +04:00
|
|
|
static VALUE
|
|
|
|
build_postexe_iseq(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE *body)
|
|
|
|
{
|
|
|
|
int line = nd_line(body);
|
|
|
|
VALUE argc = INT2FIX(0);
|
|
|
|
VALUE block = NEW_CHILD_ISEQVAL(body, make_name_for_block(iseq->parent_iseq), ISEQ_TYPE_BLOCK, line);
|
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_CALL_WITH_BLOCK(ret, line, ID2SYM(id_core_set_postexe), argc, block);
|
2013-08-22 11:23:44 +04:00
|
|
|
iseq_set_local_table(iseq, 0);
|
2013-08-22 10:50:42 +04:00
|
|
|
return Qnil;
|
|
|
|
}
|
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;
|
2013-02-28 18:04:53 +04:00
|
|
|
LINK_ELEMENT *saved_last_element = 0;
|
2013-03-07 09:17:04 +04:00
|
|
|
int line;
|
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;
|
|
|
|
}
|
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
iseq->compile_data->last_line = 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_TRACE(ret, line, RUBY_EVENT_LINE);
|
2013-02-28 18:04:53 +04:00
|
|
|
saved_last_element = ret->last;
|
2007-04-19 14:37:08 +04:00
|
|
|
}
|
|
|
|
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
then_label = NEW_LABEL(line);
|
|
|
|
else_label = NEW_LABEL(line);
|
|
|
|
end_label = NEW_LABEL(line);
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, 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);
|
2012-04-24 13:20:42 +04:00
|
|
|
int only_special_literals = 1;
|
|
|
|
VALUE literals = rb_hash_new();
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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);
|
2012-04-24 13:20:42 +04:00
|
|
|
|
2013-05-26 20:19:04 +04:00
|
|
|
rb_hash_tbl_raw(literals)->type = &cdhash_type;
|
2012-04-24 13:20: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
|
|
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
line = 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
|
|
|
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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
endlabel = NEW_LABEL(line);
|
|
|
|
elselabel = NEW_LABEL(line);
|
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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
l1 = NEW_LABEL(line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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(body_seq, l1);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(body_seq, line, 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
|
|
|
COMPILE_(body_seq, "when body", node->nd_body, poped);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(body_seq, line, 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:
|
2012-04-24 13:20:42 +04:00
|
|
|
only_special_literals = when_vals(iseq, cond_seq, vals, l1, only_special_literals, literals);
|
2008-04-20 09:44:47 +04:00
|
|
|
break;
|
|
|
|
case NODE_SPLAT:
|
|
|
|
case NODE_ARGSCAT:
|
|
|
|
case NODE_ARGSPUSH:
|
2012-04-24 13:20:42 +04:00
|
|
|
only_special_literals = 0;
|
2012-08-08 11:52:19 +04:00
|
|
|
ADD_INSN (cond_seq, nd_line(vals), dup);
|
2008-04-20 09:44:47 +04:00
|
|
|
COMPILE(cond_seq, "when/cond splat", vals);
|
2012-08-08 11:52:19 +04:00
|
|
|
ADD_INSN1(cond_seq, nd_line(vals), checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE | VM_CHECKMATCH_ARRAY));
|
2008-04-20 09:44:47 +04:00
|
|
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
line = 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
|
|
|
}
|
|
|
|
/* else */
|
|
|
|
if (node) {
|
|
|
|
ADD_LABEL(cond_seq, elselabel);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(cond_seq, line, 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
|
|
|
COMPILE_(cond_seq, "else", node, poped);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(cond_seq, line, jump, endlabel);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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 {
|
|
|
|
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
|
|
|
|
2012-04-24 13:20:42 +04:00
|
|
|
if (only_special_literals) {
|
|
|
|
iseq_add_mark_object(iseq, literals);
|
|
|
|
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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(tempnode), dup);
|
2012-04-24 13:20:42 +04:00
|
|
|
ADD_INSN2(ret, nd_line(tempnode), opt_case_dispatch, literals, elselabel);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_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);
|
2013-03-07 09:17:04 +04:00
|
|
|
endlabel = NEW_LABEL(line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_WHEN) {
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *l1 = NEW_LABEL(line = 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_LABEL(body_seq, l1);
|
|
|
|
COMPILE_(body_seq, "when", node->nd_body, poped);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(body_seq, line, jump, endlabel);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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;
|
2010-04-17 04:23:28 +04:00
|
|
|
if (!vals) {
|
|
|
|
rb_bug("NODE_WHEN: must be NODE_ARRAY, but 0");
|
|
|
|
}
|
|
|
|
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
|
|
|
while (vals) {
|
|
|
|
val = vals->nd_head;
|
|
|
|
COMPILE(ret, "when2", val);
|
|
|
|
ADD_INSNL(ret, nd_line(val), branchif, l1);
|
|
|
|
vals = vals->nd_next;
|
|
|
|
}
|
2010-04-17 04:23:28 +04:00
|
|
|
break;
|
|
|
|
case NODE_SPLAT:
|
|
|
|
case NODE_ARGSCAT:
|
|
|
|
case NODE_ARGSPUSH:
|
|
|
|
ADD_INSN(ret, nd_line(vals), putnil);
|
|
|
|
COMPILE(ret, "when2/cond splat", vals);
|
2012-08-08 11:52:19 +04:00
|
|
|
ADD_INSN1(ret, nd_line(vals), checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_WHEN | VM_CHECKMATCH_ARRAY));
|
2010-04-17 04:23:28 +04:00
|
|
|
ADD_INSNL(ret, nd_line(vals), branchif, l1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rb_bug("NODE_WHEN: unknown node (%s)",
|
|
|
|
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
|
|
|
}
|
|
|
|
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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *next_label = iseq->compile_data->start_label = NEW_LABEL(line); /* next */
|
|
|
|
LABEL *redo_label = iseq->compile_data->redo_label = NEW_LABEL(line); /* redo */
|
|
|
|
LABEL *break_label = iseq->compile_data->end_label = NEW_LABEL(line); /* break */
|
|
|
|
LABEL *end_label = NEW_LABEL(line);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *next_catch_label = NEW_LABEL(line);
|
2008-05-24 10:29:48 +04:00
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, jump, next_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
|
|
|
}
|
2008-05-24 10:29:48 +04:00
|
|
|
else {
|
2013-03-07 09:17:04 +04:00
|
|
|
tmp_label = NEW_LABEL(line);
|
|
|
|
ADD_INSNL(ret, line, jump, tmp_label);
|
2008-05-24 10:29:48 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
2008-05-24 10:29:48 +04:00
|
|
|
ADD_LABEL(ret, next_catch_label);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
|
|
|
ADD_INSNL(ret, line, jump, next_label);
|
2008-05-24 10:29:48 +04:00
|
|
|
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) {
|
2013-05-19 07:10:21 +04:00
|
|
|
/* 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
|
|
|
compile_branch_condition(iseq, ret, node->nd_cond,
|
|
|
|
end_label, redo_label);
|
|
|
|
}
|
|
|
|
else {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL_RECEIVER(ret, line);
|
|
|
|
ADD_CALL(ret, line, ID2SYM(idGets), INT2FIX(0));
|
|
|
|
ADD_INSNL(ret, line, branchif, redo_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
|
|
|
/* 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
/* ADD_INSN(ret, line, 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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *retry_label = NEW_LABEL(line);
|
|
|
|
LABEL *retry_end_l = NEW_LABEL(line);
|
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),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_BLOCK, line);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND_R(ret, line, ID2SYM(idEach), INT2FIX(0),
|
2007-08-23 10:48:28 +04:00
|
|
|
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),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_BLOCK, line);
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2007-08-23 10:48:28 +04:00
|
|
|
}
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_ADJUST(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, jump, iseq->compile_data->end_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
2008-01-26 11:27:00 +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 if (iseq->type == ISEQ_TYPE_BLOCK) {
|
|
|
|
break_by_insn:
|
|
|
|
/* escape from block */
|
|
|
|
COMPILE(ret, "break val (block)", node->nd_stts);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, throw, INT2FIX(level | 0x02) /* TAG_BREAK */ );
|
2008-01-26 11:27:00 +03:00
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2008-01-26 11:27:00 +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 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_ADJUST(ret, line, iseq->compile_data->redo_label);
|
|
|
|
ADD_INSNL(ret, line, jump, iseq->compile_data->start_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
2010-04-20 19:28:33 +04:00
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
2010-04-20 19:28:33 +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 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_ADJUST(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, jump, iseq->compile_data->end_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
2008-01-26 11:27:00 +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 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, throw, INT2FIX(level | 0x03) /* TAG_NEXT */ );
|
2008-01-26 11:27:00 +03:00
|
|
|
|
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2007-08-16 17:12:24 +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 {
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_ADJUST(ret, line, iseq->compile_data->redo_label);
|
2009-02-16 23:54:58 +03:00
|
|
|
add_ensure_iseq(ret, iseq, 0);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, jump, iseq->compile_data->redo_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
2010-04-20 19:28:33 +04:00
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
2010-04-20 19:28:33 +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 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_ADJUST(ret, line, iseq->compile_data->start_label);
|
|
|
|
ADD_INSNL(ret, line, jump, iseq->compile_data->start_label);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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 {
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
|
|
|
ADD_INSN1(ret, line, throw, INT2FIX(level | 0x05) /* TAG_REDO */ );
|
2008-01-26 11:27:00 +03:00
|
|
|
|
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2008-01-26 11:27:00 +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-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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
|
|
|
ADD_INSN1(ret, line, throw, INT2FIX(0x04) /* TAG_RETRY */ );
|
2007-12-25 15:37:16 +03:00
|
|
|
|
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2007-12-25 15:37:16 +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-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:{
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *lstart = NEW_LABEL(line);
|
|
|
|
LABEL *lend = NEW_LABEL(line);
|
|
|
|
LABEL *lcont = NEW_LABEL(line);
|
2008-01-26 11:27:00 +03:00
|
|
|
VALUE rescue = NEW_CHILD_ISEQVAL(
|
|
|
|
node->nd_resq,
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_str_concat(rb_str_new2("rescue in "), iseq->location.label),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_RESCUE, line);
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
COMPILE(ret, "rescue else", node->nd_else);
|
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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-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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
label_miss = NEW_LABEL(line);
|
|
|
|
label_hit = NEW_LABEL(line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
|
|
|
narg = resq->nd_args;
|
2008-04-20 09:44:47 +04:00
|
|
|
if (narg) {
|
|
|
|
switch (nd_type(narg)) {
|
|
|
|
case NODE_ARRAY:
|
|
|
|
while (narg) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getlocal, INT2FIX(2), INT2FIX(0));
|
2012-08-08 11:52:19 +04:00
|
|
|
COMPILE(ret, "rescue arg", narg->nd_head);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
|
|
|
|
ADD_INSNL(ret, line, branchif, label_hit);
|
2008-04-20 09:44:47 +04:00
|
|
|
narg = narg->nd_next;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NODE_SPLAT:
|
|
|
|
case NODE_ARGSCAT:
|
|
|
|
case NODE_ARGSPUSH:
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getlocal, INT2FIX(2), INT2FIX(0));
|
2008-04-20 09:44:47 +04:00
|
|
|
COMPILE(ret, "rescue/cond splat", narg);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE | VM_CHECKMATCH_ARRAY));
|
|
|
|
ADD_INSNL(ret, line, branchif, label_hit);
|
2008-04-20 09:44:47 +04:00
|
|
|
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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getlocal, INT2FIX(2), INT2FIX(0));
|
|
|
|
ADD_INSN1(ret, line, putobject, rb_eStandardError);
|
|
|
|
ADD_INSN1(ret, line, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
|
|
|
|
ADD_INSNL(ret, line, branchif, label_hit);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, jump, label_miss);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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, label_hit);
|
|
|
|
COMPILE(ret, "resbody body", resq->nd_body);
|
2007-08-19 08:16:13 +04:00
|
|
|
if (iseq->compile_data->option->tailcall_optimization) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, nop);
|
2007-08-19 08:16:13 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, leave);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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, 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 "),
|
2012-06-04 06:49:37 +04:00
|
|
|
iseq->location.label),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_ENSURE, line);
|
|
|
|
LABEL *lstart = NEW_LABEL(line);
|
|
|
|
LABEL *lend = NEW_LABEL(line);
|
|
|
|
LABEL *lcont = NEW_LABEL(line);
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
|
|
|
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:{
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *end_label = NEW_LABEL(line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_1st", node->nd_1st);
|
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_AND) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, end_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
|
|
|
}
|
|
|
|
else {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchif, end_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
|
|
|
}
|
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, setlocal, INT2FIX(idx), INT2FIX(get_lvar_level(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
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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
|
|
|
|
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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, setlocal, 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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setglobal,
|
2010-10-12 17:41:12 +04:00
|
|
|
((VALUE)node->nd_entry | 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
|
|
|
}
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, setinstancevariable,
|
2013-08-20 21:41:13 +04:00
|
|
|
ID2SYM(node->nd_vid), INT2FIX(iseq->is_size++));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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-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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_vid) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putspecialobject,
|
2009-12-03 21:25:57 +03:00
|
|
|
INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setclassvariable,
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
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;
|
2010-10-31 04:42:54 +03:00
|
|
|
VALUE flag = 0;
|
2014-06-06 12:07:13 +04:00
|
|
|
VALUE asgnflag = 0;
|
2008-10-12 05:18:49 +04:00
|
|
|
ID id = node->nd_mid;
|
2010-06-02 07:05:06 +04:00
|
|
|
int boff = 0;
|
2008-10-12 05:18:49 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
2009-09-05 10:21:15 +04:00
|
|
|
}
|
2014-06-06 12:07:13 +04:00
|
|
|
asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN1 recv", node);
|
2010-06-02 07:05:06 +04:00
|
|
|
switch (nd_type(node->nd_args->nd_head)) {
|
|
|
|
case NODE_ZARRAY:
|
|
|
|
argc = INT2FIX(0);
|
|
|
|
break;
|
|
|
|
case NODE_BLOCK_PASS:
|
|
|
|
boff = 1;
|
|
|
|
default:
|
2008-10-12 05:18:49 +04:00
|
|
|
INIT_ANCHOR(args);
|
2010-12-21 00:10:24 +03:00
|
|
|
argc = setup_args(iseq, args, node->nd_args->nd_head, &flag);
|
2008-10-12 05:18:49 +04:00
|
|
|
ADD_SEQ(ret, args);
|
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, dupn, FIXNUM_INC(argc, 1 + boff));
|
|
|
|
ADD_SEND_R(ret, line, ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
|
2014-06-06 12:07:13 +04:00
|
|
|
flag |= asgnflag;
|
2008-10-12 05:18:49 +04:00
|
|
|
|
|
|
|
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
|
|
|
*/
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *label = NEW_LABEL(line);
|
|
|
|
LABEL *lfin = NEW_LABEL(line);
|
2008-10-12 05:18:49 +04:00
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
2008-10-12 05:18:49 +04:00
|
|
|
if (id == 0) {
|
|
|
|
/* or */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchif, label);
|
2008-10-12 05:18:49 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* and */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, label);
|
2008-10-12 05:18:49 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2+boff));
|
2009-09-05 10:21:15 +04:00
|
|
|
}
|
2012-10-15 21:22:57 +04:00
|
|
|
if (flag & VM_CALL_ARGS_SPLAT) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, newarray, INT2FIX(1));
|
2010-06-02 07:05:06 +04:00
|
|
|
if (boff > 0) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, dupn, INT2FIX(3));
|
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2010-06-02 07:05:06 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, concatarray);
|
2010-06-02 07:05:06 +04:00
|
|
|
if (boff > 0) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setn, INT2FIX(3));
|
|
|
|
ADD_INSN(ret, line, pop);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2010-06-02 07:05:06 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND_R(ret, line, ID2SYM(idASET),
|
2008-10-12 05:18:49 +04:00
|
|
|
argc, Qfalse, LONG2FIX(flag));
|
|
|
|
}
|
|
|
|
else {
|
2010-06-02 07:05:06 +04:00
|
|
|
if (boff > 0)
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_SEND_R(ret, line, 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
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
|
|
|
ADD_INSNL(ret, line, jump, lfin);
|
2008-10-12 05:18:49 +04:00
|
|
|
ADD_LABEL(ret, label);
|
2009-09-05 10:21:15 +04:00
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2+boff));
|
2009-09-05 10:21:15 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, adjuststack, FIXNUM_INC(argc, 2+boff));
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND(ret, line, ID2SYM(id), INT2FIX(1));
|
2009-09-05 10:21:15 +04:00
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2+boff));
|
2009-09-05 10:21:15 +04:00
|
|
|
}
|
2012-10-15 21:22:57 +04:00
|
|
|
if (flag & VM_CALL_ARGS_SPLAT) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, newarray, INT2FIX(1));
|
2010-06-02 07:05:06 +04:00
|
|
|
if (boff > 0) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, dupn, INT2FIX(3));
|
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2010-06-02 07:05:06 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, concatarray);
|
2010-06-02 07:05:06 +04:00
|
|
|
if (boff > 0) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setn, INT2FIX(3));
|
|
|
|
ADD_INSN(ret, line, pop);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2010-06-02 07:05:06 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND_R(ret, line, ID2SYM(idASET),
|
2008-10-12 05:18:49 +04:00
|
|
|
argc, Qfalse, LONG2FIX(flag));
|
|
|
|
}
|
|
|
|
else {
|
2010-06-02 07:05:06 +04:00
|
|
|
if (boff > 0)
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_SEND_R(ret, line, 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
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2008-10-12 05:18:49 +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
|
|
|
|
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;
|
2014-06-06 12:07:13 +04:00
|
|
|
VALUE asgnflag;
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *lfin = NEW_LABEL(line);
|
|
|
|
LABEL *lcfin = NEW_LABEL(line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-06-06 12:07:13 +04:00
|
|
|
asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
|
|
|
ADD_SEND(ret, line, ID2SYM(node->nd_next->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
|
|
|
INT2FIX(0));
|
|
|
|
|
|
|
|
if (atype == 0 || atype == 1) { /* 0: OR or 1: AND */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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 (atype == 0) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchif, lcfin);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, lcfin);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_INSN1(ret, line, topn, INT2FIX(1));
|
2014-06-06 12:07:13 +04:00
|
|
|
ADD_SEND_R(ret, line, ID2SYM(node->nd_next->nd_aid),
|
|
|
|
INT2FIX(1), Qfalse, INT2FIX(asgnflag));
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2009-09-05 05:38:47 +04:00
|
|
|
if (poped) {
|
|
|
|
/* we can apply more optimize */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2009-09-05 05:38:47 +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 {
|
|
|
|
COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND(ret, line, ID2SYM(node->nd_next->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
|
|
|
INT2FIX(1));
|
2009-09-05 05:38:47 +04:00
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_INSN1(ret, line, topn, INT2FIX(1));
|
2009-09-05 05:38:47 +04:00
|
|
|
}
|
2014-06-06 12:07:13 +04:00
|
|
|
ADD_SEND_R(ret, line, ID2SYM(node->nd_next->nd_aid),
|
|
|
|
INT2FIX(1), Qfalse, INT2FIX(asgnflag));
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
2012-12-24 19:59:31 +04:00
|
|
|
case NODE_OP_CDECL: {
|
|
|
|
LABEL *lfin = 0;
|
|
|
|
LABEL *lassign = 0;
|
|
|
|
ID mid;
|
|
|
|
|
|
|
|
switch (nd_type(node->nd_head)) {
|
|
|
|
case NODE_COLON3:
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, rb_cObject);
|
2012-12-24 19:59:31 +04:00
|
|
|
break;
|
|
|
|
case NODE_COLON2:
|
|
|
|
COMPILE(ret, "NODE_OP_CDECL/colon2#nd_head", node->nd_head->nd_head);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
do {
|
|
|
|
COMPILE_ERROR((ERROR_ARGS "%s: invalid node in NODE_OP_CDECL",
|
|
|
|
ruby_node_name(nd_type(node->nd_head))));
|
|
|
|
} while (0);
|
|
|
|
return COMPILE_NG;
|
|
|
|
}
|
|
|
|
mid = node->nd_head->nd_mid;
|
|
|
|
/* cref */
|
|
|
|
if (node->nd_aid == 0) {
|
2013-03-07 09:17:04 +04:00
|
|
|
lassign = NEW_LABEL(line);
|
|
|
|
ADD_INSN(ret, line, dup); /* cref cref */
|
|
|
|
ADD_INSN3(ret, line, defined, INT2FIX(DEFINED_CONST),
|
2012-12-24 19:59:31 +04:00
|
|
|
ID2SYM(mid), Qfalse); /* cref bool */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, lassign); /* cref */
|
2012-12-24 19:59:31 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup); /* cref cref */
|
|
|
|
ADD_INSN1(ret, line, getconstant, ID2SYM(mid)); /* cref obj */
|
2012-12-24 19:59:31 +04:00
|
|
|
|
|
|
|
if (node->nd_aid == 0 || node->nd_aid == 1) {
|
2013-03-07 09:17:04 +04:00
|
|
|
lfin = NEW_LABEL(line);
|
|
|
|
if (!poped) ADD_INSN(ret, line, dup); /* cref [obj] obj */
|
2012-12-24 19:59:31 +04:00
|
|
|
if (node->nd_aid == 0)
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchif, lfin);
|
2012-12-24 19:59:31 +04:00
|
|
|
else
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, lfin);
|
2012-12-24 19:59:31 +04:00
|
|
|
/* cref [obj] */
|
2013-03-07 09:17:04 +04:00
|
|
|
if (!poped) ADD_INSN(ret, line, pop); /* cref */
|
2012-12-24 19:59:31 +04:00
|
|
|
if (lassign) ADD_LABEL(ret, lassign);
|
|
|
|
COMPILE(ret, "NODE_OP_CDECL#nd_value", node->nd_value);
|
|
|
|
/* cref value */
|
|
|
|
if (poped)
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, topn, INT2FIX(1)); /* cref value cref */
|
2012-12-24 19:59:31 +04:00
|
|
|
else {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, dupn, INT2FIX(2)); /* cref value cref value */
|
|
|
|
ADD_INSN(ret, line, swap); /* cref value value cref */
|
2012-12-24 19:59:31 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setconstant, ID2SYM(mid)); /* cref [value] */
|
2012-12-24 19:59:31 +04:00
|
|
|
ADD_LABEL(ret, lfin); /* cref [value] */
|
2013-03-07 09:17:04 +04:00
|
|
|
if (!poped) ADD_INSN(ret, line, swap); /* [value] cref */
|
|
|
|
ADD_INSN(ret, line, pop); /* [value] */
|
2012-12-24 19:59:31 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(ret, "NODE_OP_CDECL#nd_value", node->nd_value);
|
|
|
|
/* cref obj value */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL(ret, line, ID2SYM(node->nd_aid), INT2FIX(1));
|
2012-12-24 19:59:31 +04:00
|
|
|
/* cref value */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, swap); /* value cref */
|
2012-12-24 19:59:31 +04:00
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, topn, INT2FIX(1)); /* value cref value */
|
|
|
|
ADD_INSN(ret, line, swap); /* value value cref */
|
2012-12-24 19:59:31 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setconstant, ID2SYM(mid));
|
2012-12-24 19:59:31 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
case NODE_OP_ASGN_AND:
|
|
|
|
case NODE_OP_ASGN_OR:{
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *lfin = NEW_LABEL(line);
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
lassign = NEW_LABEL(line);
|
2008-03-25 09:26:32 +03:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, lassign);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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-03-25 09:26:32 +03:00
|
|
|
else {
|
2013-03-07 09:17:04 +04:00
|
|
|
lassign = NEW_LABEL(line);
|
2008-03-25 09:26:32 +03:00
|
|
|
}
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, lfin);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchif, lfin);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
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 */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_CALL:
|
2014-01-10 08:54:08 +04:00
|
|
|
/* optimization shortcut
|
|
|
|
* "literal".freeze -> opt_str_freeze("literal")
|
|
|
|
*/
|
2013-11-10 01:17:06 +04:00
|
|
|
if (node->nd_recv && nd_type(node->nd_recv) == NODE_STR &&
|
|
|
|
node->nd_mid == idFreeze && node->nd_args == NULL)
|
|
|
|
{
|
|
|
|
VALUE str = rb_fstring(node->nd_recv->nd_lit);
|
|
|
|
iseq_add_mark_object(iseq, str);
|
|
|
|
ADD_INSN1(ret, line, opt_str_freeze, str);
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, line, pop);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-01-10 08:54:08 +04:00
|
|
|
/* optimization shortcut
|
|
|
|
* obj["literal"] -> opt_aref_with(obj, "literal")
|
|
|
|
*/
|
2014-06-06 10:05:19 +04:00
|
|
|
if (node->nd_mid == idAREF && !private_recv_p(node) && node->nd_args &&
|
2014-01-10 08:54:08 +04:00
|
|
|
nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 1 &&
|
|
|
|
nd_type(node->nd_args->nd_head) == NODE_STR)
|
|
|
|
{
|
|
|
|
VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
|
|
|
|
node->nd_args->nd_head->nd_lit = str;
|
|
|
|
COMPILE(ret, "recv", node->nd_recv);
|
|
|
|
ADD_INSN2(ret, line, opt_aref_with,
|
|
|
|
new_callinfo(iseq, idAREF, 1, 0, 0), str);
|
|
|
|
if (poped) {
|
|
|
|
ADD_INSN(ret, line, pop);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
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;
|
2010-10-31 04:42:54 +03:00
|
|
|
VALUE 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) {
|
2012-12-03 09:14:50 +04:00
|
|
|
ID id_bitblt;
|
|
|
|
ID id_answer;
|
|
|
|
|
|
|
|
CONST_ID(id_bitblt, "bitblt");
|
|
|
|
CONST_ID(id_answer, "the_answer_to_life_the_universe_and_everything");
|
|
|
|
|
|
|
|
if (mid == id_bitblt) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, bitblt);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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;
|
|
|
|
}
|
2012-12-03 09:14:50 +04:00
|
|
|
else if (mid == id_answer) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, answer);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* 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
|
|
|
|
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)) {
|
2010-12-12 17:45:30 +03:00
|
|
|
LABEL *label;
|
|
|
|
st_data_t data;
|
|
|
|
st_table *labels_table = iseq->compile_data->labels_table;
|
|
|
|
ID label_name;
|
|
|
|
|
|
|
|
if (!labels_table) {
|
|
|
|
labels_table = st_init_numtable();
|
|
|
|
iseq->compile_data->labels_table = labels_table;
|
|
|
|
}
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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->nd_args->nd_head) == NODE_LIT &&
|
|
|
|
SYMBOL_P(node->nd_args->nd_head->nd_lit)) {
|
|
|
|
|
2010-12-12 17:45:30 +03:00
|
|
|
label_name = SYM2ID(node->nd_args->nd_head->nd_lit);
|
|
|
|
if (!st_lookup(labels_table, (st_data_t)label_name, &data)) {
|
2013-03-07 09:17:04 +04:00
|
|
|
label = NEW_LABEL(line);
|
|
|
|
label->position = line;
|
2010-12-12 17:45:30 +03:00
|
|
|
st_insert(labels_table, (st_data_t)label_name, (st_data_t)label);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
label = (LABEL *)data;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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 {
|
2010-12-12 17:45:30 +03:00
|
|
|
COMPILE_ERROR((ERROR_ARGS "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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, jump, 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
|
|
|
}
|
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL_RECEIVER(recv, line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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
|
|
|
/* args */
|
|
|
|
if (nd_type(node) != NODE_VCALL) {
|
2010-12-21 00:10:24 +03: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:
|
2012-10-15 21:22:57 +04:00
|
|
|
flag |= VM_CALL_VCALL;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
/* VCALL is funcall, so fall through */
|
|
|
|
case NODE_FCALL:
|
2012-10-15 21:22:57 +04:00
|
|
|
flag |= VM_CALL_FCALL;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND_R(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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);
|
2013-03-07 09:17:00 +04:00
|
|
|
int argc;
|
2010-10-31 04:42:54 +03:00
|
|
|
VALUE 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) {
|
2013-03-07 09:17:00 +04:00
|
|
|
VALUE vargc = setup_args(iseq, args, node->nd_args, &flag);
|
|
|
|
argc = FIX2INT(vargc);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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;
|
2012-10-04 17:52:20 +04:00
|
|
|
int lvar_level = get_lvar_level(iseq);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2013-03-07 09:17:00 +04:00
|
|
|
argc = 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;
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_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
|
|
|
}
|
* 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_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
|
|
|
}
|
|
|
|
i += j;
|
2013-03-07 09:17:00 +04:00
|
|
|
argc = i;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04: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
|
|
|
|
2007-06-24 11:29:21 +04:00
|
|
|
if (liseq->arg_rest != -1) {
|
|
|
|
/* rest argument */
|
|
|
|
int idx = liseq->local_size - liseq->arg_rest;
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
|
2013-03-07 09:17:00 +04:00
|
|
|
argc = liseq->arg_rest + 1;
|
2012-10-15 21:22:57 +04:00
|
|
|
flag |= VM_CALL_ARGS_SPLAT;
|
2007-06-24 11:29:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
|
2007-11-27 09:45:01 +03:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(args, line, newarray, INT2FIX(j));
|
|
|
|
ADD_INSN (args, line, concatarray);
|
2013-05-19 07:10:21 +04:00
|
|
|
/* argc is settled 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
2013-03-07 09:17:00 +04:00
|
|
|
argc = 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
|
|
|
}
|
2013-03-07 09:21:40 +04:00
|
|
|
|
2013-05-18 11:38:55 +04:00
|
|
|
if (liseq->arg_keyword >= 0) {
|
2013-03-07 09:21:40 +04:00
|
|
|
int local_size = liseq->local_size;
|
|
|
|
int idx = local_size - liseq->arg_keyword;
|
|
|
|
argc++;
|
|
|
|
ADD_INSN1(args, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
|
|
|
|
ADD_SEND (args, line, ID2SYM(rb_intern("dup")), INT2FIX(0));
|
|
|
|
for (i = 0; i < liseq->arg_keywords; ++i) {
|
|
|
|
ID id = liseq->arg_keyword_table[i];
|
|
|
|
idx = local_size - get_local_var_idx(liseq, id);
|
|
|
|
ADD_INSN1(args, line, putobject, ID2SYM(id));
|
|
|
|
ADD_INSN2(args, line, getlocal, INT2FIX(idx), INT2FIX(lvar_level));
|
|
|
|
}
|
|
|
|
ADD_SEND(args, line, ID2SYM(id_core_hash_merge_ptr), INT2FIX(i * 2 + 1));
|
2013-04-09 10:26:15 +04:00
|
|
|
if (liseq->arg_rest != -1) {
|
|
|
|
ADD_INSN1(args, line, newarray, INT2FIX(1));
|
|
|
|
ADD_INSN (args, line, concatarray);
|
|
|
|
--argc;
|
|
|
|
}
|
2013-03-07 09:21:40 +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
|
|
|
}
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2009-11-03 20:46:28 +03:00
|
|
|
/* dummy receiver */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, nd_type(node) == NODE_ZSUPER ? Qfalse : Qtrue);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, invokesuper, new_callinfo(iseq, 0, argc, parent_block,
|
2012-10-15 21:22:57 +04:00
|
|
|
flag | VM_CALL_SUPER | VM_CALL_FCALL));
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_ARRAY:{
|
2012-04-12 05:33:34 +04:00
|
|
|
compile_array_(iseq, ret, node, COMPILE_ARRAY_TYPE_ARRAY, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, newarray, 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
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, newarray, INT2FIX(node->nd_alen));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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);
|
|
|
|
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) {
|
2012-04-12 05:33:34 +04:00
|
|
|
case NODE_ARRAY:
|
2012-05-06 13:40:47 +04:00
|
|
|
compile_array(iseq, list, node->nd_head, COMPILE_ARRAY_TYPE_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
|
|
|
ADD_SEQ(ret, list);
|
|
|
|
break;
|
2012-04-12 05:33:34 +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
|
|
|
case NODE_ZARRAY:
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, newhash, 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
|
|
|
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
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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) {
|
2010-05-09 22:21:39 +04:00
|
|
|
if (is->type == ISEQ_TYPE_TOP) {
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_ADJUST(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_TRACE(ret, line, RUBY_EVENT_RETURN);
|
|
|
|
ADD_INSN(ret, line, leave);
|
2008-01-26 11:27:00 +03:00
|
|
|
ADD_ADJUST_RESTORE(ret, splabel);
|
|
|
|
|
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, throw, INT2FIX(0x01) /* TAG_RETURN */ );
|
2007-12-20 03:46:12 +03:00
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2007-12-20 03:46:12 +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_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;
|
2010-10-31 04:42:54 +03:00
|
|
|
VALUE flag = 0;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(args);
|
2010-05-09 22:21:39 +04:00
|
|
|
if (iseq->type == ISEQ_TYPE_TOP) {
|
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) {
|
2010-12-21 00:10:24 +03: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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, invokeblock, new_callinfo(iseq, 0, FIX2INT(argc), 0, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getlocal, INT2FIX(idx), INT2FIX(get_lvar_level(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
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getlocal, 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:{
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, getglobal,
|
2010-10-12 17:41:12 +04:00
|
|
|
((VALUE)node->nd_entry | 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
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
* 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getinstancevariable,
|
2013-08-20 21:41:13 +04:00
|
|
|
ID2SYM(node->nd_vid), INT2FIX(iseq->is_size++));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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-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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *lend = NEW_LABEL(line);
|
2013-08-20 21:41:13 +04:00
|
|
|
int ic_index = iseq->is_size++;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getinlinecache, lend, INT2FIX(ic_index));
|
|
|
|
ADD_INSN1(ret, line, getconstant, ID2SYM(node->nd_vid));
|
|
|
|
ADD_INSN1(ret, line, setinlinecache, INT2FIX(ic_index));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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, lend);
|
|
|
|
}
|
|
|
|
else {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putnil);
|
|
|
|
ADD_INSN1(ret, line, getconstant, 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
|
|
|
}
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, getclassvariable,
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getspecial, INT2FIX(1) /* '~' */,
|
2007-06-27 20:21:57 +04:00
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getspecial, INT2FIX(1) /* '~' */,
|
2007-06-27 20:21:57 +04:00
|
|
|
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);
|
2012-12-29 16:22:04 +04:00
|
|
|
switch (nd_type(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
|
|
|
case NODE_MATCH:
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(recv, line, putobject, node->nd_lit);
|
|
|
|
ADD_INSN2(val, line, getspecial, 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
|
|
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, opt_regexpmatch1,
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
OPERAND_AT(recv->last, 0));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, val);
|
2013-08-31 10:07:21 +04:00
|
|
|
ADD_INSN1(ret, line, opt_regexpmatch2, new_callinfo(iseq, idEqTilde, 1, 0, 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 {
|
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, val);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND(ret, line, ID2SYM(idEqTilde), 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
|
|
|
}
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, 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
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_STR:{
|
2013-11-27 03:30:25 +04:00
|
|
|
node->nd_lit = rb_fstring(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
|
|
|
debugp_param("nd_lit", node->nd_lit);
|
|
|
|
if (!poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putstring, 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
|
|
|
}
|
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_XSTR:{
|
2013-11-27 03:30:25 +04:00
|
|
|
node->nd_lit = rb_fstring(node->nd_lit);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL_RECEIVER(ret, line);
|
|
|
|
ADD_INSN1(ret, line, putobject, node->nd_lit);
|
|
|
|
ADD_CALL(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_DXSTR:{
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL_RECEIVER(ret, line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, tostring);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_DREGX_ONCE:{
|
2013-08-20 21:41:13 +04:00
|
|
|
int ic_index = iseq->is_size++;
|
|
|
|
NODE *dregx_node = NEW_NODE(NODE_DREGX, node->u1.value, node->u2.value, node->u3.value);
|
|
|
|
NODE *block_node = NEW_NODE(NODE_SCOPE, 0, dregx_node, 0);
|
|
|
|
VALUE block_iseq = NEW_CHILD_ISEQVAL(block_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2013-08-20 21:41:13 +04:00
|
|
|
ADD_INSN2(ret, line, once, block_iseq, INT2FIX(ic_index));
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_ARGSCAT:{
|
2010-08-05 16:32:02 +04:00
|
|
|
if (poped) {
|
|
|
|
COMPILE(ret, "argscat head", node->nd_head);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, splatarray, Qfalse);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2010-08-05 16:32:02 +04:00
|
|
|
COMPILE(ret, "argscat body", node->nd_body);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, splatarray, Qfalse);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2010-08-05 16:32:02 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(ret, "argscat head", node->nd_head);
|
|
|
|
COMPILE(ret, "argscat body", node->nd_body);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, concatarray);
|
2010-08-05 16:32:02 +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
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_ARGSPUSH:{
|
2010-08-05 16:32:02 +04:00
|
|
|
if (poped) {
|
|
|
|
COMPILE(ret, "arsgpush head", node->nd_head);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, splatarray, Qfalse);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2010-08-05 16:32:02 +04:00
|
|
|
COMPILE_(ret, "argspush body", node->nd_body, poped);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
COMPILE(ret, "arsgpush head", node->nd_head);
|
|
|
|
COMPILE_(ret, "argspush body", node->nd_body, poped);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, newarray, INT2FIX(1));
|
|
|
|
ADD_INSN(ret, line, concatarray);
|
2010-08-05 16:32:02 +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
|
|
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, splatarray, Qtrue);
|
2007-07-05 22:16:54 +04:00
|
|
|
|
2008-10-12 05:18:49 +04:00
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2008-10-12 05:18:49 +04:00
|
|
|
}
|
|
|
|
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,
|
2013-11-27 03:30:25 +04:00
|
|
|
rb_id2str(node->nd_mid),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_METHOD, line);
|
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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
|
|
|
|
ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid));
|
|
|
|
ADD_INSN1(ret, line, putiseq, iseqval);
|
|
|
|
ADD_SEND (ret, line, ID2SYM(id_core_define_method), INT2FIX(3));
|
2008-07-01 07:05:58 +04:00
|
|
|
|
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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,
|
2013-11-27 03:30:25 +04:00
|
|
|
rb_id2str(node->nd_mid),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_METHOD, line);
|
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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid));
|
|
|
|
ADD_INSN1(ret, line, putiseq, iseqval);
|
|
|
|
ADD_SEND (ret, line, ID2SYM(id_core_define_singleton_method), INT2FIX(3));
|
2008-07-01 07:05:58 +04:00
|
|
|
|
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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:{
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_VALIAS:{
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, line, putobject, ID2SYM(node->u1.id));
|
|
|
|
ADD_INSN1(ret, line, putobject, ID2SYM(node->u2.id));
|
|
|
|
ADD_SEND(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2008-03-25 09:09:38 +03:00
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_UNDEF:{
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
|
2008-03-25 09:09:38 +03:00
|
|
|
COMPILE(ret, "undef arg", node->u2.node);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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)),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_CLASS, line);
|
2011-01-28 20:57:34 +03:00
|
|
|
VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath);
|
2012-12-20 12:13:53 +04:00
|
|
|
int flags = VM_DEFINECLASS_TYPE_CLASS;
|
|
|
|
if (!noscope) flags |= VM_DEFINECLASS_FLAG_SCOPED;
|
|
|
|
if (node->nd_super) flags |= VM_DEFINECLASS_FLAG_HAS_SUPERCLASS;
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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, "super", node->nd_super);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN3(ret, line, defineclass,
|
2012-12-20 12:13:53 +04:00
|
|
|
ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(flags));
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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)),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_CLASS, line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-05 08:25:10 +04:00
|
|
|
|
2011-01-28 20:57:34 +03:00
|
|
|
VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath);
|
2012-12-20 12:13:53 +04:00
|
|
|
int flags = VM_DEFINECLASS_TYPE_MODULE;
|
|
|
|
if (!noscope) flags |= VM_DEFINECLASS_FLAG_SCOPED;
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN (ret, line, putnil); /* dummy */
|
|
|
|
ADD_INSN3(ret, line, defineclass,
|
2012-12-20 12:13:53 +04:00
|
|
|
ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(flags));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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 =
|
2012-03-18 10:28:41 +04:00
|
|
|
NEW_ISEQVAL(node->nd_body, rb_str_new2("singleton class"),
|
2013-03-07 09:17:04 +04:00
|
|
|
ISEQ_TYPE_CLASS, line);
|
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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN (ret, line, putnil);
|
2008-06-09 13:25:32 +04:00
|
|
|
CONST_ID(singletonclass, "singletonclass");
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN3(ret, line, defineclass,
|
2012-12-20 12:13:53 +04:00
|
|
|
ID2SYM(singletonclass), iseqval,
|
|
|
|
INT2FIX(VM_DEFINECLASS_TYPE_SINGLETON_CLASS));
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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 */
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *lend = NEW_LABEL(line);
|
2013-08-20 21:41:13 +04:00
|
|
|
int ic_index = iseq->is_size++;
|
2010-02-24 20:06:15 +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
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getinlinecache, lend, INT2FIX(ic_index));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
|
|
|
|
|
|
|
ADD_SEQ(ret, body);
|
|
|
|
|
|
|
|
if (iseq->compile_data->option->inline_const_cache) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setinlinecache, INT2FIX(ic_index));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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, lend);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ADD_SEQ(ret, pref);
|
|
|
|
ADD_SEQ(ret, body);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* function call */
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL_RECEIVER(ret, line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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, "colon2#nd_head", node->nd_head);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_CALL(ret, line, ID2SYM(node->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
|
|
|
INT2FIX(1));
|
|
|
|
}
|
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_COLON3:{
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *lend = NEW_LABEL(line);
|
2013-08-20 21:41:13 +04:00
|
|
|
int ic_index = iseq->is_size++;
|
2010-02-24 20:06:15 +03:00
|
|
|
|
2013-01-08 22:47:05 +04:00
|
|
|
debugi("colon3#nd_mid", node->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
|
|
|
|
|
|
|
/* add cache insn */
|
|
|
|
if (iseq->compile_data->option->inline_const_cache) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getinlinecache, lend, INT2FIX(ic_index));
|
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, rb_cObject);
|
|
|
|
ADD_INSN1(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setinlinecache, INT2FIX(ic_index));
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
|
|
|
ADD_INSN(ret, line, 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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, newrange, 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
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_FLIP2:
|
|
|
|
case NODE_FLIP3:{
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *lend = NEW_LABEL(line);
|
|
|
|
LABEL *lfin = NEW_LABEL(line);
|
|
|
|
LABEL *ltrue = NEW_LABEL(line);
|
2013-01-08 09:41:44 +04:00
|
|
|
rb_iseq_t *local_iseq = iseq->local_iseq;
|
2012-12-10 10:11:16 +04:00
|
|
|
rb_num_t cnt;
|
|
|
|
VALUE key;
|
|
|
|
|
2013-01-08 09:41:44 +04:00
|
|
|
cnt = local_iseq->flip_cnt++ + DEFAULT_SPECIAL_VAR_COUNT;
|
2012-12-10 10:11:16 +04:00
|
|
|
key = INT2FIX(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
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getspecial, key, INT2FIX(0));
|
|
|
|
ADD_INSNL(ret, line, branchif, 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
|
|
|
|
|
|
|
/* *flip == 0 */
|
|
|
|
COMPILE(ret, "flip2 beg", node->nd_beg);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
|
|
|
ADD_INSNL(ret, line, branchunless, lfin);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_FLIP3) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
|
|
|
ADD_INSN1(ret, line, setspecial, key);
|
|
|
|
ADD_INSNL(ret, line, jump, lfin);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSNL(ret, line, branchunless, ltrue);
|
|
|
|
ADD_INSN1(ret, line, putobject, Qfalse);
|
|
|
|
ADD_INSN1(ret, line, 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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, putself);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, Qtrue);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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_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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, 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
|
|
|
}
|
|
|
|
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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getlocal, 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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, getlocal, 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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
case NODE_DEFINED:{
|
2013-04-05 14:40:03 +04:00
|
|
|
if (poped) break;
|
|
|
|
if (!node->nd_head) {
|
|
|
|
VALUE str = rb_iseq_defined_string(DEFINED_NIL);
|
|
|
|
ADD_INSN1(ret, nd_line(node), putobject, str);
|
|
|
|
}
|
|
|
|
else {
|
2008-03-25 09:26:32 +03:00
|
|
|
LABEL *lfinish[2];
|
2013-03-07 09:17:04 +04:00
|
|
|
lfinish[0] = NEW_LABEL(line);
|
2008-03-25 09:26:32 +03:00
|
|
|
lfinish[1] = 0;
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
defined_expr(iseq, ret, node->nd_head, lfinish, Qtrue);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_INSN(ret, line, pop);
|
2008-03-25 09:26:32 +03:00
|
|
|
if (lfinish[1]) {
|
|
|
|
ADD_LABEL(ret, lfinish[1]);
|
|
|
|
}
|
|
|
|
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:{
|
2013-08-22 10:50:42 +04:00
|
|
|
/* compiled to:
|
|
|
|
* ONCE{ rb_mRubyVMFrozenCore::core#set_postexe{ ... } }
|
|
|
|
*/
|
2013-08-20 21:41:13 +04:00
|
|
|
int is_index = iseq->is_size++;
|
2013-08-22 10:50:42 +04:00
|
|
|
VALUE once_iseq = NEW_CHILD_ISEQVAL(
|
|
|
|
NEW_IFUNC(build_postexe_iseq, node->nd_body),
|
|
|
|
make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
|
2008-07-20 17:50:14 +04:00
|
|
|
|
2013-08-22 10:50:42 +04:00
|
|
|
ADD_INSN2(ret, line, once, once_iseq, INT2FIX(is_index));
|
2008-07-20 17:50:14 +04:00
|
|
|
|
2008-07-01 16:19:00 +04:00
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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;
|
2011-12-26 18:20:09 +04:00
|
|
|
}
|
|
|
|
case NODE_KW_ARG:{
|
2013-03-07 09:17:04 +04:00
|
|
|
LABEL *default_label = NEW_LABEL(line);
|
2013-03-12 17:20:50 +04:00
|
|
|
LABEL *end_label = 0;
|
2011-12-26 18:20:09 +04:00
|
|
|
int idx, lv, ls;
|
|
|
|
ID id = node->nd_body->nd_vid;
|
|
|
|
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
|
|
|
ADD_INSN1(ret, line, putobject, ID2SYM(id));
|
|
|
|
ADD_SEND(ret, line, ID2SYM(rb_intern("key?")), INT2FIX(1));
|
|
|
|
ADD_INSNL(ret, line, branchunless, default_label);
|
|
|
|
ADD_INSN(ret, line, dup);
|
|
|
|
ADD_INSN1(ret, line, putobject, ID2SYM(id));
|
|
|
|
ADD_SEND(ret, line, ID2SYM(rb_intern("delete")), INT2FIX(1));
|
2011-12-26 18:20:09 +04:00
|
|
|
switch (nd_type(node->nd_body)) {
|
2012-03-13 17:00:17 +04:00
|
|
|
case NODE_LASGN:
|
|
|
|
idx = iseq->local_iseq->local_size - get_local_var_idx(iseq, id);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, setlocal, INT2FIX(idx), INT2FIX(get_lvar_level(iseq)));
|
2012-03-13 17:00:17 +04:00
|
|
|
break;
|
|
|
|
case NODE_DASGN:
|
|
|
|
case NODE_DASGN_CURR:
|
|
|
|
idx = get_dyna_var_idx(iseq, id, &lv, &ls);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN2(ret, line, setlocal, INT2FIX(ls - idx), INT2FIX(lv));
|
2012-03-13 17:00:17 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rb_bug("iseq_compile_each (NODE_KW_ARG): unknown node: %s", ruby_node_name(nd_type(node->nd_body)));
|
2011-12-26 18:20:09 +04:00
|
|
|
}
|
2013-03-12 17:20:50 +04:00
|
|
|
if (node->nd_body->nd_value != (NODE *)-1) {
|
|
|
|
end_label = NEW_LABEL(nd_line(node));
|
|
|
|
ADD_INSNL(ret, nd_line(node), jump, end_label);
|
|
|
|
}
|
2011-12-26 18:20:09 +04:00
|
|
|
ADD_LABEL(ret, default_label);
|
2013-03-12 17:20:50 +04:00
|
|
|
if (node->nd_body->nd_value != (NODE *)-1) {
|
|
|
|
COMPILE_POPED(ret, "keyword default argument", node->nd_body);
|
|
|
|
ADD_LABEL(ret, end_label);
|
|
|
|
}
|
2011-12-26 18:20:09 +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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND(ret, line, ID2SYM(idIntern), 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 {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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_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);
|
2010-10-31 04:42:54 +03:00
|
|
|
VALUE 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
|
|
|
|
2014-01-10 08:54:08 +04:00
|
|
|
/* optimization shortcut
|
|
|
|
* obj["literal"] = value -> opt_aset_with(obj, "literal", value)
|
|
|
|
*/
|
2014-06-06 10:05:19 +04:00
|
|
|
if (node->nd_mid == idASET && !private_recv_p(node) && node->nd_args &&
|
2014-01-10 08:54:08 +04:00
|
|
|
nd_type(node->nd_args) == NODE_ARRAY && node->nd_args->nd_alen == 2 &&
|
|
|
|
nd_type(node->nd_args->nd_head) == NODE_STR)
|
|
|
|
{
|
|
|
|
VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
|
|
|
|
node->nd_args->nd_head->nd_lit = str;
|
2014-01-25 09:17:17 +04:00
|
|
|
iseq_add_mark_object(iseq, str);
|
2014-01-10 08:54:08 +04:00
|
|
|
COMPILE(ret, "recv", node->nd_recv);
|
|
|
|
COMPILE(ret, "value", node->nd_args->nd_next->nd_head);
|
2014-01-25 09:21:07 +04:00
|
|
|
if (!poped) {
|
|
|
|
ADD_INSN(ret, line, swap);
|
|
|
|
ADD_INSN1(ret, line, topn, INT2FIX(1));
|
|
|
|
}
|
2014-01-10 08:54:08 +04:00
|
|
|
ADD_INSN2(ret, line, opt_aset_with,
|
|
|
|
new_callinfo(iseq, idASET, 2, 0, 0), str);
|
2014-01-25 09:21:07 +04:00
|
|
|
ADD_INSN(ret, line, pop);
|
2014-01-10 08:54:08 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-07-20 11:11:35 +04:00
|
|
|
INIT_ANCHOR(recv);
|
|
|
|
INIT_ANCHOR(args);
|
2010-12-21 00:10:24 +03:00
|
|
|
argc = setup_args(iseq, args, node->nd_args, &flag);
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2014-06-06 12:07:13 +04:00
|
|
|
flag |= COMPILE_RECV(recv, "recv", 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("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) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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
|
|
|
ADD_SEQ(ret, recv);
|
|
|
|
ADD_SEQ(ret, args);
|
2007-07-03 22:58:42 +04:00
|
|
|
|
2012-10-15 21:22:57 +04:00
|
|
|
if (flag & VM_CALL_ARGS_BLOCKARG) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, topn, INT2FIX(1));
|
2012-10-15 21:22:57 +04:00
|
|
|
if (flag & VM_CALL_ARGS_SPLAT) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
|
|
|
|
ADD_SEND(ret, line, ID2SYM(idAREF), INT2FIX(1));
|
2011-06-17 14:18:39 +04:00
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 3));
|
|
|
|
ADD_INSN (ret, line, pop);
|
2007-07-03 22:58:42 +04:00
|
|
|
}
|
2012-10-15 21:22:57 +04:00
|
|
|
else if (flag & VM_CALL_ARGS_SPLAT) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, dup);
|
|
|
|
ADD_INSN1(ret, line, putobject, INT2FIX(-1));
|
|
|
|
ADD_SEND(ret, line, ID2SYM(idAREF), INT2FIX(1));
|
|
|
|
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 2));
|
|
|
|
ADD_INSN (ret, line, pop);
|
2011-06-17 14:18:39 +04:00
|
|
|
}
|
2007-07-03 22:58:42 +04:00
|
|
|
else {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, setn, FIXNUM_INC(argc, 1));
|
2009-09-05 09:34:56 +04:00
|
|
|
}
|
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);
|
|
|
|
}
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_SEND_R(ret, line, ID2SYM(node->nd_mid), argc, 0, LONG2FIX(flag));
|
|
|
|
ADD_INSN(ret, line, 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_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{...} */
|
2013-03-07 09:17:04 +04:00
|
|
|
VALUE block = NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
|
* compile.c, dir.c, eval.c, eval_jump.h, eval_method.h, numeric.c,
pack.c, parse.y, re.c, thread.c, vm.c, vm_dump.c, call_cfunc.ci,
thread_pthread.ci, thread_win32.ci: fixed indentation.
git-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);
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
|
|
|
|
ADD_CALL_WITH_BLOCK(ret, line, ID2SYM(idLambda), argc, 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
|
|
|
|
|
|
|
if (poped) {
|
2013-03-07 09:17:04 +04:00
|
|
|
ADD_INSN(ret, line, 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;
|
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
|
|
|
}
|
|
|
|
|
2013-02-28 18:04:53 +04:00
|
|
|
/* check & remove redundant trace(line) */
|
|
|
|
if (saved_last_element && ret /* ret can be 0 when error */ &&
|
|
|
|
ret->last == saved_last_element &&
|
|
|
|
((INSN *)saved_last_element)->insn_id == BIN(trace)) {
|
|
|
|
POP_ELEMENT(ret);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-11-29 15:45:40 +04:00
|
|
|
static VALUE
|
|
|
|
opobj_inspect(VALUE obj)
|
2006-12-31 18:02:22 +03:00
|
|
|
{
|
2013-11-29 15:45:40 +04:00
|
|
|
struct RBasic *r = (struct RBasic *) obj;
|
|
|
|
if (!SPECIAL_CONST_P(r) && r->klass == 0) {
|
|
|
|
switch (BUILTIN_TYPE(r)) {
|
|
|
|
case T_STRING:
|
|
|
|
obj = rb_str_new_cstr(RSTRING_PTR(obj));
|
|
|
|
break;
|
|
|
|
case T_ARRAY:
|
|
|
|
obj = rb_ary_dup(obj);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rb_inspect(obj);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2013-11-29 15:45:40 +04:00
|
|
|
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static VALUE
|
|
|
|
insn_data_to_s_detail(INSN *iobj)
|
|
|
|
{
|
2013-11-29 15:45:40 +04:00
|
|
|
VALUE str = rb_sprintf("%-20s ", 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;
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
if (0 && iseq) { /* TODO: invalidate now */
|
2006-12-31 18:02:22 +03:00
|
|
|
val = iseq->self;
|
|
|
|
}
|
2013-11-29 15:45:40 +04:00
|
|
|
rb_str_concat(str, opobj_inspect(val));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TS_LINDEX:
|
|
|
|
case TS_NUM: /* ulong */
|
|
|
|
case TS_VALUE: /* VALUE */
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
{
|
|
|
|
VALUE v = OPERAND_AT(iobj, j);
|
2013-11-29 15:45:40 +04:00
|
|
|
rb_str_concat(str, opobj_inspect(v));
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
break;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
case TS_ID: /* ID */
|
2013-11-29 15:45:40 +04:00
|
|
|
rb_str_concat(str, opobj_inspect(OPERAND_AT(iobj, j)));
|
2006-12-31 18:02:22 +03:00
|
|
|
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));
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
2012-10-09 09:33:54 +04:00
|
|
|
case TS_IC: /* inline cache */
|
2010-02-24 20:06:15 +03:00
|
|
|
rb_str_catf(str, "<ic:%d>", FIX2INT(OPERAND_AT(iobj, j)));
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
2012-10-09 09:33:54 +04:00
|
|
|
case TS_CALLINFO: /* call info */
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
{
|
|
|
|
rb_call_info_t *ci = (rb_call_info_t *)OPERAND_AT(iobj, j);
|
|
|
|
rb_str_catf(str, "<callinfo:%s, %d>", ci->mid ? rb_id2name(ci->mid) : "", ci->orig_argc);
|
|
|
|
break;
|
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
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);
|
2013-11-29 15:45:40 +04:00
|
|
|
printf("%04d %-65s(%4d)\n", pos, StringValueCStr(str), iobj->line_no);
|
2006-12-31 18:02:22 +03:00
|
|
|
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;
|
2013-11-29 15:45:40 +04:00
|
|
|
printf("adjust: [label: %d]\n", adjust->label ? adjust->label->label_no : -1);
|
2008-01-26 11:27:00 +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 */
|
* 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");
|
|
|
|
}
|
|
|
|
|
* probes.d: add DTrace probe declarations. [ruby-core:27448]
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.
* compile.c (rb_insns_name): allowing DTrace probes to access
instruction sequence name.
* Makefile.in: translate probes.d file to appropriate header file.
* common.mk: declare dependencies on the DTrace header.
* configure.in: add a test for existence of DTrace.
* eval.c (setup_exception): add a probe for when an exception is
raised.
* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
end.
* hash.c (empty_hash_alloc): Add a probe for hash allocation.
* insns.def: Add probes for function entry and return.
* internal.h: function declaration for compile.c change.
* load.c (rb_f_load): add probes for `load` entry and exit, require
entry and exit, and wrapping search_required for load path search.
* object.c (rb_obj_alloc): added a probe for general object creation.
* parse.y (yycompile0): added a probe around parse and compile phase.
* string.c (empty_str_alloc, str_new): DTrace probes for string
allocation.
* test/dtrace/*: tests for DTrace probes.
* vm.c (vm_invoke_proc): add probes for function return on exception
raise, hash create, and instruction sequence execution.
* vm_core.h: add probe declarations for function entry and exit.
* vm_dump.c: add probes header file.
* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
function entry and return.
* vm_exec.c: expose instruction number to instruction name function.
* vm_insnshelper.c: add function entry and exit probes for cfunc
methods.
* vm_insnhelper.h: vm usage information is always collected, so
uncomment the functions.
12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org>
* configure.in (isinf, isnan): isinf() and isnan() are macros on
DragonFly which cannot be found by AC_REPLACE_FUNCS(). This
workaround enforces the fact that they exist on DragonFly.
12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org>
* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
vm_insnhelper.c (vm_search_method): revert r37616 because it's too
slow. [ruby-dev:46477]
* test/ruby/test_refinement.rb (test_inline_method_cache): skip
the test until the bug is fixed efficiently.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-13 01:52:12 +04:00
|
|
|
const char *
|
|
|
|
rb_insns_name(int i)
|
|
|
|
{
|
|
|
|
return insn_name_info[i];
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
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++) {
|
2013-11-27 03:30:25 +04:00
|
|
|
rb_ary_push(ary, rb_fstring(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)
|
2011-02-17 18:32:55 +03:00
|
|
|
VALUE sym_inspect;
|
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;
|
2010-10-31 04:42:54 +03:00
|
|
|
if (sym == symRedo) return CATCH_TYPE_REDO;
|
2006-12-31 18:02:22 +03:00
|
|
|
if (sym == symNext) return CATCH_TYPE_NEXT;
|
2011-02-17 18:32:55 +03:00
|
|
|
sym_inspect = rb_inspect(sym);
|
* 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",
|
2011-02-20 10:23:55 +03:00
|
|
|
StringValuePtr(sym_inspect));
|
2006-12-31 18:02:22 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-10-31 04:42:54 +03:00
|
|
|
iseq_build_from_ary_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++) {
|
2013-11-08 06:00:35 +04:00
|
|
|
VALUE v, type, eiseqval;
|
|
|
|
const VALUE *ptr;
|
2006-12-31 18:02:22 +03:00
|
|
|
LABEL *lstart, *lend, *lcont;
|
|
|
|
int sp;
|
|
|
|
|
2013-05-13 13:56:22 +04:00
|
|
|
RB_GC_GUARD(v) = rb_convert_type(RARRAY_AREF(exception, i), T_ARRAY,
|
* 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
|
|
|
"Array", "to_ary");
|
|
|
|
if (RARRAY_LEN(v) != 6) {
|
|
|
|
rb_raise(rb_eSyntaxError, "wrong exception entry");
|
|
|
|
}
|
2013-11-08 06:00:35 +04:00
|
|
|
ptr = RARRAY_CONST_PTR(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
|
|
|
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]);
|
|
|
|
|
* bignum.c (big_rshift), compile.c (validate_label,
iseq_build_from_ary_exception), cont.c (cont_capture), dir.c
(dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open)
(rb_io_advise), parse.y (parser_compile_string)
(rb_parser_compile_file), proc.c (binding_free), process.c
(rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core)
(p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null),
signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main),
vm_insnhelper.c (vm_expandarray): suppress
unused-but-set-variable warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 13:57:00 +04:00
|
|
|
(void)sp;
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
static VALUE
|
|
|
|
iseq_build_load_iseq(rb_iseq_t *iseq, VALUE op)
|
|
|
|
{
|
|
|
|
VALUE iseqval;
|
|
|
|
if (RB_TYPE_P(op, T_ARRAY)) {
|
|
|
|
iseqval = rb_iseq_load(op, iseq->self, Qnil);
|
|
|
|
}
|
|
|
|
else if (CLASS_OF(op) == rb_cISeq) {
|
|
|
|
iseqval = op;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb_raise(rb_eSyntaxError, "ISEQ is required");
|
|
|
|
}
|
|
|
|
iseq_add_mark_object(iseq, iseqval);
|
|
|
|
return iseqval;
|
|
|
|
}
|
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
static int
|
2010-10-31 04:42:54 +03:00
|
|
|
iseq_build_from_ary_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 */
|
2013-11-08 06:00:35 +04:00
|
|
|
const VALUE *ptr = RARRAY_CONST_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;
|
2011-08-24 10:31:15 +04:00
|
|
|
|
2006-12-31 18:02:22 +03:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|
2011-09-29 15:07:45 +04:00
|
|
|
else if (RB_TYPE_P(obj, T_ARRAY)) {
|
2006-12-31 18:02:22 +03:00
|
|
|
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;
|
* compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
(syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
(run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
(rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
thread.c (rb_thread_local_aref),
variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
(rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
ext/iconv/iconv.c (map_charset): use st_data_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 18:47:23 +04:00
|
|
|
st_data_t insn_id;
|
2007-07-02 01:43:30 +04:00
|
|
|
VALUE insn;
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2013-05-13 13:56:22 +04:00
|
|
|
insn = (argc < 0) ? Qnil : RARRAY_AREF(obj, 0);
|
* compile.c (iseq_build_body), error.c (set_syserr, get_syserr),
(syserr_initialize), gc.c (define_final, rb_gc_copy_finalizer),
(run_final), hash.c (rb_hash_aref, rb_hash_lookup2),
(rb_hash_fetch_m, rb_hash_clear, rb_hash_aset, eql_i),
iseq.c (iseq_load, iseq_data_to_ary), marshal.c (r_symlink),
thread.c (rb_thread_local_aref),
variable.c (generic_ivar_remove, ivar_get, rb_const_get_0),
(rb_cvar_get), vm.c (rb_vm_check_redefinition_opt_method),
vm_insnhelper.c (vm_get_ev_const), vm_method.c (remove_method),
ext/iconv/iconv.c (map_charset): use st_data_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-12 18:47:23 +04:00
|
|
|
if (st_lookup(insn_table, (st_data_t)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);
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), line_no,
|
* 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
|
|
|
"unknown instruction: %s", RSTRING_PTR(insn));
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
|
2010-10-12 18:35:40 +04:00
|
|
|
if (argc != insn_len((VALUE)insn_id)-1) {
|
2012-06-04 06:49:37 +04:00
|
|
|
rb_compile_error(RSTRING_PTR(iseq->location.path), line_no,
|
* 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
|
|
|
"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);
|
2010-10-12 18:35:40 +04:00
|
|
|
switch (insn_op_type((VALUE)insn_id, j)) {
|
2006-12-31 18:02:22 +03:00
|
|
|
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_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) {
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
argv[j] = iseq_build_load_iseq(iseq, op);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
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:
|
2010-02-24 20:06:15 +03:00
|
|
|
argv[j] = op;
|
2013-08-20 21:41:13 +04:00
|
|
|
if (NUM2INT(op) >= iseq->is_size) {
|
|
|
|
iseq->is_size = NUM2INT(op) + 1;
|
2012-10-09 09:33:54 +04:00
|
|
|
}
|
2006-12-31 18:02:22 +03:00
|
|
|
break;
|
2012-10-09 09:33:54 +04:00
|
|
|
case TS_CALLINFO:
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
{
|
|
|
|
ID mid = 0;
|
|
|
|
int orig_argc = 0;
|
|
|
|
VALUE block = 0;
|
|
|
|
unsigned long flag = 0;
|
|
|
|
|
|
|
|
if (!NIL_P(op)) {
|
|
|
|
VALUE vmid = rb_hash_aref(op, ID2SYM(rb_intern("mid")));
|
|
|
|
VALUE vflag = rb_hash_aref(op, ID2SYM(rb_intern("flag")));
|
|
|
|
VALUE vorig_argc = rb_hash_aref(op, ID2SYM(rb_intern("orig_argc")));
|
2014-01-28 03:56:22 +04:00
|
|
|
VALUE vblock = rb_hash_aref(op, ID2SYM(rb_intern("blockptr")));
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
|
|
|
|
if (!NIL_P(vmid)) mid = SYM2ID(vmid);
|
|
|
|
if (!NIL_P(vflag)) flag = NUM2ULONG(vflag);
|
|
|
|
if (!NIL_P(vorig_argc)) orig_argc = FIX2INT(vorig_argc);
|
|
|
|
if (!NIL_P(vblock)) block = iseq_build_load_iseq(iseq, vblock);
|
|
|
|
}
|
|
|
|
argv[j] = (VALUE)new_callinfo(iseq, mid, orig_argc, block, flag);
|
2012-10-09 09:33:54 +04:00
|
|
|
}
|
* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:
use only a `ci' (rb_call_info_t) parameter instead of using
parameters such as `op_id', 'op_argc', `blockiseq' and flag.
These information are stored in rb_call_info_t at the compile
time.
This technique simplifies parameter passings at related
function calls (~10% speedups for simple mehtod invocation at
my machine).
`rb_call_info_t' also has new function pointer variable `call'.
This `call' variable enables to customize method (block)
invocation process for each place. However, it always call
`vm_call_general()' at this changes.
`rb_call_info_t' also has temporary variables for method
(block) invocation.
* vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP
VM_CALL macro. This flag indicates that this call can skip
caller_setup (block arg and splat arg).
* compile.c: catch up above changes.
* iseq.c: catch up above changes (especially for TS_CALLINFO).
* tool/instruction.rb: catch up above chagnes.
* vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions
parameters are changed.
* vm_eval.c (vm_call0): ditto (it will be rewriten soon).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14 20:59:05 +04:00
|
|
|
break;
|
2006-12-31 18:02:22 +03:00
|
|
|
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;
|
2010-03-17 20:33:01 +03:00
|
|
|
iseq_add_mark_object_compile_time(iseq, op);
|
2006-12-31 18:02:22 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2010-10-12 18:35:40 +04:00
|
|
|
rb_raise(rb_eSyntaxError, "unknown operand: %c", insn_op_type((VALUE)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");
|
|
|
|
}
|
|
|
|
}
|
2010-12-12 17:45:30 +03:00
|
|
|
validate_labels(iseq, labels_table);
|
2006-12-31 18:02:22 +03:00
|
|
|
st_free_table(labels_table);
|
|
|
|
iseq_setup(iseq, anchor);
|
|
|
|
return COMPILE_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-03 00:53:08 +03: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")
|
2010-07-27 11:13:43 +04:00
|
|
|
static inline VALUE CHECK_INTEGER(VALUE v) {(void)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);
|
2010-11-15 17:44:19 +03: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++) {
|
2013-05-13 13:56:22 +04:00
|
|
|
VALUE lv = RARRAY_AREF(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 */
|
2010-10-31 04:42:54 +03:00
|
|
|
iseq_build_from_ary_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 */
|
2010-10-31 04:42:54 +03:00
|
|
|
iseq_build_from_ary_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;
|
|
|
|
}
|