diff --git a/xo-expression/include/xo/expression/FunctionInterface.hpp b/xo-expression/include/xo/expression/FunctionExprInterface.hpp similarity index 74% rename from xo-expression/include/xo/expression/FunctionInterface.hpp rename to xo-expression/include/xo/expression/FunctionExprInterface.hpp index a568a71d..62756654 100644 --- a/xo-expression/include/xo/expression/FunctionInterface.hpp +++ b/xo-expression/include/xo/expression/FunctionExprInterface.hpp @@ -10,14 +10,14 @@ namespace xo { namespace scm { - class FunctionInterface : public Expression { + class FunctionExprInterface : public Expression { public: - FunctionInterface(exprtype extype, TypeDescr fn_type) + FunctionExprInterface(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; diff --git a/xo-expression/include/xo/expression/Lambda.hpp b/xo-expression/include/xo/expression/Lambda.hpp index 81a872b6..e4d24cd6 100644 --- a/xo-expression/include/xo/expression/Lambda.hpp +++ b/xo-expression/include/xo/expression/Lambda.hpp @@ -6,13 +6,12 @@ #pragma once #include "Expression.hpp" -#include "FunctionInterface.hpp" +#include "FunctionExprInterface.hpp" #include "Variable.hpp" #include "LocalSymtab.hpp" #include #include #include -//#include namespace xo { namespace scm { @@ -20,7 +19,7 @@ namespace xo { * @brief abstract syntax tree for a function definition * **/ - class Lambda : public FunctionInterface { + class Lambda : public FunctionExprInterface { public: /** * @p name. Name for this lambda -- must be unique diff --git a/xo-expression/include/xo/expression/Primitive.hpp b/xo-expression/include/xo/expression/Primitive.hpp index 6c1c12bc..e53bbcb9 100644 --- a/xo-expression/include/xo/expression/Primitive.hpp +++ b/xo-expression/include/xo/expression/Primitive.hpp @@ -5,7 +5,7 @@ #pragma once -#include "PrimitiveInterface.hpp" +#include "PrimitiveExprInterface.hpp" #include "pretty_expression.hpp" #include "llvmintrinsic.hpp" #include "xo/reflect/Reflect.hpp" @@ -38,7 +38,7 @@ namespace xo { * won't work here. **/ template - class Primitive: public PrimitiveInterface { + class Primitive: public PrimitiveExprInterface { public: using Reflect = xo::reflect::Reflect; using TaggedPtr = xo::reflect::TaggedPtr; @@ -111,7 +111,7 @@ namespace xo { FunctionPointer fnptr, bool explicit_symbol_def, llvmintrinsic intrinsic) - : PrimitiveInterface(fn_type), + : PrimitiveExprInterface(fn_type), name_{name}, value_td_{Reflect::require_function()}, value_{fnptr}, diff --git a/xo-expression/include/xo/expression/PrimitiveInterface.hpp b/xo-expression/include/xo/expression/PrimitiveExprInterface.hpp similarity index 82% rename from xo-expression/include/xo/expression/PrimitiveInterface.hpp rename to xo-expression/include/xo/expression/PrimitiveExprInterface.hpp index c9e5660e..1011e5dc 100644 --- a/xo-expression/include/xo/expression/PrimitiveInterface.hpp +++ b/xo-expression/include/xo/expression/PrimitiveExprInterface.hpp @@ -1,29 +1,27 @@ -/** @file PrimitiveInterface.hpp +/** @file PrimitiveExprInterface.hpp * * Author: Roland Conybeare **/ #pragma once -#include "FunctionInterface.hpp" +#include "FunctionExprInterface.hpp" #include "llvmintrinsic.hpp" - -//#include - #include + namespace xo { namespace scm { - class PrimitiveInterface : public FunctionInterface { + class PrimitiveExprInterface : public FunctionExprInterface { public: using void_function_type = void (*)(); public: - explicit PrimitiveInterface(TypeDescr fn_type) - : FunctionInterface(exprtype::primitive, fn_type) {} + explicit PrimitiveExprInterface(TypeDescr fn_type) + : FunctionExprInterface(exprtype::primitive, fn_type) {} /** downcast from Expression **/ - static bp from(bp x) { - return bp::from(x); + static bp from(bp x) { + return bp::from(x); } /** if true, Jit will try to explicitly symbol for this primitive diff --git a/xo-expression/src/expression/Lambda.cpp b/xo-expression/src/expression/Lambda.cpp index 7a140f04..d944b690 100644 --- a/xo-expression/src/expression/Lambda.cpp +++ b/xo-expression/src/expression/Lambda.cpp @@ -259,7 +259,7 @@ namespace xo { TypeDescr lambda_td, const rp & local_env, const rp & body) - : FunctionInterface(exprtype::lambda, lambda_td), + : FunctionExprInterface(exprtype::lambda, lambda_td), name_{name}, body_{body}, local_env_{local_env} diff --git a/xo-jit/include/xo/jit/MachPipeline.hpp b/xo-jit/include/xo/jit/MachPipeline.hpp index a66fcb14..640f8264 100644 --- a/xo-jit/include/xo/jit/MachPipeline.hpp +++ b/xo-jit/include/xo/jit/MachPipeline.hpp @@ -15,7 +15,7 @@ #include "xo/expression/Expression.hpp" #include "xo/expression/ConstantInterface.hpp" -#include "xo/expression/PrimitiveInterface.hpp" +#include "xo/expression/PrimitiveExprInterface.hpp" #include "xo/expression/Apply.hpp" #include "xo/expression/Lambda.hpp" #include "xo/expression/Variable.hpp" @@ -110,7 +110,7 @@ namespace xo { **/ llvm::Type * codegen_type(TypeDescr td); llvm::Value * codegen_constant(bp expr); - llvm::Function * codegen_primitive(bp expr); + llvm::Function * codegen_primitive(bp expr); /** like @ref codegen_primitive , but create wrapper function that accepts (and discards) * environment pointer as first argument. @@ -118,7 +118,7 @@ namespace xo { * Implementation consists of tail call to natural primitive, that skips the unused * environment pointer **/ - llvm::Function * codegen_primitive_wrapper(bp expr, + llvm::Function * codegen_primitive_wrapper(bp expr, llvm::IRBuilder<> & ir_builder); /** Generate closure for invoking a primitive function. @@ -126,7 +126,7 @@ namespace xo { * to support function-pointer-like behavior for a target function * that may resolve to primitive-or-lambda at runtime **/ - llvm::Value * codegen_primitive_closure(bp expr, + llvm::Value * codegen_primitive_closure(bp expr, llvm::IRBuilder<> & ir_builder); llvm::Value * codegen_apply(bp expr, diff --git a/xo-jit/include/xo/jit/type2llvm.hpp b/xo-jit/include/xo/jit/type2llvm.hpp index 7801309f..5308b082 100644 --- a/xo-jit/include/xo/jit/type2llvm.hpp +++ b/xo-jit/include/xo/jit/type2llvm.hpp @@ -20,7 +20,7 @@ namespace xo { **/ struct type2llvm { public: - using FunctionInterface = xo::scm::FunctionInterface; + using FunctionInterface = xo::scm::FunctionExprInterface; using Lambda = xo::scm::Lambda; using TypeDescr = xo::reflect::TypeDescr; diff --git a/xo-jit/src/jit/MachPipeline.cpp b/xo-jit/src/jit/MachPipeline.cpp index b3cef9c3..6c7fb152 100644 --- a/xo-jit/src/jit/MachPipeline.cpp +++ b/xo-jit/src/jit/MachPipeline.cpp @@ -11,7 +11,7 @@ namespace xo { using xo::scm::Expression; using xo::scm::ConstantInterface; //using xo::scm::FunctionInterface; - using xo::scm::PrimitiveInterface; + using xo::scm::PrimitiveExprInterface; using xo::scm::Lambda; using xo::scm::Variable; using xo::scm::Apply; @@ -166,7 +166,7 @@ namespace xo { } llvm::Function * - MachPipeline::codegen_primitive(bp expr) + MachPipeline::codegen_primitive(bp expr) { constexpr bool c_debug_flag = true; @@ -251,7 +251,7 @@ namespace xo { } /*codegen_primitive*/ llvm::Function * - MachPipeline::codegen_primitive_wrapper(bp expr, + MachPipeline::codegen_primitive_wrapper(bp expr, llvm::IRBuilder<> & /*ir_builder*/) { constexpr bool c_debug_flag = true; @@ -369,7 +369,7 @@ namespace xo { } /*codegen_primitive_wrapper*/ llvm::Value * - MachPipeline::codegen_primitive_closure(bp expr, + MachPipeline::codegen_primitive_closure(bp expr, llvm::IRBuilder<> & ir_builder) { constexpr bool c_debug_flag = true; @@ -422,7 +422,7 @@ namespace xo { * allows substituting LLVM intrinsic */ if (apply->fn()->extype() == exprtype::primitive) { - auto pm = PrimitiveInterface::from(apply->fn()); + auto pm = PrimitiveExprInterface::from(apply->fn()); if (pm) { llvm_closure = this->codegen_primitive_closure(pm, ir_builder); @@ -979,7 +979,7 @@ namespace xo { case exprtype::constant: return this->codegen_constant(ConstantInterface::from(expr)); case exprtype::primitive: - return this->codegen_primitive_closure(PrimitiveInterface::from(expr), ir_builder); + return this->codegen_primitive_closure(PrimitiveExprInterface::from(expr), ir_builder); case exprtype::apply: return this->codegen_apply(Apply::from(expr), envptr, ir_builder); case exprtype::lambda: diff --git a/xo-pyexpression/src/pyexpression/pyexpression.cpp b/xo-pyexpression/src/pyexpression/pyexpression.cpp index dd7dffaf..d6a22c1c 100644 --- a/xo-pyexpression/src/pyexpression/pyexpression.cpp +++ b/xo-pyexpression/src/pyexpression/pyexpression.cpp @@ -4,7 +4,7 @@ #include "xo/pyreflect/pyreflect.hpp" #include "xo/expression/Expression.hpp" #include "xo/expression/Apply.hpp" -#include "xo/expression/PrimitiveInterface.hpp" +#include "xo/expression/PrimitiveExprInterface.hpp" #include "xo/expression/Primitive.hpp" #include "xo/expression/ConstantInterface.hpp" #include "xo/expression/Constant.hpp" @@ -21,7 +21,7 @@ namespace xo { using xo::scm::exprtype; using xo::scm::Expression; using xo::scm::make_apply; - using xo::scm::PrimitiveInterface; + using xo::scm::PrimitiveExprInterface; using xo::scm::Primitive; using xo::scm::make_primitive; using xo::scm::ConstantInterface; @@ -95,24 +95,24 @@ namespace xo { // ----- Primitives ----- - py::class_>(m, "PrimitiveInterface") - .def("name", &PrimitiveInterface::name, + rp>(m, "PrimitiveInterface") + .def("name", &PrimitiveExprInterface::name, py::doc("name of this primitive function; use this name to invoke the function")) - .def("n_arg", &PrimitiveInterface::n_arg, + .def("n_arg", &PrimitiveExprInterface::n_arg, py::doc("number of arguments to this function (not counting return value)")) ; using int32_t = std::int32_t; py::class_, - PrimitiveInterface, + PrimitiveExprInterface, rp>>(m, "Primitive_i32_i32") ; py::class_, - PrimitiveInterface, + PrimitiveExprInterface, rp>>(m, "Primitive_double_double") ; using Fn_dbl_dbl_type = double (*)(double); @@ -136,7 +136,7 @@ namespace xo { py::doc("create primitive representing the ::cos() function")); py::class_, - PrimitiveInterface, + PrimitiveExprInterface, rp>>(m, "Primitive_double_double_double") ;