Mercurial > hg > octave-avbm
view src/pt-exp-base.cc @ 1742:a02f140ed897
[project @ 1996-01-12 11:09:39 by jwe]
author | jwe |
---|---|
date | Fri, 12 Jan 1996 11:21:53 +0000 |
parents | 63f6b1b57aae |
children | effa9400766f |
line wrap: on
line source
// pt-exp-base.cc -*- C++ -*- /* Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton This file is part of Octave. Octave is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Octave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Octave; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if defined (__GNUG__) #pragma implementation #endif #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <iostream.h> #include <strstream.h> #include "error.h" #include "pager.h" #include "pt-const.h" #include "pt-exp-base.h" #include "user-prefs.h" // Expressions. int tree_expression::is_logically_true (const char *warn_for) { int expr_value = 0; tree_constant t1 = eval (0); if (! error_state) { if (t1.is_defined ()) { if (t1.rows () == 0 || t1.columns () == 0) { t1 = 0.0; int flag = user_pref.propagate_empty_matrices; if (flag < 0) warning ("%s: empty matrix used in conditional expression", warn_for); else if (flag == 0) { ::error ("%s: empty matrix used in conditional expression", warn_for); return expr_value; } } else if (! t1.is_scalar_type ()) { tree_constant t2 = t1.all (); if (! error_state) t1 = t2.all (); } if (! error_state) { if (t1.is_real_scalar ()) expr_value = (int) t1.double_value (); else if (t1.is_complex_scalar ()) expr_value = t1.complex_value () != 0.0; else panic_impossible (); } else ::error ("%s: invalid type in conditional expression", warn_for); } else ::error ("%s: undefined value used in conditional expression", warn_for); } else ::error ("%s: error evaluating conditional expression", warn_for); return expr_value; } void tree_expression::mark_for_possible_ans_assign (void) { panic_impossible (); } tree_constant tree_expression::eval (int /* print */) { panic ("invalid evaluation of generic expression"); return tree_constant (); } /* ;;; Local Variables: *** ;;; mode: C++ *** ;;; page-delimiter: "^/\\*" *** ;;; End: *** */