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

symbols.h

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, std::string 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         std::string 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(std::string name);
00204 
00206         symbol_t operator[] (int32_t);
00207 
00209         const symbol_t operator[] (int32_t) const;
00210 
00212         symbol_t addSymbol(std::string name, type_t, void *user = NULL);
00213 
00215         void add(frame_t);
00216         
00218         bool resolve(std::string 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             META = 32
00241         };
00242     }
00243 
00271     class type_t
00272     {
00273     private:
00274         struct type_data;
00275         type_data *data;
00276         type_t(void *);
00277     public:
00279         type_t();
00280 
00282         type_t(const type_t &);
00283 
00285         ~type_t();
00286 
00288         const type_t &operator = (const type_t &);
00289 
00291         bool operator == (const type_t &) const;
00292 
00294         bool operator != (const type_t &) const;
00295         
00297         type_t getBase() const;
00298 
00300         frame_t getRecordFields() const;
00301 
00303         frame_t getParameters() const;
00304 
00306         frame_t getFrame() const;
00307         
00309         type_t getSub();
00310 
00312         type_t getReturnType();
00313  
00315         bool hasPrefix(prefix::prefix_t) const;
00316 
00318         type_t setPrefix(bool set, prefix::prefix_t) const;
00319 
00321         expression_t getArraySize() const;
00322 
00324         std::pair<expression_t, expression_t> getRange() const;
00325 
00327         static type_t createInteger(expression_t, expression_t);
00328         
00330         static type_t createRecord(frame_t);
00331 
00333         static type_t createFunction(frame_t, type_t);
00334 
00336         static type_t createArray(expression_t, type_t);
00337 
00339         static type_t createTypeName(type_t);
00340 
00342         static type_t createTemplate(frame_t);
00343 
00345         static type_t createProcess(frame_t);
00346 
00348         static type_t createBase();
00349 
00350         static type_t UNKNOWN;
00351         static type_t VOID_TYPE;
00352         static type_t CLOCK;
00353         static type_t INT;
00354         static type_t BOOL;
00355         static type_t LOCATION;
00356         static type_t CHANNEL;
00357         static type_t TEMPLATE;
00358         static type_t INSTANCE;
00359         static type_t FUNCTION;
00360         static type_t ARRAY;
00361         static type_t RECORD;
00362         static type_t PROCESS;
00363         static type_t NTYPE;
00364         static type_t INVARIANT;
00365         static type_t GUARD;
00366         static type_t DIFF;
00367         static type_t CONSTRAINT;
00368     };
00369 }
00370 
00371 std::ostream &operator << (std::ostream &o, const UTAP::type_t &t);
00372 
00373 #endif

Generated on Thu Feb 17 15:20:58 2005 for libutap by  doxygen 1.4.1