From 8e72f98bcce3979d3b34bc496cb4544116b6f527 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 15 Jun 2024 15:16:00 -0400 Subject: [PATCH] xo-pyjit: + lookup_dbl_dbl_fn [wip -- not actually working yet] --- src/pyjit/pyjit.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pyjit/pyjit.cpp b/src/pyjit/pyjit.cpp index 14bfc9f4..c69558a1 100644 --- a/src/pyjit/pyjit.cpp +++ b/src/pyjit/pyjit.cpp @@ -49,9 +49,19 @@ namespace xo { /* we're assuming llvm-generated code lives for as long as the Jit * instance that created it. * - * RC 14jun2024 - I think this is true modulo use of llvm resource trackers. + * RC 14jun2024 - I think this is true, modulo use of llvm resource trackers. */ py::return_value_policy::reference_internal) + .def("lookup_dbl_dbl_fn", + [](Jit & jit, const std::string & symbol) { + auto llvm_addr = jit.lookup_symbol(symbol); + + auto fn_addr = llvm_addr.toPtr(); + + return new XferFn(fn_addr); + }) + ; + py::class_>(m, "XferFn") .def("__call__", [](XferFn & self, double x) { return self(x); }