Commit graph

943 commits

Author SHA1 Message Date
nobu
cafb29479e * eval.c (load_lock): makes circular require deadlock.
[ruby-core:19821]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-11 18:49:45 +00:00
nobu
0be023cb6e * eval.c (rb_feature_p): returns found feature name if loading.
[ruby-core:19798]

* eval.c (search_required): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@20214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-11 14:54:14 +00:00
nobu
37a720e038 * eval.c (rb_mod_modfunc): method undefined in included module
may not have nd_body.  [ruby-core:18738]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@19690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-05 14:06:02 +00:00
matz
98183a08c7 * dln.c: newer BeOS support. a patch from Pete Goodeve
<pete.goodeve at computer.org> in [ruby-core:18712].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@19424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-19 00:32:22 +00:00
knu
6db402c258 * hash.c (rb_hash_set_default_proc): Add Hash#default_proc=;
submitted by Giuseppe Bilotta.  #420

* eval.c (rb_obj_is_proc), intern.h: Export rb_obj_is_proc().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 09:24:48 +00:00
matz
c27c68b8db * class.c (clone_method): should copy cbase in cref as well.
[ruby-dev:35116]

* node.h (NEW_CREF): new NEW_ macro.

* eval.c (PUSH_CREF): use NEW_CREF().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 05:42:31 +00:00
nobu
363cad3261 * gc.c (STACK_LEVEL_MAX, ruby_stack_length): returns size_t.
[ruby-core:18207]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-09 23:56:17 +00:00
nobu
22af450ebc * eval.c (timeofday): use monotonic clock. based on a patch
from zimbatm <zimbatm@oree.ch> in [ruby-core:16627].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-04 06:04:57 +00:00
nobu
42ec1fa621 * eval.c (rb_thread_schedule): runs deferred finalizers.
* gc.c (gc_sweep): sets rb_thread_pending to run deferred finalizers.

* rubysig.h (CHECK_INTS): now checks rb_thread_pending even on
  platforms where setitimer is not available.  [ruby-core:18045]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@18319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-02 07:08:18 +00:00
nobu
db391b5d66 * eval.c (rb_thread_value): missed to change at r17874. [ruby-core:17595]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-05 04:09:49 +00:00
nobu
cdd1d98ef2 * eval.c (rb_thread_join): new API.
* ext/thread/thread.c (wait_mutex, lock_mutex): wait until the locking
  thread exits.  [ruby-dev:34856]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-04 11:31:35 +00:00
nobu
86c58b7813 * error.c (rb_exc_new3): keeps the given string itself.
* eval.c (Init_Proc), gc.c (Init_GC): freeze messages of preallocated
  special exceptions also.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 22:03:24 +00:00
nobu
a9d25a31ee * eval.c (rb_longjmp): duplicate the thrown exception to set backtrace
if it was frozen.  clear all raised flags.

* eval.c (stack_check): leave clearing flag to rb_longjmp.

* eval.c (rb_thread_set_raised, rb_thread_reset_raised): use generic
  flags.

* eval.c (Init_Proc), gc.c (Init_GC): freeze preallocated special exceptions.

* gc.c (rb_memerror): use thread raised flag instead of static flag,
  and raise nomem_error without backtrace if failed to make backtrace.
  [ruby-dev:34724]

* gc.c (ruby_xmalloc): increase malloc_increase only if malloc
  succeeds.  failed malloc size can be huge.  it may increase
  malloc_limit too big which cause less GC and memory full.
  (ruby_xrealloc): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 21:17:31 +00:00
