00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UTAP_TYPE_HH
00023 #define UTAP_TYPE_HH
00024
00025 #include <inttypes.h>
00026 #include <string>
00027
00028 #include "utap/common.h"
00029 #include "utap/position.h"
00030
00031 namespace UTAP
00032 {
00033 class expression_t;
00034 class frame_t;
00035 class symbol_t;
00036
00092 class type_t
00093 {
00094 private:
00095 struct child_t;
00096 struct type_data;
00097 type_data *data;
00098
00099 explicit type_t(Constants::kind_t kind,
00100 const position_t &pos, size_t size);
00101 public:
00105 type_t();
00106
00108 type_t(const type_t &);
00109
00111 ~type_t();
00112
00114 const type_t &operator = (const type_t &);
00115
00117 bool operator == (const type_t &) const;
00118
00120 bool operator != (const type_t &) const;
00121
00123 Constants::kind_t getKind() const;
00124
00129 position_t getPosition() const;
00130
00134 size_t size() const;
00135
00137 bool operator < (const type_t &) const;
00138
00140 const type_t operator[](uint32_t) const;
00141
00143 const type_t get(uint32_t) const;
00144
00146 const std::string &getLabel(uint32_t) const;
00147
00149 expression_t getExpression() const;
00150
00155 type_t getArraySize() const;
00156
00161 type_t getSub() const;
00162
00167 type_t getSub(size_t) const;
00168
00172 size_t getRecordSize() const;
00173
00178 std::string getRecordLabel(size_t i) const;
00179
00185 int32_t findIndexOf(std::string) const;
00186
00190 std::pair<expression_t, expression_t> getRange() const;
00191
00193 std::string toString() const;
00194
00196 bool isInteger() const { return is(Constants::INT); }
00197
00199 bool isBoolean() const { return is(Constants::BOOL); }
00200
00202 bool isFunction() const { return is(Constants::FUNCTION); }
00203
00205 bool isProcess() const { return is(Constants::PROCESS); }
00206
00208 bool isProcessSet() const { return is(Constants::PROCESSSET); }
00209
00211 bool isLocation() const { return is(Constants::LOCATION); }
00212
00214 bool isChannel() const { return is(Constants::CHANNEL); }
00215
00217 bool isArray() const { return is(Constants::ARRAY); }
00218
00220 bool isScalar() const { return is(Constants::SCALAR); }
00221
00223 bool isClock() const { return is(Constants::CLOCK); }
00224
00226 bool isRecord() const { return is(Constants::RECORD); }
00227
00229 bool isDiff() const { return is(Constants::DIFF); }
00230
00232 bool isVoid() const { return is(Constants::VOID_TYPE); }
00233
00235 bool isCost() const { return is(Constants::COST); }
00236
00241 bool isIntegral() const;
00242
00247 bool isInvariant() const;
00248
00253 bool isGuard() const;
00254
00260 bool isConstraint() const;
00261
00267 bool isFormula() const;
00268
00273 type_t strip() const;
00274
00279 type_t stripArray() const;
00280
00286 bool isPrefix() const;
00287
00292 bool isConstant() const;
00293
00294
00299 bool isNonConstant() const;
00300
00306 bool is(Constants::kind_t kind) const;
00307
00311 bool unknown() const;
00312
00318 type_t rename(std::string from, std::string to) const;
00319
00325 type_t subst(symbol_t symbol, expression_t expr) const;
00331 type_t createPrefix(Constants::kind_t kind, position_t = position_t()) const;
00332
00334 type_t createLabel(std::string, position_t = position_t()) const;
00335
00337 type_t createPosition(position_t = position_t()) const;
00338
00341 static type_t createRange(type_t, expression_t, expression_t,
00342 position_t = position_t());
00343
00345 static type_t createPrimitive(Constants::kind_t,
00346 position_t = position_t());
00347
00349 static type_t createArray(type_t sub, type_t size, position_t = position_t());
00350
00352 static type_t createTypeDef(std::string, type_t, position_t = position_t());
00353
00355 static type_t createProcess(frame_t, position_t = position_t());
00356
00358 static type_t createProcessSet(type_t instance, position_t = position_t());
00359
00361 static type_t createRecord(const std::vector<type_t> &,
00362 const std::vector<std::string> &,
00363 position_t = position_t());
00364
00366 static type_t createFunction(type_t,
00367 const std::vector<type_t> &,
00368 const std::vector<std::string> &,
00369 position_t = position_t());
00370
00372 static type_t createInstance(frame_t, position_t = position_t());
00373 };
00374 }
00375
00376 std::ostream &operator << (std::ostream &o, UTAP::type_t t);
00377
00378 #endif