1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
20 |
|
21 */ |
|
22 |
1299
|
23 #if defined (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
240
|
27 #ifdef HAVE_CONFIG_H |
1192
|
28 #include <config.h> |
1
|
29 #endif |
|
30 |
581
|
31 #include <iostream.h> |
|
32 |
1742
|
33 #include "oct-obj.h" |
2900
|
34 #include "pager.h" |
1742
|
35 #include "pt-const.h" |
2124
|
36 #include "pt-walk.h" |
1558
|
37 |
2477
|
38 // We are likely to have a lot of tree_constant objects to allocate, |
|
39 // so make the grow_size large. |
|
40 octave_allocator |
|
41 tree_constant::allocator (sizeof (tree_constant), 1024); |
2475
|
42 |
2532
|
43 void |
|
44 tree_constant::print (ostream& os, bool pr_as_read_syntax, bool pr_orig_text) |
|
45 { |
|
46 if (pr_orig_text && ! orig_text.empty ()) |
|
47 os << orig_text; |
|
48 else |
|
49 val.print (os, pr_as_read_syntax); |
|
50 } |
|
51 |
2942
|
52 void |
|
53 tree_constant::print_raw (ostream& os, bool pr_as_read_syntax, |
|
54 bool pr_orig_text) |
|
55 { |
|
56 if (pr_orig_text && ! orig_text.empty ()) |
|
57 os << orig_text; |
|
58 else |
|
59 val.print_raw (os, pr_as_read_syntax); |
|
60 } |
|
61 |
2390
|
62 octave_value |
|
63 tree_constant::eval (bool print_result) |
|
64 { |
|
65 if (print_result) |
2900
|
66 val.print (octave_stdout); |
2390
|
67 |
|
68 return val; |
|
69 } |
|
70 |
|
71 octave_value_list |
|
72 tree_constant::eval (bool, int, const octave_value_list& idx) |
|
73 { |
2960
|
74 return (idx.length () > 0) ? val.do_index_op (idx) : val; |
2532
|
75 } |
|
76 |
|
77 void |
2390
|
78 tree_constant::accept (tree_walker& tw) |
|
79 { |
|
80 tw.visit_constant (*this); |
|
81 } |
|
82 |
96
|
83 /* |
1
|
84 ;;; Local Variables: *** |
|
85 ;;; mode: C++ *** |
|
86 ;;; End: *** |
|
87 */ |