xo-expression: add explicit types to all Expressions
This commit is contained in:
parent
b18de1b0ce
commit
9ff173f68a
12 changed files with 223 additions and 54 deletions
|
|
@ -4,7 +4,29 @@
|
|||
#include "xo/indentlog/print/vector.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::ref::rp;
|
||||
|
||||
namespace ast {
|
||||
rp<Apply>
|
||||
Apply::make(const rp<Expression> & fn,
|
||||
const std::vector<rp<Expression>> & argv)
|
||||
{
|
||||
/* extract result type from function type */
|
||||
TypeDescr fn_valuetype = fn->valuetype();
|
||||
|
||||
if (!fn_valuetype->is_function()) {
|
||||
throw std::runtime_error
|
||||
(tostr("Apply::make: found expression F in function position,"
|
||||
" with value-type FT where a function type expected",
|
||||
xtag("FT", fn_valuetype->short_name()),
|
||||
xtag("F", fn_valuetype)));
|
||||
}
|
||||
|
||||
TypeDescr fn_retval_type = fn_valuetype->fn_retval();
|
||||
|
||||
return new Apply(fn_retval_type, fn, argv);
|
||||
}
|
||||
|
||||
void
|
||||
Apply::display(std::ostream & os) const {
|
||||
os << "<Apply"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue