Mercurial > octave
diff libinterp/parse-tree/pt-decl.h @ 23075:4e3d47dc7e25
move parse tree classes inside octave namespace
* lex.h, lex.ll, oct-parse.in.yy, parse.h, pt-all.h, pt-arg-list.cc,
pt-arg-list.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc,
pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc,
pt-cbinop.h, pt.cc, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.cc, pt-cmd.h, pt-colon.cc,
pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h,
pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h,
pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt.h,
pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.cc, pt-jump.h,
pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h,
pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc,
pt-stmt.h, pt-unop.cc, pt-unop.h, pt-walk.h, token.cc, token.h:
Move classes and most functions inside octave namespace.
Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 19 Jan 2017 23:41:54 -0500 |
parents | f75d289645ec |
children | ef4d915df748 |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-decl.h Thu Jan 19 14:47:19 2017 -0500 +++ b/libinterp/parse-tree/pt-decl.h Thu Jan 19 23:41:54 2017 -0500 @@ -25,11 +25,6 @@ #include "octave-config.h" -class tree_expression; -class tree_identifier; - -class tree_walker; - #include <string> #include "base-list.h" @@ -38,205 +33,225 @@ #include "pt-id.h" #include "symtab.h" -// List of expressions that make up a declaration statement. - -class -tree_decl_elt +namespace octave { -public: + class tree_expression; + class tree_identifier; + + class tree_walker; - tree_decl_elt (tree_identifier *i = 0, tree_expression *e = 0) - : id (i), expr (e) { } + // List of expressions that make up a declaration statement. - // No copying! + class tree_decl_elt + { + public: - tree_decl_elt (const tree_decl_elt&) = delete; + tree_decl_elt (tree_identifier *i = 0, tree_expression *e = 0) + : id (i), expr (e) { } - tree_decl_elt& operator = (const tree_decl_elt&) = delete; - - ~tree_decl_elt (void); + // No copying! - bool eval (void); + tree_decl_elt (const tree_decl_elt&) = delete; + + tree_decl_elt& operator = (const tree_decl_elt&) = delete; - bool is_defined (void) { return id ? id->is_defined () : false; } + ~tree_decl_elt (void); - bool is_variable (void) { return id ? id->is_variable () : false; } + bool eval (void); - void mark_as_formal_parameter (void) - { - if (id) - id->mark_as_formal_parameter (); - } + bool is_defined (void) { return id ? id->is_defined () : false; } + + bool is_variable (void) { return id ? id->is_variable () : false; } - bool lvalue_ok (void) { return id ? id->lvalue_ok () : false; } + void mark_as_formal_parameter (void) + { + if (id) + id->mark_as_formal_parameter (); + } + + bool lvalue_ok (void) { return id ? id->lvalue_ok () : false; } - // Do not allow functions to return null values. - octave_value rvalue1 (int nargout = 1) - { - return id ? id->rvalue1 (nargout).storable_value () : octave_value (); - } + // Do not allow functions to return null values. + octave_value rvalue1 (int nargout = 1) + { + return id ? id->rvalue1 (nargout).storable_value () : octave_value (); + } - octave_value_list rvalue (int nargout) - { - octave_value_list retval; + octave_value_list rvalue (int nargout) + { + octave_value_list retval; - if (nargout > 1) - error ("invalid number of output arguments in declaration list"); + if (nargout > 1) + error ("invalid number of output arguments in declaration list"); - retval = rvalue1 (nargout); - - return retval; - } + retval = rvalue1 (nargout); - octave_lvalue lvalue (void) { return id ? id->lvalue () : octave_lvalue (); } + return retval; + } - tree_identifier *ident (void) { return id; } + octave_lvalue lvalue (void) { return id ? id->lvalue () : octave_lvalue (); } - std::string name (void) { return id ? id->name () : ""; } + tree_identifier *ident (void) { return id; } - tree_expression *expression (void) { return expr; } + std::string name (void) { return id ? id->name () : ""; } - tree_decl_elt *dup (symbol_table::scope_id scope, - symbol_table::context_id context) const; + tree_expression *expression (void) { return expr; } - void accept (tree_walker& tw); + tree_decl_elt *dup (symbol_table::scope_id scope, + symbol_table::context_id context) const; -private: + void accept (tree_walker& tw); + + private: - // An identifier to tag with the declared property. - tree_identifier *id; + // An identifier to tag with the declared property. + tree_identifier *id; - // An initializer expression (may be zero); - tree_expression *expr; -}; + // An initializer expression (may be zero); + tree_expression *expr; + }; -class -tree_decl_init_list : public octave::base_list<tree_decl_elt *> -{ -public: + class tree_decl_init_list : public octave::base_list<tree_decl_elt *> + { + public: + + tree_decl_init_list (void) { } - tree_decl_init_list (void) { } + tree_decl_init_list (tree_decl_elt *t) { append (t); } - tree_decl_init_list (tree_decl_elt *t) { append (t); } + // No copying! - // No copying! + tree_decl_init_list (const tree_decl_init_list&) = delete; - tree_decl_init_list (const tree_decl_init_list&) = delete; + tree_decl_init_list& operator = (const tree_decl_init_list&) = delete; - tree_decl_init_list& operator = (const tree_decl_init_list&) = delete; + ~tree_decl_init_list (void) + { + while (! empty ()) + { + iterator p = begin (); + delete *p; + erase (p); + } + } - ~tree_decl_init_list (void) - { - while (! empty ()) - { - iterator p = begin (); - delete *p; - erase (p); - } - } + tree_decl_init_list *dup (symbol_table::scope_id scope, + symbol_table::context_id context) const; - tree_decl_init_list *dup (symbol_table::scope_id scope, - symbol_table::context_id context) const; + void accept (tree_walker& tw); + }; - void accept (tree_walker& tw); -}; + // Base class for declaration commands -- global, static, etc. -// Base class for declaration commands -- global, static, etc. + class tree_decl_command : public tree_command + { + public: -class -tree_decl_command : public tree_command -{ -public: + tree_decl_command (const std::string& n, int l = -1, int c = -1) + : tree_command (l, c), cmd_name (n), init_list (0) { } + + tree_decl_command (const std::string& n, tree_decl_init_list *t, + int l = -1, int c = -1) + : tree_command (l, c), cmd_name (n), init_list (t) { } - tree_decl_command (const std::string& n, int l = -1, int c = -1) - : tree_command (l, c), cmd_name (n), init_list (0) { } + // No copying! + + tree_decl_command (const tree_decl_command&) = delete; + + tree_decl_command& operator = (const tree_decl_command&) = delete; - tree_decl_command (const std::string& n, tree_decl_init_list *t, - int l = -1, int c = -1) - : tree_command (l, c), cmd_name (n), init_list (t) { } + ~tree_decl_command (void); + + tree_decl_init_list *initializer_list (void) { return init_list; } - // No copying! + std::string name (void) { return cmd_name; } - tree_decl_command (const tree_decl_command&) = delete; - - tree_decl_command& operator = (const tree_decl_command&) = delete; + protected: - ~tree_decl_command (void); - - tree_decl_init_list *initializer_list (void) { return init_list; } + // The name of this command -- global, static, etc. + std::string cmd_name; - std::string name (void) { return cmd_name; } + // The list of variables or initializers in this declaration command. + tree_decl_init_list *init_list; + }; -protected: + // Global. - // The name of this command -- global, static, etc. - std::string cmd_name; + class tree_global_command : public tree_decl_command + { + public: - // The list of variables or initializers in this declaration command. - tree_decl_init_list *init_list; -}; + tree_global_command (int l = -1, int c = -1) + : tree_decl_command ("global", l, c) { } -// Global. + tree_global_command (tree_decl_init_list *t, int l = -1, int c = -1) + : tree_decl_command ("global", t, l, c) { } -class -tree_global_command : public tree_decl_command -{ -public: + // No copying! + + tree_global_command (const tree_global_command&) = delete; - tree_global_command (int l = -1, int c = -1) - : tree_decl_command ("global", l, c) { } + tree_global_command& operator = (const tree_global_command&) = delete; + + ~tree_global_command (void) = default; - tree_global_command (tree_decl_init_list *t, int l = -1, int c = -1) - : tree_decl_command ("global", t, l, c) { } + tree_command *dup (symbol_table::scope_id scope, + symbol_table::context_id context) const; - // No copying! + void accept (tree_walker& tw); - tree_global_command (const tree_global_command&) = delete; + private: - tree_global_command& operator = (const tree_global_command&) = delete; + static void do_init (tree_decl_elt& elt); + }; - ~tree_global_command (void) = default; + // Persistent. - tree_command *dup (symbol_table::scope_id scope, - symbol_table::context_id context) const; + class tree_persistent_command : public tree_decl_command + { + public: - void accept (tree_walker& tw); + tree_persistent_command (int l = -1, int c = -1) + : tree_decl_command ("persistent", l, c) { } -private: + tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1) + : tree_decl_command ("persistent", t, l, c) { } - static void do_init (tree_decl_elt& elt); -}; + // No copying! -// Persistent. + tree_persistent_command (const tree_persistent_command&) = delete; + + tree_persistent_command& operator = (const tree_persistent_command&) = delete; -class -tree_persistent_command : public tree_decl_command -{ -public: + ~tree_persistent_command (void) = default; + + tree_command *dup (symbol_table::scope_id scope, + symbol_table::context_id context) const; - tree_persistent_command (int l = -1, int c = -1) - : tree_decl_command ("persistent", l, c) { } + void accept (tree_walker& tw); + + private: - tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1) - : tree_decl_command ("persistent", t, l, c) { } - - // No copying! + static void do_init (tree_decl_elt& elt); + }; +} - tree_persistent_command (const tree_persistent_command&) = delete; +#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) - tree_persistent_command& operator = (const tree_persistent_command&) = delete; +OCTAVE_DEPRECATED ("use 'octave::tree_decl_elt' instead") +typedef octave::tree_decl_elt tree_decl_elt; - ~tree_persistent_command (void) = default; +// tree_decl_init_list is derived from a template. - tree_command *dup (symbol_table::scope_id scope, - symbol_table::context_id context) const; - - void accept (tree_walker& tw); +OCTAVE_DEPRECATED ("use 'octave::tree_decl_command' instead") +typedef octave::tree_decl_command tree_decl_command; -private: +OCTAVE_DEPRECATED ("use 'octave::tree_global_command' instead") +typedef octave::tree_global_command tree_global_command; - static void do_init (tree_decl_elt& elt); -}; +OCTAVE_DEPRECATED ("use 'octave::tree_persistent_command' instead") +typedef octave::tree_persistent_command tree_persistent_command; #endif +#endif