GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-decl.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-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 "defun.h"
28 #include "error.h"
29 #include "pt-cmd.h"
30 #include "ov.h"
31 #include "oct-lvalue.h"
32 #include "pt-bp.h"
33 #include "pt-decl.h"
34 #include "pt-exp.h"
35 #include "pt-id.h"
36 #include "pt-walk.h"
37 #include "utils.h"
38 #include "variables.h"
39 
40 namespace octave
41 {
42  // Declarations (global, static, etc.).
43 
45  {
46  delete m_id;
47  delete m_expr;
48  }
49 
52  {
53  return new tree_decl_elt (m_id ? m_id->dup (scope) : nullptr,
54  m_expr ? m_expr->dup (scope) : nullptr);
55  }
56 
57  // Initializer lists for declaration statements.
58 
59  // Declaration commands (global, static).
60 
62  tree_decl_init_list *t, int l, int c)
63  : tree_command (l, c), m_cmd_name (n), m_init_list (t)
64  {
65  if (t)
66  {
67  if (m_cmd_name == "global")
68  mark_global ();
69  else if (m_cmd_name == "persistent")
70  mark_persistent ();
71  else
72  error ("tree_decl_command: unknown decl type: %s",
73  m_cmd_name.c_str ());
74  }
75  }
76 
78  {
79  delete m_init_list;
80  }
81 }
tree_identifier * m_id
Definition: pt-decl.h:116
void error(const char *fmt,...)
Definition: error.cc:578
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:997
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
void mark_persistent(void)
Definition: pt-decl.h:205
tree_decl_elt * dup(symbol_scope &scope) const
Definition: pt-decl.cc:51
tree_identifier * dup(symbol_scope &scope) const
Definition: pt-id.cc:79
void mark_global(void)
Definition: pt-decl.h:199
tree_decl_command(const std::string &n, int l=-1, int c=-1)
Definition: pt-decl.h:185
tree_decl_elt(tree_identifier *i=nullptr, tree_expression *e=nullptr)
Definition: pt-decl.h:58
std::string m_cmd_name
Definition: pt-decl.h:223
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
tree_expression * m_expr
Definition: pt-decl.h:119
tree_decl_init_list * m_init_list
Definition: pt-decl.h:226
virtual tree_expression * dup(symbol_scope &scope) const =0