Skip to content

Commit ccc1c95

Browse files
authored
remove old compats (#598)
This should be good to go as far as 1.6 CI passes.
1 parent 15ad1c7 commit ccc1c95

File tree

7 files changed

+24
-59
lines changed

7 files changed

+24
-59
lines changed

src/commands.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ maybe_next_until!(@nospecialize(predicate), frame::Frame, istoplevel::Bool=false
119119
pc = next_call!(frame, istoplevel=false)
120120
121121
Execute the current statement. Continue stepping through `frame` until the next
122-
`:return` or `:call` expression.
122+
`ReturnNode` or `:call` expression.
123123
"""
124124
next_call!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false) =
125125
next_until!(frame -> is_call_or_return(pc_expr(frame)), recurse, frame, istoplevel)
@@ -129,8 +129,8 @@ next_call!(frame::Frame, istoplevel::Bool=false) = next_call!(finish_and_return!
129129
pc = maybe_next_call!(recurse, frame, istoplevel=false)
130130
pc = maybe_next_call!(frame, istoplevel=false)
131131
132-
Return the current program counter of `frame` if it is a `:return` or `:call` expression.
133-
Otherwise, step through the statements of `frame` until the next `:return` or `:call` expression.
132+
Return the current program counter of `frame` if it is a `ReturnNode` or `:call` expression.
133+
Otherwise, step through the statements of `frame` until the next `ReturnNode` or `:call` expression.
134134
"""
135135
maybe_next_call!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false) =
136136
maybe_next_until!(frame -> is_call_or_return(pc_expr(frame)), recurse, frame, istoplevel)

src/interpret.jl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,6 @@ function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplev
471471
end
472472
isa(rhs, BreakpointRef) && return rhs
473473
do_assignment!(frame, lhs, rhs)
474-
elseif node.head === :gotoifnot
475-
arg = @lookup(frame, node.args[1])
476-
if !isa(arg, Bool)
477-
throw(TypeError(nameof(frame), "if", Bool, arg))
478-
end
479-
if !arg
480-
return (frame.pc = node.args[2]::Int)
481-
end
482474
elseif node.head === :enter
483475
rhs = node.args[1]::Int
484476
push!(data.exception_frames, rhs)
@@ -499,8 +491,6 @@ function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplev
499491
elseif node.head === :pop_exception
500492
# TODO: This needs to handle the exception stack properly
501493
# (https://github.com/JuliaDebug/JuliaInterpreter.jl/issues/591)
502-
elseif node.head === :return
503-
return nothing
504494
elseif istoplevel
505495
if node.head === :method && length(node.args) > 1
506496
evaluate_methoddef(frame, node)
@@ -558,16 +548,15 @@ function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplev
558548
end
559549
elseif isa(node, GotoNode)
560550
return (frame.pc = node.label)
561-
elseif is_GotoIfNot(node)
562-
node = node::Core.GotoIfNot
551+
elseif isa(node, GotoIfNot)
563552
arg = @lookup(frame, node.cond)
564553
if !isa(arg, Bool)
565554
throw(TypeError(nameof(frame), "if", Bool, arg))
566555
end
567556
if !arg
568557
return (frame.pc = node.dest)
569558
end
570-
elseif is_ReturnNode(node)
559+
elseif isa(node, ReturnNode)
571560
return nothing
572561
elseif isa(node, NewvarNode)
573562
# FIXME: undefine the slot?
@@ -647,11 +636,7 @@ function handle_err(@nospecialize(recurse), frame, err)
647636
return (frame.pc = data.exception_frames[end])
648637
end
649638

650-
if isdefined(Core, :ReturnNode)
651-
lookup_return(frame, node::Core.ReturnNode) = @lookup(frame, node.val)
652-
else
653-
lookup_return(frame, node::Expr) = @lookup(frame, node.args[1])
654-
end
639+
lookup_return(frame, node::ReturnNode) = @lookup(frame, node.val)
655640

656641
"""
657642
ret = get_return(frame)

src/optimize.jl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,20 @@ function renumber_ssa!(stmts::Vector{Any}, ssalookup)
5656
stmts[i] = SSAValue(stmt.id)
5757
elseif isa(stmt, Expr)
5858
stmt = replace_ssa(stmt, ssalookup)
59-
if (stmt.head === :gotoifnot || stmt.head === :enter) && isa(stmt.args[end], Int)
60-
stmt.args[end] = jumplookup(ssalookup, stmt.args[end])
59+
if stmt.head === :enter
60+
stmt.args[end] = jumplookup(ssalookup, stmt.args[1]::Int)
6161
end
6262
stmts[i] = stmt
63-
elseif is_GotoIfNot(stmt)
64-
cond = (stmt::Core.GotoIfNot).cond
63+
elseif isa(stmt, GotoIfNot)
64+
cond = stmt.cond
6565
if isa(cond, SSAValue)
6666
cond = SSAValue(ssalookup[cond.id])
6767
end
68-
stmts[i] = Core.GotoIfNot(cond, jumplookup(ssalookup, stmt.dest))
69-
elseif is_ReturnNode(stmt)
70-
val = (stmt::Core.ReturnNode).val
68+
stmts[i] = GotoIfNot(cond, jumplookup(ssalookup, stmt.dest))
69+
elseif isa(stmt, ReturnNode)
70+
val = stmt.val
7171
if isa(val, SSAValue)
72-
stmts[i] = Core.ReturnNode(SSAValue(ssalookup[val.id]))
72+
stmts[i] = ReturnNode(SSAValue(ssalookup[val.id]))
7373
end
7474
end
7575
end
@@ -394,19 +394,17 @@ function replace_coretypes_list!(list::AbstractVector; rev::Bool=false)
394394
rstmt = rep(stmt, rev)
395395
if rstmt !== stmt
396396
list[i] = rstmt
397-
elseif is_GotoIfNot(stmt)
398-
stmt = stmt::Core.GotoIfNot
397+
elseif isa(stmt, GotoIfNot)
399398
cond = stmt.cond
400399
rcond = rep(cond, rev)
401400
if rcond !== cond
402-
list[i] = Core.GotoIfNot(rcond, stmt.dest)
401+
list[i] = GotoIfNot(rcond, stmt.dest)
403402
end
404-
elseif is_ReturnNode(stmt)
405-
stmt = stmt::Core.ReturnNode
403+
elseif isa(stmt, ReturnNode)
406404
val = stmt.val
407405
rval = rep(val, rev)
408406
if rval !== val
409-
list[i] = Core.ReturnNode(rval)
407+
list[i] = ReturnNode(rval)
410408
end
411409
elseif isa(stmt, Expr)
412410
replace_coretypes!(stmt; rev=rev)

src/packagedef.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Base.Meta
22
import Base: +, -, convert, isless, get_world_counter
3-
using Core: CodeInfo, SimpleVector, LineInfoNode, GotoNode,
3+
using Core: CodeInfo, SimpleVector, LineInfoNode, GotoNode, GotoIfNot, ReturnNode,
44
GeneratedFunctionStub, MethodInstance, NewvarNode, TypeName
55

66
using UUIDs

src/utils.jl

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,7 @@ end
132132

133133
isidentical(x) = Base.Fix2(===, x) # recommended over isequal(::Symbol) since it cannot be invalidated
134134

135-
# is_goto_node(@nospecialize(node)) = isa(node, GotoNode) || isexpr(node, :gotoifnot)
136-
137-
if isdefined(Core, :GotoIfNot)
138-
is_GotoIfNot(@nospecialize(node)) = isa(node, Core.GotoIfNot)
139-
is_gotoifnot(@nospecialize(node)) = is_GotoIfNot(node)
140-
else
141-
is_GotoIfNot(@nospecialize(node)) = false
142-
is_gotoifnot(@nospecialize(node)) = isexpr(node, :gotoifnot)
143-
end
144-
145-
if isdefined(Core, :ReturnNode)
146-
is_ReturnNode(@nospecialize(node)) = isa(node, Core.ReturnNode)
147-
is_return(@nospecialize(node)) = is_ReturnNode(node)
148-
get_return_node(@nospecialize(node)) = (node::Core.ReturnNode).val
149-
else
150-
is_ReturnNode(@nospecialize(node)) = false
151-
is_return(@nospecialize(node)) = isexpr(node, :return)
152-
get_return_node(@nospecialize(node)) = node.args[1]
153-
end
135+
is_return(@nospecialize(node)) = node isa ReturnNode
154136

155137
is_loc_meta(@nospecialize(expr), @nospecialize(kind)) = isexpr(expr, :meta) && length(expr.args) >= 1 && expr.args[1] === kind
156138

@@ -184,7 +166,7 @@ function is_call(@nospecialize(node))
184166
(isexpr(node, :(=)) && (isexpr(node.args[2], :call)))
185167
end
186168

187-
is_call_or_return(@nospecialize(node)) = is_call(node) || is_return(node)
169+
is_call_or_return(@nospecialize(node)) = is_call(node) || node isa ReturnNode
188170

189171
is_dummy(bpref::BreakpointRef) = bpref.stmtidx == 0 && bpref.err === nothing
190172

test/core.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ using Test
2525
end
2626

2727
thunk = Meta.lower(Main, :(return 1+2))
28-
stmt = thunk.args[1].code[end] # the return
29-
@test JuliaInterpreter.get_return_node(stmt) isa Core.SSAValue
28+
stmt = thunk.args[1].code[end]::Core.ReturnNode # the return
29+
@test stmt.val isa Core.SSAValue
3030

3131
@test string(JuliaInterpreter.parametric_type_to_expr(Base.Iterators.Stateful{String}))
3232
("Base.Iterators.Stateful{String, VS}", "(Base.Iterators).Stateful{String, VS}", "Base.Iterators.Stateful{String, VS, N}")

test/limits.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838
@test Aborted(frame, i).at.line == 6
3939
# Check conditional
4040
frame = Frame(modexs[4]...)
41-
i = findfirst(stmt->JuliaInterpreter.is_gotoifnot(stmt), frame.framecode.src.code) + 1
41+
i = findfirst(stmt->isa(stmt, Core.GotoIfNot), frame.framecode.src.code) + 1
4242
@test Aborted(frame, i).at.line == 9
4343
# Check macro
4444
frame = Frame(modexs[5]...)

0 commit comments

Comments
 (0)