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
00093 class type_t
00094 {
00095 private:
00096 struct child_t;
00097 struct type_data;
00098 type_data *data;
00099
00100 explicit type_t(Constants::kind_t kind,
00101 const position_t &pos, size_t size);
00102 public:
00106 type_t();
00107
00109 type_t(const type_t &);
00110
00112 ~type_t();
00113
00115 const type_t &operator = (const type_t &);
00116
00118 bool operator == (const type_t &) const;
00119
00121 bool operator != (const type_t &) const;
00122
00124 Constants::kind_t getKind() const;
00125
00130 position_t getPosition() const;
00131
00135 size_t size() const;
00136
00138 bool operator < (const type_t &) const;
00139
00141 const type_t operator[](uint32_t) const;
00142
00144 const type_t get(uint32_t) const;
00145
00147 const std::string &getLabel(uint32_t) const;
00148
00150 expression_t getExpression() const;
00151
00156 type_t getArraySize() const;
00157
00162 type_t getSub() const;
00163
00168 type_t getSub(size_t) const;
00169
00173 size_t getRecordSize() const;
00174
00179 std::string getRecordLabel(size_t i) const;
00180
00186 int32_t findIndexOf(std::string) const;
00187
00191 std::pair<expression_t, expression_t> getRange() const;
00192
00194 std::string toString() const;
00195
00197 bool isInteger() const { return is(Constants::INT); }
00198
00200 bool isBoolean() const { return is(Constants::BOOL); }
00201
00203 bool isFunction() const { return is(Constants::FUNCTION); }
00204
00206 bool isProcess() const { return is(Constants::PROCESS); }
00207
00209 bool isProcessSet() const { return is(Constants::PROCESSSET); }
00210
00212 bool isLocation() const { return is(Constants::LOCATION); }
00213
00215 bool isChannel() const { return is(Constants::CHANNEL); }
00216
00218 bool isArray() const { return is(Constants::ARRAY); }
00219
00221 bool isScalar() const { return is(Constants::SCALAR); }
00222
00224 bool isClock() const { return is(Constants::CLOCK); }
00225
00227 bool isRecord() const { return is(Constants::RECORD); }
00228
00230 bool isDiff() const { return is(Constants::DIFF); }
00231
00233 bool isVoid() const { return is(Constants::VOID_TYPE); }
00234
00236 bool isCost() const { return is(Constants::COST); }
00237
00242 bool isIntegral() const;
00243
00248 bool isInvariant() const;
00249
00254 bool isGuard() const;
00255
00261 bool isConstraint() const;
00262
00267 type_t strip() const;
00268
00273 type_t stripArray() const;
00274
00280 bool isPrefix() const;
00281
00287 bool is(Constants::kind_t kind) const;
00288
00292 bool unknown() const;
00293
00299 type_t rename(std::string from, std::string to) const;
00300
00306 type_t subst(symbol_t symbol, expression_t expr) const;
00312 type_t createPrefix(Constants::kind_t kind, position_t = position_t()) const;
00313
00315 type_t createLabel(std::string, position_t = position_t()) const;
00316
00318 type_t createPosition(position_t = position_t()) const;
00319
00322 static type_t createRange(type_t, expression_t, expression_t,
00323 position_t = position_t());
00324
00326 static type_t createPrimitive(Constants::kind_t,
00327 position_t = position_t());
00328
00330 static type_t createArray(type_t sub, type_t size, position_t = position_t());
00331
00333 static type_t createTypeDef(std::string, type_t, position_t = position_t());
00334
00336 static type_t createProcess(frame_t, position_t = position_t());
00337
00339 static type_t createProcessSet(type_t instance, position_t = position_t());
00340
00342 static type_t createRecord(const std::vector<type_t> &,
00343 const std::vector<std::string> &,
00344 position_t = position_t());
00345
00347 static type_t createFunction(type_t,
00348 const std::vector<type_t> &,
00349 const std::vector<std::string> &,
00350 position_t = position_t());
00351
00353 static type_t createInstance(frame_t, position_t = position_t());
00354 };
00355 }
00356
00357 std::ostream &operator << (std::ostream &o, UTAP::type_t t);
00358
00359 #endif