# HG changeset patch # User jwe # Date 1038939771 0 # Node ID fa3482b345994060abde96246d3d1961b3fb0de5 # Parent fc514e47666eaddc0bc18ce84f83cfc7aaff503c [project @ 2002-12-03 18:22:05 by jwe] diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2002-12-03 John W. Eaton + + * configure.in: Dont't set SONAME_FLAGS for alpha alpha*-dec-osf* + systems. + +2002-11-29 Paul Kienzle + + * mkoctfile.in: Include "$incflags $def" in commands to generate + dependecies. + 2002-11-21 John W. Eaton * configure.in (do-subst-config-vals): Substitute OCTAVE_BINDIR. diff --git a/configure.in b/configure.in --- a/configure.in +++ b/configure.in @@ -22,7 +22,7 @@ ### 02111-1307, USA. AC_INIT -AC_REVISION($Revision: 1.396 $) +AC_REVISION($Revision: 1.397 $) AC_PREREQ(2.52) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -647,7 +647,6 @@ CXXPICFLAG= FPICFLAG= SH_LDFLAGS="-shared -Xlinker -expect_unresolved -Xlinker '*'" - SONAME_FLAGS='-Xlinker -soname -Xlinker $@' RLD_FLAG='-Xlinker -rpath -Xlinker $(octlibdir)' ;; *-*-darwin*) diff --git a/doc/ChangeLog b/doc/ChangeLog --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2002-11-24 John W. Eaton + + * interpreter/Makefile.in (maintainer-clean): Depend on + clean-texi, don't remove $(TEXINFO). + 2002-11-12 John W. Eaton * interpreter/munge-texi.cc: Use STL map class by default, but diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,30 @@ +2002-12-03 John W. Eaton + + * pt-jump.h, pt-jump.cc: Undo previous changes. + * parse.y: Undo previous changes for brea, continue, and return. + +2002-11-25 John W. Eaton + + * pt-stmt.cc (tree_statement::eval): Allow the lookup to execute + script files. If script file has been executed, don't bother to + call expr->rvalue (). + 2002-11-22 John W. Eaton + * Makefile.in (OCTINTERP_LINK_DEPS): Include $(FLIBS) in + OCTINTERP_LINK_DEPS. + + * variables.cc (text_function_set): New static data. + (mark_as_text_function, unmark_text_function, + is_marked_as_text_function, Fmark_as_text_function, + Funmark_text_function): New functions. + (is_text_function_name): Handle functions marked as text functions + in special list, not just those marked in the symbol record. + * symtab.h (symbol_record::mark_as_text_function, + symbol_record::unmark_text_function, + symbol_record::symbol_def::mark_as_text_function, + symbol_record::symbol_def::unmark_text_function): New functions. + * oct-map.h (Octave_map::rows, Octave_map::columns): New functions. * ov-struct.h (octave_struct::rows, octave_struct::columns, octave_struct::length): New functions. diff --git a/src/ov-usr-fcn.cc b/src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -466,11 +466,11 @@ if (echo_commands) print_code_function_trailer (); - if (tree_return_expression::returning) - tree_return_expression::returning = 0; + if (tree_return_command::returning) + tree_return_command::returning = 0; - if (tree_break_expression::breaking) - tree_break_expression::breaking--; + if (tree_break_command::breaking) + tree_break_command::breaking--; if (error_state) { diff --git a/src/parse.y b/src/parse.y --- a/src/parse.y +++ b/src/parse.y @@ -219,17 +219,17 @@ tree_expression *expr, tree_statement_list *body, token *end_tok, octave_comment_list *lc); -// Build a break expression. -static tree_expression * -make_break_expression (token *break_tok); - -// Build a continue expression. -static tree_expression * -make_continue_expression (token *continue_tok); - -// Build a return expression. -static tree_expression * -make_return_expression (token *return_tok); +// Build a break command. +static tree_command * +make_break_command (token *break_tok); + +// Build a continue command. +static tree_command * +make_continue_command (token *continue_tok); + +// Build a return command. +static tree_command * +make_return_command (token *return_tok); // Start an if command. static tree_if_command_list * @@ -418,9 +418,8 @@ %type matrix_rows matrix_rows1 %type cell_rows cell_rows1 %type title matrix cell -%type primary_expr postfix_expr prefix_expr -%type binary_expr simple_expr colon_expr -%type assign_expr jump_expr expression +%type primary_expr postfix_expr prefix_expr binary_expr +%type simple_expr colon_expr assign_expr expression %type identifier %type function1 function2 function3 %type word_list_cmd @@ -430,7 +429,7 @@ %type param_list param_list1 %type return_list return_list1 %type command select_command loop_command -%type except_command function +%type jump_command except_command function %type if_command %type elseif_clause else_clause %type if_cmd_list1 if_cmd_list @@ -787,8 +786,6 @@ simple_expr : colon_expr { $$ = $1; } - | jump_expr - { $$ = $1; } | simple_expr LSHIFT simple_expr { $$ = make_binary_op (LSHIFT, $1, $2, $3); } | simple_expr RSHIFT simple_expr @@ -894,6 +891,8 @@ { $$ = $1; } | loop_command { $$ = $1; } + | jump_command + { $$ = $1; } | except_command { $$ = $1; } | function @@ -1042,19 +1041,19 @@ // Jumping // ======= -jump_expr : BREAK +jump_command : BREAK { - if (! ($$ = make_break_expression ($1))) + if (! ($$ = make_break_command ($1))) ABORT_PARSE; } | CONTINUE { - if (! ($$ = make_continue_expression ($1))) + if (! ($$ = make_continue_command ($1))) ABORT_PARSE; } | FUNC_RET { - if (! ($$ = make_return_expression ($1))) + if (! ($$ = make_return_command ($1))) ABORT_PARSE; } ; @@ -2244,12 +2243,12 @@ return retval; } -// Build a break expression. - -static tree_expression * -make_break_expression (token *break_tok) +// Build a break command. + +static tree_command * +make_break_command (token *break_tok) { - tree_expression *retval = 0; + tree_command *retval = 0; int l = break_tok->line (); int c = break_tok->column (); @@ -2257,46 +2256,46 @@ if (lexer_flags.looping || lexer_flags.defining_func || reading_script_file || evaluating_function_body || evaluating_looping_command) - retval = new tree_break_expression (l, c); + retval = new tree_break_command (l, c); else - yyerror ("invalid use of break"); + retval = new tree_no_op_command ("break", l, c); return retval; } -// Build a continue expression. - -static tree_expression * -make_continue_expression (token *continue_tok) +// Build a continue command. + +static tree_command * +make_continue_command (token *continue_tok) { - tree_expression *retval = 0; + tree_command *retval = 0; int l = continue_tok->line (); int c = continue_tok->column (); if (lexer_flags.looping || evaluating_looping_command) - retval = new tree_continue_expression (l, c); + retval = new tree_continue_command (l, c); else - yyerror ("invalid use of continue"); + retval = new tree_no_op_command ("continue", l, c); return retval; } -// Build a return expression. - -static tree_expression * -make_return_expression (token *return_tok) +// Build a return command. + +static tree_command * +make_return_command (token *return_tok) { - tree_expression *retval = 0; + tree_command *retval = 0; int l = return_tok->line (); int c = return_tok->column (); if (lexer_flags.defining_func || reading_script_file || evaluating_function_body) - retval = new tree_return_expression (l, c); + retval = new tree_return_command (l, c); else - yyerror ("invalid use of return"); + retval = new tree_no_op_command ("return", l, c); return retval; } @@ -2866,14 +2865,14 @@ OCTAVE_QUIT; - bool quit = (tree_return_expression::returning - || tree_break_expression::breaking); - - if (tree_return_expression::returning) - tree_return_expression::returning = 0; - - if (tree_break_expression::breaking) - tree_break_expression::breaking--; + bool quit = (tree_return_command::returning + || tree_break_command::breaking); + + if (tree_return_command::returning) + tree_return_command::returning = 0; + + if (tree_break_command::breaking) + tree_break_command::breaking--; if (error_state) { @@ -3559,9 +3558,9 @@ command = 0; if (error_state - || tree_return_expression::returning - || tree_break_expression::breaking - || tree_continue_expression::continuing) + || tree_return_command::returning + || tree_break_command::breaking + || tree_continue_command::continuing) break; } else if (parser_end_of_input) diff --git a/src/pt-bp.cc b/src/pt-bp.cc --- a/src/pt-bp.cc +++ b/src/pt-bp.cc @@ -140,7 +140,7 @@ } void -tree_breakpoint::visit_break_expression (tree_break_expression& cmd) +tree_breakpoint::visit_break_command (tree_break_command& cmd) { if (found) return; @@ -175,7 +175,7 @@ } void -tree_breakpoint::visit_continue_expression (tree_continue_expression& cmd) +tree_breakpoint::visit_continue_command (tree_continue_command& cmd) { if (found) return; @@ -514,7 +514,7 @@ } void -tree_breakpoint::visit_return_expression (tree_return_expression& cmd) +tree_breakpoint::visit_return_command (tree_return_command& cmd) { if (found) return; diff --git a/src/pt-bp.h b/src/pt-bp.h --- a/src/pt-bp.h +++ b/src/pt-bp.h @@ -53,11 +53,11 @@ void visit_binary_expression (tree_binary_expression&); - void visit_break_expression (tree_break_expression&); + void visit_break_command (tree_break_command&); void visit_colon_expression (tree_colon_expression&); - void visit_continue_expression (tree_continue_expression&); + void visit_continue_command (tree_continue_command&); void visit_decl_command (tree_decl_command&); @@ -111,7 +111,7 @@ void visit_prefix_expression (tree_prefix_expression&); - void visit_return_expression (tree_return_expression&); + void visit_return_command (tree_return_command&); void visit_return_list (tree_return_list&); diff --git a/src/pt-check.cc b/src/pt-check.cc --- a/src/pt-check.cc +++ b/src/pt-check.cc @@ -67,7 +67,7 @@ } void -tree_checker::visit_break_expression (tree_break_expression&) +tree_checker::visit_break_command (tree_break_command&) { } @@ -91,7 +91,7 @@ } void -tree_checker::visit_continue_expression (tree_continue_expression&) +tree_checker::visit_continue_command (tree_continue_command&) { } @@ -391,7 +391,7 @@ } void -tree_checker::visit_return_expression (tree_return_expression&) +tree_checker::visit_return_command (tree_return_command&) { } diff --git a/src/pt-check.h b/src/pt-check.h --- a/src/pt-check.h +++ b/src/pt-check.h @@ -45,11 +45,11 @@ void visit_binary_expression (tree_binary_expression&); - void visit_break_expression (tree_break_expression&); + void visit_break_command (tree_break_command&); void visit_colon_expression (tree_colon_expression&); - void visit_continue_expression(tree_continue_expression&); + void visit_continue_command(tree_continue_command&); void visit_decl_command (tree_decl_command&); @@ -93,7 +93,7 @@ void visit_prefix_expression (tree_prefix_expression&); - void visit_return_expression (tree_return_expression&); + void visit_return_command (tree_return_command&); void visit_return_list (tree_return_list&); diff --git a/src/pt-except.cc b/src/pt-except.cc --- a/src/pt-except.cc +++ b/src/pt-except.cc @@ -149,11 +149,11 @@ // We don't have to worry about continue statements because they can // only occur in loops. - unwind_protect_int (tree_return_expression::returning); - tree_return_expression::returning = 0; + unwind_protect_int (tree_return_command::returning); + tree_return_command::returning = 0; - unwind_protect_int (tree_break_expression::breaking); - tree_break_expression::breaking = 0; + unwind_protect_int (tree_break_command::breaking); + tree_break_command::breaking = 0; if (list) list->eval (); @@ -185,7 +185,7 @@ // break in the cleanup block, the values should be reset to // whatever they were when the cleanup block was entered. - if (tree_break_expression::breaking || tree_return_expression::returning) + if (tree_break_command::breaking || tree_return_command::returning) { unwind_protect::discard (); unwind_protect::discard (); diff --git a/src/pt-jump.cc b/src/pt-jump.cc --- a/src/pt-jump.cc +++ b/src/pt-jump.cc @@ -39,69 +39,63 @@ // Break. // Nonzero means we're breaking out of a loop or function body. -int tree_break_expression::breaking = 0; +int tree_break_command::breaking = 0; -octave_value -tree_break_expression::rvalue (void) +void +tree_break_command::eval (void) { // Even if we have an error we should still enter debug mode. MAYBE_DO_BREAKPOINT; if (! error_state) breaking = 1; - - return true; } void -tree_break_expression::accept (tree_walker& tw) +tree_break_command::accept (tree_walker& tw) { - tw.visit_break_expression (*this); + tw.visit_break_command (*this); } // Continue. // Nonzero means we're jumping to the end of a loop. -int tree_continue_expression::continuing = 0; +int tree_continue_command::continuing = 0; -octave_value -tree_continue_expression::rvalue (void) +void +tree_continue_command::eval (void) { MAYBE_DO_BREAKPOINT; if (! error_state) continuing = 1; - - return true; } void -tree_continue_expression::accept (tree_walker& tw) +tree_continue_command::accept (tree_walker& tw) { - tw.visit_continue_expression (*this); + tw.visit_continue_command (*this); } // Return. // Nonzero means we're returning from a function. Global because it // is also needed in tree-expr.cc. -int tree_return_expression::returning = 0; +int tree_return_command::returning = 0; -octave_value -tree_return_expression::rvalue (void) +void +tree_return_command::eval (void) { MAYBE_DO_BREAKPOINT; if (! error_state) returning = 1; - - return true; } void -tree_return_expression::accept (tree_walker& tw) +tree_return_command::accept (tree_walker& tw) { - tw.visit_return_expression (*this); + tw.visit_return_command (*this); } /* diff --git a/src/pt-jump.h b/src/pt-jump.h --- a/src/pt-jump.h +++ b/src/pt-jump.h @@ -29,25 +29,21 @@ class tree_walker; -#include "pt-exp.h" +#include "pt-cmd.h" // Break. class -tree_break_expression : public tree_expression +tree_break_command : public tree_command { public: - tree_break_expression (int l = -1, int c = -1) - : tree_expression (l, c) { } - - ~tree_break_expression (void) { } + tree_break_command (int l = -1, int c = -1) + : tree_command (l, c) { } - bool rvalue_ok (void) { return true; } + ~tree_break_command (void) { } - octave_value rvalue (void); - - octave_value_list rvalue (int nargout) { return rvalue (); } + void eval (void); void accept (tree_walker& tw); @@ -57,28 +53,24 @@ // No copying! - tree_break_expression (const tree_break_expression&); + tree_break_command (const tree_break_command&); - tree_break_expression& operator = (const tree_break_expression&); + tree_break_command& operator = (const tree_break_command&); }; // Continue. class -tree_continue_expression : public tree_expression +tree_continue_command : public tree_command { public: - tree_continue_expression (int l = -1, int c = -1) - : tree_expression (l, c) { } - - ~tree_continue_expression (void) { } + tree_continue_command (int l = -1, int c = -1) + : tree_command (l, c) { } - bool rvalue_ok (void) { return true; } + ~tree_continue_command (void) { } - octave_value rvalue (void); - - octave_value_list rvalue (int nargout) { return rvalue (); } + void eval (void); void accept (tree_walker& tw); @@ -88,28 +80,24 @@ // No copying! - tree_continue_expression (const tree_continue_expression&); + tree_continue_command (const tree_continue_command&); - tree_continue_expression& operator = (const tree_continue_expression&); + tree_continue_command& operator = (const tree_continue_command&); }; // Return. class -tree_return_expression : public tree_expression +tree_return_command : public tree_command { public: - tree_return_expression (int l = -1, int c = -1) - : tree_expression (l, c) { } - - ~tree_return_expression (void) { } + tree_return_command (int l = -1, int c = -1) + : tree_command (l, c) { } - bool rvalue_ok (void) { return true; } + ~tree_return_command (void) { } - octave_value rvalue (void); - - octave_value_list rvalue (int nargout) { return rvalue (); } + void eval (void); void accept (tree_walker& tw); @@ -119,9 +107,9 @@ // No copying! - tree_return_expression (const tree_return_expression&); + tree_return_command (const tree_return_command&); - tree_return_expression& operator = (const tree_return_expression&); + tree_return_command& operator = (const tree_return_command&); }; #endif diff --git a/src/pt-loop.cc b/src/pt-loop.cc --- a/src/pt-loop.cc +++ b/src/pt-loop.cc @@ -56,16 +56,16 @@ // Maybe handle `continue N' someday... - if (tree_continue_expression::continuing) - tree_continue_expression::continuing--; + if (tree_continue_command::continuing) + tree_continue_command::continuing--; bool quit = (error_state - || tree_return_expression::returning - || tree_break_expression::breaking - || tree_continue_expression::continuing); + || tree_return_command::returning + || tree_break_command::breaking + || tree_continue_command::continuing); - if (tree_break_expression::breaking) - tree_break_expression::breaking--; + if (tree_break_command::breaking) + tree_break_command::breaking--; return quit; } diff --git a/src/pt-pr-code.cc b/src/pt-pr-code.cc --- a/src/pt-pr-code.cc +++ b/src/pt-pr-code.cc @@ -82,7 +82,7 @@ } void -tree_print_code::visit_break_expression (tree_break_expression&) +tree_print_code::visit_break_command (tree_break_command&) { indent (); @@ -123,7 +123,7 @@ } void -tree_print_code::visit_continue_expression (tree_continue_expression&) +tree_print_code::visit_continue_command (tree_continue_command&) { indent (); @@ -782,7 +782,7 @@ } void -tree_print_code::visit_return_expression (tree_return_expression&) +tree_print_code::visit_return_command (tree_return_command&) { indent (); diff --git a/src/pt-pr-code.h b/src/pt-pr-code.h --- a/src/pt-pr-code.h +++ b/src/pt-pr-code.h @@ -53,11 +53,11 @@ void visit_binary_expression (tree_binary_expression&); - void visit_break_expression (tree_break_expression&); + void visit_break_command (tree_break_command&); void visit_colon_expression (tree_colon_expression&); - void visit_continue_expression (tree_continue_expression&); + void visit_continue_command (tree_continue_command&); void visit_decl_command (tree_decl_command&); @@ -107,7 +107,7 @@ void visit_prefix_expression (tree_prefix_expression&); - void visit_return_expression (tree_return_expression&); + void visit_return_command (tree_return_command&); void visit_return_list (tree_return_list&); diff --git a/src/pt-stmt.cc b/src/pt-stmt.cc --- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -172,11 +172,11 @@ if (error_state) break; - if (tree_break_expression::breaking - || tree_continue_expression::continuing) + if (tree_break_command::breaking + || tree_continue_command::continuing) break; - if (tree_return_expression::returning) + if (tree_return_command::returning) break; } else diff --git a/src/pt-walk.h b/src/pt-walk.h --- a/src/pt-walk.h +++ b/src/pt-walk.h @@ -25,9 +25,9 @@ class tree_argument_list; class tree_binary_expression; -class tree_break_expression; +class tree_break_command; class tree_colon_expression; -class tree_continue_expression; +class tree_continue_command; class tree_decl_command; class tree_decl_elt; class tree_decl_init_list; @@ -53,7 +53,7 @@ class plot_range; class tree_postfix_expression; class tree_prefix_expression; -class tree_return_expression; +class tree_return_command; class tree_return_list; class tree_simple_assignment; class tree_statement; @@ -80,13 +80,13 @@ visit_binary_expression (tree_binary_expression&) = 0; virtual void - visit_break_expression (tree_break_expression&) = 0; + visit_break_command (tree_break_command&) = 0; virtual void visit_colon_expression (tree_colon_expression&) = 0; virtual void - visit_continue_expression (tree_continue_expression&) = 0; + visit_continue_command (tree_continue_command&) = 0; virtual void visit_decl_command (tree_decl_command&) = 0; @@ -164,7 +164,7 @@ visit_prefix_expression (tree_prefix_expression&) = 0; virtual void - visit_return_expression (tree_return_expression&) = 0; + visit_return_command (tree_return_command&) = 0; virtual void visit_return_list (tree_return_list&) = 0; diff --git a/src/symtab.h b/src/symtab.h --- a/src/symtab.h +++ b/src/symtab.h @@ -106,6 +106,12 @@ bool is_user_variable (void) const { return (symbol_type & symbol_record::USER_VARIABLE); } + void mark_as_text_function (void) + { symbol_type |= symbol_record::TEXT_FUNCTION; } + + void unmark_text_function (void) + { symbol_type &= ~symbol_record::TEXT_FUNCTION; } + bool is_text_function (void) const { return (symbol_type & symbol_record::TEXT_FUNCTION); } @@ -237,6 +243,12 @@ bool is_function (void) const { return definition->is_function (); } + void mark_as_text_function (void) + { definition->mark_as_text_function (); } + + void unmark_text_function (void) + { definition->unmark_text_function (); } + bool is_text_function (void) const { return definition->is_text_function (); } diff --git a/src/toplev.cc b/src/toplev.cc --- a/src/toplev.cc +++ b/src/toplev.cc @@ -152,14 +152,14 @@ if (! (interactive || forced_interactive)) { - bool quit = (tree_return_expression::returning - || tree_break_expression::breaking); + bool quit = (tree_return_command::returning + || tree_break_command::breaking); - if (tree_return_expression::returning) - tree_return_expression::returning = 0; + if (tree_return_command::returning) + tree_return_command::returning = 0; - if (tree_break_expression::breaking) - tree_break_expression::breaking--; + if (tree_break_command::breaking) + tree_break_command::breaking--; if (quit) break; diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include "file-stat.h" @@ -103,11 +104,108 @@ // Is this a text-style function? +static std::set text_function_set; + +static inline bool +is_marked_as_text_function (const std::string& s) +{ + return text_function_set.find (s) != text_function_set.end (); +} + +static inline void +mark_as_text_function (const std::string& s) +{ + text_function_set.insert (s); +} + +static inline void +unmark_text_function (const std::string& s) +{ + text_function_set.erase (s); + + symbol_record *sr = fbi_sym_tab->lookup (s); + + if (sr) + sr->unmark_text_function (); +} + +DEFUN_TEXT (mark_as_text_function, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} mark_as_text_function (@var{name})\n\ +Enter @var{name} into the list of text functions\n\ +@end deftypefn") +{ + octave_value_list retval; + + int nargin = args.length (); + + if (nargin > 0) + { + int argc = nargin + 1; + + string_vector argv = args.make_argv ("mark_as_text_function"); + + if (! error_state) + { + for (int i = 1; i < argc; i++) + mark_as_text_function (argv[i]); + } + } + else + print_usage ("mark_as_text_function"); + + return retval; +} + +DEFUN_TEXT (unmark_text_function, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} mark_as_text_function (@var{name})\n\ +Enter @var{name} into the list of text functions\n\ +@end deftypefn") +{ + octave_value_list retval; + + int nargin = args.length (); + + if (nargin > 0) + { + int argc = nargin + 1; + + string_vector argv = args.make_argv ("unmark_text_function"); + + if (! error_state) + { + for (int i = 1; i < argc; i++) + unmark_text_function (argv[i]); + } + } + else + print_usage ("unmark_text_function"); + + return retval; +} + bool is_text_function_name (const std::string& s) { + bool retval = false; + symbol_record *sr = fbi_sym_tab->lookup (s); - return (sr && sr->is_text_function ()); + + if (sr) + { + if (sr->is_text_function ()) + retval = true; + else if (is_marked_as_text_function (s)) + { + sr->mark_as_text_function (); + retval = true; + } + } + else + retval = is_marked_as_text_function (s); + + return retval; } // Is this a built-in function?