From e5a72bce36601aa9c088f3d4b4ed433c42aa03c8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 25 Nov 2025 12:43:57 -0500 Subject: [PATCH] xo-interpreter: implement variable lookup --- include/xo/alloc/Object.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/xo/alloc/Object.hpp b/include/xo/alloc/Object.hpp index 73a60edd..c8772db9 100644 --- a/include/xo/alloc/Object.hpp +++ b/include/xo/alloc/Object.hpp @@ -39,6 +39,10 @@ namespace xo { template gc_ptr(const gc_ptr & x) : ptr_{x.ptr()} {} + /** runtime downcast. shorthand for dynamic_cast **/ + template + static gc_ptr from(const gc_ptr & x) { return gc_ptr{dynamic_cast(x.ptr())}; } + /** convenience for static asserts **/ static constexpr bool is_gc_ptr = true; /** see also: xo/refcnt/Refcounted.hpp **/