From bc4f80e29b556c9ea753e6bf76fa54ea4022ae9a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 09:03:24 -0500 Subject: [PATCH] xo-interpreter2 stack: + dict type + pop more pm types --- include/xo/type/DFunctionType.hpp | 32 ++++++++++++++++++++++++++----- include/xo/type/Metatype.hpp | 9 ++++++++- src/type/Metatype.cpp | 6 ++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/include/xo/type/DFunctionType.hpp b/include/xo/type/DFunctionType.hpp index 7090a60..51568bf 100644 --- a/include/xo/type/DFunctionType.hpp +++ b/include/xo/type/DFunctionType.hpp @@ -32,17 +32,27 @@ namespace xo { * for a function with return type @p ret_type and arguments @p args **/ template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) explicit DFunctionType(obj mm, obj ret_type, Args... args); /** create instance using memory from @p mm, * for a function with return type @p ret_type and arguments @p args **/ template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) static DFunctionType * _make(obj mm, obj ret_type, Args... args); +#ifdef NOT_USING + /** create instance using memory from @p mm + * for function with return type @p ret_type and arguments @p args + **/ + template + requires (std::same_as> && ...) + static obj make(obj mm, + obj ret_type, Args... args); +#endif + ///@} /** @defgroup xo-scm-arraytype-type-facet **/ ///@{ @@ -72,14 +82,14 @@ namespace xo { }; template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) DFunctionType::DFunctionType(obj mm, obj return_type, Args... args) : return_type_{return_type}, - arg_types_{DArray::array(mm, args...)} + arg_types_{DArray::array(mm, args.template to_facet()...)} {} template - requires (std::same_as> && ...) + requires (std::convertible_to> && ...) DFunctionType * DFunctionType::_make(obj mm, obj ret_type, Args... args) { @@ -88,6 +98,18 @@ namespace xo { return new (mem) DFunctionType(mm, ret_type, args...); } +#ifdef NOT_USING + template + requires (std::same_as> && ...) + obj + DFunctionType::make(obj mm, obj ret_type, Args... args) + { + void * mem = mm.alloc_for(); + + return obj(_make(mm, ret_type, args...)); + } +#endif + } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/type/Metatype.hpp b/include/xo/type/Metatype.hpp index 30952df..0b0aeef 100644 --- a/include/xo/type/Metatype.hpp +++ b/include/xo/type/Metatype.hpp @@ -39,8 +39,13 @@ namespace xo { t_function, /* struct */ t_struct, + /* dicttionary: like struct, but w/ dynamic key/value pairs */ + t_dict, - /* any numeric type: i16|i32|i64|f32|f64 */ + /** any integer type: i16|i32|i64 **/ + t_integer, + + /** any numeric type: i16|i32|i64|f32|f64 **/ t_numeric, /* any type at all */ @@ -66,7 +71,9 @@ namespace xo { static Metatype t_array() { return Metatype(code::t_array); } static Metatype t_function() { return Metatype(code::t_function); } static Metatype t_struct() { return Metatype(code::t_struct); } + static Metatype t_dict() { return Metatype(code::t_dict); } + static Metatype t_integer() { return Metatype(code::t_integer); } static Metatype t_numeric() { return Metatype(code::t_numeric); } static Metatype t_any() { return Metatype(code::t_any); } diff --git a/src/type/Metatype.cpp b/src/type/Metatype.cpp index 9e50f11..be42f61 100644 --- a/src/type/Metatype.cpp +++ b/src/type/Metatype.cpp @@ -28,7 +28,9 @@ namespace xo { case code::t_array: return "array"; case code::t_function: return "function"; case code::t_struct: return "struct"; + case code::t_dict: return "dict"; + case code::t_integer: return "integer"; case code::t_numeric: return "numeric"; case code::t_any: return "any"; } @@ -68,7 +70,11 @@ namespace xo { return false; case code::t_struct: return false; + case code::t_dict: + return true; + case code::t_integer: + return true; case code::t_numeric: return true; case code::t_any: