Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include "defun.h"
00028 #include "error.h"
00029 #include "pt-cmd.h"
00030 #include "ov.h"
00031 #include "oct-lvalue.h"
00032 #include "pt-bp.h"
00033 #include "pt-decl.h"
00034 #include "pt-exp.h"
00035 #include "pt-id.h"
00036 #include "pt-walk.h"
00037 #include "utils.h"
00038 #include "variables.h"
00039
00040
00041
00042 tree_decl_elt::~tree_decl_elt (void)
00043 {
00044 delete id;
00045 delete expr;
00046 }
00047
00048 bool
00049 tree_decl_elt::eval (void)
00050 {
00051 bool retval = false;
00052
00053 if (id && expr)
00054 {
00055 octave_lvalue ult = id->lvalue ();
00056
00057 octave_value init_val = expr->rvalue1 ();
00058
00059 if (! error_state)
00060 {
00061 ult.assign (octave_value::op_asn_eq, init_val);
00062
00063 retval = true;
00064 }
00065 }
00066
00067 return retval;
00068 }
00069
00070 tree_decl_elt *
00071 tree_decl_elt::dup (symbol_table::scope_id scope,
00072 symbol_table::context_id context) const
00073 {
00074 return new tree_decl_elt (id ? id->dup (scope, context) : 0,
00075 expr ? expr->dup (scope, context) : 0);
00076 }
00077
00078 void
00079 tree_decl_elt::accept (tree_walker& tw)
00080 {
00081 tw.visit_decl_elt (*this);
00082 }
00083
00084
00085
00086 tree_decl_init_list *
00087 tree_decl_init_list::dup (symbol_table::scope_id scope,
00088 symbol_table::context_id context) const
00089 {
00090 tree_decl_init_list *new_dil = new tree_decl_init_list ();
00091
00092 for (const_iterator p = begin (); p != end (); p++)
00093 {
00094 const tree_decl_elt *elt = *p;
00095
00096 new_dil->append (elt ? elt->dup (scope, context) : 0);
00097 }
00098
00099 return new_dil;
00100 }
00101
00102 void
00103 tree_decl_init_list::accept (tree_walker& tw)
00104 {
00105 tw.visit_decl_init_list (*this);
00106 }
00107
00108
00109
00110 tree_decl_command::~tree_decl_command (void)
00111 {
00112 delete init_list;
00113 }
00114
00115
00116
00117 tree_command *
00118 tree_global_command::dup (symbol_table::scope_id scope,
00119 symbol_table::context_id context) const
00120 {
00121 return
00122 new tree_global_command (init_list ? init_list->dup (scope, context) : 0,
00123 line (), column ());
00124 }
00125
00126 void
00127 tree_global_command::accept (tree_walker& tw)
00128 {
00129 tw.visit_global_command (*this);
00130 }
00131
00132
00133
00134 tree_command *
00135 tree_static_command::dup (symbol_table::scope_id scope,
00136 symbol_table::context_id context) const
00137 {
00138 return
00139 new tree_static_command (init_list ? init_list->dup (scope, context) : 0,
00140 line (), column ());
00141 }
00142
00143 void
00144 tree_static_command::accept (tree_walker& tw)
00145 {
00146 tw.visit_static_command (*this);
00147 }