CodeTransformation.addmethod!Method
addmethod!(f, argtypes, ci)

Add a method to a function.

The types of the arguments is given as a Tuple.

Example:

g(x) = x + 13
ci = code_lowered(g)[1]
function f end
addmethod!(f, (Any,), ci)
f(1) # returns 14
CodeTransformation.addmethod!Method
addmethod(sig, ci)

Alternative syntax where the call signature is a Tuple type.

Example:

addmethod!(Tuple{typeof(f), Any}, ci)
CodeTransformation.codetransform!Method
codetransform!(tr, dst, src)

Apply a code transformation function tr on the methods of a function src, adding the transformed methods to another function dst.

Example: Search-and-replace a constant in a function.

g(x) = x + 13
function e end
codetransform!(g => e) do ci
    for ex in ci.code
        if ex isa Expr
            map!(x -> x === 13 ? 7 : x, ex.args, ex.args)
        end
    end
    ci
end
e(1) # returns 8
CodeTransformation.argdataMethod
argdata(sig[, f])

Turn a call signature into the 'argdata' svec that jl_method_def uses When a function is given in the second argument, it replaces the one in the call signature.

CodeTransformation.jl_method_defMethod
jl_method_def(argdata, ci, mod) - C function wrapper

This is a wrapper of the C function with the same name, found in the Julia source tree at julia/src/method.c

Use addmethod! or codetransform! instead of calling this function directly.