| Title: | Inject code to existing functions |
|---|---|
| Description: | Allow one to inject arbitrary code at the entry point or at the exit point of an existing function. |
| Authors: | Filip Krikava [aut, cre] (ORCID: <https://orcid.org/0000-0002-0478-6202>) |
| Maintainer: | Filip Krikava <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1 |
| Built: | 2026-07-15 01:00:31 UTC |
| Source: | https://github.com/PRL-PRG/injectr |
Creates a duplicate of an R object using R's native duplication mechanism.
create_duplicate(x)create_duplicate(x)
x |
An R object to duplicate. Must not be |
A duplicate of x.
The code argument is recorded without evaluation and it will be inserted
at the beginning of the fun. If it is a symbol, its value will be looked
starting in the callee frame. If where is not onentry it will be wrapped
in on.exit call. If where is onerror, the wrapped code will further
make the code to run only in the case the function failed with an error
condition.
inject_code(code, fun, where = "onentry", wrap = FALSE)inject_code(code, fun, where = "onentry", wrap = FALSE)
code |
the code that should be inserted. |
fun |
the function into which the code should be inserted. |
where |
indicates at which point of the |
wrap |
indicates if it the given |
This function modifies the original function.
NULL invisibly
Returns the address of an object's underlying S-expression. This low-level helper is primarily useful when testing whether two objects share storage.
sexp_address(x)sexp_address(x)
x |
An R object. Must not be |
A character scalar containing the hexadecimal memory address of x.