Skip to content

Commit 8cfa7c5

Browse files
committed
run format
1 parent ba7c4f4 commit 8cfa7c5

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

src/CassetteOverlay.jl

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module CassetteOverlay
22

33
export @MethodTable, @overlay, @overlaypass, getpass, nonoverlay, @nonoverlay,
4-
AbstractBindingOverlay, Overlay
4+
AbstractBindingOverlay, Overlay
55

66
using CassetteBase
77

@@ -42,16 +42,19 @@ function (generator::CassetteOverlayGenerator)(world::UInt, source::SourceType,
4242
catch err
4343
# internal error happened - return an expression to raise the special exception
4444
return generate_internalerr_ex(
45-
err, #=bt=#catch_backtrace(), #=context=#:CassetteOverlayGenerator, world, source,
46-
#=argnames=#Core.svec(selfname, fargsname), #=spnames=#Core.svec(),
47-
#=metadata=#(; world, source, passtype, fargtypes))
45+
err, #=bt=# catch_backtrace(), #=context=# :CassetteOverlayGenerator, world, source,
46+
#=argnames=# Core.svec(selfname, fargsname), #=spnames=# Core.svec(),
47+
#=metadata=# (; world, source, passtype, fargtypes)
48+
)
4849
end
4950
end
5051

5152
global invalid_code::Vector{Any} = []
5253

53-
function generate_overlay_src(world::UInt, source::SourceType, passtype, fargtypes,
54-
selfname::Symbol, fargsname::Symbol)
54+
function generate_overlay_src(
55+
world::UInt, source::SourceType, passtype, fargtypes,
56+
selfname::Symbol, fargsname::Symbol
57+
)
5558
@nospecialize passtype fargtypes
5659
tt = Base.to_tuple_type(fargtypes)
5760
mt_worlds = methodtable(world, passtype)
@@ -61,7 +64,7 @@ function generate_overlay_src(world::UInt, source::SourceType, passtype, fargtyp
6164
method_table = mt_worlds
6265
worlds = nothing
6366
end
64-
match = Base._which(tt; method_table, raise=false, world)
67+
match = Base._which(tt; method_table, raise = false, world)
6568
match === nothing && return nothing # method match failed – the fallback implementation will raise a proper MethodError
6669
mi = Core.Compiler.specialize_method(match)
6770
src = Core.Compiler.retrieve_code_info(mi, world)
@@ -112,7 +115,7 @@ macro overlaypass(args...)
112115

113116
# primitives
114117
primitives = quote
115-
@inline function (::$PassName)(f::Union{Core.Builtin,Core.IntrinsicFunction}, args...)
118+
@inline function (::$PassName)(f::Union{Core.Builtin, Core.IntrinsicFunction}, args...)
116119
@nospecialize f args
117120
return f(args...)
118121
end
@@ -145,10 +148,14 @@ macro overlaypass(args...)
145148
# nonoverlay primitives
146149
nonoverlaypass = quote
147150
@nospecialize
148-
@inline (pass::$PassName)(::$nonoverlaytype,
149-
f, args...; kwargs...) = f(args...; kwargs...)
150-
@inline (pass::$PassName)(::typeof(Core.kwcall),
151-
kwargs::Any, ::$nonoverlaytype, fargs...) = Core.kwcall(kwargs, fargs...)
151+
@inline (pass::$PassName)(
152+
::$nonoverlaytype,
153+
f, args...; kwargs...
154+
) = f(args...; kwargs...)
155+
@inline (pass::$PassName)(
156+
::typeof(Core.kwcall),
157+
kwargs::Any, ::$nonoverlaytype, fargs...
158+
) = Core.kwcall(kwargs, fargs...)
152159
@specialize
153160
end
154161
append!(topblk.args, nonoverlaypass.args)
@@ -164,20 +171,20 @@ macro overlaypass(args...)
164171
end
165172

166173
function isconst_at_world(m::Module, var::Symbol, world::UInt)
167-
bpart = Base.lookup_binding_partition(world, GlobalRef(m, var))
168-
kind = Base.binding_kind(bpart)
169-
return Base.is_defined_const_binding(kind)
170-
end
171-
172-
function getglobal_at_world(m::Module, var::Symbol, world::UInt)
173-
b = @ccall jl_get_binding(m::Any, var::Any)::Any
174-
bp = Base.lookup_binding_partition(world, b)
175-
val_ptr = @ccall jl_get_binding_value_in_world(b::Any, world::Csize_t)::Ptr{Any}
176-
if val_ptr == C_NULL
177-
throw(ccall(:jl_new_struct, Any, (Any, Any...), UndefVarError, var, world, m))
178-
end
179-
return Pair{Any,UnitRange{UInt}}(unsafe_pointer_to_objref(val_ptr), bp.min_world:bp.max_world)
180-
end
174+
bpart = Base.lookup_binding_partition(world, GlobalRef(m, var))
175+
kind = Base.binding_kind(bpart)
176+
return Base.is_defined_const_binding(kind)
177+
end
178+
179+
function getglobal_at_world(m::Module, var::Symbol, world::UInt)
180+
b = @ccall jl_get_binding(m::Any, var::Any)::Any
181+
bp = Base.lookup_binding_partition(world, b)
182+
val_ptr = @ccall jl_get_binding_value_in_world(b::Any, world::Csize_t)::Ptr{Any}
183+
if val_ptr == C_NULL
184+
throw(ccall(:jl_new_struct, Any, (Any, Any...), UndefVarError, var, world, m))
185+
end
186+
return Pair{Any, UnitRange{UInt}}(unsafe_pointer_to_objref(val_ptr), bp.min_world:bp.max_world)
187+
end
181188

182189
abstract type AbstractBindingOverlay{M, S} <: OverlayPass; end
183190
function methodtable(world::UInt, ::Type{<:AbstractBindingOverlay{M, S}}) where {M, S}
@@ -194,7 +201,8 @@ function methodtable(world::UInt, ::Type{<:AbstractBindingOverlay{M, S}}) where
194201
end
195202
@overlaypass AbstractBindingOverlay nothing
196203

197-
struct Overlay{M, S} <: AbstractBindingOverlay{M, S}; end
204+
struct Overlay{M, S} <: AbstractBindingOverlay{M, S}
205+
end
198206
function Overlay(mt::MethodTable)
199207
@assert @invokelatest isconst(mt.module, mt.name)
200208
@assert mt === @invokelatest getglobal(mt.module, mt.name)

0 commit comments

Comments
 (0)