nobu
bf67d8a89b * eval.c (PUSH_FRAME): suppress warnings.
* eval.c (arg_defined): constified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-02 20:11:53 +00:00
akr
d85fc22700 * eval.c (rb_obj_respond_to): use RTEST to test the result of
respond_to? method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-28 15:14:30 +00:00
matz
4bbdc4c4d5 * eval.c (rb_call0): wrong condition to check insecure method.
a patch from Keita Yamaguchi <keita.yamaguchi at gmail.com>.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-26 08:50:47 +00:00
knu
2e8b16b48b * eval.c (PUSH_FRAME, PUSH_CLASS): Add volatile to avoid a
possible optimization bug on OS X/PPC.  This at least makes
  build with gcc -O1 and `make test' pass.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-23 11:01:00 +00:00
nobu
397ee1a315 * eval.c (rb_thread_select), string.c (str_gsub): suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-10 04:40:40 +00:00
nobu
1378795e08 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
knu
266be04a8d * eval.c (rb_mod_module_exec, Init_eval): Add
Module#{module_exec,class_exec}.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 07:03:21 +00:00
knu
42ef66d945 * eval.c (yield_under, yield_under_i, yield_args_under_i)
(specific_eval, rb_obj_instance_exec, Init_eval): Implement
  Object#instance_exec(), a 1.9 feature.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-26 01:13:53 +00:00
knu
258129588f * eval.c (Init_Thread): Initialize recursive_key.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 18:13:33 +00:00
matz
f513d9ab28 * marshal.c (reentrant_check): check reentrance via callcc.
[ruby-dev:34802]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-24 00:26:26 +00:00
knu
be5d23c22a * eval.c (rb_copy_node_scope), node.h: Rename from copy_node_scope
and export.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-22 15:49:42 +00:00
matz
255341597a * proc.c (proc_dup): should copy safe_level from src proc
properly.  a patch from Keita Yamaguchi
  <keita.yamaguchi at gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-21 20:50:16 +00:00
nobu
0590791d04 * eval.c (rb_get_method_body, rb_alias, rb_eval): should not cache
uninitialized value, since search_method doesn't set origin if the
  method wasn't found.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-21 14:31:47 +00:00
nobu
722ad8f214 * eval.c (search_method, remove_method, error_print, rb_alias)
(rb_eval, rb_rescue2, search_required, Init_eval, rb_thread_create),
  gc.c (rb_source_filename, Init_stack), io.c (rb_io_getline),
  parse.y (rb_id2name, rb_parser_free): suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-21 14:29:55 +00:00
matz
9193324a10 * eval.c (is_defined): add NODE_OP_ASGN_{OR,AND}. "defined?(a||=1)"
should not operate assignment.  [ruby-dev:34645]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 05:01:01 +00:00
kazu
5fed7fa349 * eval.c (method_name, method_owner): New methods; backported from 1.9. (UnboundMethod#name, UnboundMethod#owner)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 01:38:12 +00:00
knu
5f909db83b * class.c (struct clone_method_data): Add cref.
(clone_method): Properly handle NODE_BMETHOD and NODE_DMETHOD.
  (rb_singleton_class_clone, singleton_class_clone_int): Set a
  proper value to klass and propagate cref. [ruby-core:16238]

* eval.c (rb_block_dup, rb_method_dup), intern.h: Add duplicator
  methods for use from class.c#clone_method().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16206 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-26 10:52:56 +00:00
knu
f2323f8869 * eval.c (rb_yield_0, proc_invoke, proc_arity): allow passing a block
to a Proc.  [ruby-dev:23533]

* parse.y (block_par, block_var): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-26 10:37:13 +00:00
matz
0007c24a5c * eval.c (THREAD_SAVE_CONTEXT): remove unnecessary
FLUSH_REGISTER_WINDOWS before calling setjmp().  [ruby-core:16285]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-24 08:07:42 +00:00
knu
afc2d9e389 * eval.c (bind_eval): Add Binding#eval, a shorthand method for
eval(str, binding, ..); backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-23 06:44:56 +00:00
akr
168e2a279d * eval.c (error_print): show full stack grace except SystemStackError.
backport from 1.9.  [ruby-dev:31014]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 15:44:40 +00:00
knu
bc3ce4588d * eval.c (rb_proc_new, YIELD_FUNC_LAMBDA): Add a new nd_state
YIELD_FUNC_LAMBDA which avoids automatic `avalue' conversion for
  arguments.  This fixes a bug where [1,[2,3]].map(&:object_id)
  fails.

