aboutsummaryrefslogtreecommitdiffstats
path: root/proc.c
Commit message (Collapse)AuthorAgeFilesLines
* Add rb_iseq_locationJeremy Evans2019-08-301-1/+7
| | | | This wraps iseq_location and should fix the leaked global test.
* Use more accurate source location in keyword argument separation warningsJeremy Evans2019-08-301-1/+1
| | | | | | | | This shows locations in places it didn't before, such as for proc calls, and fixes the location for super calls. This requires making iseq_location non-static and MJIT exported, which I hope will not cause problems.
* Separate keyword arguments from positional argumentsYusuke Endoh2019-08-301-1/+1
| | | | And, allow non-symbol keys as a keyword arugment
* [DOC] Return obj may be different from 1st argument [ci skip]Kazuhiro NISHIYAMA2019-08-301-3/+3
|
* proc.c: Add UnboundMethod#bind_callYusuke Endoh2019-08-301-31/+72
| | | | | | | | | | | | | | | | | | | | | | | | | `umethod.bind_call(obj, ...)` is semantically equivalent to `umethod.bind(obj).call(...)`. This idiom is used in some libraries to call a method that is overridden. The added method does the same without allocation of intermediate Method object. [Feature #15955] ``` class Foo def add_1(x) x + 1 end end class Bar < Foo def add_1(x) # override x + 2 end end obj = Bar.new p obj.add_1(1) #=> 3 p Foo.instance_method(:add_1).bind(obj).call(1) #=> 2 p Foo.instance_method(:add_1).bind_call(obj, 1) #=> 2 ```
* move docs around [ci skip]卜部昌平2019-08-291-12/+12
| | | | To properly generate documents.
* drop-in type check for rb_define_global_function卜部昌平2019-08-291-2/+14
| | | | | | We can check the function pointer passed to rb_define_global_function like we do so in rb_define_method. It turns out that almost anybody is misunderstanding the API.
* rb_proc_new / rb_fiber_new now free from ANYARGS卜部昌平2019-08-271-8/+8
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_proc_new / rb_fiber_new, and applies RB_BLOCK_CALL_FUNC_ARGLIST wherever necessary.
* decouple compile.c usage of imemo_ifunc卜部昌平2019-08-271-4/+4
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from struct vm_ifunc, but in doing so we also have to decouple the usage of this struct in compile.c, which (I think) is an abuse of ANYARGS.
* Add details about parameters to define_method doc (#2165)OKURA Masafumi2019-08-161-2/+12
| | | | | | When we use `define_method` and `define_singleton_method`, if we supply block parameters to a block then a generated method has corresponding parameters. However, the doc doesn't mention it, so this info has been added.
* * expand tabs.git2019-08-141-1/+1
|
* change Proc#to_s format ('@...' -> ' ...') (#2362)Koichi Sasada2019-08-141-1/+1
| | | | | | | | Now Proc#to_s returns "#<Proc:0x00000237a0f5f170@t.rb:1>". However, it is convenient to select a file name by (double-)clicking on some terminals by separating ' ' instead of '@' like "#<Proc:0x00000237a0f5f170 t.rb:1>" [Feature #16101]
* Rename rb_gc_mark_no_pin -> rb_gc_mark_movableAaron Patterson2019-08-121-5/+5
| | | | | | Renaming this function. "No pin" leaks some implementation details. We just want users to know that if they mark this object, the reference may move and they'll need to update the reference accordingly.
* fix typos.Tanaka Akira2019-07-141-8/+9
|
* Method#inspect with source location.Koichi Sasada2019-07-141-0/+12
| | | | | Method#inspect shows with source location. [Feature #14145]
* Describe lambda-ness of Proc more.Tanaka Akira2019-07-141-4/+65
|
* * expand tabs.git2019-06-121-3/+3
|
* Add compaction support for more types.Aaron Patterson2019-06-111-1/+4
| | | | | | | | This commit adds compaction support for: * Fibers * Continuations * Autoload Constants
* Unpin objects that `proc` referencesAaron Patterson2019-06-031-9/+62
| | | | | | This commit adds compaction support to method and proc objects. It just unpins references and implements the "compact" callback and updates references.
* Add class ref to `UnboundMethod#owner` docokuramasafumi2019-04-271-1/+1
| | | | | | | | It refers to `Method#receiver` in the doc, but there's no class reference in current doc. Some tools automatically make it a link so it's useful. Closes: https://github.com/ruby/ruby/pull/2156
* Adds a reference to `TracePoint` to `binding` docsKazuhiro NISHIYAMA2019-04-221-1/+1
| | | | | | | | | | This change adds an explicit reference to `TracePoint` in the documentation for `binding`. Currently it only refers to the now deprecated `Kernel#set_trace_func`. This reference is left alone for continuity in the documentation. [Fix GH-2079] Co-authored-by: Brandon Weaver <baweaver@squareup.com>
* * expand tabs.svn2019-04-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Proc.new: change deprecation warning for clarity (issue #15539)marcandre2019-04-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* range.c: force hash values fixablenobu2019-04-081-1/+1
| | | | | | | * range.c (method_hash): force hash values fixable on LLP64 environment. [ruby-core:92191] [Bug #15756] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] fix markups [ci skip]nobu2019-03-281-53/+49
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: call respond_to_missing? with a symbolnobu2019-03-061-8/+13
| | | | | | [ruby-core:91683] [Bug #15640] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2019-01-281-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add refinements support to method/instance_method.nobu2019-01-281-4/+4
| | | | | | | | [Fix GH-2034] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: proc without blocknobu2019-01-101-0/+3
| | | | | | | * proc.c (proc_new): promoted lambda/proc/Proc.new with no block in a method called with a block to a warning/error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: check if callablenobu2019-01-101-4/+33
| | | | | | | * proc.c: check the argument at composition, expect a Proc, Method, or callable object. [ruby-core:90591] [Bug #15428] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: [DOC] fix typosstomar2018-12-141-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces. [ci skip]svn2018-12-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tweak syntax of Proc documentation [ci skip]duerst2018-12-141-31/+36
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: [DOC] fix typosstomar2018-12-131-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Fix typos [ci skip]kazu2018-12-131-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enhance Proc docs [Misc #14610]duerst2018-12-121-4/+164
| | | | | | | From: Victor Shepelev <zverok.offline@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer rb_check_arity when 0 or 1 argumentsnobu2018-12-061-2/+1
| | | | | | | Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-11-261-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Support targetting TracePoint [Feature #15289]ko12018-11-261-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_trace.c (rb_tracepoint_enable_for_target): support targetting TracePoint. [Feature #15289] Tragetting TracePoint is only enabled on specified method, proc and so on, example: `tp.enable(target: code)`. `code` should be consisted of InstructionSeuqnece (iseq) (RubyVM::InstructionSeuqnece.of(code) should not return nil) If code is a tree of iseq, TracePoint is enabled on all of iseqs in a tree. Enabled tragetting TracePoints can not enabled again with and without target. * vm_core.h (rb_iseq_t): introduce `rb_iseq_t::local_hooks` to store local hooks. `rb_iseq_t::aux::trace_events` is renamed to `global_trace_events` to contrast with `local_hooks`. * vm_core.h (rb_hook_list_t): add `rb_hook_list_t::running` to represent how many Threads/Fibers are used this list. If this field is 0, nobody using this hooks and we can delete it. This is why we can remove code from cont.c. * vm_core.h (rb_vm_t): because of above change, we can eliminate `rb_vm_t::trace_running` field. Also renamed from `rb_vm_t::event_hooks` to `global_hooks`. * vm_core.h, vm.c (ruby_vm_event_enabled_global_flags): renamed from `ruby_vm_event_enabled_flags. * vm_core.h, vm.c (ruby_vm_event_local_num): added to count enabled targetting TracePoints. * vm_core.h, vm_trace.c (rb_exec_event_hooks): accepts hook list. * vm_core.h (rb_vm_global_hooks): added for convinience. * method.h (rb_method_bmethod_t): added to maintain Proc and `rb_hook_list_t` for bmethod (defined by define_method). * prelude.rb (TracePoint#enable): extracet a keyword parameter (because it is easy than writing in C). It calls `TracePoint#__enable` internal method written in C. * vm_insnhelper.c (vm_trace): check also iseq->local_hooks. * vm.c (invoke_bmethod): check def->body.bmethod.hooks. * vm.c (hook_before_rewind): check iseq->local_hooks and def->body.bmethod.hooks before rewind by exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: [DOC] refine proc-compistion examples [ci skip]nobu2018-11-231-17/+13
| | | | | | | * proc.c: [DOC] refine proc-compistion examples by using same Proc/Method and different composition orders. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Proc#<< and Proc#>>nobu2018-11-221-13/+82
| | | | | | [Feature #6284] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: Support any callable when composing Procsnobu2018-11-221-13/+3
| | | | | | | | | | | | | | | | | | * proc.c (proc_compose): support any object with a call method rather than supporting only procs. [Feature #6284] * proc.c (compose): use the function call on the given object rather than rb_proc_call_with_block in order to support any object. * test/ruby/test_proc.rb: Add test cases for composing Procs with callable objects. * test/ruby/test_method.rb: Add test cases for composing Methods with callable objects. From: Paul Mucur <paul@altmetric.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: Implement Method#* for Method compositionnobu2018-11-221-0/+25
| | | | | | | | | | | * proc.c (rb_method_compose): Implement Method#* for Method composition, which delegates to Proc#*. * test/ruby/test_method.rb: Add test cases for Method composition. From: Paul Mucur <mudge@mudge.name> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: Implement Proc#* for Proc compositionnobu2018-11-221-0/+54
| | | | | | | | | | | * proc.c (proc_compose): Implement Proc#* for Proc composition, enabling composition of Procs and Methods. [Feature #6284] * test/ruby/test_proc.rb: Add test cases for Proc composition. From: Paul Mucur <mudge@mudge.name> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: [DOC] improve docs for {Method,Proc}#===stomar2018-10-261-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* proc.c: [DOC] fix grammar in doc for Method#to_sstomar2018-10-261-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Improve docs of Proc / Methodaycabta2018-10-211-5/+49
| | | | | | | | * proc.c: Add descriptions and code examples. [ruby-core:85600] [Bug #14483] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer `rb_fstring_lit` over `rb_fstring_cstr`nobu2018-10-131-3/+3
| | | | | | | The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revisit `RARRAY_PTR()`.ko12018-10-101-7/+5
| | | | | | | | | | | | | | | * array.c (yield_indexed_values): use RARRAY_AREF/ASET instead of using RARRAY_PTR(). * enum.c (nmin_filter): ditto. * proc.c (rb_sym_to_proc): ditto. * enum.c (rb_nmin_run): use RARRAY_PTR_USE() instead of RARRAY_PTR(). It is safe because they don't make new referecen from an array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove obsolete comment from Module#define_method documentationtenderlove2018-07-251-4/+2
| | | | | | | | Since 2.5, Module#define_method is public. (feature #14133) Co-Authored-By: Miguel Landaeta <miguel@miguel.cc> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e