Mercurial > hg > octave-nkf
annotate src/pt-decl.cc @ 9393:d6c99b2ee941
print.m: reimplement options -landscape and -portrait.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 24 Jun 2009 19:04:30 -0400 |
parents | eb63fbe60fab |
children | cd96d29c5efa |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
8920 | 4 2006, 2007, 2008, 2009 John W. Eaton |
2982 | 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. | |
2982 | 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/>. | |
2982 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
3156 | 28 #include "defun.h" |
2982 | 29 #include "error.h" |
30 #include "pt-cmd.h" | |
31 #include "ov.h" | |
32 #include "oct-lvalue.h" | |
7205 | 33 #include "pt-bp.h" |
2982 | 34 #include "pt-decl.h" |
35 #include "pt-exp.h" | |
36 #include "pt-id.h" | |
37 #include "pt-walk.h" | |
3156 | 38 #include "utils.h" |
39 #include "variables.h" | |
40 | |
2982 | 41 // Declarations (global, static, etc.). |
42 | |
43 tree_decl_elt::~tree_decl_elt (void) | |
44 { | |
45 delete id; | |
46 delete expr; | |
47 } | |
48 | |
6215 | 49 bool |
50 tree_decl_elt::eval (void) | |
51 { | |
52 bool retval = false; | |
53 | |
54 if (id && expr) | |
55 { | |
56 octave_lvalue ult = id->lvalue (); | |
57 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
58 octave_value init_val = expr->rvalue1 (); |
6215 | 59 |
60 if (! error_state) | |
61 { | |
62 ult.assign (octave_value::op_asn_eq, init_val); | |
63 | |
64 retval = true; | |
65 } | |
66 } | |
67 | |
68 return retval; | |
69 } | |
70 | |
5861 | 71 tree_decl_elt * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
72 tree_decl_elt::dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
73 symbol_table::context_id context) const |
5861 | 74 { |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
75 return new tree_decl_elt (id ? id->dup (scope, context) : 0, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
76 expr ? expr->dup (scope, context) : 0); |
5861 | 77 } |
78 | |
2982 | 79 void |
80 tree_decl_elt::accept (tree_walker& tw) | |
81 { | |
82 tw.visit_decl_elt (*this); | |
83 } | |
84 | |
85 // Initializer lists for declaration statements. | |
86 | |
5861 | 87 tree_decl_init_list * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
88 tree_decl_init_list::dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
89 symbol_table::context_id context) const |
5861 | 90 { |
91 tree_decl_init_list *new_dil = new tree_decl_init_list (); | |
92 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
93 for (const_iterator p = begin (); p != end (); p++) |
5861 | 94 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
95 const tree_decl_elt *elt = *p; |
5861 | 96 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
97 new_dil->append (elt ? elt->dup (scope, context) : 0); |
5861 | 98 } |
99 | |
100 return new_dil; | |
101 } | |
102 | |
2982 | 103 void |
104 tree_decl_init_list::accept (tree_walker& tw) | |
105 { | |
106 tw.visit_decl_init_list (*this); | |
107 } | |
108 | |
109 // Base class for declaration commands (global, static). | |
110 | |
111 tree_decl_command::~tree_decl_command (void) | |
112 { | |
113 delete init_list; | |
114 } | |
115 | |
116 // Global. | |
117 | |
5861 | 118 tree_command * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
119 tree_global_command::dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
120 symbol_table::context_id context) const |
5861 | 121 { |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
122 return |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
123 new tree_global_command (init_list ? init_list->dup (scope, context) : 0, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
124 line (), column ()); |
5861 | 125 } |
126 | |
2989 | 127 void |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
128 tree_global_command::accept (tree_walker& tw) |
2982 | 129 { |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
130 tw.visit_global_command (*this); |
2982 | 131 } |
132 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
133 // Static. |
2982 | 134 |
5861 | 135 tree_command * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
136 tree_static_command::dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
137 symbol_table::context_id context) const |
5861 | 138 { |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
139 return |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
140 new tree_static_command (init_list ? init_list->dup (scope, context) : 0, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
141 line (), column ()); |
5861 | 142 } |
143 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
144 void |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
145 tree_static_command::accept (tree_walker& tw) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
146 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
147 tw.visit_static_command (*this); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
148 } |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
149 |
2982 | 150 /* |
151 ;;; Local Variables: *** | |
152 ;;; mode: C++ *** | |
153 ;;; End: *** | |
154 */ |