GNU Octave
10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Loading...
Searching...
No Matches
pt-decl.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 "
defun.h
"
31
#include "
error.h
"
32
#include "
pt-cmd.h
"
33
#include "
ov.h
"
34
#include "
oct-lvalue.h
"
35
#include "
pt-bp.h
"
36
#include "
pt-decl.h
"
37
#include "
pt-exp.h
"
38
#include "
pt-id.h
"
39
#include "
pt-walk.h
"
40
#include "
utils.h
"
41
#include "
variables.h
"
42
43
OCTAVE_BEGIN_NAMESPACE
(octave)
44
45
// Declarations (global, static, etc.).
46
47
tree_decl_elt
::
tree_decl_elt
(
tree_identifier
*i,
tree_expression
*e)
48
: m_type (unknown), m_id (i), m_expr (e)
49
{
50
if
(! m_id)
51
error
(
"tree_decl_elt: invalid ID"
);
52
}
53
54
tree_decl_elt::~tree_decl_elt
()
55
{
56
delete
m_id;
57
delete
m_expr;
58
}
59
60
tree_decl_elt
*
61
tree_decl_elt::dup
(
symbol_scope
& scope)
const
62
{
63
return
new
tree_decl_elt
(m_id->
dup
(scope),
64
m_expr ? m_expr->
dup
(scope) :
nullptr
);
65
}
66
67
// Initializer lists for declaration statements.
68
69
// Declaration commands (global, static).
70
71
tree_decl_command::tree_decl_command
(
const
std::string& n,
const
token
& tok,
tree_decl_init_list
*t)
72
: m_cmd_name (n), m_token (tok), m_init_list (t)
73
{
74
if
(t)
75
{
76
if
(m_cmd_name ==
"global"
)
77
mark_global
();
78
else
if
(m_cmd_name ==
"persistent"
)
79
mark_persistent
();
80
else
81
error
(
"tree_decl_command: unknown decl type: %s"
,
82
m_cmd_name.c_str ());
83
}
84
}
85
86
tree_decl_command::~tree_decl_command
()
87
{
88
delete
m_init_list;
89
}
90
91
OCTAVE_END_NAMESPACE(octave)
symbol_scope
Definition
symscope.h:52
token
Definition
token.h:42
tree_decl_command::mark_persistent
void mark_persistent()
Definition
pt-decl.h:202
tree_decl_command::mark_global
void mark_global()
Definition
pt-decl.h:196
tree_decl_command::tree_decl_command
tree_decl_command(const std::string &n, const token &tok, tree_decl_init_list *t)
Definition
pt-decl.cc:71
tree_decl_command::~tree_decl_command
~tree_decl_command()
Definition
pt-decl.cc:86
tree_decl_elt
Definition
pt-decl.h:49
tree_decl_elt::dup
tree_decl_elt * dup(symbol_scope &scope) const
Definition
pt-decl.cc:61
tree_decl_elt::~tree_decl_elt
~tree_decl_elt()
Definition
pt-decl.cc:54
tree_decl_init_list
Definition
pt-decl.h:111
tree_expression
Definition
pt-exp.h:49
tree_expression::dup
virtual tree_expression * dup(symbol_scope &scope) const =0
tree_identifier
Definition
pt-id.h:53
tree_identifier::dup
tree_identifier * dup(symbol_scope &scope) const
Definition
pt-id.cc:77
OCTAVE_BEGIN_NAMESPACE
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
defun.h
error
void error(const char *fmt,...)
Definition
error.cc:1003
error.h
oct-lvalue.h
ov.h
pt-bp.h
pt-cmd.h
pt-decl.h
pt-exp.h
pt-id.h
pt-walk.h
utils.h
variables.h
libinterp
parse-tree
pt-decl.cc
Generated on Sat Aug 2 2025 06:52:13 for GNU Octave by
1.9.8