Mercurial > octave
annotate libinterp/octave-value/ov-usr-fcn.h @ 23723:ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
* pt-stmt.h, pt-stmt.cc (tree_statement::echo_code): New argument,
prefix. Pass prefix to tree_print_code constructor instead of VPS4.
* basics.txi: Delete documentation for echo_executing_commands.
* interpreter.h, interpreter.cc (interpreter::maximum_braindamage):
Now a member function.
(interpreter::interpreter): Call tree_evaluator::echo directly instead
of using Fecho_executing_commands. Don't force input to be echoed if
forced_interactive is etst.
* input.h, input.cc (Fecho_executing_commands): Delete.
(Vecho_executing_commands): Delete variable and all uses.
(VPS4): Delete.
(set_default_prompts): Don't set global value for PS4 here.
(base_reader::do_input_echo): Delete.
(gnu_readline): Don't call do_input_echo.
* pt-eval.h, pt-eval.cc (Fecho_executing_commands): Delete.
(FPS4): Move here from input.cc.
(Fecho): Move here from input.cc Rewrite. Handle "echo function
on|off" syntax.
(echo_state): Move enum declaration to tree_evaluator class from input.h.
* ov-usr-fcn.cc (octave_user_script::call, octave_user_function::call):
Push echo state before executing commands. Don't print function
header or trailer here.
(octave_user_function::print_code_function_header,
octave_user_function::print_code_function_trailer): New arg, prefix.
Pass prefix to tree_print_code constructor instead of VPS4.
* pt-eval.h, pt-eval.cc (tree_evaluator::m_PS4,
tree_evaluator::m_echo, tree_evaluator::m_echo_state,
tree_evaluator::m_echo_file_name, tree_evaluator::m_echo_file_pos,
tree_evaluator::m_echo_files): New member variables.
(tree_evaluator::echo_state, tree_evaluator::PS4,
tree_evaluator::echo, tree_evaluator::push_echo_state,
tree_evaluator::set_echo_state, tree_evaluator::set_echo_file_name,
tree_evaluator::set_echo_file_pos, tree_evaluator::echo_this_file,
tree_evaluator::echo_code): New member functions.
(tree_evaluator::visit_break_command,
tree_evaluator::visit_continue_command,
tree_evaluator::visit_decl_command,
tree_evaluator::visit_simple_for_command,
tree_evaluator::visit_complex_for_command,
tree_evaluator::visit_if_command,
tree_evaluator::visit_no_op_command,
tree_evaluator::visit_return_command,
tree_evaluator::visit_switch_command,
tree_evaluator::visit_try_catch_command,
tree_evaluator::visit_unwind_protect_command,
tree_evaluator::visit_while_command,
tree_evaluator::visit_do_until_command):
Manage echo_file_pos and echo code here.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 30 Jun 2017 20:59:54 -0400 |
parents | c495549e9a94 |
children | b40b7243a782 |
rev | line source |
---|---|
2974 | 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 |
2974 | 4 |
5 This file is part of Octave. | |
6 | |
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 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
2974 | 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. |
2974 | 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 |
19 <http://www.gnu.org/licenses/>. | |
2974 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19861
diff
changeset
|
23 #if ! defined (octave_ov_usr_fcn_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
24 #define octave_ov_usr_fcn_h 1 |
2974 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
27 |
2974 | 28 #include <ctime> |
29 | |
30 #include <string> | |
4214 | 31 #include <stack> |
2974 | 32 |
3665 | 33 #include "comment-list.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
34 #include "ovl.h" |
2974 | 35 #include "ov-fcn.h" |
36 #include "ov-typeinfo.h" | |
7336 | 37 #include "symtab.h" |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
38 #include "unwind-prot.h" |
2974 | 39 |
40 class string_vector; | |
41 | |
42 class octave_value; | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
43 |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
44 namespace octave |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
45 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
46 class tree_parameter_list; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
47 class tree_statement_list; |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
48 class tree_evaluator; |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
49 class tree_expression; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
50 class tree_walker; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
51 } |
2974 | 52 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
53 #if defined (HAVE_LLVM) |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
54 class jit_function_info; |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
55 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
56 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 class |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
58 octave_user_code : public octave_function |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
59 { |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
60 protected: |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
61 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
62 octave_user_code (const std::string& nm, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
63 const std::string& ds = "") |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
64 : octave_function (nm, ds) { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
65 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
66 public: |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
67 |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
68 octave_user_code (void) |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
69 : octave_function () { } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
70 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
71 // No copying! |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
72 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
73 octave_user_code (const octave_user_code& f) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
74 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
75 octave_user_code& operator = (const octave_user_code& f) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
76 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
77 ~octave_user_code (void) = default; |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
78 |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
79 bool is_user_code (void) const { return true; } |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
80 |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
81 virtual std::map<std::string, octave_value> subfunctions (void) const; |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
82 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
83 virtual octave::tree_statement_list * body (void) = 0; |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
84 }; |
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
85 |
5744 | 86 // Scripts. |
87 | |
88 class | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
89 octave_user_script : public octave_user_code |
5744 | 90 { |
91 public: | |
92 | |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
93 octave_user_script (void); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
94 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
95 octave_user_script (const std::string& fnm, const std::string& nm, |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
96 octave::tree_statement_list *cmds, |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
97 const std::string& ds = ""); |
5744 | 98 |
99 octave_user_script (const std::string& fnm, const std::string& nm, | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
100 const std::string& ds = ""); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
101 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
102 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
103 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
104 octave_user_script (const octave_user_script& f) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
105 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
106 octave_user_script& operator = (const octave_user_script& f) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
107 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
108 ~octave_user_script (void); |
5744 | 109 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
110 octave_function * function_value (bool = false) { return this; } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
111 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
112 octave_user_script * user_script_value (bool = false) { return this; } |
5744 | 113 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
114 octave_user_code * user_code_value (bool = false) { return this; } |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
115 |
5744 | 116 // Scripts and user functions are both considered "scripts" because |
117 // they are written in Octave's scripting language. | |
118 | |
119 bool is_user_script (void) const { return true; } | |
120 | |
121 void stash_fcn_file_name (const std::string& nm) { file_name = nm; } | |
122 | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
123 void mark_fcn_file_up_to_date (const octave::sys::time& t) { t_checked = t; } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
124 |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
125 void stash_fcn_file_time (const octave::sys::time& t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
126 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 t_parsed = t; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
128 mark_fcn_file_up_to_date (t); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
130 |
5744 | 131 std::string fcn_file_name (void) const { return file_name; } |
132 | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
133 octave::sys::time time_parsed (void) const { return t_parsed; } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
134 |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
135 octave::sys::time time_checked (void) const { return t_checked; } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
136 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
137 octave_value_list |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
138 call (octave::tree_evaluator& tw, int nargout = 0, |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
139 const octave_value_list& args = octave_value_list ()); |
7336 | 140 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
141 octave::tree_statement_list * body (void) { return cmd_list; } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
142 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
143 void accept (octave::tree_walker& tw); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
144 |
5744 | 145 private: |
146 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
147 // The list of commands that make up the body of this function. |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
148 octave::tree_statement_list *cmd_list; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
149 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
150 // The name of the file we parsed. |
5744 | 151 std::string file_name; |
152 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
153 // The time the file was parsed. |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
154 octave::sys::time t_parsed; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
155 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
156 // The time the file was last checked to see if it needs to be |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
157 // parsed again. |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
158 octave::sys::time t_checked; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
159 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
160 // Used to keep track of recursion depth. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
161 int call_depth; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7651
diff
changeset
|
162 |
5744 | 163 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
164 }; | |
165 | |
166 // User-defined functions. | |
2974 | 167 |
168 class | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
169 octave_user_function : public octave_user_code |
2974 | 170 { |
171 public: | |
172 | |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
173 octave_user_function (octave::symbol_table::scope *scope = nullptr, |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
174 octave::tree_parameter_list *pl = nullptr, |
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
175 octave::tree_parameter_list *rl = nullptr, |
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23446
diff
changeset
|
176 octave::tree_statement_list *cl = nullptr); |
2974 | 177 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
178 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
179 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
180 octave_user_function (const octave_user_function& fn) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
181 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
182 octave_user_function& operator = (const octave_user_function& fn) = delete; |
2974 | 183 |
184 ~octave_user_function (void); | |
185 | |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
186 octave::symbol_table::context_id active_context () const |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
187 { |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
188 return is_anonymous_function () |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
189 ? 0 : static_cast<octave::symbol_table::context_id>(call_depth); |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
190 } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
191 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
192 octave_function * function_value (bool = false) { return this; } |
2974 | 193 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
194 octave_user_function * user_function_value (bool = false) { return this; } |
4700 | 195 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
196 octave_user_code * user_code_value (bool = false) { return this; } |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
197 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
198 octave_user_function * define_param_list (octave::tree_parameter_list *t); |
2974 | 199 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
200 octave_user_function * define_ret_list (octave::tree_parameter_list *t); |
2974 | 201 |
4343 | 202 void stash_fcn_file_name (const std::string& nm); |
2974 | 203 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
204 void stash_fcn_location (int line, int col) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
205 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
206 location_line = line; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
207 location_column = col; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
208 } |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
209 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
210 int beginning_line (void) const { return location_line; } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
211 int beginning_column (void) const { return location_column; } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
212 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
213 void stash_fcn_end_location (int line, int col) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
214 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
215 end_location_line = line; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
216 end_location_column = col; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 } |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
218 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
219 int ending_line (void) const { return end_location_line; } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
220 int ending_column (void) const { return end_location_column; } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
221 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
222 void maybe_relocate_end (void); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
223 |
6323 | 224 void stash_parent_fcn_name (const std::string& p) { parent_name = p; } |
225 | |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
226 void stash_parent_fcn_scope (octave::symbol_table::scope *ps); |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
227 |
3665 | 228 void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; } |
229 | |
230 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; } | |
231 | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
232 void mark_fcn_file_up_to_date (const octave::sys::time& t) { t_checked = t; } |
3165 | 233 |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
234 void stash_fcn_file_time (const octave::sys::time& t) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
235 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
236 t_parsed = t; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
237 mark_fcn_file_up_to_date (t); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 } |
2974 | 239 |
4346 | 240 std::string fcn_file_name (void) const { return file_name; } |
2974 | 241 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
242 std::string profiler_name (void) const; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
243 |
6323 | 244 std::string parent_fcn_name (void) const { return parent_name; } |
245 | |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
246 octave::symbol_table::scope * |
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
247 parent_fcn_scope (void) const { return parent_scope; } |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
248 |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
249 octave::symbol_table::scope *scope (void) { return m_scope; } |
7336 | 250 |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
251 octave::sys::time time_parsed (void) const { return t_parsed; } |
2974 | 252 |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
253 octave::sys::time time_checked (void) const { return t_checked; } |
3165 | 254 |
2974 | 255 void mark_as_system_fcn_file (void); |
256 | |
4346 | 257 bool is_system_fcn_file (void) const { return system_fcn_file; } |
2974 | 258 |
4748 | 259 bool is_user_function (void) const { return true; } |
260 | |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
261 void erase_subfunctions (void); |
7876
8447a5024650
clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents:
7761
diff
changeset
|
262 |
2974 | 263 bool takes_varargs (void) const; |
264 | |
5848 | 265 bool takes_var_return (void) const; |
2974 | 266 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
267 void mark_as_private_function (const std::string& cname = ""); |
11445
40f311a69417
fix OO field access in subfunctions of private functions
John W. Eaton <jwe@octave.org>
parents:
11220
diff
changeset
|
268 |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
269 void lock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
270 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
271 void unlock_subfunctions (void); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
272 |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
273 std::map<std::string, octave_value> subfunctions (void) const; |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
274 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
275 bool has_subfunctions (void) const; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
276 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
277 void stash_subfunction_names (const std::list<std::string>& names); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
278 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
279 std::list<std::string> subfunction_names (void) const |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
280 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
281 return subfcn_names; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
282 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
283 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
284 octave_value_list all_va_args (const octave_value_list& args); |
2974 | 285 |
4748 | 286 void stash_function_name (const std::string& s) { my_name = s; } |
2974 | 287 |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
288 void mark_as_subfunction (void) { subfunction = true; } |
4238 | 289 |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
290 bool is_subfunction (void) const { return subfunction; } |
4238 | 291 |
6149 | 292 void mark_as_inline_function (void) { inline_function = true; } |
293 | |
294 bool is_inline_function (void) const { return inline_function; } | |
295 | |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
296 void mark_as_anonymous_function (void) { anonymous_function = true; } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
297 |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
298 bool is_anonymous_function (void) const { return anonymous_function; } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
299 |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
300 bool is_anonymous_function_of_class |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
301 (const std::string& cname = "") const |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
302 { |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
303 return anonymous_function |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
304 ? (cname.empty () |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
305 ? (! dispatch_class ().empty ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
306 : cname == dispatch_class ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
307 : false; |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
308 } |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
309 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
310 // If we are a special expression, then the function body consists of exactly |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
311 // one expression. The expression's result is the return value of the |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
312 // function. |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
313 bool is_special_expr (void) const |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
314 { |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
315 return is_inline_function () || is_anonymous_function (); |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
316 } |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
317 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
318 bool is_nested_function (void) const { return nested_function; } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
319 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
320 void mark_as_nested_function (void) { nested_function = true; } |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
321 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
322 void mark_as_class_constructor (void) { class_constructor = legacy; } |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
323 |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
324 void mark_as_classdef_constructor (void) { class_constructor = classdef; } |
7336 | 325 |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
326 bool is_class_constructor (const std::string& cname = "") const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
327 { |
17856
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
328 return class_constructor == legacy |
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
329 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
330 } |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
331 |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
332 bool is_classdef_constructor (const std::string& cname = "") const |
17856
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
333 { |
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
334 return class_constructor == classdef |
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
335 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
336 } |
7336 | 337 |
338 void mark_as_class_method (void) { class_method = true; } | |
339 | |
21017
93748bcaec17
maint: Replace emtpy 'std::string ()' calls with "".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
340 bool is_class_method (const std::string& cname = "") const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
342 return class_method |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
343 ? (cname.empty () ? true : cname == dispatch_class ()) : false; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
344 } |
7336 | 345 |
23653
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
346 octave_value_list |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
347 call (octave::tree_evaluator& tw, int nargout = 0, |
3bb0a937c071
avoid possible memory errors when parsing function files
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
348 const octave_value_list& args = octave_value_list ()); |
2974 | 349 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
350 octave::tree_parameter_list * parameter_list (void) { return param_list; } |
2974 | 351 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
352 octave::tree_parameter_list * return_list (void) { return ret_list; } |
2974 | 353 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
354 octave::tree_statement_list * body (void) { return cmd_list; } |
2974 | 355 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
356 octave_comment_list * leading_comment (void) { return lead_comm; } |
3665 | 357 |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
358 octave_comment_list * trailing_comment (void) { return trail_comm; } |
3665 | 359 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
360 // If is_special_expr is true, retrieve the sigular expression that forms the |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
361 // body. May be null (even if is_special_expr is true). |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
362 octave::tree_expression * special_expr (void); |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
363 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
364 bool subsasgn_optimization_ok (void); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
365 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
366 void accept (octave::tree_walker& tw); |
2974 | 367 |
23704
c495549e9a94
refactor local protection for internal variables
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
368 octave::unwind_protect * |
c495549e9a94
refactor local protection for internal variables
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
369 unwind_protect_frame (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
370 { |
23704
c495549e9a94
refactor local protection for internal variables
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
371 return curr_unwind_protect_frame; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
372 } |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
373 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
374 #if defined (HAVE_LLVM) |
23446
cd4e1ee28716
maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
375 jit_function_info * get_info (void) { return jit_info; } |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
376 |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
377 void stash_info (jit_function_info *info) { jit_info = info; } |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
378 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
379 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
380 octave_value dump (void) const; |
3933 | 381 |
2974 | 382 private: |
383 | |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
384 enum class_ctor_type |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
385 { |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
386 none, |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
387 legacy, |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
388 classdef |
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
389 }; |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
390 |
23680
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
391 std::string ctor_type_str (void) const; |
ef71711f6d64
rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents:
23653
diff
changeset
|
392 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
393 // Our symbol table scope. |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
394 octave::symbol_table::scope *m_scope; |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
395 |
2974 | 396 // List of arguments for this function. These are local variables. |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
397 octave::tree_parameter_list *param_list; |
2974 | 398 |
399 // List of parameters we return. These are also local variables in | |
400 // this function. | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
401 octave::tree_parameter_list *ret_list; |
2974 | 402 |
403 // The list of commands that make up the body of this function. | |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22869
diff
changeset
|
404 octave::tree_statement_list *cmd_list; |
2974 | 405 |
3665 | 406 // The comments preceding the FUNCTION token. |
407 octave_comment_list *lead_comm; | |
408 | |
409 // The comments preceding the ENDFUNCTION token. | |
410 octave_comment_list *trail_comm; | |
411 | |
6323 | 412 // The name of the file we parsed. |
3523 | 413 std::string file_name; |
2974 | 414 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
415 // Location where this function was defined. |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
416 int location_line; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
417 int location_column; |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
418 int end_location_line; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
419 int end_location_column; |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
11586
diff
changeset
|
420 |
6323 | 421 // The name of the parent function, if any. |
422 std::string parent_name; | |
423 | |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
424 // The list of subfunctions (if any) in the order they appear in the |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
425 // file. |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
426 std::list<std::string> subfcn_names; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
427 |
2974 | 428 // The time the file was parsed. |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
429 octave::sys::time t_parsed; |
2974 | 430 |
3165 | 431 // The time the file was last checked to see if it needs to be |
432 // parsed again. | |
21730
30c53770f47e
use namespace for system time classes
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
433 octave::sys::time t_checked; |
3165 | 434 |
2974 | 435 // True if this function came from a file that is considered to be a |
436 // system function. This affects whether we check the time stamp | |
437 // on the file to see if it has changed. | |
438 bool system_fcn_file; | |
439 | |
440 // Used to keep track of recursion depth. | |
441 int call_depth; | |
442 | |
443 // The number of arguments that have names. | |
444 int num_named_args; | |
445 | |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
446 // TRUE means this subfunction of a primary function. |
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11445
diff
changeset
|
447 bool subfunction; |
4238 | 448 |
6149 | 449 // TRUE means this is an inline function. |
450 bool inline_function; | |
451 | |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
452 // TRUE means this is an anonymous function. |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
453 bool anonymous_function; |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12783
diff
changeset
|
454 |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
455 // TRUE means this is a nested function. (either a child or parent) |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
456 bool nested_function; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14138
diff
changeset
|
457 |
15869
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
458 // Enum describing whether this function is the constructor for class object. |
5e5705b3e505
Implement some embryonic handle-classdef semantic.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15427
diff
changeset
|
459 class_ctor_type class_constructor; |
7336 | 460 |
461 // TRUE means this function is a method for a class. | |
462 bool class_method; | |
463 | |
7968
0d607e8dbbfa
eliminate curr_parent_function; fix subfunction lookup
John W. Eaton <jwe@octave.org>
parents:
7876
diff
changeset
|
464 // The scope of the parent function, if any. |
23693
b9378eff6d13
move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23680
diff
changeset
|
465 octave::symbol_table::scope *parent_scope; |
2974 | 466 |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
467 // pointer to the current unwind_protect frame of this function. |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
468 octave::unwind_protect *curr_unwind_protect_frame; |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
469 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
470 #if defined (HAVE_LLVM) |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
471 jit_function_info *jit_info; |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
472 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
473 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
474 void maybe_relocate_end_internal (void); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16596
diff
changeset
|
475 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23704
diff
changeset
|
476 void print_code_function_header (const std::string& prefix); |
2974 | 477 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23704
diff
changeset
|
478 void print_code_function_trailer (const std::string& prefix); |
2974 | 479 |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23520
diff
changeset
|
480 void bind_automatic_vars (octave::tree_evaluator& tw, |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
481 const string_vector& arg_names, |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
482 int nargin, int nargout, |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
483 const octave_value_list& va_args); |
3219 | 484 |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
485 void restore_warning_states (void); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
486 |
4612 | 487 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2974 | 488 }; |
489 | |
490 #endif |