Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-const.cc @ 19840:c5270263d466 gui-release
close gui-release branch
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 30 Jan 2015 17:41:50 -0500 |
parents | 175b392e91fe |
children | 76478d2da117 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3 Copyright (C) 1993-2013 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
240 | 23 #ifdef HAVE_CONFIG_H |
1192 | 24 #include <config.h> |
1 | 25 #endif |
26 | |
3503 | 27 #include <iostream> |
581 | 28 |
2971 | 29 #include "error.h" |
1742 | 30 #include "oct-obj.h" |
2900 | 31 #include "pager.h" |
1742 | 32 #include "pt-const.h" |
2124 | 33 #include "pt-walk.h" |
1558 | 34 |
2477 | 35 // We are likely to have a lot of tree_constant objects to allocate, |
36 // so make the grow_size large. | |
13969
3b5afcec526b
* pt-const.h, pt-const.cc: Use macros to declare and define octave_allocator.
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
37 DEFINE_OCTAVE_ALLOCATOR2 (tree_constant, 1024); |
2475 | 38 |
2532 | 39 void |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
40 tree_constant::print (std::ostream& os, bool pr_as_read_syntax, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 bool pr_orig_text) |
2532 | 42 { |
43 if (pr_orig_text && ! orig_text.empty ()) | |
44 os << orig_text; | |
45 else | |
46 val.print (os, pr_as_read_syntax); | |
47 } | |
48 | |
2942 | 49 void |
3523 | 50 tree_constant::print_raw (std::ostream& os, bool pr_as_read_syntax, |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
51 bool pr_orig_text) |
2942 | 52 { |
53 if (pr_orig_text && ! orig_text.empty ()) | |
54 os << orig_text; | |
55 else | |
56 val.print_raw (os, pr_as_read_syntax); | |
57 } | |
58 | |
2971 | 59 octave_value_list |
60 tree_constant::rvalue (int nargout) | |
2390 | 61 { |
2971 | 62 octave_value_list retval; |
2390 | 63 |
2971 | 64 if (nargout > 1) |
65 error ("invalid number of output arguments for constant expression"); | |
66 else | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
67 retval = rvalue1 (nargout); |
2390 | 68 |
2971 | 69 return retval; |
2532 | 70 } |
71 | |
5861 | 72 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
73 tree_constant::dup (symbol_table::scope_id, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
74 symbol_table::context_id) const |
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 } |