Mercurial > hg > octave-avbm
comparison src/pt-id.h @ 7336:745a8299c2b5
[project @ 2007-12-28 20:56:55 by jwe]
author | jwe |
---|---|
date | Fri, 28 Dec 2007 20:56:58 +0000 |
parents | a1dbe9d80eee |
children | db02cc0ba8f2 |
comparison
equal
deleted
inserted
replaced
7335:58f5fab3ebe5 | 7336:745a8299c2b5 |
---|---|
28 #include <string> | 28 #include <string> |
29 | 29 |
30 class octave_value; | 30 class octave_value; |
31 class octave_value_list; | 31 class octave_value_list; |
32 class octave_function; | 32 class octave_function; |
33 class symbol_record; | |
34 | 33 |
35 class tree_walker; | 34 class tree_walker; |
36 | 35 |
37 #include "pt-exp.h" | 36 #include "pt-exp.h" |
37 #include "symtab.h" | |
38 | 38 |
39 // Symbols from the symbol table. | 39 // Symbols from the symbol table. |
40 | 40 |
41 class | 41 class |
42 tree_identifier : public tree_expression | 42 tree_identifier : public tree_expression |
44 friend class tree_index_expression; | 44 friend class tree_index_expression; |
45 | 45 |
46 public: | 46 public: |
47 | 47 |
48 tree_identifier (int l = -1, int c = -1) | 48 tree_identifier (int l = -1, int c = -1) |
49 : tree_expression (l, c), sym (0) { } | 49 : tree_expression (l, c), sym () { } |
50 | 50 |
51 tree_identifier (symbol_record *s, int l = -1, int c = -1) | 51 tree_identifier (const symbol_table::symbol_record& s, int l = -1, int c = -1) |
52 : tree_expression (l, c), sym (s) { } | 52 : tree_expression (l, c), sym (s) { } |
53 | 53 |
54 ~tree_identifier (void) { } | 54 ~tree_identifier (void) { } |
55 | 55 |
56 bool has_magic_end (void) const { return (name () == "__end__"); } | 56 bool has_magic_end (void) const { return (name () == "__end__"); } |
57 | 57 |
58 bool is_identifier (void) const { return true; } | 58 bool is_identifier (void) const { return true; } |
59 | 59 |
60 std::string name (void) const; | 60 std::string name (void) const { return sym.name (); } |
61 | 61 |
62 tree_identifier *define (octave_function *f, unsigned int sym_type); | 62 bool is_defined (void) { return sym.is_defined (); } |
63 | 63 |
64 void document (const std::string& s); | 64 bool is_variable (void) { return sym.is_variable (); } |
65 | 65 |
66 bool is_defined (void); | 66 // Try to find a definition for an identifier. Here's how: |
67 | 67 // |
68 bool is_function (void); | 68 // * If the identifier is already defined and is a function defined |
69 // in an function file that has been modified since the last time | |
70 // we parsed it, parse it again. | |
71 // | |
72 // * If the identifier is not defined, try to find a builtin | |
73 // variable or an already compiled function with the same name. | |
74 // | |
75 // * If the identifier is still undefined, try looking for an | |
76 // function file to parse. | |
77 // | |
78 // * On systems that support dynamic linking, we prefer .oct files, | |
79 // then .mex files, then .m files. | |
69 | 80 |
70 octave_value | 81 octave_value |
71 do_lookup (bool& script_file_executed, bool exec_script = true); | 82 do_lookup (bool& script_file_executed, bool exec_script = true) |
83 { | |
84 // FIXME -- SYMTAB: what about executing script files? | |
85 octave_value_list evaluated_args; | |
86 bool args_evaluated; | |
87 return sym.find (0, string_vector (), evaluated_args, args_evaluated); | |
88 } | |
72 | 89 |
73 void link_to_global (void); | 90 octave_value |
91 do_lookup (tree_argument_list *args, const string_vector& arg_names, | |
92 octave_value_list& evaluated_args, bool& args_evaluated) | |
93 { | |
94 return sym.find (args, arg_names, evaluated_args, args_evaluated); | |
95 } | |
74 | 96 |
75 void mark_as_static (void); | 97 void mark_global (void) { sym.mark_global (); } |
76 | 98 |
77 void mark_as_formal_parameter (void); | 99 void mark_as_static (void) { sym.init_persistent (); } |
100 | |
101 void mark_as_formal_parameter (void) { sym.mark_formal (); } | |
78 | 102 |
79 // We really need to know whether this symbol referst to a variable | 103 // We really need to know whether this symbol referst to a variable |
80 // or a function, but we may not know that yet. | 104 // or a function, but we may not know that yet. |
81 | 105 |
82 bool lvalue_ok (void) const { return true; } | 106 bool lvalue_ok (void) const { return true; } |
87 | 111 |
88 octave_lvalue lvalue (void); | 112 octave_lvalue lvalue (void); |
89 | 113 |
90 void eval_undefined_error (void); | 114 void eval_undefined_error (void); |
91 | 115 |
92 tree_identifier *dup (symbol_table *sym_tab); | 116 tree_identifier *dup (symbol_table::scope_id scope); |
93 | 117 |
94 void accept (tree_walker& tw); | 118 void accept (tree_walker& tw); |
95 | 119 |
96 private: | 120 private: |
97 | 121 |
98 // The symbol record that this identifier references. | 122 // The symbol record that this identifier references. |
99 symbol_record *sym; | 123 symbol_table::symbol_record sym; |
100 | 124 |
101 // No copying! | 125 // No copying! |
102 | 126 |
103 tree_identifier (const tree_identifier&); | 127 tree_identifier (const tree_identifier&); |
104 | 128 |