Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TracePoint for v2.6.0 #2692

Merged
merged 5 commits into from
Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions refm/api/src/_builtin/TracePoint
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ trace.disable
ファイバーの切り替え。
#@end

#@since 2.6.0
: :script_compiled

スクリプトのコンパイル
#@end

指定イベントに関連しない情報を取得するメソッドを実行した場合には
[[c:RuntimeError]] が発生します。

Expand Down Expand Up @@ -486,3 +492,58 @@ begin
rescue
end
#@end

#@since 2.6.0
--- parameters -> [object]

現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。
フォーマットは [[m:Method#parameters]] と同じです。

@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベントフックの外側で実行した場合に発生します。

#@samplecode 例
def foo(a, b = 2)
end
TracePoint.new(:call) do |tp|
p tp.parameters # => [[:req, :a], [:opt, :b]]
end.enable do
foo(1)
end
#@end

@see [[m:Method#parameters]], [[m:UnboundMethod#parameters]], [[m:Proc#parameters]]

--- eval_script -> String | nil

script_compiledイベント発生時にコンパイルされたソースコードを返します。
ファイルから読み込んだ場合は、nilを返します。

#@samplecode 例
TracePoint.new(:script_compiled) do |tp|
p tp.eval_script # => "puts 'hello'"
end.enable do
eval("puts 'hello'")
end
#@end

@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。

--- instruction_sequence -> RubyVM::InstructionSequence

script_compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。

#@samplecode 例
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("puts 'hello'")
end
#@end

@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。

#@end