xo-object2: obj<ACollector> argument to DArray::push_back()
This commit is contained in:
parent
32fea42633
commit
df32ec55c8
4 changed files with 22 additions and 12 deletions
|
|
@ -15,6 +15,7 @@
|
|||
//#include "expect_expr_xs.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::print::APrintable;
|
||||
using xo::reflect::typeseq;
|
||||
|
|
@ -73,7 +74,7 @@ namespace xo {
|
|||
*
|
||||
* See similar code in DExpectFormalArglistSsm::_make
|
||||
*/
|
||||
DArray * args = DArray::empty(mm, 8);
|
||||
DArray * args = DArray::_empty(mm, 8);
|
||||
|
||||
applyexprstatetype applystate
|
||||
= (fn_expr
|
||||
|
|
@ -232,23 +233,24 @@ namespace xo {
|
|||
assert(expr_gco);
|
||||
|
||||
obj<AAllocator,DArena> mm(&(p_psm->parser_alloc()));
|
||||
auto gc = obj<AAllocator>(mm).try_to_facet<ACollector>();
|
||||
|
||||
if (args_expr_v_->size() == args_expr_v_->capacity()) {
|
||||
// need to expand .args_expr_v_ capacity.
|
||||
// Could use DArena checkpoint to redo this in place,
|
||||
// since argument array must be on the top of the stack.
|
||||
|
||||
DArray * argv_2x = DArray::empty(mm, 2 * args_expr_v_->capacity());
|
||||
DArray * argv_2x = DArray::_empty(mm, 2 * args_expr_v_->capacity());
|
||||
|
||||
for (DArray::size_type i = 0, n = args_expr_v_->size(); i < n; ++i) {
|
||||
argv_2x->push_back((*args_expr_v_)[i]);
|
||||
argv_2x->push_back(gc, (*args_expr_v_)[i]);
|
||||
}
|
||||
|
||||
this->args_expr_v_ = argv_2x;
|
||||
}
|
||||
|
||||
if (args_expr_v_->size() < args_expr_v_->capacity())
|
||||
args_expr_v_->push_back(expr_gco);
|
||||
args_expr_v_->push_back(gc, expr_gco);
|
||||
|
||||
if (tk.tk_type() == tokentype::tk_rightparen) {
|
||||
obj<AExpression> apply_ex = this->assemble_expr(p_psm->expr_alloc());
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace xo {
|
|||
using xo::print::APrintable;
|
||||
using xo::print::ppstate;
|
||||
using xo::print::ppindentinfo;
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
using xo::mm::AAllocator;
|
||||
using xo::facet::FacetRegistry;
|
||||
|
|
@ -61,7 +62,7 @@ namespace xo {
|
|||
/* allocate room for 8 arguments (during parsing)
|
||||
* will re-alloc to expand as needed
|
||||
*/
|
||||
DArray * argl = DArray::empty(mm, 8);
|
||||
DArray * argl = DArray::_empty(mm, 8);
|
||||
|
||||
return new (mem) DExpectFormalArglistSsm(argl);
|
||||
}
|
||||
|
|
@ -198,18 +199,22 @@ namespace xo {
|
|||
// could do this in place since this SSM is at the top of the parser stack.
|
||||
|
||||
obj<AAllocator,DArena> mm(&parser_alloc);
|
||||
DArray * argl_2x = DArray::empty(mm, 2 * argl_->capacity());
|
||||
DArray * argl_2x = DArray::_empty(mm, 2 * argl_->capacity());
|
||||
|
||||
auto gc = obj<AAllocator>(mm).try_to_facet<ACollector>();
|
||||
|
||||
for (DArray::size_type i = 0, n = argl_->size(); i < n; ++i) {
|
||||
// TODO: prefer non-bounds-checked access here
|
||||
argl_2x->push_back(argl_->at(i));
|
||||
argl_2x->push_back(gc, argl_->at(i));
|
||||
}
|
||||
|
||||
// update in place
|
||||
this->argl_ = argl_2x;
|
||||
}
|
||||
|
||||
this->argl_->push_back(var_o);
|
||||
auto gc = expr_alloc.try_to_facet<ACollector>();
|
||||
|
||||
this->argl_->push_back(gc, var_o);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
namespace xo {
|
||||
using xo::print::APrintable;
|
||||
using xo::facet::FacetRegistry;
|
||||
using xo::mm::ACollector;
|
||||
using xo::mm::AGCObject;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -142,8 +143,8 @@ namespace xo {
|
|||
if (state_.code() == QArrayXst::code::qarray_0) {
|
||||
this->state_ = QArrayXst(QArrayXst::code::qarray_1a);
|
||||
|
||||
this->array_ = DArray::empty(p_psm->expr_alloc(),
|
||||
8 /*heuristic starting capacity*/);
|
||||
this->array_ = DArray::_empty(p_psm->expr_alloc(),
|
||||
8 /*heuristic starting capacity*/);
|
||||
|
||||
DExpectQLiteralSsm::start(p_psm,
|
||||
false /*cxl_on_rightparen*/,
|
||||
|
|
@ -177,6 +178,8 @@ namespace xo {
|
|||
DExpectQArraySsm::on_quoted_literal(obj<AGCObject> lit,
|
||||
ParserStateMachine * p_psm)
|
||||
{
|
||||
auto gc = p_psm->expr_alloc().try_to_facet<ACollector>();
|
||||
|
||||
if(state_.code() == QArrayXst::code::qarray_1a) {
|
||||
// append lit at the end of array_
|
||||
{
|
||||
|
|
@ -192,7 +195,7 @@ namespace xo {
|
|||
2 * array_->capacity());
|
||||
}
|
||||
|
||||
bool ok = array_->push_back(lit);
|
||||
bool ok = array_->push_back(gc, lit);
|
||||
|
||||
assert(ok);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace xo {
|
|||
DGlobalEnv::_make(obj<AAllocator> mm,
|
||||
DGlobalSymtab * symtab)
|
||||
{
|
||||
DArray * values = DArray::empty(mm, symtab->var_capacity());
|
||||
DArray * values = DArray::_empty(mm, symtab->var_capacity());
|
||||
|
||||
void * mem = mm.alloc_for<DGlobalSymtab>();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue