1- const badfile = (nothing , nothing , nothing , UInt128 (0 ))
21function pkg_fileinfo (id:: PkgId )
32 origin = get (Base. pkgorigins, id, nothing )
4- origin === nothing && return badfile
3+ origin === nothing && return nothing
54 cachepath = origin. cachepath
6- cachepath === nothing && return badfile
5+ cachepath === nothing && return nothing
76 local checksum
87 provides, includes_requires, required_modules = try
98 ret = @static if VERSION ≥ v " 1.11.0-DEV.683" # https://github.com/JuliaLang/julia/pull/49866
@@ -16,42 +15,38 @@ function pkg_fileinfo(id::PkgId)
1615 provides, (includes_srcfiles_only, requires), required_modules
1716 else
1817 checksum = UInt64 (0 ) # Buildid prior to v"1.12.0-DEV.764", and the `srcfiles_only` API does not take `io`
19- Base. parse_cache_header (cachepath, srcfiles_only = true )
18+ Base. parse_cache_header (cachepath; srcfiles_only = true )
2019 end
2120 ret
2221 catch err
23- return badfile
22+ return nothing
2423 end
2524 includes, _ = includes_requires
2625 for (pkgid, buildid) in provides
2726 if pkgid. uuid === id. uuid && pkgid. name == id. name
2827 return cachepath, includes, first .(required_modules), (UInt128 (checksum) << 64 | buildid)
2928 end
3029 end
30+ return nothing
3131end
3232
3333function parse_pkg_files (id:: PkgId )
34- pkgdata = get (pkgdatas, id, nothing )
35- if pkgdata === nothing
36- pkgdata = PkgData (id)
37- end
38- modsym = Symbol (id. name)
34+ pkgdata = get! (()-> PkgData (id), pkgdatas, id)
3935 if use_compiled_modules ()
40- cachefile, includes, reqs, buildid = pkg_fileinfo (id)
41- if cachefile != = nothing
42- @assert includes != = nothing
43- @assert reqs != = nothing
36+ cachefile_includes_reqs_buildid = pkg_fileinfo (id)
37+ if cachefile_includes_reqs_buildid != = nothing
38+ cachefile, includes, reqs, buildid = cachefile_includes_reqs_buildid
4439 pkgdata. requirements = reqs
4540 for chi in includes
46- if isdefined (Base, :maybe_loaded_precompile ) && Base. maybe_loaded_precompile (id, buildid) isa Module
47- mod = Base . maybe_loaded_precompile (id, buildid)
41+ if isdefined (Base, :maybe_loaded_precompile ) && (mod′ = Base. maybe_loaded_precompile (id, buildid); mod′ isa Module)
42+ mod = mod′
4843 elseif isdefined (Base, :loaded_precompiles ) && haskey (Base. loaded_precompiles, id => buildid)
4944 mod = Base. loaded_precompiles[id => buildid]
5045 else
5146 mod = Base. root_module (id)
5247 end
5348 for mpath in chi. modpath
54- mod = getfield (mod, Symbol (mpath)):: Module
49+ mod = getglobal (mod, Symbol (mpath)):: Module
5550 end
5651 fname = relpath (chi. filename, pkgdata)
5752 # For precompiled packages, we can read the source later (whenever we need it)
@@ -68,7 +63,7 @@ function parse_pkg_files(id::PkgId)
6863 # To reduce compiler latency, use runtime dispatch for `queue_includes!`.
6964 # `queue_includes!` requires compilation of the whole parsing/expression-splitting infrastructure,
7065 # and it's better to wait to compile it until we actually need it.
71- Base . invokelatest ( queue_includes!, pkgdata, id)
66+ @ invokelatest queue_includes! ( pkgdata, id)
7267 return pkgdata
7368end
7469
@@ -93,8 +88,9 @@ function modulefiles(mod::Module)
9388 return keypath (parentfile), [keypath (mf[2 ]) for mf in included_files]
9489 end
9590 use_compiled_modules () || return nothing , nothing # FIXME : support non-precompiled packages
96- _, filedata, reqs = pkg_fileinfo (id)
97- filedata === nothing && return nothing , nothing
98- included_files = filter (mf-> mf. id == id, filedata)
91+ cachefile_includes_reqs_buildid = pkg_fileinfo (id)
92+ cachefile_includes_reqs_buildid === nothing && return nothing , nothing
93+ _, includes, _, _ = cachefile_includes_reqs_buildid
94+ included_files = filter (mf-> mf. id == id, includes)
9995 return keypath (parentfile), [keypath (mf. filename) for mf in included_files]
10096end
0 commit comments