xo-expression2 stack: + mvp DGlobalSymtab impl
This commit is contained in:
parent
4c1c746763
commit
3e53b0d10a
2 changed files with 24 additions and 0 deletions
|
|
@ -58,6 +58,13 @@ namespace xo {
|
|||
static DArray * empty(obj<AAllocator> mm,
|
||||
size_type cap);
|
||||
|
||||
/** create copy of @p src using memory from @p mm
|
||||
* with capacity for @p new_cap elements
|
||||
**/
|
||||
static DArray * copy(obj<AAllocator> mm,
|
||||
DArray * src,
|
||||
size_type new_cap);
|
||||
|
||||
/** create array containing elements @p args, using memory from @p mm.
|
||||
* Nullptr if space exhausted.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -37,6 +37,23 @@ namespace xo {
|
|||
return result;
|
||||
}
|
||||
|
||||
DArray *
|
||||
DArray::copy(obj<AAllocator> mm,
|
||||
DArray * src,
|
||||
size_type new_cap)
|
||||
{
|
||||
DArray * dest = empty(mm, new_cap);
|
||||
|
||||
/** could just memcpy here **/
|
||||
for (size_type i = 0, n = src->size(); i < n; ++i) {
|
||||
dest->elts_[i] = src->elts_[i];
|
||||
}
|
||||
|
||||
dest->size_ = src->size();
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
obj<AGCObject>
|
||||
DArray::at(size_type ix) const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue