Mercurial > hg > octave-lyh
changeset 4212:8ad52ec4f374
[project @ 2002-12-04 03:50:45 by jwe]
author | jwe |
---|---|
date | Wed, 04 Dec 2002 03:50:45 +0000 |
parents | 4804f1151361 |
children | f8f7fc582c62 |
files | src/ChangeLog src/comment-list.h src/pt-arg-list.cc src/pt-arg-list.h src/pt-bp.cc src/pt-decl.h src/pt-mat.cc src/pt-mat.h src/pt-misc.cc src/pt-misc.h src/pt-plot.cc src/pt-plot.h src/pt-select.cc src/pt-select.h src/pt-stmt.cc src/pt-stmt.h src/utils.cc |
diffstat | 17 files changed, 277 insertions(+), 93 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,17 @@ 2002-12-03 John W. Eaton <jwe@bevo.che.wisc.edu> + * utils.cc: Don't include SLStack.h. + + * pt-stmt.h (tree_statement_list): Make list member data instead + of deriving from SLList object. + * pt-select.h (tree_switch_case_list): Likewise. + (tree_if_command_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. + * defun.h (DEFCMD): Rename from DEFUN_TEXT. Provide DEFUN_TEXT as an alias for DEFCMD. Change all uses.
--- a/src/comment-list.h +++ b/src/comment-list.h @@ -85,31 +85,43 @@ }; class -octave_comment_list : public SLList<octave_comment_elt> +octave_comment_list { public: - octave_comment_list (void) { } + octave_comment_list (void) : lst () { } ~octave_comment_list (void) { } - void append - (const std::string& s, - octave_comment_elt::comment_type t = octave_comment_elt::unknown) - { - SLList<octave_comment_elt>::append (octave_comment_elt (s, t)); - } + 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) - : SLList<octave_comment_elt> (ocb) { } + : lst (ocb.lst) { } octave_comment_list& operator = (const octave_comment_list& ocb) { if (this != &ocb) - SLList<octave_comment_elt>::operator = (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<octave_comment_elt> lst; }; class
--- a/src/pt-arg-list.cc +++ b/src/pt-arg-list.cc @@ -47,9 +47,9 @@ tree_argument_list::~tree_argument_list (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_expression *t = remove_front (); + tree_expression *t = lst.remove_front (); delete t; } } @@ -59,9 +59,9 @@ { int retval = 0; - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_expression *elt = this->operator () (p); + tree_expression *elt = lst (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 +76,9 @@ bool tree_argument_list::all_elements_are_constant (void) const { - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_expression *elt = this->operator () (p); + tree_expression *elt = lst (p); if (! elt->is_constant ()) return false; @@ -100,11 +100,11 @@ int args_len = len; args.resize (args_len); - Pix p = first (); + Pix p = lst.first (); int j = 0; for (int k = 0; k < len; k++) { - tree_expression *elt = this->operator () (p); + tree_expression *elt = lst (p); if (elt) { @@ -172,9 +172,9 @@ int k = 0; - for (Pix p = first (); p; next (p)) + for (Pix p = lst.first (); p; lst.next (p)) { - tree_expression *elt = this->operator () (p); + tree_expression *elt = lst (p); retval(k++) = elt->str_print_code (); }
--- a/src/pt-arg-list.h +++ b/src/pt-arg-list.h @@ -41,18 +41,35 @@ // arguments in a function call or index expression. class -tree_argument_list : public SLList<tree_expression *> +tree_argument_list { public: tree_argument_list (void) - : SLList<tree_expression *> () { } + : lst () { } tree_argument_list (tree_expression *t) - : SLList<tree_expression *> () { append (t); } + : lst () { lst.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 (); } + int nargout_count (void) const; bool all_elements_are_constant (void) const; @@ -65,6 +82,9 @@ private: + // The list of argument list elements. + SLList<tree_expression *> lst; + // No copying! tree_argument_list (const tree_argument_list&);
--- a/src/pt-bp.cc +++ b/src/pt-bp.cc @@ -377,7 +377,7 @@ while (p) { - tree_argument_list *elt = mat (p); + tree_argument_list *elt = mat(p); mat.next (p); if (elt)
--- a/src/pt-decl.h +++ b/src/pt-decl.h @@ -76,31 +76,45 @@ }; class -tree_decl_init_list : public SLList<tree_decl_elt *> +tree_decl_init_list { public: tree_decl_init_list (void) - : SLList<tree_decl_elt *> () { } + : lst () { } tree_decl_init_list (tree_decl_elt *t) - : SLList<tree_decl_elt *> () { append (t); } + : lst () { lst.append (t); } ~tree_decl_init_list (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_decl_elt *t = remove_front (); + tree_decl_elt *t = lst.remove_front (); delete t; } } + 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<tree_decl_elt *> lst; + // No copying! tree_decl_init_list (const tree_decl_init_list&);
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -406,9 +406,9 @@ tree_matrix::~tree_matrix (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_argument_list *t = remove_front (); + tree_argument_list *t = lst.remove_front (); delete t; } } @@ -416,9 +416,9 @@ bool tree_matrix::all_elements_are_constant (void) const { - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_argument_list *elt = this->operator () (p); + tree_argument_list *elt = lst (p); if (! elt->all_elements_are_constant ()) return false;
--- a/src/pt-mat.h +++ b/src/pt-mat.h @@ -43,19 +43,32 @@ // other matrices, variables, and functions. class -tree_matrix : public tree_expression, public SLList<tree_argument_list *> +tree_matrix : public tree_expression { public: tree_matrix (tree_argument_list *row = 0, int line = -1, int column = -1) - : tree_expression (line, column), SLList<tree_argument_list *> () + : tree_expression (line, column), lst () { if (row) - append (row); + lst.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; } @@ -68,6 +81,9 @@ private: + // The list matrix elements for this row. + SLList<tree_argument_list *> lst; + // No copying! tree_matrix (const tree_matrix&);
--- a/src/pt-misc.cc +++ b/src/pt-misc.cc @@ -42,9 +42,9 @@ tree_parameter_list::~tree_parameter_list (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_identifier *t = remove_front (); + tree_identifier *t = lst.remove_front (); delete t; } } @@ -52,9 +52,9 @@ void tree_parameter_list::mark_as_formal_parameters (void) { - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_identifier *elt = this->operator () (p); + tree_identifier *elt = lst (p); elt->mark_as_formal_parameter (); } } @@ -62,9 +62,9 @@ void tree_parameter_list::initialize_undefined_elements (octave_value& val) { - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_identifier *elt = this->operator () (p); + tree_identifier *elt = lst (p); if (! elt->is_defined ()) { @@ -85,11 +85,11 @@ int expected_nargin = length (); - Pix p = first (); + Pix p = lst.first (); for (int i = 0; i < expected_nargin; i++) { - tree_identifier *elt = this->operator () (p); + tree_identifier *elt = lst (p); octave_lvalue ref = elt->lvalue (); @@ -106,7 +106,7 @@ else ref.assign (octave_value::op_asn_eq, octave_value ()); - next (p); + lst.next (p); } } @@ -115,17 +115,17 @@ { int len = length (); - Pix p = first (); + Pix p = lst.first (); for (int i = 0; i < len; i++) { - tree_identifier *elt = this->operator () (p); + tree_identifier *elt = lst (p); octave_lvalue ref = elt->lvalue (); ref.assign (octave_value::op_asn_eq, octave_value ()); - next (p); + lst.next (p); } } @@ -142,7 +142,7 @@ int i = 0; - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { tree_identifier *elt = this->operator () (p); @@ -169,9 +169,9 @@ { bool status = true; - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_identifier *elt = this->operator () (p); + tree_identifier *elt = lst (p); if (! elt->is_defined ()) { @@ -193,9 +193,9 @@ tree_return_list::~tree_return_list (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_index_expression *t = remove_front (); + tree_index_expression *t = lst.remove_front (); delete t; } }
--- a/src/pt-misc.h +++ b/src/pt-misc.h @@ -43,18 +43,31 @@ // only. class -tree_parameter_list : public SLList<tree_identifier *> +tree_parameter_list { public: tree_parameter_list (void) - : SLList<tree_identifier *> (), marked_for_varargs (0) { } + : lst (), marked_for_varargs (0) { } tree_parameter_list (tree_identifier *t) - : SLList<tree_identifier *> (), marked_for_varargs (0) { append (t); } + : lst (), marked_for_varargs (0) { lst.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; } @@ -79,6 +92,9 @@ private: + // The list of identifiers in the parameter list. + SLList<tree_identifier *> lst; + int marked_for_varargs; // No copying! @@ -92,22 +108,36 @@ // assignment expressions. class -tree_return_list : public SLList<tree_index_expression *> +tree_return_list { public: tree_return_list (void) - : SLList<tree_index_expression *> () { } + : lst () { } tree_return_list (tree_index_expression *t) - : SLList<tree_index_expression *> () { append (t); } + : lst () { lst.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<tree_index_expression *> lst; + // No copying! tree_return_list (const tree_return_list&); @@ -116,16 +146,36 @@ }; class -tree_va_return_list : public SLList<octave_value> +tree_va_return_list { public: - tree_va_return_list (void) : SLList<octave_value> () { } + tree_va_return_list (void) : lst () { } ~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<octave_value> lst; + // No copying! tree_va_return_list (const tree_va_return_list&);
--- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -817,9 +817,9 @@ subplot_list::~subplot_list (void) { - while (! empty ()) + while (! lst.empty ()) { - subplot *t = remove_front (); + subplot *t = lst.remove_front (); delete t; } } @@ -829,9 +829,9 @@ { int status = 0; - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - subplot *elt = this->operator () (p); + subplot *elt = lst (p); plot_line_count++;
--- a/src/pt-plot.h +++ b/src/pt-plot.h @@ -396,24 +396,38 @@ }; class -subplot_list : public SLList<subplot *> +subplot_list { public: subplot_list (void) - : SLList<subplot *> () { } + : lst () { } subplot_list (subplot *t) - : SLList<subplot *> () { append (t); } + : lst () { lst.append (t); } ~subplot_list (void); + 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); } + int print (int ndim, OSSTREAM& plot_buf); void accept (tree_walker& tw); private: + // The list of subplot commands. + SLList<subplot *> lst; + // No copying! subplot_list (const subplot_list&);
--- a/src/pt-select.cc +++ b/src/pt-select.cc @@ -73,9 +73,9 @@ void tree_if_command_list::eval (void) { - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_if_clause *t = this->operator () (p); + tree_if_clause *t = lst (p); if (t->eval () || error_state) break; @@ -230,9 +230,9 @@ void tree_switch_case_list::eval (const octave_value& val) { - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_switch_case *t = this->operator () (p); + tree_switch_case *t = lst (p); if (t->eval (val) || error_state) break;
--- a/src/pt-select.h +++ b/src/pt-select.h @@ -88,31 +88,45 @@ }; class -tree_if_command_list : public SLList<tree_if_clause *> +tree_if_command_list { public: tree_if_command_list (void) - : SLList<tree_if_clause *> () { } + : lst () { } tree_if_command_list (tree_if_clause *t) - : SLList<tree_if_clause *> () { append (t); } + : lst () { lst.append (t); } ~tree_if_command_list (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_if_clause *t = remove_front (); + tree_if_clause *t = lst.remove_front (); delete t; } } + 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<tree_if_clause *> lst; + // No copying! tree_if_command_list (const tree_if_command_list&); @@ -216,31 +230,45 @@ }; class -tree_switch_case_list : public SLList<tree_switch_case *> +tree_switch_case_list { public: tree_switch_case_list (void) - : SLList<tree_switch_case *> () { } + : lst () { } tree_switch_case_list (tree_switch_case *t) - : SLList<tree_switch_case *> () { append (t); } + : lst () { lst.append (t); } ~tree_switch_case_list (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_switch_case *t = remove_front (); + tree_switch_case *t = lst.remove_front (); delete t; } } + 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<tree_switch_case *> lst; + // No copying! tree_switch_case_list (const tree_switch_case_list&);
--- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -159,9 +159,9 @@ if (error_state) return retval; - for (Pix p = first (); p != 0; next (p)) + for (Pix p = lst.first (); p != 0; lst.next (p)) { - tree_statement *elt = this->operator () (p); + tree_statement *elt = lst (p); if (elt) { @@ -202,9 +202,9 @@ { if (line < 0) { - octave_value_list lst = list_breakpoints (); + octave_value_list bp_lst = list_breakpoints (); - int len = lst.length (); + int len = bp_lst.length (); for (int line = 0; line < len; line++) {
--- a/src/pt-stmt.h +++ b/src/pt-stmt.h @@ -105,25 +105,42 @@ // A list of statements to evaluate. class -tree_statement_list : public SLList<tree_statement *> +tree_statement_list { public: tree_statement_list (void) - : SLList<tree_statement *> (), function_body (false) { } + : lst (), function_body (false) { } tree_statement_list (tree_statement *s) - : SLList<tree_statement *> (), function_body (false) { append (s); } + : lst (), function_body (false) { lst.append (s); } ~tree_statement_list (void) { - while (! empty ()) + while (! lst.empty ()) { - tree_statement *t = remove_front (); + tree_statement *t = lst.remove_front (); delete t; } } + 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); @@ -138,6 +155,9 @@ private: + // List of statements to evaluate. + SLList<tree_statement *> lst; + // Does this list of statements make up the body of a function? bool function_body;