2006-12-31 10:02:22 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
blockinlining.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
|
|
|
|
Copyright (C) 2004-2006 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#include "ruby/ruby.h"
|
|
|
|
#include "ruby/node.h"
|
2006-12-31 10:02:22 -05:00
|
|
|
#include "yarvcore.h"
|
|
|
|
|
|
|
|
VALUE yarv_new_iseqval(VALUE node, VALUE name, VALUE file,
|
|
|
|
VALUE parent, VALUE type, VALUE block_opt, VALUE opt);
|
|
|
|
|
|
|
|
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 14:00:03 -05:00
|
|
|
yarv_iseq_special_block(rb_iseq_t *iseq, void *builder)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
#if OPT_BLOCKINLINING
|
|
|
|
VALUE parent = Qfalse;
|
|
|
|
VALUE iseqval;
|
|
|
|
|
|
|
|
if (iseq->argc > 1 || iseq->arg_simple == 0) {
|
|
|
|
/* argument check */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iseq->cached_special_block_builder) {
|
|
|
|
if (iseq->cached_special_block_builder == builder) {
|
|
|
|
return iseq->cached_special_block;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iseq->cached_special_block_builder = (void *)1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iseq->parent_iseq) {
|
|
|
|
parent = iseq->parent_iseq->self;
|
|
|
|
}
|
2007-02-24 20:34:33 -05:00
|
|
|
iseqval = rb_iseq_new_with_bopt(iseq->node, iseq->name, iseq->filename,
|
2006-12-31 10:02:22 -05:00
|
|
|
parent, iseq->type,
|
|
|
|
GC_GUARDED_PTR(builder));
|
|
|
|
if (0) {
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
printf("%s\n", RSTRING_PTR(ruby_iseq_disasm(iseqval)));
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
iseq->cached_special_block = iseqval;
|
|
|
|
iseq->cached_special_block_builder = builder;
|
|
|
|
return iseqval;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
|
|
|
new_block(NODE * head, NODE * tail)
|
|
|
|
{
|
|
|
|
head = NEW_BLOCK(head);
|
|
|
|
tail = NEW_BLOCK(tail);
|
|
|
|
head->nd_next = tail;
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
|
|
|
new_ary(NODE * head, NODE * tail)
|
|
|
|
{
|
|
|
|
head = NEW_ARRAY(head);
|
|
|
|
head->nd_next = tail;
|
|
|
|
return head;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
|
|
|
new_assign(NODE * lnode, NODE * rhs)
|
|
|
|
{
|
|
|
|
switch (nd_type(lnode)) {
|
|
|
|
case NODE_LASGN:{
|
|
|
|
return NEW_NODE(NODE_LASGN, lnode->nd_vid, rhs, lnode->nd_cnt);
|
|
|
|
/* NEW_LASGN(lnode->nd_vid, rhs); */
|
|
|
|
}
|
|
|
|
case NODE_GASGN:{
|
|
|
|
return NEW_GASGN(lnode->nd_vid, rhs);
|
|
|
|
}
|
|
|
|
case NODE_DASGN:{
|
|
|
|
return NEW_DASGN(lnode->nd_vid, rhs);
|
|
|
|
}
|
|
|
|
case NODE_ATTRASGN:{
|
|
|
|
NODE *args = 0;
|
|
|
|
if (lnode->nd_args) {
|
|
|
|
args = NEW_ARRAY(lnode->nd_args->nd_head);
|
|
|
|
args->nd_next = NEW_ARRAY(rhs);
|
|
|
|
args->nd_alen = 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
args = NEW_ARRAY(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NEW_ATTRASGN(lnode->nd_recv,
|
|
|
|
lnode->nd_mid,
|
|
|
|
args);
|
|
|
|
}
|
|
|
|
default:
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
rb_bug("unimplemented (block inlining): %s", ruby_node_name(nd_type(lnode)));
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* 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 14:00:03 -05:00
|
|
|
build_Integer_times_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
/* Special Block for Integer#times
|
|
|
|
{|e, _self|
|
|
|
|
_e = e
|
|
|
|
while(e < _self)
|
|
|
|
e = _e
|
|
|
|
redo_point:
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
_e = _e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
{|e, _self|
|
|
|
|
while(e < _self)
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
e = e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
ID _self = rb_intern("#_self");
|
|
|
|
if (iseq->argc == 0) {
|
|
|
|
ID e = rb_intern("#e");
|
|
|
|
rb_ary_push(param_vars, ID2SYM(e));
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
iseq->argc += 2;
|
|
|
|
|
|
|
|
node =
|
|
|
|
NEW_WHILE(NEW_CALL
|
|
|
|
(NEW_DVAR(e), idLT, new_ary(NEW_DVAR(_self), 0)),
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(e,
|
|
|
|
NEW_CALL(NEW_DVAR(e), idSucc, 0))),
|
|
|
|
Qundef);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ID _e = rb_intern("#_e");
|
|
|
|
ID e = SYM2ID(rb_ary_entry(param_vars, 0));
|
|
|
|
NODE *assign;
|
|
|
|
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_e));
|
|
|
|
iseq->argc++;
|
|
|
|
|
|
|
|
if (nd_type(lnode) == NODE_DASGN_CURR) {
|
|
|
|
assign = NEW_DASGN(e, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assign = new_assign(lnode, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_e, NEW_DVAR(e)),
|
|
|
|
NEW_WHILE(NEW_CALL
|
|
|
|
(NEW_DVAR(_e), idLT,
|
|
|
|
new_ary(NEW_DVAR(_self), 0)),
|
|
|
|
new_block(assign,
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(_e,
|
|
|
|
NEW_CALL
|
|
|
|
(NEW_DVAR(_e),
|
|
|
|
idSucc, 0)))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
yarv_invoke_Integer_times_special_block(VALUE num)
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th = GET_THREAD();
|
* 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 14:00:03 -05:00
|
|
|
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
if (orig_block && BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
|
|
|
|
VALUE tsiseqval = yarv_iseq_special_block(orig_block->iseq,
|
|
|
|
build_Integer_times_node);
|
* 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 14:00:03 -05:00
|
|
|
rb_iseq_t *tsiseq;
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE argv[2], val;
|
|
|
|
|
|
|
|
if (tsiseqval) {
|
* 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 14:00:03 -05:00
|
|
|
rb_block_t block = *orig_block;
|
2006-12-31 10:02:22 -05:00
|
|
|
GetISeqPtr(tsiseqval, tsiseq);
|
|
|
|
block.iseq = tsiseq;
|
|
|
|
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
|
|
|
|
argv[0] = INT2FIX(0);
|
|
|
|
argv[1] = num;
|
* 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 11:42:41 -04:00
|
|
|
val = vm_yield(th, 2, argv);
|
2006-12-31 10:02:22 -05:00
|
|
|
if (val == Qundef) {
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Qundef;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* 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 14:00:03 -05:00
|
|
|
build_Range_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE param_vars, VALUE local_vars, ID mid)
|
|
|
|
{
|
|
|
|
/* Special Block for Range#each
|
|
|
|
{|e, _last|
|
|
|
|
_e = e
|
|
|
|
while _e < _last
|
|
|
|
e = _e
|
|
|
|
next_point:
|
|
|
|
BODY
|
|
|
|
redo_point:
|
|
|
|
_e = _e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
{|e, _last|
|
|
|
|
while e < _last
|
|
|
|
BODY
|
|
|
|
redo_point:
|
|
|
|
e = e.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
ID _last = rb_intern("#_last");
|
|
|
|
if (iseq->argc == 0) {
|
|
|
|
ID e = rb_intern("#e");
|
|
|
|
rb_ary_push(param_vars, ID2SYM(e));
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_last));
|
|
|
|
iseq->argc += 2;
|
|
|
|
|
|
|
|
node =
|
|
|
|
NEW_WHILE(NEW_CALL(NEW_DVAR(e), mid, new_ary(NEW_DVAR(_last), 0)),
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(e,
|
|
|
|
NEW_CALL(NEW_DVAR(e), idSucc, 0))),
|
|
|
|
Qundef);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ID _e = rb_intern("#_e");
|
|
|
|
ID e = SYM2ID(rb_ary_entry(param_vars, 0));
|
|
|
|
NODE *assign;
|
|
|
|
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_last));
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_e));
|
|
|
|
iseq->argc++;
|
|
|
|
|
|
|
|
if (nd_type(lnode) == NODE_DASGN_CURR) {
|
|
|
|
assign = NEW_DASGN(e, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assign = new_assign(lnode, NEW_DVAR(_e));
|
|
|
|
}
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_e, NEW_DVAR(e)),
|
|
|
|
NEW_WHILE(NEW_CALL
|
|
|
|
(NEW_DVAR(_e), mid,
|
|
|
|
new_ary(NEW_DVAR(_last), 0)),
|
|
|
|
new_block(assign,
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(_e,
|
|
|
|
NEW_CALL
|
|
|
|
(NEW_DVAR(_e),
|
|
|
|
idSucc, 0)))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* 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 14:00:03 -05:00
|
|
|
build_Range_each_node_LE(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
return build_Range_each_node(iseq, node, lnode,
|
|
|
|
param_vars, local_vars, idLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static NODE *
|
* 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 14:00:03 -05:00
|
|
|
build_Range_each_node_LT(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
return build_Range_each_node(iseq, node, lnode,
|
|
|
|
param_vars, local_vars, idLT);
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
yarv_invoke_Range_each_special_block(VALUE range,
|
|
|
|
VALUE beg, VALUE end, int excl)
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th = GET_THREAD();
|
* 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 14:00:03 -05:00
|
|
|
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
|
|
|
|
void *builder =
|
|
|
|
excl ? build_Range_each_node_LT : build_Range_each_node_LE;
|
|
|
|
VALUE tsiseqval = yarv_iseq_special_block(orig_block->iseq, builder);
|
* 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 14:00:03 -05:00
|
|
|
rb_iseq_t *tsiseq;
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE argv[2];
|
|
|
|
|
|
|
|
if (tsiseqval) {
|
|
|
|
VALUE val;
|
* 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 14:00:03 -05:00
|
|
|
rb_block_t block = *orig_block;
|
2006-12-31 10:02:22 -05:00
|
|
|
GetISeqPtr(tsiseqval, tsiseq);
|
|
|
|
block.iseq = tsiseq;
|
|
|
|
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
|
|
|
|
argv[0] = beg;
|
|
|
|
argv[1] = end;
|
* 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 11:42:41 -04:00
|
|
|
val = vm_yield(th, 2, argv);
|
2006-12-31 10:02:22 -05:00
|
|
|
if (val == Qundef) {
|
|
|
|
return range;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Qundef;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NODE *
|
* 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 14:00:03 -05:00
|
|
|
build_Array_each_node(rb_iseq_t *iseq, NODE * node, NODE * lnode,
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE param_vars, VALUE local_vars)
|
|
|
|
{
|
|
|
|
/* Special block for Array#each
|
|
|
|
ary.each{|e|
|
|
|
|
BODY
|
|
|
|
}
|
|
|
|
=>
|
|
|
|
{|e, _self|
|
|
|
|
_i = 0
|
|
|
|
while _i < _self.length
|
|
|
|
e = _self[_i]
|
|
|
|
redo_point:
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
_i = _i.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
ary.each{
|
|
|
|
BODY
|
|
|
|
}
|
|
|
|
=>
|
|
|
|
{|_i, _self|
|
|
|
|
_i = 0
|
|
|
|
while _i < _self.length
|
|
|
|
redo_point:
|
|
|
|
BODY
|
|
|
|
next_point:
|
|
|
|
_i = _i.succ
|
|
|
|
end
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
ID _self = rb_intern("#_self");
|
|
|
|
ID _i = rb_intern("#_i");
|
|
|
|
|
|
|
|
if (iseq->argc == 0) {
|
|
|
|
ID _e = rb_intern("#_e");
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_e));
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
iseq->argc += 2;
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_i));
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_i, NEW_LIT(INT2FIX(0))),
|
|
|
|
NEW_WHILE(NEW_CALL(NEW_DVAR(_i), idLT,
|
|
|
|
new_ary(NEW_CALL
|
|
|
|
(NEW_DVAR(_self), idLength,
|
|
|
|
0), 0)),
|
|
|
|
new_block(NEW_OPTBLOCK(node),
|
|
|
|
NEW_DASGN(_i,
|
|
|
|
NEW_CALL(NEW_DVAR(_i),
|
|
|
|
idSucc, 0))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ID e = SYM2ID(rb_ary_entry(param_vars, 0));
|
|
|
|
NODE *assign;
|
|
|
|
|
|
|
|
rb_ary_push(param_vars, ID2SYM(_self));
|
|
|
|
iseq->argc++;
|
|
|
|
rb_ary_push(local_vars, ID2SYM(_i));
|
|
|
|
|
|
|
|
if (nd_type(lnode) == NODE_DASGN_CURR) {
|
|
|
|
assign = NEW_DASGN(e,
|
|
|
|
NEW_CALL(NEW_DVAR(_self), idAREF,
|
|
|
|
new_ary(NEW_DVAR(_i), 0)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assign = new_assign(lnode,
|
|
|
|
NEW_CALL(NEW_DVAR(_self), idAREF,
|
|
|
|
new_ary(NEW_DVAR(_i), 0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
node =
|
|
|
|
new_block(NEW_DASGN(_i, NEW_LIT(INT2FIX(0))),
|
|
|
|
NEW_WHILE(NEW_CALL(NEW_DVAR(_i), idLT,
|
|
|
|
new_ary(NEW_CALL
|
|
|
|
(NEW_DVAR(_self), idLength,
|
|
|
|
0), 0)), new_block(assign,
|
|
|
|
new_block
|
|
|
|
(NEW_OPTBLOCK
|
|
|
|
(node),
|
|
|
|
NEW_DASGN
|
|
|
|
(_i,
|
|
|
|
NEW_CALL
|
|
|
|
(NEW_DVAR
|
|
|
|
(_i),
|
|
|
|
idSucc,
|
|
|
|
0)))),
|
|
|
|
Qundef));
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
VALUE
|
|
|
|
yarv_invoke_Array_each_special_block(VALUE ary)
|
|
|
|
{
|
* blockinlining.c, error.c, eval.c, eval_error.h, eval_intern.h,
eval_jump.h, eval_load.c, eval_safe.h, gc.c, proc.c, signal.c,
thread.c, thread_pthread.ci, thread_win32.ci, vm.c, vm.h,
vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fix typo (rb_thead_t -> rb_thread_t).
* eval_intern.h: remove unused definitions.
* common.mk: fix around vm_opts.h path
and remove harmful argument passed to insns2vm.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-08 01:37:46 -05:00
|
|
|
rb_thread_t *th = GET_THREAD();
|
* 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 14:00:03 -05:00
|
|
|
rb_block_t *orig_block = GC_GUARDED_PTR_REF(th->cfp->lfp[0]);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
if (BUILTIN_TYPE(orig_block->iseq) != T_NODE) {
|
|
|
|
VALUE tsiseqval = yarv_iseq_special_block(orig_block->iseq,
|
|
|
|
build_Array_each_node);
|
* 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 14:00:03 -05:00
|
|
|
rb_iseq_t *tsiseq;
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE argv[2];
|
|
|
|
|
|
|
|
if (tsiseqval) {
|
|
|
|
VALUE val;
|
* 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 14:00:03 -05:00
|
|
|
rb_block_t block = *orig_block;
|
2006-12-31 10:02:22 -05:00
|
|
|
GetISeqPtr(tsiseqval, tsiseq);
|
|
|
|
block.iseq = tsiseq;
|
|
|
|
th->cfp->lfp[0] = GC_GUARDED_PTR(&block);
|
|
|
|
argv[0] = 0;
|
|
|
|
argv[1] = ary;
|
* 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 11:42:41 -04:00
|
|
|
val = vm_yield(th, 2, argv);
|
2006-12-31 10:02:22 -05:00
|
|
|
if (val == Qundef) {
|
|
|
|
return ary;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Qundef;
|
|
|
|
}
|