GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-misc.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1994-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_pt_misc_h)
24 #define octave_pt_misc_h 1
25 
26 #include "octave-config.h"
27 
28 #include "base-list.h"
29 #include "pt-decl.h"
30 #include "pt-walk.h"
31 #include "symrec.h"
32 
33 namespace octave
34 {
35  class symbol_scope;
36  class tree_identifier;
37  class tree_index_expression;
38 
39  // Parameter lists. Used to hold the list of input and output
40  // parameters in a function definition. Elements are identifiers
41  // only.
42 
43  class tree_parameter_list : public base_list<tree_decl_elt *>
44  {
45  public:
46 
47  enum in_or_out
48  {
49  in = 1,
50  out = 2
51  };
52 
54  : m_marked_for_varargs (0) { }
55 
57  : m_marked_for_varargs (0) { append (t); }
58 
60  : m_marked_for_varargs (0) { append (new tree_decl_elt (id)); }
61 
62  // No copying!
63 
64  tree_parameter_list (const tree_parameter_list&) = delete;
65 
67 
68  ~tree_parameter_list (void);
69 
70  void mark_as_formal_parameters (void);
71 
72  void mark_varargs (void) { m_marked_for_varargs = 1; }
73 
75 
76  bool takes_varargs (void) const { return m_marked_for_varargs != 0; }
77 
78  bool varargs_only (void) { return (m_marked_for_varargs < 0); }
79 
81 
82  std::list<std::string> variable_names (void) const;
83 
84  tree_parameter_list * dup (symbol_scope& scope) const;
85 
86  void accept (tree_walker& tw)
87  {
88  tw.visit_parameter_list (*this);
89  }
90 
91  private:
92 
94  };
95 
96  // Return lists. Used to hold the right hand sides of multiple
97  // assignment expressions.
98 
99  class tree_return_list : public base_list<tree_index_expression *>
100  {
101  public:
102 
103  tree_return_list (void) { }
104 
106 
107  // No copying!
108 
109  tree_return_list (const tree_return_list&) = delete;
110 
112 
113  ~tree_return_list (void);
114 
115  void accept (tree_walker& tw)
116  {
117  tw.visit_return_list (*this);
118  }
119  };
120 }
121 
122 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
123 
124 // tree_parameter_list is derived from a template.
125 // tree_return_list is derived from a template.
126 
127 #endif
128 
129 #endif
tree_parameter_list & operator=(const tree_parameter_list &)=delete
void accept(tree_walker &tw)
Definition: pt-misc.h:86
tree_return_list(tree_index_expression *t)
Definition: pt-misc.h:105
void accept(tree_walker &tw)
Definition: pt-misc.h:115
tree_parameter_list * dup(symbol_scope &scope) const
Definition: pt-misc.cc:80
bool is_defined(symbol_record::context_id context)
Definition: pt-misc.cc:63
std::list< std::string > variable_names(void) const
Definition: pt-misc.cc:52
virtual void visit_parameter_list(tree_parameter_list &)=0
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:79
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
bool takes_varargs(void) const
Definition: pt-misc.h:76
tree_parameter_list(tree_decl_elt *t)
Definition: pt-misc.h:56
void mark_varargs_only(void)
Definition: pt-misc.h:74
void mark_as_formal_parameters(void)
Definition: pt-misc.cc:45
virtual void visit_return_list(tree_return_list &)=0
tree_parameter_list(tree_identifier *id)
Definition: pt-misc.h:59
void append(const tree_decl_elt * &s)
Definition: base-list.h:110
tree_return_list & operator=(const tree_return_list &)=delete