Made split_cons_expr a global function

This commit is contained in:
John Wiegley 2012-03-13 10:33:51 -05:00
parent c8dd3d28e3
commit e65fc729bc
2 changed files with 22 additions and 20 deletions

View file

@ -48,31 +48,31 @@ void intrusive_ptr_release(const expr_t::op_t * op)
op->release(); op->release();
} }
namespace { value_t split_cons_expr(expr_t::ptr_op_t op)
value_t split_cons_expr(expr_t::ptr_op_t op) {
{ if (op->kind == expr_t::op_t::O_CONS) {
if (op->kind == expr_t::op_t::O_CONS) { value_t seq;
value_t seq; seq.push_back(expr_value(op->left()));
seq.push_back(expr_value(op->left()));
expr_t::ptr_op_t next = op->right(); expr_t::ptr_op_t next = op->right();
while (next) { while (next) {
expr_t::ptr_op_t value_op; expr_t::ptr_op_t value_op;
if (next->kind == expr_t::op_t::O_CONS) { if (next->kind == expr_t::op_t::O_CONS) {
value_op = next->left(); value_op = next->left();
next = next->has_right() ? next->right() : NULL; next = next->has_right() ? next->right() : NULL;
} else { } else {
value_op = next; value_op = next;
next = NULL; next = NULL;
}
seq.push_back(expr_value(value_op));
} }
return seq; seq.push_back(expr_value(value_op));
} else {
return expr_value(op);
} }
return seq;
} else {
return expr_value(op);
} }
}
namespace {
inline void check_type_context(scope_t& scope, value_t& result) inline void check_type_context(scope_t& scope, value_t& result)
{ {
if (scope.type_required() && if (scope.type_required() &&

View file

@ -371,6 +371,8 @@ expr_t::op_t::wrap_functor(expr_t::func_t fobj) {
string op_context(const expr_t::ptr_op_t op, string op_context(const expr_t::ptr_op_t op,
const expr_t::ptr_op_t locus = NULL); const expr_t::ptr_op_t locus = NULL);
value_t split_cons_expr(expr_t::ptr_op_t op);
} // namespace ledger } // namespace ledger
#endif // _OP_H #endif // _OP_H