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

expression.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-2006 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_EXPRESSION_HH
00023 #define UTAP_EXPRESSION_HH
00024 
00025 #include <vector>
00026 #include <set>
00027 #include <map>
00028 
00029 #include "utap/common.h"
00030 #include "utap/symbols.h"
00031 #include "utap/position.h"
00032 
00033 namespace UTAP
00034 {
00068     class expression_t 
00069     {
00070     private:
00071         expression_t(Constants::kind_t, const position_t &);
00072     public:
00074         expression_t();
00075 
00077         expression_t(const expression_t &);
00078 
00080         ~expression_t();
00081 
00083         expression_t clone() const;
00084 
00086         Constants::kind_t getKind() const;
00087 
00089         size_t getSize() const;
00090 
00092         const position_t &getPosition() const;  
00093         
00095         type_t getType() const;
00096 
00098         void setType(type_t);
00099 
00102         int32_t getValue() const;
00103 
00105         int32_t getIndex() const;
00106 
00108         bool empty() const;
00109 
00111         Constants::synchronisation_t getSync() const;
00112 
00114         std::string toString(bool old = false) const;
00115 
00117         expression_t &operator[](uint32_t);
00118         
00120         const expression_t operator[](uint32_t) const;
00121 
00123         expression_t &get(uint32_t);
00124 
00126         const expression_t &get(uint32_t) const;
00127 
00129         expression_t &operator=(const expression_t &);
00130 
00132         bool equal(const expression_t &) const;
00133         
00144         symbol_t getSymbol();
00145 
00156         void getSymbols(std::set<symbol_t> &symbols) const;
00157 
00160         const symbol_t getSymbol() const;
00161 
00164         bool isReferenceTo(const std::set<symbol_t> &) const;
00165 
00168         bool changesVariable(const std::set<symbol_t> &) const;
00169 
00172         bool dependsOn(const std::set<symbol_t> &) const;
00173 
00174         void collectPossibleWrites(std::set<symbol_t> &) const;
00175         void collectPossibleReads(std::set<symbol_t> &) const;
00176 
00179         bool operator < (const expression_t) const;
00180  
00183         bool operator == (const expression_t) const;
00184 
00185         expression_t subst(symbol_t, expression_t) const;
00186  
00187         static int getPrecedence(Constants::kind_t); 
00188 
00190         static expression_t createConstant(int32_t, position_t = position_t());
00191 
00193         static expression_t createIdentifier(symbol_t, position_t = position_t());
00194 
00196         static expression_t createUnary(Constants::kind_t, expression_t,
00197                                         position_t = position_t(),
00198                                         type_t = type_t());
00200         static expression_t createBinary(Constants::kind_t,
00201                                          expression_t, expression_t,
00202                                          position_t = position_t(),
00203                                          type_t = type_t());
00204 
00206         static expression_t createTernary(Constants::kind_t, expression_t, 
00207                                           expression_t, expression_t,
00208                                           position_t = position_t(),
00209                                           type_t = type_t());
00210 
00212         static expression_t createNary(Constants::kind_t, 
00213                                        const std::vector<expression_t> &,
00214                                        position_t = position_t(),
00215                                        type_t = type_t());
00216 
00218         static expression_t createDot(expression_t, int32_t = -1,
00219                                       position_t = position_t(), 
00220                                       type_t = type_t());
00221 
00223         static expression_t createSync(expression_t, 
00224                                        Constants::synchronisation_t,
00225                                        position_t = position_t());
00226 
00228         static expression_t createDeadlock(position_t = position_t());
00229 
00230     private:
00231         struct expression_data;
00232         expression_data *data;
00233         int getPrecedence() const;
00234         void toString(bool, char *&str, char *&end, int &size) const;
00235     };
00236 }
00237 
00238 std::ostream &operator<< (std::ostream &o, const UTAP::expression_t &e);
00239 
00240 #endif
00241 
00242 
00243 

Generated on Sat Apr 29 21:02:14 2006 for libutap by  doxygen 1.4.2