Skip to content

Commit

Permalink
InteractiveUtils: define InteractiveUtils.@code_ircode (#56390)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Oct 31, 2024
1 parent c6e7f83 commit 2a24b8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion stdlib/InteractiveUtils/src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# macro wrappers for various reflection functions

import Base: typesof, insert!, replace_ref_begin_end!, infer_effects
import Base: typesof, insert!, replace_ref_begin_end!, infer_effects, code_ircode

# defined in Base so it's possible to time all imports, including InteractiveUtils and its deps
# via. `Base.@time_imports` etc.
Expand Down Expand Up @@ -249,6 +249,14 @@ macro code_lowered(ex0...)
end
end

macro code_ircode(ex0...)
thecall = gen_call_with_extracted_types_and_kwargs(__module__, :code_ircode, ex0)
quote
local results = $thecall
length(results) == 1 ? results[1] : results
end
end

"""
@functionloc
Expand Down
2 changes: 2 additions & 0 deletions stdlib/InteractiveUtils/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ end
end

@test Base.infer_effects(sin, (Int,)) == InteractiveUtils.@infer_effects sin(42)
@test first(InteractiveUtils.@code_ircode sin(42)) isa Core.Compiler.IRCode
@test first(InteractiveUtils.@code_ircode optimize_until="Inlining" sin(42)) isa Core.Compiler.IRCode

@testset "Docstrings" begin
@test isempty(Docs.undocumented_names(InteractiveUtils))
Expand Down

2 comments on commit 2a24b8f

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

Please sign in to comment.