00001 #ifndef DVE_SYMBOL_HH
00002 #define DVE_SYMBOL_HH
00003
00008 #ifndef DOXYGEN_PROCESSING
00009 #include <vector>
00010 #include "system/dve/dve_expression.hh"
00011
00012 namespace divine {
00013 #endif //DOXYGEN_PROCESSING
00014
00015 class dve_expression_t;
00017 enum dve_var_type_t
00018 {
00019 VAR_BYTE = 0,
00020 VAR_INT = 1
00021 };
00023 enum dve_sym_type_t
00024 { SYM_VARIABLE,
00025 SYM_STATE,
00026 SYM_PROCESS,
00027 SYM_CHANNEL
00028 };
00029
00032
00060 class dve_symbol_t
00061 {
00062 private:
00063 struct var_t
00064 {
00065 bool vector;
00066 bool const_var;
00067 dve_var_type_t var_type;
00068 size_int_t bound;
00069 union
00070 {
00071 dve_expression_t * expr;
00072 std::vector<dve_expression_t *> * field;
00073 } init;
00074 };
00075 size_int_t lid;
00076 size_int_t sid;
00077 size_int_t gid;
00078 dve_sym_type_t type;
00079 const char *name;
00080 size_int_t namelen;
00081 bool valid;
00082 var_t info_var;
00083 size_int_t frame;
00084 size_int_t channel_item_count;
00085 bool channel_typed;
00086 array_t<dve_var_type_t> channel_type_list;
00087
00088 slong_int_t channel_buffer_size;
00089
00090 public:
00092
00095 static const size_int_t CHANNEL_UNUSED;
00097
00101 dve_symbol_t(const dve_sym_type_t t, const char * const n, const size_int_t l):
00102 lid(NO_ID), sid(NO_ID), gid(NO_ID), type(t), name(n),
00103 namelen(l), valid(false), channel_item_count(CHANNEL_UNUSED),
00104 channel_typed(false), channel_buffer_size(0) {}
00106 ~dve_symbol_t();
00108
00112 size_int_t get_lid() const { return lid; }
00114 void set_lid(const size_int_t lid_arg) { lid = lid_arg; }
00116 size_int_t get_sid() const { return sid; }
00118 void set_sid(const size_int_t symb_id) { sid = symb_id; }
00120 size_int_t get_gid() const { return gid; }
00122 void set_gid(const size_int_t gid_arg) { gid = gid_arg; }
00124
00126 size_int_t get_process_gid() const { return frame; }
00128 void set_process_gid(const size_int_t nbr) { frame = nbr; }
00130 const char * get_name() const { return name; }
00132 void set_name(const char * new_name) { name = new_name; }
00134 size_int_t get_name_length() const { return namelen; }
00136 void set_name(const char * const str, const size_int_t length)
00137 { namelen = length; name = str; }
00139 dve_sym_type_t get_symbol_type() const { return type; }
00141 void set_symbol_type(const dve_sym_type_t symb_type) { type = symb_type; }
00143 bool get_valid() const { return valid; }
00145 void set_valid(const bool is_valid) { valid = is_valid; }
00147 bool is_variable() const { return (type == SYM_VARIABLE); }
00149 bool is_process() const { return (type == SYM_PROCESS); }
00151 bool is_channel() const { return (type == SYM_CHANNEL); }
00153 bool is_state() const { return (type == SYM_STATE); }
00156
00157 bool is_vector() const { return info_var.vector; }
00159 void set_vector(const bool is_vector) { info_var.vector = is_vector; }
00161 bool is_const() const { return info_var.const_var; }
00163 void set_const(const bool const_var) { info_var.const_var = const_var; }
00165
00167 bool is_byte() const { return (info_var.var_type == VAR_BYTE); }
00169
00171 bool is_int() const { return (info_var.var_type == VAR_INT); }
00173 dve_var_type_t get_var_type() const { return info_var.var_type; }
00175 void set_var_type(const dve_var_type_t var_type) { info_var.var_type=var_type; }
00177
00180
00181
00184 dve_expression_t * get_init_expr() { return (info_var.init.expr); }
00187 const dve_expression_t * get_init_expr() const { return (info_var.init.expr); }
00189 void set_init_expr(dve_expression_t * const p_expr)
00190 { info_var.init.expr = p_expr; }
00192
00194
00195 size_int_t get_vector_size() const { return info_var.bound; }
00197 void set_vector_size(const size_int_t ar_size) { info_var.bound = ar_size; }
00199 size_int_t get_init_expr_count() const
00200 { return (info_var.init.field ? (*info_var.init.field).size() : 0); }
00202 std::vector<dve_expression_t *> * get_init_expr_field()
00203 { return info_var.init.field; }
00206 void create_init_expr_field()
00207 { info_var.init.field = new std::vector<dve_expression_t *>; }
00209
00212 void no_init_expr_field() { info_var.init.field = 0; }
00214 const dve_expression_t * get_init_expr(const size_int_t i) const
00215 { return (*info_var.init.field)[i]; }
00217 void set_init_expr(const size_int_t i, dve_expression_t * const trans)
00218 { (*info_var.init.field)[i] = trans; }
00220
00222
00223
00226 size_int_t get_channel_item_count() const
00227 { if (get_channel_typed()) return get_channel_type_list_size();
00228 else return channel_item_count; }
00230
00231 void set_channel_item_count(const size_int_t size)
00232 { if (get_channel_typed()) set_channel_type_list_size(size);
00233 else channel_item_count = size; }
00235 bool get_channel_typed() const { return channel_typed; }
00237 void set_channel_typed(const bool typed) { channel_typed = typed; }
00240 size_int_t get_channel_type_list_size() const
00241 { return channel_type_list.size(); }
00244 void set_channel_type_list_size(const size_int_t size)
00245 { channel_type_list.resize(size); }
00248 dve_var_type_t get_channel_type_list_item(const size_int_t index) const
00249 { return channel_type_list[index]; }
00252 void set_channel_type_list_item(const size_int_t index,
00253 const dve_var_type_t type_item)
00254 { channel_type_list[index] = type_item; }
00256 slong_int_t get_channel_buffer_size() const
00257 { return channel_buffer_size; }
00259 void set_channel_buffer_size(const slong_int_t buffer_size)
00260 { channel_buffer_size = buffer_size; }
00262 };
00263
00264 #ifndef DOXYGEN_PROCESSING
00265 }
00266 #include "common/undeb.hh"
00267
00268 #endif //DOXYGEN_PROCESSING
00269
00270 #endif
00271