xo-expression: use Reflect::require_function() for precision
This commit is contained in:
parent
2b32aa83c7
commit
6783cb7e8c
3 changed files with 14 additions and 6 deletions
|
|
@ -35,6 +35,9 @@ namespace xo {
|
|||
const std::vector<std::string> & argv() const { return argv_; }
|
||||
const ref::rp<Expression> & body() const { return body_; }
|
||||
|
||||
/** return number of arguments expected by this function **/
|
||||
int n_arg() const { return argv_.size(); }
|
||||
|
||||
// ----- Expression -----
|
||||
|
||||
virtual void display(std::ostream & os) const override;
|
||||
|
|
|
|||
|
|
@ -33,17 +33,20 @@ namespace xo {
|
|||
FunctionPointer fnptr)
|
||||
: PrimitiveInterface(),
|
||||
name_{name},
|
||||
value_td_{Reflect::require<FunctionPointer>()},
|
||||
value_td_{Reflect::require_function<FunctionPointer>()},
|
||||
value_{fnptr}
|
||||
{}
|
||||
{
|
||||
if (!value_td_->is_function())
|
||||
throw std::runtime_error("Primitive: expected function pointer");
|
||||
if (!value_td_->fn_retval())
|
||||
throw std::runtime_error("Primitive: expected non-null function return value");
|
||||
}
|
||||
|
||||
FunctionPointer value() const { return value_; }
|
||||
|
||||
// ----- PrimitiveInterface -----
|
||||
|
||||
virtual std::string const & name() const { return name_; }
|
||||
/** FIXME for now **/
|
||||
virtual int n_arg() const { return 1; }
|
||||
virtual std::string const & name() const override { return name_; }
|
||||
|
||||
// ----- ConstantInterface -----
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ namespace xo {
|
|||
}
|
||||
|
||||
virtual const std::string & name() const = 0;
|
||||
virtual int n_arg() const = 0;
|
||||
int n_arg() const { return this->value_td()->n_fn_arg(); }
|
||||
TypeDescr fn_retval() const { return this->value_td()->fn_retval(); }
|
||||
TypeDescr fn_arg(uint32_t i) const { return this->value_td()->fn_arg(i); }
|
||||
|
||||
//virtual TypeDescr value_td() const override = 0;
|
||||
//virtual TaggedPtr value_tp() const override = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue