Mercurial > octave
diff libinterp/parse-tree/parse.h @ 27504:7a31b25e3252
use shared_ptr for storing classdef and statement_list objects in parser
* parse.h, oct-parse.yy (base_parser::m_stmt_list,
base_parser::m_classdef_object): Use shared_ptr object.
(base_parser::statement_list, base_parser::classdef_object):
New accessor functions. Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 10 Oct 2019 13:33:33 -0400 |
parents | 9b261300a001 |
children | c409d16b7190 |
line wrap: on
line diff
--- a/libinterp/parse-tree/parse.h Wed Oct 16 10:56:10 2019 -0400 +++ b/libinterp/parse-tree/parse.h Thu Oct 10 13:33:33 2019 -0400 @@ -27,11 +27,11 @@ #include <cstdio> -#include <string> - #include <deque> #include <map> +#include <memory> #include <set> +#include <string> #include "lex.h" #include "pt-misc.h" @@ -154,6 +154,26 @@ void reset (void); + void classdef_object (const std::shared_ptr<tree_classdef>& obj) + { + m_classdef_object = obj; + } + + std::shared_ptr<tree_classdef> classdef_object (void) const + { + return m_classdef_object; + } + + void statement_list (const std::shared_ptr<tree_statement_list>& lst) + { + m_stmt_list = lst; + } + + std::shared_ptr<tree_statement_list> statement_list (void) const + { + return m_stmt_list; + } + // Error mesages for mismatched end tokens. void end_token_error (token *tok, token::end_tok_type expected); @@ -467,10 +487,10 @@ std::list<std::string> m_subfunction_names; // Pointer to the classdef object we just parsed, if any. - tree_classdef *m_classdef_object; + std::shared_ptr<tree_classdef> m_classdef_object; // Result of parsing input. - tree_statement_list *m_stmt_list; + std::shared_ptr <tree_statement_list> m_stmt_list; // State of the lexer. base_lexer& m_lexer;