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
44
45// Declarations (global, static, etc.).
46
48 : m_type (unknown), m_id (i), m_expr (e)
49{
50 if (! m_id)
51 error ("tree_decl_elt: invalid ID");
52}
53
55{
56 delete m_id;
57 delete m_expr;
58}
59
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
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")
80 else
81 error ("tree_decl_command: unknown decl type: %s",
82 m_cmd_name.c_str ());
83 }
84}
85
87{
88 delete m_init_list;
89}
90
91OCTAVE_END_NAMESPACE(octave)
Definition token.h:42
void mark_persistent()
Definition pt-decl.h:202
void mark_global()
Definition pt-decl.h:196
tree_decl_command(const std::string &n, const token &tok, tree_decl_init_list *t)
Definition pt-decl.cc:71
tree_decl_elt * dup(symbol_scope &scope) const
Definition pt-decl.cc:61
virtual tree_expression * dup(symbol_scope &scope) const =0
tree_identifier * dup(symbol_scope &scope) const
Definition pt-id.cc:77
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error(const char *fmt,...)
Definition error.cc:1003