Skip to content

Commit 49b4c92

Browse files
authored
[email protected] compat, drop Julia 1.0 support (#70)
1 parent ff8998f commit 49b4c92

File tree

7 files changed

+38
-50
lines changed

7 files changed

+38
-50
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
version:
16-
- '1.0'
17-
- '1'
16+
- '1.6' # current LTS
17+
- '1' # latest stable
1818
- 'nightly'
1919
os:
2020
- ubuntu-latest

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name = "LoweredCodeUtils"
22
uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
33
authors = ["Tim Holy <[email protected]>"]
4-
version = "2.1.2"
4+
version = "2.1.4"
55

66
[deps]
77
JuliaInterpreter = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
88

99
[compat]
10-
JuliaInterpreter = "0.8.8"
11-
julia = "1"
10+
JuliaInterpreter = "0.8.8, 0.9"
11+
julia = "1.6"
1212

1313
[extras]
1414
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

src/codeedges.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const preprinter_sentinel = isdefined(Base.IRShow, :statementidx_lineinfo_printe
100100

101101
if isdefined(Base.IRShow, :show_ir_stmt)
102102
function print_with_code(preprint, postprint, io::IO, src::CodeInfo)
103-
src = JuliaInterpreter.copy_codeinfo(src)
103+
src = copy(src)
104104
JuliaInterpreter.replace_coretypes!(src; rev=true)
105105
if isdefined(JuliaInterpreter, :reverse_lookup_globalref!)
106106
JuliaInterpreter.reverse_lookup_globalref!(src.code)
@@ -899,7 +899,7 @@ end
899899
function print_with_code(io::IO, frame::Frame, obj)
900900
src = frame.framecode.src
901901
if isdefined(JuliaInterpreter, :reverse_lookup_globalref!)
902-
src = JuliaInterpreter.copy_codeinfo(src)
902+
src = copy(src)
903903
JuliaInterpreter.reverse_lookup_globalref!(src.code)
904904
end
905905
print_with_code(io, src, obj)

src/packagedef.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ using Base.Meta: isexpr
77

88
const SSAValues = Union{Core.Compiler.SSAValue, JuliaInterpreter.SSAValue}
99

10-
const structheads = VERSION >= v"1.5.0-DEV.702" ? () : (:struct_type, :abstract_type, :primitive_type)
11-
const trackedheads = (:method, structheads...)
10+
const trackedheads = (:method,)
1211
const structdecls = (:_structtype, :_abstracttype, :_primitivetype)
1312

1413
export signature, rename_framemethods!, methoddef!, methoddefs!, bodymethod

src/utils.jl

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,10 @@ function isanonymous_typedef(stmt)
7676
if isa(stmt, CodeInfo)
7777
src = stmt # just for naming consistency
7878
length(src.code) >= 4 || return false
79-
if VERSION >= v"1.5.0-DEV.702"
80-
stmt = src.code[end-1]
81-
(isexpr(stmt, :call) && is_global_ref(stmt.args[1], Core, :_typebody!)) || return false
82-
name = (stmt::Expr).args[2]::Symbol
83-
return startswith(String(name), "#")
84-
else
85-
stmt = src.code[end-1]
86-
isexpr(stmt, :struct_type) || return false
87-
name = (stmt::Expr).args[1]::Symbol
88-
return startswith(String(name), "#")
89-
end
79+
stmt = src.code[end-1]
80+
(isexpr(stmt, :call) && is_global_ref(stmt.args[1], Core, :_typebody!)) || return false
81+
name = (stmt::Expr).args[2]::Symbol
82+
return startswith(String(name), "#")
9083
end
9184
return false
9285
end
@@ -95,7 +88,6 @@ function istypedef(stmt)
9588
isa(stmt, Expr) || return false
9689
stmt = rhs(stmt)
9790
isa(stmt, Expr) || return false
98-
stmt.head structheads && return true
9991
@static if all(s->isdefined(Core,s), structdecls)
10092
if stmt.head === :call
10193
f = stmt.args[1]
@@ -126,7 +118,6 @@ function typedef_range(src::CodeInfo, idx)
126118
istart -= 1
127119
end
128120
istart >= 1 || error("no initial :global found")
129-
stmt.head structheads && return istart:idx
130121
iend, n = idx, length(src.code)
131122
have_typebody = have_equivtypedef = false
132123
while iend <= n

test/codeedges.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ end
341341
str = String(take!(io))
342342
@test occursin(r"slot 1:\n preds: ssas: \[\d+, \d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d+, \d+\]", str)
343343
@test occursin(r"succs: ssas: ∅, slots: \[\d+\], names: ∅;", str)
344-
VERSION >= v"1.1" && @test occursin(r"s:\n preds: ssas: \[\d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d, \d+\]", str)
345-
VERSION >= v"1.1" && @test occursin(r"\d+ preds: ssas: \[\d+\], slots: ∅, names: \[:s\];\n\d+ succs: ssas: ∅, slots: ∅, names: \[:s\];", str)
344+
@test occursin(r"s:\n preds: ssas: \[\d+\], slots: ∅, names: ∅;\n succs: ssas: \[\d+, \d+, \d+\], slots: ∅, names: ∅;\n assign @: \[\d, \d+\]", str)
345+
@test occursin(r"\d+ preds: ssas: \[\d+\], slots: ∅, names: \[:s\];\n\d+ succs: ssas: ∅, slots: ∅, names: \[:s\];", str)
346346
LoweredCodeUtils.print_with_code(io, src, cl)
347347
str = String(take!(io))
348348
if isdefined(Base.IRShow, :show_ir_stmt)
@@ -357,8 +357,8 @@ end
357357
edges = CodeEdges(src)
358358
show(io, edges)
359359
str = String(take!(io))
360-
VERSION >= v"1.1" && @test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str)
361-
VERSION >= v"1.1" && @test count(occursin("statement $i depends on [1, $(i-1), $(i+1)] and is used by [1, $(i+1)]", str) for i = 1:length(src.code)) == 1
360+
@test occursin(r"s: assigned on \[\d, \d+\], depends on \[\d+\], and used by \[\d+, \d+, \d+\]", str)
361+
@test count(occursin("statement $i depends on [1, $(i-1), $(i+1)] and is used by [1, $(i+1)]", str) for i = 1:length(src.code)) == 1
362362
LoweredCodeUtils.print_with_code(io, src, edges)
363363
str = String(take!(io))
364364
if isdefined(Base.IRShow, :show_ir_stmt)

test/signatures.jl

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -406,30 +406,28 @@ bodymethtest5(x, y=Dict(1=>2)) = 5
406406
rename_framemethods!(frame)
407407

408408
# https://github.com/timholy/Revise.jl/issues/550
409-
if Base.VERSION >= v"1.4"
410-
using Pkg
411-
try
412-
# we test with the old version of CBinding, let's do it in an isolated environment
413-
Pkg.activate(; temp=true)
414-
415-
@info "Adding CBinding to the environment for test purposes"
416-
Pkg.add(; name="CBinding", version="0.9.4") # `@cstruct` isn't defined for v1.0 and above
417-
418-
m = Module()
419-
Core.eval(m, :(using CBinding))
420-
421-
ex = :(@cstruct S {
422-
val::Int8
423-
})
424-
empty!(signatures)
425-
Core.eval(m, ex)
426-
frame = Frame(m, ex)
427-
rename_framemethods!(frame)
428-
pc = methoddefs!(signatures, frame; define=false)
429-
@test !isempty(signatures) # really we just need to know that `methoddefs!` completed without getting stuck
430-
finally
431-
Pkg.activate() # back to the original environment
432-
end
409+
using Pkg
410+
try
411+
# we test with the old version of CBinding, let's do it in an isolated environment
412+
Pkg.activate(; temp=true)
413+
414+
@info "Adding CBinding to the environment for test purposes"
415+
Pkg.add(; name="CBinding", version="0.9.4") # `@cstruct` isn't defined for v1.0 and above
416+
417+
m = Module()
418+
Core.eval(m, :(using CBinding))
419+
420+
ex = :(@cstruct S {
421+
val::Int8
422+
})
423+
empty!(signatures)
424+
Core.eval(m, ex)
425+
frame = Frame(m, ex)
426+
rename_framemethods!(frame)
427+
pc = methoddefs!(signatures, frame; define=false)
428+
@test !isempty(signatures) # really we just need to know that `methoddefs!` completed without getting stuck
429+
finally
430+
Pkg.activate() # back to the original environment
433431
end
434432
end
435433

0 commit comments

Comments
 (0)