annotate src/ov-usr-fcn.h @ 7948:af10baa63915 ss-3-1-50

3.1.50 snapshot
author John W. Eaton <jwe@octave.org>
date Fri, 18 Jul 2008 17:42:48 -0400
parents 8447a5024650
children 0d607e8dbbfa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
1 /*
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 2005, 2006, 2007 John W. Eaton
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
5
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
7
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6505
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6505
diff changeset
11 option) any later version.
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
12
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
16 for more details.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
17
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6505
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6505
diff changeset
20 <http://www.gnu.org/licenses/>.
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
21
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
22 */
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
23
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
24 #if !defined (octave_user_function_h)
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
25 #define octave_user_function_h 1
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
26
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
27 #include <ctime>
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
28
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
29 #include <string>
4214
b9317f3973ec [project @ 2002-12-04 04:57:01 by jwe]
jwe
parents: 4192
diff changeset
30 #include <stack>
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
31
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
32 #include "comment-list.h"
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
33 #include "oct-obj.h"
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
34 #include "ov-fcn.h"
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
35 #include "ov-typeinfo.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
36 #include "symtab.h"
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
37
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
38 class string_vector;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
39
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
40 class octave_value;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
41 class tree_parameter_list;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
42 class tree_statement_list;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
43 class tree_va_return_list;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
44 class tree_walker;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
45
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
46 class
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
47 octave_user_code : public octave_function
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
48 {
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
49 public:
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
50 octave_user_code (void)
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
51 : octave_function () { }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
52
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
53 ~octave_user_code (void) { }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
54
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
55 bool is_user_code (void) const { return true; }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
56
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
57 virtual tree_statement_list *body (void) = 0;
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
58
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
59 protected:
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
60
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
61 octave_user_code (const std::string& nm,
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
62 const std::string& ds = std::string ())
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
63 : octave_function (nm, ds) { }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
64
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
65 private:
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
66
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
67 // No copying!
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
68
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
69 octave_user_code (const octave_user_code& f);
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
70
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
71 octave_user_code& operator = (const octave_user_code& f);
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
72 };
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
73
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
74 // Scripts.
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
75
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
76 class
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
77 octave_user_script : public octave_user_code
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
78 {
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
79 public:
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
80
7731
2d2a969c731c fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents: 7719
diff changeset
81 octave_user_script (void);
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
82
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
83 octave_user_script (const std::string& fnm, const std::string& nm,
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
84 tree_statement_list *cmds,
7731
2d2a969c731c fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents: 7719
diff changeset
85 const std::string& ds = std::string ());
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
86
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
87 octave_user_script (const std::string& fnm, const std::string& nm,
7731
2d2a969c731c fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents: 7719
diff changeset
88 const std::string& ds = std::string ());
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
89
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
90 ~octave_user_script (void);
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
91
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
92 octave_function *function_value (bool = false) { return this; }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
93
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
94 const octave_function *function_value (bool = false) const { return this; }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
95
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
96 octave_user_script *user_script_value (bool = false) { return this; }
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
97
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
98 octave_user_code *user_code_value (bool = false) { return this; }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
99
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
100 // Scripts and user functions are both considered "scripts" because
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
101 // they are written in Octave's scripting language.
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
102
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
103 bool is_user_script (void) const { return true; }
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
104
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
105 void stash_fcn_file_name (const std::string& nm) { file_name = nm; }
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
106
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
107 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
108
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
109 void stash_fcn_file_time (const octave_time& t)
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
110 {
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
111 t_parsed = t;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
112 mark_fcn_file_up_to_date (t);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
113 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
114
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
115 std::string fcn_file_name (void) const { return file_name; }
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
116
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
117 octave_time time_parsed (void) const { return t_parsed; }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
118
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
119 octave_time time_checked (void) const { return t_checked; }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
120
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
121 octave_value subsref (const std::string& type,
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
122 const std::list<octave_value_list>& idx)
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
123 {
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
124 octave_value_list tmp = subsref (type, idx, 1);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
125 return tmp.length () > 0 ? tmp(0) : octave_value ();
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
126 }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
127
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
128 octave_value_list subsref (const std::string& type,
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
129 const std::list<octave_value_list>& idx,
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
130 int nargout);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
131
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
132 octave_value_list
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
133 do_multi_index_op (int nargout, const octave_value_list& args);
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
134
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
135 tree_statement_list *body (void) { return cmd_list; }
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
136
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
137 void traceback_error (void) const;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
138
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
139 void accept (tree_walker& tw);
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
140
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
141 private:
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
142
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
143 // The list of commands that make up the body of this function.
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
144 tree_statement_list *cmd_list;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
145
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
146 // The name of the file we parsed.
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
147 std::string file_name;
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
148
7715
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
149 // The time the file was parsed.
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
150 octave_time t_parsed;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
151
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
152 // The time the file was last checked to see if it needs to be
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
153 // parsed again.
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
154 octave_time t_checked;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
155
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
156 // Used to keep track of recursion depth.
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
157 int call_depth;
5b4d278ec828 parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents: 7651
diff changeset
158
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
159 // No copying!
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
160
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
161 octave_user_script (const octave_user_script& f);
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
162
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
163 octave_user_script& operator = (const octave_user_script& f);
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
164
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
165 DECLARE_OCTAVE_ALLOCATOR
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
166
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
167 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
168 };
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
169
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5307
diff changeset
170 // User-defined functions.
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
171
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
172 class
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
173 octave_user_function : public octave_user_code
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
174 {
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
175 public:
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
176
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
177 octave_user_function (symbol_table::scope_id sid = -1,
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
178 tree_parameter_list *pl = 0,
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
179 tree_parameter_list *rl = 0,
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
180 tree_statement_list *cl = 0);
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
181
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
182 ~octave_user_function (void);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
183
4654
a9b22513b7a6 [project @ 2003-11-24 18:56:35 by jwe]
jwe
parents: 4645
diff changeset
184 octave_function *function_value (bool = false) { return this; }
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
185
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
186 const octave_function *function_value (bool = false) const { return this; }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
187
4700
ca3a1d687bba [project @ 2004-01-21 03:28:31 by jwe]
jwe
parents: 4661
diff changeset
188 octave_user_function *user_function_value (bool = false) { return this; }
ca3a1d687bba [project @ 2004-01-21 03:28:31 by jwe]
jwe
parents: 4661
diff changeset
189
7719
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
190 octave_user_code *user_code_value (bool = false) { return this; }
87eda1f8faaa octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents: 7715
diff changeset
191
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
192 octave_user_function *define_param_list (tree_parameter_list *t);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
193
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
194 octave_user_function *define_ret_list (tree_parameter_list *t);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
195
4343
db5e0814277a [project @ 2003-02-20 16:44:16 by jwe]
jwe
parents: 4271
diff changeset
196 void stash_fcn_file_name (const std::string& nm);
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
197
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
198 void stash_parent_fcn_name (const std::string& p) { parent_name = p; }
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
199
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
200 void stash_leading_comment (octave_comment_list *lc) { lead_comm = lc; }
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
201
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
202 void stash_trailing_comment (octave_comment_list *tc) { trail_comm = tc; }
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
203
3325
2efa28a91e7a [project @ 1999-10-29 21:39:20 by jwe]
jwe
parents: 3255
diff changeset
204 void mark_fcn_file_up_to_date (const octave_time& t) { t_checked = t; }
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
205
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 3239
diff changeset
206 void stash_fcn_file_time (const octave_time& t)
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
207 {
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
208 t_parsed = t;
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
209 mark_fcn_file_up_to_date (t);
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
210 }
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
211
4346
d39de791ef9c [project @ 2003-02-20 21:38:39 by jwe]
jwe
parents: 4343
diff changeset
212 std::string fcn_file_name (void) const { return file_name; }
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
213
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
214 std::string parent_fcn_name (void) const { return parent_name; }
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
215
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
216 symbol_table::scope_id scope (void) { return local_scope; }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
217
4346
d39de791ef9c [project @ 2003-02-20 21:38:39 by jwe]
jwe
parents: 4343
diff changeset
218 octave_time time_parsed (void) const { return t_parsed; }
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
219
4346
d39de791ef9c [project @ 2003-02-20 21:38:39 by jwe]
jwe
parents: 4343
diff changeset
220 octave_time time_checked (void) const { return t_checked; }
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
221
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
222 void mark_as_system_fcn_file (void);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
223
4346
d39de791ef9c [project @ 2003-02-20 21:38:39 by jwe]
jwe
parents: 4343
diff changeset
224 bool is_system_fcn_file (void) const { return system_fcn_file; }
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
225
4748
7b145222fea3 [project @ 2004-02-07 06:27:27 by jwe]
jwe
parents: 4700
diff changeset
226 bool is_user_function (void) const { return true; }
7b145222fea3 [project @ 2004-02-07 06:27:27 by jwe]
jwe
parents: 4700
diff changeset
227
7876
8447a5024650 clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents: 7761
diff changeset
228 void erase_subfunctions (void)
8447a5024650 clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents: 7761
diff changeset
229 {
8447a5024650 clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents: 7761
diff changeset
230 symbol_table::erase_subfunctions_in_scope (local_scope);
8447a5024650 clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents: 7761
diff changeset
231 }
8447a5024650 clear subfunctions when clearing parent function
John W. Eaton <jwe@octave.org>
parents: 7761
diff changeset
232
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
233 bool takes_varargs (void) const;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
234
5848
415ae81d331b [project @ 2006-06-08 20:37:29 by jwe]
jwe
parents: 5744
diff changeset
235 bool takes_var_return (void) const;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
236
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
237 void lock_subfunctions (void);
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
238
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
239 void unlock_subfunctions (void);
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
240
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
241 octave_value_list octave_all_va_args (void);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
242
4748
7b145222fea3 [project @ 2004-02-07 06:27:27 by jwe]
jwe
parents: 4700
diff changeset
243 void stash_function_name (const std::string& s) { my_name = s; }
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
244
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4219
diff changeset
245 void mark_as_nested_function (void) { nested_function = true; }
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4219
diff changeset
246
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4219
diff changeset
247 bool is_nested_function (void) const { return nested_function; }
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4219
diff changeset
248
6149
3a68a2dc6eb1 [project @ 2006-11-09 18:26:56 by jwe]
jwe
parents: 5848
diff changeset
249 void mark_as_inline_function (void) { inline_function = true; }
3a68a2dc6eb1 [project @ 2006-11-09 18:26:56 by jwe]
jwe
parents: 5848
diff changeset
250
3a68a2dc6eb1 [project @ 2006-11-09 18:26:56 by jwe]
jwe
parents: 5848
diff changeset
251 bool is_inline_function (void) const { return inline_function; }
3a68a2dc6eb1 [project @ 2006-11-09 18:26:56 by jwe]
jwe
parents: 5848
diff changeset
252
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
253 void mark_as_class_constructor (void) { class_constructor = true; }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
254
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
255 bool is_class_constructor (void) const { return class_constructor; }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
256
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
257 void mark_as_class_method (void) { class_method = true; }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
258
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
259 bool is_class_method (void) const { return class_method; }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
260
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
261 void stash_dispatch_class (const std::string& nm) { xdispatch_class = nm; }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
262
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
263 std::string dispatch_class (void) const { return xdispatch_class; }
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
264
3875
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
265 void save_args_passed (const octave_value_list& args)
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
266 {
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7731
diff changeset
267 if (call_depth > 0)
3875
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
268 saved_args.push (args_passed);
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
269
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
270 args_passed = args;
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
271 }
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
272
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
273 void restore_args_passed (void)
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
274 {
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3875
diff changeset
275 if (saved_args.empty ())
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3875
diff changeset
276 args_passed = octave_value_list ();
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3875
diff changeset
277 else
4214
b9317f3973ec [project @ 2002-12-04 04:57:01 by jwe]
jwe
parents: 4192
diff changeset
278 {
b9317f3973ec [project @ 2002-12-04 04:57:01 by jwe]
jwe
parents: 4192
diff changeset
279 args_passed = saved_args.top ();
b9317f3973ec [project @ 2002-12-04 04:57:01 by jwe]
jwe
parents: 4192
diff changeset
280 saved_args.pop ();
b9317f3973ec [project @ 2002-12-04 04:57:01 by jwe]
jwe
parents: 4192
diff changeset
281 }
3875
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
282 }
3239
d54ef0aa6e82 [project @ 1999-03-27 17:40:45 by jwe]
jwe
parents: 3219
diff changeset
283
7651
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
284 octave_value subsref (const std::string& type,
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
285 const std::list<octave_value_list>& idx)
4271
be631c1720ea [project @ 2003-01-03 19:36:04 by jwe]
jwe
parents: 4247
diff changeset
286 {
7651
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
287 octave_value_list tmp = subsref (type, idx, 1);
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7336
diff changeset
288 return tmp.length () > 0 ? tmp(0) : octave_value ();
4271
be631c1720ea [project @ 2003-01-03 19:36:04 by jwe]
jwe
parents: 4247
diff changeset
289 }
be631c1720ea [project @ 2003-01-03 19:36:04 by jwe]
jwe
parents: 4247
diff changeset
290
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4238
diff changeset
291 octave_value_list subsref (const std::string& type,
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4214
diff changeset
292 const std::list<octave_value_list>& idx,
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3875
diff changeset
293 int nargout);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3875
diff changeset
294
3544
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3523
diff changeset
295 octave_value_list
71bd2d124119 [project @ 2000-02-02 21:02:31 by jwe]
jwe
parents: 3523
diff changeset
296 do_multi_index_op (int nargout, const octave_value_list& args);
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
297
4346
d39de791ef9c [project @ 2003-02-20 21:38:39 by jwe]
jwe
parents: 4343
diff changeset
298 void traceback_error (void) const;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
299
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
300 tree_parameter_list *parameter_list (void) { return param_list; }
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
301
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
302 tree_parameter_list *return_list (void) { return ret_list; }
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
303
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
304 tree_statement_list *body (void) { return cmd_list; }
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
305
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
306 octave_comment_list *leading_comment (void) { return lead_comm; }
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
307
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
308 octave_comment_list *trailing_comment (void) { return trail_comm; }
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
309
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
310 void accept (tree_walker& tw);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
311
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
312 #if 0
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3875
diff changeset
313 void print_symtab_info (std::ostream& os) const;
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
314 #endif
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3875
diff changeset
315
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
316 private:
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
317
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
318 // List of arguments for this function. These are local variables.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
319 tree_parameter_list *param_list;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
320
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
321 // List of parameters we return. These are also local variables in
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
322 // this function.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
323 tree_parameter_list *ret_list;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
324
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
325 // The list of commands that make up the body of this function.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
326 tree_statement_list *cmd_list;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
327
3665
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
328 // The comments preceding the FUNCTION token.
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
329 octave_comment_list *lead_comm;
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
330
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
331 // The comments preceding the ENDFUNCTION token.
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
332 octave_comment_list *trail_comm;
0689afb1d001 [project @ 2000-05-11 19:07:56 by jwe]
jwe
parents: 3544
diff changeset
333
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
334 // The name of the file we parsed.
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3325
diff changeset
335 std::string file_name;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
336
6323
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
337 // The name of the parent function, if any.
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
338 std::string parent_name;
ea65de49e18e [project @ 2007-02-17 02:51:02 by jwe]
jwe
parents: 6149
diff changeset
339
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
340 // The time the file was parsed.
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 3239
diff changeset
341 octave_time t_parsed;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
342
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
343 // The time the file was last checked to see if it needs to be
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
344 // parsed again.
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 3239
diff changeset
345 octave_time t_checked;
3165
e4bbfc196e53 [project @ 1998-04-16 03:01:47 by jwe]
jwe
parents: 2974
diff changeset
346
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
347 // True if this function came from a file that is considered to be a
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
348 // system function. This affects whether we check the time stamp
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
349 // on the file to see if it has changed.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
350 bool system_fcn_file;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
351
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
352 // Used to keep track of recursion depth.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
353 int call_depth;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
354
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
355 // The number of arguments that have names.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
356 int num_named_args;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
357
4238
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4219
diff changeset
358 // TRUE means this is a nested function.
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4219
diff changeset
359 bool nested_function;
a5a68c0afe56 [project @ 2002-12-25 21:04:33 by jwe]
jwe
parents: 4219
diff changeset
360
6149
3a68a2dc6eb1 [project @ 2006-11-09 18:26:56 by jwe]
jwe
parents: 5848
diff changeset
361 // TRUE means this is an inline function.
3a68a2dc6eb1 [project @ 2006-11-09 18:26:56 by jwe]
jwe
parents: 5848
diff changeset
362 bool inline_function;
3a68a2dc6eb1 [project @ 2006-11-09 18:26:56 by jwe]
jwe
parents: 5848
diff changeset
363
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
364 // TRUE means this function is the constructor for class object.
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
365 bool class_constructor;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
366
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
367 // TRUE means this function is a method for a class.
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
368 bool class_method;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
369
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
370 // If this object is a class method or constructor, this is the name
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
371 // of the class to which the method belongs.
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
372 std::string xdispatch_class;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
373
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
374 // The values that were passed as arguments.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
375 octave_value_list args_passed;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
376
3875
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
377 // A place to store the passed args for recursive calls.
4214
b9317f3973ec [project @ 2002-12-04 04:57:01 by jwe]
jwe
parents: 4192
diff changeset
378 std::stack<octave_value_list> saved_args;
3875
09323fcea5ab [project @ 2002-03-06 17:59:40 by jwe]
jwe
parents: 3805
diff changeset
379
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
380 // The number of arguments passed in.
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
381 int num_args_passed;
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
382
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
383 symbol_table::scope_id local_scope;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
384
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
385 #if 0
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
386 // The symbol record for argn in the local symbol table.
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
387 octave_value& argn_varref;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
388
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
389 // The symbol record for nargin in the local symbol table.
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
390 octave_value& nargin_varref;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
391
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
392 // The symbol record for nargout in the local symbol table.
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
393 octave_value& nargout_varref;
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
394
3974
e2290bf911f0 [project @ 2002-07-04 17:38:22 by jwe]
jwe
parents: 3933
diff changeset
395 // The symbol record for varargin in the local symbol table.
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
396 octave_value& varargin_varref;
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
397 #endif
3974
e2290bf911f0 [project @ 2002-07-04 17:38:22 by jwe]
jwe
parents: 3933
diff changeset
398
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
399 void print_code_function_header (void);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
400
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
401 void print_code_function_trailer (void);
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
402
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
403 void bind_automatic_vars (const string_vector& arg_names, int nargin,
3974
e2290bf911f0 [project @ 2002-07-04 17:38:22 by jwe]
jwe
parents: 3933
diff changeset
404 int nargout, const octave_value_list& va_args);
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3165
diff changeset
405
4645
bd2067547b40 [project @ 2003-11-23 08:07:52 by jwe]
jwe
parents: 4639
diff changeset
406 // No copying!
bd2067547b40 [project @ 2003-11-23 08:07:52 by jwe]
jwe
parents: 4639
diff changeset
407
bd2067547b40 [project @ 2003-11-23 08:07:52 by jwe]
jwe
parents: 4639
diff changeset
408 octave_user_function (const octave_user_function& fn);
bd2067547b40 [project @ 2003-11-23 08:07:52 by jwe]
jwe
parents: 4639
diff changeset
409
bd2067547b40 [project @ 2003-11-23 08:07:52 by jwe]
jwe
parents: 4639
diff changeset
410 octave_user_function& operator = (const octave_user_function& fn);
bd2067547b40 [project @ 2003-11-23 08:07:52 by jwe]
jwe
parents: 4639
diff changeset
411
4612
d44675070f1a [project @ 2003-11-14 19:49:56 by jwe]
jwe
parents: 4346
diff changeset
412 DECLARE_OCTAVE_ALLOCATOR
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3165
diff changeset
413
4612
d44675070f1a [project @ 2003-11-14 19:49:56 by jwe]
jwe
parents: 4346
diff changeset
414 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
2974
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
415 };
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
416
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
417 #endif
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
418
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
419 /*
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
420 ;;; Local Variables: ***
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
421 ;;; mode: C++ ***
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
422 ;;; End: ***
ebbc34ff7f66 [project @ 1997-05-15 19:36:16 by jwe]
jwe
parents:
diff changeset
423 */