/** @file Apply.hpp * * Author: Roland Conybeare **/ #pragma once #include "Expression.hpp" //#include namespace xo { namespace ast { /** @class Apply * @brief syntax for a function call. * * In general we don't know function to be invoked * until runtime, depending on the nature of Expression. **/ class Apply : public Expression { public: Apply(const ref::rp & fn, const std::vector> & argv) : Expression(exprtype::apply), fn_{fn}, argv_(argv) {} /** downcast from Expression **/ static ref::brw from(ref::brw x) { return ref::brw::from(x); } const ref::rp & fn() const { return fn_; } const std::vector> & argv() const { return argv_; } virtual void display(std::ostream & os) const; private: /** function to invoke **/ ref::rp fn_; /** argument expressions, in l-to-r order **/ std::vector> argv_; }; /*Apply*/ inline ref::rp make_apply(const ref::rp & fn, const ref::rp & arg1) { std::vector> argv; argv.push_back(arg1); return new Apply(fn, argv); } /*make_apply*/ } /*namespace ast*/ } /*namespace xo*/ /** end Apply.hpp **/