Clarify documentation for InstructionSequence#compile
.
We incorrectly assumed that the `file` argument should be the file name and caused https://github.com/scoutapp/scout_apm_ruby/issues/307 because exception backtrace did not contain correct path. This documentation clarifies the role of the different arguments and provides extra examples.
This commit is contained in:
parent
cef9ebfbd3
commit
78e266da1d
16
iseq.c
16
iseq.c
@ -1156,10 +1156,14 @@ rb_iseqw_new(const rb_iseq_t *iseq)
|
|||||||
* Takes +source+, a String of Ruby code and compiles it to an
|
* Takes +source+, a String of Ruby code and compiles it to an
|
||||||
* InstructionSequence.
|
* InstructionSequence.
|
||||||
*
|
*
|
||||||
* Optionally takes +file+, +path+, and +line+ which describe the filename,
|
* Optionally takes +file+, +path+, and +line+ which describe the file path,
|
||||||
* absolute path and first line number of the ruby code in +source+ which are
|
* real path and first line number of the ruby code in +source+ which are
|
||||||
* metadata attached to the returned +iseq+.
|
* metadata attached to the returned +iseq+.
|
||||||
*
|
*
|
||||||
|
* +file+ is used for `__FILE__` and exception backtrace. +path+ is used for
|
||||||
|
* +require_relative+ base. It is recommended these should be the same full
|
||||||
|
* path.
|
||||||
|
*
|
||||||
* +options+, which can be +true+, +false+ or a +Hash+, is used to
|
* +options+, which can be +true+, +false+ or a +Hash+, is used to
|
||||||
* modify the default behavior of the Ruby iseq compiler.
|
* modify the default behavior of the Ruby iseq compiler.
|
||||||
*
|
*
|
||||||
@ -1168,6 +1172,14 @@ rb_iseqw_new(const rb_iseq_t *iseq)
|
|||||||
* RubyVM::InstructionSequence.compile("a = 1 + 2")
|
* RubyVM::InstructionSequence.compile("a = 1 + 2")
|
||||||
* #=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
|
* #=> <RubyVM::InstructionSequence:<compiled>@<compiled>>
|
||||||
*
|
*
|
||||||
|
* path = "test.rb"
|
||||||
|
* RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path))
|
||||||
|
* #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1>
|
||||||
|
*
|
||||||
|
* path = File.expand_path("test.rb")
|
||||||
|
* RubyVM::InstructionSequence.compile(File.read(path), path, path)
|
||||||
|
* #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
static VALUE
|
static VALUE
|
||||||
iseqw_s_compile(int argc, VALUE *argv, VALUE self)
|
iseqw_s_compile(int argc, VALUE *argv, VALUE self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user