Skip to content

Commit f9bdad5

Browse files
committed
some minor cleanups
1 parent 0b17ba7 commit f9bdad5

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/optimize.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function build_compiled_foreigncall!(stmt::Expr, code::CodeInfo, sparams::Vector
219219
dynamic_ccall = false
220220
oldcfunc = nothing
221221
if isa(cfuncarg, Expr) || isa(cfuncarg, GlobalRef) || isa(cfuncarg, Symbol) # specification by tuple, e.g., (:clock, "libc")
222-
cfunc = something(static_eval(evalmod, cfuncarg), cfuncarg)
222+
cfunc = something(try Core.eval(evalmod, cfuncarg) catch nothing end, cfuncarg)
223223
elseif isa(cfuncarg, QuoteNode)
224224
cfunc = cfuncarg.value
225225
else

src/utils.jl

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,14 @@ Test whether expression `ex` is a `@doc` expression.
237237
function is_doc_expr(@nospecialize(ex))
238238
docsym = Symbol("@doc")
239239
if isexpr(ex, :macrocall)
240-
ex::Expr
241240
length(ex.args) == 4 || return false
242241
a = ex.args[1]
243-
is_global_ref(a, Core, docsym) && return true
244-
isa(a, Symbol) && a == docsym && return true
245-
if isexpr(a, :.)
246-
mod, name = (a::Expr).args[1], (a::Expr).args[2]
242+
if isa(a, Symbol) && a === docsym
243+
return true
244+
elseif is_global_ref(a, Core, docsym)
245+
return true
246+
elseif isexpr(a, :.)
247+
mod, name = a.args[1], a.args[2]
247248
return mod === :Core && isa(name, QuoteNode) && name.value === docsym
248249
end
249250
end
@@ -682,7 +683,7 @@ respectively) can be evaluated using the syntax `var"%3"` and `var"@_4"` respect
682683
"""
683684
function eval_code end
684685

685-
function extract_usage!(s::Set{Symbol}, expr)
686+
function extract_usage!(s::Set{Symbol}, @nospecialize expr)
686687
if expr isa Expr
687688
for arg in expr.args
688689
if arg isa Symbol
@@ -753,7 +754,7 @@ function eval_code(frame::Frame, expr::Expr)
753754
eval_res
754755
end
755756

756-
function show_stackloc(io::IO, frame)
757+
function show_stackloc(io::IO, frame::Frame)
757758
indent = ""
758759
fr = root(frame)
759760
shown = false
@@ -772,7 +773,7 @@ function show_stackloc(io::IO, frame)
772773
println(io, indent, scopeof(frame), ", pc = ", frame.pc)
773774
end
774775
end
775-
show_stackloc(frame) = show_stackloc(stdout, frame)
776+
show_stackloc(frame::Frame) = show_stackloc(stdout, frame)
776777

777778
# Printing of stacktraces and errors with Frame
778779
function Base.StackTraces.StackFrame(frame::Frame)
@@ -821,11 +822,3 @@ function Base.display_error(io::IO, er, frame::Frame)
821822
showerror(IOContext(io, :limit => true), er, frame)
822823
println(io)
823824
end
824-
825-
function static_eval(evalmod, ex)
826-
try
827-
Core.eval(evalmod, ex)
828-
catch
829-
nothing
830-
end
831-
end

0 commit comments

Comments
 (0)