xo-expression: naming: {Primitive,Function}ExprInterface

This commit is contained in:
Roland Conybeare 2025-11-26 13:43:02 -05:00
commit a49fe25ace
5 changed files with 18 additions and 21 deletions

View file

@ -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<FunctionInterface> from(bp<Expression> x) {
return bp<FunctionInterface>::from(x);
static bp<FunctionExprInterface> from(bp<Expression> x) {
return bp<FunctionExprInterface>::from(x);
}
virtual const std::string & name() const = 0;

View file

@ -6,13 +6,12 @@
#pragma once
#include "Expression.hpp"
#include "FunctionInterface.hpp"
#include "FunctionExprInterface.hpp"
#include "Variable.hpp"
#include "LocalSymtab.hpp"
#include <map>
#include <vector>
#include <string>
//#include <cstdint>
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

View file

@ -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 <typename FunctionPointer>
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<FunctionPointer>()},
value_{fnptr},

View file

@ -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 <cstdint>
#include <type_traits>
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<PrimitiveInterface> from(bp<Expression> x) {
return bp<PrimitiveInterface>::from(x);
static bp<PrimitiveExprInterface> from(bp<Expression> x) {
return bp<PrimitiveExprInterface>::from(x);
}
/** if true, Jit will try to explicitly symbol for this primitive

View file

@ -259,7 +259,7 @@ namespace xo {
TypeDescr lambda_td,
const rp<LocalSymtab> & local_env,
const rp<Expression> & body)
: FunctionInterface(exprtype::lambda, lambda_td),
: FunctionExprInterface(exprtype::lambda, lambda_td),
name_{name},
body_{body},
local_env_{local_env}