Skip to content

Commit

Permalink
Run objectid in Compiled mode (fixes #92)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Mar 5, 2019
1 parent 5855707 commit 21c5d64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/JuliaInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct Variable
isparam::Bool
end
Base.show(io::IO, var::Variable) = print(io, var.name, " = ", var.value)
Base.isequal(var1::Variable, var2::Variable) =
Base.isequal(var1::Variable, var2::Variable) =
var1.value == var2.value && var1.name == var2.name && var1.isparam == var2.isparam

"""
Expand Down Expand Up @@ -1148,6 +1148,8 @@ function set_compiled_methods()
# issue #76
push!(compiled_methods, which(unsafe_store!, (Ptr{Any}, Any, Int)))
push!(compiled_methods, which(unsafe_store!, (Ptr, Any, Int)))
# issue #92
push!(compiled_methods, which(objectid, Tuple{Any}))
end

function __init__()
Expand Down
6 changes: 6 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ let TT = Union{UInt8, Int8}
@interpret unsafe_store!(pa, 0x1, 2)
end

# issue #92
let x = Core.TypedSlot(1, Any)
f(x) = objectid(x)
@test isa(@interpret(f(x)), UInt)
end

# Some expression can appear nontrivial but lower to nothing
@test isa(JuliaInterpreter.prepare_thunk(Main, :(@static if ccall(:jl_get_UNAME, Any, ()) == :NoOS 1+1 end)), Nothing)
@test isa(JuliaInterpreter.prepare_thunk(Main, :(Base.BaseDocs.@kw_str "using")), Nothing)
Expand Down

0 comments on commit 21c5d64

Please sign in to comment.