2979
|
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 |
3203
|
27 #include "error.h" |
2979
|
28 #include "oct-obj.h" |
|
29 #include "oct-lvalue.h" |
|
30 #include "ov.h" |
|
31 |
|
32 void |
|
33 octave_lvalue::assign (octave_value::assign_op op, const octave_value& rhs) |
|
34 { |
|
35 octave_value saved_val; |
|
36 |
|
37 if (chg_fcn) |
3203
|
38 saved_val = *val; |
2979
|
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 |
3203
|
55 if (chg_fcn && ! error_state && chg_fcn () < 0) |
|
56 *val = saved_val; |
|
57 } |
|
58 |
|
59 void |
|
60 octave_lvalue::do_unary_op (octave_value::unary_op op) |
|
61 { |
|
62 octave_value saved_val; |
|
63 |
|
64 if (chg_fcn) |
|
65 saved_val = *val; |
|
66 |
|
67 if (idx.empty ()) |
|
68 val->do_non_const_unary_op (op); |
|
69 else |
|
70 { |
|
71 string on = octave_value::unary_op_as_string (op); |
|
72 error ("indexed operations not implemented yet for operator `%s'", |
|
73 on.c_str ()); |
|
74 } |
|
75 |
|
76 if (chg_fcn && ! error_state && chg_fcn () < 0) |
2979
|
77 *val = saved_val; |
|
78 } |
|
79 |
|
80 /* |
|
81 ;;; Local Variables: *** |
|
82 ;;; mode: C++ *** |
|
83 ;;; End: *** |
|
84 */ |