GNU Octave
4.0.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 2367 of file variables.cc.
Referenced by Fclear().
Definition at line 491 of file variables.cc.
Referenced by unique_symbol_name().
void bind_ans | ( | const octave_value & | val, |
bool | |||
) |
Definition at line 1980 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(), eval_string(), and tree_evaluator::visit_statement().
void bind_internal_variable | ( | const std::string & | fname, |
const octave_value & | val | ||
) |
Definition at line 2004 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(), Fdaspk(), Fdasrt(), Fdassl(), Flsode(), Fquad(), and G__eigs__().
void clear_mex_functions | ( | void | ) |
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 2200 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 2230 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 2301 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 2267 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 329 of file variables.cc.
References error(), symbol_table::is_global(), octave_value_list::length(), and print_usage().
Referenced by Fisglobal().
|
static |
Definition at line 2327 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 1643 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 140 of file variables.cc.
References error(), eval_string(), octave_value::is_string(), is_valid_function(), octave_value::string_value(), and warning().
Referenced by Farrayfun(), Fcellfun(), Fdaspk(), Fdasrt(), Fdassl(), Flsode(), Fquad(), Fquadcc(), and G__eigs__().
OCTAVE_EXPORT octave_value_list F__varval__ | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 2710 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 2450 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 581 of file variables.cc.
References error(), octave_value::length(), print_usage(), symbol_exist(), and warning().
OCTAVE_EXPORT octave_value_list Fisglobal | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 367 of file variables.cc.
References do_isglobal().
OCTAVE_EXPORT octave_value_list Fmislocked | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 2126 of file variables.cc.
References octave_call_stack::caller(), error(), 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 2757 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 2678 of file variables.cc.
References SET_INTERNAL_VARIABLE.
OCTAVE_EXPORT octave_value_list Fmlock | ( | const octave_value_list & | args, |
int | |||
) |
Definition at line 2061 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 2088 of file variables.cc.
References octave_call_stack::caller(), error(), munlock(), print_usage(), and octave_function::unlock().
OCTAVE_EXPORT octave_value_list Fwho | ( | const octave_value_list & | args, |
int | nargout | ||
) |
Definition at line 1877 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 1958 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 2659 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 241 of file variables.cc.
References discard_error_messages, discard_warning_messages, error_state, eval_string(), octave_value::is_classdef_object(), 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 1127 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 697 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 189 of file variables.cc.
References Array< T >::length().
octave_value get_top_level_value | ( | const std::string & | nm, |
bool | silent | ||
) |
Definition at line 714 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(), octave_value::is_string(), is_valid_function(), and octave_value::string_value().
|
inlinestatic |
Definition at line 226 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 295 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 689 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 2683 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(), and feval().
|
inlinestatic |
bool mislocked | ( | const std::string & | nm | ) |
Definition at line 2039 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().
void mlock | ( | void | ) |
Definition at line 2014 of file variables.cc.
References octave_call_stack::current(), error(), and octave_function::lock().
Referenced by G__init_fltk__(), G__init_gnuplot__(), install_variables_fcns(), and mexLock().
void munlock | ( | const std::string & | nm | ) |
Definition at line 2025 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 2158 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 1026 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 373 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 708 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 769 of file variables.cc.
References error(), error_state, octave_value_list::length(), print_usage(), try_local_protect(), wants_local_change(), and warning().
Referenced by F__lexer_debug_flag__(), F__parser_debug_flag__(), 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 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 | ( | int & | var, |
const octave_value_list & | args, | ||
int | nargout, | ||
const char * | nm, | ||
int | minval, | ||
int | maxval | ||
) |
Definition at line 848 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 889 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 929 of file variables.cc.
References error(), 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 966 of file variables.cc.
References error(), 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 725 of file variables.cc.
References symbol_table::top_level_assign().
int symbol_exist | ( | const std::string & | name, |
const std::string & | type | ||
) |
Definition at line 388 of file variables.cc.
References file_in_path(), load_path::find_fcn(), 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_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 755 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 495 of file variables.cc.
References GET_IDX, and symbol_exist().
Referenced by Farrayfun(), Fcellfun(), Fdaspk(), Fdasrt(), Fdassl(), Flsode(), Fquad(), Fquadcc(), and G__eigs__().
|
static |
Definition at line 733 of file variables.cc.
References error_with_cfn().
Referenced by set_internal_variable().
|
static |
Definition at line 2729 of file variables.cc.
|
static |
Definition at line 2664 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().