# HG changeset patch # User jwe # Date 821444689 0 # Node ID fe9d3b2ded2682341900e005ea7c69f3982f9e98 # Parent bbfca89cb1cdd62f908ef2a74baf854d303331d2 [project @ 1996-01-12 11:03:26 by jwe] diff --git a/src/balance.cc b/src/balance.cc --- a/src/balance.cc +++ b/src/balance.cc @@ -29,10 +29,8 @@ #include -#include "CMatrix.h" #include "CmplxAEPBAL.h" #include "CmplxAEPBAL.h" -#include "dMatrix.h" #include "dbleAEPBAL.h" #include "dbleAEPBAL.h" #include "dbleGEPBAL.h" @@ -41,7 +39,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/chol.cc b/src/chol.cc --- a/src/chol.cc +++ b/src/chol.cc @@ -32,7 +32,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/colloc.cc b/src/colloc.cc --- a/src/colloc.cc +++ b/src/colloc.cc @@ -32,7 +32,8 @@ #include "defun-dld.h" #include "error.h" #include "help.h" -#include "tree-const.h" +#include "mappers.h" +#include "oct-obj.h" #include "utils.h" DEFUN_DLD_BUILTIN ("colloc", Fcolloc, Scolloc, FScolloc, 10, diff --git a/src/dassl.cc b/src/dassl.cc --- a/src/dassl.cc +++ b/src/dassl.cc @@ -35,8 +35,8 @@ #include "error.h" #include "gripes.h" #include "help.h" +#include "oct-obj.h" #include "pager.h" -#include "tree-const.h" #include "utils.h" #include "variables.h" diff --git a/src/det.cc b/src/det.cc --- a/src/det.cc +++ b/src/det.cc @@ -32,7 +32,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/eig.cc b/src/eig.cc --- a/src/eig.cc +++ b/src/eig.cc @@ -31,7 +31,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/expm.cc b/src/expm.cc --- a/src/expm.cc +++ b/src/expm.cc @@ -29,10 +29,7 @@ #include -#include "CColVector.h" -#include "CMatrix.h" #include "CmplxAEPBAL.h" -#include "dMatrix.h" #include "dbleAEPBAL.h" #include "f77-uscore.h" @@ -40,7 +37,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/fft.cc b/src/fft.cc --- a/src/fft.cc +++ b/src/fft.cc @@ -25,14 +25,12 @@ #include #endif -#include "CMatrix.h" -#include "dMatrix.h" - #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "mappers.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/fft2.cc b/src/fft2.cc --- a/src/fft2.cc +++ b/src/fft2.cc @@ -25,14 +25,12 @@ #include #endif -#include "CMatrix.h" -#include "dMatrix.h" - #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "mappers.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/filter.cc b/src/filter.cc --- a/src/filter.cc +++ b/src/filter.cc @@ -33,13 +33,9 @@ #include #endif -#include "Array.h" -#include "CColVector.h" -#include "dColVector.h" - #include "defun-dld.h" #include "error.h" -#include "tree-const.h" +#include "oct-obj.h" #include "help.h" extern Array diff --git a/src/find.cc b/src/find.cc --- a/src/find.cc +++ b/src/find.cc @@ -29,7 +29,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" static Octave_object find_to_fortran_idx (const ColumnVector i_idx, const ColumnVector j_idx, diff --git a/src/fsolve.cc b/src/fsolve.cc --- a/src/fsolve.cc +++ b/src/fsolve.cc @@ -36,7 +36,7 @@ #include "gripes.h" #include "help.h" #include "pager.h" -#include "tree-const.h" +#include "oct-obj.h" #include "utils.h" #include "variables.h" diff --git a/src/fsqp.cc b/src/fsqp.cc --- a/src/fsqp.cc +++ b/src/fsqp.cc @@ -30,7 +30,7 @@ #include "defun-dld.h" #include "error.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #ifndef FSQP_MISSING diff --git a/src/givens.cc b/src/givens.cc --- a/src/givens.cc +++ b/src/givens.cc @@ -27,15 +27,13 @@ #include #endif -#include "CMatrix.h" -#include "dMatrix.h" #include "f77-uscore.h" #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" extern "C" diff --git a/src/hess.cc b/src/hess.cc --- a/src/hess.cc +++ b/src/hess.cc @@ -32,7 +32,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/ifft.cc b/src/ifft.cc --- a/src/ifft.cc +++ b/src/ifft.cc @@ -25,14 +25,12 @@ #include #endif -#include "CMatrix.h" -#include "dMatrix.h" - #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "mappers.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/ifft2.cc b/src/ifft2.cc --- a/src/ifft2.cc +++ b/src/ifft2.cc @@ -25,14 +25,12 @@ #include #endif -#include "CMatrix.h" -#include "dMatrix.h" - #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "mappers.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/inv.cc b/src/inv.cc --- a/src/inv.cc +++ b/src/inv.cc @@ -25,14 +25,11 @@ #include #endif -#include "CMatrix.h" -#include "dMatrix.h" - #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/lex.l b/src/lex.l --- a/src/lex.l +++ b/src/lex.l @@ -50,12 +50,12 @@ #include "parse.h" #include "symtab.h" #include "token.h" -#include "tree-base.h" -#include "tree-cmd.h" -#include "tree-const.h" -#include "tree-expr.h" -#include "tree-misc.h" -#include "tree-plot.h" +#include "pt-base.h" +#include "pt-cmd.h" +#include "pt-const.h" +#include "pt-exp.h" +#include "pt-misc.h" +#include "pt-plot.h" #include "user-prefs.h" #include "utils.h" #include "variables.h" diff --git a/src/log.cc b/src/log.cc --- a/src/log.cc +++ b/src/log.cc @@ -31,7 +31,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/lpsolve.cc b/src/lpsolve.cc --- a/src/lpsolve.cc +++ b/src/lpsolve.cc @@ -30,7 +30,7 @@ #include "defun-dld.h" #include "error.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" DEFUN_DLD_BUILTIN ("lp_solve", Flp_solve, Slp_solve, FSlp_solve, 00, "lp_solve (): solve linear programs using lp_solve.") diff --git a/src/lsode.cc b/src/lsode.cc --- a/src/lsode.cc +++ b/src/lsode.cc @@ -35,8 +35,8 @@ #include "error.h" #include "gripes.h" #include "help.h" +#include "oct-obj.h" #include "pager.h" -#include "tree-const.h" #include "utils.h" #include "variables.h" diff --git a/src/lu.cc b/src/lu.cc --- a/src/lu.cc +++ b/src/lu.cc @@ -29,9 +29,10 @@ #include "dbleLU.h" #include "defun-dld.h" +#include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/minmax.cc b/src/minmax.cc --- a/src/minmax.cc +++ b/src/minmax.cc @@ -31,7 +31,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #ifndef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) diff --git a/src/npsol.cc b/src/npsol.cc --- a/src/npsol.cc +++ b/src/npsol.cc @@ -35,8 +35,9 @@ #include "error.h" #include "gripes.h" #include "help.h" +#include "mappers.h" +#include "oct-obj.h" #include "pager.h" -#include "tree-const.h" #include "utils.h" #include "variables.h" diff --git a/src/parse.y b/src/parse.y --- a/src/parse.y +++ b/src/parse.y @@ -44,14 +44,17 @@ #include "toplev.h" #include "pager.h" #include "parse.h" +#include "pt-cmd.h" +#include "pt-const.h" +#include "pt-fcn.h" +#include "pt-fvc.h" +#include "pt-mat.h" +#include "pt-mvr.h" +#include "pt-exp.h" +#include "pt-misc.h" +#include "pt-plot.h" #include "symtab.h" #include "token.h" -#include "tree-base.h" -#include "tree-cmd.h" -#include "tree-const.h" -#include "tree-expr.h" -#include "tree-misc.h" -#include "tree-plot.h" #include "user-prefs.h" #include "utils.h" #include "variables.h" diff --git a/src/pinv.cc b/src/pinv.cc --- a/src/pinv.cc +++ b/src/pinv.cc @@ -25,14 +25,11 @@ #include #endif -#include "CMatrix.h" -#include "dMatrix.h" - #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/pt-cmd.h b/src/pt-cmd.h --- a/src/pt-cmd.h +++ b/src/pt-cmd.h @@ -1,4 +1,4 @@ -// tree-cmd.h -*- C++ -*- +// pt-cmd.h -*- C++ -*- /* Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton @@ -28,7 +28,7 @@ #pragma interface #endif -#include +class ostream; class Octave_object; @@ -53,7 +53,7 @@ class tree_continue_command; class tree_return_command; -#include "tree-base.h" +#include "pt-base.h" // A base class for commands. @@ -72,12 +72,11 @@ tree_global_command : public tree_command { public: - tree_global_command (int l = -1, int c = -1) : tree_command (l, c) - { init_list = 0; } + tree_global_command (int l = -1, int c = -1) + : tree_command (l, c), init_list (0) { } tree_global_command (tree_global_init_list *t, int l = -1, int c = -1) - : tree_command (l, c) - { init_list = t; } + : tree_command (l, c), init_list (t) { } ~tree_global_command (void); @@ -95,26 +94,15 @@ tree_while_command : public tree_command { public: - tree_while_command (int l = -1, int c = -1) : tree_command (l, c) - { - expr = 0; - list = 0; - } + tree_while_command (int l = -1, int c = -1) + : tree_command (l, c), expr (0), list (0) { } tree_while_command (tree_expression *e, int l = -1, int c = -1) - : tree_command (l, c) - { - expr = e; - list = 0; - } + : tree_command (l, c), expr (e), list (0) { } tree_while_command (tree_expression *e, tree_statement_list *lst, int l = -1, int c = -1) - : tree_command (l, c) - { - expr = e; - list = lst; - } + : tree_command (l, c), expr (e), list (lst) { } ~tree_while_command (void); @@ -135,33 +123,18 @@ tree_for_command : public tree_command { public: - tree_for_command (int l = -1, int c = -1) : tree_command (l, c) - { - id = 0; - id_list = 0; - expr = 0; - list = 0; - } + tree_for_command (int l = -1, int c = -1) + : tree_command (l, c), id (0), id_list (0), expr (0), list (0) { } tree_for_command (tree_index_expression *ident, tree_expression *e, tree_statement_list *lst, int l = -1, int c = -1) - : tree_command (l, c) - { - id = ident; - id_list = 0; - expr = e; - list = lst; - } + : tree_command (l, c), id (ident), id_list (0), expr (e), + list (lst) { } tree_for_command (tree_return_list *ident, tree_expression *e, tree_statement_list *lst, int l = -1, int c = -1) - : tree_command (l, c) - { - id = 0; - id_list = ident; - expr = e; - list = lst; - } + : tree_command (l, c), id (0), id_list (ident), expr (e), + list (lst) { } ~tree_for_command (void); @@ -193,12 +166,11 @@ tree_if_command : public tree_command { public: - tree_if_command (int l = -1, int c = -1) : tree_command (l, c) - { list = 0; } + tree_if_command (int l = -1, int c = -1) + : tree_command (l, c), list (0) { } tree_if_command (tree_if_command_list *lst, int l = -1, int c = -1) - : tree_command (l, c) - { list = lst; } + : tree_command (l, c), list (lst) { } ~tree_if_command (void); @@ -218,20 +190,13 @@ tree_unwind_protect_command : public tree_command { public: - tree_unwind_protect_command (int l = -1, int c = -1) : tree_command (l, c) - { - unwind_protect_code = 0; - cleanup_code = 0; - } + tree_unwind_protect_command (int l = -1, int c = -1) + : tree_command (l, c), unwind_protect_code (0), cleanup_code (0) { } tree_unwind_protect_command (tree_statement_list *tc, tree_statement_list *cc, int l = -1, int c = -1) - : tree_command (l, c) - { - unwind_protect_code = tc; - cleanup_code = cc; - } + : tree_command (l, c), unwind_protect_code (tc), cleanup_code (cc) { } ~tree_unwind_protect_command (void); @@ -250,20 +215,13 @@ tree_try_catch_command : public tree_command { public: - tree_try_catch_command (int l = -1, int c = -1) : tree_command (l, c) - { - try_code = 0; - catch_code = 0; - } + tree_try_catch_command (int l = -1, int c = -1) + : tree_command (l, c), try_code (0), catch_code (0) { } tree_try_catch_command (tree_statement_list *tc, tree_statement_list *cc, int l = -1, int c = -1) - : tree_command (l, c) - { - try_code = tc; - catch_code = cc; - } + : tree_command (l, c), try_code (tc), catch_code (cc) { } ~tree_try_catch_command (void); diff --git a/src/pt-const.h b/src/pt-const.h --- a/src/pt-const.h +++ b/src/pt-const.h @@ -1,4 +1,4 @@ -// tree-const.h -*- C++ -*- +// pt-const.h -*- C++ -*- /* Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton @@ -32,19 +32,15 @@ #include -#include +class ostream; #include "Range.h" #include "mx-base.h" -#include "oct-obj.h" -#include "tree-base.h" -#include "tree-expr.h" +#include "pt-fvc.h" -class idx_vector; class Octave_map; - -struct Mapper_fcn; +class Octave_object; // Constants. @@ -624,20 +620,7 @@ return *this; } - Octave_object eval (int print, int /* nargout */, const Octave_object& args) - { - Octave_object retval; - - if (args.length () > 0) - retval(0) = rep->do_index (args); - else - retval(0) = *this; - - if (retval(0).is_defined ()) - retval(0).eval (print); - - return retval; - } + Octave_object eval (int, int, const Octave_object&); // Store the original text corresponding to this constant for later // pretty printing. diff --git a/src/pt-exp-base.h b/src/pt-exp-base.h --- a/src/pt-exp-base.h +++ b/src/pt-exp-base.h @@ -1,4 +1,4 @@ -// tree-expr.h -*- C++ -*- +// pt-exp.h -*- C++ -*- /* Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton @@ -28,44 +28,9 @@ #pragma interface #endif -#include -#include - -#include - -#include "SLList.h" - -#include "error.h" -#include "mappers.h" -#include "oct-obj.h" -#include "variables.h" +class tree_constant; -class tree_constant; -class tree_statement_list; -class tree_argument_list; -class tree_parameter_list; -class tree_return_list; -class tree_va_return_list; -class symbol_record; -class symbol_table; - -class tree_matrix; -class tree_builtin; -class tree_identifier; -class tree_indirect_ref; -class tree_function; -class tree_expression; -class tree_prefix_expression; -class tree_postfix_expression; -class tree_unary_expression; -class tree_binary_expression; -class tree_assignment_expression; -class tree_simple_assignment_expression; -class tree_multi_assignment_expression; -class tree_colon_expression; -class tree_index_expression; - -#include "tree-base.h" +#include "pt-base.h" // A base class for expressions. @@ -112,11 +77,8 @@ decrement, }; - tree_expression (int l = -1, int c = -1) : tree (l, c) - { - in_parens = 0; - etype = unknown; - } + tree_expression (int l = -1, int c = -1, type et = unknown) + : tree (l, c), in_parens (0), etype (et) { } virtual ~tree_expression (void) { } @@ -149,8 +111,7 @@ virtual int is_logically_true (const char *); - virtual void mark_for_possible_ans_assign (void) - { panic_impossible (); } + virtual void mark_for_possible_ans_assign (void); virtual tree_constant eval (int print) = 0; @@ -158,811 +119,6 @@ type etype; }; -// General matrices. This allows us to construct matrices from -// other matrices, variables, and functions. - -class -tree_matrix : public tree_expression -{ -public: - enum dir - { - md_none, - md_right, - md_down, - }; - - tree_matrix (void) - { - direction = tree_matrix::md_none; - element = 0; - next = 0; - } - - tree_matrix (tree_expression *e, tree_matrix::dir d) - { - direction = d; - element = e; - next = 0; - } - - ~tree_matrix (void); - - int is_matrix_constant (void) const; - - tree_matrix *chain (tree_expression *e, tree_matrix::dir d); - tree_matrix *reverse (void); - int length (void); - - tree_return_list *to_return_list (void); - - tree_constant eval (int print); - - void print_code (ostream& os); - -private: - tree_matrix::dir direction; // Direction from the previous element. - tree_expression *element; - tree_matrix *next; -}; - -// A base class for objects that can be return multiple values - -class -tree_multi_val_ret : public tree_expression -{ -public: - tree_multi_val_ret (int l = -1, int c = -1) : tree_expression (l, c) { } - - ~tree_multi_val_ret (void) { } - - int is_multi_val_ret_expression (void) const - { return 1; } - - tree_constant eval (int print); - - virtual Octave_object eval (int print, int nargout, - const Octave_object& args) = 0; -}; - -// Used internally. - -class -tree_oct_obj : public tree_multi_val_ret -{ -public: - tree_oct_obj (int l = -1, int c = -1) : tree_multi_val_ret (l, c) { } - - tree_oct_obj (const Octave_object& v, int l = -1, int c = -1) - : tree_multi_val_ret (l, c) - { - values = v; - } - - ~tree_oct_obj (void) { } - - tree_constant eval (int print); - - Octave_object eval (int print, int nargout, const Octave_object& args); - - void print_code (ostream&) { } - -private: - Octave_object values; -}; - -// A base class for objects that can be evaluated with argument lists. - -class -tree_fvc : public tree_multi_val_ret -{ -public: - tree_fvc (int l = -1, int c = -1) : tree_multi_val_ret (l, c) { } - - ~tree_fvc (void) { } - - virtual tree_constant assign (tree_constant& t, - const Octave_object& args); - - virtual char *name (void) const - { panic_impossible (); return 0; } - - virtual void bump_value (tree_expression::type) - { panic_impossible (); } - - virtual tree_constant lookup_map_element (SLList& list, - int insert = 0, int silent = 0); - - virtual char *fcn_file_name (void) - { return 0; } - - virtual time_t time_parsed (void) - { panic_impossible (); return 0; } - - virtual int is_system_fcn_file (void) const - { return 0; } - - virtual int save (ostream& /* os */, int /* mark_as_global */ = 0, - int /* precision */ = 17) - { panic_impossible (); return 0; } -}; - -// Symbols from the symbol table. - -class -tree_identifier : public tree_fvc -{ - friend class tree_index_expression; - -public: - tree_identifier (int l = -1, int c = -1) : tree_fvc (l, c) - { - sym = 0; - maybe_do_ans_assign = 0; - } - - tree_identifier (symbol_record *s, int l = -1, int c = -1) : tree_fvc (l, c) - { - sym = s; - maybe_do_ans_assign = 0; - } - - ~tree_identifier (void) { } - - int is_identifier (void) const - { return 1; } - - char *name (void) const; - - tree_identifier *define (tree_constant *t); - tree_identifier *define (tree_function *t); - - void document (char *s); - - tree_constant assign (tree_constant& t); - tree_constant assign (tree_constant& t, const Octave_object& args); - - tree_constant assign (SLList list, tree_constant& t); - tree_constant assign (SLList list, tree_constant& t, - const Octave_object& args); - - int is_defined (void); - - void bump_value (tree_expression::type); - - tree_fvc *do_lookup (int& script_file_executed, int exec_script = 1); - - void link_to_global (void); - - void mark_as_formal_parameter (void); - - void mark_for_possible_ans_assign (void) - { maybe_do_ans_assign = 1; } - - tree_constant eval (int print); - - Octave_object eval (int print, int nargout, const Octave_object& args); - - void eval_undefined_error (void); - - void print_code (ostream& os); - -private: - symbol_record *sym; - int maybe_do_ans_assign; -}; - -// Indirect references to values (structure references). - -class -tree_indirect_ref : public tree_fvc -{ -public: - tree_indirect_ref (int l = -1, int c = -1) : tree_fvc (l, c) - { - id = 0; - preserve_ident = 0; - } - - tree_indirect_ref (tree_identifier *i, int l = -1, int c = -1) - : tree_fvc (l, c) - { - id = i; - preserve_ident = 0; - } - - ~tree_indirect_ref (void); - - tree_indirect_ref *chain (const char *s); - - int is_indirect_ref (void) const - { return 1; } - - int is_identifier_only (void) const - { return (id && refs.empty ()); } - - tree_identifier *ident (void) - { return id; } - - void preserve_identifier (void) - { preserve_ident = 1; } - - char *name (void); - - tree_constant assign (tree_constant& t); - tree_constant assign (tree_constant& t, const Octave_object& args); - - void mark_for_possible_ans_assign (void) - { id->mark_for_possible_ans_assign (); } - - tree_constant eval (int print); - - Octave_object eval (int print, int nargout, const Octave_object& args); - - void print_code (ostream& os); - -private: - tree_identifier *id; - SLList refs; - int preserve_ident; -}; - -// Index expressions. - -class -tree_index_expression : public tree_multi_val_ret -{ -public: - tree_index_expression (int l = -1, int c = -1) : tree_multi_val_ret (l, c) - { - id = 0; - list = 0; - } - - tree_index_expression (tree_identifier *i, int l = -1, int c = -1) - : tree_multi_val_ret (l, c) - { - id = new tree_indirect_ref (i); - list = 0; - } - - tree_index_expression (tree_identifier *i, tree_argument_list *lst, - int l = -1, int c = -1) - : tree_multi_val_ret (l, c) - { - id = new tree_indirect_ref (i); - list = lst; - } - - tree_index_expression (tree_indirect_ref *i, int l = -1, int c = -1) - : tree_multi_val_ret (l, c) - { - id = i; - list = 0; - } - - tree_index_expression (tree_indirect_ref *i, tree_argument_list *lst, - int l = -1, int c = -1) - : tree_multi_val_ret (l, c) - { - id = i; - list = lst; - } - - ~tree_index_expression (void); - - int is_index_expression (void) const - { return 1; } - - tree_indirect_ref *ident (void) - { return id; } - - char *name (void) - { return id->name (); } - - tree_argument_list *arg_list (void) - { return list; } - - void mark_for_possible_ans_assign (void) - { - if (id) - id->mark_for_possible_ans_assign (); - } - - tree_constant eval (int print); - - Octave_object eval (int print, int nargout, const Octave_object& args); - - void eval_error (void); - - void print_code (ostream& os); - - private: - tree_indirect_ref *id; - tree_argument_list *list; -}; - -// Prefix expressions. - -class -tree_prefix_expression : public tree_expression -{ - public: - tree_prefix_expression (int l = -1, int c = -1) : tree_expression (l, c) - { - id = 0; - etype = unknown; - } - - tree_prefix_expression (tree_identifier *t, tree_expression::type et, - int l = -1, int c = -1) - : tree_expression (l, c) - { - id = t; - etype = et; - } - - ~tree_prefix_expression (void) - { delete id; } - - tree_constant eval (int print); - - void eval_error (void); - - int is_prefix_expression (void) const - { return 1; } - - char *oper (void) const; - - void print_code (ostream& os); - - private: - tree_identifier *id; -}; - -// Postfix expressions. - -class -tree_postfix_expression : public tree_expression -{ - public: - tree_postfix_expression (int l = -1, int c = -1) : tree_expression (l, c) - { - id = 0; - etype = unknown; - } - - tree_postfix_expression (tree_identifier *t, tree_expression::type et, - int l = -1, int c = -1) - : tree_expression (l, c) - { - id = t; - etype = et; - } - - ~tree_postfix_expression (void) - { delete id; } - - tree_constant eval (int print); - - void eval_error (void); - - char *oper (void) const; - - void print_code (ostream& os); - - private: - tree_identifier *id; -}; - -// Unary expressions. - -class -tree_unary_expression : public tree_expression -{ - public: - tree_unary_expression (int l = -1, int c = -1) : tree_expression (l, c) - { - etype = tree_expression::unknown; - op = 0; - } - - tree_unary_expression (tree_expression *a, tree_expression::type t, - int l = -1, int c = -1) - : tree_expression (l, c) - { - etype = t; - op = a; - } - - ~tree_unary_expression (void) - { delete op; } - - tree_constant eval (int print); - - void eval_error (void); - - char *oper (void) const; - - void print_code (ostream& os); - - private: - tree_expression *op; -}; - -// Binary expressions. - -class -tree_binary_expression : public tree_expression -{ - public: - tree_binary_expression (int l = -1, int c = -1) : tree_expression (l, c) - { - etype = tree_expression::unknown; - op1 = 0; - op2 = 0; - } - - tree_binary_expression (tree_expression *a, tree_expression *b, - tree_expression::type t, int l = -1, int c = -1) - : tree_expression (l, c) - { - etype = t; - op1 = a; - op2 = b; - } - - ~tree_binary_expression (void) - { - delete op1; - delete op2; - } - - tree_constant eval (int print); - - void eval_error (void); - - char *oper (void) const; - - void print_code (ostream& os); - - private: - tree_expression *op1; - tree_expression *op2; -}; - -// Simple assignment expressions. - -class -tree_simple_assignment_expression : public tree_expression -{ -private: - void init (int plhs, int ans_assign) - { - etype = tree_expression::assignment; - lhs_idx_expr = 0; - lhs = 0; - index = 0; - rhs = 0; - preserve = plhs; - ans_ass = ans_assign; - } - - public: - tree_simple_assignment_expression (int plhs = 0, int ans_assign = 0, - int l = -1, int c = -1) - : tree_expression (l, c) - { init (plhs, ans_assign); } - - tree_simple_assignment_expression (tree_identifier *i, - tree_expression *r, - int plhs = 0, int ans_assign = 0, - int l = -1, int c = -1) - : tree_expression (l, c) - { - init (plhs, ans_assign); - lhs = new tree_indirect_ref (i); - rhs = r; - } - - tree_simple_assignment_expression (tree_indirect_ref *i, - tree_expression *r, - int plhs = 0, int ans_assign = 0, - int l = -1, int c = -1) - : tree_expression (l, c) - { - init (plhs, ans_assign); - lhs = i; - rhs = r; - } - - tree_simple_assignment_expression (tree_index_expression *idx_expr, - tree_expression *r, - int plhs = 0, int ans_assign = 0, - int l = -1, int c = -1) - : tree_expression (l, c) - { - init (plhs, ans_assign); - lhs_idx_expr = idx_expr; // cache this -- we may need to delete it. - lhs = idx_expr->ident (); - index = idx_expr->arg_list (); - rhs = r; - } - - ~tree_simple_assignment_expression (void); - - int left_hand_side_is_identifier_only (void) - { return lhs->is_identifier_only (); } - - tree_identifier *left_hand_side_id (void) - { return lhs->ident (); } - - int is_ans_assign (void) - { return ans_ass; } - - tree_constant eval (int print); - - int is_assignment_expression (void) const - { return 1; } - - void eval_error (void); - - void print_code (ostream& os); - - private: - tree_index_expression *lhs_idx_expr; - tree_indirect_ref *lhs; - tree_argument_list *index; - tree_expression *rhs; - int preserve; - int ans_ass; -}; - -// Multi-valued assignment expressions. - -class -tree_multi_assignment_expression : public tree_multi_val_ret -{ - public: - tree_multi_assignment_expression (int plhs = 0, int l = -1, int c = -1) - : tree_multi_val_ret (l, c) - { - etype = tree_expression::multi_assignment; - preserve = plhs; - lhs = 0; - rhs = 0; - } - - tree_multi_assignment_expression (tree_return_list *lst, - tree_multi_val_ret *r, - int plhs = 0, - int l = -1, int c = -1) - : tree_multi_val_ret (l, c) - { - etype = tree_expression::multi_assignment; - preserve = plhs; - lhs = lst; - rhs = r; - } - - ~tree_multi_assignment_expression (void); - - tree_constant eval (int print); - - Octave_object eval (int print, int nargout, const Octave_object& args); - - int is_assignment_expression (void) const - { return 1; } - - void eval_error (void); - - void print_code (ostream& os); - - private: - int preserve; - tree_return_list *lhs; - tree_multi_val_ret *rhs; -}; - -// Colon expressions. - -class -tree_colon_expression : public tree_expression -{ - public: - tree_colon_expression (int l = -1, int c = -1) : tree_expression (l, c) - { - etype = tree_expression::colon; - op1 = 0; - op2 = 0; - op3 = 0; - } - - tree_colon_expression (tree_expression *a, tree_expression *b, - int l = -1, int c = -1) - : tree_expression (l, c) - { - etype = tree_expression::colon; - op1 = a; - op2 = b; - op3 = 0; - } - - ~tree_colon_expression (void) - { - delete op1; - delete op2; - delete op3; - } - - int is_range_constant (void) const; - - tree_colon_expression *chain (tree_expression *t); - - tree_constant eval (int print); - - void eval_error (const char *s); - - void print_code (ostream& os); - - private: - tree_expression *op1; - tree_expression *op2; - tree_expression *op3; -}; - -// Builtin functions. - -class -tree_builtin : public tree_fvc -{ -public: - tree_builtin (const char *nm = 0); - - tree_builtin (Mapper_fcn& m_fcn, const char *nm = 0); - - tree_builtin (Octave_builtin_fcn f, const char *nm = 0); - - ~tree_builtin (void) { } // XXX ?? XXX - -// int is_builtin (void) const; - - int is_mapper_function (void) const - { return is_mapper; } - - tree_constant eval (int print); - - Octave_object eval (int print, int nargout, const Octave_object& args); - - char *name (void) const - { return my_name; } - - void print_code (ostream& os) - { - os << my_name << " can't be printed because it is a builtin function\n"; - } - -private: - int is_mapper; - Mapper_fcn mapper_fcn; - Octave_builtin_fcn fcn; - char *my_name; -}; - -// User defined functions. - -class -tree_function : public tree_fvc -{ -private: - void install_nargin_and_nargout (void); - - void bind_nargin_and_nargout (int nargin, int nargout); - - void init (void) - { - call_depth = 0; - param_list = 0; - ret_list = 0; - sym_tab = 0; - cmd_list = 0; - file_name = 0; - fcn_name = 0; - t_parsed = 0; - system_fcn_file = 0; - num_named_args = 0; - num_args_passed = 0; - curr_va_arg_number = 0; - vr_list = 0; - } - -public: - tree_function (int l = -1, int c = -1) : tree_fvc (l, c) - { init (); } - - tree_function (tree_statement_list *cl, symbol_table *st, - int l = -1, int c = -1) - : tree_fvc (l, c) - { - init (); - sym_tab = st; - cmd_list = cl; - install_nargin_and_nargout (); - } - - ~tree_function (void); - -// tree_function *define (tree_statement_list *t); - tree_function *define_param_list (tree_parameter_list *t); - tree_function *define_ret_list (tree_parameter_list *t); - - void stash_fcn_file_name (void); - - void stash_fcn_file_time (time_t t) - { t_parsed = t; } - - char *fcn_file_name (void) - { return file_name; } - - time_t time_parsed (void) - { return t_parsed; } - - void mark_as_system_fcn_file (void); - - int is_system_fcn_file (void) const - { return system_fcn_file; } - - int takes_varargs (void) const; - - void octave_va_start (void) - { curr_va_arg_number = num_named_args; } - - tree_constant octave_va_arg (void); - - Octave_object octave_all_va_args (void); - - int takes_var_return (void) const; - - void octave_vr_val (const tree_constant& val); - - void stash_function_name (char *s); - - char *function_name (void) - { return fcn_name; } - - tree_constant eval (int print); - - Octave_object eval (int print, int nargout, const Octave_object& args); - - void traceback_error (void); - - void print_code (ostream& os); - -private: - int call_depth; - tree_parameter_list *param_list; - tree_parameter_list *ret_list; - symbol_table *sym_tab; - tree_statement_list *cmd_list; - char *file_name; - char *fcn_name; - time_t t_parsed; - int system_fcn_file; - int num_named_args; - Octave_object args_passed; - int num_args_passed; - int curr_va_arg_number; - tree_va_return_list *vr_list; - symbol_record *nargin_sr; - symbol_record *nargout_sr; - - void print_code_function_header (void); - void print_code_function_header (ostream& os); - - void print_code_function_trailer (void); - void print_code_function_trailer (ostream& os); -}; - #endif /* diff --git a/src/pt-misc.h b/src/pt-misc.h --- a/src/pt-misc.h +++ b/src/pt-misc.h @@ -1,4 +1,4 @@ -// tree-misc.h -*- C++ -*- +// pt-misc.h -*- C++ -*- /* Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton @@ -29,11 +29,13 @@ #endif class ostream; + class Octave_object; class tree_constant; class tree_command; class tree_expression; class tree_simple_assignment_expression; +class tree_index_expression; class tree_identifier; class symbol_record; class symbol_table; @@ -49,10 +51,7 @@ #include -#include "tree-base.h" -#include "tree-cmd.h" -#include "tree-const.h" -#include "tree-expr.h" +#include "pt-base.h" // A list of expressions and commands to be executed. @@ -63,25 +62,13 @@ public: tree_statement (void) - { - command = 0; - expression = 0; - print_flag = 1; - } + : tree_print_code (), command (0), expression (0), print_flag (1) { } tree_statement (tree_command *c) - { - command = c; - expression = 0; - print_flag = 1; - } + : tree_print_code (), command (c), expression (0), print_flag (1) { } tree_statement (tree_expression *e) - { - command = 0; - expression = e; - print_flag = 1; - } + : tree_print_code (), command (0), expression (e), print_flag (1) { } ~tree_statement (void); @@ -94,19 +81,8 @@ int is_expression (void) { return expression != 0; } - int line (void) - { - return command - ? command->line () - : (expression ? expression->line () : -1); - } - - int column (void) - { - return command - ? command->column () - : (expression ? expression->column () : -1); - } + int line (void); + int column (void); void maybe_echo_code (int); @@ -127,11 +103,8 @@ { function_body = 0; } tree_statement_list (tree_statement *s) - : SLList (), tree_print_code () - { - function_body = 0; - append (s); - } + : SLList (), tree_print_code (), function_body (0) + { append (s); } ~tree_statement_list (void) { @@ -191,24 +164,15 @@ { public: tree_parameter_list (void) - : SLList (), tree_print_code () - { marked_for_varargs = 0; } + : SLList (), tree_print_code (), + marked_for_varargs (0) { } tree_parameter_list (tree_identifier *t) - : SLList (), tree_print_code () - { - marked_for_varargs = 0; - append (t); - } + : SLList (), tree_print_code (), + marked_for_varargs (0) + { append (t); } - ~tree_parameter_list (void) - { - while (! empty ()) - { - tree_identifier *t = remove_front (); - delete t; - } - } + ~tree_parameter_list (void); // char *name (void) const; @@ -255,14 +219,7 @@ : SLList (), tree_print_code () { append (t); } - ~tree_return_list (void) - { - while (! empty ()) - { - tree_index_expression *t = remove_front (); - delete t; - } - } + ~tree_return_list (void); void print_code (ostream& os); }; @@ -282,29 +239,15 @@ tree_global : public tree_print_code { public: - tree_global (void) - { - ident = 0; - assign_expr = 0; - } + tree_global (void) : tree_print_code (), ident (0), assign_expr (0) { } tree_global (tree_identifier *id) - { - ident = id; - assign_expr = 0; - } + : tree_print_code (), ident (id), assign_expr (0) { } tree_global (tree_simple_assignment_expression *ass) - { - ident = 0; - assign_expr = ass; - } + : tree_print_code (), ident (0), assign_expr (ass) { } - ~tree_global (void) - { - delete ident; - delete assign_expr; - } + ~tree_global (void); void eval (void); @@ -344,30 +287,15 @@ tree_if_clause : public tree_print_code { public: - tree_if_clause (void) : tree_print_code () - { - expr = 0; - list = 0; - } + tree_if_clause (void) : tree_print_code (), expr (0), list (0) { } - tree_if_clause (tree_statement_list *l) : tree_print_code () - { - expr = 0; - list = l; - } + tree_if_clause (tree_statement_list *l) + : tree_print_code (), expr (0), list (l) { } tree_if_clause (tree_expression *e, tree_statement_list *l) - : tree_print_code () - { - expr = e; - list = l; - } + : tree_print_code (), expr (e), list (l) { } - ~tree_if_clause (void) - { - delete expr; - delete list; - } + ~tree_if_clause (void); int is_else_clause (void) { diff --git a/src/pt-plot.h b/src/pt-plot.h --- a/src/pt-plot.h +++ b/src/pt-plot.h @@ -1,4 +1,4 @@ -// tree-plot.h -*- C++ -*- +// pt-plot.h -*- C++ -*- /* Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton @@ -28,7 +28,8 @@ #pragma interface #endif -#include +class ostream; +class ostrstream; class tree_command; class tree_plot_command; @@ -44,27 +45,15 @@ #include "dColVector.h" #include "idx-vector.h" -#include "tree-cmd.h" -#include "tree-expr.h" +#include "pt-cmd.h" +#include "pt-exp.h" class tree_plot_command : public tree_command { public: - tree_plot_command (void) : tree_command () - { - range = 0; - plot_list = 0; - ndim = 0; - } - - tree_plot_command (subplot_list *plt, plot_limits *rng, int nd) - : tree_command () - { - range = rng; - plot_list = plt; - ndim = nd; - } + tree_plot_command (subplot_list *plt = 0, plot_limits *rng = 0, int nd = 0) + : tree_command (), ndim (nd), range (rng), plot_list (plt) { } ~tree_plot_command (void); @@ -82,33 +71,9 @@ plot_limits : public tree_print_code { public: - plot_limits (void) - { - x_range = 0; - y_range = 0; - z_range = 0; - } - - plot_limits (plot_range *xlim) - { - x_range = xlim; - y_range = 0; - z_range = 0; - } - - plot_limits (plot_range *xlim, plot_range *ylim) - { - x_range = xlim; - y_range = ylim; - z_range = 0; - } - - plot_limits (plot_range *xlim, plot_range *ylim, plot_range *zlim) - { - x_range = xlim; - y_range = ylim; - z_range = zlim; - } + plot_limits (plot_range *xlim = 0, plot_range *ylim = 0, + plot_range *zlim = 0) + : tree_print_code (), x_range (xlim), y_range (ylim), z_range (zlim) { } ~plot_limits (void); @@ -126,17 +91,8 @@ plot_range : public tree_print_code { public: - plot_range (void) - { - lower = 0; - upper = 0; - } - - plot_range (tree_expression *l, tree_expression *u) - { - lower = l; - upper = u; - } + plot_range (tree_expression *l = 0, tree_expression *u = 0) + : tree_print_code (), lower (l), upper (u) { } ~plot_range (void); @@ -205,11 +161,7 @@ { public: subplot_style (void) - { - style = 0; - linetype = 0; - pointtype = 0; - } + : tree_print_code (), style (0), linetype (0), pointtype (0) { } subplot_style (char *s); subplot_style (char *s, tree_expression *lt); @@ -233,29 +185,13 @@ subplot : public tree_print_code { public: - subplot (void) - { - plot_data = 0; - using_clause = 0; - title_clause = 0; - style_clause = 0; - } - - subplot (tree_expression *data) - { - plot_data = data; - using_clause = 0; - title_clause = 0; - style_clause = 0; - } + subplot (tree_expression *data = 0) + : tree_print_code (), plot_data (data), using_clause (0), + title_clause (0), style_clause (0) { } subplot (subplot_using *u, tree_expression *t, subplot_style *s) - { - plot_data = 0; - using_clause = u; - title_clause = t; - style_clause = s; - } + : tree_print_code (), plot_data (0), using_clause (u), + title_clause (t), style_clause (s) { } ~subplot (void); @@ -283,7 +219,7 @@ class subplot_list : public SLList, public tree_print_code { - public: +public: subplot_list (void) : SLList (), tree_print_code () { } subplot_list (subplot *t) : SLList (), tree_print_code () diff --git a/src/qpsol.cc b/src/qpsol.cc --- a/src/qpsol.cc +++ b/src/qpsol.cc @@ -35,8 +35,9 @@ #include "error.h" #include "gripes.h" #include "help.h" +#include "mappers.h" +#include "oct-obj.h" #include "pager.h" -#include "tree-const.h" #include "utils.h" #include "variables.h" diff --git a/src/qr.cc b/src/qr.cc --- a/src/qr.cc +++ b/src/qr.cc @@ -31,9 +31,10 @@ #include "dbleQRP.h" #include "defun-dld.h" +#include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/quad.cc b/src/quad.cc --- a/src/quad.cc +++ b/src/quad.cc @@ -37,7 +37,7 @@ #include "help.h" #include "mappers.h" #include "pager.h" -#include "tree-const.h" +#include "oct-obj.h" #include "utils.h" #include "variables.h" diff --git a/src/qzval.cc b/src/qzval.cc --- a/src/qzval.cc +++ b/src/qzval.cc @@ -29,16 +29,13 @@ #include -#include "CColVector.h" -#include "dColVector.h" -#include "dMatrix.h" #include "f77-uscore.h" #include "defun-dld.h" #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/rand.cc b/src/rand.cc --- a/src/rand.cc +++ b/src/rand.cc @@ -35,7 +35,8 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "mappers.h" +#include "oct-obj.h" #include "unwind-prot.h" #include "utils.h" diff --git a/src/schur.cc b/src/schur.cc --- a/src/schur.cc +++ b/src/schur.cc @@ -34,7 +34,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/sort.cc b/src/sort.cc --- a/src/sort.cc +++ b/src/sort.cc @@ -29,7 +29,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" // This is algorithm 5.2.4L from Knuth, Volume 3. diff --git a/src/svd.cc b/src/svd.cc --- a/src/svd.cc +++ b/src/svd.cc @@ -33,8 +33,8 @@ #include "gripes.h" #include "help.h" #include "mappers.h" +#include "oct-obj.h" #include "pr-output.h" -#include "tree-const.h" #include "user-prefs.h" #include "utils.h" diff --git a/src/syl.cc b/src/syl.cc --- a/src/syl.cc +++ b/src/syl.cc @@ -27,9 +27,7 @@ #include #endif -#include "CMatrix.h" #include "CmplxSCHUR.h" -#include "dMatrix.h" #include "dbleSCHUR.h" #include "f77-uscore.h" @@ -37,7 +35,7 @@ #include "error.h" #include "gripes.h" #include "help.h" -#include "tree-const.h" +#include "oct-obj.h" #include "user-prefs.h" #include "utils.h"