xo-interpreter2 stack: define-expr's work at top-level
This commit is contained in:
parent
66492c1d99
commit
b64dee41cb
2 changed files with 22 additions and 3 deletions
|
|
@ -75,9 +75,6 @@ namespace xo {
|
|||
requires (std::same_as<Args, obj<AGCObject>> && ...)
|
||||
static DArray * array(obj<AAllocator> mm, Args... args);
|
||||
|
||||
const obj<AGCObject> & operator[](size_type index) const noexcept { return elts_[index]; }
|
||||
obj<AGCObject> & operator[](size_type index) noexcept { return elts_[index]; }
|
||||
|
||||
///@}
|
||||
/** @defgroup darray-access acecss methods **/
|
||||
///@{
|
||||
|
|
@ -91,6 +88,10 @@ namespace xo {
|
|||
size_type size() const noexcept { return size_; }
|
||||
/** return element @p index of this array (0-based) **/
|
||||
obj<AGCObject> at(size_type index) const;
|
||||
|
||||
const obj<AGCObject> & operator[](size_type index) const noexcept { return elts_[index]; }
|
||||
obj<AGCObject> & operator[](size_type index) noexcept { return elts_[index]; }
|
||||
|
||||
///@}
|
||||
/** @defgroup darray-iterators iterators **/
|
||||
///@{
|
||||
|
|
@ -106,6 +107,11 @@ namespace xo {
|
|||
/** @defgroup darray-general general methods **/
|
||||
///@{
|
||||
|
||||
/** resize to @p new_size. @p new_size may not be larger than capacity
|
||||
* Return true if resize was accomplished; false otherwise.
|
||||
**/
|
||||
bool resize(size_type new_size) noexcept;
|
||||
|
||||
///@}
|
||||
/** @defgroup darray-conversion-operators conversion operators **/
|
||||
///@{
|
||||
|
|
|
|||
|
|
@ -84,6 +84,19 @@ namespace xo {
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
DArray::resize(size_type new_z) noexcept {
|
||||
if (new_z >= capacity_) {
|
||||
return false;
|
||||
} else if (new_z > size_) {
|
||||
// ensure new size is zeroed (we/re not zeroing if/when we shrink)
|
||||
::memset((std::byte *)(&elts_[size_]), 0, (std::byte *)(&elts_[new_z]) - (std::byte *)(&elts_[size_]));
|
||||
}
|
||||
|
||||
this->size_ = new_z;
|
||||
return true;
|
||||
}
|
||||
|
||||
// printing support
|
||||
|
||||
bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue