Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

JuliaDebug/TypedCodeUtils.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypedCodeUtils

This package performs operations on Julia's typed IR.

Example: Your own Cthulhu.jl

using TypedCodeUtils
import TypedCodeUtils: reflect, filter, lookthrough,
                       DefaultConsumer, Reflection, Callsite,
                       identify_invoke, identify_call,
                       process_invoke, process_call

# Cthulhu's inner loop
function cthulhu(ref::Reflection)
    callsites = Callsite[]

    invokes      = filter((c)->lookthrough(identify_invoke,      c), ref.CI.code)
    calls        = filter((c)->lookthrough(identify_call,        c), ref.CI.code)

    invokes = map((arg) -> process_invoke(DefaultConsumer(), ref, arg...), invokes)
    append!(callsites, invokes)
    calls = map((arg) -> process_call(DefaultConsumer(), ref, arg...), calls)
    append!(callsites, calls)

    sort!(callsites, by=(c)->c.id)
    return callsites
end

params = TypedCodeUtils.current_params()
ref = reflect(f, Tuple{Int, Int}, params=params)
calls = cthulhu(ref)
nextrefs = collect(reflect(c) for c in calls if TypedCodeUtils.canreflect(c))

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages