Mercurial > hg > octave-nkf
annotate src/pt-const.cc @ 9479:d9716e3ee0dd
supply optimized compiled sub2ind & ind2sub
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 03 Aug 2009 15:52:40 +0200 |
parents | eb63fbe60fab |
children | cd96d29c5efa |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2002, 2004, 2005, |
8920 | 4 2006, 2007, 2008, 2009 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 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
68 retval = rvalue1 (nargout); |
2390 | 69 |
2971 | 70 return retval; |
2532 | 71 } |
72 | |
5861 | 73 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
74 tree_constant::dup (symbol_table::scope_id, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
75 symbol_table::context_id) const |
5861 | 76 { |
77 tree_constant *new_tc | |
78 = new tree_constant (val, orig_text, line (), column ()); | |
79 | |
80 new_tc->copy_base (*this); | |
81 | |
82 return new_tc; | |
83 } | |
84 | |
2532 | 85 void |
2390 | 86 tree_constant::accept (tree_walker& tw) |
87 { | |
88 tw.visit_constant (*this); | |
89 } | |
90 | |
96 | 91 /* |
1 | 92 ;;; Local Variables: *** |
93 ;;; mode: C++ *** | |
94 ;;; End: *** | |
95 */ |