GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
pt-arg-list.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <string>
31
32#include "str-vec.h"
33
34#include "ovl.h"
35#include "ov.h"
36#include "pt-arg-list.h"
37#include "pt-exp.h"
38#include "pt-id.h"
39#include "pt-idx.h"
40#include "pt-pr-code.h"
41
43
44// Argument lists.
45
47{
48 while (! empty ())
49 {
50 auto p = begin ();
51 delete *p;
52 erase (p);
53 }
54}
55
56void
58{
59 std::list<tree_expression *>::push_back (s);
60
61 if (! m_list_includes_magic_tilde && s && s->is_identifier ())
62 {
63 tree_identifier *id = dynamic_cast<tree_identifier *> (s);
64 m_list_includes_magic_tilde = id && id->is_black_hole ();
65 }
66}
67
68bool
70{
71 for (const tree_expression *elt : *this)
72 {
73 if (! elt->is_constant ())
74 return false;
75 }
76
77 return true;
78}
79
80bool
82{
83 bool retval = true;
84
85 for (const tree_expression *elt : *this)
86 {
87 // There is no need for a separate check for the magic "~" because it
88 // is represented by tree_black_hole, and that is derived from
89 // tree_identifier.
90 if (! (elt->is_identifier () || elt->is_index_expression ()))
91 {
92 retval = false;
93 break;
94 }
95 }
96
97 return retval;
98}
99
102{
103 int len = size ();
104
105 string_vector retval (len);
106
107 int k = 0;
108
109 for (tree_expression *elt : *this)
110 retval(k++) = elt->str_print_code ();
111
112 return retval;
113}
114
115std::list<std::string>
117{
118 std::list<std::string> retval;
119
120 for (tree_expression *elt : *this)
121 {
122 if (elt->is_identifier ())
123 {
124 tree_identifier *id = dynamic_cast<tree_identifier *> (elt);
125
126 retval.push_back (id->name ());
127 }
128 else if (elt->is_index_expression ())
129 {
130 tree_index_expression *idx_expr
131 = dynamic_cast<tree_index_expression *> (elt);
132
133 retval.push_back (idx_expr->name ());
134 }
135 }
136
137 return retval;
138}
139
142{
143 tree_argument_list *new_list = new tree_argument_list ();
144
145 new_list->m_simple_assign_lhs = m_simple_assign_lhs;
146 new_list->m_list_includes_magic_tilde = m_list_includes_magic_tilde;
147 new_list->m_delims = m_delims;
148
149 for (const tree_expression *elt : *this)
150 new_list->push_back (elt ? elt->dup (scope) : nullptr);
151
152 return new_list;
153}
154
155OCTAVE_END_NAMESPACE(octave)
std::list< std::string > variable_names() const
bool all_elements_are_constant() const
void push_back(const element_type &s)
tree_argument_list * dup(symbol_scope &scope) const
bool is_valid_lvalue_list() const
string_vector get_arg_names() const
virtual bool is_identifier() const
Definition pt-exp.h:68
std::string name() const
Definition pt-id.h:71
std::string name() const
Definition pt-idx.cc:131
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T len
Definition xerbla.cc:61