Skip to content

Commit 70237e1

Browse files
committed
added identity function for pipes
1 parent bf57dac commit 70237e1

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

src/CodeInfoTools.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Base: show
99
##### Exports
1010
#####
1111

12-
export var, Variable, Canvas, renumber, code_info, finish
12+
export var, Variable, Canvas, renumber, code_info, finish, get_slot
1313

1414
#####
1515
##### Utilities
@@ -28,7 +28,7 @@ function code_info(f, tt; generated=true, debuginfo=:default)
2828
end
2929

3030
function get_slot(ci::CodeInfo, s::Symbol)
31-
ind = findfirst(ci.slotnames, s)
31+
ind = findfirst(el -> el == s, ci.slotnames)
3232
ind == nothing && return
3333
return Core.Compiler.SlotNumber(ind)
3434
end

test/misc.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
@testset "Base.:(+) -- SSAValues" begin
3+
@test (+)(Core.SSAValue(1), 1) == Core.SSAValue(2)
4+
@test (+)(1, Core.SSAValue(1)) == Core.SSAValue(2)
5+
end
6+
7+
@testset "Pipe -- misc." begin
8+
ir = code_info(g, Tuple{Int})
9+
p = CodeInfoTools.Pipe(ir)
10+
for (v, st) in p
11+
end
12+
display(p)
13+
display(length(p))
14+
p = CodeInfoTools.Pipe(ir)
15+
p = identity(p)
16+
get_slot(p, :x)
17+
end

test/pipe.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,3 @@ end
144144
display(finish(p))
145145
end
146146

147-
@testset "Base.:(+) -- SSAValues" begin
148-
@test (+)(Core.SSAValue(1), 1) == Core.SSAValue(2)
149-
@test (+)(1, Core.SSAValue(1)) == Core.SSAValue(2)
150-
end
151-
152-
@testset "Pipe -- misc." begin
153-
ir = code_info(g, Tuple{Int})
154-
p = CodeInfoTools.Pipe(ir)
155-
for (v, st) in p
156-
end
157-
display(p)
158-
display(length(p))
159-
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ using Test
55

66
include("canvas.jl")
77
include("pipe.jl")
8+
include("misc.jl")
89

910
end # module

0 commit comments

Comments
 (0)