Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

symbols.hh

Go to the documentation of this file.
00001 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; -*- 00002 00003 /* libutap - Uppaal Timed Automata Parser. 00004 Copyright (C) 2002 Uppsala University and Aalborg University. 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public License 00008 as published by the Free Software Foundation; either version 2.1 of 00009 the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00019 USA 00020 */ 00021 00022 #ifndef UTAP_SYMBOLS_HH 00023 #define UTAP_SYMBOLS_HH 00024 00025 #include <inttypes.h> 00026 #include <exception> 00027 00028 namespace UTAP 00029 { 00030 class frame_t; 00031 class type_t; 00032 class expression_t; 00033 00034 class NoParentException : public std::exception {}; 00035 00038 class range_t { 00039 public: 00040 int lower, upper; 00041 00043 range_t(); 00044 00046 range_t(int); 00047 00049 range_t(int,int); 00050 00052 range_t(const std::pair<int,int> &); 00053 00055 range_t intersect(const range_t &) const; 00056 00058 range_t join(const range_t &) const; 00059 00061 bool contains(const range_t &) const; 00062 00064 bool contains(int32_t) const; 00065 00067 bool operator == (const range_t &) const; 00068 00070 bool operator != (const range_t &) const; 00071 00073 bool isEmpty() const; 00074 }; 00075 00076 00096 class symbol_t 00097 { 00098 private: 00099 struct symbol_data; 00100 symbol_data *data; 00101 protected: 00102 friend class frame_t; 00103 symbol_t(void *frame, type_t &type, const char *name, void *user); 00104 public: 00106 symbol_t(); 00107 00109 symbol_t(const symbol_t &); 00110 00112 ~symbol_t(); 00113 00115 const symbol_t &operator = (const symbol_t &); 00116 00118 bool operator == (const symbol_t &) const; 00119 00121 bool operator != (const symbol_t &) const; 00122 00124 bool operator < (const symbol_t &) const; 00125 00127 frame_t getFrame(); 00128 00130 type_t getType() const; 00131 00133 void setType(type_t); 00134 00136 void *getData(); 00137 00139 const void *getData() const; 00140 00142 const char *getName() const; 00143 00145 void setData(void *); 00146 }; 00147 00169 class frame_t 00170 { 00171 private: 00172 struct frame_data; 00173 frame_data *data; 00174 protected: 00175 friend class symbol_t; 00176 frame_t(void *); 00177 public: 00179 frame_t(); 00180 00182 frame_t(const frame_t &); 00183 00185 ~frame_t(); 00186 00188 const frame_t &operator = (const frame_t &); 00189 00191 bool operator == (const frame_t &) const; 00192 00194 bool operator != (const frame_t &) const; 00195 00197 uint32_t getSize() const; 00198 00200 symbol_t getSymbol(int32_t); 00201 00203 int32_t getIndexOf(const char *name); 00204 00206 symbol_t operator[] (int32_t); 00207 00209 const symbol_t operator[] (int32_t) const; 00210 00212 symbol_t addSymbol(const char *, type_t, void *user = NULL); 00213 00215 void add(frame_t); 00216 00218 bool resolve(const char *name, symbol_t &symbol); 00219 00221 frame_t getParent() throw (NoParentException); 00222 00224 bool hasParent() const; 00225 00227 static frame_t createFrame(); 00228 00230 static frame_t createFrame(const frame_t &parent); 00231 }; 00232 00233 namespace prefix { 00234 enum prefix_t { 00235 URGENT = 1, 00236 COMMITTED = 2, 00237 CONSTANT = 4, 00238 BROADCAST = 8, 00239 REFERENCE = 16 00240 }; 00241 } 00242 00270 class type_t 00271 { 00272 private: 00273 struct type_data; 00274 type_data *data; 00275 type_t(void *); 00276 public: 00278 type_t(); 00279 00281 type_t(const type_t &); 00282 00284 ~type_t(); 00285 00287 const type_t &operator = (const type_t &); 00288 00290 bool operator == (const type_t &) const; 00291 00293 bool operator != (const type_t &) const; 00294 00296 type_t getBase() const; 00297 00299 frame_t getRecordFields() const; 00300 00302 frame_t getParameters() const; 00303 00305 frame_t getFrame() const; 00306 00308 type_t getSub(); 00309 00311 bool hasPrefix(prefix::prefix_t) const; 00312 00314 type_t setPrefix(bool set, prefix::prefix_t) const; 00315 00317 expression_t getArraySize() const; 00318 00320 std::pair<expression_t, expression_t> getRange() const; 00321 00323 static type_t createInteger(expression_t, expression_t); 00324 00326 static type_t createRecord(frame_t); 00327 00329 static type_t createFunction(frame_t, type_t); 00330 00332 static type_t createArray(expression_t, type_t); 00333 00335 static type_t createTypeName(type_t); 00336 00338 static type_t createTemplate(frame_t); 00339 00341 static type_t createProcess(frame_t); 00342 00344 static type_t createBase(); 00345 00346 static type_t UNKNOWN; 00347 static type_t VOID_TYPE; 00348 static type_t CLOCK; 00349 static type_t INT; 00350 static type_t BOOL; 00351 static type_t LOCATION; 00352 static type_t CHANNEL; 00353 static type_t TEMPLATE; 00354 static type_t INSTANCE; 00355 static type_t FUNCTION; 00356 static type_t ARRAY; 00357 static type_t RECORD; 00358 static type_t PROCESS; 00359 static type_t NTYPE; 00360 static type_t INVARIANT; 00361 static type_t GUARD; 00362 static type_t DIFF; 00363 static type_t CONSTRAINT; 00364 }; 00365 } 00366 00367 #endif

Generated on Sat May 15 12:33:41 2004 for libutap by doxygen 1.3.7