Mercurial > hg > octave-lyh
changeset 2892:aef2d43edbc2
[project @ 1997-04-28 02:04:28 by jwe]
author | jwe |
---|---|
date | Mon, 28 Apr 1997 02:04:28 +0000 |
parents | 1a30f46e1870 |
children | 9fd1df4b464a |
files | src/variables.cc src/variables.h |
diffstat | 2 files changed, 55 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/src/variables.cc +++ b/src/variables.cc @@ -46,6 +46,7 @@ #endif #include "file-ops.h" +#include "lo-mappers.h" #include "oct-glob.h" #include "str-vec.h" @@ -69,11 +70,15 @@ #include "parse.h" #include "symtab.h" #include "sysdep.h" +#include "oct-sym.h" +#include "oct-builtin.h" +#include "oct-mapper.h" +#include "oct-usr-fcn.h" #include "pt-const.h" #include "oct-obj.h" #include "pt-exp.h" -#include "pt-fcn.h" -#include "pt-fvc.h" +#include "pt-id.h" +#include "pt-indir.h" #include "pt-mat.h" #include "pt-plot.h" #include "pr-output.h" @@ -237,10 +242,10 @@ // Is this octave_value a valid function? -tree_fvc * +octave_symbol * is_valid_function (const octave_value& arg, const string& warn_for, bool warn) { - tree_fvc *ans = 0; + octave_symbol *ans = 0; string fcn_name; @@ -274,12 +279,12 @@ return ans; } -tree_fvc * +octave_symbol * extract_function (const octave_value& arg, const string& warn_for, const string& fname, const string& header, const string& trailer) { - tree_fvc *retval = 0; + octave_symbol *retval = 0; retval = is_valid_function (arg, warn_for, 0); @@ -449,7 +454,7 @@ if (sr) { - tree_fvc *ans = sr->def (); + octave_symbol *ans = sr->def (); if (ans) { string ff = ans->fcn_file_name (); @@ -843,12 +848,10 @@ if (sr) { - // Do something with the value in foo. - - tree_fvc *sr_def = sr->def (); + octave_symbol *sr_def = sr->def (); if (sr_def) - retval = sr_def->eval (true); + retval = sr_def->eval (); else error ("get_global_by_name: undefined symbol `%s'", nm.c_str ()); } @@ -907,7 +910,7 @@ string retval; - tree_fvc *defn = sr->def (); + octave_symbol *defn = sr->def (); if (defn) { @@ -934,7 +937,7 @@ assert (sr); - tree_fvc *defn = sr->def (); + octave_symbol *defn = sr->def (); if (defn) { @@ -963,7 +966,7 @@ assert (sr); - tree_fvc *defn = sr->def (); + octave_symbol *defn = sr->def (); if (defn) retval = defn->eval (); @@ -1405,31 +1408,34 @@ // Install variables and functions in the symbol tables. void -install_builtin_mapper (const builtin_mapper_function& mf) +install_builtin_mapper (octave_mapper *mf) { - symbol_record *sym_rec = global_sym_tab->lookup (mf.name, true); - sym_rec->unprotect (); + symbol_record *sym_rec = global_sym_tab->lookup (mf->name (), true); - tree_builtin *def = new tree_builtin (mf, mf.name); + unsigned int t + = symbol_def::BUILTIN_FUNCTION | symbol_def::MAPPER_FUNCTION; - sym_rec->define (def); - - sym_rec->document (mf.help_string); + sym_rec->unprotect (); + sym_rec->define (mf, t); + sym_rec->document (mf->doc_string ()); sym_rec->make_eternal (); sym_rec->protect (); } void -install_builtin_function (const builtin_function& f) +install_builtin_function (octave_builtin *f, bool is_text_fcn) { - symbol_record *sym_rec = global_sym_tab->lookup (f.name, true); - sym_rec->unprotect (); + symbol_record *sym_rec = global_sym_tab->lookup (f->name (), true); + + unsigned int t + = symbol_def::BUILTIN_FUNCTION | symbol_def::MAPPER_FUNCTION; - tree_builtin *def = new tree_builtin (f.fcn, f.name); + if (is_text_fcn) + t |= symbol_def::TEXT_FUNCTION; - sym_rec->define (def, f.is_text_fcn); - - sym_rec->document (f.help_string); + sym_rec->unprotect (); + sym_rec->define (f, t); + sym_rec->document (f->doc_string ()); sym_rec->make_eternal (); sym_rec->protect (); } @@ -1705,10 +1711,10 @@ symbols_of_input (); symbols_of_lex (); symbols_of_load_save (); + symbols_of_oct_usr_fcn (); symbols_of_pager (); symbols_of_parse (); symbols_of_pr_output (); - symbols_of_pt_fcn (); symbols_of_pt_mat (); symbols_of_pt_plot (); symbols_of_syscalls ();
--- a/src/variables.h +++ b/src/variables.h @@ -23,22 +23,22 @@ #if !defined (octave_variables_h) #define octave_variables_h 1 +class octave_symbol; class symbol_record; class symbol_table; -class tree_fvc; class tree_identifier; class tree_indirect_ref; class octave_value; class octave_value_list; +class octave_builtin; +class octave_mapper; class string_vector; #include <string> #include "ov.h" -struct builtin_mapper_function; - typedef int (*sv_Function)(void); struct builtin_variable @@ -90,18 +90,6 @@ typedef octave_value_list (*Octave_builtin_fcn)(const octave_value_list&, int); -struct builtin_function -{ - builtin_function (const string& n, bool itf, Octave_builtin_fcn f, - const string& h) - : name (n), is_text_fcn (itf), fcn (f), help_string (h) { } - - string name; - bool is_text_fcn; - Octave_builtin_fcn fcn; - string help_string; -}; - extern void initialize_symbol_tables (void); extern bool lookup (symbol_record *s, bool exec_script = true); @@ -131,20 +119,24 @@ extern bool is_builtin_function_name (const string&); extern bool is_globally_visible (const string&); -extern tree_fvc *is_valid_function (const octave_value&, const string&, - bool warn = false); +extern octave_symbol * +is_valid_function (const octave_value&, const string&, bool warn = false); -tree_fvc *extract_function (const octave_value& arg, const string& warn_for, - const string& fname, const string& header, - const string& trailer); +octave_symbol * +extract_function (const octave_value& arg, const string& warn_for, + const string& fname, const string& header, + const string& trailer); extern string_vector make_name_list (void); -extern void install_builtin_mapper (const builtin_mapper_function& mf); +extern void +install_builtin_mapper (octave_mapper *mf); -extern void install_builtin_function (const builtin_function& gf); +extern void +install_builtin_function (octave_builtin *f, bool is_text_fcn = false); -extern void install_builtin_variable (const builtin_variable& v); +extern void +install_builtin_variable (const builtin_variable& v); extern void install_builtin_variable_as_function (const string& name, @@ -161,11 +153,11 @@ extern void clear_global_error_variable (void *); -extern void bind_builtin_variable (const string&, const octave_value&, - bool protect = false, - bool eternal = false, - sv_Function f = (sv_Function) 0, - const string& help = string ()); +extern void +bind_builtin_variable (const string&, const octave_value&, + bool protect = false, bool eternal = false, + sv_Function f = (sv_Function) 0, + const string& help = string ()); extern void install_builtin_variables (void);