comparison src/symtab.h @ 530:c3268005bf98

[project @ 1994-07-20 19:26:33 by jwe]
author jwe
date Wed, 20 Jul 1994 19:26:33 +0000
parents 88614b380d6e
children a8d5d1072d99
comparison
equal deleted inserted replaced
529:7ea224e713cd 530:c3268005bf98
1 // Symbol table classes. -*- C++ -*- 1 // symtab.h -*- C++ -*-
2 /* 2 /*
3 3
4 Copyright (C) 1992, 1993, 1994 John W. Eaton 4 Copyright (C) 1992, 1993, 1994 John W. Eaton
5 5
6 This file is part of Octave. 6 This file is part of Octave.
26 26
27 #if defined (__GNUG__) 27 #if defined (__GNUG__)
28 #pragma interface 28 #pragma interface
29 #endif 29 #endif
30 30
31 #include <stdlib.h>
32 #include <string.h>
33 #include <iostream.h>
34 #include <assert.h>
35
36 #include "SLStack.h" 31 #include "SLStack.h"
37 32
38 #include "builtins.h" 33 #include "variables.h"
34
35 class ostream;
39 36
40 #define HASH_TABLE_SIZE 1024 /* Must be multiple of 2 */ 37 #define HASH_TABLE_SIZE 1024 /* Must be multiple of 2 */
41 #define HASH_MASK (HASH_TABLE_SIZE - 1) 38 #define HASH_MASK (HASH_TABLE_SIZE - 1)
42 39
43 class tree; 40 class tree;
61 58
62 public: 59 public:
63 60
64 symbol_def (void); 61 symbol_def (void);
65 symbol_def (tree_constant *t); 62 symbol_def (tree_constant *t);
66 symbol_def (tree_builtin *t); 63 symbol_def (tree_builtin *t, unsigned fcn_type = 0);
67 symbol_def (tree_function *t); 64 symbol_def (tree_function *t, unsigned fcn_type = 0);
68 65
69 ~symbol_def (void); 66 ~symbol_def (void);
70 67
71 int is_variable (void) const; 68 int is_variable (void) const;
72 int is_function (void) const; 69 int is_function (void) const;
70 int is_text_function (void) const;
71 int is_mapper_function (void) const;
73 int is_user_variable (void) const; 72 int is_user_variable (void) const;
74 int is_user_function (void) const; 73 int is_user_function (void) const;
75 int is_builtin_variable (void) const; 74 int is_builtin_variable (void) const;
76 int is_builtin_function (void) const; 75 int is_builtin_function (void) const;
77 76
78 void define (tree_constant *t); 77 void define (tree_constant *t);
79 void define (tree_builtin *t); 78 void define (tree_builtin *t, unsigned fcn_type = 0);
80 void define (tree_function *t); 79 void define (tree_function *t, unsigned fcn_type = 0);
81 80
82 void protect (void); 81 void protect (void);
83 void unprotect (void); 82 void unprotect (void);
84 void make_eternal (void); 83 void make_eternal (void);
85 84
93 { 92 {
94 UNKNOWN = 0, 93 UNKNOWN = 0,
95 USER_FUNCTION = 1, 94 USER_FUNCTION = 1,
96 USER_VARIABLE = 2, 95 USER_VARIABLE = 2,
97 BUILTIN_FUNCTION = 4, 96 BUILTIN_FUNCTION = 4,
98 BUILTIN_VARIABLE = 8 97 TEXT_FUNCTION = 8,
98 MAPPER_FUNCTION = 16,
99 BUILTIN_VARIABLE = 32
99 }; 100 };
100 101
101 friend maybe_delete (symbol_def *def); 102 friend maybe_delete (symbol_def *def);
102 103
103 private: 104 private:
104 105
105 unsigned type : 4; 106 unsigned type : 6;
106 unsigned eternal : 1; 107 unsigned eternal : 1;
107 unsigned read_only : 1; 108 unsigned read_only : 1;
108 109
109 char *help_string; 110 char *help_string;
110 tree_fvc *definition; 111 tree_fvc *definition;
125 { 126 {
126 friend class symbol_record_info; 127 friend class symbol_record_info;
127 128
128 public: 129 public:
129 symbol_record (void); 130 symbol_record (void);
130 symbol_record (const char *n, symbol_record *nxt = (symbol_record *) NULL); 131 symbol_record (const char *n, symbol_record *nxt = 0);
131 132
132 ~symbol_record (void); 133 ~symbol_record (void);
133 134
134 char *name (void) const; 135 char *name (void) const;
135 char *help (void) const; 136 char *help (void) const;
137 138
138 void rename (const char *n); 139 void rename (const char *n);
139 140
140 int is_function (void) const; 141 int is_function (void) const;
141 int is_user_function (void) const; 142 int is_user_function (void) const;
143 int is_text_function (void) const;
144 int is_mapper_function (void) const;
142 int is_builtin_function (void) const; 145 int is_builtin_function (void) const;
143 int is_variable (void) const; 146 int is_variable (void) const;
144 int is_user_variable (void) const; 147 int is_user_variable (void) const;
145 int is_builtin_variable (void) const; 148 int is_builtin_variable (void) const;
146 149
155 void make_eternal (void); 158 void make_eternal (void);
156 159
157 void set_sv_function (sv_Function f); 160 void set_sv_function (sv_Function f);
158 161
159 int define (tree_constant *t); 162 int define (tree_constant *t);
160 int define (tree_builtin *t); 163 int define (tree_builtin *t, int text_fcn = 0);
161 int define (tree_function *t); 164 int define (tree_function *t, int text_fcn = 0);
162 int define_as_fcn (tree_constant *t); 165 int define_as_fcn (tree_constant *t);
163 int define_builtin_var (tree_constant *t); 166 int define_builtin_var (tree_constant *t);
164 167
165 void document (const char *h); 168 void document (const char *h);
166 169
281 #define SYMTAB_ALL_SCOPES (SYMTAB_LOCAL_SCOPE | SYMTAB_GLOBAL_SCOPE) 284 #define SYMTAB_ALL_SCOPES (SYMTAB_LOCAL_SCOPE | SYMTAB_GLOBAL_SCOPE)
282 285
283 #define SYMTAB_ALL_TYPES (symbol_def::USER_FUNCTION \ 286 #define SYMTAB_ALL_TYPES (symbol_def::USER_FUNCTION \
284 | symbol_def::USER_VARIABLE \ 287 | symbol_def::USER_VARIABLE \
285 | symbol_def::BUILTIN_FUNCTION \ 288 | symbol_def::BUILTIN_FUNCTION \
289 | symbol_def::TEXT_FUNCTION \
286 | symbol_def::BUILTIN_VARIABLE) 290 | symbol_def::BUILTIN_VARIABLE)
287 291
288 class 292 class
289 symbol_table 293 symbol_table
290 { 294 {