xo-expression: refactor: Lambda/Primitive share FunctionInterface
This commit is contained in:
parent
0595c7c74e
commit
5c4b062cf8
6 changed files with 63 additions and 22 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "PrimitiveInterface.hpp"
|
||||
#include "xo/reflect/Reflect.hpp"
|
||||
//#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -42,14 +43,8 @@ namespace xo {
|
|||
|
||||
FunctionPointer value() const { return value_; }
|
||||
|
||||
// ----- PrimitiveInterface -----
|
||||
|
||||
virtual std::string const & name() const override { return name_; }
|
||||
|
||||
// ----- ConstantInterface -----
|
||||
|
||||
virtual TypeDescr value_td() const override { return value_td_; }
|
||||
virtual TaggedPtr value_tp() const override {
|
||||
TypeDescr value_td() const { return value_td_; }
|
||||
TaggedPtr value_tp() const {
|
||||
/* note: idk why, but need to spell this out in two steps with gcc 13.2 */
|
||||
const void * erased_cptr = &value_;
|
||||
void * erased_ptr = const_cast<void*>(erased_cptr);
|
||||
|
|
@ -57,6 +52,15 @@ namespace xo {
|
|||
return TaggedPtr(value_td_, erased_ptr);
|
||||
}
|
||||
|
||||
// ----- PrimitiveInterface -----
|
||||
|
||||
// ----- FunctionInterface -----
|
||||
|
||||
virtual std::string const & name() const override { return name_; }
|
||||
virtual int n_arg() const override { return this->value_td()->n_fn_arg(); }
|
||||
virtual TypeDescr fn_retval() const override { return this->value_td()->fn_retval(); }
|
||||
virtual TypeDescr fn_arg(uint32_t i) const override { return this->value_td()->fn_arg(i); }
|
||||
|
||||
// ----- Expression -----
|
||||
|
||||
virtual void display(std::ostream & os) const override {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue