GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
pt-args-block.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2021-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 (octave_pt_args_block_h)
27#define octave_pt_args_block_h 1
28
29#include "octave-config.h"
30
31#include <list>
32
33#include "pt-arg-list.h"
34#include "pt-cmd.h"
35#include "pt-exp.h"
36#include "pt-id.h"
37#include "pt-walk.h"
38
39// FIXME: We could maybe re-think the naming of some of these objects
40// before releasing a version that contains these new classes...
41
43
44class comment_list;
45
47{
48public:
49
53
54 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (tree_arg_size_spec)
55
57 {
58 delete m_size_args;
59 }
60
61 tree_argument_list * size_args () { return m_size_args; }
62
64 {
65 tw.visit_arg_size_spec (*this);
66 }
67
68private:
69
70 tree_argument_list *m_size_args;
71};
72
74{
75public:
76
80
81 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (tree_arg_validation_fcns)
82
84 {
85 delete m_fcn_args;
86 }
87
88 tree_argument_list * fcn_args () { return m_fcn_args; }
89
91 {
93 }
94
95private:
96
97 tree_argument_list *m_fcn_args;
98};
99
101{
102public:
103
107 const token& eq_tok,
108 tree_expression *default_value)
109 : m_arg_name (nullptr), m_size_spec (size_spec),
110 m_class_name (class_name), m_validation_fcns (validation_fcns),
111 m_eq_tok (eq_tok), m_default_value (default_value)
112 { }
113
114 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (tree_arg_validation)
115
117 {
118 delete m_arg_name;
119 delete m_size_spec;
120 delete m_class_name;
121 delete m_validation_fcns;
122 delete m_default_value;
123 }
124
126 {
127 m_arg_name = name;
128 }
129
130 tree_expression * identifier_expression () { return m_arg_name; }
131
132 tree_arg_size_spec * size_spec () { return m_size_spec; }
133
134 tree_identifier * class_name () { return m_class_name; }
135
137 validation_fcns () { return m_validation_fcns; }
138
140 initializer_expression () { return m_default_value; }
141
143 {
144 tw.visit_arg_validation (*this);
145 }
146
147private:
148
149 // May be a simple identifier or an identifier followed by a single
150 // field name.
151 tree_expression *m_arg_name;
152 tree_arg_size_spec *m_size_spec;
153 tree_identifier *m_class_name;
154 tree_arg_validation_fcns *m_validation_fcns;
155 token m_eq_tok;
156 tree_expression *m_default_value;
157};
158
160 : public std::list<tree_arg_validation *>
161{
162public:
163
165
167
168 tree_args_block_validation_list (const std::list<tree_arg_validation *>& a)
169 : std::list<tree_arg_validation *> (a)
170 { }
171
172 OCTAVE_DISABLE_COPY_MOVE (tree_args_block_validation_list)
173
175
177 {
179 }
180};
181
182// FIXME: Maybe make this object an actual list even though we don't
183// currently need it?
184
186{
187public:
188
190 : m_attr (attr)
191 { }
192
193 OCTAVE_DISABLE_COPY_MOVE (tree_args_block_attribute_list)
194
196 {
197 delete m_attr;
198 }
199
200 tree_identifier * attribute () { return m_attr; }
201
203 {
205 }
206
207private:
208
209 tree_identifier *m_attr;
210};
211
212// Arguments block.
213
215{
216public:
217
219 : m_args_tok (args_tok), m_attr_list (attr_list), m_validation_list (validation_list), m_end_tok (end_tok)
220 { }
221
222 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (tree_arguments_block)
223
225 {
226 delete m_attr_list;
227 delete m_validation_list;
228 }
229
230 filepos beg_pos () const { return m_args_tok.beg_pos (); }
231 filepos end_pos () const { return m_end_tok.end_pos (); }
232
234 {
235 return m_attr_list;
236 }
237
239 {
240 return m_validation_list;
241 }
242
244 {
245 tw.visit_arguments_block (*this);
246 }
247
248private:
249
250 token m_args_tok;
251
253
254 tree_args_block_validation_list *m_validation_list;
255
256 token m_end_tok;
257};
258
259OCTAVE_END_NAMESPACE(octave)
260
261#endif
Definition token.h:42
filepos end_pos() const
Definition token.h:129
filepos beg_pos() const
Definition token.h:128
tree_argument_list * size_args()
void accept(tree_walker &tw)
tree_arg_size_spec(tree_argument_list *size_args)
void accept(tree_walker &tw)
tree_argument_list * fcn_args()
tree_arg_validation_fcns(tree_argument_list *fcn_args)
tree_arg_validation(tree_arg_size_spec *size_spec, tree_identifier *class_name, tree_arg_validation_fcns *validation_fcns, const token &eq_tok, tree_expression *default_value)
tree_arg_size_spec * size_spec()
tree_expression * initializer_expression()
tree_identifier * class_name()
void arg_name(tree_expression *name)
void accept(tree_walker &tw)
tree_expression * identifier_expression()
tree_arg_validation_fcns * validation_fcns()
tree_identifier * attribute()
tree_args_block_attribute_list(tree_identifier *attr=nullptr)
void accept(tree_walker &tw)
tree_args_block_validation_list(const std::list< tree_arg_validation * > &a)
tree_args_block_validation_list(tree_arg_validation *a)
void accept(tree_walker &tw)
tree_args_block_attribute_list * attribute_list()
void accept(tree_walker &tw)
tree_args_block_validation_list * validation_list()
filepos beg_pos() const
tree_arguments_block(const token &args_tok, tree_args_block_attribute_list *attr_list, tree_args_block_validation_list *validation_list, const token &end_tok)
filepos end_pos() const
virtual void visit_args_block_validation_list(tree_args_block_validation_list &)
Definition pt-walk.cc:85
virtual void visit_arg_size_spec(tree_arg_size_spec &)
Definition pt-walk.cc:124
virtual void visit_args_block_attribute_list(tree_args_block_attribute_list &)
Definition pt-walk.cc:76
virtual void visit_arguments_block(tree_arguments_block &)
Definition pt-walk.cc:62
virtual void visit_arg_validation_fcns(tree_arg_validation_fcns &)
Definition pt-walk.cc:133
virtual void visit_arg_validation(tree_arg_validation &)
Definition pt-walk.cc:95
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn