Mercurial > octave
annotate libinterp/parse-tree/pt-eval.cc @ 26662:05fc703b419a
update handling of command-style function call syntax in eval
* lex.h, lex.ll (lexical_feedback::m_allow_command_syntax):
New data member.
(lexical_feedback::reset): Reset it.
(lexical_feedback::previous_token_may_be_command,
base_lexer::looks_like_command_arg): Return false immediately if
m_allow_command_syntax is false.
(base_lexer::is_variable): Check if name is a variable if parsing in
top level scope.
* parse.h, oct-parse.yy (base_parser::disallow_command_syntax):
New function.
(word_list_command): Mark index expression as a word list command.
* pt-eval.cc (tree_evaluator::eval_string): If nargout > 0, don't
allow evaluated code to be parsed as a command-style function call.
(tree_evaluator::visit_index_expression): Error if identifier is a
variable and index expression is a command-style function call.
* pt-idx.h, pt-idx.cc (tree_index_expression::m_word_list_cmd):
New member variable.
(tree_index_expression::mark_word_list_cmd,
tree_index_expression::is_word_list_cmd): New functions.
* clearvars.m: Avoid evaluating command-style function call when
assigning result of call to eval.
* test/eval-command.tst: New file.
* bug-38565.tst, bug-38576.tst: Delete obsolete tests.
* test/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 31 Jan 2019 18:45:37 +0000 |
parents | cf9e10ce3351 |
children | 581d01526b34 |
rev | line source |
---|---|
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26179
diff
changeset
|
3 Copyright (C) 2009-2019 John W. Eaton |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
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:
22703
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:
22703
diff
changeset
|
10 (at your option) any later version. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22703
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:
22703
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22703
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22703
diff
changeset
|
15 GNU General Public License for more details. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
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/>. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21542
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21211
diff
changeset
|
24 # include "config.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include <cctype> |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <iostream> |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
30 #include <list> |
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25407
diff
changeset
|
31 #include <string> |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
33 #include "cmd-edit.h" |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
34 #include "file-ops.h" |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
35 #include "oct-env.h" |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
36 |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23110
diff
changeset
|
37 #include "bp-table.h" |
22091
0f6fc2ec3b1a
move call_stack class to a separate file
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
38 #include "call-stack.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 #include "defun.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20962
diff
changeset
|
41 #include "errwarn.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 #include "input.h" |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
43 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
22091
diff
changeset
|
44 #include "interpreter.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "ov-fcn-handle.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 #include "ov-usr-fcn.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
47 #include "ov-re-sparse.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
48 #include "ov-cx-sparse.h" |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
49 #include "profiler.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
50 #include "pt-all.h" |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
51 #include "pt-anon-scopes.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
52 #include "pt-eval.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
53 #include "pt-tm-const.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 #include "symtab.h" |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 #include "unwind-prot.h" |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
56 #include "utils.h" |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
57 #include "variables.h" |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
14899 | 59 //FIXME: This should be part of tree_evaluator |
60 #include "pt-jit.h" | |
15310
b055fc077224
allow jit compiler to be enabled at run-time
John W. Eaton <jwe@octave.org>
parents:
15244
diff
changeset
|
61 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
62 namespace octave |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
64 // Normal evaluator. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
66 bool tree_evaluator::at_top_level (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
67 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
68 return m_call_stack.at_top_level (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
69 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
70 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
71 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
72 tree_evaluator::reset (void) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
73 { |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
74 m_statement_context = SC_OTHER; |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
75 m_result_type = RT_UNDEFINED; |
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
76 m_expr_result_value = octave_value (); |
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
77 m_expr_result_value_list = octave_value_list (); |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
78 m_lvalue_list_stack.clear (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
79 m_nargout_stack.clear (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
80 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
81 |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
82 int tree_evaluator::repl (bool interactive) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
83 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
84 int retval = 0; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
85 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
86 // The parser takes ownership of the lexer and will delete it when |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
87 // the parser goes out of scope. |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
88 |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
89 parser repl_parser (interactive |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
90 ? new lexer (m_interpreter) |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
91 : new lexer (stdin, m_interpreter)); |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
92 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
93 do |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
94 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
95 try |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
96 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
97 reset_error_handler (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
98 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
99 repl_parser.reset (); |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
100 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
101 if (at_top_level ()) |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
102 reset_debug_state (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
103 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
104 retval = repl_parser.run (); |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
105 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
106 if (retval == 0) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
107 { |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
108 if (repl_parser.m_stmt_list) |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
109 { |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
110 repl_parser.m_stmt_list->accept (*this); |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
111 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
112 octave_quit (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
113 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
114 if (! interactive) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
115 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
116 bool quit = (m_returning || m_breaking); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
117 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
118 if (m_returning) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
119 m_returning = 0; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
120 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
121 if (m_breaking) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
122 m_breaking--; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
123 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
124 if (quit) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
125 break; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
126 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
127 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
128 if (octave_completion_matches_called) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
129 octave_completion_matches_called = false; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
130 else |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
131 command_editor::increment_current_command_number (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
132 } |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
133 else if (repl_parser.m_lexer.m_end_of_input) |
25404
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
134 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
135 retval = EOF; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
136 break; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
137 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
138 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
139 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
140 catch (const interrupt_exception&) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
141 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
142 m_interpreter.recover_from_exception (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
143 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
144 // Required newline when the user does Ctrl+C at the prompt. |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
145 if (interactive) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
146 octave_stdout << "\n"; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
147 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
148 catch (const index_exception& e) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
149 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
150 m_interpreter.recover_from_exception (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
151 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
152 std::cerr << "error: unhandled index exception: " |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
153 << e.message () << " -- trying to return to prompt" |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
154 << std::endl; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
155 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
156 catch (const execution_exception& e) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
157 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
158 std::string stack_trace = e.info (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
159 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
160 if (! stack_trace.empty ()) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
161 std::cerr << stack_trace; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
162 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
163 if (interactive) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
164 m_interpreter.recover_from_exception (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
165 else |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
166 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
167 // We should exit with a nonzero status. |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
168 retval = 1; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
169 break; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
170 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
171 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
172 catch (const std::bad_alloc&) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
173 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
174 m_interpreter.recover_from_exception (); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
175 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
176 std::cerr << "error: out of memory -- trying to return to prompt" |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
177 << std::endl; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
178 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
179 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
180 #if defined (DBSTOP_NANINF) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
181 if (Vdebug_on_naninf) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
182 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
183 if (setjump (naninf_jump) != 0) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
184 debug_or_throw_exception (true); // true = stack trace |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
185 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
186 #endif |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
187 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
188 while (retval == 0); |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
189 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
190 if (retval == EOF) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
191 { |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
192 if (interactive) |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
193 octave_stdout << "\n"; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
194 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
195 retval = 0; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
196 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
197 |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
198 return retval; |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
199 } |
e37d857716c3
move core of interpreter::main_loop to evaluator
John W. Eaton <jwe@octave.org>
parents:
25403
diff
changeset
|
200 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
201 octave_value_list |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
202 tree_evaluator::eval_string (const std::string& eval_str, bool silent, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
203 int& parse_status, int nargout) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
204 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
205 octave_value_list retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
206 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
207 parser eval_parser (eval_str, m_interpreter); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
208 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
209 do |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
210 { |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
211 eval_parser.reset (); |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
212 |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
213 // If we are looking at |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
214 // |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
215 // val = eval ("code"); |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
216 // |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
217 // then don't allow code to be parsed as a command. |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
218 |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
219 if (nargout > 0) |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
220 eval_parser.disallow_command_syntax (); |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
221 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
222 parse_status = eval_parser.run (); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
223 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
224 if (parse_status == 0) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
225 { |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
226 if (eval_parser.m_stmt_list) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
227 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
228 tree_statement *stmt = nullptr; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
229 |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
230 if (eval_parser.m_stmt_list->length () == 1 |
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
231 && (stmt = eval_parser.m_stmt_list->front ()) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
232 && stmt->is_expression ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
233 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
234 tree_expression *expr = stmt->expression (); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
235 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
236 if (silent) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
237 expr->set_print_flag (false); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
238 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
239 retval = evaluate_n (expr, nargout); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
240 |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
241 bool do_bind_ans = false; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
242 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
243 if (expr->is_identifier ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
244 do_bind_ans = ! is_variable (expr); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
245 else |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
246 do_bind_ans = ! expr->is_assignment_expression (); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
247 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
248 if (do_bind_ans && ! retval.empty ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
249 bind_ans (retval(0), expr->print_result ()); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
250 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
251 if (nargout == 0) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
252 retval = octave_value_list (); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
253 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
254 else if (nargout == 0) |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
255 eval_parser.m_stmt_list->accept (*this); |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
256 else |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
257 error ("eval: invalid use of statement list"); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
258 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
259 if (returning () || breaking () || continuing ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
260 break; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
261 } |
26512
4d6392c879d7
avoid double free of lexer on exit (bug #55347)
John W. Eaton <jwe@octave.org>
parents:
26509
diff
changeset
|
262 else if (eval_parser.m_lexer.m_end_of_input) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
263 break; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
264 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
265 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
266 while (parse_status == 0); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
267 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
268 return retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
269 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
270 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
271 octave_value tree_evaluator::eval_string (const std::string& eval_str, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
272 bool silent, int& parse_status) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
273 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
274 octave_value retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
275 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
276 octave_value_list tmp = eval_string (eval_str, silent, parse_status, 1); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
277 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
278 if (! tmp.empty ()) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
279 retval = tmp(0); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
280 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
281 return retval; |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
282 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
283 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
284 octave_value_list tree_evaluator::eval_string (const octave_value& arg, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
285 bool silent, int& parse_status, |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
286 int nargout) |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
287 { |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
288 std::string s = arg.xstring_value ("eval: expecting string argument"); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
289 |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
290 return eval_string (s, silent, parse_status, nargout); |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
291 } |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
292 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
293 void |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
294 tree_evaluator::visit_anon_fcn_handle (tree_anon_fcn_handle& anon_fh) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
295 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
296 // FIXME: should CMD_LIST be limited to a single expression? |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
297 // I think that is what Matlab does. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
298 |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
299 tree_parameter_list *param_list = anon_fh.parameter_list (); |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
300 tree_expression *expr = anon_fh.expression (); |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
301 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
302 symbol_scope af_scope = anon_fh.scope (); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
303 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
304 symbol_scope new_scope; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
305 if (af_scope) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
306 new_scope = af_scope.dup (); |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
307 |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
308 tree_parameter_list *param_list_dup |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
309 = param_list ? param_list->dup (new_scope) : nullptr; |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
310 |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
311 tree_parameter_list *ret_list = nullptr; |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
312 |
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
313 tree_statement_list *stmt_list = nullptr; |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
314 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
315 symbol_scope parent_scope = get_current_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
316 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
317 new_scope.set_parent (parent_scope); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
318 new_scope.set_primary_parent (parent_scope); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
319 |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
320 if (expr) |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
321 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
322 tree_expression *expr_dup = expr->dup (new_scope); |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
323 tree_statement *stmt = new tree_statement (expr_dup, nullptr); |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
324 stmt_list = new tree_statement_list (stmt); |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
325 } |
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
326 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
327 tree_anon_scopes anon_fcn_ctx (anon_fh); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
328 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
329 std::set<std::string> free_vars = anon_fcn_ctx.free_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
330 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
331 octave_user_function::local_vars_map local_var_init_vals; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
332 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
333 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
334 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
335 for (auto& name : free_vars) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
336 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
337 octave_value val = frame.varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
338 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
339 if (val.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
340 local_var_init_vals[name] = val; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
341 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
342 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
343 octave_user_function *af |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
344 = new octave_user_function (new_scope, param_list_dup, ret_list, |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
345 stmt_list, local_var_init_vals); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
346 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
347 octave_function *curr_fcn = m_call_stack.current (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
348 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
349 if (curr_fcn) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
350 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
351 // FIXME: maybe it would be better to just stash curr_fcn |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
352 // instead of individual bits of info about it? |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
353 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
354 af->stash_parent_fcn_name (curr_fcn->name ()); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
355 af->stash_dir_name (curr_fcn->dir_name ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
356 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
357 // The following is needed so that class method dispatch works |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
358 // properly for anonymous functions that wrap class methods. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
359 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
360 if (curr_fcn->is_class_method () || curr_fcn->is_class_constructor ()) |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
361 af->stash_dispatch_class (curr_fcn->dispatch_class ()); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
362 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
363 af->stash_fcn_file_name (curr_fcn->fcn_file_name ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
364 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
365 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
366 af->mark_as_anonymous_function (); |
23600
db947ba52118
explicitly limit anonymous functions to a single expression
John W. Eaton <jwe@octave.org>
parents:
23599
diff
changeset
|
367 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
368 octave_value ov_fcn (af); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
369 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
370 // octave_value fh (octave_fcn_binder::maybe_binder (ov_fcn, *this)); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
371 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
372 octave_value fh (new octave_fcn_handle (ov_fcn, octave_fcn_handle::anonymous)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
373 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
374 push_result (fh); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
375 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
377 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
378 tree_evaluator::visit_argument_list (tree_argument_list&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
379 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
380 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
381 } |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
382 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
383 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
384 tree_evaluator::visit_binary_expression (tree_binary_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
385 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
386 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
387 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
388 tree_expression *op_lhs = expr.lhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
389 tree_expression *op_rhs = expr.rhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
390 octave_value::binary_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
391 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
392 if (expr.is_eligible_for_braindead_shortcircuit ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
393 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
394 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
395 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
396 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
397 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
398 if (a.ndims () == 2 && a.rows () == 1 && a.columns () == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
399 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
400 bool result = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
401 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
402 bool a_true = a.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
403 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
404 if (a_true) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
405 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
406 if (etype == octave_value::op_el_or) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
407 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
408 expr.matlab_style_short_circuit_warning ("|"); |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
409 push_result (octave_value (true)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
410 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
411 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
412 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
413 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
414 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
415 if (etype == octave_value::op_el_and) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
416 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
417 expr.matlab_style_short_circuit_warning ("&"); |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
418 push_result (octave_value (false)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
419 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
420 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
421 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
422 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
423 if (op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
424 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
425 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
426 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
427 result = b.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
428 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
429 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
430 push_result (octave_value (result)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
431 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
432 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
433 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
434 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
435 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
436 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
437 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
438 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
439 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
440 if (a.is_defined () && op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
441 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
442 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
443 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
444 if (b.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
445 { |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
446 profiler::enter<tree_binary_expression> |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
447 block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
448 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
449 // Note: The profiler does not catch the braindead |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
450 // short-circuit evaluation code above, but that should be |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
451 // ok. The evaluation of operands and the operator itself |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
452 // is entangled and it's not clear where to start/stop |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
453 // timing the operator to make it reasonable. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
454 |
24565
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
455 type_info& ti = m_interpreter.get_type_info (); |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
456 |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
457 val = ::do_binary_op (ti, etype, a, b); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
458 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
459 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
460 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
461 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
462 push_result (val); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
463 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
464 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
465 void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
466 tree_evaluator::visit_boolean_expression (tree_boolean_expression& expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
467 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
468 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
469 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
470 bool result = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
471 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
472 // This evaluation is not caught by the profiler, since we can't find |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
473 // a reasonable place where to time. Note that we don't want to |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
474 // include evaluation of LHS or RHS into the timing, but this is |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
475 // entangled together with short-circuit evaluation here. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
476 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
477 tree_expression *op_lhs = expr.lhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
478 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
479 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
480 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
481 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
482 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
483 bool a_true = a.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
484 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
485 tree_boolean_expression::type etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
486 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
487 if (a_true) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
488 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
489 if (etype == tree_boolean_expression::bool_or) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
490 { |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
491 push_result (octave_value (true)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
492 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
493 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
494 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
495 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
496 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
497 if (etype == tree_boolean_expression::bool_and) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
498 { |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
499 push_result (octave_value (false)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
500 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
501 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
502 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
503 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
504 tree_expression *op_rhs = expr.rhs (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
505 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
506 if (op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
507 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
508 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
509 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
510 result = b.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
511 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
512 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
513 val = octave_value (result); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
514 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
515 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
516 push_result (val); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
517 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
518 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
519 void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
520 tree_evaluator::visit_compound_binary_expression (tree_compound_binary_expression& expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
521 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
522 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
523 |
23523
d2748870db4e
undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
23522
diff
changeset
|
524 tree_expression *op_lhs = expr.clhs (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
525 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
526 if (op_lhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
527 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
528 octave_value a = evaluate (op_lhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
529 |
23523
d2748870db4e
undo part of previous change
John W. Eaton <jwe@octave.org>
parents:
23522
diff
changeset
|
530 tree_expression *op_rhs = expr.crhs (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
531 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
532 if (a.is_defined () && op_rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
533 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
534 octave_value b = evaluate (op_rhs); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
535 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
536 if (b.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
537 { |
23522
d2e300f7700c
fix compound binary op error introduced in c452180ab672
John W. Eaton <jwe@octave.org>
parents:
23521
diff
changeset
|
538 octave_value::compound_binary_op etype = expr.cop_type (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
539 |
24565
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
540 type_info& ti = m_interpreter.get_type_info (); |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
541 |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
542 val = ::do_binary_op (ti, etype, a, b); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
543 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
544 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
545 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
546 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
547 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
548 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
550 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
551 tree_evaluator::visit_break_command (tree_break_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
552 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
553 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
554 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
555 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
556 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
557 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
558 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
559 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
560 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
561 do_breakpoint (cmd.is_active_breakpoint (*this)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
563 if (m_in_loop_command) |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
564 m_breaking = 1; |
22785
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
565 else |
9c6661004167
error if break statement is in script file separate from loop (bug #39168)
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
566 error ("break must appear in a loop in the same file as loop command"); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
567 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
568 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
569 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
570 tree_evaluator::visit_colon_expression (tree_colon_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
571 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
572 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
573 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
574 tree_expression *op_base = expr.base (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
575 tree_expression *op_limit = expr.limit (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
576 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
577 if (! op_base || ! op_limit) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
578 { |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
579 push_result (octave_value (val)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
580 return; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
581 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
582 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
583 octave_value ov_base = evaluate (op_base); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
584 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
585 octave_value ov_limit = evaluate (op_limit); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
586 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
587 tree_expression *op_increment = expr.increment (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
588 |
23587
0c468af9dc00
maint: Deprecate is_object and replace with isobject.
Rik <rik@octave.org>
parents:
23584
diff
changeset
|
589 if (ov_base.isobject () || ov_limit.isobject ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
590 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
591 octave_value_list tmp1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
592 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
593 if (op_increment) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
594 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
595 octave_value ov_increment = evaluate (op_increment); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
596 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
597 tmp1(2) = ov_limit; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
598 tmp1(1) = ov_increment; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
599 tmp1(0) = ov_base; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
600 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
601 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
602 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
603 tmp1(1) = ov_limit; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
604 tmp1(0) = ov_base; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
605 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
606 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
607 symbol_table& symtab = m_interpreter.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
608 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
609 octave_value fcn = symtab.find_function ("colon", tmp1); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
610 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
611 if (! fcn.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
612 error ("can not find overloaded colon function"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
613 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
614 octave_value_list tmp2 = feval (fcn, tmp1, 1); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
615 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
616 val = tmp2 (0); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
617 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
618 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
619 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
620 octave_value ov_increment = 1.0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
621 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
622 if (op_increment) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
623 ov_increment = evaluate (op_increment); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
624 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
625 val = do_colon_op (ov_base, ov_increment, ov_limit, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
626 expr.is_for_cmd_expr ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
627 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
628 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
629 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
630 } |
10188
97ae300aa73a
improve implementation of break, continue, and return commands
John W. Eaton <jwe@octave.org>
parents:
10186
diff
changeset
|
631 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
632 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
633 tree_evaluator::visit_continue_command (tree_continue_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
634 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
635 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
636 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
637 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
638 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
639 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
640 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
641 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
642 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
643 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
644 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
645 if (m_in_loop_command) |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
646 m_continuing = 1; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
647 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
648 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
649 bool |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
650 tree_evaluator::statement_printing_enabled (void) |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
651 { |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
652 return ! (m_silent_functions && (m_statement_context == SC_FUNCTION |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
653 || m_statement_context == SC_SCRIPT)); |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
654 } |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
655 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
656 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
657 tree_evaluator::reset_debug_state (void) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
658 { |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
659 m_debug_mode = m_bp_table.have_breakpoints () || Vdebugging; |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
660 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
661 m_dbstep_flag = 0; |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
662 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
663 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
664 void |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
665 tree_evaluator::reset_debug_state (bool mode) |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
666 { |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
667 m_debug_mode = mode; |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
668 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
669 m_dbstep_flag = 0; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
670 } |
10186
095a1e670e68
make dbstep work with keyboard function
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
671 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
672 Matrix |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
673 tree_evaluator::ignored_fcn_outputs (void) const |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
674 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
675 Matrix retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
676 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
677 const std::list<octave_lvalue> *lvalues = lvalue_list (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
678 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
679 if (! lvalues) |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
680 return retval; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
681 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
682 octave_idx_type nbh = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
683 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
684 for (const auto& lval : *lvalues) |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
685 nbh += lval.is_black_hole (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
686 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
687 if (nbh > 0) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
688 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
689 retval.resize (1, nbh); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
690 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
691 octave_idx_type k = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
692 octave_idx_type l = 0; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
693 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
694 for (const auto& lval : *lvalues) |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
695 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
696 if (lval.is_black_hole ()) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
697 retval(l++) = k+1; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
698 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
699 k += lval.numel (); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
700 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
701 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
702 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
703 return retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
704 } |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
705 |
24349
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
706 bool |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
707 tree_evaluator::isargout (int nargout, int iout) const |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
708 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
709 const std::list<octave_lvalue> *lvalues = lvalue_list (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
710 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
711 if (iout >= std::max (nargout, 1)) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
712 return false; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
713 else if (lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
714 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
715 int k = 0; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
716 for (const auto& lval : *lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
717 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
718 if (k == iout) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
719 return ! lval.is_black_hole (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
720 k += lval.numel (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
721 if (k > iout) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
722 break; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
723 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
724 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
725 return true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
726 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
727 else |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
728 return true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
729 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
730 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
731 void |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
732 tree_evaluator::isargout (int nargout, int nout, bool *isargout) const |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
733 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
734 const std::list<octave_lvalue> *lvalues = lvalue_list (); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
735 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
736 if (lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
737 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
738 int k = 0; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
739 for (const auto& lval : *lvalues) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
740 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
741 if (lval.is_black_hole ()) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
742 isargout[k++] = false; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
743 else |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
744 { |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
745 int l = std::min (k + lval.numel (), |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
746 static_cast<octave_idx_type> (nout)); |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
747 while (k < l) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
748 isargout[k++] = true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
749 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
750 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
751 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
752 else |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
753 for (int i = 0; i < nout; i++) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
754 isargout[i] = true; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
755 |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
756 for (int i = std::max (nargout, 1); i < nout; i++) |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
757 isargout[i] = false; |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
758 } |
4ced2bfd737e
deprecate defun_isargout functions
John W. Eaton <jwe@octave.org>
parents:
24270
diff
changeset
|
759 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
760 octave_value |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
761 tree_evaluator::evaluate (tree_decl_elt *elt) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
762 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
763 // Do not allow functions to return null values. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
764 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
765 tree_identifier *id = elt->ident (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
766 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
767 return id ? evaluate (id).storable_value () : octave_value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
768 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
769 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
770 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
771 tree_evaluator::is_variable (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
772 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
773 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
774 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
775 return frame.is_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
776 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
777 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
778 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
779 tree_evaluator::is_local_variable (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
780 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
781 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
782 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
783 return frame.is_local_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
784 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
785 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
786 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
787 tree_evaluator::is_variable (const tree_expression *expr) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
788 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
789 if (expr->is_identifier ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
790 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
791 const tree_identifier *id |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
792 = dynamic_cast<const tree_identifier *> (expr); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
793 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
794 if (id->is_black_hole ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
795 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
796 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
797 return is_variable (id->symbol ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
798 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
799 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
800 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
801 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
802 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
803 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
804 tree_evaluator::is_defined (const tree_expression *expr) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
805 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
806 if (expr->is_identifier ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
807 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
808 const tree_identifier *id |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
809 = dynamic_cast<const tree_identifier *> (expr); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
810 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
811 return is_defined (id->symbol ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
812 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
813 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
814 return false; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
815 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
816 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
817 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
818 tree_evaluator::is_variable (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
819 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
820 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
821 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
822 return frame.is_variable (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
823 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
824 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
825 bool |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
826 tree_evaluator::is_defined (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
827 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
828 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
829 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
830 return frame.is_defined (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
831 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
832 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
833 bool tree_evaluator::is_global (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
834 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
835 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
836 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
837 return frame.is_global (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
838 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
839 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
840 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
841 tree_evaluator::varval (const symbol_record& sym) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
842 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
843 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
844 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
845 return frame.varval (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
846 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
847 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
848 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
849 tree_evaluator::varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
850 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
851 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
852 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
853 return frame.varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
854 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
855 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
856 void tree_evaluator::install_variable (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
857 const octave_value& value, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
858 bool global) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
859 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
860 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
861 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
862 return frame.install_variable (name, value, global); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
863 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
864 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
865 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
866 tree_evaluator::global_varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
867 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
868 return m_call_stack.global_varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
869 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
870 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
871 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
872 tree_evaluator::global_assign (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
873 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
874 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
875 m_call_stack.global_varref (name) = val; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
876 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
877 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
878 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
879 tree_evaluator::top_level_varval (const std::string& name) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
880 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
881 return m_call_stack.get_top_level_value (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
882 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
883 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
884 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
885 tree_evaluator::top_level_assign (const std::string& name, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
886 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
887 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
888 m_call_stack.set_top_level_value (name, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
889 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
890 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
891 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
892 tree_evaluator::assign (const std::string& name, const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
893 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
894 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
895 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
896 frame.assign (name, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
897 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
898 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
899 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
900 tree_evaluator::set_auto_fcn_var (stack_frame::auto_var_type avt, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
901 const octave_value& val) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
902 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
903 m_call_stack.set_auto_fcn_var (avt, val); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
904 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
905 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
906 octave_value |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
907 tree_evaluator::get_auto_fcn_var (stack_frame::auto_var_type avt) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
908 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
909 return m_call_stack.get_auto_fcn_var (avt); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
910 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
911 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
912 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
913 tree_evaluator::define_parameter_list_from_arg_vector |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
914 (tree_parameter_list *param_list, const octave_value_list& args) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
915 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
916 int i = -1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
917 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
918 for (tree_decl_elt *elt : *param_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
919 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
920 i++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
921 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
922 octave_lvalue ref = elt->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
923 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
924 if (i < args.length ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
925 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
926 if (args(i).is_defined () && args(i).is_magic_colon ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
927 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
928 if (! eval_decl_elt (elt)) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
929 error ("no default value for argument %d", i+1); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
930 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
931 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
932 ref.define (args(i)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
933 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
934 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
935 eval_decl_elt (elt); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
936 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
937 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
938 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
939 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
940 tree_evaluator::undefine_parameter_list (tree_parameter_list *param_list) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
941 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
942 for (tree_decl_elt *elt : *param_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
943 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
944 octave_lvalue ref = elt->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
945 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
946 ref.assign (octave_value::op_asn_eq, octave_value ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
947 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
948 } |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
949 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
950 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
951 // END is documented in op-kw-docs. |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
952 DEFCONSTMETHOD (end, interp, , , |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
953 doc: /* -*- texinfo -*- |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
954 @deftypefn {} {} end |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
955 Last element of an array or the end of any @code{for}, @code{parfor}, |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
956 @code{if}, @code{do}, @code{while}, @code{function}, @code{switch}, |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
957 @code{try}, or @code{unwind_protect} block. |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
958 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
959 As an index of an array, the magic index @qcode{"end"} refers to the |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
960 last valid entry in an indexing operation. |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
961 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
962 Example: |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
963 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
964 @example |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
965 @group |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
966 @var{x} = [ 1 2 3; 4 5 6 ]; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
967 @var{x}(1,end) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
968 @result{} 3 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
969 @var{x}(end,1) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
970 @result{} 4 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
971 @var{x}(end,end) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
972 @result{} 6 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
973 @end group |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
974 @end example |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
975 @seealso{for, parfor, if, do, while, function, switch, try, unwind_protect} |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
976 @end deftypefn */) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
977 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
978 octave_value retval; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
979 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
980 octave::tree_evaluator& tw = interp.get_evaluator (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
981 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
982 const octave_value *indexed_object = tw.indexed_object (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
983 int index_position = tw.index_position (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
984 int num_indices = tw.num_indices (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
985 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
986 if (! indexed_object) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
987 error ("invalid use of end"); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
988 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
989 if (indexed_object->isobject ()) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
990 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
991 octave_value_list args; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
992 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
993 args(2) = num_indices; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
994 args(1) = index_position + 1; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
995 args(0) = *indexed_object; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
996 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
997 std::string class_name = indexed_object->class_name (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
998 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
999 octave::symbol_table& symtab = interp.get_symbol_table (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1000 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1001 octave_value meth = symtab.find_method ("end", class_name); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1002 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1003 if (meth.is_defined ()) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1004 return octave::feval (meth.function_value (), args, 1); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1005 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1006 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1007 dim_vector dv = indexed_object->dims (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1008 int ndims = dv.ndims (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1009 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1010 if (num_indices < ndims) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1011 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1012 for (int i = num_indices; i < ndims; i++) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1013 dv(num_indices-1) *= dv(i); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1014 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1015 if (num_indices == 1) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1016 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1017 ndims = 2; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1018 dv.resize (ndims); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1019 dv(1) = 1; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1020 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1021 else |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1022 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1023 ndims = num_indices; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1024 dv.resize (ndims); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1025 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1026 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1027 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1028 if (index_position < ndims) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1029 retval = dv(index_position); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1030 else |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1031 retval = 1; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1032 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1033 return retval; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1034 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1035 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1036 namespace octave |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1037 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1038 octave_value_list |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1039 tree_evaluator::convert_to_const_vector (tree_argument_list *arg_list, |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1040 const octave_value *object) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1041 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1042 // END doesn't make sense as a direct argument for a function (i.e., |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1043 // "fcn (end)" is invalid but "fcn (array (end))" is OK). Maybe we |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1044 // need a different way of asking an octave_value object this |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1045 // question? |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1046 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1047 bool stash_object = (arg_list->includes_magic_end () |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1048 && object |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1049 && ! (object->is_function () |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1050 || object->is_function_handle ())); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1051 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1052 unwind_protect frame; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1053 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1054 if (stash_object) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1055 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1056 frame.protect_var (m_indexed_object); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1057 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1058 m_indexed_object = object; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1059 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1060 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1061 int len = arg_list->length (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1062 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1063 std::list<octave_value_list> args; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1064 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1065 auto p = arg_list->begin (); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1066 for (int k = 0; k < len; k++) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1067 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1068 if (stash_object) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1069 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1070 frame.protect_var (m_index_position); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1071 frame.protect_var (m_num_indices); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1072 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1073 m_index_position = k; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1074 m_num_indices = len; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1075 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1076 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1077 tree_expression *elt = *p++; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1078 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1079 if (elt) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1080 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1081 octave_value tmp = evaluate (elt); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1082 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1083 if (tmp.is_cs_list ()) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1084 args.push_back (tmp.list_value ()); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1085 else if (tmp.is_defined ()) |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1086 args.push_back (tmp); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1087 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1088 else |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1089 { |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1090 args.push_back (octave_value ()); |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1091 break; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1092 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1093 } |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1094 |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1095 return args; |
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
1096 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1097 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1098 octave_value_list |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1099 tree_evaluator::convert_return_list_to_const_vector |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1100 (tree_parameter_list *ret_list, int nargout, const Cell& varargout) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1101 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1102 octave_idx_type vlen = varargout.numel (); |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1103 int len = ret_list->length (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1104 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1105 // Special case. Will do a shallow copy. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1106 if (len == 0) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1107 return varargout; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1108 else if (nargout <= len) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1109 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1110 octave_value_list retval (nargout); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1111 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1112 int i = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1113 |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1114 for (tree_decl_elt *elt : *ret_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1115 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1116 if (is_defined (elt->ident ())) |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
1117 { |
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
1118 octave_value tmp = evaluate (elt); |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1119 retval(i) = tmp; |
23602
214cb58ccc1c
use pointer to scope instead of scope id
John W. Eaton <jwe@octave.org>
parents:
23600
diff
changeset
|
1120 } |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1121 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1122 i++; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1123 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1124 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1125 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1126 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1127 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1128 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1129 octave_value_list retval (len + vlen); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1130 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1131 int i = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1132 |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
1133 for (tree_decl_elt *elt : *ret_list) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1134 retval(i++) = evaluate (elt); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1135 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1136 for (octave_idx_type j = 0; j < vlen; j++) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1137 retval(i++) = varargout(j); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1138 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1139 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1140 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1141 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1142 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1143 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1144 tree_evaluator::eval_decl_elt (tree_decl_elt *elt) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1145 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1146 bool retval = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1147 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1148 tree_identifier *id = elt->ident (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1149 tree_expression *expr = elt->expression (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1150 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1151 if (id && expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1152 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
1153 octave_lvalue ult = id->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1154 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1155 octave_value init_val = evaluate (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1156 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1157 ult.assign (octave_value::op_asn_eq, init_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1158 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1159 retval = true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1160 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1161 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1162 return retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1163 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1164 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1165 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1166 tree_evaluator::switch_case_label_matches (tree_switch_case *expr, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1167 const octave_value& val) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1168 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1169 tree_expression *label = expr->case_label (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1170 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1171 octave_value label_value = evaluate (label); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1172 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1173 if (label_value.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1174 { |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23563
diff
changeset
|
1175 if (label_value.iscell ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1176 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1177 Cell cell (label_value.cell_value ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1178 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1179 for (octave_idx_type i = 0; i < cell.rows (); i++) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1180 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1181 for (octave_idx_type j = 0; j < cell.columns (); j++) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1182 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1183 bool match = val.is_equal (cell(i,j)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1184 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1185 if (match) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1186 return true; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1187 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1188 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1189 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1190 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1191 return val.is_equal (label_value); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1192 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1193 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1194 return false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1195 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1196 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1197 symbol_scope tree_evaluator::get_top_scope (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1198 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1199 return m_call_stack.top_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1200 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1201 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1202 symbol_scope tree_evaluator::get_current_scope (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1203 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1204 return m_call_stack.current_scope (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1205 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1206 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1207 octave_value tree_evaluator::find (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1208 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1209 const stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1210 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1211 octave_value val = frame.varval (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1212 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1213 if (val.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1214 return val; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1215 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1216 // Subfunction. I think it only makes sense to check for |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1217 // subfunctions if we are currently executing a function defined |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1218 // from a .m file. |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1219 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1220 octave_value fcn = frame.find_subfunction (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1221 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1222 if (fcn.is_defined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1223 return fcn; |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1224 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1225 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1226 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1227 return symtab.fcn_table_find (name, ovl ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1228 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1229 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1230 void tree_evaluator::clear_objects (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1231 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1232 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1233 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1234 frame.clear_objects (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1235 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1236 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1237 void tree_evaluator::clear_variable (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1238 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1239 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1240 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1241 frame.clear_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1242 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1243 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1244 void tree_evaluator::clear_variable_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1245 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1246 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1247 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1248 frame.clear_variable_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1249 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1250 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1251 void tree_evaluator::clear_variable_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1252 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1253 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1254 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1255 frame.clear_variable_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1256 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1257 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1258 void tree_evaluator::clear_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1259 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1260 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1261 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1262 frame.clear_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1263 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1264 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1265 void tree_evaluator::clear_global_variable (const std::string& name) |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1266 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1267 m_call_stack.clear_global_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1268 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1269 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1270 void |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1271 tree_evaluator::clear_global_variable_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1272 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1273 m_call_stack.clear_global_variable_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1274 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1275 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1276 void tree_evaluator::clear_global_variable_regexp(const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1277 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1278 m_call_stack.clear_global_variable_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1279 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1280 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1281 void tree_evaluator::clear_global_variables (void) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1282 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1283 m_call_stack.clear_global_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1284 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1285 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1286 void tree_evaluator::clear_all (bool force) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1287 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1288 // FIXME: should this also clear objects? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1289 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1290 clear_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1291 clear_global_variables (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1292 |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1293 symbol_table& symtab = m_interpreter.get_symbol_table (); |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1294 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1295 symtab.clear_functions (force); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1296 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1297 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1298 void tree_evaluator::clear_symbol (const std::string& name) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1299 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1300 // FIXME: are we supposed to do both here? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1301 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1302 clear_variable (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1303 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1304 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1305 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1306 symtab.clear_function (name); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1307 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1308 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1309 void tree_evaluator::clear_symbol_pattern (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1310 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1311 // FIXME: are we supposed to do both here? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1312 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1313 clear_variable_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1314 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1315 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1316 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1317 symtab.clear_function_pattern (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1318 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1319 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1320 void tree_evaluator::clear_symbol_regexp (const std::string& pattern) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1321 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1322 // FIXME: are we supposed to do both here? |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1323 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1324 clear_variable_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1325 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1326 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1327 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1328 symtab.clear_function_regexp (pattern); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1329 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1330 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1331 std::list<std::string> tree_evaluator::global_variable_names (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1332 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1333 return m_call_stack.global_variable_names (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1334 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1335 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1336 std::list<std::string> tree_evaluator::variable_names (void) const |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1337 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1338 return m_call_stack.variable_names (); |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1339 } |
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1340 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1341 // Return a pointer to the user-defined function FNAME. If FNAME is empty, |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1342 // search backward for the first user-defined function in the |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1343 // current call stack. |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1344 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1345 octave_user_code * |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1346 tree_evaluator::get_user_code (const std::string& fname) |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1347 { |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1348 octave_user_code *user_code = nullptr; |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1349 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1350 if (fname.empty ()) |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1351 user_code = m_call_stack.debug_user_code (); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1352 else |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1353 { |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1354 std::string name = fname; |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1355 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1356 if (sys::file_ops::dir_sep_char () != '/' && name[0] == '@') |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1357 { |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1358 auto beg = name.begin () + 2; // never have @/method |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1359 auto end = name.end () - 1; // never have trailing '/' |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1360 std::replace (beg, end, '/', sys::file_ops::dir_sep_char ()); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1361 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1362 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1363 size_t name_len = name.length (); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1364 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1365 if (name_len > 2 && name.substr (name_len-2) == ".m") |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1366 name = name.substr (0, name_len-2); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1367 |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1368 if (name.empty ()) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1369 return nullptr; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1370 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1371 symbol_table& symtab = m_interpreter.get_symbol_table (); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1372 |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1373 octave_value fcn; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1374 size_t p2; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1375 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1376 if (name[0] == '@') |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1377 { |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1378 size_t p1 = name.find (sys::file_ops::dir_sep_char (), 1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1379 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1380 if (p1 == std::string::npos) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1381 return nullptr; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1382 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1383 std::string dispatch_type = name.substr (1, p1-1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1384 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1385 p2 = name.find ('>', p1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1386 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1387 std::string method = name.substr (p1+1, p2-1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1388 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1389 fcn = symtab.find_method (method, dispatch_type); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1390 } |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1391 else |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1392 { |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1393 p2 = name.find ('>'); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1394 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1395 std::string main_fcn = name.substr (0, p2); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1396 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1397 fcn = symtab.find_function (main_fcn); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1398 } |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1399 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1400 // List of function names sub1>sub2>... |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1401 std::string subfuns; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1402 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1403 if (p2 != std::string::npos) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1404 subfuns = name.substr (p2+1); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1405 |
26179
a0b63c183d4b
Do not attempt to extract user code from oct-files (bug #55184).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26164
diff
changeset
|
1406 if (fcn.is_defined () && fcn.is_user_code ()) |
a0b63c183d4b
Do not attempt to extract user code from oct-files (bug #55184).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26164
diff
changeset
|
1407 user_code = fcn.user_code_value (); |
26065
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1408 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1409 if (! user_code || subfuns.empty ()) |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1410 return user_code; |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1411 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1412 fcn = user_code->find_subfunction (subfuns); |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1413 |
2eb71b83d3e2
partially refactor function lookup in symbol table
John W. Eaton <jwe@octave.org>
parents:
26039
diff
changeset
|
1414 user_code = fcn.user_code_value (); |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1415 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1416 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1417 return user_code; |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1418 } |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1419 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1420 void |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1421 tree_evaluator::visit_decl_command (tree_decl_command& cmd) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1422 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1423 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1424 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1425 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1426 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1427 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1428 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1429 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
1430 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1431 do_breakpoint (cmd.is_active_breakpoint (*this)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1432 |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1433 tree_decl_init_list *init_list = cmd.initializer_list (); |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1434 |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1435 if (init_list) |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1436 init_list->accept (*this); |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1437 } |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1438 |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1439 void |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1440 tree_evaluator::visit_decl_init_list (tree_decl_init_list& lst) |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1441 { |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1442 for (tree_decl_elt *elt : lst) |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1443 elt->accept (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1444 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1445 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1446 void |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1447 tree_evaluator::visit_decl_elt (tree_decl_elt& elt) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1448 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1449 tree_identifier *id = elt.ident (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1450 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1451 if (id) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1452 { |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1453 if (elt.is_global ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1454 m_call_stack.make_global (id->symbol ()); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1455 else if (elt.is_persistent ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1456 m_call_stack.make_persistent (id->symbol ()); |
23469
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1457 else |
2699c5974844
handle global and persistent in tree_decl_command, not as separate classes
John W. Eaton <jwe@octave.org>
parents:
23458
diff
changeset
|
1458 error ("declaration list element not global or persistent"); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1459 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
1460 octave_lvalue ult = id->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1461 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1462 if (ult.is_undefined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1463 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1464 tree_expression *expr = elt.expression (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1465 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1466 octave_value init_val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1467 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1468 if (expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1469 init_val = evaluate (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1470 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1471 init_val = Matrix (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1472 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1473 ult.assign (octave_value::op_asn_eq, init_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1474 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1475 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1476 } |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24690
diff
changeset
|
1477 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1478 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1479 tree_evaluator::visit_simple_for_command (tree_simple_for_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1480 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1481 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1482 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1483 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1484 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1485 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1486 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1487 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1488 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
1489 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1490 do_breakpoint (cmd.is_active_breakpoint (*this)); |
13245
027a2186cd90
parfor keyword and infrastructure, but handle parfor as normal for loop for now
John W. Eaton <jwe@octave.org>
parents:
13226
diff
changeset
|
1491 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1492 // FIXME: need to handle PARFOR loops here using cmd.in_parallel () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1493 // and cmd.maxproc_expr (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1494 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1495 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1496 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1497 frame.protect_var (m_in_loop_command); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1498 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1499 m_in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1500 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1501 tree_expression *expr = cmd.control_expr (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1502 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1503 octave_value rhs = evaluate (expr); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1504 |
21211
2cf8bc5c7017
use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
1505 #if defined (HAVE_LLVM) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1506 if (tree_jit::execute (cmd, rhs)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1507 return; |
15027
741d2dbcc117
Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents:
15023
diff
changeset
|
1508 #endif |
741d2dbcc117
Check trip count before compiling for loops.
Max Brister <max@2bass.com>
parents:
15023
diff
changeset
|
1509 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1510 if (rhs.is_undefined ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1511 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1512 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1513 tree_expression *lhs = cmd.left_hand_side (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1514 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
1515 octave_lvalue ult = lhs->lvalue (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1516 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1517 tree_statement_list *loop_body = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1518 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1519 if (rhs.is_range ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1520 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1521 Range rng = rhs.range_value (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1522 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1523 octave_idx_type steps = rng.numel (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1524 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1525 for (octave_idx_type i = 0; i < steps; i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1526 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1527 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1528 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1529 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1530 octave_value val (rng.elem (i)); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1531 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1532 ult.assign (octave_value::op_asn_eq, val); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1533 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1534 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1535 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1536 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1537 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1538 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1539 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1540 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1541 else if (rhs.is_scalar_type ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1542 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1543 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1544 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1545 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1546 ult.assign (octave_value::op_asn_eq, rhs); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1547 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1548 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1549 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1550 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1551 // Maybe decrement break and continue states. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1552 quit_loop_now (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1553 } |
23576
00e518162fda
maint: Deprecate is_cell and replace with iscell.
Rik <rik@octave.org>
parents:
23563
diff
changeset
|
1554 else if (rhs.is_matrix_type () || rhs.iscell () || rhs.is_string () |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1555 || rhs.isstruct ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1556 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1557 // A matrix or cell is reshaped to 2 dimensions and iterated by |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1558 // columns. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1559 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1560 dim_vector dv = rhs.dims ().redim (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1561 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1562 octave_idx_type nrows = dv(0); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1563 octave_idx_type steps = dv(1); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1564 |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1565 octave_value arg = rhs; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1566 if (rhs.ndims () > 2) |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1567 arg = arg.reshape (dv); |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1568 |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1569 if (nrows > 0 && steps > 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1570 { |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1571 octave_value_list idx; |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1572 octave_idx_type iidx; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1573 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1574 // for row vectors, use single index to speed things up. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1575 if (nrows == 1) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1576 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1577 idx.resize (1); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1578 iidx = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1579 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1580 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1581 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1582 idx.resize (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1583 idx(0) = octave_value::magic_colon_t; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1584 iidx = 1; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1585 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1586 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1587 for (octave_idx_type i = 1; i <= steps; i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1588 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1589 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1590 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1591 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1592 // do_index_op expects one-based indices. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1593 idx(iidx) = i; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1594 octave_value val = arg.do_index_op (idx); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1595 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1596 ult.assign (octave_value::op_asn_eq, val); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1597 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1598 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1599 loop_body->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1600 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1601 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1602 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1603 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1604 } |
23514
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1605 else |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1606 { |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1607 // Handle empty cases, while still assigning to loop var. |
fd7a16594614
Don't iterate over empty for loop expressions (bug #50893).
Rik <rik@octave.org>
parents:
23503
diff
changeset
|
1608 ult.assign (octave_value::op_asn_eq, arg); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1609 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1610 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1611 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1612 error ("invalid type in for loop expression near line %d, column %d", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1613 cmd.line (), cmd.column ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1614 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1615 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1616 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1617 tree_evaluator::visit_complex_for_command (tree_complex_for_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1618 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1619 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1620 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1621 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1622 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1623 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1624 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1625 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1626 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
1627 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
1628 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1629 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1630 unwind_protect frame; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1631 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1632 frame.protect_var (m_in_loop_command); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1633 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
1634 m_in_loop_command = true; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1635 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1636 tree_expression *expr = cmd.control_expr (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1637 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1638 octave_value rhs = evaluate (expr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1639 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1640 if (rhs.is_undefined ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1641 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1642 |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1643 if (! rhs.isstruct ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1644 error ("in statement 'for [X, Y] = VAL', VAL must be a structure"); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1645 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1646 // Cycle through structure elements. First element of id_list |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1647 // is set to value and the second is set to the name of the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1648 // structure element. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1649 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1650 tree_argument_list *lhs = cmd.left_hand_side (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1651 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
1652 auto p = lhs->begin (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1653 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1654 tree_expression *elt = *p++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1655 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
1656 octave_lvalue val_ref = elt->lvalue (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1657 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1658 elt = *p; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1659 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
1660 octave_lvalue key_ref = elt->lvalue (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1661 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1662 const octave_map tmp_val = rhs.map_value (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1663 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1664 tree_statement_list *loop_body = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1665 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1666 string_vector keys = tmp_val.keys (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1667 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1668 octave_idx_type nel = keys.numel (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1669 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1670 for (octave_idx_type i = 0; i < nel; i++) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1671 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1672 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1673 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
1674 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1675 std::string key = keys[i]; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1676 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1677 const Cell val_lst = tmp_val.contents (key); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1678 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1679 octave_idx_type n = val_lst.numel (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1680 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1681 octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1682 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1683 val_ref.assign (octave_value::op_asn_eq, val); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1684 key_ref.assign (octave_value::op_asn_eq, key); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1685 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1686 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1687 loop_body->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1688 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1689 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1690 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1691 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1692 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1693 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1694 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1695 tree_evaluator::visit_octave_user_script (octave_user_script&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1696 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1697 // ?? |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1698 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1699 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1700 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1701 octave_value_list |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1702 tree_evaluator::execute_user_script (octave_user_script& user_script, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1703 int nargout, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1704 const octave_value_list& args) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1705 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1706 octave_value_list retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1707 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1708 std::string file_name = user_script.fcn_file_name (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1709 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1710 if (args.length () != 0 || nargout != 0) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1711 error ("invalid call to script %s", file_name.c_str ()); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1712 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1713 tree_statement_list *cmd_list = user_script.body (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1714 |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
1715 if (! cmd_list) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1716 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1717 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1718 unwind_protect frame; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1719 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1720 if (m_call_stack.size () >= static_cast<size_t> (m_max_recursion_depth)) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1721 error ("max_recursion_depth exceeded"); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1722 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1723 m_call_stack.push (&user_script, &frame); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1724 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1725 // Set pointer to the current unwind_protect frame to allow |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1726 // certain builtins register simple cleanup in a very optimized manner. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1727 // This is *not* intended as a general-purpose on-cleanup mechanism, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1728 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1729 frame.add_method (m_call_stack, &call_stack::pop); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1730 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1731 // Update line number even if debugging. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1732 frame.protect_var (Vtrack_line_num); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1733 Vtrack_line_num = true; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1734 |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
1735 frame.protect_var (m_statement_context); |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
1736 m_statement_context = SC_SCRIPT; |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1737 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1738 profiler::enter<octave_user_script> block (m_profiler, user_script); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1739 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1740 if (echo ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1741 push_echo_state (frame, tree_evaluator::ECHO_SCRIPTS, file_name); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1742 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1743 cmd_list->accept (*this); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1744 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1745 if (m_returning) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1746 m_returning = 0; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1747 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1748 if (m_breaking) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1749 m_breaking--; |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1750 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1751 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1752 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1753 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1754 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1755 tree_evaluator::visit_octave_user_function (octave_user_function&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1756 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1757 // ?? |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1758 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1759 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1760 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1761 octave_value_list |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1762 tree_evaluator::execute_user_function (octave_user_function& user_function, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1763 int nargout, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1764 const octave_value_list& xargs) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1765 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1766 octave_value_list retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1767 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1768 tree_statement_list *cmd_list = user_function.body (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1769 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1770 if (! cmd_list) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1771 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1772 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1773 // If this function is a classdef constructor, extract the first input |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1774 // argument, which must be the partially constructed object instance. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1775 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1776 octave_value_list args (xargs); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1777 octave_value_list ret_args; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1778 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1779 if (user_function.is_classdef_constructor ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1780 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1781 if (args.length () > 0) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1782 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1783 ret_args = args.slice (0, 1, true); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1784 args = args.slice (1, args.length () - 1, true); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1785 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1786 else |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1787 panic_impossible (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1788 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1789 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1790 #if defined (HAVE_LLVM) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1791 if (user_function.is_special_expr () |
26004
94fecd437d9c
* pt-eval.cc: Fix call to JIT evaluate function.
John W. Eaton <jwe@octave.org>
parents:
25789
diff
changeset
|
1792 && tree_jit::execute (user_function, args, retval)) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1793 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1794 #endif |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1795 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1796 unwind_protect frame; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1797 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1798 if (m_call_stack.size () >= static_cast<size_t> (m_max_recursion_depth)) |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1799 error ("max_recursion_depth exceeded"); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1800 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1801 // Save old and set current symbol table context, for |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1802 // eval_undefined_error(). |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1803 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1804 m_call_stack.push (&user_function, &frame); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1805 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1806 frame.protect_var (Vtrack_line_num); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1807 // update source line numbers, even if debugging |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1808 Vtrack_line_num = true; |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1809 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1810 frame.add_method (m_call_stack, &call_stack::pop); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1811 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1812 bind_auto_fcn_vars (xargs.name_tags (), args.length (), |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
1813 nargout, user_function.takes_varargs (), |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
1814 user_function.all_va_args (args)); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1815 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1816 if (user_function.is_anonymous_function ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1817 init_local_fcn_vars (user_function); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1818 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1819 tree_parameter_list *param_list = user_function.parameter_list (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1820 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1821 if (param_list && ! param_list->varargs_only ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1822 define_parameter_list_from_arg_vector (param_list, args); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1823 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1824 // For classdef constructor, pre-populate the output arguments |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1825 // with the pre-initialized object instance, extracted above. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1826 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1827 tree_parameter_list *ret_list = user_function.return_list (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1828 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1829 if (user_function.is_classdef_constructor ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1830 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1831 if (! ret_list) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1832 error ("%s: invalid classdef constructor, no output argument defined", |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1833 user_function.dispatch_class ().c_str ()); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1834 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1835 define_parameter_list_from_arg_vector (ret_list, ret_args); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1836 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1837 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1838 // Force parameter list to be undefined when this function exits. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1839 // Doing so decrements the reference counts on the values of local |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1840 // variables that are also named function parameters. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1841 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1842 // if (param_list) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1843 // frame.add_method (this, &tree_evaluator::undefine_parameter_list, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1844 // param_list); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1845 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1846 // Force return list to be undefined when this function exits. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1847 // Doing so decrements the reference counts on the values of local |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1848 // variables that are also named values returned by this function. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1849 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1850 // if (ret_list) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1851 // frame.add_method (this, &tree_evaluator::undefine_parameter_list, |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1852 // ret_list); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1853 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1854 frame.add_method (&user_function, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1855 &octave_user_function::restore_warning_states); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1856 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1857 // Evaluate the commands that make up the function. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1858 |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
1859 frame.protect_var (m_statement_context); |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
1860 m_statement_context = SC_FUNCTION; |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1861 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1862 frame.add_method (m_call_stack, &call_stack::clear_current_frame_values); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1863 |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1864 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1865 profiler::enter<octave_user_function> block (m_profiler, user_function); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1866 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1867 if (echo ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1868 push_echo_state (frame, tree_evaluator::ECHO_FUNCTIONS, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1869 user_function.fcn_file_name ()); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1870 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1871 if (user_function.is_special_expr ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1872 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1873 assert (cmd_list->length () == 1); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1874 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1875 tree_statement *stmt = cmd_list->front (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1876 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1877 tree_expression *expr = stmt->expression (); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1878 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1879 if (expr) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1880 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1881 m_call_stack.set_location (stmt->line (), stmt->column ()); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1882 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1883 retval = evaluate_n (expr, nargout); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1884 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1885 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1886 else |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1887 cmd_list->accept (*this); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1888 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1889 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1890 if (m_returning) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1891 m_returning = 0; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1892 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1893 if (m_breaking) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
1894 m_breaking--; |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1895 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1896 // Copy return values out. |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1897 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1898 if (ret_list && ! user_function.is_special_expr ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1899 { |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1900 Cell varargout; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1901 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1902 if (ret_list->takes_varargs ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1903 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1904 octave_value varargout_varval = varval ("varargout"); |
25400
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1905 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1906 if (varargout_varval.is_defined ()) |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1907 varargout = varargout_varval.xcell_value ("varargout must be a cell array object"); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1908 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1909 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1910 retval = convert_return_list_to_const_vector (ret_list, nargout, |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1911 varargout); |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1912 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1913 |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1914 return retval; |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1915 } |
d423ce60f5c8
evaluate script and function code in tree_evaluator methods
John W. Eaton <jwe@octave.org>
parents:
25399
diff
changeset
|
1916 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1917 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1918 tree_evaluator::visit_octave_user_function_header (octave_user_function&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1919 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1920 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1921 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1922 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1923 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1924 tree_evaluator::visit_octave_user_function_trailer (octave_user_function&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1925 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1926 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1927 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1928 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1929 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1930 tree_evaluator::visit_function_def (tree_function_def& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1931 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1932 octave_value fcn = cmd.function (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1933 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1934 octave_function *f = fcn.function_value (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1935 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1936 if (f) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1937 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1938 std::string nm = f->name (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1939 |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1940 symbol_table& symtab = m_interpreter.get_symbol_table (); |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1941 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23587
diff
changeset
|
1942 symtab.install_cmdline_function (nm, fcn); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1943 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1944 // Make sure that any variable with the same name as the new |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1945 // function is cleared. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1946 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1947 assign (nm); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1948 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1949 } |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
1950 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1951 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1952 tree_evaluator::visit_identifier (tree_identifier& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
1953 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1954 octave_value_list retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1955 |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
24075
diff
changeset
|
1956 symbol_record sym = expr.symbol (); |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
1957 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1958 octave_value val = varval (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1959 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1960 if (val.is_undefined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1961 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1962 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1963 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1964 val = symtab.find_function (sym.name ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
1965 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1966 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1967 if (val.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1968 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1969 // GAGME -- this would be cleaner if we required |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1970 // parens to indicate function calls. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1971 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1972 // If this identifier refers to a function, we need to know |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1973 // whether it is indexed so that we can do the same thing |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1974 // for 'f' and 'f()'. If the index is present and the function |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1975 // object declares it can handle it, return the function object |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1976 // and let tree_index_expression::rvalue handle indexing. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1977 // Otherwise, arrange to call the function here, so that we don't |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1978 // return the function definition as a value. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1979 |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
1980 octave_function *fcn = nullptr; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1981 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1982 if (val.is_function ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1983 fcn = val.function_value (true); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1984 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1985 int nargout = m_nargout_stack.top (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1986 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1987 if (fcn && ! (expr.is_postfix_indexed () |
23503
6a2fed2d39ac
improve some function names
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
1988 && fcn->accepts_postfix_index (expr.postfix_index ()))) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1989 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23523
diff
changeset
|
1990 retval = fcn->call (*this, nargout); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1991 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1992 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1993 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1994 if (expr.print_result () && nargout == 0 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
1995 && statement_printing_enabled ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1996 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1997 octave_value_list args = ovl (val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
1998 args.stash_name_tags (string_vector (expr.name ())); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1999 feval ("display", args); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2000 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2001 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2002 push_result (val); |
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2003 return; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2004 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2005 } |
24037
21915520ac7b
use more direct method for non-local symbol access (bug #38236)
John W. Eaton <jwe@octave.org>
parents:
23916
diff
changeset
|
2006 else if (sym.is_added_static ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2007 expr.static_workspace_error (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2008 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2009 expr.eval_undefined_error (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2010 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2011 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2012 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2013 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2014 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2015 tree_evaluator::visit_if_clause (tree_if_clause&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2016 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2017 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2018 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2019 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2020 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2021 tree_evaluator::visit_if_command (tree_if_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2022 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2023 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2024 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2025 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2026 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2027 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2028 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2029 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2030 tree_if_command_list *lst = cmd.cmd_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2031 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2032 if (lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2033 lst->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2034 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2035 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2036 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2037 tree_evaluator::visit_if_command_list (tree_if_command_list& lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2038 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
2039 for (tree_if_clause *tic : lst) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2040 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2041 tree_expression *expr = tic->condition (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2042 |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
2043 if (m_statement_context == SC_FUNCTION |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
2044 || m_statement_context == SC_SCRIPT) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2045 m_call_stack.set_location (tic->line (), tic->column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2046 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
2047 if (m_debug_mode && ! tic->is_else_clause ()) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
2048 do_breakpoint (tic->is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2049 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2050 if (tic->is_else_clause () || is_logically_true (expr, "if")) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2051 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2052 tree_statement_list *stmt_lst = tic->commands (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2053 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2054 if (stmt_lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2055 stmt_lst->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2056 |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
2057 break; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2058 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2059 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2060 } |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24690
diff
changeset
|
2061 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2062 // Unlike Matlab, which does not allow the result of a function call |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2063 // or array indexing expression to be further indexed, Octave attempts |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2064 // to handle arbitrary index expressions. For example, Octave allows |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2065 // expressions like |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2066 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2067 // svd (rand (10))(1:5) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2068 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2069 // Although octave_value objects may contain function objects, no |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2070 // indexing operation or function call is supposed to return them |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2071 // directly. Instead, the language is supposed to only allow function |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2072 // objects to be stored as function handles (named or anonymous) or as |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2073 // inline functions. The only place a function object should appear |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2074 // directly is if the symbol stored in a tree_identifier object |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2075 // resolves to a function. This means that the only place we need to |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2076 // look for functions is in the first element of the index |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2077 // expression. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2078 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2079 // Steps: |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2080 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2081 // * Obtain the initial value from the expression component of the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2082 // tree_index_expression object. If it is a tree_identifier object |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2083 // indexed by '(args)' and the identifier is not a variable, then |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2084 // peform a function call. Use the (optional) arguments to perform |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2085 // the function lookup so we choose the correct function or class |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2086 // method to call. Otherwise, evaluate the first expression |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2087 // without any additional arguments. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2088 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2089 // * Iterate over the remaining elements of the index expression and |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2090 // call the octave_value::subsref method. If indexing a class or |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2091 // classdef object, build up a list of indices for a call to the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2092 // subsref method for the object. Otherwise, use the result of |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2093 // each temporary evaluation for the next index element. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2094 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2095 // * If not indexing a class or classdef object and any partial |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2096 // expression evaluation produces a class or classdef object, then |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2097 // build up a complete argument list from that point on for a final |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2098 // subsref call for that object. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2099 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2100 // Multiple partial evaluations may be required. For example, |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2101 // given a class or classdef object X, then for the expression |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2102 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2103 // x.a{end}(2:end).b |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2104 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2105 // we must evaluate x.a to obtain the size for the first {end} |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2106 // expression, then we must evaluate x.a{end} to obtain the size |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2107 // for the second (2:end) expression. Finally, the complete |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2108 // expression may be evaluated. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2109 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2110 // If X is a cell array in the above expression, and none of the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2111 // intermediate evaluations produces a class or classdef object, |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2112 // then the evaluation is performed as the following series of |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2113 // steps |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2114 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2115 // tmp = x.a |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2116 // tmp = tmp{end} |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2117 // tmp = tmp(2:end) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2118 // result = tmp.b |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2119 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2120 // If any of the partial evaluations produces a class or classdef |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2121 // object, then the subsref method for that object is called as |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2122 // described above. For example, suppose x.a produces a classdef |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2123 // object. Then the evaluation is performed as the following |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2124 // series of steps |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2125 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2126 // base_expr = tmp = x.a |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2127 // tmp = base_expr{end} |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2128 // base_expr{end}(2:end).b |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2129 // |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2130 // In the last two steps, the partial value computed in the |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2131 // previous step is used to determine the value of END. |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2132 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2133 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2134 tree_evaluator::visit_index_expression (tree_index_expression& idx_expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2135 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2136 octave_value_list retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2137 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2138 int nargout = m_nargout_stack.top (); |
23458
0f4ed33886de
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
23457
diff
changeset
|
2139 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2140 std::string type = idx_expr.type_tags (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2141 std::list<tree_argument_list *> args = idx_expr.arg_lists (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2142 std::list<string_vector> arg_nm = idx_expr.arg_names (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2143 std::list<tree_expression *> dyn_field = idx_expr.dyn_fields (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2144 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2145 assert (! args.empty ()); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2146 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
2147 auto p_args = args.begin (); |
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
2148 auto p_arg_nm = arg_nm.begin (); |
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
2149 auto p_dyn_field = dyn_field.begin (); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2150 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2151 int n = args.size (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2152 int beg = 0; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2153 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2154 octave_value base_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2155 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2156 tree_expression *expr = idx_expr.expression (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2157 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2158 if (expr->is_identifier () && type[beg] == '(') |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2159 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2160 tree_identifier *id = dynamic_cast<tree_identifier *> (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2161 |
26662
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2162 bool is_var = is_variable (expr); |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2163 |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2164 std::string nm = id->name (); |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2165 |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2166 if (is_var && idx_expr.is_word_list_cmd ()) |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2167 error ("%s used as variable and later as function", nm.c_str ()); |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2168 |
05fc703b419a
update handling of command-style function call syntax in eval
John W. Eaton <jwe@octave.org>
parents:
26661
diff
changeset
|
2169 if (! is_var) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2170 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2171 octave_value_list first_args; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2172 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2173 tree_argument_list *al = *p_args; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2174 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2175 if (al && al->length () > 0) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2176 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2177 // Function calls inside an argument list can't have |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2178 // ignored output arguments. |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2179 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2180 unwind_protect frame; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2181 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
2182 m_lvalue_list_stack.push (nullptr); |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2183 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2184 frame.add_method (m_lvalue_list_stack, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2185 &value_stack<const std::list<octave_lvalue>*>::pop); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2186 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2187 string_vector anm = *p_arg_nm; |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2188 first_args = convert_to_const_vector (al); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2189 first_args.stash_name_tags (anm); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2190 } |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2191 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2192 symbol_record sym = id->symbol (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2193 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2194 octave_value val = varval (sym); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2195 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2196 if (val.is_undefined ()) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2197 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2198 symbol_table& symtab = m_interpreter.get_symbol_table (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2199 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2200 val = symtab.find_function (sym.name (), first_args); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2201 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2202 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2203 octave_function *fcn = nullptr; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2204 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2205 if (val.is_function ()) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2206 fcn = val.function_value (true); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2207 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2208 if (fcn) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2209 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2210 try |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2211 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23523
diff
changeset
|
2212 retval = fcn->call (*this, nargout, first_args); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2213 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2214 catch (index_exception& e) |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2215 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2216 final_index_error (e, expr); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2217 } |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2218 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2219 beg++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2220 p_args++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2221 p_arg_nm++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2222 p_dyn_field++; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2223 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2224 if (n > beg) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2225 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2226 // More indices to follow. Silently ignore |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2227 // extra output values. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2228 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2229 if (retval.length () == 0) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2230 error ("indexing undefined value"); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2231 else |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2232 base_expr_val = retval(0); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2233 } |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2234 else |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2235 { |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2236 // No more indices, so we are done. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2237 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2238 push_result (retval); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2239 return; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2240 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2241 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2242 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2243 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2244 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2245 if (base_expr_val.is_undefined ()) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2246 base_expr_val = evaluate (expr); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2247 |
23781
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2248 // If we are indexing an object or looking at something like |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2249 // |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2250 // classname.static_function (args, ...); |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2251 // |
23844
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
2252 // then we'll just build a complete index list for one big subsref |
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
2253 // call. If the expression we are indexing is a classname then |
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
2254 // base_expr_val will be an octave_classdef_meta object. If we have |
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
2255 // files in a +packagename folder, they will also be an |
23838
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
2256 // octave_classdef_meta object, but we don't want to index them. |
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
2257 |
23844
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
2258 bool indexing_object = (base_expr_val.isobject () |
23838
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
2259 || base_expr_val.isjava () |
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
2260 || (base_expr_val.is_classdef_meta () |
6e0fd7e3c262
Fix argument lookup in '+' package functions (Bug #51532).
Piotr Held <pjheld@gmail.com>
parents:
23795
diff
changeset
|
2261 && ! base_expr_val.is_package ())); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2262 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2263 std::list<octave_value_list> idx; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2264 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2265 octave_value partial_expr_val = base_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2266 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2267 for (int i = beg; i < n; i++) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2268 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2269 if (i > beg) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2270 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2271 tree_argument_list *al = *p_args; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2272 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2273 if (! indexing_object || (al && al->has_magic_end ())) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2274 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2275 // Evaluate what we have so far to find the value to |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2276 // pass to the END function. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2277 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2278 try |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2279 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2280 // Silently ignore extra output values. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2281 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2282 octave_value_list tmp_list |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2283 = base_expr_val.subsref (type.substr (beg, i-beg), |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2284 idx, nargout); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2285 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2286 partial_expr_val |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2287 = tmp_list.length () ? tmp_list(0) : octave_value (); |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2288 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2289 if (! indexing_object) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2290 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2291 base_expr_val = partial_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2292 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2293 if (partial_expr_val.is_cs_list ()) |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2294 err_indexed_cs_list (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2295 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2296 retval = partial_expr_val; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2297 |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2298 beg = i; |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2299 idx.clear (); |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2300 |
23781
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2301 if (partial_expr_val.isobject () |
24075
3645139bd28f
allow meta.class.fromName to work again (bug #51935)
Piotr Held <pjheld@gmail.com>
parents:
24037
diff
changeset
|
2302 || partial_expr_val.isjava () |
3645139bd28f
allow meta.class.fromName to work again (bug #51935)
Piotr Held <pjheld@gmail.com>
parents:
24037
diff
changeset
|
2303 || (partial_expr_val.is_classdef_meta () |
3645139bd28f
allow meta.class.fromName to work again (bug #51935)
Piotr Held <pjheld@gmail.com>
parents:
24037
diff
changeset
|
2304 && ! partial_expr_val.is_package ())) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2305 { |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2306 // Found an object, so now we'll build up |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2307 // complete index list for one big subsref |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2308 // call from this point on. |
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2309 |
23781
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2310 // FIXME: is is also possible to have a |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2311 // static method call buried somewhere in |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2312 // the depths of a complex indexing |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2313 // expression so that we would also need to |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2314 // check for an octave_classdef_meta object |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2315 // here? |
d891b6a16a4d
* pt-eval.cc: Expand on comment introduced in previous change.
John W. Eaton <jwe@octave.org>
parents:
23780
diff
changeset
|
2316 |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2317 indexing_object = true; |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2318 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2319 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2320 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2321 catch (index_exception& e) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2322 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2323 final_index_error (e, expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2324 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2325 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2326 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2327 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2328 switch (type[i]) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2329 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2330 case '(': |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2331 idx.push_back (make_value_list (*p_args, *p_arg_nm, &partial_expr_val)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2332 break; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2333 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2334 case '{': |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2335 idx.push_back (make_value_list (*p_args, *p_arg_nm, &partial_expr_val)); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2336 break; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2337 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2338 case '.': |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2339 idx.push_back (octave_value |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2340 (idx_expr.get_struct_index (*this, p_arg_nm, p_dyn_field))); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2341 break; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2342 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2343 default: |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2344 panic_impossible (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2345 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2346 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2347 p_args++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2348 p_arg_nm++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2349 p_dyn_field++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2350 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2351 |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2352 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2353 // If ! idx.empty () that means we still have stuff to index otherwise |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2354 // they would have been dealt with and idx would have been emptied. |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2355 if (! idx.empty ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2356 { |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2357 // This is for +package and other classdef_meta objects |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2358 if (! base_expr_val.is_function () |
23844
ca4535a6ee9f
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
23843
diff
changeset
|
2359 || base_expr_val.is_classdef_meta ()) |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2360 { |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2361 try |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2362 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2363 retval = base_expr_val.subsref (type.substr (beg, n-beg), |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2364 idx, nargout); |
23871
5352f632859b
Fix (once more) pkg.fcn with no arguments (bug #51715).
Piotr Held <pjheld@gmail.com>
parents:
23865
diff
changeset
|
2365 beg = n; |
5352f632859b
Fix (once more) pkg.fcn with no arguments (bug #51715).
Piotr Held <pjheld@gmail.com>
parents:
23865
diff
changeset
|
2366 idx.clear (); |
23876
b6e756d8f485
maint: eliminate TAB characters from source files
John W. Eaton <jwe@octave.org>
parents:
23872
diff
changeset
|
2367 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
2368 catch (index_exception& e) |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2369 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2370 final_index_error (e, expr); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2371 } |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2372 } |
23872
9b39ec2e0952
revert unintended change to pt-eval.cc made in d56c18dc1373
John W. Eaton <jwe@octave.org>
parents:
23871
diff
changeset
|
2373 else |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2374 { |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2375 // FIXME: we want this to only be a superclass constructor |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2376 // call Should we actually make a check for this or are all |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2377 // other types of calls already dealt with? |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2378 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2379 octave_function *fcn = base_expr_val.function_value (); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2380 |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2381 if (fcn) |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2382 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2383 try |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2384 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2385 retval = fcn->call (*this, nargout, idx); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2386 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
2387 catch (index_exception& e) |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2388 { |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2389 final_index_error (e, expr); |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2390 } |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2391 } |
23521
551fa3879615
improve compatibility and simplify evaluation of index expressions
John W. Eaton <jwe@octave.org>
parents:
23514
diff
changeset
|
2392 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2393 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2394 |
23842
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2395 // FIXME: when can the following happen? In what case does indexing |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2396 // result in a value that is a function? Classdef method calls? |
ff893e26aeeb
make calling parent class constructors work again (bug #51534)
Piotr Held <pjheld@gmail.com>
parents:
23838
diff
changeset
|
2397 // Something else? |
23683
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2398 |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2399 octave_value val = (retval.length () ? retval(0) : octave_value ()); |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2400 |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2401 if (val.is_function ()) |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2402 { |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2403 octave_function *fcn = val.function_value (true); |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2404 |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2405 if (fcn) |
23684
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2406 { |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2407 octave_value_list final_args; |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2408 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2409 if (! idx.empty ()) |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2410 { |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2411 if (n - beg != 1) |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2412 error ("unexpected extra index at end of expression"); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2413 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2414 if (type[beg] != '(') |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2415 error ("invalid index type '%c' for function call", |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2416 type[beg]); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2417 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2418 final_args = idx.front (); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2419 } |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2420 |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2421 retval = fcn->call (*this, nargout, final_args); |
c84328c2a6c7
handle remaining args (if any) in index expression (bug #51295)
John W. Eaton <jwe@octave.org>
parents:
23683
diff
changeset
|
2422 } |
23683
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2423 } |
ffd27f53fc79
make +package function calls work again (bug #51295, #51296)
John W. Eaton <jwe@octave.org>
parents:
23671
diff
changeset
|
2424 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2425 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2426 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2427 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2428 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2429 tree_evaluator::visit_matrix (tree_matrix& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2430 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2431 tm_const tmp (expr, *this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2432 |
25393
b860a7e526cf
refactor evaluation of tree_matrix object
John W. Eaton <jwe@octave.org>
parents:
25383
diff
changeset
|
2433 push_result (tmp.concat (m_string_fill_char)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2434 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2435 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2436 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2437 tree_evaluator::visit_cell (tree_cell& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2438 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2439 octave_value retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2440 |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2441 // Function calls inside an argument list can't have ignored |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2442 // output arguments. |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2443 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2444 unwind_protect frame; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2445 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
2446 m_lvalue_list_stack.push (nullptr); |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2447 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2448 frame.add_method (m_lvalue_list_stack, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2449 &value_stack<const std::list<octave_lvalue>*>::pop); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
2450 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2451 octave_idx_type nr = expr.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2452 octave_idx_type nc = -1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2453 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2454 Cell val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2455 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2456 octave_idx_type i = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2457 |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
2458 for (tree_argument_list *elt : expr) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2459 { |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
2460 octave_value_list row = convert_to_const_vector (elt); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2461 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2462 if (nr == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2463 // Optimize the single row case. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2464 val = row.cell_value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2465 else if (nc < 0) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2466 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2467 nc = row.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2468 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2469 val = Cell (nr, nc); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2470 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2471 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2472 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2473 octave_idx_type this_nc = row.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2474 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2475 if (this_nc != nc) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2476 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2477 if (this_nc == 0) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2478 continue; // blank line |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2479 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2480 error ("number of columns must match"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2481 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2482 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2483 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2484 for (octave_idx_type j = 0; j < nc; j++) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2485 val(i,j) = row(j); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2486 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2487 i++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2488 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2489 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2490 if (i < nr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2491 val.resize (dim_vector (i, nc)); // there were blank rows |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2492 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2493 retval = val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2494 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2495 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2496 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2497 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2498 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2499 tree_evaluator::visit_multi_assignment (tree_multi_assignment& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2500 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2501 octave_value_list val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2502 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2503 tree_expression *rhs = expr.right_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2504 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2505 if (rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2506 { |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2507 unwind_protect frame; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2508 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2509 tree_argument_list *lhs = expr.left_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2510 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2511 std::list<octave_lvalue> lvalue_list = make_lvalue_list (lhs); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2512 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2513 m_lvalue_list_stack.push (&lvalue_list); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2514 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2515 frame.add_method (m_lvalue_list_stack, |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2516 &value_stack<const std::list<octave_lvalue>*>::pop); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2517 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2518 octave_idx_type n_out = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2519 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2520 for (const auto& lval : lvalue_list) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2521 n_out += lval.numel (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2522 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2523 // The following trick is used to keep rhs_val constant. |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2524 const octave_value_list rhs_val1 = evaluate_n (rhs, n_out); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2525 const octave_value_list rhs_val = (rhs_val1.length () == 1 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2526 && rhs_val1(0).is_cs_list () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2527 ? rhs_val1(0).list_value () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2528 : rhs_val1); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2529 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2530 octave_idx_type k = 0; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2531 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2532 octave_idx_type n = rhs_val.length (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2533 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2534 // To avoid copying per elements and possible optimizations, we |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2535 // postpone joining the final values. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2536 std::list<octave_value_list> retval_list; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2537 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
2538 auto q = lhs->begin (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2539 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2540 for (octave_lvalue ult : lvalue_list) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2541 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2542 tree_expression *lhs_elt = *q++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2543 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2544 octave_idx_type nel = ult.numel (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2545 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2546 if (nel != 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2547 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2548 // Huge kluge so that wrapper scripts with lines like |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2549 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2550 // [varargout{1:nargout}] = fcn (args); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2551 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2552 // Will work the same as calling fcn directly when nargout |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2553 // is 0 and fcn produces more than one output even when |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2554 // nargout is 0. This only works if varargout has not yet |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2555 // been defined. See also bug #43813. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2556 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2557 if (lvalue_list.size () == 1 && nel == 0 && n > 0 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2558 && ! ult.is_black_hole () && ult.is_undefined () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2559 && ult.index_type () == "{" && ult.index_is_empty ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2560 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2561 // Convert undefined lvalue with empty index to a cell |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2562 // array with a single value and indexed by 1 to |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2563 // handle a single output. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2564 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2565 nel = 1; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2566 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2567 ult.define (Cell (1, 1)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2568 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2569 ult.clear_index (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2570 std::list<octave_value_list> idx; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2571 idx.push_back (octave_value_list (octave_value (1))); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2572 ult.set_index ("{", idx); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2573 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2574 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2575 if (k + nel > n) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2576 error ("some elements undefined in return list"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2577 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2578 // This element of the return list expects a |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2579 // comma-separated list of values. Slicing avoids |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2580 // copying. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2581 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2582 octave_value_list ovl = rhs_val.slice (k, nel); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2583 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2584 ult.assign (octave_value::op_asn_eq, octave_value (ovl)); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2585 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2586 retval_list.push_back (ovl); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2587 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2588 k += nel; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2589 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2590 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2591 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2592 if (k < n) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2593 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2594 if (ult.is_black_hole ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2595 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2596 k++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2597 continue; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2598 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2599 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2600 { |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2601 octave_value tmp = rhs_val(k); |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2602 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2603 if (tmp.is_undefined ()) |
26164
7f6a50f73625
Silence compiler warnings about format identifier for octave_idx_type (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26149
diff
changeset
|
2604 error ("element number %" OCTAVE_IDX_TYPE_FORMAT |
7f6a50f73625
Silence compiler warnings about format identifier for octave_idx_type (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26149
diff
changeset
|
2605 " undefined in return list", k+1); |
23916
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2606 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2607 ult.assign (octave_value::op_asn_eq, tmp); |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2608 |
85488effc0ff
refactor function value return code
John W. Eaton <jwe@octave.org>
parents:
23913
diff
changeset
|
2609 retval_list.push_back (tmp); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2610 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2611 k++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2612 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2613 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2614 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2615 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2616 // This can happen for a function like |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2617 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2618 // function varargout = f () |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2619 // varargout{1} = nargout; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2620 // endfunction |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2621 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2622 // called with |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2623 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2624 // [a, ~] = f (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2625 // |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2626 // Then the list of of RHS values will contain one |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2627 // element but we are iterating over the list of all |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2628 // RHS values. We shouldn't complain that a value we |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2629 // don't need is missing from the list. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2630 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2631 if (! ult.is_black_hole ()) |
26164
7f6a50f73625
Silence compiler warnings about format identifier for octave_idx_type (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26149
diff
changeset
|
2632 error ("element number %" OCTAVE_IDX_TYPE_FORMAT |
7f6a50f73625
Silence compiler warnings about format identifier for octave_idx_type (bug #55046).
Markus Mützel <markus.muetzel@gmx.de>
parents:
26149
diff
changeset
|
2633 " undefined in return list", k+1); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2634 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2635 k++; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2636 continue; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2637 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2638 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2639 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2640 if (expr.print_result () && statement_printing_enabled ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2641 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2642 // We clear any index here so that we can get |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2643 // the new value of the referenced object below, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2644 // instead of the indexed value (which should be |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2645 // the same as the right hand side value). |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2646 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2647 ult.clear_index (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2648 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2649 octave_value lhs_val = ult.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2650 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2651 octave_value_list args = ovl (lhs_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2652 args.stash_name_tags (string_vector (lhs_elt->name ())); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2653 feval ("display", args); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2654 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2655 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2656 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2657 // Concatenate return values. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2658 val = retval_list; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2659 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2660 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2661 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2662 } |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
2663 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2664 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2665 tree_evaluator::visit_no_op_command (tree_no_op_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2666 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2667 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2668 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2669 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2670 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2671 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2672 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2673 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
2674 if (m_debug_mode && cmd.is_end_of_fcn_or_script ()) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
2675 do_breakpoint (cmd.is_active_breakpoint (*this), true); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2676 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2677 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2678 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2679 tree_evaluator::visit_constant (tree_constant& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2680 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2681 int nargout = m_nargout_stack.top (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2682 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2683 if (nargout > 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2684 error ("invalid number of output arguments for constant expression"); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2685 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2686 push_result (expr.value ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2687 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2688 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2689 void |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2690 tree_evaluator::visit_fcn_handle (tree_fcn_handle& expr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2691 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2692 std::string nm = expr.name (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2693 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2694 octave_value fh = make_fcn_handle (nm); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2695 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2696 push_result (fh); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2697 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2698 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2699 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2700 tree_evaluator::visit_funcall (tree_funcall& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2701 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2702 octave_value_list retval; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2703 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2704 octave_value fcn = expr.function (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2705 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2706 octave_value_list args = expr.arguments (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2707 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2708 int nargout = m_nargout_stack.top (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2709 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2710 retval = feval (fcn.function_value (), args, nargout); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2711 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2712 if (retval.length () == 1 && retval(0).is_function ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2713 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2714 // The return object is a function. We may need to re-index it |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2715 // using the same logic as for identifier. This is primarily |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2716 // used for superclass references in classdef. |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2717 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2718 octave_value val = retval(0); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2719 octave_function *f = val.function_value (true); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2720 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2721 if (f && ! (expr.is_postfix_indexed () |
23503
6a2fed2d39ac
improve some function names
John W. Eaton <jwe@octave.org>
parents:
23502
diff
changeset
|
2722 && f->accepts_postfix_index (expr.postfix_index ()))) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2723 { |
23532
084245f9bd03
pass reference to evaluator to octave_function call methods
John W. Eaton <jwe@octave.org>
parents:
23523
diff
changeset
|
2724 retval = f->call (*this, nargout); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2725 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2726 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2727 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2728 push_result (retval); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2729 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2730 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2731 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2732 tree_evaluator::visit_parameter_list (tree_parameter_list&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2733 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2734 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2735 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2736 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2737 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2738 tree_evaluator::visit_postfix_expression (tree_postfix_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2739 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2740 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2741 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2742 tree_expression *op = expr.operand (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2743 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2744 if (op) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2745 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2746 octave_value::unary_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2747 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2748 if (etype == octave_value::op_incr || etype == octave_value::op_decr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2749 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2750 octave_lvalue ref = op->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2751 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2752 val = ref.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2753 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2754 profiler::enter<tree_postfix_expression> block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2755 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2756 ref.do_unary_op (etype); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2757 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2758 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2759 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2760 octave_value op_val = evaluate (op); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2761 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2762 if (op_val.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2763 { |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2764 profiler::enter<tree_postfix_expression> |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2765 block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2766 |
24565
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2767 type_info& ti = m_interpreter.get_type_info (); |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2768 |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2769 val = ::do_unary_op (ti, etype, op_val); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2770 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2771 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2772 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2773 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2774 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2775 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2776 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2777 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2778 tree_evaluator::visit_prefix_expression (tree_prefix_expression& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2779 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2780 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2781 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2782 tree_expression *op = expr.operand (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2783 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2784 if (op) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2785 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2786 octave_value::unary_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2787 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2788 if (etype == octave_value::op_incr || etype == octave_value::op_decr) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2789 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2790 octave_lvalue op_ref = op->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2791 |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2792 profiler::enter<tree_prefix_expression> block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2793 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2794 op_ref.do_unary_op (etype); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2795 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2796 val = op_ref.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2797 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2798 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2799 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2800 octave_value op_val = evaluate (op); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2801 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2802 if (op_val.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2803 { |
23753
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2804 profiler::enter<tree_prefix_expression> |
c3828bd031cd
move profiler inside evaluator and inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23729
diff
changeset
|
2805 block (m_profiler, expr); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2806 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2807 // Attempt to do the operation in-place if it is unshared |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2808 // (a temporary expression). |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2809 if (op_val.get_count () == 1) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2810 val = op_val.do_non_const_unary_op (etype); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2811 else |
24565
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2812 { |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2813 type_info& ti = m_interpreter.get_type_info (); |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2814 |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2815 val = ::do_unary_op (ti, etype, op_val); |
dbec1e04f499
accept type_info obj as arg to binary_op, unary_op, and cat_op functions
John W. Eaton <jwe@octave.org>
parents:
24564
diff
changeset
|
2816 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2817 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2818 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2819 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2820 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2821 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2822 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2823 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2824 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2825 tree_evaluator::visit_return_command (tree_return_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2826 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2827 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2828 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2829 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2830 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2831 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2832 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2833 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
2834 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
2835 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2836 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2837 // Act like dbcont. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2838 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
2839 if (Vdebugging && m_call_stack.current_frame () == m_current_frame) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2840 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2841 Vdebugging = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2842 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2843 reset_debug_state (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2844 } |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
2845 else if (m_statement_context == SC_FUNCTION |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
2846 || m_statement_context == SC_SCRIPT |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
2847 || m_in_loop_command) |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
2848 m_returning = 1; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2849 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2850 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2851 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2852 tree_evaluator::visit_return_list (tree_return_list&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2853 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2854 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2855 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2856 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2857 void |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2858 tree_evaluator::visit_simple_assignment (tree_simple_assignment& expr) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2859 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2860 octave_value val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2861 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2862 tree_expression *rhs = expr.right_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2863 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2864 if (rhs) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2865 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2866 tree_expression *lhs = expr.left_hand_side (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2867 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2868 try |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2869 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2870 unwind_protect frame; |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2871 |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
2872 octave_lvalue ult = lhs->lvalue (*this); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2873 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2874 std::list<octave_lvalue> lvalue_list; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2875 lvalue_list.push_back (ult); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2876 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2877 m_lvalue_list_stack.push (&lvalue_list); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2878 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2879 frame.add_method (m_lvalue_list_stack, |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2880 &value_stack<const std::list<octave_lvalue>*>::pop); |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
2881 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2882 if (ult.numel () != 1) |
24690
2ce26c4cb323
More descriptive error message for assignment to empty structure (bug #36003).
Joe Winegarden <joewino19@gmail.com>
parents:
24583
diff
changeset
|
2883 err_invalid_structure_assignment (); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2884 |
25789
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2885 octave_value rhs_val = evaluate (rhs); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2886 |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2887 if (rhs_val.is_undefined ()) |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2888 error ("value on right hand side of assignment is undefined"); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2889 |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2890 if (rhs_val.is_cs_list ()) |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2891 { |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2892 const octave_value_list lst = rhs_val.list_value (); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2893 |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2894 if (lst.empty ()) |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2895 error ("invalid number of elements on RHS of assignment"); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2896 |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2897 rhs_val = lst(0); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2898 } |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
25722
diff
changeset
|
2899 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2900 octave_value::assign_op etype = expr.op_type (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2901 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2902 ult.assign (etype, rhs_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2903 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2904 if (etype == octave_value::op_asn_eq) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2905 val = rhs_val; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2906 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2907 val = ult.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2908 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
2909 if (expr.print_result () && statement_printing_enabled ()) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2910 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2911 // We clear any index here so that we can |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2912 // get the new value of the referenced |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2913 // object below, instead of the indexed |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2914 // value (which should be the same as the |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2915 // right hand side value). |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2916 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2917 ult.clear_index (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2918 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2919 octave_value lhs_val = ult.value (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2920 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2921 octave_value_list args = ovl (lhs_val); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2922 args.stash_name_tags (string_vector (lhs->name ())); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2923 feval ("display", args); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2924 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2925 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
2926 catch (index_exception& e) |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2927 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2928 e.set_var (lhs->name ()); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2929 std::string msg = e.message (); |
26149
242aa7b2c783
Silence unnecessary warnings about security-format (bug #55046).
Rik <rik@octave.org>
parents:
26113
diff
changeset
|
2930 error_with_id (e.err_id (), "%s", msg.c_str ()); |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2931 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2932 } |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2933 |
24563
8f2c479eb125
eliminate unnecessary value stack in evaluator
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
2934 push_result (val); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2935 } |
8662
af72c8137d64
improve looping over arrays
Jaroslav Hajek <highegg@gmail.com>
parents:
8658
diff
changeset
|
2936 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2937 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2938 tree_evaluator::visit_statement (tree_statement& stmt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2939 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2940 tree_command *cmd = stmt.command (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2941 tree_expression *expr = stmt.expression (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2942 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2943 if (cmd || expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2944 { |
25401
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
2945 if (m_statement_context == SC_FUNCTION |
6f6479125d80
eliminate some globals from tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
25400
diff
changeset
|
2946 || m_statement_context == SC_SCRIPT) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2947 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2948 // Skip commands issued at a debug> prompt to avoid disturbing |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2949 // the state of the program we are debugging. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2950 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2951 if (Vtrack_line_num) |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
2952 m_call_stack.set_location (stmt.line (), stmt.column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2953 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2954 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2955 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2956 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2957 if (cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2958 cmd->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2959 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2960 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2961 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2962 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2963 size_t line = stmt.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2964 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2965 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2966 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
2967 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
2968 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
2969 do_breakpoint (expr->is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2970 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2971 // FIXME: maybe all of this should be packaged in |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2972 // one virtual function that returns a flag saying whether |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2973 // or not the expression will take care of binding ans and |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2974 // printing the result. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2975 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2976 // FIXME: it seems that we should just have to |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
2977 // evaluate the expression and that should take care of |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2978 // everything, binding ans as necessary? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2979 |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2980 octave_value tmp_result = evaluate (expr, 0); |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2981 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2982 if (tmp_result.is_defined ()) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2983 { |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2984 bool do_bind_ans = false; |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2985 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2986 if (expr->is_identifier ()) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2987 do_bind_ans = ! is_variable (expr); |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2988 else |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
2989 do_bind_ans = ! expr->is_assignment_expression (); |
24564
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2990 |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2991 if (do_bind_ans) |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2992 bind_ans (tmp_result, expr->print_result () |
07876b7127bf
reorganize binding to ans in evaluator for clarity
John W. Eaton <jwe@octave.org>
parents:
24563
diff
changeset
|
2993 && statement_printing_enabled ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2994 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2995 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2996 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2997 catch (const std::bad_alloc&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2998 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
2999 // FIXME: We want to use error_with_id here so that give users |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3000 // control over this error message but error_with_id will |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3001 // require some memory allocations. Is there anything we can |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3002 // do to make those more likely to succeed? |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3003 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3004 error_with_id ("Octave:bad-alloc", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3005 "out of memory or dimension too large for Octave's index type"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3006 } |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
3007 catch (const interrupt_exception&) |
24583
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3008 { |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3009 // If we are debugging, then continue with next statement. |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3010 // Otherwise, jump out of here. |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3011 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3012 if (m_debug_mode) |
24583
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3013 interpreter::recover_from_exception (); |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3014 else |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3015 throw; |
466e2aab871b
stay in debug mode on Control-C interrupts (bug #52750)
John W. Eaton <jwe@octave.org>
parents:
24565
diff
changeset
|
3016 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3017 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3018 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3019 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3020 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3021 tree_evaluator::visit_statement_list (tree_statement_list& lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3022 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3023 // FIXME: commented out along with else clause below. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3024 // static octave_value_list empty_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3025 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25336
diff
changeset
|
3026 auto p = lst.begin (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3027 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3028 if (p != lst.end ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3029 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3030 while (true) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3031 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3032 tree_statement *elt = *p++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3033 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3034 if (! elt) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3035 error ("invalid statement found in statement list!"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3036 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3037 octave_quit (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3038 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3039 elt->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3040 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3041 if (m_breaking || m_continuing) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3042 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3043 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3044 if (m_returning) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3045 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3046 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3047 if (p == lst.end ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3048 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3049 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3050 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3051 // Clear previous values before next statement is |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3052 // evaluated so that we aren't holding an extra |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3053 // reference to a value that may be used next. For |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3054 // example, in code like this: |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3055 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3056 // X = rand (N); # refcount for X should be 1 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3057 // # after this statement |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3058 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3059 // X(idx) = val; # no extra copy of X should be |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3060 // # needed, but we will be faked |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3061 // # out if retval is not cleared |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3062 // # between statements here |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3063 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3064 // result_values = empty_list; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3065 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3066 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3067 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3068 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3069 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3070 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3071 tree_evaluator::visit_switch_case (tree_switch_case&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3072 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3073 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3074 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3075 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3076 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3077 tree_evaluator::visit_switch_case_list (tree_switch_case_list&) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3078 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3079 panic_impossible (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3080 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3081 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3082 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3083 tree_evaluator::visit_switch_command (tree_switch_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3084 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3085 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3086 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3087 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3088 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3089 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3090 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3091 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3092 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3093 do_breakpoint (cmd.is_active_breakpoint (*this)); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3094 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3095 tree_expression *expr = cmd.switch_value (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3096 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3097 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3098 error ("missing value in switch command near line %d, column %d", |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3099 cmd.line (), cmd.column ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3100 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3101 octave_value val = evaluate (expr); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3102 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3103 tree_switch_case_list *lst = cmd.case_list (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3104 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3105 if (lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3106 { |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23435
diff
changeset
|
3107 for (tree_switch_case *t : *lst) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3108 { |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3109 if (t->is_default_case () || switch_case_label_matches (t, val)) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3110 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3111 tree_statement_list *stmt_lst = t->commands (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3112 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3113 if (stmt_lst) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3114 stmt_lst->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3115 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3116 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3117 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3118 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3119 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3120 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3121 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3122 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3123 tree_evaluator::visit_try_catch_command (tree_try_catch_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3124 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3125 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3126 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3127 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3128 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3129 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3130 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3131 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3132 bool execution_error = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3133 |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
3134 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
3135 // unwind frame before catch block |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3136 unwind_protect frame; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3137 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3138 frame.protect_var (buffer_error_messages); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3139 frame.protect_var (Vdebug_on_error); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3140 frame.protect_var (Vdebug_on_warning); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3141 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3142 buffer_error_messages++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3143 Vdebug_on_error = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3144 Vdebug_on_warning = false; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3145 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3146 // The catch code is *not* added to unwind_protect stack; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3147 // it doesn't need to be run on interrupts. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3148 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3149 tree_statement_list *try_code = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3150 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3151 if (try_code) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3152 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3153 try |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
3154 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3155 in_try_catch++; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3156 try_code->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3157 in_try_catch--; |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
3158 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3159 catch (const execution_exception&) |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
3160 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3161 interpreter::recover_from_exception (); |
13225
359153d26cc1
eliminate DO_SIMPLE_FOR_LOOP_ONCE macro
John W. Eaton <jwe@octave.org>
parents:
12833
diff
changeset
|
3162 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3163 in_try_catch--; // must be restored before "catch" block |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3164 execution_error = true; |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
3165 } |
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
3166 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3167 // Unwind to let the user print any messages from |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3168 // errors that occurred in the body of the try_catch statement, |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3169 // or throw further errors. |
20784
52f6921dde09
* pt-eval.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
3170 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3171 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3172 if (execution_error) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3173 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3174 tree_statement_list *catch_code = cmd.cleanup (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3175 if (catch_code) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3176 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3177 tree_identifier *expr_id = cmd.identifier (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3178 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3179 if (expr_id) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3180 { |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
3181 octave_lvalue ult = expr_id->lvalue (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3182 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3183 octave_scalar_map err; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3184 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3185 err.assign ("message", last_error_message ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3186 err.assign ("identifier", last_error_id ()); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3187 err.assign ("stack", last_error_stack ()); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3188 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3189 ult.assign (octave_value::op_asn_eq, err); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3190 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3191 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3192 // perform actual "catch" block |
26451
0ab258611cc5
pt-eval.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
3193 catch_code->accept (*this); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3194 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3195 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3196 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3197 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3198 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3199 tree_evaluator::do_unwind_protect_cleanup_code (tree_statement_list *list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3200 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3201 unwind_protect frame; |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3202 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3203 frame.protect_var (octave_interrupt_state); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3204 octave_interrupt_state = 0; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3205 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3206 // We want to preserve the last location info for possible |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3207 // backtracking. |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
3208 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3209 frame.add_method (m_call_stack, &call_stack::set_line, |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
3210 m_call_stack.current_line ()); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3211 frame.add_method (m_call_stack, &call_stack::set_column, |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
3212 m_call_stack.current_column ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3213 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3214 // Similarly, if we have seen a return or break statement, allow all |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3215 // the cleanup code to run before returning or handling the break. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3216 // We don't have to worry about continue statements because they can |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3217 // only occur in loops. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3218 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3219 frame.protect_var (m_returning); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3220 m_returning = 0; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3221 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3222 frame.protect_var (m_breaking); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3223 m_breaking = 0; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3224 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3225 try |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3226 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3227 if (list) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3228 list->accept (*this); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3229 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3230 catch (const execution_exception&) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3231 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3232 interpreter::recover_from_exception (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3233 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3234 if (m_breaking || m_returning) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3235 frame.discard (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3236 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3237 frame.run (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3238 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3239 frame.discard (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3240 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3241 throw; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3242 } |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3243 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3244 // The unwind_protects are popped off the stack in the reverse of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3245 // the order they are pushed on. |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3246 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3247 // FIXME: these statements say that if we see a break or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3248 // return statement in the cleanup block, that we want to use the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3249 // new value of the breaking or returning flag instead of restoring |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3250 // the previous value. Is that the right thing to do? I think so. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3251 // Consider the case of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3252 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3253 // function foo () |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3254 // unwind_protect |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3255 // fprintf (stderr, "1: this should always be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3256 // break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3257 // fprintf (stderr, "1: this should never be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3258 // unwind_protect_cleanup |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3259 // fprintf (stderr, "2: this should always be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3260 // return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3261 // fprintf (stderr, "2: this should never be executed\n"); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3262 // end_unwind_protect |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3263 // endfunction |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3264 // |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3265 // If we reset the value of the breaking flag, both the returning |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3266 // flag and the breaking flag will be set, and we shouldn't have |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3267 // both. So, use the most recent one. If there is no return or |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3268 // break in the cleanup block, the values should be reset to |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3269 // whatever they were when the cleanup block was entered. |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3270 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3271 if (m_breaking || m_returning) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3272 frame.discard (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3273 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3274 frame.run (2); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3275 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
3276 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3277 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3278 tree_evaluator::visit_unwind_protect_command (tree_unwind_protect_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3279 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3280 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3281 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3282 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3283 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3284 m_echo_file_pos = line + 1; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3285 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3286 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3287 tree_statement_list *cleanup_code = cmd.cleanup (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3288 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3289 tree_statement_list *unwind_protect_code = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3290 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3291 if (unwind_protect_code) |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3292 { |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3293 try |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3294 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3295 unwind_protect_code->accept (*this); |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3296 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3297 catch (const execution_exception&) |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3298 { |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3299 // FIXME: Maybe we should be able to temporarily set the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3300 // interpreter's exception handling state to something "safe" |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3301 // while the cleanup block runs instead of just resetting it |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3302 // here? |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3303 interpreter::recover_from_exception (); |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3304 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3305 // Run the cleanup code on exceptions, so that it is run even |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3306 // in case of interrupt or out-of-memory. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3307 do_unwind_protect_cleanup_code (cleanup_code); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3308 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3309 // If an error occurs inside the cleanup code, a new |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3310 // exception will be thrown instead of the original. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3311 throw; |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3312 } |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3313 catch (const interrupt_exception&) |
23612
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
3314 { |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
3315 // The comments above apply here as well. |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3316 interpreter::recover_from_exception (); |
23612
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
3317 do_unwind_protect_cleanup_code (cleanup_code); |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
3318 throw; |
fecca33388f7
also run unwind protect cleanup code on interrupt exceptions (bug #51209)
John W. Eaton <jwe@octave.org>
parents:
23219
diff
changeset
|
3319 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3320 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3321 // Also execute the unwind_protect_cleanump code if the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3322 // unwind_protect block runs without error. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3323 do_unwind_protect_cleanup_code (cleanup_code); |
21922
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3324 } |
c34f9c182dcf
Make debug_on_error to apply to the "catch" block of try/catch (bug #47685)
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
3325 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3326 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3327 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3328 tree_evaluator::visit_while_command (tree_while_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3329 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3330 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3331 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3332 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3333 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3334 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3335 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3336 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3337 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3338 #if defined (HAVE_LLVM) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3339 if (tree_jit::execute (cmd)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3340 return; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3341 #endif |
9383 | 3342 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3343 unwind_protect frame; |
10210
752f349052a2
ensure correct backtraces after error in unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
10194
diff
changeset
|
3344 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3345 frame.protect_var (m_in_loop_command); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3346 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3347 m_in_loop_command = true; |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
3348 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3349 tree_expression *expr = cmd.condition (); |
20824
8848e35e5ef8
better handling of exceptions in unwind-protect blocks
John W. Eaton <jwe@octave.org>
parents:
20784
diff
changeset
|
3350 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3351 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3352 panic_impossible (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3353 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3354 for (;;) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3355 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3356 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3357 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3358 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3359 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3360 do_breakpoint (cmd.is_active_breakpoint (*this)); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3361 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3362 if (is_logically_true (expr, "while")) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3363 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3364 tree_statement_list *loop_body = cmd.body (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3365 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3366 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3367 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3368 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3369 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3370 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3371 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3372 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3373 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3374 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3375 } |
20666
e0e2c2ce7e94
defer stack trace until back at top level
John W. Eaton <jwe@octave.org>
parents:
20560
diff
changeset
|
3376 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3377 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3378 tree_evaluator::visit_do_until_command (tree_do_until_command& cmd) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3379 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3380 size_t line = cmd.line (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3381 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3382 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3383 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3384 echo_code (line); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3385 line++; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3386 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3387 |
21211
2cf8bc5c7017
use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
3388 #if defined (HAVE_LLVM) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3389 if (tree_jit::execute (cmd)) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3390 return; |
15023
75d1bc2fd6d2
Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents:
14932
diff
changeset
|
3391 #endif |
75d1bc2fd6d2
Compile top level while loops in JIT.
Max Brister <max@2bass.com>
parents:
14932
diff
changeset
|
3392 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3393 unwind_protect frame; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3394 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3395 frame.protect_var (m_in_loop_command); |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3396 |
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3397 m_in_loop_command = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3398 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3399 tree_expression *expr = cmd.condition (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3400 int until_line = cmd.line (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3401 int until_column = cmd.column (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3402 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3403 if (! expr) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3404 panic_impossible (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3405 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3406 for (;;) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3407 { |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3408 if (m_echo_state) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3409 m_echo_file_pos = line; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3410 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3411 tree_statement_list *loop_body = cmd.body (); |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3412 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3413 if (loop_body) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3414 loop_body->accept (*this); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3415 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3416 if (quit_loop_now ()) |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3417 break; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3418 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3419 if (m_debug_mode) |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3420 do_breakpoint (cmd.is_active_breakpoint (*this)); |
18325
2a8243d8327a
jit compiler: Add support for the do_until statement
LYH <lyh.kernel@gmail.com>
parents:
18270
diff
changeset
|
3421 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23532
diff
changeset
|
3422 m_call_stack.set_location (until_line, until_column); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3423 |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3424 if (is_logically_true (expr, "do-until")) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3425 break; |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3426 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3427 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3428 |
23702
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3429 void tree_evaluator::bind_ans (const octave_value& val, bool print) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3430 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3431 static std::string ans = "ans"; |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3432 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3433 if (val.is_defined ()) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3434 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3435 if (val.is_cs_list ()) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3436 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3437 octave_value_list lst = val.list_value (); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3438 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3439 for (octave_idx_type i = 0; i < lst.length (); i++) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3440 bind_ans (lst(i), print); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3441 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3442 else |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3443 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3444 assign (ans, val); |
23702
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3445 |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3446 if (print) |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3447 { |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3448 octave_value_list args = ovl (val); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3449 args.stash_name_tags (string_vector (ans)); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3450 feval ("display", args); |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3451 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3452 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3453 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3454 } |
d396b5fd9199
move bind_ans to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
3455 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3456 void |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3457 tree_evaluator::do_breakpoint (tree_statement& stmt) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3458 { |
26113
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3459 do_breakpoint (stmt.is_active_breakpoint (*this), |
8a15f3bace49
move eval_string inside interpreter/evaluator class
John W. Eaton <jwe@octave.org>
parents:
26094
diff
changeset
|
3460 stmt.is_end_of_fcn_or_script ()); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3461 } |
8845
5a6db6bd1a02
eigs.cc (Feigs): fix handling of sigma arg
John W. Eaton <jwe@octave.org>
parents:
8679
diff
changeset
|
3462 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3463 void |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3464 tree_evaluator::do_breakpoint (bool is_breakpoint, |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3465 bool is_end_of_fcn_or_script) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3466 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3467 bool break_on_this_statement = false; |
21542
7ba48ff6ce83
Record correct line number with "until" command (bug #43249)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
3468 |
25405
df2f3af2c6c5
eliminate unused octave_debug_on_interrupt_state variable
John W. Eaton <jwe@octave.org>
parents:
25404
diff
changeset
|
3469 if (is_breakpoint) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3470 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3471 break_on_this_statement = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3472 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3473 m_dbstep_flag = 0; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3474 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3475 m_current_frame = m_call_stack.current_frame (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3476 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3477 else if (m_dbstep_flag > 0) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3478 { |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3479 if (m_call_stack.current_frame () == m_current_frame) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3480 { |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3481 if (m_dbstep_flag == 1 || is_end_of_fcn_or_script) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3482 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3483 // We get here if we are doing a "dbstep" or a "dbstep N" and the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3484 // count has reached 1 so that we must stop and return to debug |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3485 // prompt. Alternatively, "dbstep N" has been used but the end |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3486 // of the frame has been reached so we stop at the last line and |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3487 // return to prompt. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3488 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3489 break_on_this_statement = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3490 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3491 m_dbstep_flag = 0; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3492 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3493 else |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3494 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3495 // Executing "dbstep N". Decrease N by one and continue. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3496 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3497 m_dbstep_flag--; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3498 } |
15574
d20cbfec6df7
Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
3499 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3500 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3501 else if (m_dbstep_flag == 1 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3502 && m_call_stack.current_frame () < m_current_frame) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3503 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3504 // We stepped out from the end of a function. |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3505 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3506 m_current_frame = m_call_stack.current_frame (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3507 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3508 break_on_this_statement = true; |
15574
d20cbfec6df7
Fix off-by-1 error when executing 'dbstep N'
Rik <rik@octave.org>
parents:
15469
diff
changeset
|
3509 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3510 m_dbstep_flag = 0; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3511 } |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3512 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3513 else if (m_dbstep_flag == -1) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3514 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3515 // We get here if we are doing a "dbstep in". |
16396
c6a13c1900fc
make "dbstep out" and "dbstep" after "dbstep in" work properly
John W. Eaton <jwe@octave.org>
parents:
16354
diff
changeset
|
3516 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3517 break_on_this_statement = true; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3518 |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3519 m_dbstep_flag = 0; |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3520 |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3521 m_current_frame = m_call_stack.current_frame (); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3522 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3523 else if (m_dbstep_flag == -2) |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3524 { |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3525 // We get here if we are doing a "dbstep out". Check for end of |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3526 // function and whether the current frame is the same as the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3527 // cached value because we want to step out from the frame where |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3528 // "dbstep out" was evaluated, not from any functions called from |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3529 // that frame. |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3530 |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3531 if (is_end_of_fcn_or_script |
25402
ef2b9d4abf4a
eliminate some global variables from tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25401
diff
changeset
|
3532 && m_call_stack.current_frame () == m_current_frame) |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3533 m_dbstep_flag = -1; |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3534 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3535 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3536 if (break_on_this_statement) |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3537 { |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3538 input_system& input_sys = m_interpreter.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3539 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3540 input_sys.keyboard (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3541 } |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3542 } |
10219
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
3543 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3544 // ARGS is currently unused, but since the do_keyboard function in |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3545 // input.cc accepts an argument list, we preserve it here so that the |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3546 // interface won't have to change if we decide to use it in the future. |
10219
979fb2606c4f
new tree_evaluator::do_keyoard function
Ryan Rusaw <rrusaw@gmail.com>
parents:
10210
diff
changeset
|
3547 |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3548 octave_value |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3549 tree_evaluator::do_keyboard (const octave_value_list& args) const |
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3550 { |
25407
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3551 input_system& input_sys = m_interpreter.get_input_system (); |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3552 |
ab10403a0b50
new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents:
25405
diff
changeset
|
3553 return input_sys.keyboard (args); |
22196
dd992fd74fce
put parser, lexer, and evaluator in namespace; interpreter now owns evaluator
John W. Eaton <jwe@octave.org>
parents:
22164
diff
changeset
|
3554 } |
23435
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3555 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3556 bool |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3557 tree_evaluator::is_logically_true (tree_expression *expr, |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3558 const char *warn_for) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3559 { |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3560 bool expr_value = false; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3561 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3562 octave_value t1 = evaluate (expr); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3563 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3564 if (t1.is_defined ()) |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3565 return t1.is_true (); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3566 else |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3567 error ("%s: undefined value used in conditional expression", warn_for); |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3568 |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3569 return expr_value; |
c452180ab672
begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents:
23398
diff
changeset
|
3570 } |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3571 |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3572 octave_value_list |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
3573 tree_evaluator::make_value_list (tree_argument_list *args, |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3574 const string_vector& arg_nm, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3575 const octave_value *object, bool rvalue) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3576 { |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3577 octave_value_list retval; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3578 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3579 if (args) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3580 { |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3581 // Function calls inside an argument list can't have ignored |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3582 // output arguments. |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3583 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3584 unwind_protect frame; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3585 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23781
diff
changeset
|
3586 m_lvalue_list_stack.push (nullptr); |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3587 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3588 frame.add_method (m_lvalue_list_stack, |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3589 &value_stack<const std::list<octave_lvalue>*>::pop); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3590 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3591 if (rvalue && object && args->has_magic_end () |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3592 && object->is_undefined ()) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3593 err_invalid_inquiry_subscript (); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3594 |
25382
749d9e858553
move convert_to_const_vector from tree_argument_list to tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
25381
diff
changeset
|
3595 retval = convert_to_const_vector (args, object); |
23482
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3596 } |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3597 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3598 octave_idx_type n = retval.length (); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3599 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3600 if (n > 0) |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3601 retval.stash_name_tags (arg_nm); |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3602 |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3603 return retval; |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3604 } |
c9937e865768
make isargout work again for nested function calls
John W. Eaton <jwe@octave.org>
parents:
23481
diff
changeset
|
3605 |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3606 std::list<octave_lvalue> |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3607 tree_evaluator::make_lvalue_list (tree_argument_list *lhs) |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3608 { |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3609 std::list<octave_lvalue> retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3610 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3611 for (tree_expression *elt : *lhs) |
25383
d3a035528c9a
use reference to tree_evaluator instead of pointer
John W. Eaton <jwe@octave.org>
parents:
25382
diff
changeset
|
3612 retval.push_back (elt->lvalue (*this)); |
23481
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3613 |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3614 return retval; |
73558a835b64
eliminate lvalue list arguments from evaluator functions
John W. Eaton <jwe@octave.org>
parents:
23470
diff
changeset
|
3615 } |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3616 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3617 octave_value |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3618 tree_evaluator::max_recursion_depth (const octave_value_list& args, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3619 int nargout) |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3620 { |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3621 return set_internal_variable (m_max_recursion_depth, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3622 "max_recursion_depth", 0); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3623 } |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3624 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3625 octave_value |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
3626 tree_evaluator::whos_line_format (const octave_value_list& args, int nargout) |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
3627 { |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
3628 return set_internal_variable (m_whos_line_format, args, nargout, |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
3629 "whos_line_format"); |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
3630 } |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
3631 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
3632 octave_value |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3633 tree_evaluator::silent_functions (const octave_value_list& args, int nargout) |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3634 { |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3635 return set_internal_variable (m_silent_functions, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3636 "silent_functions"); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3637 } |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3638 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3639 octave_value |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3640 tree_evaluator::string_fill_char (const octave_value_list& args, int nargout) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3641 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3642 return set_internal_variable (m_string_fill_char, args, nargout, |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3643 "string_fill_char"); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3644 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3645 |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3646 // Final step of processing an indexing error. Add the name of the |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3647 // variable being indexed, if any, then issue an error. (Will this also |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3648 // be needed by pt-lvalue, which calls subsref?) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3649 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3650 void tree_evaluator::final_index_error (index_exception& e, |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3651 const tree_expression *expr) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3652 { |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3653 std::string extra_message; |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3654 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3655 symbol_scope scope = get_current_scope (); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3656 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3657 if (is_variable (expr)) |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3658 { |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3659 std::string var = expr->name (); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3660 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3661 e.set_var (var); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3662 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3663 symbol_table& symtab = m_interpreter.get_symbol_table (); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3664 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3665 octave_value fcn = symtab.find_function (var); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3666 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3667 if (fcn.is_function ()) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3668 { |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3669 octave_function *fp = fcn.function_value (); |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3670 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3671 if (fp && fp->name () == var) |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3672 extra_message |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3673 = " (note: variable '" + var + "' shadows function)"; |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3674 } |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3675 } |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3676 |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3677 std::string msg = e.message () + extra_message; |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3678 |
26149
242aa7b2c783
Silence unnecessary warnings about security-format (bug #55046).
Rik <rik@octave.org>
parents:
26113
diff
changeset
|
3679 error_with_id (e.err_id (), "%s", msg.c_str ()); |
26094
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3680 } |
8fb0df0c8772
eliminate duplicate final_index_error function
John W. Eaton <jwe@octave.org>
parents:
26087
diff
changeset
|
3681 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3682 void |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3683 tree_evaluator::push_echo_state (unwind_protect& frame, int type, |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3684 const std::string& file_name, |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3685 size_t pos) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3686 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3687 push_echo_state_cleanup (frame); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3688 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3689 set_echo_state (type, file_name, pos); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3690 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3691 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3692 void |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3693 tree_evaluator::set_echo_state (int type, const std::string& file_name, |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3694 size_t pos) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3695 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3696 m_echo_state = echo_this_file (file_name, type); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3697 m_echo_file_name = file_name; |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3698 m_echo_file_pos = pos; |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3699 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3700 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3701 void |
25653
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3702 tree_evaluator::uwp_set_echo_state (bool state, const std::string& file_name, |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3703 size_t pos) |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3704 { |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3705 m_echo_state = state; |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3706 m_echo_file_name = file_name; |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3707 m_echo_file_pos = pos; |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3708 } |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3709 |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3710 void |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3711 tree_evaluator::maybe_set_echo_state (void) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3712 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3713 octave_function *caller = m_call_stack.caller (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3714 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3715 if (caller && caller->is_user_code ()) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3716 { |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3717 octave_user_code *fcn = dynamic_cast<octave_user_code *> (caller); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3718 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3719 int type = fcn->is_user_function () ? ECHO_FUNCTIONS : ECHO_SCRIPTS; |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3720 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3721 std::string file_name = fcn->fcn_file_name (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3722 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3723 size_t pos = m_call_stack.current_line (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3724 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3725 set_echo_state (type, file_name, pos); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3726 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3727 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3728 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3729 void |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3730 tree_evaluator::push_echo_state_cleanup (unwind_protect& frame) |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3731 { |
25653
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3732 frame.add_method (this, &tree_evaluator::uwp_set_echo_state, |
b3d357990b52
better use of templates for action_container and derived classes
John W. Eaton <jwe@octave.org>
parents:
25483
diff
changeset
|
3733 m_echo_state, m_echo_file_name, m_echo_file_pos); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3734 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3735 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3736 bool tree_evaluator::maybe_push_echo_state_cleanup (void) |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3737 { |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3738 // This function is expected to be called from ECHO, which would be |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3739 // the top of the call stack. If the caller of ECHO is a |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
3740 // user-defined function or script, then set up unwind-protect |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3741 // elements to restore echo state. |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3742 |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
3743 unwind_protect *frame = m_call_stack.curr_fcn_unwind_protect_frame (); |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
3744 |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
3745 if (frame) |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3746 { |
25399
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
3747 push_echo_state_cleanup (*frame); |
6ca2c0d76d84
store unwind protect frame for function evaluation in call_stack object
John W. Eaton <jwe@octave.org>
parents:
25393
diff
changeset
|
3748 return true; |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3749 } |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3750 |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3751 return false; |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
3752 } |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3753 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3754 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3755 octave_value |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3756 tree_evaluator::echo (const octave_value_list& args, int) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3757 { |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3758 bool cleanup_pushed = maybe_push_echo_state_cleanup (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3759 |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3760 string_vector argv = args.make_argv (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3761 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3762 switch (args.length ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3763 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3764 case 0: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3765 if ((m_echo & ECHO_SCRIPTS) || (m_echo & ECHO_FUNCTIONS)) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3766 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3767 m_echo = ECHO_OFF; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3768 m_echo_files.clear (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3769 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3770 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3771 m_echo = ECHO_SCRIPTS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3772 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3773 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3774 case 1: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3775 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3776 std::string arg0 = argv[0]; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3777 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3778 if (arg0 == "on") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3779 m_echo = ECHO_SCRIPTS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3780 else if (arg0 == "off") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3781 m_echo = ECHO_OFF; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3782 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3783 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3784 std::string file = fcn_file_in_path (arg0); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3785 file = sys::env::make_absolute (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3786 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3787 if (file.empty ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3788 error ("echo: no such file %s", arg0.c_str ()); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3789 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3790 if (m_echo & ECHO_ALL) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3791 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3792 // Echo is enabled for all functions, so turn it off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3793 // for this one. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3794 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3795 m_echo_files[file] = false; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3796 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3797 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3798 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3799 // Echo may be enabled for specific functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3800 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3801 auto p = m_echo_files.find (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3802 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3803 if (p == m_echo_files.end ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3804 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3805 // Not this one, so enable it. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3806 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3807 m_echo |= ECHO_FUNCTIONS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3808 m_echo_files[file] = true; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3809 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3810 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3811 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3812 // This one is already in the list. Flip the |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3813 // status for it. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3814 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3815 p->second = ! p->second; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3816 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3817 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3818 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3819 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3820 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3821 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3822 case 2: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3823 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3824 std::string arg0 = argv[0]; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3825 std::string arg1 = argv[1]; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3826 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3827 if (arg1 == "on" || arg1 == "off") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3828 std::swap (arg0, arg1); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3829 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3830 if (arg0 == "on") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3831 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3832 if (arg1 == "all") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3833 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3834 m_echo = (ECHO_SCRIPTS | ECHO_FUNCTIONS | ECHO_ALL); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3835 m_echo_files.clear (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3836 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3837 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3838 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3839 std::string file = fcn_file_in_path (arg1); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3840 file = sys::env::make_absolute (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3841 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3842 if (file.empty ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3843 error ("echo: no such file %s", arg1.c_str ()); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3844 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3845 m_echo |= ECHO_FUNCTIONS; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3846 m_echo_files[file] = true; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3847 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3848 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3849 else if (arg0 == "off") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3850 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3851 if (arg1 == "all") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3852 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3853 m_echo = ECHO_OFF; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3854 m_echo_files.clear (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3855 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3856 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3857 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3858 std::string file = fcn_file_in_path (arg1); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3859 file = sys::env::make_absolute (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3860 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3861 if (file.empty ()) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3862 error ("echo: no such file %s", arg1.c_str ()); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3863 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3864 m_echo_files[file] = false; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3865 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3866 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3867 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3868 print_usage (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3869 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3870 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3871 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3872 default: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3873 print_usage (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3874 break; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3875 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3876 |
23729
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3877 if (cleanup_pushed) |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3878 maybe_set_echo_state (); |
06b3d1d54054
allow echo state to be modified from inside functions
John W. Eaton <jwe@octave.org>
parents:
23728
diff
changeset
|
3879 |
23913
062ce545b21e
mark octave_value from octave_value_list constructor explicit
John W. Eaton <jwe@octave.org>
parents:
23876
diff
changeset
|
3880 return octave_value (); |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3881 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3882 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3883 octave_value |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3884 tree_evaluator::PS4 (const octave_value_list& args, int nargout) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3885 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3886 return set_internal_variable (m_PS4, args, nargout, "PS4"); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3887 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3888 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3889 bool tree_evaluator::echo_this_file (const std::string& file, int type) const |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3890 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3891 if ((type & m_echo) == ECHO_SCRIPTS) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3892 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3893 // Asking about scripts and echo is enabled for them. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3894 return true; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3895 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3896 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3897 if ((type & m_echo) == ECHO_FUNCTIONS) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3898 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3899 // Asking about functions and echo is enabled for functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3900 // Now, which ones? |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3901 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3902 auto p = m_echo_files.find (file); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3903 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3904 if (m_echo & ECHO_ALL) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3905 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3906 // Return true ulness echo was turned off for a specific |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3907 // file. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3908 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3909 return (p == m_echo_files.end () || p->second); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3910 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3911 else |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3912 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3913 // Return true if echo is specifically enabled for this file. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3914 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3915 return p != m_echo_files.end () && p->second; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3916 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3917 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3918 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3919 return false; |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3920 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3921 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3922 void tree_evaluator::echo_code (size_t line) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3923 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3924 std::string prefix = command_editor::decode_prompt_string (m_PS4); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3925 |
23728
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3926 octave_function *curr_fcn = m_call_stack.current (); |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3927 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3928 if (curr_fcn && curr_fcn->is_user_code ()) |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3929 { |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3930 octave_user_code *code = dynamic_cast<octave_user_code *> (curr_fcn); |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3931 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3932 size_t num_lines = line - m_echo_file_pos + 1; |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3933 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3934 std::deque<std::string> lines |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3935 = code->get_code_lines (m_echo_file_pos, num_lines); |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3936 |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3937 for (auto& elt : lines) |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3938 octave_stdout << prefix << elt << std::endl; |
b40b7243a782
new class for caching file contents for debug and echo
John W. Eaton <jwe@octave.org>
parents:
23723
diff
changeset
|
3939 } |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
3940 } |
25360
bc5f225bc578
eliminate some global accesses to the breakpoint table
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
3941 |
25403
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3942 // Decide if it's time to quit a for or while loop. |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3943 bool tree_evaluator::quit_loop_now (void) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3944 { |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3945 octave_quit (); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3946 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3947 // Maybe handle 'continue N' someday... |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3948 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3949 if (m_continuing) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3950 m_continuing--; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3951 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3952 bool quit = (m_returning || m_breaking || m_continuing); |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3953 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3954 if (m_breaking) |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3955 m_breaking--; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3956 |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3957 return quit; |
2b7d7a3f5f57
move returning, breaking, and continuing flags to evaluator
John W. Eaton <jwe@octave.org>
parents:
25402
diff
changeset
|
3958 } |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3959 |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3960 void tree_evaluator::bind_auto_fcn_vars (const string_vector& arg_names, |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3961 int nargin, int nargout, |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3962 bool takes_varargs, |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3963 const octave_value_list& va_args) |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3964 { |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3965 set_auto_fcn_var (stack_frame::ARG_NAMES, Cell (arg_names)); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3966 set_auto_fcn_var (stack_frame::IGNORED, ignored_fcn_outputs ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3967 set_auto_fcn_var (stack_frame::NARGIN, nargin); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3968 set_auto_fcn_var (stack_frame::NARGOUT, nargout); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3969 set_auto_fcn_var (stack_frame::SAVED_WARNING_STATES, octave_value ()); |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3970 |
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3971 if (takes_varargs) |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3972 assign ("varargin", va_args.cell_value ()); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3973 } |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3974 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3975 void tree_evaluator::init_local_fcn_vars (octave_user_function& user_fcn) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3976 { |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3977 stack_frame& frame = m_call_stack.get_current_stack_frame (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3978 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3979 const octave_user_function::local_vars_map& lviv |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3980 = user_fcn.local_var_init_vals (); |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3981 |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3982 for (const auto& nm_ov : lviv) |
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
3983 frame.assign (nm_ov.first, nm_ov.second); |
26039
d2aae3570c81
perform automatic function variable binding in tree_evaluator
John W. Eaton <jwe@octave.org>
parents:
26004
diff
changeset
|
3984 } |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3985 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3986 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3987 DEFMETHOD (max_recursion_depth, interp, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
3988 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3989 @deftypefn {} {@var{val} =} max_recursion_depth () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3990 @deftypefnx {} {@var{old_val} =} max_recursion_depth (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3991 @deftypefnx {} {} max_recursion_depth (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3992 Query or set the internal limit on the number of times a function may |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3993 be called recursively. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3994 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3995 If the limit is exceeded, an error message is printed and control returns to |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3996 the top level. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3997 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3998 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
3999 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4000 The original variable value is restored when exiting the function. |
24855
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24738
diff
changeset
|
4001 |
41f80b9af274
prevent stack overflow crash on deeply nested function calls (bug #47620)
John W. Eaton <jwe@octave.org>
parents:
24738
diff
changeset
|
4002 @seealso{max_stack_depth} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4003 @end deftypefn */) |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
4004 { |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4005 octave::tree_evaluator& tw = interp.get_evaluator (); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4006 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4007 return tw.max_recursion_depth (args, nargout); |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
4008 } |
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
4009 |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4010 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4011 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4012 %! orig_val = max_recursion_depth (); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4013 %! old_val = max_recursion_depth (2*orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4014 %! assert (orig_val, old_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4015 %! assert (max_recursion_depth (), 2*orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4016 %! max_recursion_depth (orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4017 %! assert (max_recursion_depth (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
4018 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
4019 %!error (max_recursion_depth (1, 2)) |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4020 */ |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4021 |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4022 DEFMETHOD (whos_line_format, interp, args, nargout, |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4023 doc: /* -*- texinfo -*- |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4024 @deftypefn {} {@var{val} =} whos_line_format () |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4025 @deftypefnx {} {@var{old_val} =} whos_line_format (@var{new_val}) |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4026 @deftypefnx {} {} whos_line_format (@var{new_val}, "local") |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4027 Query or set the format string used by the command @code{whos}. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4028 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4029 A full format string is: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4030 @c Set example in small font to prevent overfull line |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4031 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4032 @smallexample |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4033 %[modifier]<command>[:width[:left-min[:balance]]]; |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4034 @end smallexample |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4035 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4036 The following command sequences are available: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4037 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4038 @table @code |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4039 @item %a |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26512
diff
changeset
|
4040 Prints attributes of variables (g=global, p=persistent, f=formal parameter). |
26087
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4041 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4042 @item %b |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4043 Prints number of bytes occupied by variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4044 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4045 @item %c |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4046 Prints class names of variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4047 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4048 @item %e |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4049 Prints elements held by variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4050 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4051 @item %n |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4052 Prints variable names. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4053 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4054 @item %s |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4055 Prints dimensions of variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4056 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4057 @item %t |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4058 Prints type names of variables. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4059 @end table |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4060 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4061 Every command may also have an alignment modifier: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4062 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4063 @table @code |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4064 @item l |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4065 Left alignment. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4066 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4067 @item r |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4068 Right alignment (default). |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4069 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4070 @item c |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4071 Column-aligned (only applicable to command %s). |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4072 @end table |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4073 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4074 The @code{width} parameter is a positive integer specifying the minimum |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4075 number of columns used for printing. No maximum is needed as the field will |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4076 auto-expand as required. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4077 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4078 The parameters @code{left-min} and @code{balance} are only available when |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4079 the column-aligned modifier is used with the command @samp{%s}. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4080 @code{balance} specifies the column number within the field width which |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4081 will be aligned between entries. Numbering starts from 0 which indicates |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4082 the leftmost column. @code{left-min} specifies the minimum field width to |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4083 the left of the specified balance column. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4084 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4085 The default format is: |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4086 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4087 @qcode{" %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;@xbackslashchar{}n"} |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4088 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4089 When called from inside a function with the @qcode{"local"} option, the |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4090 variable is changed locally for the function and any subroutines it calls. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4091 The original variable value is restored when exiting the function. |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4092 @seealso{whos} |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4093 @end deftypefn */) |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4094 { |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4095 octave::tree_evaluator& tw = interp.get_evaluator (); |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4096 |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4097 return tw.whos_line_format (args, nargout); |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4098 } |
7656fcd0ff9f
move whos_line_format to evaluator
John W. Eaton <jwe@octave.org>
parents:
26065
diff
changeset
|
4099 |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4100 DEFMETHOD (silent_functions, interp, args, nargout, |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4101 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4102 @deftypefn {} {@var{val} =} silent_functions () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4103 @deftypefnx {} {@var{old_val} =} silent_functions (@var{new_val}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4104 @deftypefnx {} {} silent_functions (@var{new_val}, "local") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4105 Query or set the internal variable that controls whether internal |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4106 output from a function is suppressed. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4107 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4108 If this option is disabled, Octave will display the results produced by |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4109 evaluating expressions within a function body that are not terminated with |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4110 a semicolon. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4111 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4112 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4113 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4114 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21922
diff
changeset
|
4115 @end deftypefn */) |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4116 { |
23705
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4117 octave::tree_evaluator& tw = interp.get_evaluator (); |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4118 |
4c597585ff52
move Vmax_recursion_depth and Vsilent_functions to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23702
diff
changeset
|
4119 return tw.silent_functions (args, nargout); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4120 } |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4121 |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4122 /* |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4123 %!test |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4124 %! orig_val = silent_functions (); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4125 %! old_val = silent_functions (! orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4126 %! assert (orig_val, old_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4127 %! assert (silent_functions (), ! orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4128 %! silent_functions (orig_val); |
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4129 %! assert (silent_functions (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
4130 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14294
diff
changeset
|
4131 %!error (silent_functions (1, 2)) |
12833
9f0f2c226053
codesprint: new tests for functions in pt-eval.cc
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
4132 */ |
23706
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4133 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4134 DEFMETHOD (string_fill_char, interp, args, nargout, |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4135 doc: /* -*- texinfo -*- |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4136 @deftypefn {} {@var{val} =} string_fill_char () |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4137 @deftypefnx {} {@var{old_val} =} string_fill_char (@var{new_val}) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4138 @deftypefnx {} {} string_fill_char (@var{new_val}, "local") |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4139 Query or set the internal variable used to pad all rows of a character |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4140 matrix to the same length. |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4141 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4142 The value must be a single character and the default is @qcode{" "} (a |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4143 single space). For example: |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4144 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4145 @example |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4146 @group |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4147 string_fill_char ("X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4148 [ "these"; "are"; "strings" ] |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4149 @result{} "theseXX" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4150 "areXXXX" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4151 "strings" |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4152 @end group |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4153 @end example |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4154 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4155 When called from inside a function with the @qcode{"local"} option, the |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4156 variable is changed locally for the function and any subroutines it calls. |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4157 The original variable value is restored when exiting the function. |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4158 @end deftypefn */) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4159 { |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4160 octave::tree_evaluator& tw = interp.get_evaluator (); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4161 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4162 return tw.string_fill_char (args, nargout); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4163 } |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4164 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4165 /* |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4166 ## string_fill_char() function call must be outside of %!test block |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4167 ## due to the way a %!test block is wrapped inside a function |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4168 %!shared orig_val, old_val |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4169 %! orig_val = string_fill_char (); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4170 %! old_val = string_fill_char ("X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4171 %!test |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4172 %! assert (orig_val, old_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4173 %! assert (string_fill_char (), "X"); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4174 %! assert (["these"; "are"; "strings"], ["theseXX"; "areXXXX"; "strings"]); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4175 %! string_fill_char (orig_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4176 %! assert (string_fill_char (), orig_val); |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4177 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4178 %!assert ( [ [], {1} ], {1} ) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4179 |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4180 %!error (string_fill_char (1, 2)) |
6683451b75b2
move Vstring_fill_char to tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23705
diff
changeset
|
4181 */ |
23723
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4182 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4183 DEFMETHOD (PS4, interp, args, nargout, |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4184 doc: /* -*- texinfo -*- |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4185 @deftypefn {} {@var{val} =} PS4 () |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4186 @deftypefnx {} {@var{old_val} =} PS4 (@var{new_val}) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4187 @deftypefnx {} {} PS4 (@var{new_val}, "local") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4188 Query or set the character string used to prefix output produced |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4189 when echoing commands is enabled. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4190 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4191 The default value is @qcode{"+ "}. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4192 @xref{Diary and Echo Commands}, for a description of echoing commands. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4193 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4194 When called from inside a function with the @qcode{"local"} option, the |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4195 variable is changed locally for the function and any subroutines it calls. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4196 The original variable value is restored when exiting the function. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4197 @seealso{echo, PS1, PS2} |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4198 @end deftypefn */) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4199 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4200 octave::tree_evaluator& tw = interp.get_evaluator (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4201 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4202 return tw.PS4 (args, nargout); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4203 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4204 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4205 DEFMETHOD (echo, interp, args, nargout, |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4206 doc: /* -*- texinfo -*- |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4207 @deftypefn {} {} echo |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4208 @deftypefnx {} {} echo on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4209 @deftypefnx {} {} echo off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4210 @deftypefnx {} {} echo on all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4211 @deftypefnx {} {} echo off all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4212 @deftypefnx {} {} echo @var{function} on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4213 @deftypefnx {} {} echo @var{function} off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4214 Control whether commands are displayed as they are executed. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4215 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4216 Valid options are: |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4217 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4218 @table @code |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4219 @item on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4220 Enable echoing of commands as they are executed in script files. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4221 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4222 @item off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4223 Disable echoing of commands as they are executed in script files. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4224 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4225 @item on all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4226 Enable echoing of commands as they are executed in script files and |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4227 functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4228 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4229 @item off all |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4230 Disable echoing of commands as they are executed in script files and |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4231 functions. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4232 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4233 @item @var{function} on |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4234 Enable echoing of commands as they are executed in the named function. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4235 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4236 @item @var{function} off |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4237 Disable echoing of commands as they are executed in the named function. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4238 @end table |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4239 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4240 @noindent |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4241 With no arguments, @code{echo} toggles the current echo state. |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4242 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4243 @seealso{PS4} |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4244 @end deftypefn */) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4245 { |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4246 octave::tree_evaluator& tw = interp.get_evaluator (); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4247 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4248 return tw.echo (args, nargout); |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4249 } |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4250 |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4251 /* |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4252 %!error echo ([]) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4253 %!error echo (0) |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4254 %!error echo ("") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4255 %!error echo ("Octave") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4256 %!error echo ("off", "invalid") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4257 %!error echo ("on", "invalid") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4258 %!error echo ("on", "all", "all") |
ab8831d346c1
revamp echo command and move related variables inside tree_evaluator class
John W. Eaton <jwe@octave.org>
parents:
23706
diff
changeset
|
4259 */ |