Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/pt-decl.h @ 15195:2fc554ffbc28
split libinterp from src
* libinterp: New directory. Move all files from src directory here
except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc,
mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh.
* libinterp/Makefile.am: New file, extracted from src/Makefile.am.
* src/Makefile.am: Delete everything except targets and definitions
needed to build and link main and utility programs.
* Makefile.am (SUBDIRS): Include libinterp in the list.
* autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not
src/dldfcn directory.
* configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not
src/octave.cc.
(DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src.
(AC_CONFIG_FILES): Include libinterp/Makefile in the list.
* find-docstring-files.sh: Look in libinterp, not src.
* gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in
libinterp, not src.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Aug 2012 16:23:39 -0400 |
parents | src/parse-tree/pt-decl.h@46b19589b593 |
children | 3f43e9d6d86e |
comparison
equal
deleted
inserted
replaced
15194:0f0b795044c3 | 15195:2fc554ffbc28 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 1996-2012 John W. Eaton | |
4 | |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #if !defined (octave_tree_decl_h) | |
24 #define octave_tree_decl_h 1 | |
25 | |
26 class tree_expression; | |
27 class tree_identifier; | |
28 | |
29 class tree_walker; | |
30 | |
31 #include <string> | |
32 | |
33 #include "base-list.h" | |
34 #include "oct-lvalue.h" | |
35 #include "pt-cmd.h" | |
36 #include "pt-id.h" | |
37 #include "symtab.h" | |
38 | |
39 // List of expressions that make up a declaration statement. | |
40 | |
41 class | |
42 tree_decl_elt | |
43 { | |
44 public: | |
45 | |
46 tree_decl_elt (tree_identifier *i = 0, tree_expression *e = 0) | |
47 : id (i), expr (e) { } | |
48 | |
49 ~tree_decl_elt (void); | |
50 | |
51 bool eval (void); | |
52 | |
53 bool is_defined (void) { return id ? id->is_defined () : false; } | |
54 | |
55 bool is_variable (void) { return id ? id->is_variable () : false; } | |
56 | |
57 void mark_as_formal_parameter (void) | |
58 { | |
59 if (id) | |
60 id->mark_as_formal_parameter (); | |
61 } | |
62 | |
63 bool lvalue_ok (void) { return id ? id->lvalue_ok () : false; } | |
64 | |
65 // Do not allow functions to return null values. | |
66 octave_value rvalue1 (int nargout = 1) | |
67 { | |
68 return id ? id->rvalue1 (nargout).storable_value () : octave_value (); | |
69 } | |
70 | |
71 octave_value_list rvalue (int nargout) | |
72 { | |
73 octave_value_list retval; | |
74 | |
75 if (nargout > 1) | |
76 error ("invalid number of output arguments in declaration list"); | |
77 else | |
78 retval = rvalue1 (nargout); | |
79 | |
80 return retval; | |
81 } | |
82 | |
83 octave_lvalue lvalue (void) { return id ? id->lvalue () : octave_lvalue (); } | |
84 | |
85 tree_identifier *ident (void) { return id; } | |
86 | |
87 tree_expression *expression (void) { return expr; } | |
88 | |
89 tree_decl_elt *dup (symbol_table::scope_id scope, | |
90 symbol_table::context_id context) const; | |
91 | |
92 void accept (tree_walker& tw); | |
93 | |
94 private: | |
95 | |
96 // An identifier to tag with the declared property. | |
97 tree_identifier *id; | |
98 | |
99 // An initializer expression (may be zero); | |
100 tree_expression *expr; | |
101 | |
102 // No copying! | |
103 | |
104 tree_decl_elt (const tree_decl_elt&); | |
105 | |
106 tree_decl_elt& operator = (const tree_decl_elt&); | |
107 }; | |
108 | |
109 class | |
110 tree_decl_init_list : public octave_base_list<tree_decl_elt *> | |
111 { | |
112 public: | |
113 | |
114 tree_decl_init_list (void) { } | |
115 | |
116 tree_decl_init_list (tree_decl_elt *t) { append (t); } | |
117 | |
118 ~tree_decl_init_list (void) | |
119 { | |
120 while (! empty ()) | |
121 { | |
122 iterator p = begin (); | |
123 delete *p; | |
124 erase (p); | |
125 } | |
126 } | |
127 | |
128 tree_decl_init_list *dup (symbol_table::scope_id scope, | |
129 symbol_table::context_id context) const; | |
130 | |
131 void accept (tree_walker& tw); | |
132 | |
133 private: | |
134 | |
135 // No copying! | |
136 | |
137 tree_decl_init_list (const tree_decl_init_list&); | |
138 | |
139 tree_decl_init_list& operator = (const tree_decl_init_list&); | |
140 }; | |
141 | |
142 // Base class for declaration commands -- global, static, etc. | |
143 | |
144 class | |
145 tree_decl_command : public tree_command | |
146 { | |
147 public: | |
148 | |
149 tree_decl_command (const std::string& n, int l = -1, int c = -1) | |
150 : tree_command (l, c), cmd_name (n), init_list (0) { } | |
151 | |
152 tree_decl_command (const std::string& n, tree_decl_init_list *t, | |
153 int l = -1, int c = -1) | |
154 : tree_command (l, c), cmd_name (n), init_list (t) { } | |
155 | |
156 ~tree_decl_command (void); | |
157 | |
158 tree_decl_init_list *initializer_list (void) { return init_list; } | |
159 | |
160 std::string name (void) { return cmd_name; } | |
161 | |
162 protected: | |
163 | |
164 // The name of this command -- global, static, etc. | |
165 std::string cmd_name; | |
166 | |
167 // The list of variables or initializers in this declaration command. | |
168 tree_decl_init_list *init_list; | |
169 | |
170 private: | |
171 | |
172 // No copying! | |
173 | |
174 tree_decl_command (const tree_decl_command&); | |
175 | |
176 tree_decl_command& operator = (const tree_decl_command&); | |
177 }; | |
178 | |
179 // Global. | |
180 | |
181 class | |
182 tree_global_command : public tree_decl_command | |
183 { | |
184 public: | |
185 | |
186 tree_global_command (int l = -1, int c = -1) | |
187 : tree_decl_command ("global", l, c) { } | |
188 | |
189 tree_global_command (tree_decl_init_list *t, int l = -1, int c = -1) | |
190 : tree_decl_command ("global", t, l, c) { } | |
191 | |
192 ~tree_global_command (void) { } | |
193 | |
194 tree_command *dup (symbol_table::scope_id scope, | |
195 symbol_table::context_id context) const; | |
196 | |
197 void accept (tree_walker& tw); | |
198 | |
199 private: | |
200 | |
201 static void do_init (tree_decl_elt& elt); | |
202 | |
203 // No copying! | |
204 | |
205 tree_global_command (const tree_global_command&); | |
206 | |
207 tree_global_command& operator = (const tree_global_command&); | |
208 }; | |
209 | |
210 // Persistent. | |
211 | |
212 class | |
213 tree_persistent_command : public tree_decl_command | |
214 { | |
215 public: | |
216 | |
217 tree_persistent_command (int l = -1, int c = -1) | |
218 : tree_decl_command ("persistent", l, c) { } | |
219 | |
220 tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1) | |
221 : tree_decl_command ("persistent", t, l, c) { } | |
222 | |
223 ~tree_persistent_command (void) { } | |
224 | |
225 tree_command *dup (symbol_table::scope_id scope, | |
226 symbol_table::context_id context) const; | |
227 | |
228 void accept (tree_walker& tw); | |
229 | |
230 private: | |
231 | |
232 static void do_init (tree_decl_elt& elt); | |
233 | |
234 // No copying! | |
235 | |
236 tree_persistent_command (const tree_persistent_command&); | |
237 | |
238 tree_persistent_command& operator = (const tree_persistent_command&); | |
239 }; | |
240 | |
241 #endif |