Mercurial > hg > octave-avbm
annotate src/pt-id.h @ 9680:73153525df9a
initial implementation of OpenGL image rendering
author | Shai Ayal <shaiay@users.sourceforge.net> |
---|---|
date | Thu, 01 Oct 2009 11:41:28 -0400 |
parents | c5f03874ea2a |
children | cd96d29c5efa |
rev | line source |
---|---|
2887 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004, 2005, 2006, 2007, |
4 2008, 2009 John W. Eaton | |
2887 | 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. | |
2887 | 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/>. | |
2887 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_identifier_h) | |
25 #define octave_tree_identifier_h 1 | |
26 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
27 #include <iosfwd> |
2887 | 28 #include <string> |
29 | |
2943 | 30 class octave_value; |
31 class octave_value_list; | |
2887 | 32 class octave_function; |
33 | |
34 class tree_walker; | |
35 | |
7677
db02cc0ba8f2
handle breakpoints in tree_identifier::do_lookup
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
36 #include "pt-bp.h" |
2980 | 37 #include "pt-exp.h" |
7336 | 38 #include "symtab.h" |
2887 | 39 |
40 // Symbols from the symbol table. | |
41 | |
42 class | |
2971 | 43 tree_identifier : public tree_expression |
2887 | 44 { |
45 friend class tree_index_expression; | |
46 | |
47 public: | |
48 | |
49 tree_identifier (int l = -1, int c = -1) | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
50 : tree_expression (l, c), sym (), scope (-1) { } |
2887 | 51 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
52 tree_identifier (const symbol_table::symbol_record& s, |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
53 int l = -1, int c = -1, |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
54 symbol_table::scope_id sc = symbol_table::current_scope ()) |
7753
e76a4a6e3c47
initialize args_evaluated; delete useless statement
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
55 : tree_expression (l, c), sym (s), scope (sc) { } |
2887 | 56 |
57 ~tree_identifier (void) { } | |
58 | |
4267 | 59 bool has_magic_end (void) const { return (name () == "__end__"); } |
60 | |
3933 | 61 bool is_identifier (void) const { return true; } |
2887 | 62 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
63 // The name doesn't change with scope, so use sym instead of |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
64 // accessing it through sym so that this function may remain const. |
7336 | 65 std::string name (void) const { return sym.name (); } |
2887 | 66 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
67 bool is_defined (void) { return xsym().is_defined (); } |
7336 | 68 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
69 bool is_variable (void) { return xsym().is_variable (); } |
2887 | 70 |
7336 | 71 // Try to find a definition for an identifier. Here's how: |
72 // | |
73 // * If the identifier is already defined and is a function defined | |
74 // in an function file that has been modified since the last time | |
75 // we parsed it, parse it again. | |
76 // | |
77 // * If the identifier is not defined, try to find a builtin | |
78 // variable or an already compiled function with the same name. | |
79 // | |
80 // * If the identifier is still undefined, try looking for an | |
81 // function file to parse. | |
82 // | |
83 // * On systems that support dynamic linking, we prefer .oct files, | |
84 // then .mex files, then .m files. | |
2971 | 85 |
86 octave_value | |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
87 do_lookup (const octave_value_list& args = octave_value_list ()) |
7336 | 88 { |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
89 return xsym().find (args); |
7336 | 90 } |
2887 | 91 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
92 void mark_global (void) { xsym().mark_global (); } |
7336 | 93 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
94 void mark_as_static (void) { xsym().init_persistent (); } |
7336 | 95 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
96 void mark_as_formal_parameter (void) { xsym().mark_formal (); } |
2887 | 97 |
3010 | 98 // We really need to know whether this symbol referst to a variable |
99 // or a function, but we may not know that yet. | |
100 | |
3933 | 101 bool lvalue_ok (void) const { return true; } |
3010 | 102 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
103 octave_value rvalue1 (int nargout = 1); |
2887 | 104 |
2971 | 105 octave_value_list rvalue (int nargout); |
2887 | 106 |
2979 | 107 octave_lvalue lvalue (void); |
2887 | 108 |
109 void eval_undefined_error (void); | |
110 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
111 tree_identifier *dup (symbol_table::scope_id scope, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
112 symbol_table::context_id context) const; |
5861 | 113 |
2887 | 114 void accept (tree_walker& tw); |
115 | |
116 private: | |
117 | |
118 // The symbol record that this identifier references. | |
7336 | 119 symbol_table::symbol_record sym; |
2988 | 120 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
121 symbol_table::scope_id scope; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
122 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
123 // A script may be executed in multiple scopes. If the last one was |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
124 // different from the one we are in now, update sym to be from the |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
125 // new scope. |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
126 symbol_table::symbol_record& xsym (void) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
127 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
128 symbol_table::scope_id curr_scope = symbol_table::current_scope (); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
129 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
130 if (scope != curr_scope) |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
131 { |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
132 scope = curr_scope; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
133 sym = symbol_table::insert (sym.name ()); |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
134 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
135 |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
136 return sym; |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
137 } |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
138 |
2988 | 139 // No copying! |
140 | |
141 tree_identifier (const tree_identifier&); | |
142 | |
143 tree_identifier& operator = (const tree_identifier&); | |
2887 | 144 }; |
145 | |
146 #endif | |
147 | |
148 /* | |
149 ;;; Local Variables: *** | |
150 ;;; mode: C++ *** | |
151 ;;; End: *** | |
152 */ |