Mercurial > octave-nkf
diff src/pt-misc.cc @ 581:bc813f5eb025
[project @ 1994-08-07 01:02:15 by jwe]
author | jwe |
---|---|
date | Sun, 07 Aug 1994 01:02:15 +0000 |
parents | 91e2164fb1b2 |
children | 4057f845c1ee |
line wrap: on
line diff
--- a/src/pt-misc.cc Sun Aug 07 01:02:15 1994 +0000 +++ b/src/pt-misc.cc Sun Aug 07 01:02:15 1994 +0000 @@ -34,6 +34,8 @@ #include <unistd.h> #endif +#include <iostream.h> + #include "error.h" #include "tree.h" #include "tree-misc.h" @@ -59,6 +61,31 @@ delete expression; } +void +tree_statement::print_code (ostream& os) +{ + if (command) + { + command->print_code (os); + + if (! print_flag) + os << ";"; + + command->print_code_new_line (os); + } + else if (expression) + { + expression->print_code (os); + + if (! print_flag) + os << ";"; + + expression->print_code_new_line (os); + } + + +} + tree_constant tree_statement_list::eval (int print) { @@ -102,6 +129,18 @@ return retval; } +void +tree_statement_list::print_code (ostream& os) +{ + for (Pix p = first (); p != 0; next (p)) + { + tree_statement *elt = this->operator () (p); + + if (elt) + elt->print_code (os); + } +} + Octave_object tree_argument_list::convert_to_const_vector (void) { @@ -135,6 +174,27 @@ return args; } +void +tree_argument_list::print_code (ostream& os) +{ + Pix p = first (); + + while (p) + { + tree_expression *elt = this->operator () (p); + + next (p); + + if (elt) + { + elt->print_code (os); + + if (p) + os << ", "; + } + } +} + // Parameter lists. void @@ -225,6 +285,52 @@ } void +tree_parameter_list::print_code (ostream& os) +{ + Pix p = first (); + + while (p) + { + tree_identifier *elt = this->operator () (p); + + next (p); + + if (elt) + { + elt->print_code (os); + + if (p) + os << ", "; + } + } +} + +// Return lists. + +void +tree_return_list::print_code (ostream& os) +{ + Pix p = first (); + + while (p) + { + tree_index_expression *elt = this->operator () (p); + + next (p); + + if (elt) + { + elt->print_code (os); + + if (p) + os << ", "; + } + } +} + +// Global. + +void tree_global::eval (void) { if (ident) @@ -243,6 +349,18 @@ } void +tree_global::print_code (ostream& os) +{ + if (ident) + ident->print_code (os); + + if (assign_expr) + assign_expr->print_code (os); +} + +// Global initializer lists. + +void tree_global_init_list::eval (void) { for (Pix p = first (); p != 0; next (p)) @@ -252,6 +370,29 @@ } } +void +tree_global_init_list::print_code (ostream& os) +{ + Pix p = first (); + + while (p) + { + tree_global *elt = this->operator () (p); + + next (p); + + if (elt) + { + elt->print_code (os); + + if (p) + os << ", "; + } + } +} + +// If. + int tree_if_clause::eval (void) { @@ -309,6 +450,38 @@ } void +tree_if_clause::print_code (ostream& os) +{ + if (expr) + { + expr->print_code (os); + + print_code_new_line (os); + + increment_indent_level (); + } + else + { + print_code_indent (os); + + os << "else"; + + print_code_new_line (os); + + increment_indent_level (); + } + + if (list) + { + list->print_code (os); + + decrement_indent_level (); + } +} + +// List of if commands. + +void tree_if_command_list::eval (void) { for (Pix p = first (); p != 0; next (p)) @@ -320,6 +493,35 @@ } } +void +tree_if_command_list::print_code (ostream& os) +{ + Pix p = first (); + + int first_elt = 1; + + while (p) + { + tree_if_clause *elt = this->operator () (p); + + next (p); + + if (elt) + { + if (p && ! first_elt) + { + print_code_indent (os); + + os << "elseif "; + } + + elt->print_code (os); + } + + first_elt = 0; + } +} + /* ;;; Local Variables: *** ;;; mode: C++ ***