Mercurial > hg > octave-avbm
comparison src/variables.cc @ 2953:ca7d3625ee01
[project @ 1997-05-09 14:56:52 by jwe]
author | jwe |
---|---|
date | Fri, 09 May 1997 14:57:34 +0000 |
parents | 5252c7275b8c |
children | ac3368dba5d3 |
comparison
equal
deleted
inserted
replaced
2952:c4bc40161199 | 2953:ca7d3625ee01 |
---|---|
107 symbol_table *curr_sym_tab = 0; | 107 symbol_table *curr_sym_tab = 0; |
108 | 108 |
109 // Symbol table for global symbols. | 109 // Symbol table for global symbols. |
110 symbol_table *global_sym_tab = 0; | 110 symbol_table *global_sym_tab = 0; |
111 | 111 |
112 void | |
113 octave_variable_reference::assign (octave_value::assign_op op, | |
114 const octave_value& rhs) | |
115 { | |
116 octave_value saved_val; | |
117 | |
118 if (chg_fcn) | |
119 octave_value saved_val = *val; | |
120 | |
121 if (struct_elt_name.empty ()) | |
122 val->assign (op, rhs); | |
123 else | |
124 val->assign_struct_elt (op, struct_elt_name, rhs); | |
125 | |
126 if (chg_fcn && chg_fcn () < 0) | |
127 *val = saved_val; | |
128 } | |
129 | |
130 void | |
131 octave_variable_reference::assign (octave_value::assign_op op, | |
132 const octave_value_list& idx, | |
133 const octave_value& rhs) | |
134 { | |
135 octave_value saved_val; | |
136 | |
137 if (chg_fcn) | |
138 octave_value saved_val = *val; | |
139 | |
140 if (struct_elt_name.empty ()) | |
141 val->assign (op, idx, rhs); | |
142 else | |
143 val->assign_struct_elt (op, struct_elt_name, idx, rhs); | |
144 | |
145 if (chg_fcn && chg_fcn () < 0) | |
146 *val = saved_val; | |
147 } | |
148 | |
149 // Initialization. | 112 // Initialization. |
150 | 113 |
151 // Create the initial symbol tables and set the current scope at the | 114 // Create the initial symbol tables and set the current scope at the |
152 // top level. | 115 // top level. |
153 | 116 |
1575 if (v.install_as_function) | 1538 if (v.install_as_function) |
1576 install_builtin_variable_as_function (v.name, v.value, v.protect, | 1539 install_builtin_variable_as_function (v.name, v.value, v.protect, |
1577 v.eternal, v.help_string); | 1540 v.eternal, v.help_string); |
1578 else | 1541 else |
1579 bind_builtin_variable (v.name, v.value, v.protect, v.eternal, | 1542 bind_builtin_variable (v.name, v.value, v.protect, v.eternal, |
1580 v.sv_function, v.help_string); | 1543 v.sv_fcn, v.help_string); |
1581 } | 1544 } |
1582 | 1545 |
1583 void | 1546 void |
1584 install_builtin_variable_as_function (const string& name, | 1547 install_builtin_variable_as_function (const string& name, |
1585 const octave_value& val, | 1548 const octave_value& val, |
1663 // How is this different than install_builtin_variable? Are both | 1626 // How is this different than install_builtin_variable? Are both |
1664 // functions needed? | 1627 // functions needed? |
1665 | 1628 |
1666 void | 1629 void |
1667 bind_builtin_variable (const string& varname, const octave_value& val, | 1630 bind_builtin_variable (const string& varname, const octave_value& val, |
1668 bool protect, bool eternal, sv_Function sv_fcn, | 1631 bool protect, bool eternal, |
1632 symbol_record::sv_function sv_fcn, | |
1669 const string& help) | 1633 const string& help) |
1670 { | 1634 { |
1671 symbol_record *sr = global_sym_tab->lookup (varname, true); | 1635 symbol_record *sr = global_sym_tab->lookup (varname, true); |
1672 | 1636 |
1673 // It is a programming error for a builtin symbol to be missing. | 1637 // It is a programming error for a builtin symbol to be missing. |