# HG changeset patch # User jwe # Date 863719110 0 # Node ID 1b47dd00a8319b1846c5c512f16f2cefbdbd8f91 # Parent e330cb788508fb12ee91d2a1ea5df038f87c9b45 [project @ 1997-05-15 17:57:48 by jwe] diff --git a/src/dynamic-ld.cc b/src/dynamic-ld.cc --- a/src/dynamic-ld.cc +++ b/src/dynamic-ld.cc @@ -50,7 +50,7 @@ #include "toplev.h" #include "pathsearch.h" #include "oct-obj.h" -#include "oct-builtin.h" +#include "ov-builtin.h" #include "ov.h" #include "utils.h" #include "variables.h" @@ -69,7 +69,7 @@ private: - octave_dynamic_loader::builtin_fcn + octave_dynamic_loader::builtin_fcn_installer resolve_reference (const string& mangled_name, const string& file); // No copying! @@ -80,11 +80,11 @@ operator = (const octave_dlopen_dynamic_loader&); }; -octave_dynamic_loader::builtin_fcn +octave_dynamic_loader::builtin_fcn_installer octave_dlopen_dynamic_loader::resolve_reference (const string& name, const string& file) { - octave_dynamic_loader::builtin_fcn retval = 0; + octave_dynamic_loader::builtin_fcn_installer retval = 0; // Dynamic linking with dlopen/dlsym doesn't require specification // of the libraries at runtime. Instead, they are specified when @@ -98,7 +98,7 @@ { void *tmp = dlsym (handle, nm); - retval = static_cast (tmp); + retval = static_cast (tmp); if (! retval) { @@ -132,7 +132,7 @@ private: - octave_dynamic_loader::builtin_fcn + octave_dynamic_loader::builtin_fcn_installer resolve_reference (const string& mangled_name, const string& file); // No copying! @@ -143,11 +143,11 @@ operator = (const octave_shl_load_dynamic_loader&); }; -octave_dynamic_loader::builtin_fcn +octave_dynamic_loader::builtin_fcn_installer octave_shl_load_dynamic_loader::resolve_reference (const string& name, const string& file) { - octave_dynamic_loader::builtin_fcn retval = 0; + octave_dynamic_loader::builtin_fcn_installer retval = 0; // Dynamic linking with shl_load/shl_findsym doesn't require // specification of the libraries at runtime. Instead, they are @@ -213,13 +213,13 @@ #endif } -int +bool octave_dynamic_loader::load_fcn_from_dot_oct_file (const string& fcn_name) { if (! instance_ok ()) make_dynamic_loader (); - int retval = 0; + bool retval = false; string oct_file = oct_file_in_path (fcn_name); @@ -227,24 +227,17 @@ { string mangled_name = instance->mangle_name (fcn_name); - builtin_fcn f = instance->resolve_reference (mangled_name, oct_file); + builtin_fcn_installer f + = instance->resolve_reference (mangled_name, oct_file); if (f) - { - octave_builtin *obj = f (); - - if (obj) - { - install_builtin_function (obj); - retval = 1; - } - } + retval = f (); } return retval; } -octave_dynamic_loader::builtin_fcn +octave_dynamic_loader::builtin_fcn_installer octave_dynamic_loader::resolve_reference (const string&, const string&) { return 0; 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 @@ -31,7 +31,7 @@ #include #include "error.h" -#include "oct-usr-fcn.h" +#include "ov-usr-fcn.h" #include "pr-output.h" #include "pt-cmd.h" #include "pt-const.h" @@ -40,7 +40,6 @@ #include "pt-indir.h" #include "pt-mat.h" #include "pt-misc.h" -#include "pt-mvr.h" #include "pt-plot.h" #include "pt-pr-code.h" @@ -157,10 +156,14 @@ if (id) id->accept (*this); - tree_simple_assignment_expression *ass_expr = cmd.assign_expr (); + tree_expression *expr = cmd.expression (); - if (ass_expr) - ass_expr->accept (*this); + if (expr) + { + os << " = "; + + expr->accept (*this); + } } void @@ -185,16 +188,16 @@ } void -tree_print_code::visit_for_command (tree_for_command& cmd) +tree_print_code::visit_simple_for_command (tree_simple_for_command& cmd) { indent (); os << "for "; - tree_index_expression *id = cmd.ident (); + tree_expression *lhs = cmd.left_hand_side (); - if (id) - id->accept (*this); + if (lhs) + lhs->accept (*this); os << " = "; @@ -220,6 +223,41 @@ } void +tree_print_code::visit_complex_for_command (tree_complex_for_command& cmd) +{ + indent (); + + os << "for ["; + + tree_argument_list *lhs = cmd.left_hand_side (); + + if (lhs) + lhs->accept (*this); + + os << "] = "; + + tree_expression *expr = cmd.control_expr (); + + if (expr) + expr->accept (*this); + + newline (); + + tree_statement_list *list = cmd.body (); + + if (list) + { + increment_indent_level (); + list->accept (*this); + decrement_indent_level (); + } + + indent (); + + os << "endfor"; +} + +void tree_print_code::visit_octave_user_function (octave_user_function& fcn) { reset (); @@ -410,10 +448,10 @@ print_parens (expr, "("); - tree_indirect_ref *id = expr.ident (); + tree_expression *e= expr.expression (); - if (id) - id->accept (*this); + if (e) + e->accept (*this); tree_argument_list *list = expr.arg_list (); @@ -434,10 +472,12 @@ print_parens (expr, "("); - // The name of the indirect ref includes the sub-elements. + tree_expression *e = expr.expression (); - string nm = expr.name (); - os << (nm.empty () ? string ("(empty)") : nm); + if (e) + e->accept (*this); + + os << "." << expr.elt_name (); print_parens (expr, ")"); } @@ -455,7 +495,7 @@ while (p) { - tree_matrix_row *elt = lst (p); + tree_argument_list *elt = lst (p); lst.next (p); @@ -474,35 +514,13 @@ } void -tree_print_code::visit_matrix_row (tree_matrix_row& lst) -{ - Pix p = lst.first (); - - while (p) - { - tree_expression *elt = lst (p); - - lst.next (p); - - if (elt) - { - elt->accept (*this); - - if (p) - os << ", "; - } - } -} - -void -tree_print_code::visit_multi_assignment_expression - (tree_multi_assignment_expression& expr) +tree_print_code::visit_multi_assignment (tree_multi_assignment& expr) { indent (); print_parens (expr, "("); - tree_return_list *lhs = expr.left_hand_side (); + tree_argument_list *lhs = expr.left_hand_side (); if (lhs) { @@ -519,7 +537,7 @@ os << " = "; - tree_multi_val_ret *rhs = expr.right_hand_side (); + tree_expression *rhs = expr.right_hand_side (); if (rhs) rhs->accept (*this); @@ -714,31 +732,18 @@ } void -tree_print_code::visit_simple_assignment_expression - (tree_simple_assignment_expression& expr) +tree_print_code::visit_simple_assignment (tree_simple_assignment& expr) { indent (); print_parens (expr, "("); - if (! expr.is_ans_assign ()) - { - tree_indirect_ref *lhs = expr.left_hand_side (); - - if (lhs) - lhs->accept (*this); - - tree_argument_list *index = expr.lhs_index (); + tree_expression *lhs = expr.left_hand_side (); - if (index) - { - os << " ("; - index->accept (*this); - os << ")"; - } + if (lhs) + lhs->accept (*this); - os << " " << expr.oper () << " "; - } + os << " " << expr.oper () << " "; tree_expression *rhs = expr.right_hand_side (); 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 @@ -62,7 +62,9 @@ void visit_decl_init_list (tree_decl_init_list&); - void visit_for_command (tree_for_command&); + void visit_simple_for_command (tree_simple_for_command&); + + void visit_complex_for_command (tree_complex_for_command&); void visit_octave_user_function (octave_user_function&); @@ -84,9 +86,7 @@ void visit_matrix (tree_matrix&); - void visit_matrix_row (tree_matrix_row&); - - void visit_multi_assignment_expression (tree_multi_assignment_expression&); + void visit_multi_assignment (tree_multi_assignment&); void visit_no_op_command (tree_no_op_command&); @@ -110,7 +110,7 @@ void visit_return_list (tree_return_list&); - void visit_simple_assignment_expression (tree_simple_assignment_expression&); + void visit_simple_assignment (tree_simple_assignment&); void visit_statement (tree_statement&); diff --git a/src/pt-walk.h b/src/pt-walk.h --- a/src/pt-walk.h +++ b/src/pt-walk.h @@ -31,7 +31,8 @@ class tree_decl_command; class tree_decl_elt; class tree_decl_init_list; -class tree_for_command; +class tree_simple_for_command; +class tree_complex_for_command; class octave_user_function; class tree_identifier; class tree_if_clause; @@ -43,8 +44,7 @@ class tree_index_expression; class tree_indirect_ref; class tree_matrix; -class tree_matrix_row; -class tree_multi_assignment_expression; +class tree_multi_assignment; class tree_no_op_command; class tree_oct_obj; class tree_constant; @@ -56,7 +56,7 @@ class tree_prefix_expression; class tree_return_command; class tree_return_list; -class tree_simple_assignment_expression; +class tree_simple_assignment; class tree_statement; class tree_statement_list; class subplot; @@ -97,7 +97,10 @@ visit_decl_init_list (tree_decl_init_list&) = 0; virtual void - visit_for_command (tree_for_command&) = 0; + visit_simple_for_command (tree_simple_for_command&) = 0; + + virtual void + visit_complex_for_command (tree_complex_for_command&) = 0; virtual void visit_octave_user_function (octave_user_function&) = 0; @@ -133,10 +136,7 @@ visit_matrix (tree_matrix&) = 0; virtual void - visit_matrix_row (tree_matrix_row&) = 0; - - virtual void - visit_multi_assignment_expression (tree_multi_assignment_expression&) = 0; + visit_multi_assignment (tree_multi_assignment&) = 0; virtual void visit_no_op_command (tree_no_op_command&) = 0; @@ -172,7 +172,7 @@ visit_return_list (tree_return_list&) = 0; virtual void - visit_simple_assignment_expression (tree_simple_assignment_expression&) = 0; + visit_simple_assignment (tree_simple_assignment&) = 0; virtual void visit_statement (tree_statement&) = 0;