* intern.h, object.c: Hide rb_proc_new() from intern.h.  It should
  not be considered an official API function yet.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 13:51:44 +00:00
knu
a2b186bee4 * eval.c (rb_proc_new): Turn the BLOCK_LAMBDA flag on.
* object.c (sym_to_proc), test/ruby/test_symbol.rb: Add back
  Symbol#to_proc, now that it passes the tests.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-22 12:42:57 +00:00
knu
5391877f53 * eval.c (rb_f_method_name): New gloval function: __method__;
backported from matzruby / 1.9.

* eval.c (rb_frame_this_func), intern.h: New internal function.

* intern.h (RETURN_ENUMERATOR): Use rb_frame_this_func() instead
  of rb_frame_last_func(), to accommodate the behavior to that of
  1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-21 08:20:52 +00:00
knu
932ac5d35d * eval.c (rb_exec_recursive): New internal function to help
perform recursive operation; backported from 1.9.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-19 10:29:59 +00:00
kazu
3be6ebc5ce * eval.c (method_receiver, method_name, method_owner): New
methods; backported from 1.9. bug#19007


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-15 10:07:59 +00:00
knu
badb865567 * enumerator.c (rb_eStopIteration), eval.c (rb_f_loop), ruby.h:
Add a new exception class StopIteration, which breaks Kernel#loop
  iteration when raised; backported from 1.9.

* enumerator.c (enumerator_next, enumerator_rewind): Implement
  #next and #rewind using the "generator" library.

* lib/generator.rb: Implement Enumerable::Enumerator#next and
  #rewind.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-10 10:52:50 +00:00
knu
e6de1a384e * eval.c (rb_obj_method, rb_proc_call), intern.h: Export.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-09 10:47:13 +00:00
matz
7bd34cdb70 * eval.c (EXEC_TAG): remove unnecessary FLUSH_REGISTER_WINDOWS for
better performance on SPARC.  [ruby-core:16159]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-08 02:13:25 +00:00
nobu
ba570c7378 * configure.in (RUBY_SETJMP, RUBY_LONGJMP, RUBY_JMP_BUF): prefers
__builtin_setjmp, _setjmp over setjmp and sigsetjmp.
  [ruby-core:16023], [ruby-core:16086]

* configure.in (--with-setjmp-type): new option to override the
  default rule in the above.

* eval.c (ruby_setjmp, ruby_longjmp), gc.c (rb_setjmp),
  node.h (rb_jmpbuf_t): use RUBY_SETJMP, RUBY_LONGJMP and
  RUBY_JMP_BUF.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-31 17:58:14 +00:00
knu
058c981311 * eval.c (rb_eval): Call trace hook for if expression after the
condition has been evaluated, not before; submitted by Rocky
  Bernstein in #18722.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-24 11:09:51 +00:00
nobu
6017f19422 * eval.c (rb_call0): yields the last executed node line number at
return event.  [ruby-core:15855]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-12 15:37:22 +00:00
nobu
9041dfdefc * eval.c, gc.c (setjmp): sigsetjmp is a macro on cygwin.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-21 03:50:14 +00:00
nobu
475449aa18 * configure.in (sigsetjmp): check if available.
* eval.c, gc.c (setjmp): do not use _setjmp if sigsetjmp is available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-19 02:21:55 +00:00
nobu
5dd6a853ed * eval.c (eval): check if backtrace is empty. [ruby-core:15040]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-14 18:41:44 +00:00
nobu
0d7451ba82 * eval.c (rb_define_alloc_func, rb_undef_alloc_func): should
define/undef on a signleton class.  [ruby-core:09959]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-12 09:27:48 +00:00
nobu
a953db445d * eval.c (error_print): put newline unless multiple line message ends
with a newline.  [ruby-dev:32429]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@14086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-02 13:43:47 +00:00