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 |
3929
|
60 octave_lvalue::set_index (const octave_value_list& i, |
|
61 tree_index_expression::type t) |
3357
|
62 { |
|
63 if (! index_set) |
|
64 { |
|
65 idx = i; |
3929
|
66 itype = t; |
3357
|
67 index_set = true; |
|
68 } |
|
69 else |
|
70 error ("invalid index expression in assignment"); |
|
71 } |
|
72 |
|
73 void |
3203
|
74 octave_lvalue::do_unary_op (octave_value::unary_op op) |
|
75 { |
|
76 octave_value saved_val; |
|
77 |
|
78 if (chg_fcn) |
|
79 saved_val = *val; |
|
80 |
|
81 if (idx.empty ()) |
|
82 val->do_non_const_unary_op (op); |
|
83 else |
3205
|
84 val->do_non_const_unary_op (op, idx); |
3203
|
85 |
|
86 if (chg_fcn && ! error_state && chg_fcn () < 0) |
2979
|
87 *val = saved_val; |
|
88 } |
|
89 |
|
90 /* |
|
91 ;;; Local Variables: *** |
|
92 ;;; mode: C++ *** |
|
93 ;;; End: *** |
|
94 */ |