Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound 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     };
00072 
00073 
00093     class symbol_t
00094     {
00095     private:
00096         struct symbol_data;
00097         symbol_data *data;
00098     protected:
00099         friend class frame_t;
00100         symbol_t(void *frame, type_t &type, const char *name, void *user);
00101     public:
00103         symbol_t();
00104 
00106         symbol_t(const symbol_t &);
00107         
00109         ~symbol_t();
00110 
00112         const symbol_t &operator = (const symbol_t &);
00113 
00115         bool operator == (const symbol_t &) const;
00116 
00118         bool operator != (const symbol_t &) const;
00119 
00121         bool operator < (const symbol_t &) const;
00122         
00124         frame_t getFrame();
00125 
00127         type_t getType() const;
00128 
00130         void setType(type_t);
00131         
00133         void *getData();
00134 
00136         const void *getData() const;
00137 
00139         const char *getName() const;
00140         
00142         void setData(void *);
00143     };
00144 
00166     class frame_t
00167     {
00168     private:
00169         struct frame_data;
00170         frame_data *data;
00171     protected:
00172         friend class symbol_t;
00173         frame_t(void *);
00174     public:
00176         frame_t();
00177 
00179         frame_t(const frame_t &);
00180 
00182         ~frame_t();
00183 
00185         const frame_t &operator = (const frame_t &);
00186 
00188         bool operator == (const frame_t &) const;
00189 
00191         bool operator != (const frame_t &) const;
00192         
00194         uint32_t getSize() const;
00195 
00197         symbol_t getSymbol(int32_t);
00198 
00200         int32_t getIndexOf(const char *name);
00201 
00203         symbol_t operator[] (int32_t);
00204 
00206         const symbol_t operator[] (int32_t) const;
00207 
00209         symbol_t addSymbol(const char *, type_t, void *user = NULL);
00210 
00212         void add(frame_t);
00213         
00215         bool resolve(const char *name, symbol_t &symbol);
00216 
00218         frame_t getParent() throw (NoParentException);
00219 
00221         bool hasParent() const;
00222 
00224         static frame_t createFrame();
00225 
00227         static frame_t createFrame(const frame_t &parent);
00228     };
00229 
00230     namespace prefix {
00231         enum prefix_t {
00232             URGENT = 1,
00233             COMMITTED = 2,
00234             CONSTANT = 4,
00235             BROADCAST = 8,
00236             REFERENCE = 16
00237         };
00238     }
00239 
00267     class type_t
00268     {
00269     private:
00270         struct type_data;
00271         type_data *data;
00272         type_t(void *);
00273     public:
00275         type_t();
00276 
00278         type_t(const type_t &);
00279 
00281         ~type_t();
00282 
00284         const type_t &operator = (const type_t &);
00285 
00287         bool operator == (const type_t &) const;
00288 
00290         bool operator != (const type_t &) const;
00291         
00293         type_t getBase() const;
00294 
00296         frame_t getRecordFields() const;
00297 
00299         frame_t getParameters() const;
00300 
00302         frame_t getFrame() const;
00303         
00305         type_t getSub();
00306 
00308         bool hasPrefix(prefix::prefix_t) const;
00309 
00311         type_t setPrefix(bool set, prefix::prefix_t) const;
00312 
00314         expression_t getArraySize() const;
00315 
00317         std::pair<expression_t, expression_t> getRange() const;
00318 
00320         static type_t createInteger(expression_t, expression_t);
00321         
00323         static type_t createRecord(frame_t);
00324 
00326         static type_t createFunction(frame_t, type_t);
00327 
00329         static type_t createArray(expression_t, type_t);
00330 
00332         static type_t createTypeName(type_t);
00333 
00335         static type_t createTemplate(frame_t);
00336 
00338         static type_t createProcess(frame_t);
00339 
00341         static type_t createBase();
00342 
00343         static type_t UNKNOWN;
00344         static type_t VOID_TYPE;
00345         static type_t CLOCK;
00346         static type_t INT;
00347         static type_t LOCATION;
00348         static type_t CHANNEL;
00349         static type_t TEMPLATE;
00350         static type_t INSTANCE;
00351         static type_t FUNCTION;
00352         static type_t ARRAY;
00353         static type_t RECORD;
00354         static type_t PROCESS;
00355         static type_t NTYPE;
00356         static type_t INVARIANT;
00357         static type_t GUARD;
00358         static type_t DIFF;
00359         static type_t CONSTRAINT;
00360     };
00361 }
00362 
00363 #endif

Generated on Wed Jul 2 12:08:18 2003 for libutap by doxygen 1.3.2