#include <rewrite/desugarer.hh>
#include <rewrite/pattern-binder.hh>
#include <rewrite/rewrite.hh>
#include <rewrite/rescoper.hh>

namespace rewrite
{
  // FIXME: template-factor those two
  ast::rNary
  rewrite(ast::rConstNary nary)
  {
    Desugarer desugar;
    Rescoper rescope;
    ast::rAst res;

    desugar(nary.get());
    res = desugar.result_get();

    rescope(res.get());
    res = rescope.result_get();

    return res.unsafe_cast<ast::Nary>();
  }

  ast::rExp
  rewrite(ast::rConstExp nary)
  {
    Desugarer desugar;
    Rescoper rescope;
    ast::rAst res;

    desugar(nary.get());
    res = desugar.result_get();

    rescope(res.get());
    res = rescope.result_get();

    return res.unsafe_cast<ast::Exp>();
  }
}

#include <rewrite/desugarer.hh>
#include <rewrite/pattern-binder.hh>
#include <rewrite/rewrite.hh>
#include <rewrite/rescoper.hh>

namespace rewrite
{
  ast::rNary
  rewrite(ast::rConstNary nary)
  {
    return rewrite(ast::rConstExp(nary)).unsafe_cast<ast::Nary>();
  }

  ast::rExp
  rewrite(ast::rConstExp nary)
  {
    Desugarer desugar;
    Rescoper rescope;
    ast::rAst res;

    desugar(nary.get());
    res = desugar.result_get();

    rescope(res.get());
    res = rescope.result_get();

    return res.unsafe_cast<ast::Exp>();
  }
}

Make inner call instead of duplicating the code.
Make inner call instead of duplicating the code.

	* src/rewrite/rewrite.cc (rewrite(ast::rConstNary)): Put
	appropriate type casts around an inner call rather than
	duplicate the code.
