Mercurial > octave
diff src/pt-decl.cc @ 3156:a494f93e60ff
[project @ 1998-02-20 07:47:48 by jwe]
author | jwe |
---|---|
date | Fri, 20 Feb 1998 07:47:52 +0000 |
parents | a8dcfbf87ea3 |
children | 974e596662f9 |
line wrap: on
line diff
--- a/src/pt-decl.cc Wed Feb 18 21:51:50 1998 +0000 +++ b/src/pt-decl.cc Fri Feb 20 07:47:52 1998 +0000 @@ -28,6 +28,7 @@ #include <config.h> #endif +#include "defun.h" #include "error.h" #include "pt-cmd.h" #include "ov.h" @@ -36,6 +37,12 @@ #include "pt-exp.h" #include "pt-id.h" #include "pt-walk.h" +#include "utils.h" +#include "variables.h" + +// Control whether otherwise uninitialized global variables are +// given a default value. +static int Vinitialize_global_variables; // Declarations (global, static, etc.). @@ -97,12 +104,13 @@ octave_lvalue ult = id->lvalue (); - if (ult.is_undefined ()) + if (ult.is_undefined () && Vinitialize_global_variables) { tree_expression *expr = elt.expression (); octave_value init_val = expr - ? expr->rvalue () : octave_value (Matrix ()); + ? expr->rvalue () + : builtin_any_variable ("default_global_variable_value"); ult.assign (octave_value::asn_eq, init_val); } @@ -165,6 +173,27 @@ } } +static int +initialize_global_variables (void) +{ + Vinitialize_global_variables + = check_preference ("initialize_global_variables"); + + return 0; +} + +void +symbols_of_pt_decl (void) +{ + DEFVAR (default_global_variable_value, , 0, 0, + "the default for value for otherwise uninitialized global variables.\n\ +Only used if the variable initialize_global_variables is nonzero."); + + DEFVAR (initialize_global_variables, 0.0, 0, initialize_global_variables, + "control whether otherwise uninitialized global variables are\n\ +given a default value. See also default_global_variable_value"); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***