Mercurial > octave
annotate libinterp/parse-tree/pt-id.cc @ 24846:7620f1f5290d
use m_ prefix for member variables in parse tree classes
* pt-arg-list.cc, pt-arg-list.h, pt-assign.cc, pt-assign.h,
pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h,
pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h,
pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc,
pt-decl.h, pt-except.cc, pt-except.h, pt-fcn-handle.cc,
pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt-id.cc, pt-id.h,
pt-idx.cc, pt-idx.h, pt-jit.cc, pt-jit.h, pt-loop.cc, pt-loop.h,
pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h,
pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt.cc, pt.h:
Use m_ prefix for member variables in parse tree classes.
Style fixes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 07 Mar 2018 14:56:03 -0500 |
parents | 194eb4bd202b |
children | 6652d3823428 |
rev | line source |
---|---|
2887 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
2887 | 4 |
5 This file is part of Octave. | |
6 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24361
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24361
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
2887 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
2887 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24361
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
2887 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
2887 | 25 #endif |
26 | |
27 #include "error.h" | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23435
diff
changeset
|
28 #include "interpreter-private.h" |
2979 | 29 #include "oct-lvalue.h" |
22898
9baa19102908
refactor display and disp functions (bug #49794)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
30 #include "parse.h" |
2887 | 31 #include "pt-const.h" |
32 #include "pt-id.h" | |
24352
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
33 #include "symscope.h" |
2887 | 34 #include "utils.h" |
2956 | 35 #include "variables.h" |
2887 | 36 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
37 namespace octave |
2887 | 38 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
39 // Symbols from the symbol table. |
2887 | 40 |
23656
609658f98feb
remove some unnecessary include statements from parse tree source
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
41 class tree_evaluator; |
609658f98feb
remove some unnecessary include statements from parse tree source
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
42 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
43 void tree_identifier::link_to_global (const symbol_scope& global_scope, |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
44 const symbol_record& global_sym) |
24352
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
45 { |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
46 if (! m_sym.is_global ()) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
47 m_sym.bind_fwd_rep (global_scope.get_rep (), global_sym); |
24352
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
48 } |
bff8e3884a88
restructure global variable handling in symbol table
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
49 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
50 void |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
51 tree_identifier::eval_undefined_error (void) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
52 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
53 int l = line (); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
54 int c = column (); |
10443
34e51d4e199b
implement smart warnings about missing Matlab functionality
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
55 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
56 maybe_missing_function_hook (name ()); |
2887 | 57 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
58 if (l == -1 && c == -1) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
59 error_with_id ("Octave:undefined-function", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
60 "'%s' undefined", name ().c_str ()); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
61 else |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
62 error_with_id ("Octave:undefined-function", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
63 "'%s' undefined near line %d column %d", |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
64 name ().c_str (), l, c); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
65 } |
2887 | 66 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
67 octave_lvalue |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
68 tree_identifier::lvalue (tree_evaluator *tw) |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
69 { |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
70 if (m_sym.is_added_static ()) |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
71 static_workspace_error (); |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
72 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
73 symbol_scope scope = tw->get_current_scope (); |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24352
diff
changeset
|
74 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
75 return octave_lvalue (m_sym, scope.current_context ()); |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
76 } |
2971 | 77 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
78 tree_identifier * |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
24037
diff
changeset
|
79 tree_identifier::dup (symbol_scope& scope) const |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
80 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
81 // The new tree_identifier object contains a symbol_record |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
82 // entry from the duplicated scope. |
5861 | 83 |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
24037
diff
changeset
|
84 symbol_record new_sym = scope.find_symbol (name ()); |
7336 | 85 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
86 tree_identifier *new_id |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
87 = new tree_identifier (new_sym, line (), column ()); |
5861 | 88 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
89 new_id->copy_base (*this); |
5861 | 90 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
91 return new_id; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22898
diff
changeset
|
92 } |
2887 | 93 } |