Mercurial > hg > octave-nkf
annotate src/pt-idx.h @ 10182:0522a65bcd56
assume unistd.h and sys/types.h exist
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Jan 2010 15:41:19 -0500 |
parents | cd96d29c5efa |
children | f3b65e1ae355 |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008, 2009 John W. Eaton |
2980 | 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. | |
2980 | 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/>. | |
2980 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_index_h) | |
25 #define octave_tree_index_h 1 | |
26 | |
4219 | 27 #include <list> |
28 | |
2980 | 29 class tree_argument_list; |
30 | |
31 class tree_walker; | |
32 | |
3933 | 33 class Octave_map; |
2980 | 34 class octave_value; |
35 class octave_value_list; | |
36 class octave_lvalue; | |
37 | |
38 #include "str-vec.h" | |
39 | |
40 #include "pt-exp.h" | |
7336 | 41 #include "symtab.h" |
2980 | 42 |
43 // Index expressions. | |
44 | |
45 class | |
46 tree_index_expression : public tree_expression | |
47 { | |
48 public: | |
49 | |
50 tree_index_expression (tree_expression *e = 0, tree_argument_list *lst = 0, | |
3933 | 51 int l = -1, int c = -1, char t = '('); |
2980 | 52 |
3930 | 53 tree_index_expression (tree_expression *e, const std::string& n, |
54 int l = -1, int c = -1); | |
55 | |
4131 | 56 tree_index_expression (tree_expression *e, tree_expression* df, |
57 int l = -1, int c = -1); | |
58 | |
2980 | 59 ~tree_index_expression (void); |
60 | |
5099 | 61 bool has_magic_end (void) const; |
4267 | 62 |
3933 | 63 void append (tree_argument_list *lst = 0, char t = '('); |
3930 | 64 |
3933 | 65 void append (const std::string& n); |
66 | |
4131 | 67 void append (tree_expression *df); |
68 | |
3933 | 69 bool is_index_expression (void) const { return true; } |
2980 | 70 |
3523 | 71 std::string name (void) const; |
2991 | 72 |
3933 | 73 tree_expression *expression (void) { return expr; } |
3930 | 74 |
4219 | 75 std::list<tree_argument_list *> arg_lists (void) { return args; } |
3930 | 76 |
3933 | 77 std::string type_tags (void) { return type; } |
2980 | 78 |
4219 | 79 std::list<string_vector> arg_names (void) { return arg_nm; } |
2980 | 80 |
3933 | 81 bool lvalue_ok (void) const { return expr->lvalue_ok (); } |
3010 | 82 |
3933 | 83 bool rvalue_ok (void) const { return true; } |
2980 | 84 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
85 octave_value rvalue1 (int nargout = 1); |
2980 | 86 |
87 octave_value_list rvalue (int nargout); | |
88 | |
89 octave_lvalue lvalue (void); | |
90 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
91 tree_index_expression *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
92 symbol_table::context_id context) const; |
5861 | 93 |
2980 | 94 void accept (tree_walker& tw); |
95 | |
96 private: | |
97 | |
3930 | 98 // The LHS of this index expression. |
2980 | 99 tree_expression *expr; |
100 | |
3933 | 101 // The indices (only valid if type == paren || type == brace). |
4219 | 102 std::list<tree_argument_list *> args; |
2980 | 103 |
3930 | 104 // The type of this index expression. |
3933 | 105 std::string type; |
3929 | 106 |
4131 | 107 // The names of the arguments. Used for constant struct element |
108 // references. | |
4219 | 109 std::list<string_vector> arg_nm; |
3933 | 110 |
4131 | 111 // The list of dynamic field names, if any. |
4219 | 112 std::list<tree_expression *> dyn_field; |
4131 | 113 |
7790
c23fab029f46
tree_index_expression constructor: delete default arg values
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
114 tree_index_expression (int l, int c); |
5861 | 115 |
4131 | 116 Octave_map make_arg_struct (void) const; |
117 | |
4219 | 118 std::string |
119 get_struct_index | |
120 (std::list<string_vector>::const_iterator p_arg_nm, | |
121 std::list<tree_expression *>::const_iterator p_dyn_field) const; | |
2988 | 122 |
123 // No copying! | |
124 | |
125 tree_index_expression (const tree_index_expression&); | |
126 | |
127 tree_index_expression& operator = (const tree_index_expression&); | |
2980 | 128 }; |
129 | |
130 #endif |