1
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2002, 2004, 2005, |
|
4 2006, 2007 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
1
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
3503
|
28 #include <iostream> |
581
|
29 |
2971
|
30 #include "error.h" |
1742
|
31 #include "oct-obj.h" |
2900
|
32 #include "pager.h" |
1742
|
33 #include "pt-const.h" |
2124
|
34 #include "pt-walk.h" |
1558
|
35 |
2477
|
36 // We are likely to have a lot of tree_constant objects to allocate, |
|
37 // so make the grow_size large. |
|
38 octave_allocator |
|
39 tree_constant::allocator (sizeof (tree_constant), 1024); |
2475
|
40 |
2532
|
41 void |
3523
|
42 tree_constant::print (std::ostream& os, bool pr_as_read_syntax, bool pr_orig_text) |
2532
|
43 { |
|
44 if (pr_orig_text && ! orig_text.empty ()) |
|
45 os << orig_text; |
|
46 else |
|
47 val.print (os, pr_as_read_syntax); |
|
48 } |
|
49 |
2942
|
50 void |
3523
|
51 tree_constant::print_raw (std::ostream& os, bool pr_as_read_syntax, |
2942
|
52 bool pr_orig_text) |
|
53 { |
|
54 if (pr_orig_text && ! orig_text.empty ()) |
|
55 os << orig_text; |
|
56 else |
|
57 val.print_raw (os, pr_as_read_syntax); |
|
58 } |
|
59 |
2971
|
60 octave_value_list |
|
61 tree_constant::rvalue (int nargout) |
2390
|
62 { |
2971
|
63 octave_value_list retval; |
2390
|
64 |
2971
|
65 if (nargout > 1) |
|
66 error ("invalid number of output arguments for constant expression"); |
|
67 else |
|
68 retval = rvalue (); |
2390
|
69 |
2971
|
70 return retval; |
2532
|
71 } |
|
72 |
5861
|
73 tree_expression * |
7336
|
74 tree_constant::dup (symbol_table::scope_id) |
5861
|
75 { |
|
76 tree_constant *new_tc |
|
77 = new tree_constant (val, orig_text, line (), column ()); |
|
78 |
|
79 new_tc->copy_base (*this); |
|
80 |
|
81 return new_tc; |
|
82 } |
|
83 |
2532
|
84 void |
2390
|
85 tree_constant::accept (tree_walker& tw) |
|
86 { |
|
87 tw.visit_constant (*this); |
|
88 } |
|
89 |
96
|
90 /* |
1
|
91 ;;; Local Variables: *** |
|
92 ;;; mode: C++ *** |
|
93 ;;; End: *** |
|
94 */ |