Mercurial > octave-nkf
comparison libinterp/octave-value/ov-usr-fcn.cc @ 16644:856cb7cba231 classdef
maint: periodic merge of default to classdef
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 12 May 2013 21:45:57 -0400 |
parents | 2ed5bc680c71 de91b1621260 |
children | 498b2dd1bd56 |
comparison
equal
deleted
inserted
replaced
16595:8abae9ea4cb5 | 16644:856cb7cba231 |
---|---|
56 #include "ov-fcn-handle.h" | 56 #include "ov-fcn-handle.h" |
57 | 57 |
58 // Whether to optimize subsasgn method calls. | 58 // Whether to optimize subsasgn method calls. |
59 static bool Voptimize_subsasgn_calls = true; | 59 static bool Voptimize_subsasgn_calls = true; |
60 | 60 |
61 | |
62 std::map<std::string, octave_value> | |
63 octave_user_code::subfunctions (void) const | |
64 { | |
65 return std::map<std::string, octave_value> (); | |
66 } | |
67 | |
61 // User defined scripts. | 68 // User defined scripts. |
62 | 69 |
63 DEFINE_OCTAVE_ALLOCATOR (octave_user_script); | 70 DEFINE_OCTAVE_ALLOCATOR (octave_user_script); |
64 | 71 |
65 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_user_script, | 72 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_user_script, |
221 | 228 |
222 #ifdef HAVE_LLVM | 229 #ifdef HAVE_LLVM |
223 delete jit_info; | 230 delete jit_info; |
224 #endif | 231 #endif |
225 | 232 |
233 // FIXME -- this is really playing with fire. | |
226 symbol_table::erase_scope (local_scope); | 234 symbol_table::erase_scope (local_scope); |
227 } | 235 } |
228 | 236 |
229 octave_user_function * | 237 octave_user_function * |
230 octave_user_function::define_ret_list (tree_parameter_list *t) | 238 octave_user_function::define_ret_list (tree_parameter_list *t) |
236 | 244 |
237 void | 245 void |
238 octave_user_function::stash_fcn_file_name (const std::string& nm) | 246 octave_user_function::stash_fcn_file_name (const std::string& nm) |
239 { | 247 { |
240 file_name = nm; | 248 file_name = nm; |
249 } | |
250 | |
251 // If there is no explicit end statement at the end of the function, | |
252 // relocate the no_op that was generated for the end of file condition | |
253 // to appear on the next line after the last statement in the file, or | |
254 // the next line after the function keyword if there are no statements. | |
255 // More precisely, the new location should probably be on the next line | |
256 // after the end of the parameter list, but we aren't tracking that | |
257 // information (yet). | |
258 | |
259 void | |
260 octave_user_function::maybe_relocate_end_internal (void) | |
261 { | |
262 if (cmd_list && ! cmd_list->empty ()) | |
263 { | |
264 tree_statement *last_stmt = cmd_list->back (); | |
265 | |
266 if (last_stmt && last_stmt->is_end_of_fcn_or_script () | |
267 && last_stmt->is_end_of_file ()) | |
268 { | |
269 tree_statement_list::reverse_iterator | |
270 next_to_last_elt = cmd_list->rbegin (); | |
271 | |
272 next_to_last_elt++; | |
273 | |
274 int new_eof_line; | |
275 int new_eof_col; | |
276 | |
277 if (next_to_last_elt == cmd_list->rend ()) | |
278 { | |
279 new_eof_line = beginning_line (); | |
280 new_eof_col = beginning_column (); | |
281 } | |
282 else | |
283 { | |
284 tree_statement *next_to_last_stmt = *next_to_last_elt; | |
285 | |
286 new_eof_line = next_to_last_stmt->line (); | |
287 new_eof_col = next_to_last_stmt->column (); | |
288 } | |
289 | |
290 last_stmt->set_location (new_eof_line + 1, new_eof_col); | |
291 } | |
292 } | |
293 } | |
294 | |
295 void | |
296 octave_user_function::maybe_relocate_end (void) | |
297 { | |
298 std::map<std::string, octave_value> fcns = subfunctions (); | |
299 | |
300 if (! fcns.empty ()) | |
301 { | |
302 for (std::map<std::string, octave_value>::iterator p = fcns.begin (); | |
303 p != fcns.end (); p++) | |
304 { | |
305 octave_user_function *f = (p->second).user_function_value (); | |
306 | |
307 if (f) | |
308 f->maybe_relocate_end_internal (); | |
309 } | |
310 } | |
311 | |
312 maybe_relocate_end_internal (); | |
241 } | 313 } |
242 | 314 |
243 std::string | 315 std::string |
244 octave_user_function::profiler_name (void) const | 316 octave_user_function::profiler_name (void) const |
245 { | 317 { |
302 | 374 |
303 void | 375 void |
304 octave_user_function::unlock_subfunctions (void) | 376 octave_user_function::unlock_subfunctions (void) |
305 { | 377 { |
306 symbol_table::unlock_subfunctions (local_scope); | 378 symbol_table::unlock_subfunctions (local_scope); |
379 } | |
380 | |
381 std::map<std::string, octave_value> | |
382 octave_user_function::subfunctions (void) const | |
383 { | |
384 return symbol_table::subfunctions_defined_in_scope (local_scope); | |
385 } | |
386 | |
387 bool | |
388 octave_user_function::has_subfunctions (void) const | |
389 { | |
390 return ! subfcn_names.empty (); | |
391 } | |
392 | |
393 void | |
394 octave_user_function::stash_subfunction_names | |
395 (const std::list<std::string>& names) | |
396 { | |
397 subfcn_names = names; | |
307 } | 398 } |
308 | 399 |
309 octave_value_list | 400 octave_value_list |
310 octave_user_function::all_va_args (const octave_value_list& args) | 401 octave_user_function::all_va_args (const octave_value_list& args) |
311 { | 402 { |