GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
|
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <set>
#include <string>
#include "file-stat.h"
#include "oct-env.h"
#include "file-ops.h"
#include "glob-match.h"
#include "lo-regexp.h"
#include "str-vec.h"
#include <defaults.h>
#include "Cell.h"
#include "defun.h"
#include "dirfns.h"
#include "error.h"
#include "gripes.h"
#include "help.h"
#include "input.h"
#include "lex.h"
#include "load-path.h"
#include "octave-link.h"
#include "oct-map.h"
#include "oct-obj.h"
#include "ov.h"
#include "ov-class.h"
#include "ov-usr-fcn.h"
#include "pager.h"
#include "parse.h"
#include "symtab.h"
#include "toplev.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"
Go to the source code of this file.
Classes | |
struct | symbol_info_list::symbol_info |
class | symbol_info_list |
struct | whos_parameter |
Macros | |
#define | CLEAR_OPTION_ERROR(cond) |
#define | GET_IDX(LEN) static_cast<int> ((LEN-1) * static_cast<double> (rand ()) / RAND_MAX) |
Functions | |
void | bind_ans (const octave_value &val, bool print) |
void | bind_internal_variable (const std::string &fname, const octave_value &val) |
void | clear_function (const std::string &nm) |
void | clear_mex_functions (void) |
void | clear_symbol (const std::string &nm) |
void | clear_variable (const std::string &nm) |
static void | do_clear_functions (const string_vector &argv, int argc, int idx, bool exclusive=false) |
static void | do_clear_globals (const string_vector &argv, int argc, int idx, bool exclusive=false) |
static void | do_clear_symbols (const string_vector &argv, int argc, int idx, bool exclusive=false) |
static void | do_clear_variables (const string_vector &argv, int argc, int idx, bool exclusive=false, bool have_regexp=false) |
static octave_value | do_isglobal (const octave_value_list &args) |
static void | do_matlab_compatible_clear (const string_vector &argv, int argc, int idx) |
static octave_value | do_who (int argc, const string_vector &argv, bool return_list, bool verbose=false, std::string msg=std::string()) |
octave_function * | extract_function (const octave_value &arg, const std::string &warn_for, const std::string &fname, const std::string &header, const std::string &trailer) |
OCTAVE_EXPORT octave_value_list | F__varval__ (const octave_value_list &args, int) |
OCTAVE_EXPORT octave_value_list | Fclear (const octave_value_list &args, int) |
OCTAVE_EXPORT octave_value_list | Fexist (const octave_value_list &args, int) |
OCTAVE_EXPORT octave_value_list | Fisglobal (const octave_value_list &args, int) |
OCTAVE_EXPORT octave_value_list | Fmislocked (const octave_value_list &args, int) |
OCTAVE_EXPORT octave_value_list | Fmissing_component_hook (const octave_value_list &args, int nargout) |
OCTAVE_EXPORT octave_value_list | Fmissing_function_hook (const octave_value_list &args, int nargout) |
OCTAVE_EXPORT octave_value_list | Fmlock (const octave_value_list &args, int) |
OCTAVE_EXPORT octave_value_list | Fmunlock (const octave_value_list &args, int) |
OCTAVE_EXPORT octave_value_list | Fwho (const octave_value_list &args, int nargout) |
OCTAVE_EXPORT octave_value_list | Fwhos (const octave_value_list &args, int nargout) |
OCTAVE_EXPORT octave_value_list | Fwhos_line_format (const octave_value_list &args, int nargout) |
string_vector | generate_struct_completions (const std::string &text, std::string &prefix, std::string &hint) |
std::string | get_dims_str (const octave_value &val) |
octave_value | get_global_value (const std::string &nm, bool silent) |
string_vector | get_struct_elts (const std::string &text) |
octave_value | get_top_level_value (const std::string &nm, bool silent) |
octave_function * | is_valid_function (const std::string &fcn_name, const std::string &warn_for, bool warn) |
octave_function * | is_valid_function (const octave_value &arg, const std::string &warn_for, bool warn) |
static bool | is_variable (const std::string &name) |
bool | looks_like_struct (const std::string &text) |
octave_value | lookup_function_handle (const std::string &nm) |
void | maybe_missing_function_hook (const std::string &name) |
static void | maybe_warn_exclusive (bool exclusive) |
bool | mislocked (const std::string &nm) |
void | mlock (void) |
void | munlock (const std::string &nm) |
static bool | name_matches_any_pattern (const std::string &nm, const string_vector &argv, int argc, int idx, bool have_regexp=false) |
static void | print_descriptor (std::ostream &os, std::list< whos_parameter > params) |
static octave_value | safe_symbol_lookup (const std::string &symbol_name) |
void | set_global_value (const std::string &nm, const octave_value &val) |
octave_value | set_internal_variable (bool &var, const octave_value_list &args, int nargout, const char *nm) |
octave_value | set_internal_variable (char &var, const octave_value_list &args, int nargout, const char *nm) |
octave_value | set_internal_variable (int &var, const octave_value_list &args, int nargout, const char *nm, int minval, int maxval) |
octave_value | set_internal_variable (double &var, const octave_value_list &args, int nargout, const char *nm, double minval, double maxval) |
octave_value | set_internal_variable (std::string &var, const octave_value_list &args, int nargout, const char *nm, bool empty_ok) |
octave_value | set_internal_variable (int &var, const octave_value_list &args, int nargout, const char *nm, const char **choices) |
void | set_top_level_value (const std::string &nm, const octave_value &val) |
int | symbol_exist (const std::string &name, const std::string &type) |
template<class T > | |
bool | try_local_protect (T &var) |
std::string | unique_symbol_name (const std::string &basename) |
static bool | wants_local_change (const octave_value_list &args, int &nargin) |
Variables | |
static std::string | Vmissing_component_hook |
static std::string | Vmissing_function_hook = "__unimplemented__" |
static std::string | Vwhos_line_format = " %a:4; %ln:6; %cs:16:6:1; %rb:12; %lc:-1;\n" |
#define CLEAR_OPTION_ERROR | ( | cond | ) |
Definition at line 2266 of file variables.cc.
Referenced by Fclear().
Definition at line 492 of file variables.cc.
Referenced by unique_symbol_name().
void bind_ans | ( | const octave_value & | val, |
bool | |||
) |
Definition at line 1884 of file variables.cc.
References bind_ans(), symbol_table::force_assign(), octave_value::is_cs_list(), octave_value::is_defined(), octave_value_list::length(), octave_value::list_value(), octave_stdout, and octave_value::print_with_name().
Referenced by bind_ans(), and tree_evaluator::visit_statement().
void bind_internal_variable | ( | const std::string & | fname, |
const octave_value & | val | ||
) |
Definition at line 1908 of file variables.cc.
References feval().
void clear_function | ( | const std::string & | nm | ) |
Definition at line 77 of file variables.cc.
References symbol_table::clear_function().
Referenced by symbol_table::clear_symbol(), DEFUN_DLD(), Fdaspk(), Fdasrt(), Fdassl(), Flsode(), and Fquad().
Definition at line 71 of file variables.cc.
References symbol_table::clear_mex_functions().
Referenced by do_octave_atexit().
void clear_symbol | ( | const std::string & | nm | ) |
Definition at line 89 of file variables.cc.
References symbol_table::clear_symbol().
void clear_variable | ( | const std::string & | nm | ) |
Definition at line 83 of file variables.cc.
References symbol_table::clear_variable().
Referenced by symbol_table::clear(), and symbol_table::clear_symbol().
|
static |
Definition at line 2100 of file variables.cc.
References symbol_table::clear_function(), symbol_table::clear_function_pattern(), symbol_table::clear_functions(), Array< T >::length(), name_matches_any_pattern(), and symbol_table::user_function_names().
Referenced by do_clear_symbols(), do_matlab_compatible_clear(), and Fclear().
|
static |
Definition at line 2130 of file variables.cc.
References symbol_table::clear_global(), symbol_table::clear_global_pattern(), symbol_table::global_variable_names(), Array< T >::length(), and name_matches_any_pattern().
Referenced by do_matlab_compatible_clear(), and Fclear().
|
static |
Definition at line 2201 of file variables.cc.
References symbol_table::clear_symbol_pattern(), symbol_table::clear_variables(), do_clear_functions(), and do_clear_variables().
Referenced by Fclear().
|
static |
Definition at line 2167 of file variables.cc.
References symbol_table::clear_variable(), symbol_table::clear_variable_pattern(), symbol_table::clear_variable_regexp(), symbol_table::clear_variables(), Array< T >::length(), name_matches_any_pattern(), and symbol_table::variable_names().
Referenced by do_clear_symbols(), and Fclear().
|
static |
Definition at line 331 of file variables.cc.
References error(), error_state, symbol_table::is_global(), octave_value_list::length(), and print_usage().
Referenced by Fisglobal().
|
static |
Definition at line 2227 of file variables.cc.
References symbol_table::clear_all(), octave_class::clear_exemplar_map(), symbol_table::clear_objects(), symbol_table::clear_symbol_pattern(), symbol_table::clear_variables(), do_clear_functions(), do_clear_globals(), and symbol_table::is_local_variable().
Referenced by Fclear().
|
static |
Definition at line 1552 of file variables.cc.
References action_container::add_fcn(), symbol_table::alloc_scope(), symbol_info_list::append(), octave_call_stack::caller(), symbol_table::clear_variables(), symbol_info_list::display(), symbol_info_list::empty(), symbol_table::erase_scope(), error(), error_state, eval_string(), feval(), symbol_table::find_symbol(), symbol_table::glob_global_variables(), symbol_table::glob_variables(), symbol_table::symbol_record::is_global(), symbol_table::is_variable(), string_vector::list_in_columns(), symbol_info_list::map_value(), octave_function::name(), names(), octave_stdout, octave_call_stack::pop(), octave_call_stack::push(), symbol_table::regexp_global_variables(), symbol_table::regexp_variables(), string_vector::resize(), symbol_table::set_scope(), and warning().
octave_function* extract_function | ( | const octave_value & | arg, |
const std::string & | warn_for, | ||
const std::string & | fname, | ||
const std::string & | header, | ||
const std::string & | trailer | ||
) |
Definition at line 143 of file variables.cc.
References error(), error_state, eval_string(), is_valid_function(), octave_value::string_value(), and warning().
Referenced by DEFUN_DLD(), Farrayfun(), Fcellfun(), Fdaspk(), Fdasrt(), Fdassl(), Flsode(), Fquad(), and Fquadcc().
OCTAVE_EXPORT octave_value_list F__varval__ | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 2604 of file variables.cc.
References error(), error_state, print_usage(), octave_value::string_value(), and symbol_table::varval().
OCTAVE_EXPORT octave_value_list Fclear | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 2346 of file variables.cc.
References symbol_table::clear_all(), octave_class::clear_exemplar_map(), symbol_table::clear_objects(), CLEAR_OPTION_ERROR, octave_link::clear_workspace(), do_clear_functions(), do_clear_globals(), do_clear_symbols(), do_clear_variables(), do_matlab_compatible_clear(), error_state, maybe_warn_exclusive(), octave_link::set_workspace(), and warning().
Referenced by main_window::clear_workspace_callback().
OCTAVE_EXPORT octave_value_list Fexist | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 552 of file variables.cc.
References error(), error_state, octave_value::length(), print_usage(), and symbol_exist().
OCTAVE_EXPORT octave_value_list Fisglobal | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 368 of file variables.cc.
References do_isglobal().
OCTAVE_EXPORT octave_value_list Fmislocked | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 2027 of file variables.cc.
References octave_call_stack::caller(), error(), error_state, octave_function::islocked(), mislocked(), print_usage(), and octave_value::string_value().
OCTAVE_EXPORT octave_value_list Fmissing_component_hook | ( | const octave_value_list & | args, |
int | nargout | ||
) |
Definition at line 2649 of file variables.cc.
References SET_INTERNAL_VARIABLE.
OCTAVE_EXPORT octave_value_list Fmissing_function_hook | ( | const octave_value_list & | args, |
int | nargout | ||
) |
Definition at line 2572 of file variables.cc.
References SET_INTERNAL_VARIABLE.
OCTAVE_EXPORT octave_value_list Fmlock | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 1965 of file variables.cc.
References octave_call_stack::caller(), error(), octave_function::lock(), and print_usage().
OCTAVE_EXPORT octave_value_list Fmunlock | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 1991 of file variables.cc.
References octave_call_stack::caller(), error(), error_state, munlock(), print_usage(), and octave_function::unlock().
OCTAVE_EXPORT octave_value_list Fwho | ( | const octave_value_list & | args, |
int | nargout | ||
) |
Definition at line 1784 of file variables.cc.
References do_who(), error_state, and print_usage().
OCTAVE_EXPORT octave_value_list Fwhos | ( | const octave_value_list & | args, |
int | nargout | ||
) |
Definition at line 1862 of file variables.cc.
References do_who(), error_state, and print_usage().
OCTAVE_EXPORT octave_value_list Fwhos_line_format | ( | const octave_value_list & | args, |
int | nargout | ||
) |
Definition at line 2553 of file variables.cc.
References SET_INTERNAL_VARIABLE.
string_vector generate_struct_completions | ( | const std::string & | text, |
std::string & | prefix, | ||
std::string & | hint | ||
) |
Definition at line 244 of file variables.cc.
References discard_error_messages, discard_warning_messages, error_state, eval_string(), octave_value::is_defined(), octave_value::is_java(), octave_value::is_map(), is_variable(), octave_value::map_keys(), names(), action_container::protect_var(), action_container::run(), and warning_state.
Referenced by generate_possible_completions().
std::string get_dims_str | ( | const octave_value & | val | ) |
Definition at line 1038 of file variables.cc.
References dim_vector::alloc(), dim_vector::length(), Array< T >::numel(), octave_value::size(), and dim_vector::str().
Referenced by symbol_info_list::symbol_info::display_line(), and symbol_info_list::parse_whos_line_format().
octave_value get_global_value | ( | const std::string & | nm, |
bool | silent | ||
) |
Definition at line 609 of file variables.cc.
References error(), symbol_table::global_varval(), and octave_value::is_undefined().
Referenced by mexGetVariable().
string_vector get_struct_elts | ( | const std::string & | text | ) |
Definition at line 192 of file variables.cc.
References Array< T >::length().
octave_value get_top_level_value | ( | const std::string & | nm, |
bool | silent | ||
) |
Definition at line 626 of file variables.cc.
References error(), octave_value::is_undefined(), and symbol_table::top_level_varval().
octave_function* is_valid_function | ( | const std::string & | fcn_name, |
const std::string & | warn_for, | ||
bool | warn | ||
) |
Definition at line 99 of file variables.cc.
References error(), symbol_table::find_function(), octave_value::function_value(), and octave_value::is_defined().
Referenced by extract_function(), Fdasrt(), named_hook_function::is_valid(), and is_valid_function().
octave_function* is_valid_function | ( | const octave_value & | arg, |
const std::string & | warn_for, | ||
bool | warn | ||
) |
Definition at line 120 of file variables.cc.
References error(), error_state, octave_value::is_string(), is_valid_function(), and octave_value::string_value().
|
inlinestatic |
Definition at line 229 of file variables.cc.
References octave_value::is_defined(), and symbol_table::varval().
Referenced by generate_struct_completions().
bool looks_like_struct | ( | const std::string & | text | ) |
Definition at line 297 of file variables.cc.
References file_ops::dir_sep_chars(), discard_error_messages, error_state, eval_string(), octave_value::is_defined(), octave_value::is_map(), action_container::protect_var(), and action_container::run().
Referenced by generate_completion(), and generate_possible_completions().
octave_value lookup_function_handle | ( | const std::string & | nm | ) |
Definition at line 601 of file variables.cc.
References octave_value::is_function_handle(), octave_value(), and symbol_table::varval().
void maybe_missing_function_hook | ( | const std::string & | name | ) |
Definition at line 2577 of file variables.cc.
References buffer_error_messages, feval(), symbol_table::find_function(), octave_value::is_defined(), action_container::protect_var(), and Vmissing_function_hook.
Referenced by tree_identifier::eval_undefined_error().
bool mislocked | ( | const std::string & | nm | ) |
Definition at line 1943 of file variables.cc.
References symbol_table::find_function(), octave_value::function_value(), octave_value::is_defined(), and octave_function::islocked().
Referenced by Fmislocked(), install_variables_fcns(), and mexIsLocked().
Definition at line 1918 of file variables.cc.
References octave_call_stack::current(), error(), and octave_function::lock().
Referenced by DEFUN_DLD(), install_variables_fcns(), and mexLock().
void munlock | ( | const std::string & | nm | ) |
Definition at line 1929 of file variables.cc.
References symbol_table::find_function(), octave_value::function_value(), octave_value::is_defined(), and octave_function::unlock().
Referenced by gnuplot_graphics_toolkit::close(), Fmunlock(), install_variables_fcns(), and mexUnlock().
|
inlinestatic |
Definition at line 2058 of file variables.cc.
References is_regexp_match(), and glob_match::match().
Referenced by do_clear_functions(), do_clear_globals(), and do_clear_variables().
|
static |
Definition at line 938 of file variables.cc.
References whos_parameter::balance, whos_parameter::command, whos_parameter::first_parameter_length, left, jit_convention::length, whos_parameter::line, whos_parameter::modifier, whos_parameter::parameter_length, and whos_parameter::text.
Referenced by symbol_info_list::display().
|
static |
Definition at line 374 of file variables.cc.
References error_state, symbol_table::find(), and interpreter_try().
Referenced by symbol_exist().
void set_global_value | ( | const std::string & | nm, |
const octave_value & | val | ||
) |
Definition at line 620 of file variables.cc.
References symbol_table::global_assign().
Referenced by mexPutVariable().
octave_value set_internal_variable | ( | bool & | var, |
const octave_value_list & | args, | ||
int | nargout, | ||
const char * | nm | ||
) |
Definition at line 681 of file variables.cc.
References error(), error_state, octave_value_list::length(), print_usage(), try_local_protect(), wants_local_change(), and warning().
Referenced by DEFUN(), Fhistory_control(), Fhistory_file(), Fhistory_save(), and Fhistory_size().
octave_value set_internal_variable | ( | char & | var, |
const octave_value_list & | args, | ||
int | nargout, | ||
const char * | nm | ||
) |
Definition at line 713 of file variables.cc.
References error(), error_state, octave_value_list::length(), print_usage(), try_local_protect(), wants_local_change(), and warning().
octave_value set_internal_variable | ( | int & | var, |
const octave_value_list & | args, | ||
int | nargout, | ||
const char * | nm, | ||
int | minval, | ||
int | maxval | ||
) |
Definition at line 760 of file variables.cc.
References error(), error_state, octave_value_list::length(), print_usage(), try_local_protect(), wants_local_change(), and warning().
octave_value set_internal_variable | ( | double & | var, |
const octave_value_list & | args, | ||
int | nargout, | ||
const char * | nm, | ||
double | minval, | ||
double | maxval | ||
) |
Definition at line 801 of file variables.cc.
References error(), error_state, octave_value_list::length(), print_usage(), try_local_protect(), wants_local_change(), and warning().
octave_value set_internal_variable | ( | std::string & | var, |
const octave_value_list & | args, | ||
int | nargout, | ||
const char * | nm, | ||
bool | empty_ok | ||
) |
Definition at line 841 of file variables.cc.
References error(), error_state, octave_value_list::length(), print_usage(), try_local_protect(), wants_local_change(), and warning().
octave_value set_internal_variable | ( | int & | var, |
const octave_value_list & | args, | ||
int | nargout, | ||
const char * | nm, | ||
const char ** | choices | ||
) |
Definition at line 878 of file variables.cc.
References error(), error_state, octave_value_list::length(), print_usage(), try_local_protect(), wants_local_change(), and warning().
void set_top_level_value | ( | const std::string & | nm, |
const octave_value & | val | ||
) |
Definition at line 637 of file variables.cc.
References symbol_table::top_level_assign().
int symbol_exist | ( | const std::string & | name, |
const std::string & | type | ||
) |
Definition at line 389 of file variables.cc.
References f, octave_function::fcn_file_name(), file_in_path(), load_path::find_fcn(), octave_value::function_value(), octave_value::is_anonymous_function(), octave_value::is_builtin_function(), octave_value::is_constant(), octave_value::is_defined(), base_file_stat::is_dir(), octave_value::is_dld_function(), octave_value::is_function_handle(), octave_value::is_inline_function(), is_keyword(), octave_value::is_object(), octave_value::is_user_function(), lookup_autoload(), safe_symbol_lookup(), and symbol_table::varval().
Referenced by Fexist(), and unique_symbol_name().
bool try_local_protect | ( | T & | var | ) |
Definition at line 667 of file variables.cc.
References octave_call_stack::caller_user_code(), octave_base_value::is_user_function(), and octave_user_function::local_protect().
Referenced by set_internal_variable().
std::string unique_symbol_name | ( | const std::string & | basename | ) |
Definition at line 496 of file variables.cc.
References GET_IDX, and symbol_exist().
Referenced by DEFUN_DLD(), Farrayfun(), Fcellfun(), Fdaspk(), Fdasrt(), Fdassl(), Flsode(), Fquad(), and Fquadcc().
|
static |
Definition at line 645 of file variables.cc.
References error_with_cfn().
Referenced by set_internal_variable().
|
static |
Definition at line 2623 of file variables.cc.
|
static |
Definition at line 2558 of file variables.cc.
Referenced by maybe_missing_function_hook().
|
static |
Definition at line 68 of file variables.cc.
Referenced by symbol_info_list::parse_whos_line_format().