# HG changeset patch # User jwe # Date 1039210159 0 # Node ID 23d06c9e1eddf408e77fcbc8ade3be5b35b17b5b # Parent 4a392a01e51a3120508ec011e8271fab05946ee9 [project @ 2002-12-06 21:29:17 by jwe] diff -r 4a392a01e51a -r 23d06c9e1edd liboctave/ChangeLog --- a/liboctave/ChangeLog Thu Dec 05 04:43:20 2002 +0000 +++ b/liboctave/ChangeLog Fri Dec 06 21:29:19 2002 +0000 @@ -1,3 +1,8 @@ +2002-12-06 John W. Eaton + + * oct-alloc.h (DECLARE_OCTAVE_ALLOCATOR): Also declare and define + a placement operator new. + 2002-12-03 John W. Eaton * Matrix.h: Include mx-ops.h too. diff -r 4a392a01e51a -r 23d06c9e1edd liboctave/oct-alloc.h --- a/liboctave/oct-alloc.h Thu Dec 05 04:43:20 2002 +0000 +++ b/liboctave/oct-alloc.h Fri Dec 06 21:29:19 2002 +0000 @@ -61,6 +61,8 @@ #define DECLARE_OCTAVE_ALLOCATOR \ public: \ + void *operator new (size_t size, void *p) \ + { return ::operator new (size, p); } \ void *operator new (size_t size) { return allocator.alloc (size); } \ void operator delete (void *p, size_t size) { allocator.free (p, size); } \ private: \ diff -r 4a392a01e51a -r 23d06c9e1edd src/BaseSLList.cc --- a/src/BaseSLList.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,257 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "BaseSLList.h" - -#include "error.h" - -void BaseSLList::error(const char* msg) const -{ - ::error ("SLList: %s", msg); -} - -int BaseSLList::length() const -{ - int l = 0; - BaseSLNode* t = last; - if (t != 0) do { ++l; t = t->tl; } while (t != last); - return l; -} - -void BaseSLList::clear() -{ - if (last == 0) - return; - - BaseSLNode* p = last->tl; - last->tl = 0; - last = 0; - - while (p != 0) - { - BaseSLNode* nxt = p->tl; - delete_node(p); - p = nxt; - } -} - - -// Note: This is an internal method. It does *not* free old contents! - -void BaseSLList::copy(const BaseSLList& a) -{ - if (a.last == 0) - last = 0; - else - { - BaseSLNode* p = a.last->tl; - BaseSLNode* h = copy_node(p->item()); - last = h; - for (;;) - { - if (p == a.last) - { - last->tl = h; - return; - } - p = p->tl; - BaseSLNode* n = copy_node(p->item()); - last->tl = n; - last = n; - } - } -} - -BaseSLList& BaseSLList::operator = (const BaseSLList& a) -{ - if (last != a.last) - { - clear(); - copy(a); - } - return *this; -} - -Pix BaseSLList::prepend(const void *datum) -{ - return prepend(copy_node(datum)); -} - - -Pix BaseSLList::prepend(BaseSLNode* t) -{ - if (t == 0) return 0; - if (last == 0) - t->tl = last = t; - else - { - t->tl = last->tl; - last->tl = t; - } - return Pix(t); -} - - -Pix BaseSLList::append(const void *datum) -{ - return append(copy_node(datum)); -} - -Pix BaseSLList::append(BaseSLNode* t) -{ - if (t == 0) return 0; - if (last == 0) - t->tl = last = t; - else - { - t->tl = last->tl; - last->tl = t; - last = t; - } - return Pix(t); -} - -void BaseSLList::join(BaseSLList& b) -{ - BaseSLNode* t = b.last; - b.last = 0; - if (last == 0) - last = t; - else if (t != 0) - { - BaseSLNode* f = last->tl; - last->tl = t->tl; - t->tl = f; - last = t; - } -} - -Pix BaseSLList::ins_after(Pix p, const void *datum) -{ - BaseSLNode* u = (BaseSLNode*)p; - BaseSLNode* t = copy_node(datum); - if (last == 0) - t->tl = last = t; - else if (u == 0) // ins_after 0 means prepend - { - t->tl = last->tl; - last->tl = t; - } - else - { - t->tl = u->tl; - u->tl = t; - if (u == last) - last = t; - } - return Pix(t); -} - -void BaseSLList::del_after(Pix p) -{ - BaseSLNode* u = (BaseSLNode*)p; - if (last == 0 || u == last) error("cannot del_after last"); - if (u == 0) u = last; // del_after 0 means delete first - BaseSLNode* t = u->tl; - if (u == t) - last = 0; - else - { - u->tl = t->tl; - if (last == t) - last = u; - } - delete_node(t); -} - -int BaseSLList::owns(Pix p) const -{ - BaseSLNode* t = last; - if (t != 0 && p != 0) - { - do - { - if (Pix(t) == p) return 1; - t = t->tl; - } while (t != last); - } - return 0; -} - -int BaseSLList::remove_front(void *dst, int signal_error) -{ - if (last) - { - BaseSLNode* t = last->tl; - copy_item(dst, t->item()); - if (t == last) - last = 0; - else - last->tl = t->tl; - delete_node(t); - return 1; - } - if (signal_error) - error("remove_front of empty list"); - return 0; -} - -void BaseSLList::del_front() -{ - if (last == 0) error("del_front of empty list"); - BaseSLNode* t = last->tl; - if (t == last) - last = 0; - else - last->tl = t->tl; - delete_node(t); -} - -int BaseSLList::OK() const -{ - int v = 1; - if (last != 0) - { - BaseSLNode* t = last; - long count = LONG_MAX; // Lots of chances to find last! - do - { - count--; - t = t->tl; - } while (count > 0 && t != last); - v &= count > 0; - } - if (!v) error("invariant failure"); - return v; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/BaseSLList.h --- a/src/BaseSLList.h Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef _BaseSLList_h -#define _BaseSLList_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#undef OK - -#include - -struct BaseSLNode -{ - union { - struct BaseSLNode *tl; - double dummy; /* To force correct alignment */ - }; - void *item() {return (void*)(this+1);} // Return ((SLNode*)this)->hd -}; - -class -BaseSLList -{ - protected: - BaseSLNode *last; - virtual void delete_node(BaseSLNode*node) = 0; - virtual BaseSLNode* copy_node(const void* datum) = 0; - virtual void copy_item(void *dst, void *src) = 0; - virtual ~BaseSLList() { } - BaseSLList() { last = 0; } - void copy(const BaseSLList&); - BaseSLList& operator = (const BaseSLList& a); - Pix ins_after(Pix p, const void *datum); - Pix prepend(const void *datum); - Pix append(const void *datum); - int remove_front(void *dst, int signal_error = 0); - void join(BaseSLList&); - public: - int length() const; - int empty() const { return last == 0; } - void clear(); - Pix prepend(BaseSLNode*); - Pix append(BaseSLNode*); - int OK() const; - void error(const char* msg) const; - void del_after(Pix p); - int owns(Pix p) const; - void del_front(); -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/Cell.h --- a/src/Cell.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/Cell.h Fri Dec 06 21:29:19 2002 +0000 @@ -46,7 +46,7 @@ Cell (const octave_value& val) : Array2 (1, 1, val) { } - Cell (int n, int m, const octave_value& val = octave_value ()) + Cell (int n, int m, const octave_value& val = resize_fill_value ()) : Array2 (n, m, val) { } Cell (const Array2& c) @@ -69,7 +69,7 @@ // XXX FIXME XXX bool is_true (void) const { return false; } - static octave_value resize_fill_value (void) { return octave_value (); } + static octave_value resize_fill_value (void) { return Matrix (); } }; #endif diff -r 4a392a01e51a -r 23d06c9e1edd src/ChangeLog --- a/src/ChangeLog Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ChangeLog Fri Dec 06 21:29:19 2002 +0000 @@ -1,3 +1,73 @@ +2002-12-06 John W. Eaton + + * pt-mat.cc (class tm_row_const::tm_row_const_rep): Derive from + octave_base_list instead of SLList. Fix tm_row_const member + functions as needed, change all uses. + (class tm_const): Derive from octave_base_list, not SLList. Fix + member functions as needed, change all uses. + * pt-mat.h (class tree_matrix): Derive from octave_base_list + instead of including SLList object as data member. Fix member + functions as needed, change all uses. + + * pt-idx.h (tree_index_expression::args, + tree_index_expression::arg_nm, tree_index_expression::dyn_field): + Now std::list, not SLList. Fix member functions as needed, change + all uses. + + * oct-map.h (Octave_map::map): Now std::map instead of CHMap. + Fix member functions as needed, change all uses. + + * oct-lvalue.h (octave_lvalue::idx): Now std::list instead of + SLList object. Fix member functions as needed, change all uses. + + * dynamic-ld.cc (octave_shlib_list::lib_list): Now std::list + instead of DLList object. Fix member functions as needed, change + all uses. + + * ov.h (octave_value::subsref, octave_value::subsasgn): + Index arg is not std::list, not SLList. Change all derived + classes, all uses. + + * pt-stmt.h (tree_statement_list): Derive from base_octave_list + object instead of including SLList object as data member. Fix + member functions as needed, change all uses. + * pt-select.h (tree_switch_case_list): Likewise. + (tree_if_command_list): Likewise. + * pt-misc.h (tree_parameter_list, tree_return_list, + tree_va_return_list): Likewise. + * pt-plot.h (subplot_list): Likewise. + * pt-mat.h (tree_matrix): Likewise. + * pt-decl.h (tree_decl_init_list): Likewise. + * pt-arg-list.h (tree_argument_list): Likewise. + * comment-list.h (octave_comment_list): Likewise. + + * BaseSLList.cc, DLList.cc, Map.cc, SLList.cc, SLStack.cc, + Stack.cc: Delete. + * Makefile.in (DIST_SRC): Delete them from the list. + + * BaseSLList.h, DLList.h, Map.h, Pix.h, SLList.h, SLStack.h, + Stack.h: Delete + * Makefile.in (INCLUDES): Delete them from the list. + + * Map-oct-obj.cc, SLList-expr.cc, SLList-misc.cc, SLList-plot.cc, + SLList-tc.cc, SLList-tm.cc: Delete. + * Makefile.in (TI_XSRC): Delete them from the list. + + * ov-base-mat.cc (octave_base_matrix::assign): Pass + MT::resize_fill_value () as third arg for ::assign. + + * Cell.h (Cell::resize_fill_value): Use empty Matrix object, not + undefined octave_value object. + (Cell::Cell (int, int, const octave_value&)): Use + resize_fill_value () as default value, not undefined octave_value + object. + +2002-12-05 John W. Eaton + + * Makefile.in (DEFUN_PATTERN): Make it work for DEFCMD too. + + * base-list.h: New file. + 2002-12-04 John W. Eaton * toplev.cc (octave_interpreter_ready): New global variable. diff -r 4a392a01e51a -r 23d06c9e1edd src/DLList.cc --- a/src/DLList.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,331 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "DLList.h" - -#include "error.h" - -void BaseDLList::error(const char* msg) const -{ - ::error ("DLList: %s", msg); -} - -int BaseDLList::length() const -{ - int l = 0; - BaseDLNode* t = h; - if (t != 0) do { ++l; t = t->fd; } while (t != h); - return l; -} - -// Note: This is an internal method. It does *not* free old contents! - -void BaseDLList::copy(const BaseDLList& a) -{ - if (a.h == 0) - h = 0; - else - { - BaseDLNode* p = a.h; - BaseDLNode* t = copy_node(p->item()); - h = t; - p = p->fd; - while (p != a.h) - { - BaseDLNode* n = copy_node(p->item()); - t->fd = n; - n->bk = t; - t = n; - p = p->fd; - } - t->fd = h; - h->bk = t; - return; - } -} - -void BaseDLList::clear() -{ - if (h == 0) - return; - - BaseDLNode* p = h->fd; - h->fd = 0; - h = 0; - - while (p != 0) - { - BaseDLNode* nxt = p->fd; - delete_node(p); - p = nxt; - } -} - -BaseDLList& BaseDLList::operator = (const BaseDLList& a) -{ - if (h != a.h) - { - clear(); - copy(a); - } - return *this; -} - - -Pix BaseDLList::prepend(const void *datum) -{ - BaseDLNode* t = copy_node(datum); - if (h == 0) - t->fd = t->bk = h = t; - else - { - t->fd = h; - t->bk = h->bk; - h->bk->fd = t; - h->bk = t; - h = t; - } - return Pix(t); -} - -Pix BaseDLList::append(const void *datum) -{ - BaseDLNode* t = copy_node(datum); - if (h == 0) - t->fd = t->bk = h = t; - else - { - t->bk = h->bk; - t->bk->fd = t; - t->fd = h; - h->bk = t; - } - return Pix(t); -} - -Pix BaseDLList::ins_after(Pix p, const void *datum) -{ - if (p == 0) return prepend(datum); - BaseDLNode* u = (BaseDLNode*) p; - BaseDLNode* t = copy_node(datum); - t->bk = u; - t->fd = u->fd; - u->fd->bk = t; - u->fd = t; - return Pix(t); -} - -Pix BaseDLList::ins_before(Pix p, const void *datum) -{ - if (p == 0) error("null Pix"); - BaseDLNode* u = (BaseDLNode*) p; - BaseDLNode* t = copy_node(datum); - t->bk = u->bk; - t->fd = u; - u->bk->fd = t; - u->bk = t; - if (u == h) h = t; - return Pix(t); -} - -void BaseDLList::join(BaseDLList& b) -{ - BaseDLNode* t = b.h; - b.h = 0; - if (h == 0) - h = t; - else if (t != 0) - { - BaseDLNode* l = t->bk; - h->bk->fd = t; - t->bk = h->bk; - h->bk = l; - l->fd = h; - } -} - -int BaseDLList::owns(Pix p) const -{ - BaseDLNode* t = h; - if (t != 0 && p != 0) - { - do - { - if (Pix(t) == p) return 1; - t = t->fd; - } while (t != h); - } - return 0; -} - -void BaseDLList::del(Pix& p, int dir) -{ - if (p == 0) error("null Pix"); - BaseDLNode* t = (BaseDLNode*) p; - if (t->fd == t) - { - h = 0; - p = 0; - } - else - { - if (dir < 0) - { - if (t == h) - p = 0; - else - p = Pix(t->bk); - } - else - { - if (t == h->bk) - p = 0; - else - p = Pix(t->fd); - } - t->bk->fd = t->fd; - t->fd->bk = t->bk; - if (t == h) h = t->fd; - } - delete_node(t); -} - -void BaseDLList::del_after(Pix& p) -{ - if (p == 0) - { - del_front(); - return; - } - - BaseDLNode* b = (BaseDLNode*) p; - BaseDLNode* t = b->fd; - - if (b == t) - { - h = 0; - p = 0; - } - else - { - t->bk->fd = t->fd; - t->fd->bk = t->bk; - if (t == h) h = t->fd; - } - delete_node(t); -} - -void BaseDLList::remove_front(void *dst) -{ - if (h == 0) - error("remove_front of empty list"); - else { - BaseDLNode* t = h; - copy_item(dst, t->item()); - if (h->fd == h) - h = 0; - else - { - h->fd->bk = h->bk; - h->bk->fd = h->fd; - h = h->fd; - } - delete_node(t); - } -} - -void BaseDLList::del_front() -{ - if (h == 0) - error("del_front of empty list"); - BaseDLNode* t = h; - if (h->fd == h) - h = 0; - else - { - h->fd->bk = h->bk; - h->bk->fd = h->fd; - h = h->fd; - } - delete_node(t); -} - -void BaseDLList::remove_rear(void *dst) -{ - if (h == 0) - error("remove_rear of empty list"); - else - { - BaseDLNode* t = h->bk; - copy_item(dst, t->item()); - if (h->fd == h) - h = 0; - else - { - t->fd->bk = t->bk; - t->bk->fd = t->fd; - } - delete_node(t); - } -} - -void BaseDLList::del_rear() -{ - if (h == 0) - error("del_rear of empty list"); - BaseDLNode* t = h->bk; - if (h->fd == h) - h = 0; - else - { - t->fd->bk = t->bk; - t->bk->fd = t->fd; - } - delete_node(t); -} - - -int BaseDLList::OK() const -{ - int v = 1; - if (h != 0) - { - BaseDLNode* t = h; - long count = LONG_MAX; // Lots of chances to find h! - do - { - count--; - v &= t->bk->fd == t; - v &= t->fd->bk == t; - t = t->fd; - } while (v && count > 0 && t != h); - v &= count > 0; - } - if (!v) error("invariant failure"); - return v; -} diff -r 4a392a01e51a -r 23d06c9e1edd src/DLList.h --- a/src/DLList.h Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#ifndef _DLList_h -#define _DLList_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#undef OK - -#include - -struct BaseDLNode { - BaseDLNode *bk; - BaseDLNode *fd; - void *item() {return (void*)(this+1);} //Return ((DLNode*)this)->hd -}; - -template -class -DLNode : public BaseDLNode -{ - public: - T hd; - DLNode() { } - DLNode(const T& h, DLNode* p = 0, DLNode* n = 0) - : hd(h) { bk = p; fd = n; } - ~DLNode() { } -}; - -class -BaseDLList -{ - protected: - BaseDLNode *h; - - BaseDLList() { h = 0; } - void copy(const BaseDLList&); - BaseDLList& operator= (const BaseDLList& a); - virtual void delete_node(BaseDLNode*node) = 0; - virtual BaseDLNode* copy_node(const void* datum) = 0; - virtual void copy_item(void *dst, void *src) = 0; - virtual ~BaseDLList() { } - - Pix prepend(const void*); - Pix append(const void*); - Pix ins_after(Pix p, const void *datum); - Pix ins_before(Pix p, const void *datum); - void remove_front(void *dst); - void remove_rear(void *dst); - void join(BaseDLList&); - - public: - int empty() const { return h == 0; } - int length() const; - void clear(); - void error(const char* msg) const; - int owns(Pix p) const; - int OK() const; - void del(Pix& p, int dir = 1); - void del_after(Pix& p); - void del_front(); - void del_rear(); -}; - -template -class -DLList : public BaseDLList -{ - //friend class DLListTrav; - - virtual void delete_node(BaseDLNode *node) { delete (DLNode*)node; } - virtual BaseDLNode* copy_node(const void *datum) - { return new DLNode(*(const T*)datum); } - virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } - - public: - DLList() : BaseDLList() { } - DLList(const DLList& a) : BaseDLList() { copy(a); } - - DLList& operator = (const DLList& a) - { BaseDLList::operator=((const BaseDLList&) a); return *this; } - virtual ~DLList() { clear(); } - - Pix prepend(const T& item) {return BaseDLList::prepend(&item);} - Pix append(const T& item) {return BaseDLList::append(&item);} - - void join(DLList& a) { BaseDLList::join(a); } - - T& front() { - if (h == 0) error("front: empty list"); - return ((DLNode*)h)->hd; } - T& rear() { - if (h == 0) error("rear: empty list"); - return ((DLNode*)h->bk)->hd; - } - const T& front() const { - if (h == 0) error("front: empty list"); - return ((DLNode*)h)->hd; } - const T& rear() const { - if (h == 0) error("rear: empty list"); - return ((DLNode*)h->bk)->hd; - } - T remove_front() { T dst; BaseDLList::remove_front(&dst); return dst; } - T remove_rear() { T dst; BaseDLList::remove_rear(&dst); return dst; } - - T& operator () (Pix p) { - if (p == 0) error("null Pix"); - return ((DLNode*)p)->hd; - } - const T& operator () (Pix p) const { - if (p == 0) error("null Pix"); - return ((DLNode*)p)->hd; - } - Pix first() const { return Pix(h); } - Pix last() const { return (h == 0) ? 0 : Pix(h->bk); } - void next(Pix& p) const - { p = (p == 0 || h == 0 || p == h->bk)? 0 : Pix(((DLNode*)p)->fd); } - void prev(Pix& p) const - { p = (p == 0 || p == h)? 0 : Pix(((DLNode*)p)->bk); } - Pix ins_after(Pix p, const T& item) - {return BaseDLList::ins_after(p, &item); } - Pix ins_before(Pix p, const T& item) - {return BaseDLList::ins_before(p, &item);} -}; - -#endif diff -r 4a392a01e51a -r 23d06c9e1edd src/Makefile.in --- a/src/Makefile.in Thu Dec 05 04:43:20 2002 +0000 +++ b/src/Makefile.in Fri Dec 06 21:29:19 2002 +0000 @@ -79,8 +79,7 @@ pt-jump.h pt-loop.h pt-mat.h pt-misc.h pt-plot.h \ pt-pr-code.h pt-select.h pt-stmt.h pt-unop.h pt-walk.h \ -INCLUDES := BaseSLList.h Cell.h DLList.h Map.h Pix.h SLList.h \ - SLStack.h Stack.h c-file-ptr-stream.h comment-list.h defun-dld.h \ +INCLUDES := Cell.h c-file-ptr-stream.h comment-list.h defun-dld.h \ defun-int.h defun.h dirfns.h dynamic-ld.h error.h file-io.h \ fn-cache.h gripes.h help.h input.h lex.h load-save.h \ oct-fstrm.h oct-hist.h oct-iostrm.h oct-map.h oct-obj.h \ @@ -90,8 +89,7 @@ siglist.h symtab.h sysdep.h token.h toplev.h unwind-prot.h utils.h \ variables.h version.h xdiv.h xpow.h $(OV_INCLUDES) $(PT_INCLUDES) -TI_XSRC := Array-oc.cc Array-os.cc Array-sym.cc Array-tc.cc Map-oct-obj.cc \ - SLList-expr.cc SLList-misc.cc SLList-plot.cc SLList-tc.cc SLList-tm.cc +TI_XSRC := Array-oc.cc Array-os.cc Array-sym.cc Array-tc.cc TI_SRC := $(addprefix TEMPLATE-INST/, $(TI_XSRC)) @@ -121,8 +119,7 @@ pt-loop.cc pt-mat.cc pt-misc.cc pt-plot.cc pt-pr-code.cc \ pt-select.cc pt-stmt.cc pt-unop.cc -DIST_SRC := BaseSLList.cc Cell.cc DLList.cc Map.cc SLList.cc \ - SLStack.cc Stack.cc c-file-ptr-stream.cc comment-list.cc \ +DIST_SRC := Cell.cc c-file-ptr-stream.cc comment-list.cc \ cutils.c data.cc debug.cc defaults.cc defun.cc dirfns.cc \ dynamic-ld.cc error.cc file-io.cc fn-cache.cc gripes.cc \ help.cc input.cc lex.l load-save.cc main.c mappers.cc \ @@ -166,7 +163,7 @@ # so we have to repeat ourselves because some stupid egreps don't like # empty elements in alternation patterns. -DEFUN_PATTERN = "^[ \t]*DEFU(N|N_DLD|N_TEXT|N_MAPPER)[ \t]*\\(" +DEFUN_PATTERN = "^[ \t]*DEF(CMD|UN|UN_DLD|UN_TEXT|UN_MAPPER)[ \t]*\\(" DLD_DEF_FILES := $(patsubst %.cc, %.df, $(DLD_XSRC)) diff -r 4a392a01e51a -r 23d06c9e1edd src/Map.cc --- a/src/Map.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,303 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' versions -of Map and CHMap from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "Map.h" - -template -unsigned int -CHMap::hash (const std::string& str) const -{ - unsigned h = 0; - for (unsigned i = 0; i < str.length (); i++) - h = h * 33 + str[i]; - return h; -} - -template -Pix -Map::seek (const std::string& item) const -{ - Pix i = 0; - - for (i = first (); i != 0 && key (i) != item; next (i)) - ; // Skip items until match found. - - return i; -} - -template -int -Map::owns (Pix idx) const -{ - if (idx == 0) - return 0; - - for (Pix i = first (); i != 0; next (i)) - if (i == idx) - return 1; - - return 0; -} - -template -void -Map::clear (void) -{ - Pix i = first (); - while (i != 0) - { - del (key (i)); - i = first (); - } -} - -template -int -Map::contains (const std::string& item) const -{ - return seek (item) != 0; -} - -template -void -Map::error (const std::string& msg) const -{ - std::cerr << "Map: " << msg << "\n"; -} - -// CHMap class. - -#define index_to_CHptr(i) (X_CAST (void *, (i << 1) + 1)) - -template -CHMap::CHMap (const C& dflt, unsigned int sz) : Map (dflt) -{ - tab = new CHNode* [size = sz]; - for (unsigned int i = 0; i < size; ++i) - tab[i] = static_cast *> (index_to_CHptr (i+1)); - count = 0; -} - -template -CHMap::CHMap (const CHMap& a) : Map (a.def) -{ - tab = new CHNode* [size = a.size]; - for (unsigned int i = 0; i < size; ++i) - tab[i] = static_cast *> (index_to_CHptr (i+1)); - count = 0; - for (Pix p = a.first (); p; a.next (p)) - (*this) [a.key (p)] = a.contents (p); -} - -template -CHMap& -CHMap::operator = (const CHMap& a) -{ - Map::operator = (*this); - - unsigned int old_size = a.size; - - CHNode **old_tab = tab; - old_size = a.size; - - size = old_size; - tab = new CHNode* [size]; - - for (unsigned int i = 0; i < size; ++i) - tab[i] = static_cast *> (index_to_CHptr (i+1)); - - for (Pix p = a.first (); p; a.next (p)) - (*this) [a.key (p)] = a.contents (p); - - for (unsigned int i = 0; i < old_size; ++i) - { - CHNode *p = old_tab[i]; - old_tab[i] = static_cast *> (index_to_CHptr (i+1)); - while (p->goodCHptr ()) - { - CHNode *nxt = p->tl; - delete p; - p = nxt; - } - } - delete [] old_tab; - - return *this; -} - -template -Pix -CHMap::seek (const std::string& key) const -{ - unsigned int h = hash (key) % size; - - for (CHNode *t = tab[h]; t->goodCHptr (); t = t->tl) - if (key == t->hd) - return Pix (t); - - return 0; -} - -template -C& -CHMap::operator [] (const std::string& item) -{ - unsigned int h = hash (item) % size; - - CHNode *t = 0; - for (t = tab[h]; t->goodCHptr (); t = t->tl) - if (item == t->hd) - return t->cont; - - t = new CHNode (item, def, tab[h]); - tab[h] = t; - ++count; - return t->cont; -} - -template -void -CHMap::del (const std::string& key) -{ - unsigned int h = hash (key) % size; - - CHNode *t = tab[h]; - CHNode *trail = t; - while (t->goodCHptr ()) - { - if (key == t->hd) - { - if (trail == t) - tab[h] = t->tl; - else - trail->tl = t->tl; - delete t; - --count; - return; - } - trail = t; - t = t->tl; - } -} - -template -void -CHMap::clear (void) -{ - for (unsigned int i = 0; i < size; ++i) - { - CHNode *p = tab[i]; - tab[i] = static_cast *> (index_to_CHptr (i+1)); - while (p->goodCHptr ()) - { - CHNode *nxt = p->tl; - delete p; - p = nxt; - } - } - count = 0; -} - -template -Pix -CHMap::first (void) const -{ - for (unsigned int i = 0; i < size; ++i) - if (tab[i]->goodCHptr ()) - return Pix (tab[i]); - return 0; -} - -template -void -CHMap::next (Pix& p) const -{ - CHNode *t = (static_cast *> (p))->tl; - if (t->goodCHptr ()) - p = Pix (t); - else - { - for (unsigned int i = t->CHptr_to_index (); i < size; ++i) - { - if (tab[i]->goodCHptr ()) - { - p = Pix (tab[i]); - return; - } - } - p = 0; - } -} - -template -int -CHMap::OK (void) const -{ - int v = tab != 0; - int n = 0; - - for (unsigned int i = 0; i < size; ++i) - { - CHNode *p = 0; - - for (p = tab[i]; p->goodCHptr (); p = p->tl) - ++n; - - v &= p->CHptr_to_index () == i + 1; - } - - v &= count == n; - - if (! v) - error ("invariant failure"); - - return v; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/Map.h --- a/src/Map.h Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' versions -of Map and CHMap from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if ! defined (octave_Map_h) -#define octave_Map_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include - -#include - -template -class -Map -{ -protected: - int count; - C def; - -public: - Map (const C& dflt) : count (0), def (dflt) { } - - Map (const Map& m) : count (m.count), def (m.def) { } - - Map& operator = (const Map& m) - { - count = m.count; - def = m.def; - - return *this; - } - - virtual ~Map (void) { } - - int length (void) const { return count; } // current number of items - int empty (void) const { return count == 0; } - - virtual int contains (const std::string& key) const; // is key mapped? - - virtual void clear (void); // delete all items - - virtual C& operator [] (const std::string& key) = 0; // access contents by key - - virtual void del (const std::string& key) = 0; // delete entry - - virtual Pix first (void) const = 0; // Pix of first item or 0 - virtual void next (Pix& i) const = 0; // advance to next or 0 - virtual std::string key (Pix i) const = 0; // access key at i - virtual C& contents (Pix i) const = 0; // access contents at i - - virtual int owns (Pix i) const; // is i a valid Pix ? - virtual Pix seek (const std::string& key) const; // Pix of key - - C& dflt (void) { return def; } // access default val - - void error (const std::string& msg) const; - - virtual int OK (void) const = 0; // rep invariant -}; - -template -struct CHNode -{ - CHNode *tl; - std::string hd; - C cont; - - CHNode (void) : tl (0), hd (), cont () { } - - CHNode (const std::string& h, const C& c, CHNode *t = 0) - : tl (t), hd (h), cont (c) { } - - ~CHNode (void) { } - - // The nodes are linked together serially via a version of a trick - // used in some vtables: odd pointers are actually links to the next - // table entry. Not terrible, but not wonderful either. - - int goodCHptr (void) - { return ((((unsigned long) this) & 1) == 0); } - - unsigned int CHptr_to_index (void) - { return (((unsigned long) this) >> 1); } -}; - -#ifndef DEFAULT_INITIAL_CAPACITY -#define DEFAULT_INITIAL_CAPACITY 8 -#endif - -template -class -CHMap : public Map -{ -protected: - CHNode **tab; - unsigned int size; - -public: - CHMap (const C& dflt, unsigned int sz = DEFAULT_INITIAL_CAPACITY); - - CHMap (const CHMap& a); - - CHMap& operator = (const CHMap& a); - - ~CHMap (void) - { - clear (); - delete [] tab; - } - - C& operator [] (const std::string& key); - - void del (const std::string& key); - - Pix first (void) const; - void next (Pix& i) const; - - std::string key (Pix p) const - { - if (p == 0) - error ("null Pix"); - - return ((CHNode *) p)->hd; - } - - C& contents (Pix p) const - { - if (p == 0) - error ("null Pix"); - - return ((CHNode *) p)->cont; - } - - Pix seek (const std::string& key) const; - - int contains (const std::string& key) const - { - return seek (key) != 0; - } - - void clear (void); - int OK (void) const; - - unsigned int hash (const std::string& str) const; -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/Pix.h --- a/src/Pix.h Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ - -#ifndef _Pix_h -#define _Pix_h 1 -typedef void* Pix; -#endif diff -r 4a392a01e51a -r 23d06c9e1edd src/SLList.cc --- a/src/SLList.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SLList.h" - -template -SLList::~SLList (void) -{ - clear(); -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/SLList.h --- a/src/SLList.h Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef _SLList_h -#define _SLList_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include - -#include "BaseSLList.h" - -template -class -SLNode : public BaseSLNode -{ - public: - T hd; // Data part of node - SLNode() { } - SLNode(const T& h, SLNode* t = 0) - : hd(h) { tl = t; } - ~SLNode() { } -}; - -template -class -SLList : public BaseSLList -{ - private: - virtual void delete_node(BaseSLNode *node) { delete (SLNode*)node; } - virtual BaseSLNode* copy_node(const void *datum) - { return new SLNode(*(const T*)datum); } - virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } - -public: - SLList() : BaseSLList() { } - SLList(const SLList& a) : BaseSLList() { copy(a); } - SLList& operator = (const SLList& a) - { BaseSLList::operator=((const BaseSLList&) a); return *this; } - ~SLList (void); - - Pix prepend(const T& item) {return BaseSLList::prepend(&item);} - Pix append(const T& item) {return BaseSLList::append(&item);} - Pix prepend(SLNode* node) {return BaseSLList::prepend(node);} - Pix append(SLNode* node) {return BaseSLList::append(node);} - - T& operator () (Pix p) { - if (p == 0) error("null Pix"); - return ((SLNode*)(p))->hd; } - const T& operator () (Pix p) const { - if (p == 0) error("null Pix"); - return ((SLNode*)(p))->hd; } - inline Pix first() const { return (last == 0) ? 0 : Pix(last->tl); } - void next(Pix& p) const - { p = (p == 0 || p == last) ? 0 : Pix(((SLNode*)(p))->tl); } - Pix ins_after(Pix p, const T& item) - { return BaseSLList::ins_after(p, &item); } - void join(SLList& a) { BaseSLList::join(a); } - - T& front() { - if (last == 0) error("front: empty list"); - return ((SLNode*)last->tl)->hd; } - T& rear() { - if (last == 0) error("rear: empty list"); - return ((SLNode*)last)->hd; } - const T& front() const { - if (last == 0) error("front: empty list"); - return ((SLNode*)last->tl)->hd; } - const T& rear() const { - if (last == 0) error("rear: empty list"); - return ((SLNode*)last)->hd; } - int remove_front(T& x) { return BaseSLList::remove_front(&x); } - T remove_front() { T dst; BaseSLList::remove_front(&dst, 1); return dst; } -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/SLStack.cc --- a/src/SLStack.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SLStack.h" - -template -SLStack& -SLStack::operator = (const SLStack& s) -{ - if (this != &s) - p = s.p; - - return *this; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/SLStack.h --- a/src/SLStack.h Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' version -of SLStack from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if !defined (_SLStack_h) -#define _SLStack_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include "SLList.h" -#include "Stack.h" - -template -class -SLStack : public Stack -{ -private: - - SLList p; - -public: - - SLStack (void) : p () { } - - SLStack (const SLStack& s) : p (s.p) { } - - ~SLStack (void) { } - - SLStack& operator = (const SLStack& s); - - void push (const T& item) { p.prepend (item); } - - T pop (void) { return p.remove_front (); } - - T& top (void) { return p.front (); } - - void del_top (void) { p.del_front (); } - - int empty (void) { return p.empty (); } - - int full (void) { return 0; } - - int length (void) { return p.length (); } - - void clear (void) { p.clear (); } - - int OK (void) { return p.OK (); } -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/Stack.cc --- a/src/Stack.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "Stack.h" - -template -void -Stack::error (const char *msg) -{ - std::cerr << msg; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/Stack.h --- a/src/Stack.h Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' version -of Stack from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if !defined (_Stack_h) -#define _Stack_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -template -class -Stack -{ - public: - - Stack (void) { } - - virtual ~Stack (void) { } - - virtual void push (const T& item) = 0; - - virtual T pop (void) = 0; - virtual T& top (void) = 0; - - virtual void del_top (void) = 0; - - virtual int empty (void) = 0; - virtual int full (void) = 0; - virtual int length (void) = 0; - - virtual void clear (void) = 0; - - void error (const char *msg); - - virtual int OK (void) = 0; -}; - -#endif diff -r 4a392a01e51a -r 23d06c9e1edd src/TEMPLATE-INST/Map-oct-obj.cc --- a/src/TEMPLATE-INST/Map-oct-obj.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - -Copyright (C) 2002 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Maps of octave_value_lists. - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "Map.h" -#include "Map.cc" - -#include "oct-obj.h" - -template class Map; -template class CHNode; -template class CHMap; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/TEMPLATE-INST/SLList-expr.cc --- a/src/TEMPLATE-INST/SLList-expr.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "oct-obj.h" -#include "pt-exp.h" -#include "pt-id.h" -#include "pt-idx.h" - -template class SLNode; -template class SLList; - -template class SLNode; -template class SLList; - -template class SLNode; -template class SLList; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/TEMPLATE-INST/SLList-misc.cc --- a/src/TEMPLATE-INST/SLList-misc.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "ov.h" -#include "pt-arg-list.h" -#include "pt-decl.h" -#include "pt-select.h" -#include "pt-stmt.h" - -template class SLNode; -template class SLList; - -template class SLNode; -template class SLList; - -template class SLNode; -template class SLList; - -template class SLList; -template class SLNode; - -template class SLList; -template class SLNode; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/TEMPLATE-INST/SLList-plot.cc --- a/src/TEMPLATE-INST/SLList-plot.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "ov.h" -#include "pt-plot.h" - -template class SLNode; -template class SLList; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/TEMPLATE-INST/SLList-tc.cc --- a/src/TEMPLATE-INST/SLList-tc.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "oct-obj.h" - -template class SLNode; -template class SLList; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/TEMPLATE-INST/SLList-tm.cc --- a/src/TEMPLATE-INST/SLList-tm.cc Thu Dec 05 04:43:20 2002 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Stacks of tree_matrix* values. - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "oct-obj.h" -#include "pt-mat.h" - -template class SLNode; -template class SLList; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/ diff -r 4a392a01e51a -r 23d06c9e1edd src/comment-list.cc --- a/src/comment-list.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/comment-list.cc Fri Dec 06 21:29:19 2002 +0000 @@ -33,11 +33,6 @@ #include "comment-list.h" #include "error.h" -#include "SLList.h" -#include "SLList.cc" - -template class SLList; - octave_comment_buffer *octave_comment_buffer::instance = 0; bool diff -r 4a392a01e51a -r 23d06c9e1edd src/comment-list.h --- a/src/comment-list.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/comment-list.h Fri Dec 06 21:29:19 2002 +0000 @@ -29,7 +29,7 @@ #include -#include +#include extern std::string get_comment_text (void); @@ -85,43 +85,16 @@ }; class -octave_comment_list +octave_comment_list : public octave_base_list { public: - octave_comment_list (void) : lst () { } - - ~octave_comment_list (void) { } + void append (const octave_comment_elt& elt) + { octave_base_list::append (elt); } void append (const std::string& s, octave_comment_elt::comment_type t = octave_comment_elt::unknown) - { lst.append (octave_comment_elt (s, t)); } - - octave_comment_list (const octave_comment_list& ocb) - : lst (ocb.lst) { } - - octave_comment_list& operator = (const octave_comment_list& ocb) - { - if (this != &ocb) - lst = ocb.lst; - - return *this; - } - - int length (void) const { return lst.length (); } - - octave_comment_elt& operator () (Pix p) { return lst (p); } - - const octave_comment_elt& operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - -private: - - // The list of comments. - SLList lst; + { append (octave_comment_elt (s, t)); } }; class diff -r 4a392a01e51a -r 23d06c9e1edd src/dynamic-ld.cc --- a/src/dynamic-ld.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/dynamic-ld.cc Fri Dec 06 21:29:19 2002 +0000 @@ -24,11 +24,11 @@ #include #endif +#include + #include "oct-time.h" #include "file-stat.h" -#include "DLList.h" - #include #include "defun.h" @@ -42,9 +42,6 @@ // functions to be cleared. static bool Vwarn_reload_forces_clear; -template class DLNode; -template class DLList; - class octave_shlib_list { @@ -75,7 +72,7 @@ static bool instance_ok (void); // List of libraries we have loaded. - DLList lib_list; + std::list lib_list; // No copying! @@ -89,19 +86,22 @@ void octave_shlib_list::do_append (const octave_shlib& shl) { - lib_list.append (shl); + lib_list.push_back (shl); } void octave_shlib_list::do_remove (octave_shlib& shl) { - for (Pix p = lib_list.first (); p != 0; lib_list.next (p)) + + for (std::list::iterator p = lib_list.begin (); + p != lib_list.end (); + p++) { - if (lib_list(p) == shl) + if (*p == shl) { shl.close (); - lib_list.del (p); + lib_list.erase (p); break; } @@ -116,13 +116,15 @@ shl = octave_shlib (); - for (Pix p = lib_list.first (); p != 0; lib_list.next (p)) + for (std::list::iterator p = lib_list.begin (); + p != lib_list.end (); + p++) { - function = lib_list(p).search (fcn_name, mangler); + function = p->search (fcn_name, mangler); if (function) { - shl = lib_list(p); + shl = *p; break; } diff -r 4a392a01e51a -r 23d06c9e1edd src/load-save.cc --- a/src/load-save.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/load-save.cc Fri Dec 06 21:29:19 2002 +0000 @@ -3855,8 +3855,8 @@ // recursively add each element of the structure to this group Octave_map m = tc.map_value (); - Pix i = m.first (); - while (i) + Octave_map::iterator i = m.begin (); + while (i != m.end ()) { bool retval2 = add_hdf5_data (data_id, m.contents (i), m.key (i), "", @@ -3864,8 +3864,7 @@ if (! retval2) goto error_cleanup; - // advance i to next element, or 0 - m.next (i); + i++; } } else @@ -4196,21 +4195,20 @@ // an Octave structure */ // recursively write each element of the structure Octave_map m = tc.map_value (); - Pix i; { char buf[32]; FOUR_BYTE_INT maxfieldnamelength = 32; int fieldcnt = 0; - for (i = m.first (); i; m.next (i)) + for (Octave_map::iterator i = m.begin (); i != m.end (); i++) fieldcnt++; write_mat5_tag (os, miINT32, 4); os.write ((char *)&maxfieldnamelength, 4); write_mat5_tag (os, miINT8, fieldcnt*32); - - for (i = m.first (); i; m.next (i)) + + for (Octave_map::iterator i = m.begin (); i != m.end (); i++) { // write the name of each element std::string tstr = m.key (i); @@ -4219,7 +4217,7 @@ os.write (buf, 32); } - for (i = m.first (); i; m.next (i)) + for (Octave_map::iterator i = m.begin (); i != m.end (); i++) { // write the data of each element bool retval2 = save_mat5_binary_element (os, m.contents (i), "", diff -r 4a392a01e51a -r 23d06c9e1edd src/oct-lvalue.cc --- a/src/oct-lvalue.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/oct-lvalue.cc Fri Dec 06 21:29:19 2002 +0000 @@ -42,7 +42,7 @@ void octave_lvalue::set_index (const std::string& t, - const SLList& i) + const std::list& i) { if (! index_set) { diff -r 4a392a01e51a -r 23d06c9e1edd src/oct-lvalue.h --- a/src/oct-lvalue.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/oct-lvalue.h Fri Dec 06 21:29:19 2002 +0000 @@ -28,8 +28,6 @@ #include -#include "SLList.h" - #include "oct-obj.h" #include "pt-idx.h" #include "symtab.h" @@ -78,7 +76,7 @@ void assign (octave_value::assign_op, const octave_value&); - void set_index (const std::string& t, const SLList& i); + void set_index (const std::string& t, const std::list& i); void clear_index (void) { type = std::string (); idx.clear (); } @@ -93,7 +91,7 @@ std::string type; - SLList idx; + std::list idx; symbol_record::change_function chg_fcn; diff -r 4a392a01e51a -r 23d06c9e1edd src/oct-map.cc --- a/src/oct-map.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/oct-map.cc Fri Dec 06 21:29:19 2002 +0000 @@ -37,9 +37,9 @@ octave_value_list Octave_map::operator [] (const std::string& key) const { - Pix p = map.seek (key); + const_iterator p = seek (key); - return p ? map.contents (p) : octave_value_list (); + return p != end () ? p->second : octave_value_list (); } string_vector @@ -50,7 +50,7 @@ string_vector names (len); int i = 0; - for (Pix p = first (); p != 0; next (p)) + for (const_iterator p = begin (); p != end (); p++) names[i++] = key (p); return names; @@ -61,7 +61,7 @@ { if (array_len == 0 && length () != 0) { - Pix p = first (); + const_iterator p = begin (); array_len = contents(p).length (); } @@ -142,7 +142,7 @@ } else if (rhs_len > len) { - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) contents(p).resize (rhs_len, fill_value); array_len = rhs_len; @@ -157,11 +157,11 @@ Octave_map& Octave_map::assign (const std::string& key, const octave_value_list& rhs) { - if (map.empty ()) + if (empty ()) map[key] = rhs; else { - octave_value_list tmp = map.contents (map.first ()); + octave_value_list tmp = contents (begin ()); if (tmp.length () == rhs.length ()) map[key] = rhs; @@ -177,7 +177,7 @@ { Octave_map retval; - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { octave_value_list tmp = contents(p).index (idx); diff -r 4a392a01e51a -r 23d06c9e1edd src/oct-map.h --- a/src/oct-map.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/oct-map.h Fri Dec 06 21:29:19 2002 +0000 @@ -27,7 +27,7 @@ #pragma interface #endif -#include "Map.h" +#include #include "oct-obj.h" @@ -37,10 +37,14 @@ Octave_map { public: - Octave_map (void) : map (octave_value_list ()), array_len (0) { } + + typedef std::map::iterator iterator; + typedef std::map::const_iterator const_iterator; + + Octave_map (void) : map (), array_len (0) { } Octave_map (const std::string& key, const octave_value& value) - : map (octave_value_list ()), array_len (1) + : map (), array_len (1) { map[key] = octave_value_list (value); } @@ -61,7 +65,7 @@ ~Octave_map (void) { } // This is the number of keys. - int length (void) const { return map.length (); } + int length (void) const { return map.size (); } int empty (void) const { return map.empty (); } @@ -69,18 +73,31 @@ octave_value_list operator [] (const std::string& key) const; - void del (const std::string& key) { map.del (key); } + void del (const std::string& key) + { + iterator p = map.find (key); + if (p != map.end ()) + map.erase (p); + } - Pix first (void) const { return map.first (); } - void next (Pix& i) const { map.next (i); } + iterator begin (void) { return iterator (map.begin ()); } + const_iterator begin (void) const { return const_iterator (map.begin ()); } + + iterator end (void) { return iterator (map.end ()); } + const_iterator end (void) const { return const_iterator (map.end ()); } - std::string key (Pix p) const { return map.key (p); } + std::string key (const_iterator p) const { return p->first; } - octave_value_list& contents (Pix p) const { return map.contents (p); } + octave_value_list& contents (const_iterator p) + { return operator [] (key(p)); } - Pix seek (const std::string& key) const { return map.seek (key); } + octave_value_list contents (const_iterator p) const + { return operator [] (key(p)); } - int contains (const std::string& key) const { return map.contains (key); } + const_iterator seek (const std::string& key) const { return map.find (key); } + + int contains (const std::string& key) const + { return (seek (key) != map.end ()); } void clear (void) { map.clear (); } @@ -104,7 +121,7 @@ private: // The map of names to values. - CHMap map; + std::map map; // The current size of this struct array; mutable int array_len; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-base-mat.cc --- a/src/ov-base-mat.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-base-mat.cc Fri Dec 06 21:29:19 2002 +0000 @@ -40,7 +40,7 @@ template octave_value octave_base_matrix::subsref (const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; @@ -68,7 +68,7 @@ template octave_value octave_base_matrix::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; @@ -144,11 +144,6 @@ return retval; } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -template -extern void assign (MT&, const MT&); -#endif - template void octave_base_matrix::assign (const octave_value_list& idx, const MT& rhs) @@ -165,7 +160,7 @@ matrix.set_index (i); matrix.set_index (j); - ::assign (matrix, rhs); + ::assign (matrix, rhs, MT::resize_fill_value ()); } break; @@ -175,7 +170,7 @@ matrix.set_index (i); - ::assign (matrix, rhs); + ::assign (matrix, rhs, MT::resize_fill_value ()); } break; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-base-mat.h --- a/src/ov-base-mat.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-base-mat.h Fri Dec 06 21:29:19 2002 +0000 @@ -67,10 +67,10 @@ octave_value *empty_clone (void) const { return new octave_base_matrix (); } octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); octave_value do_index_op (const octave_value_list& idx, int resize_ok); diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-base-scalar.cc --- a/src/ov-base-scalar.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-base-scalar.cc Fri Dec 06 21:29:19 2002 +0000 @@ -40,7 +40,7 @@ template octave_value octave_base_scalar::subsref (const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; @@ -68,7 +68,7 @@ template octave_value octave_base_scalar::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-base-scalar.h --- a/src/ov-base-scalar.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-base-scalar.h Fri Dec 06 21:29:19 2002 +0000 @@ -60,10 +60,10 @@ ~octave_base_scalar (void) { } octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); int rows (void) const { return 1; } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-base.cc --- a/src/ov-base.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-base.cc Fri Dec 06 21:29:19 2002 +0000 @@ -54,7 +54,7 @@ octave_value octave_base_value::subsref (const std::string, - const SLList&) + const std::list&) { std::string nm = type_name (); error ("can't perform indexing operations for %s type", nm.c_str ()); @@ -63,7 +63,7 @@ octave_value_list octave_base_value::subsref (const std::string, - const SLList&, int) + const std::list&, int) { std::string nm = type_name (); error ("can't perform indexing operations for %s type", nm.c_str ()); @@ -96,7 +96,7 @@ octave_value octave_base_value::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-base.h --- a/src/ov-base.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-base.h Fri Dec 06 21:29:19 2002 +0000 @@ -72,10 +72,10 @@ { return static_cast (0); } octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); octave_value_list subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout); octave_value do_index_op (const octave_value_list& idx, int resize_ok); @@ -89,7 +89,7 @@ idx_vector index_vector (void) const; octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); int rows (void) const { return -1; } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-builtin.cc --- a/src/ov-builtin.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-builtin.cc Fri Dec 06 21:29:19 2002 +0000 @@ -53,7 +53,7 @@ octave_value_list octave_builtin::subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout) { octave_value_list retval; @@ -86,7 +86,7 @@ // do? If it is not, then what should happen for stat("file").size, // for exmaple? - if (idx.length () > 1) + if (idx.size () > 1) retval = retval(0).next_subsref (type, idx); return retval; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-builtin.h --- a/src/ov-builtin.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-builtin.h Fri Dec 06 21:29:19 2002 +0000 @@ -51,7 +51,7 @@ ~octave_builtin (void) { } octave_value_list subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout); octave_function *function_value (bool) { return this; } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-cell.cc --- a/src/ov-cell.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-cell.cc Fri Dec 06 21:29:19 2002 +0000 @@ -53,7 +53,7 @@ octave_value octave_cell::subsref (const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; @@ -104,7 +104,7 @@ octave_value octave_cell::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; @@ -126,9 +126,9 @@ if (! error_state) { - SLList next_idx (idx); + std::list next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); } @@ -148,9 +148,9 @@ { tmp = tcell(0,0); - SLList next_idx (idx); + std::list next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-cell.h --- a/src/ov-cell.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-cell.h Fri Dec 06 21:29:19 2002 +0000 @@ -74,10 +74,10 @@ #endif octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); bool is_defined (void) const { return true; } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-cs-list.cc --- a/src/ov-cs-list.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-cs-list.cc Fri Dec 06 21:29:19 2002 +0000 @@ -46,7 +46,7 @@ octave_value octave_list::subsref (const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; @@ -118,7 +118,7 @@ octave_value octave_list::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; @@ -140,9 +140,9 @@ if (! error_state) { - SLList next_idx (idx); + std::list next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-cs-list.h --- a/src/ov-cs-list.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-cs-list.h Fri Dec 06 21:29:19 2002 +0000 @@ -66,12 +66,12 @@ #if 0 octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); octave_value do_index_op (const octave_value_list& idx, int resize_ok); octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); void assign (const octave_value_list& idx, const octave_value& rhs); diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-list.cc --- a/src/ov-list.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-list.cc Fri Dec 06 21:29:19 2002 +0000 @@ -44,7 +44,7 @@ octave_value octave_list::subsref (const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; @@ -116,7 +116,7 @@ octave_value octave_list::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; @@ -138,9 +138,9 @@ if (! error_state) { - SLList next_idx (idx); + std::list next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-list.h --- a/src/ov-list.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-list.h Fri Dec 06 21:29:19 2002 +0000 @@ -65,12 +65,12 @@ octave_value *empty_clone (void) const { return new octave_list (); } octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); octave_value do_index_op (const octave_value_list& idx, int resize_ok); octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); void assign (const octave_value_list& idx, const octave_value& rhs); diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-mapper.cc --- a/src/ov-mapper.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-mapper.cc Fri Dec 06 21:29:19 2002 +0000 @@ -245,7 +245,7 @@ octave_value_list octave_mapper::subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout) { octave_value_list retval; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-mapper.h --- a/src/ov-mapper.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-mapper.h Fri Dec 06 21:29:19 2002 +0000 @@ -67,7 +67,7 @@ octave_function *function_value (bool) { return this; } octave_value_list subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout); octave_value_list diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-range.cc --- a/src/ov-range.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-range.cc Fri Dec 06 21:29:19 2002 +0000 @@ -83,7 +83,7 @@ octave_value octave_range::subsref (const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-range.h --- a/src/ov-range.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-range.h Fri Dec 06 21:29:19 2002 +0000 @@ -40,7 +40,6 @@ #include "oct-alloc.h" #include "str-vec.h" -#include "SLList.h" #include "error.h" #include "ov-base.h" #include "ov-typeinfo.h" @@ -87,7 +86,7 @@ octave_value *try_narrowing_conversion (void); octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); octave_value do_index_op (const octave_value_list& idx, int resize_ok); diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-struct.cc --- a/src/ov-struct.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-struct.cc Fri Dec 06 21:29:19 2002 +0000 @@ -51,9 +51,9 @@ std::string nm = idx(0).string_value (); - Pix p = map.seek (nm); + Octave_map::const_iterator p = map.seek (nm); - if (p) + if (p != map.end ()) retval = map.contents (p); else error ("structure has no member `%s'", nm.c_str ()); @@ -87,7 +87,7 @@ octave_value octave_struct::subsref (const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; @@ -99,9 +99,8 @@ { if (type.length () > 1 && type[1] == '.') { - Pix p = idx.first (); - idx.next (p); - octave_value_list key_idx = idx(p); + std::list::const_iterator p = idx.begin (); + octave_value_list key_idx = *++p; octave_value_list tmp = dotref (key_idx); @@ -183,7 +182,7 @@ octave_value octave_struct::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; @@ -200,13 +199,12 @@ { if (type.length () > 1 && type[1] == '.') { - Pix p = idx.first (); - octave_value_list t_idx = idx(p); + std::list::const_iterator p = idx.begin (); + octave_value_list t_idx = *p; if (t_idx.length () == 1) { - idx.next (p); - octave_value_list key_idx = idx(p); + octave_value_list key_idx = *++p; assert (key_idx.length () == 1); @@ -231,13 +229,13 @@ if (! error_state) { - SLList next_idx (idx); + std::list next_idx (idx); // We handled two index elements, so subsasgn to // needs to skip both of them. - next_idx.remove_front (); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); + next_idx.erase (next_idx.begin ()); u.make_unique (); @@ -273,9 +271,9 @@ if (! error_state) { - SLList next_idx (idx); + std::list next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); u.make_unique (); @@ -301,9 +299,8 @@ { if (n > 1 && type[1] == '.') { - Pix p = idx.first (); - idx.next (p); - octave_value_list key_idx = idx(p); + std::list::const_iterator p = idx.begin (); + octave_value_list key_idx = *++p; assert (key_idx.length () == 1); @@ -418,7 +415,7 @@ int n = map.array_length (); - for (Pix p = map.first (); p; map.next (p)) + for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++) { std::string key = map.key (p); octave_value_list val = map.contents (p); diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-struct.h --- a/src/ov-struct.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-struct.h Fri Dec 06 21:29:19 2002 +0000 @@ -70,13 +70,13 @@ octave_value_list dotref (const octave_value_list& idx); octave_value subsref (const std::string type, - const SLList& idx); + const std::list& idx); static octave_value numeric_conv (const octave_value_list& val, const std::string& type); octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); int rows (void) const { return map.rows (); } diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-usr-fcn.cc Fri Dec 06 21:29:19 2002 +0000 @@ -284,7 +284,7 @@ tree_parameter_list *tmp = static_cast (lst); if (tmp) - tmp->clear (); + tmp->undefine (); } static void @@ -305,7 +305,7 @@ octave_value_list octave_user_function::subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout) { octave_value_list retval; @@ -332,7 +332,7 @@ // octave_value_list::next_subsref member function? See also // octave_builtin::subsref. - if (idx.length () > 1) + if (idx.size () > 1) retval = retval(0).next_subsref (type, idx); return retval; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov-usr-fcn.h --- a/src/ov-usr-fcn.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov-usr-fcn.h Fri Dec 06 21:29:19 2002 +0000 @@ -140,7 +140,7 @@ } octave_value_list subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout); octave_value_list diff -r 4a392a01e51a -r 23d06c9e1edd src/ov.cc --- a/src/ov.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov.cc Fri Dec 06 21:29:19 2002 +0000 @@ -568,7 +568,7 @@ octave_value_list octave_value::subsref (const std::string type, - const SLList& idx, int nargout) + const std::list& idx, int nargout) { if (is_constant ()) return rep->subsref (type, idx); @@ -578,16 +578,16 @@ octave_value octave_value::next_subsref (const std::string type, - const SLList& idx, + const std::list& idx, int skip) { assert (skip > 0); - if (idx.length () > skip) + if (idx.size () > skip) { - SLList new_idx (idx); + std::list new_idx (idx); for (int i = 0; i < skip; i++) - new_idx.remove_front (); + new_idx.erase (new_idx.begin ()); return subsref (type.substr (skip), new_idx); } else @@ -629,7 +629,7 @@ octave_value octave_value::subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { return rep->subsasgn (type, idx, rhs); @@ -637,7 +637,7 @@ octave_value octave_value::assign (assign_op op, const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; @@ -1080,7 +1080,7 @@ octave_value octave_value::numeric_assign (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs) { octave_value retval; @@ -1433,7 +1433,7 @@ octave_value octave_value::do_non_const_unary_op (unary_op op, const std::string type, - const SLList& idx) + const std::list& idx) { octave_value retval; diff -r 4a392a01e51a -r 23d06c9e1edd src/ov.h --- a/src/ov.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/ov.h Fri Dec 06 21:29:19 2002 +0000 @@ -31,6 +31,7 @@ #include #include +#include #include "Range.h" #include "idx-vector.h" @@ -38,8 +39,6 @@ #include "oct-alloc.h" #include "str-vec.h" -#include "SLList.h" - class Cell; class Octave_map; class octave_stream; @@ -244,24 +243,24 @@ { return rep->try_narrowing_conversion (); } virtual octave_value subsref (const std::string type, - const SLList& idx) + const std::list& idx) { return rep->subsref (type, idx); } octave_value subsref (const std::string type, const octave_value_list& idx) { - SLList i; + std::list i; - i.append (idx); + i.push_back (idx); return rep->subsref (type, i); } virtual octave_value_list subsref (const std::string type, - const SLList& idx, + const std::list& idx, int nargout); octave_value next_subsref (const std::string type, const - SLList& idx, + std::list& idx, int skip = 1); virtual octave_value do_index_op (const octave_value_list& idx, @@ -275,11 +274,11 @@ do_multi_index_op (int nargout, const octave_value_list& idx); virtual octave_value subsasgn (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); octave_value assign (assign_op op, const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); const octave_value& assign (assign_op, const octave_value& rhs); @@ -529,7 +528,7 @@ void do_non_const_unary_op (unary_op op, const octave_value_list& idx); octave_value do_non_const_unary_op (unary_op op, const std::string type, - const SLList& idx); + const std::list& idx); friend octave_value do_binary_op (binary_op op, const octave_value& a, @@ -547,7 +546,7 @@ // This should only be called for derived types. octave_value numeric_assign (const std::string type, - const SLList& idx, + const std::list& idx, const octave_value& rhs); void reset_indent_level (void) const diff -r 4a392a01e51a -r 23d06c9e1edd src/parse.y --- a/src/parse.y Thu Dec 05 04:43:20 2002 +0000 +++ b/src/parse.y Fri Dec 06 21:29:19 2002 +0000 @@ -2786,7 +2786,7 @@ { if (lexer_flags.defining_func && Vwarn_missing_semicolon) { - tree_statement *tmp = t->rear(); + tree_statement *tmp = t->back(); if (tmp->is_expression ()) warning ("missing semicolon near line %d, column %d in file `%s'", @@ -2803,7 +2803,7 @@ { case ';': { - tree_statement *tmp = list->rear (); + tree_statement *tmp = list->back (); tmp->set_print_flag (0); } break; diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-arg-list.cc --- a/src/pt-arg-list.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-arg-list.cc Fri Dec 06 21:29:19 2002 +0000 @@ -47,10 +47,11 @@ tree_argument_list::~tree_argument_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_expression *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } @@ -59,9 +60,9 @@ { int retval = 0; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p; // XXX FIXME XXX -- need to be able to determine whether elt is // an expression that could evaluate to a cs-list object, and if @@ -76,9 +77,9 @@ bool tree_argument_list::all_elements_are_constant (void) const { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p; if (! elt->is_constant ()) return false; @@ -100,11 +101,11 @@ int args_len = len; args.resize (args_len); - Pix p = lst.first (); + iterator p = begin (); int j = 0; for (int k = 0; k < len; k++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p++; if (elt) { @@ -149,7 +150,6 @@ else args(j++) = tmp; } - next (p); } else { @@ -172,9 +172,9 @@ int k = 0; - for (Pix p = lst.first (); p; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p; retval(k++) = elt->str_print_code (); } diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-arg-list.h --- a/src/pt-arg-list.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-arg-list.h Fri Dec 06 21:29:19 2002 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - class octave_value_list; class tree_expression; @@ -37,38 +35,29 @@ #include "str-vec.h" +#include "base-list.h" + // Argument lists. Used to hold the list of expressions that are the // arguments in a function call or index expression. class -tree_argument_list +tree_argument_list : public octave_base_list { public: - tree_argument_list (void) - : lst () { } + tree_argument_list (void) { } - tree_argument_list (tree_expression *t) - : lst () { lst.append (t); } + tree_argument_list (tree_expression *t) { append (t); } ~tree_argument_list (void); - int length (void) const { return lst.length (); } - - void append (tree_expression *&s) { lst.append (s); } - void append (tree_expression * const &s) { lst.append (s); } - - tree_expression *&operator () (Pix p) { return lst (p); } - - tree_expression * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - - int remove_front (tree_expression *x) { return lst.remove_front (x); } - - tree_expression *remove_front (void) { return lst.remove_front (); } + tree_expression *remove_front (void) + { + iterator p = begin (); + tree_expression *retval = *p; + erase (p); + return retval; + } int nargout_count (void) const; @@ -82,9 +71,6 @@ private: - // The list of argument list elements. - SLList lst; - // No copying! tree_argument_list (const tree_argument_list&); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-assign.cc --- a/src/pt-assign.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-assign.cc Fri Dec 06 21:29:19 2002 +0000 @@ -230,9 +230,11 @@ retval.resize (n, octave_value ()); - for (Pix p = lhs->first (); p != 0; lhs->next (p)) + for (tree_argument_list::iterator p = lhs->begin (); + p != lhs->end (); + p++) { - tree_expression *lhs_elt = lhs->operator () (p); + tree_expression *lhs_elt = *p; if (lhs_elt) { diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-bp.cc --- a/src/pt-bp.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-bp.cc Fri Dec 06 21:29:19 2002 +0000 @@ -114,9 +114,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_argument_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_expression *elt = lst(p); + tree_expression *elt = *p; if (elt) elt->accept (*this); @@ -220,9 +220,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_decl_init_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_decl_elt *elt = lst(p); + tree_decl_elt *elt = *p; if (elt) elt->accept (*this); @@ -334,9 +334,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_if_command_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_if_clause *elt = lst(p); + tree_if_clause *elt = *p; if (elt) elt->accept (*this); @@ -354,13 +354,16 @@ if (expr && expr->line () >= line) take_action (*expr); - SLList lst = cmd.arg_lists (); + std::list lst = cmd.arg_lists (); + if (! lst.empty ()) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (std::list::iterator p = lst.begin (); + p != lst.end (); + p++) { - tree_argument_list *elt = lst(p); + tree_argument_list *elt = *p; elt->accept (*this); } @@ -373,12 +376,11 @@ if (found) return; - Pix p = mat.first (); + tree_matrix::iterator p = mat.begin (); - while (p) + while (p != mat.end ()) { - tree_argument_list *elt = mat(p); - mat.next (p); + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); @@ -391,12 +393,11 @@ if (found) return; - Pix p = cell.first (); + tree_cell::iterator p = cell.begin (); - while (p) + while (p != cell.end ()) { - tree_argument_list *elt = cell (p); - cell.next (p); + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); @@ -446,12 +447,11 @@ if (found) return; - Pix p = lst.first (); + tree_parameter_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_identifier *elt = lst(p); - lst.next (p); + tree_identifier *elt = *p++; if (elt) elt->accept (*this); @@ -529,12 +529,11 @@ if (found) return; - Pix p = lst.first (); + tree_return_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_index_expression *elt = lst(p); - lst.next (p); + tree_index_expression *elt = *p++; if (elt) elt->accept (*this); @@ -577,9 +576,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_statement_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_statement *elt = lst(p); + tree_statement *elt = *p; if (elt) elt->accept (*this); @@ -636,16 +635,14 @@ if (found) return; - Pix p = lst.first (); + tree_switch_case_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_switch_case *elt = lst(p); + tree_switch_case *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-cell.cc --- a/src/pt-cell.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-cell.cc Fri Dec 06 21:29:19 2002 +0000 @@ -53,9 +53,9 @@ int nr = length (); int nc = -1; - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_argument_list *elt = this->operator () (p); + tree_argument_list *elt = *p; if (nc < 0) nc = elt->length (); @@ -70,9 +70,9 @@ int i = 0; - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_argument_list *elt = this->operator () (p); + tree_argument_list *elt = *p; octave_value_list row = elt->convert_to_const_vector (); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-cell.h --- a/src/pt-cell.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-cell.h Fri Dec 06 21:29:19 2002 +0000 @@ -35,8 +35,6 @@ class tree_walker; -#include - #include "pt-mat.h" // General cells. diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-check.cc --- a/src/pt-check.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-check.cc Fri Dec 06 21:29:19 2002 +0000 @@ -36,13 +36,11 @@ void tree_checker::visit_argument_list (tree_argument_list& lst) { - Pix p = lst.first (); + tree_argument_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_expression *elt = lst (p); - - lst.next (p); + tree_expression *elt = *p++; if (elt) { @@ -121,13 +119,11 @@ void tree_checker::visit_decl_init_list (tree_decl_init_list& lst) { - Pix p = lst.first (); + tree_decl_init_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_decl_elt *elt = lst (p); - - lst.next (p); + tree_decl_elt *elt = *p++; if (elt) elt->accept (*this); @@ -227,16 +223,14 @@ void tree_checker::visit_if_command_list (tree_if_command_list& lst) { - Pix p = lst.first (); + tree_if_command_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_if_clause *elt = lst (p); + tree_if_clause *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } @@ -248,31 +242,41 @@ if (e) e->accept (*this); - SLList lst = expr.arg_lists (); + std::list lst = expr.arg_lists (); - Pix p = lst.first (); + std::list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } void tree_checker::visit_matrix (tree_matrix& lst) { - Pix p = lst.first (); + tree_matrix::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); + tree_argument_list *elt = *p++; + + if (elt) + elt->accept (*this); + } +} - lst.next (p); +void +tree_checker::visit_cell (tree_cell& lst) +{ + tree_matrix::iterator p = lst.begin (); + + while (p != lst.end ()) + { + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); @@ -312,13 +316,11 @@ void tree_checker::visit_parameter_list (tree_parameter_list& lst) { - Pix p = lst.first (); + tree_parameter_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_identifier *elt = lst (p); - - lst.next (p); + tree_identifier *elt = *p++; if (elt) elt->accept (*this); @@ -398,13 +400,11 @@ void tree_checker::visit_return_list (tree_return_list& lst) { - Pix p = lst.first (); + tree_return_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_index_expression *elt = lst (p); - - lst.next (p); + tree_index_expression *elt = *p++; if (elt) elt->accept (*this); @@ -447,9 +447,9 @@ void tree_checker::visit_statement_list (tree_statement_list& lst) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_statement_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_statement *elt = lst (p); + tree_statement *elt = *p; if (elt) elt->accept (*this); @@ -483,13 +483,11 @@ void tree_checker::visit_subplot_list (subplot_list& lst) { - Pix p = lst.first (); + subplot_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - subplot *elt = lst (p); - - lst.next (p); + subplot *elt = *p++; if (elt) elt->accept (*this); @@ -551,16 +549,14 @@ void tree_checker::visit_switch_case_list (tree_switch_case_list& lst) { - Pix p = lst.first (); + tree_switch_case_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_switch_case *elt = lst (p); + tree_switch_case *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-check.h --- a/src/pt-check.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-check.h Fri Dec 06 21:29:19 2002 +0000 @@ -75,6 +75,8 @@ void visit_matrix (tree_matrix&); + void visit_cell (tree_cell&); + void visit_multi_assignment (tree_multi_assignment&); void visit_no_op_command (tree_no_op_command&); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-decl.cc --- a/src/pt-decl.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-decl.cc Fri Dec 06 21:29:19 2002 +0000 @@ -63,9 +63,11 @@ void tree_decl_init_list::eval (tree_decl_elt::eval_fcn f) { - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - f (*(this->operator () (p))); + tree_decl_elt *elt = *p; + + f (*elt); if (error_state) break; diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-decl.h --- a/src/pt-decl.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-decl.h Fri Dec 06 21:29:19 2002 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - class tree_expression; class tree_identifier; @@ -36,6 +34,7 @@ #include +#include "base-list.h" #include "pt-cmd.h" // List of expressions that make up a declaration statement. @@ -76,45 +75,30 @@ }; class -tree_decl_init_list +tree_decl_init_list : public octave_base_list { public: - tree_decl_init_list (void) - : lst () { } + tree_decl_init_list (void) { } - tree_decl_init_list (tree_decl_elt *t) - : lst () { lst.append (t); } + tree_decl_init_list (tree_decl_elt *t) { append (t); } ~tree_decl_init_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_decl_elt *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_decl_elt *&s) { lst.append (s); } - void append (tree_decl_elt * const &s) { lst.append (s); } - - tree_decl_elt *&operator () (Pix p) { return lst (p); } - - tree_decl_elt * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void eval (tree_decl_elt::eval_fcn); void accept (tree_walker& tw); private: - // The list of variables/initializers. - SLList lst; - // No copying! tree_decl_init_list (const tree_decl_init_list&); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-idx.cc --- a/src/pt-idx.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-idx.cc Fri Dec 06 21:29:19 2002 +0000 @@ -42,11 +42,6 @@ #include "utils.h" #include "variables.h" -#include "SLList.cc" - -template class SLNode; -template class SLList; - // Index expressions. tree_index_expression::tree_index_expression (tree_expression *e, @@ -79,28 +74,28 @@ void tree_index_expression::append (tree_argument_list *lst, char t) { - args.append (lst); + args.push_back (lst); type.append (1, t); - arg_nm.append (lst ? lst->get_arg_names () : string_vector ()); - dyn_field.append (static_cast (0)); + arg_nm.push_back (lst ? lst->get_arg_names () : string_vector ()); + dyn_field.push_back (static_cast (0)); } void tree_index_expression::append (const std::string& n) { - args.append (static_cast (0)); + args.push_back (static_cast (0)); type.append ("."); - arg_nm.append (n); - dyn_field.append (static_cast (0)); + arg_nm.push_back (n); + dyn_field.push_back (static_cast (0)); } void tree_index_expression::append (tree_expression *df) { - args.append (static_cast (0)); + args.push_back (static_cast (0)); type.append ("."); - arg_nm.append (""); - dyn_field.append (df); + arg_nm.push_back (""); + dyn_field.push_back (df); } tree_index_expression::~tree_index_expression (void) @@ -109,8 +104,9 @@ while (! args.empty ()) { - tree_argument_list *t = args.remove_front (); - delete t; + std::list::iterator p = args.begin (); + delete *p; + args.erase (p); } } @@ -171,13 +167,15 @@ } std::string -tree_index_expression::get_struct_index (Pix p_arg_nm, Pix p_dyn_field) const +tree_index_expression::get_struct_index + (std::list::const_iterator p_arg_nm, + std::list::const_iterator p_dyn_field) const { - std::string fn = arg_nm(p_arg_nm)(0); + std::string fn = (*p_arg_nm)(0); if (fn.empty ()) { - tree_expression *df = dyn_field (p_dyn_field); + tree_expression *df = *p_dyn_field; if (df) { @@ -201,14 +199,14 @@ Octave_map tree_index_expression::make_arg_struct (void) const { - int n = args.length (); + int n = args.size (); octave_value_list subs_list (n, octave_value ()); octave_value_list type_list (n, octave_value ()); - Pix p_args = args.first (); - Pix p_arg_nm = arg_nm.first (); - Pix p_dyn_field = dyn_field.first (); + std::list::const_iterator p_args = args.begin (); + std::list::const_iterator p_arg_nm = arg_nm.begin (); + std::list::const_iterator p_dyn_field = dyn_field.begin (); Octave_map m; @@ -217,11 +215,11 @@ switch (type[i]) { case '(': - subs_list(i) = make_subs_cell (args(p_args), arg_nm(p_arg_nm)); + subs_list(i) = make_subs_cell (*p_args, *p_arg_nm); break; case '{': - subs_list(i) = make_subs_cell (args(p_args), arg_nm(p_arg_nm)); + subs_list(i) = make_subs_cell (*p_args, *p_arg_nm); break; case '.': @@ -240,9 +238,9 @@ if (error_state) return m; - args.next (p_args); - arg_nm.next (p_arg_nm); - dyn_field.next (p_dyn_field); + p_args++; + p_arg_nm++; + p_dyn_field++; } m ["subs"] = subs_list; @@ -263,29 +261,29 @@ if (! error_state) { - SLList idx; + std::list idx; - int n = args.length (); + int n = args.size (); - Pix p_args = args.first (); - Pix p_arg_nm = arg_nm.first (); - Pix p_dyn_field = dyn_field.first (); + std::list::iterator p_args = args.begin (); + std::list::iterator p_arg_nm = arg_nm.begin (); + std::list::iterator p_dyn_field = dyn_field.begin (); for (int i = 0; i < n; i++) { switch (type[i]) { case '(': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '{': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '.': { - idx.append (get_struct_index (p_arg_nm, p_dyn_field)); + idx.push_back (get_struct_index (p_arg_nm, p_dyn_field)); if (error_state) eval_error (); @@ -299,9 +297,9 @@ if (error_state) break; - args.next (p_args); - arg_nm.next (p_arg_nm); - dyn_field.next (p_dyn_field); + p_args++; + p_arg_nm++; + p_dyn_field++; } if (! error_state) @@ -329,29 +327,29 @@ { octave_lvalue retval; - SLList idx; + std::list idx; - int n = args.length (); + int n = args.size (); - Pix p_args = args.first (); - Pix p_arg_nm = arg_nm.first (); - Pix p_dyn_field = dyn_field.first (); + std::list::iterator p_args = args.begin (); + std::list::iterator p_arg_nm = arg_nm.begin (); + std::list::iterator p_dyn_field = dyn_field.begin (); for (int i = 0; i < n; i++) { switch (type[i]) { case '(': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '{': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '.': { - idx.append (get_struct_index (p_arg_nm, p_dyn_field)); + idx.push_back (get_struct_index (p_arg_nm, p_dyn_field)); if (error_state) eval_error (); @@ -365,9 +363,9 @@ if (error_state) break; - args.next (p_args); - arg_nm.next (p_arg_nm); - dyn_field.next (p_dyn_field); + p_args++; + p_arg_nm++; + p_dyn_field++; } if (! error_state) diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-idx.h --- a/src/pt-idx.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-idx.h Fri Dec 06 21:29:19 2002 +0000 @@ -27,6 +27,8 @@ #pragma interface #endif +#include + class tree_argument_list; class tree_walker; @@ -36,7 +38,6 @@ class octave_value_list; class octave_lvalue; -#include "SLList.h" #include "str-vec.h" #include "pt-exp.h" @@ -71,11 +72,11 @@ tree_expression *expression (void) { return expr; } - SLList arg_lists (void) { return args; } + std::list arg_lists (void) { return args; } std::string type_tags (void) { return type; } - SLList arg_names (void) { return arg_nm; } + std::list arg_names (void) { return arg_nm; } bool lvalue_ok (void) const { return expr->lvalue_ok (); } @@ -97,21 +98,24 @@ tree_expression *expr; // The indices (only valid if type == paren || type == brace). - SLList args; + std::list args; // The type of this index expression. std::string type; // The names of the arguments. Used for constant struct element // references. - SLList arg_nm; + std::list arg_nm; // The list of dynamic field names, if any. - SLList dyn_field; + std::list dyn_field; Octave_map make_arg_struct (void) const; - std::string get_struct_index (Pix p_arg_nm, Pix p_dyn_field) const; + std::string + get_struct_index + (std::list::const_iterator p_arg_nm, + std::list::const_iterator p_dyn_field) const; // No copying! diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-loop.cc --- a/src/pt-loop.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-loop.cc Fri Dec 06 21:29:19 2002 +0000 @@ -373,7 +373,9 @@ { Octave_map tmp_val (rhs.map_value ()); - for (Pix p = tmp_val.first (); p != 0; tmp_val.next (p)) + for (Octave_map::iterator p = tmp_val.begin (); + p != tmp_val.end (); + p++) { MAYBE_DO_BREAKPOINT; @@ -476,21 +478,19 @@ // is set to value and the second is set to the name of the // structure element. - Pix p = lhs->first (); - tree_expression *elt = lhs->operator () (p); + tree_argument_list::iterator p = lhs->begin (); + tree_expression *elt = *p++; octave_lvalue val_ref = elt->lvalue (); - - lhs->next (p); - elt = lhs->operator () (p); + elt = *p; octave_lvalue key_ref = elt->lvalue (); Octave_map tmp_val (rhs.map_value ()); - for (p = tmp_val.first (); p != 0; tmp_val.next (p)) + for (Octave_map::iterator q = tmp_val.begin (); q != tmp_val.end (); p++) { - octave_value key = tmp_val.key (p); + octave_value key = tmp_val.key (q); - octave_value_list val_lst = tmp_val.contents (p); + octave_value_list val_lst = tmp_val.contents (q); int n = tmp_val.array_length (); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-mat.cc --- a/src/pt-mat.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-mat.cc Fri Dec 06 21:29:19 2002 +0000 @@ -66,17 +66,17 @@ private: class - tm_row_const_rep : public SLList + tm_row_const_rep : public octave_base_list { public: tm_row_const_rep (void) - : SLList (), count (1), nr (0), nc (0), + : count (1), nr (0), nc (0), all_str (false), some_str (false), is_cmplx (false), all_mt (true), ok (false) { } tm_row_const_rep (const tree_argument_list& row) - : SLList (), count (1), nr (0), nc (0), + : count (1), nr (0), nc (0), all_str (false), some_str (false), is_cmplx (false), all_mt (true), ok (false) { init (row); } @@ -111,6 +111,9 @@ public: + typedef tm_row_const_rep::iterator iterator; + typedef tm_row_const_rep::const_iterator const_iterator; + tm_row_const (void) : rep (0) { } @@ -154,15 +157,13 @@ bool complex_p (void) const { return rep->is_cmplx; } bool all_empty_p (void) const { return rep->all_mt; } - octave_value& operator () (Pix p) { return rep->operator () (p); } - - const octave_value& operator () (Pix p) const - { return rep->operator () (p); } + operator bool () const { return (rep && rep->ok); } - Pix first (void) const { return rep->first (); } - void next (Pix& p) const { rep->next (p); } - - operator bool () const { return (rep && rep->ok); } + iterator begin (void) { return rep->begin (); } + const_iterator begin (void) const { return rep->begin (); } + + iterator end (void) { return rep->end (); } + const_iterator end (void) const { return rep->end (); } private: @@ -176,9 +177,11 @@ bool first_elem = true; - for (Pix p = row.first (); p != 0; row.next (p)) + for (tree_argument_list::const_iterator p = row.begin (); + p != row.end (); + p++) { - tree_expression *elt = row (p); + tree_expression *elt = *p; octave_value tmp = elt->rvalue (); @@ -267,19 +270,13 @@ ::warning ("%s near line %d, column %d", msg, l, c); } -#include "SLList.h" -#include "SLList.cc" - -template class SLNode; -template class SLList; - class -tm_const : public SLList +tm_const : public octave_base_list { public: tm_const (const tree_matrix& tm) - : SLList (), nr (0), nc (0), + : nr (0), nc (0), all_str (false), some_str (false), is_cmplx (false), all_mt (true), ok (false) { init (tm); } @@ -329,9 +326,9 @@ // numeric matrix -- collections of strings can have elements of // different lengths. - for (Pix p = tm.first (); p != 0; tm.next (p)) + for (tree_matrix::const_iterator p = tm.begin (); p != tm.end (); p++) { - tree_argument_list *elt = tm (p); + tree_argument_list *elt = *p; tm_row_const tmp (*elt); @@ -357,9 +354,9 @@ if (! error_state) { - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - tm_row_const elt = this->operator () (p); + tm_row_const elt = *p; int this_elt_nr = elt.rows (); int this_elt_nc = elt.cols (); @@ -406,19 +403,20 @@ tree_matrix::~tree_matrix (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_argument_list *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } bool tree_matrix::all_elements_are_constant (void) const { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_argument_list *elt = lst (p); + tree_argument_list *elt = *p; if (! elt->all_elements_are_constant ()) return false; @@ -488,15 +486,15 @@ int put_row = 0; - for (Pix p = tmp.first (); p != 0; tmp.next (p)) + for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++) { int put_col = 0; - tm_row_const row = tmp (p); + tm_row_const row = *p; - for (Pix q = row.first (); q != 0; row.next (q)) + for (tm_row_const::iterator q = row.begin (); q != row.end (); q++) { - octave_value elt = row (q); + octave_value elt = *q; if (found_complex) { diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-mat.h --- a/src/pt-mat.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-mat.h Fri Dec 06 21:29:19 2002 +0000 @@ -35,40 +35,27 @@ class tree_walker; -#include - +#include "base-list.h" #include "pt-exp.h" // General matrices. This allows us to construct matrices from // other matrices, variables, and functions. class -tree_matrix : public tree_expression +tree_matrix : public tree_expression, + public octave_base_list { public: tree_matrix (tree_argument_list *row = 0, int line = -1, int column = -1) - : tree_expression (line, column), lst () + : tree_expression (line, column) { if (row) - lst.append (row); + append (row); } ~tree_matrix (void); - int length (void) const { return lst.length (); } - - void append (tree_argument_list *&s) { lst.append (s); } - void append (tree_argument_list * const &s) { lst.append (s); } - - tree_argument_list *&operator () (Pix p) { return lst (p); } - - tree_argument_list * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - bool all_elements_are_constant (void) const; bool rvalue_ok (void) const { return true; } @@ -81,9 +68,6 @@ private: - // The list matrix elements for this row. - SLList lst; - // No copying! tree_matrix (const tree_matrix&); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-misc.cc --- a/src/pt-misc.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-misc.cc Fri Dec 06 21:29:19 2002 +0000 @@ -28,8 +28,6 @@ #include #endif -#include - #include "error.h" #include "ov.h" #include "oct-lvalue.h" @@ -42,19 +40,20 @@ tree_parameter_list::~tree_parameter_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_identifier *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } void tree_parameter_list::mark_as_formal_parameters (void) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p; elt->mark_as_formal_parameter (); } } @@ -62,9 +61,9 @@ void tree_parameter_list::initialize_undefined_elements (octave_value& val) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p; if (! elt->is_defined ()) { @@ -85,11 +84,11 @@ int expected_nargin = length (); - Pix p = lst.first (); + iterator p = begin (); for (int i = 0; i < expected_nargin; i++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p++; octave_lvalue ref = elt->lvalue (); @@ -105,27 +104,23 @@ } else ref.assign (octave_value::op_asn_eq, octave_value ()); - - lst.next (p); } } void -tree_parameter_list::clear (void) +tree_parameter_list::undefine (void) { int len = length (); - Pix p = lst.first (); + iterator p = begin (); for (int i = 0; i < len; i++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p++; octave_lvalue ref = elt->lvalue (); ref.assign (octave_value::op_asn_eq, octave_value ()); - - lst.next (p); } } @@ -142,22 +137,21 @@ int i = 0; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = this->operator () (p); + tree_identifier *elt = *p; if (elt->is_defined ()) - retval(i) = elt->rvalue (); - - i++; + retval(i++) = elt->rvalue (); } if (vr_list) { - for (Pix p = vr_list->first (); p != 0; vr_list->next (p)) + for (tree_va_return_list::iterator p = vr_list->begin (); + p != vr_list->end (); + p++) { - retval(i) = vr_list->operator () (p); - i++; + retval(i++) = *p; } } @@ -169,9 +163,9 @@ { bool status = true; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p; if (! elt->is_defined ()) { @@ -193,10 +187,11 @@ tree_return_list::~tree_return_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_index_expression *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-misc.h --- a/src/pt-misc.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-misc.h Fri Dec 06 21:29:19 2002 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - class octave_value; class octave_value_list; @@ -38,36 +36,25 @@ class tree_walker; +#include "base-list.h" + // Parameter lists. Used to hold the list of input and output // parameters in a function definition. Elements are identifiers // only. class -tree_parameter_list +tree_parameter_list : public octave_base_list { public: tree_parameter_list (void) - : lst (), marked_for_varargs (0) { } + : marked_for_varargs (0) { } tree_parameter_list (tree_identifier *t) - : lst (), marked_for_varargs (0) { lst.append (t); } + : marked_for_varargs (0) { append (t); } ~tree_parameter_list (void); - int length (void) const { return lst.length (); } - - void append (tree_identifier *&s) { lst.append (s); } - void append (tree_identifier * const &s) { lst.append (s); } - - tree_identifier *&operator () (Pix p) { return lst (p); } - - tree_identifier * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void mark_as_formal_parameters (void); void mark_varargs (void) { marked_for_varargs = 1; } @@ -82,7 +69,7 @@ void define_from_arg_vector (const octave_value_list& args); - void clear (void); + void undefine (void); bool is_defined (void); @@ -92,9 +79,6 @@ private: - // The list of identifiers in the parameter list. - SLList lst; - int marked_for_varargs; // No copying! @@ -108,36 +92,20 @@ // assignment expressions. class -tree_return_list +tree_return_list : public octave_base_list { public: - tree_return_list (void) - : lst () { } + tree_return_list (void) { } - tree_return_list (tree_index_expression *t) - : lst () { lst.append (t); } + tree_return_list (tree_index_expression *t) { append (t); } ~tree_return_list (void); - void append (tree_index_expression *&s) { lst.append (s); } - void append (tree_index_expression * const &s) { lst.append (s); } - - tree_index_expression *&operator () (Pix p) { return lst (p); } - - tree_index_expression * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void accept (tree_walker& tw); private: - // The list of expressions in the return list. - SLList lst; - // No copying! tree_return_list (const tree_return_list&); @@ -146,36 +114,16 @@ }; class -tree_va_return_list +tree_va_return_list : public octave_base_list { public: - tree_va_return_list (void) : lst () { } + tree_va_return_list (void) { } ~tree_va_return_list (void) { } - int length (void) const { return lst.length (); } - - void clear (void) { lst.clear (); } - - int empty (void) const { return lst.empty (); } - - void append (octave_value& s) { lst.append (s); } - void append (const octave_value& s) { lst.append (s); } - - octave_value& operator () (Pix p) { return lst (p); } - - const octave_value& operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - private: - // The list of values in the va return list. - SLList lst; - // No copying! tree_va_return_list (const tree_va_return_list&); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-plot.cc --- a/src/pt-plot.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-plot.cc Fri Dec 06 21:29:19 2002 +0000 @@ -815,27 +815,18 @@ tw.visit_subplot (*this); } -subplot_list::~subplot_list (void) -{ - while (! lst.empty ()) - { - subplot *t = lst.remove_front (); - delete t; - } -} - int subplot_list::print (int ndim, OSSTREAM& plot_buf) { int status = 0; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - subplot *elt = lst (p); + subplot *elt = *p; plot_line_count++; - if (p != first ()) + if (p != begin ()) plot_buf << ",\\\n "; status = elt->print (ndim, plot_buf); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-plot.h --- a/src/pt-plot.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-plot.h Fri Dec 06 21:29:19 2002 +0000 @@ -45,10 +45,9 @@ #include -#include - #include "dColVector.h" +#include "base-list.h" #include "pt-cmd.h" class @@ -396,28 +395,23 @@ }; class -subplot_list +subplot_list : public octave_base_list { public: - subplot_list (void) - : lst () { } + subplot_list (void) { } - subplot_list (subplot *t) - : lst () { lst.append (t); } - - ~subplot_list (void); + subplot_list (subplot *t) { append (t); } - void append (subplot *&s) { lst.append (s); } - void append (subplot * const &s) { lst.append (s); } - - subplot *&operator () (Pix p) { return lst (p); } - - subplot * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } + ~subplot_list (void) + { + while (! empty ()) + { + iterator p = begin (); + delete *p; + erase (p); + } + } int print (int ndim, OSSTREAM& plot_buf); @@ -425,9 +419,6 @@ private: - // The list of subplot commands. - SLList lst; - // No copying! subplot_list (const subplot_list&); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-pr-code.cc --- a/src/pt-pr-code.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-pr-code.cc Fri Dec 06 21:29:19 2002 +0000 @@ -41,19 +41,17 @@ void tree_print_code::visit_argument_list (tree_argument_list& lst) { - Pix p = lst.first (); + tree_argument_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_expression *elt = lst (p); - - lst.next (p); + tree_expression *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -164,19 +162,17 @@ void tree_print_code::visit_decl_init_list (tree_decl_init_list& lst) { - Pix p = lst.first (); + tree_decl_init_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_decl_elt *elt = lst (p); - - lst.next (p); + tree_decl_elt *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -436,13 +432,13 @@ void tree_print_code::visit_if_command_list (tree_if_command_list& lst) { - Pix p = lst.first (); + tree_if_command_list::iterator p = lst.begin (); bool first_elt = true; - while (p) + while (p != lst.end ()) { - tree_if_clause *elt = lst (p); + tree_if_clause *elt = *p++; if (elt) { @@ -462,7 +458,6 @@ } first_elt = false; - lst.next (p); } } @@ -484,14 +479,14 @@ expr_has_parens = e->is_postfix_indexed (); } - SLList arg_lists = expr.arg_lists (); + std::list arg_lists = expr.arg_lists (); std::string type_tags = expr.type_tags (); - SLList arg_names = expr.arg_names (); + std::list arg_names = expr.arg_names (); int n = type_tags.length (); - Pix arg_lists_p = arg_lists.first (); - Pix arg_names_p = arg_names.first (); + std::list::iterator p_arg_lists = arg_lists.begin (); + std::list::iterator p_arg_names = arg_names.begin (); for (int i = 0; i < n; i++) { @@ -500,7 +495,7 @@ case '(': { os << " ("; - tree_argument_list *l = arg_lists (arg_lists_p); + tree_argument_list *l = *p_arg_lists; if (l) l->accept (*this); os << ")"; @@ -510,7 +505,7 @@ case '{': { os << " {"; - tree_argument_list *l = arg_lists (arg_lists_p); + tree_argument_list *l = *p_arg_lists; if (l) l->accept (*this); os << "}"; @@ -519,7 +514,7 @@ case '.': { - string_vector nm = arg_names (arg_names_p); + string_vector nm = *p_arg_names; assert (nm.length () == 1); os << "." << nm(0); } @@ -529,8 +524,8 @@ panic_impossible (); } - arg_lists.next (arg_lists_p); - arg_names.next (arg_names_p); + p_arg_lists++; + p_arg_names++; } print_parens (expr, ")"); @@ -545,19 +540,17 @@ os << "["; - Pix p = lst.first (); + tree_matrix::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); - - lst.next (p); + tree_argument_list *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << "; "; } } @@ -576,19 +569,17 @@ os << "{"; - Pix p = lst.first (); + tree_cell::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); - - lst.next (p); + tree_argument_list *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << "; "; } } @@ -653,19 +644,17 @@ void tree_print_code::visit_parameter_list (tree_parameter_list& lst) { - Pix p = lst.first (); + tree_parameter_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_identifier *elt = lst (p); - - lst.next (p); + tree_identifier *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -792,19 +781,17 @@ void tree_print_code::visit_return_list (tree_return_list& lst) { - Pix p = lst.first (); + tree_return_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_index_expression *elt = lst (p); - - lst.next (p); + tree_index_expression *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -867,9 +854,9 @@ void tree_print_code::visit_statement_list (tree_statement_list& lst) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_statement_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_statement *elt = lst (p); + tree_statement *elt = *p; if (elt) elt->accept (*this); @@ -918,19 +905,17 @@ void tree_print_code::visit_subplot_list (subplot_list& lst) { - Pix p = lst.first (); + subplot_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - subplot *elt = lst (p); - - lst.next (p); + subplot *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ","; } } @@ -1025,16 +1010,14 @@ void tree_print_code::visit_switch_case_list (tree_switch_case_list& lst) { - Pix p = lst.first (); + tree_switch_case_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_switch_case *elt = lst (p); + tree_switch_case *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } @@ -1347,17 +1330,15 @@ { if (comment_list) { - Pix p = comment_list->first (); + octave_comment_list::iterator p = comment_list->begin (); - while (p) + while (p != comment_list->end ()) { - octave_comment_elt elt = comment_list->operator () (p); + octave_comment_elt elt = *p++; print_comment_elt (elt); - comment_list->next (p); - - if (p) + if (p != comment_list->end ()) newline (); } } diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-select.cc --- a/src/pt-select.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-select.cc Fri Dec 06 21:29:19 2002 +0000 @@ -73,9 +73,9 @@ void tree_if_command_list::eval (void) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_if_clause *t = lst (p); + tree_if_clause *t = *p; if (t->eval () || error_state) break; @@ -230,9 +230,9 @@ void tree_switch_case_list::eval (const octave_value& val) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_switch_case *t = lst (p); + tree_switch_case *t = *p; if (t->eval (val) || error_state) break; diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-select.h --- a/src/pt-select.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-select.h Fri Dec 06 21:29:19 2002 +0000 @@ -27,13 +27,12 @@ #pragma interface #endif -#include - class expression; class tree_statement_list; class tree_walker; +#include "base-list.h" #include "comment-list.h" #include "pt-cmd.h" @@ -88,45 +87,30 @@ }; class -tree_if_command_list +tree_if_command_list : public octave_base_list { public: - tree_if_command_list (void) - : lst () { } + tree_if_command_list (void) { } - tree_if_command_list (tree_if_clause *t) - : lst () { lst.append (t); } + tree_if_command_list (tree_if_clause *t) { append (t); } ~tree_if_command_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_if_clause *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_if_clause *&s) { lst.append (s); } - void append (tree_if_clause * const &s) { lst.append (s); } - - tree_if_clause *&operator () (Pix p) { return lst (p); } - - tree_if_clause * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void eval (void); void accept (tree_walker& tw); private: - // The list of if/elseif clauses. - SLList lst; - // No copying! tree_if_command_list (const tree_if_command_list&); @@ -230,45 +214,30 @@ }; class -tree_switch_case_list +tree_switch_case_list : public octave_base_list { public: - tree_switch_case_list (void) - : lst () { } + tree_switch_case_list (void) { } - tree_switch_case_list (tree_switch_case *t) - : lst () { lst.append (t); } + tree_switch_case_list (tree_switch_case *t) { append (t); } ~tree_switch_case_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_switch_case *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_switch_case *&s) { lst.append (s); } - void append (tree_switch_case * const &s) { lst.append (s); } - - tree_switch_case *&operator () (Pix p) { return lst (p); } - - tree_switch_case * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void eval (const octave_value& val); void accept (tree_walker& tw); private: - // The list of switch cases. - SLList lst; - // No copying! tree_switch_case_list (const tree_switch_case_list&); diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-stmt.cc --- a/src/pt-stmt.cc Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-stmt.cc Fri Dec 06 21:29:19 2002 +0000 @@ -28,8 +28,6 @@ #include #endif -#include - #include "quit.h" #include "defun.h" @@ -159,9 +157,9 @@ if (error_state) return retval; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_statement *elt = lst (p); + tree_statement *elt = *p; if (elt) { diff -r 4a392a01e51a -r 23d06c9e1edd src/pt-stmt.h --- a/src/pt-stmt.h Thu Dec 05 04:43:20 2002 +0000 +++ b/src/pt-stmt.h Fri Dec 06 21:29:19 2002 +0000 @@ -27,8 +27,6 @@ #pragma interface #endif -#include - class octave_value_list; class tree_command; @@ -36,6 +34,7 @@ class tree_walker; +#include "base-list.h" #include "comment-list.h" // A statement is either a command to execute or an expression to @@ -105,42 +104,26 @@ // A list of statements to evaluate. class -tree_statement_list +tree_statement_list : public octave_base_list { public: tree_statement_list (void) - : lst (), function_body (false) { } + : function_body (false) { } tree_statement_list (tree_statement *s) - : lst (), function_body (false) { lst.append (s); } + : function_body (false) { append (s); } ~tree_statement_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_statement *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_statement *&s) { lst.append (s); } - void append (tree_statement * const &s) { lst.append (s); } - - tree_statement *&operator () (Pix p) { return lst (p); } - - tree_statement * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - - tree_statement *front (void) { return lst.front (); } - tree_statement *rear (void) { return lst.rear (); } - - const tree_statement *front (void) const { return lst.front (); } - const tree_statement *rear (void) const { return lst.rear (); } - void mark_as_function_body (void) { function_body = true; } octave_value_list eval (bool silent = false, int nargout = 0); @@ -155,9 +138,6 @@ private: - // List of statements to evaluate. - SLList lst; - // Does this list of statements make up the body of a function? bool function_body;