GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-id.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 "error.h"
28 #include "interpreter-private.h"
29 #include "oct-lvalue.h"
30 #include "parse.h"
31 #include "pt-const.h"
32 #include "pt-id.h"
33 #include "symscope.h"
34 #include "utils.h"
35 #include "variables.h"
36 
37 namespace octave
38 {
39  // Symbols from the symbol table.
40 
41  class tree_evaluator;
42 
43  void tree_identifier::link_to_global (const symbol_scope& global_scope,
44  const symbol_record& global_sym)
45  {
46  if (! m_sym.is_global ())
47  m_sym.bind_fwd_rep (global_scope.get_rep (), global_sym);
48  }
49 
50  void
52  {
53  int l = line ();
54  int c = column ();
55 
57 
58  if (l == -1 && c == -1)
59  error_with_id ("Octave:undefined-function",
60  "'%s' undefined", name ().c_str ());
61  else
62  error_with_id ("Octave:undefined-function",
63  "'%s' undefined near line %d column %d",
64  name ().c_str (), l, c);
65  }
66 
69  {
70  if (m_sym.is_added_static ())
72 
73  symbol_scope scope = tw->get_current_scope ();
74 
75  return octave_lvalue (m_sym, scope.current_context ());
76  }
77 
80  {
81  // The new tree_identifier object contains a symbol_record
82  // entry from the duplicated scope.
83 
84  symbol_record new_sym = scope.find_symbol (name ());
85 
86  tree_identifier *new_id
87  = new tree_identifier (new_sym, line (), column ());
88 
89  new_id->copy_base (*this);
90 
91  return new_id;
92  }
93 }
virtual int line(void) const
Definition: pt.h:56
symbol_record m_sym
Definition: pt-id.h:142
bool is_global(void) const
Definition: symrec.h:653
void eval_undefined_error(void)
Definition: pt-id.cc:51
virtual int column(void) const
Definition: pt.h:58
void link_to_global(const symbol_scope &global_scope, const symbol_record &global_sym)
Definition: pt-id.cc:43
symbol_record find_symbol(const std::string &name)
Definition: symscope.h:674
nd deftypefn *void maybe_missing_function_hook(const std::string &name)
Definition: variables.cc:2216
octave_lvalue lvalue(tree_evaluator *)
Definition: pt-id.cc:68
void bind_fwd_rep(const std::shared_ptr< symbol_scope_rep > &fwd_scope, const symbol_record &sr)
Definition: symrec.h:683
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
symbol_record::context_id current_context(void) const
Definition: symscope.h:669
void error_with_id(const char *id, const char *fmt,...)
Definition: error.cc:623
virtual void copy_base(const tree_expression &e)
Definition: pt-exp.h:130
tree_identifier(int l=-1, int c=-1)
Definition: pt-id.h:53
std::shared_ptr< symbol_scope_rep > get_rep(void) const
Definition: symscope.h:970
bool is_added_static(void) const
Definition: symrec.h:658
tree_identifier * dup(symbol_scope &scope) const
Definition: pt-id.cc:79
symbol_scope get_current_scope(void)
Definition: pt-eval.cc:688
void static_workspace_error(void)
Definition: pt-id.h:124
std::string name(void) const
Definition: pt-id.h:72