GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-misc.cc
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 (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "pt-idx.h"
28 #include "pt-misc.h"
29 
30 namespace octave
31 {
32  // Parameter lists.
33 
35  {
36  while (! empty ())
37  {
38  iterator p = begin ();
39  delete *p;
40  erase (p);
41  }
42  }
43 
44  void
46  {
47  for (tree_decl_elt *elt : *this)
49  }
50 
51  std::list<std::string>
53  {
54  std::list<std::string> retval;
55 
56  for (tree_decl_elt *elt : *this)
57  retval.push_back (elt->name ());
58 
59  return retval;
60  }
61 
62  bool
64  {
65  bool status = true;
66 
67  for (tree_decl_elt *elt : *this)
68  {
69  if (! elt->is_variable (context))
70  {
71  status = false;
72  break;
73  }
74  }
75 
76  return status;
77  }
78 
81  {
82  tree_parameter_list *new_list = new tree_parameter_list ();
83 
84  if (takes_varargs ())
85  new_list->mark_varargs ();
86 
87  for (const tree_decl_elt *elt : *this)
88  new_list->append (elt->dup (scope));
89 
90  return new_list;
91  }
92 
93  // Return lists.
94 
96  {
97  while (! empty ())
98  {
99  iterator p = begin ();
100  delete *p;
101  erase (p);
102  }
103  }
104 }
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
std::list< tree_decl_elt * >::iterator iterator
Definition: base-list.h:40
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:79
iterator erase(iterator pos)
Definition: base-list.h:52
bool is_variable(symbol_record::context_id context)
Definition: pt-decl.h:74
bool takes_varargs(void) const
Definition: pt-misc.h:76
void mark_as_formal_parameter(void)
Definition: pt-decl.h:79
std::string name(void) const
Definition: pt-decl.h:100
octave_value retval
Definition: data.cc:6246
void mark_as_formal_parameters(void)
Definition: pt-misc.cc:45
tree_decl_elt * dup(symbol_scope &scope) const
Definition: pt-decl.cc:51
p
Definition: lu.cc:138
void append(const elt_type &s)
Definition: base-list.h:110