2952
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "oct-obj.h" |
|
28 #include "oct-var-ref.h" |
|
29 #include "ov.h" |
|
30 |
|
31 void |
|
32 octave_variable_reference::assign (octave_value::assign_op op, |
|
33 const octave_value& rhs) |
|
34 { |
|
35 octave_value saved_val; |
|
36 |
|
37 if (chg_fcn) |
|
38 octave_value saved_val = *val; |
|
39 |
|
40 if (idx.empty ()) |
|
41 { |
|
42 if (struct_elt_name.empty ()) |
|
43 val->assign (op, rhs); |
|
44 else |
|
45 val->assign_struct_elt (op, struct_elt_name, rhs); |
|
46 } |
|
47 else |
|
48 { |
|
49 if (struct_elt_name.empty ()) |
|
50 val->assign (op, idx, rhs); |
|
51 else |
|
52 val->assign_struct_elt (op, struct_elt_name, idx, rhs); |
|
53 } |
|
54 |
|
55 if (chg_fcn && chg_fcn () < 0) |
|
56 *val = saved_val; |
2963
|
57 |
|
58 // Clear index so subsequent value() operations will not perform an |
|
59 // indexing operation. |
|
60 |
|
61 idx = octave_value_list (); |
2952
|
62 } |
|
63 |
|
64 /* |
|
65 ;;; Local Variables: *** |
|
66 ;;; mode: C++ *** |
|
67 ;;; End: *** |
|
68 */ |