From 0e2ddcf839a1e5abbd81d282666ceadf987369af Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 26 Nov 2025 20:15:03 -0500 Subject: [PATCH] xo-interpreter: Object->TaggedPtr conversion (prep for primitives) --- .../xo/expression/FunctionExprInterface.hpp | 12 +++---- include/xo/expression/Lambda.hpp | 4 +-- .../xo/expression/PrimitiveExprInterface.hpp | 6 ++-- .../xo/expression/ProcedureExprInterface.hpp | 33 +++++++++++++++++++ src/expression/Lambda.cpp | 2 +- 5 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 include/xo/expression/ProcedureExprInterface.hpp diff --git a/include/xo/expression/FunctionExprInterface.hpp b/include/xo/expression/FunctionExprInterface.hpp index 62756654..340d3f11 100644 --- a/include/xo/expression/FunctionExprInterface.hpp +++ b/include/xo/expression/FunctionExprInterface.hpp @@ -1,4 +1,4 @@ -/** @file FunctionInterface.hpp +/** @file ProcedureExprInterface.hpp * * Author: Roland Conybeare **/ @@ -10,14 +10,14 @@ namespace xo { namespace scm { - class FunctionExprInterface : public Expression { + class ProcedureExprInterface : public Expression { public: - FunctionExprInterface(exprtype extype, TypeDescr fn_type) + ProcedureExprInterface(exprtype extype, TypeDescr fn_type) : Expression(extype, fn_type) {} /** downcast from Expression **/ - static bp from(bp x) { - return bp::from(x); + static bp from(bp x) { + return bp::from(x); } virtual const std::string & name() const = 0; @@ -30,4 +30,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/** end FunctionInterface.hpp **/ +/** end ProcedureExprInterface.hpp **/ diff --git a/include/xo/expression/Lambda.hpp b/include/xo/expression/Lambda.hpp index e4d24cd6..e5b3aeb1 100644 --- a/include/xo/expression/Lambda.hpp +++ b/include/xo/expression/Lambda.hpp @@ -6,7 +6,7 @@ #pragma once #include "Expression.hpp" -#include "FunctionExprInterface.hpp" +#include "ProcedureExprInterface.hpp" #include "Variable.hpp" #include "LocalSymtab.hpp" #include @@ -19,7 +19,7 @@ namespace xo { * @brief abstract syntax tree for a function definition * **/ - class Lambda : public FunctionExprInterface { + class Lambda : public ProcedureExprInterface { public: /** * @p name. Name for this lambda -- must be unique diff --git a/include/xo/expression/PrimitiveExprInterface.hpp b/include/xo/expression/PrimitiveExprInterface.hpp index 1011e5dc..9db7be14 100644 --- a/include/xo/expression/PrimitiveExprInterface.hpp +++ b/include/xo/expression/PrimitiveExprInterface.hpp @@ -5,19 +5,19 @@ #pragma once -#include "FunctionExprInterface.hpp" +#include "ProcedureExprInterface.hpp" #include "llvmintrinsic.hpp" #include namespace xo { namespace scm { - class PrimitiveExprInterface : public FunctionExprInterface { + class PrimitiveExprInterface : public ProcedureExprInterface { public: using void_function_type = void (*)(); public: explicit PrimitiveExprInterface(TypeDescr fn_type) - : FunctionExprInterface(exprtype::primitive, fn_type) {} + : ProcedureExprInterface(exprtype::primitive, fn_type) {} /** downcast from Expression **/ static bp from(bp x) { diff --git a/include/xo/expression/ProcedureExprInterface.hpp b/include/xo/expression/ProcedureExprInterface.hpp new file mode 100644 index 00000000..62acf21a --- /dev/null +++ b/include/xo/expression/ProcedureExprInterface.hpp @@ -0,0 +1,33 @@ +/** @file FunctionExprInterface.hpp + * + * Author: Roland Conybeare + **/ + +#pragma once + +#include "Expression.hpp" +//#include + +namespace xo { + namespace scm { + class ProcedureExprInterface : public Expression { + public: + ProcedureExprInterface(exprtype extype, TypeDescr fn_type) + : Expression(extype, fn_type) {} + + /** downcast from Expression **/ + static bp from(bp x) { + return bp::from(x); + } + + virtual const std::string & name() const = 0; + virtual int n_arg() const = 0; // { return this->value_td()->n_fn_arg(); } + virtual TypeDescr fn_retval() const = 0; // { return this->value_td()->fn_retval(); } + virtual TypeDescr fn_arg(uint32_t i) const = 0; // { return this->value_td()->fn_arg(i); } + + private: + }; /*FunctionInterface*/ + } /*namespace scm*/ +} /*namespace xo*/ + +/** end FunctionExprInterface.hpp **/ diff --git a/src/expression/Lambda.cpp b/src/expression/Lambda.cpp index d944b690..0196f52e 100644 --- a/src/expression/Lambda.cpp +++ b/src/expression/Lambda.cpp @@ -259,7 +259,7 @@ namespace xo { TypeDescr lambda_td, const rp & local_env, const rp & body) - : FunctionExprInterface(exprtype::lambda, lambda_td), + : ProcedureExprInterface(exprtype::lambda, lambda_td), name_{name}, body_{body}, local_env_{local_env}