libutap  0.93
Uppaal Timed Automata Parser
type.cpp
Go to the documentation of this file.
1 // -*- mode: C++; c-file-style: "stroustrup"; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 
3 /* libutap - Uppaal Timed Automata Parser.
4  Copyright (C) 2002-2006 Uppsala University and Aalborg University.
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public License
8  as published by the Free Software Foundation; either version 2.1 of
9  the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  USA
20 */
21 
22 #include <boost/format.hpp>
23 
24 #include "utap/type.h"
25 #include "utap/expression.h"
26 
27 using std::string;
28 using std::vector;
29 
30 using namespace UTAP;
31 using namespace Constants;
32 
33 struct type_t::child_t
34 {
35  string label;
36  type_t child;
37 };
38 
39 struct type_t::type_data
40 {
41  kind_t kind; // Kind of type object
42  position_t position; // Position in the input file
43  expression_t expr; //
44  std::vector<child_t> children;
45 };
46 
47 type_t::type_t(kind_t kind, const position_t &pos, size_t size)
48 {
49  data = std::make_shared<type_data>();
50  data->kind = kind;
51  data->position = pos;
52  data->children.resize(size);
53 }
54 
55 type_t::type_t(const type_t &type)
56 {
57  *this = type;
58 }
59 
60 const type_t& type_t::operator = (const type_t &type)
61 {
62  data = type.data;
63  return *this;
64 }
65 
66 bool type_t::operator == (const type_t &type) const
67 {
68  return data == type.data;
69 }
70 
71 bool type_t::operator != (const type_t &type) const
72 {
73  return data != type.data;
74 }
75 
76 bool type_t::operator < (const type_t &type) const
77 {
78  return data < type.data;
79 }
80 
81 size_t type_t::size() const
82 {
83  assert(data);
84  return data->children.size();
85 }
86 
87 const type_t type_t::operator[](uint32_t i) const
88 {
89  assert(i < size());
90  return data->children[i].child;
91 }
92 
93 const type_t type_t::get(uint32_t i) const
94 {
95  assert(i < size());
96  return data->children[i].child;
97 }
98 
99 const std::string &type_t::getLabel(uint32_t i) const
100 {
101  assert(i < size());
102  return data->children[i].label;
103 }
104 
105 int32_t type_t::findIndexOf(const std::string& label) const
106 {
107  assert(isRecord() || isProcess());
108  type_t type = strip();
109  size_t n = type.size();
110  for (size_t i = 0; i < n; i++)
111  {
112  if (type.getLabel(i) == label)
113  {
114  return i;
115  }
116  }
117  return -1;
118 }
119 
121 {
122  return unknown() ? UNKNOWN : data->kind;
123 }
124 
125 bool type_t::isPrefix() const
126 {
127  switch (getKind())
128  {
129  case Constants::FRACTION:
130  case Constants::UNKNOWN:
132  case Constants::CLOCK:
133  case Constants::INT:
134  case Constants::DOUBLE:
135  case Constants::BOOL:
136  case Constants::SCALAR:
137  case Constants::LOCATION:
139  case Constants::CHANNEL:
140  case Constants::COST:
143  case Constants::GUARD:
144  case Constants::DIFF:
146  case Constants::FORMULA:
147  case Constants::TIOGRAPH:
148  case Constants::ARRAY:
149  case Constants::RECORD:
150  case Constants::PROCESS:
152  case Constants::FUNCTION:
153  case Constants::INSTANCE:
154  case Constants::RANGE:
155  case Constants::REF:
156  case Constants::TYPEDEF:
157  case Constants::LABEL:
158  case Constants::RATE:
159  case Constants::INSTANCELINE://LSC
160  case Constants::MESSAGE://LSC
161  case Constants::CONDITION://LSC
162  case Constants::UPDATE://LSC
163  case Constants::LSCINSTANCE://LSC
164  return false;
165 
166  default:
167  return true;
168  }
169 }
170 
171 bool type_t::unknown() const
172 {
173  return data == NULL || data->kind == UNKNOWN;
174 }
175 
176 bool type_t::is(kind_t kind) const
177 {
178  if (getKind () == Constants::PROCESSVAR)
179  {
180  return kind == Constants::PROCESSVAR;
181  }
182  if (getKind () == Constants::DOUBLEINVGUARD)
183  {
184  return kind == Constants::DOUBLEINVGUARD;
185  }
186  return (getKind() == kind)
187  || (isPrefix() && get(0).is(kind))
188  || (getKind() == RANGE && get(0).is(kind))
189  || (getKind() == REF && get(0).is(kind))
190  || (getKind() == LABEL && get(0).is(kind));
191 }
192 
194 {
195  assert(isArray());
196  if (getKind() == REF || getKind() == LABEL)
197  {
198  return get(0).getSub();
199  }
200  else if (isPrefix())
201  {
202  return get(0).getSub().createPrefix(getKind());
203  }
204  else
205  {
206  return get(0);
207  }
208 }
209 
210 type_t type_t::getSub(size_t i) const
211 {
212  assert(isRecord() || isProcess());
213  if (getKind() == REF || getKind() == LABEL)
214  {
215  return get(0).getSub(i);
216  }
217  else if (isPrefix())
218  {
219  return get(0).getSub(i).createPrefix(getKind());
220  }
221  else
222  {
223  return get(i);
224  }
225 }
226 
228 {
229  if (isPrefix() || getKind() == REF || getKind() == LABEL)
230  {
231  return get(0).getArraySize();
232  }
233  else
234  {
235  assert(getKind() == ARRAY);
236  return get(1);
237  }
238 }
239 
240 size_t type_t::getRecordSize() const
241 {
242  if (isPrefix() || getKind() == REF || getKind() == LABEL)
243  {
244  return get(0).getRecordSize();
245  }
246  else
247  {
248  assert(getKind() == RECORD);
249  return size();
250  }
251 }
252 
253 string type_t::getRecordLabel(size_t i) const
254 {
255  if (isPrefix() || getKind() == REF || getKind() == LABEL)
256  {
257  return get(0).getRecordLabel(i);
258  }
259  else
260  {
261  assert(getKind() == RECORD || getKind() == PROCESS);
262  return getLabel(i);
263  }
264 }
265 
266 std::pair<expression_t, expression_t> type_t::getRange() const
267 {
268  assert(is(RANGE));
269  if (getKind() == RANGE)
270  {
271  return std::make_pair(get(1).getExpression(), get(2).getExpression());
272  }
273  else
274  {
275  return get(0).getRange();
276  }
277 }
278 
280 {
281  assert(data);
282  return data->expr;
283 }
284 
286 {
287  if (isPrefix() || getKind() == RANGE || getKind() == REF || getKind() == LABEL)
288  {
289  return get(0).strip();
290  }
291  else
292  {
293  return *this;
294  }
295 }
296 
298 {
299  type_t type = strip();
300  while (type.getKind() == ARRAY)
301  {
302  type = type.get(0).strip();
303  }
304  return type;
305 }
306 
307 type_t type_t::rename(const std::string& from, const std::string& to) const
308 {
309  type_t type(getKind(), getPosition(), size());
310  type.data->expr = getExpression();
311  for (size_t i = 0; i < size(); ++i)
312  {
313  type.data->children[i].child = get(i).rename(from, to);
314  type.data->children[i].label = getLabel(i);
315  }
316  if (getKind() == LABEL && getLabel(0) == from)
317  {
318  type.data->children[0].label = to;
319  }
320  return type;
321 }
322 
324 {
325  type_t type = type_t(getKind(), getPosition(), size());
326  for (size_t i = 0; i < size(); i++)
327  {
328  type.data->children[i].label = getLabel(i);
329  type.data->children[i].child = get(i).subst(symbol, expr);
330  }
331  if (!data->expr.empty())
332  {
333  type.data->expr = data->expr.subst(symbol, expr);
334  }
335  return type;
336 }
337 
339 {
340  return data->position;
341 }
342 
343 bool type_t::isIntegral() const
344 {
345  return is(Constants::INT) || is(Constants::BOOL) || is(PROCESSVAR);
346 }
347 
349 {
350  return is(INVARIANT) || isIntegral();
351 }
352 
353 bool type_t::isGuard() const
354 {
355  return is(GUARD) || isInvariant();
356 }
357 
358 #ifdef ENABLE_PROB
359 bool type_t::isProbability() const
360 {
361  return is(PROBABILITY) || isInteger();
362 }
363 #endif
364 
366 {
367  return is(CONSTRAINT) || isGuard();
368 }
369 
370 bool type_t::isFormula() const
371 {
372  return is(FORMULA) || isConstraint();
373 }
374 
375 bool type_t::isConstant() const
376 {
377  switch (getKind())
378  {
379  case FUNCTION:
380  case PROCESS:
381  case INSTANCE:
382  case LSCINSTANCE:
383  return false;
384  case CONSTANT:
385  return true;
386  case RECORD:
387  for (size_t i = 0; i < size(); i++)
388  {
389  if (!get(i).isConstant())
390  {
391  return false;
392  }
393  }
394  return true;
395  default:
396  return size() > 0 && get(0).isConstant();
397  }
398 }
399 
401 {
402  switch (getKind())
403  {
404  case FUNCTION:
405  case PROCESS:
406  case INSTANCE:
407  case LSCINSTANCE:
408  return false;
409  case CONSTANT:
410  return false;
411  case RECORD:
412  for (size_t i = 0; i < size(); i++)
413  {
414  if (!get(i).isNonConstant())
415  {
416  return false;
417  }
418  }
419  return true;
420  default:
421  return size() == 0 || get(0).isNonConstant();
422  }
423 }
424 
426  position_t pos)
427 {
428  type_t t(RANGE, pos, 3);
429  t.data->children[0].child = type;
430  t.data->children[1].child = type_t(UNKNOWN, pos, 0);
431  t.data->children[2].child = type_t(UNKNOWN, pos, 0);
432  t[1].data->expr = lower;
433  t[2].data->expr = upper;
434  return t;
435 }
436 
437 type_t type_t::createRecord(const vector<type_t> &types,
438  const vector<string> &labels,
439  position_t pos)
440 {
441  assert(types.size() == labels.size());
442  type_t type(RECORD, pos, types.size());
443  for (size_t i = 0; i < types.size(); i++)
444  {
445  type.data->children[i].child = types[i];
446  type.data->children[i].label = labels[i];
447  }
448  return type;
449 }
450 
452  const std::vector<type_t> &parameters,
453  const std::vector<std::string> &labels,
454  position_t pos)
455 {
456  assert(parameters.size() == labels.size());
457  type_t type(FUNCTION, pos, parameters.size() + 1);
458  type.data->children[0].child = ret;
459  for (size_t i = 0; i < parameters.size(); i++)
460  {
461  type.data->children[i + 1].child = parameters[i];
462  type.data->children[i + 1].label = labels[i];
463  }
464  return type;
465 }
466 
468 {
469  type_t type(ARRAY, pos, 2);
470  type.data->children[0].child = sub;
471  type.data->children[1].child = size;
472  return type;
473 }
474 
475 type_t type_t::createTypeDef(const std::string& label, type_t type, position_t pos)
476 {
477  type_t t(TYPEDEF, pos, 1);
478  t.data->children[0].label = label;
479  t.data->children[0].child = type;
480  return t;
481 }
482 
484 {
485  type_t type(INSTANCE, pos, parameters.getSize());
486  for (size_t i = 0; i < parameters.getSize(); i++)
487  {
488  type.data->children[i].child = parameters[i].getType();
489  type.data->children[i].label = parameters[i].getName();
490  }
491  return type;
492 }
493 
495 {
496  type_t type(LSCINSTANCE, pos, parameters.getSize());
497  for (size_t i = 0; i < parameters.getSize(); i++)
498  {
499  type.data->children[i].child = parameters[i].getType();
500  type.data->children[i].label = parameters[i].getName();
501  }
502  return type;
503 }
504 
506 {
507  type_t type(PROCESS, pos, frame.getSize());
508  for (size_t i = 0; i < frame.getSize(); i++)
509  {
510  type.data->children[i].child = frame[i].getType();
511  type.data->children[i].label = frame[i].getName();
512  }
513  return type;
514 }
515 
517 {
518  type_t type(PROCESSSET, pos, instance.size());
519  for (size_t i = 0; i < instance.size(); i++)
520  {
521  type.data->children[i].child = instance[i];
522  type.data->children[i].label = instance.getLabel(i);
523  }
524  return type;
525 }
526 
528 {
529  return type_t(kind, pos, 0);
530 }
531 
533 {
534  type_t type(kind, pos, 1);
535  type.data->children[0].child = *this;
536  return type;
537 }
538 
539 type_t type_t::createLabel(const string& label, position_t pos) const
540 {
541  type_t type(LABEL, pos, 1);
542  type.data->children[0].child = *this;
543  type.data->children[0].label = label;
544  return type;
545 }
546 
547 string type_t::toString() const
548 {
549  auto kind = std::string();
550 
551  if (data == NULL)
552  {
553  return "unknown";
554  }
555 
556  if (!data->expr.empty())
557  {
558  return string("\"") + data->expr.toString() + "\"";
559  }
560 
561  switch (getKind())
562  {
563  case Constants::UNKNOWN:
564  kind = "unknown";
565  break;
566 
567  case Constants::RANGE:
568  kind = "range";
569  break;
570 
571  case Constants::ARRAY:
572  kind = "array";
573  break;
574 
575  case Constants::RECORD:
576  kind = "struct";
577  break;
578 
579  case Constants::CONSTANT:
580  kind = "const";
581  break;
582 
583  case Constants::REF:
584  kind = "ref";
585  break;
586 
587  case Constants::URGENT:
588  kind = "urgent";
589  break;
590 
592  kind = "committed";
593  break;
594 
596  kind = "broadcast";
597  break;
598 
600  kind = "void";
601  break;
602 
603  case Constants::CLOCK:
604  kind = "clock";
605  break;
606 
607  case Constants::FRACTION:
608  kind = "fraction";
609  break;
610 
611  case Constants::INT:
612  kind = "int";
613  break;
614 
615  case Constants::DOUBLE:
616  kind = "double";
617  break;
618 
619  case Constants::BOOL:
620  kind = "bool";
621  break;
622 
623  case Constants::SCALAR:
624  kind = "scalar";
625  break;
626 
627  case Constants::CHANNEL:
628  kind = "channel";
629  break;
630 
632  kind = "invariant";
633  break;
634 
635  case Constants::GUARD:
636  kind = "guard";
637  break;
638 
639  case Constants::DIFF:
640  kind = "diff";
641  break;
642 
644  kind = "constraint";
645  break;
646 
647  case Constants::FORMULA:
648  kind = "formula";
649  break;
650 
651  case Constants::COST:
652  kind = "cost";
653  break;
654 
655  case Constants::RATE:
656  kind = "rate";
657  break;
658 
659  case Constants::TYPEDEF:
660  kind = "def";
661  break;
662 
663  case Constants::PROCESS:
664  kind = "process";
665  break;
666 
667  case Constants::INSTANCE:
668  kind = "instance";
669  break;
670 
671  case Constants::LABEL:
672  kind = "label";
673  break;
674 
675  case Constants::FUNCTION:
676  kind = "function";
677  break;
678 
679  case Constants::LOCATION:
680  kind = "location";
681  break;
682 
684  kind = "branchpoint";
685  break;
686 
687  case Constants::TIOGRAPH:
688  kind = "TIgraph";
689  break;
690 
691  //LSC
692  case INSTANCELINE:
693  kind = "instance line";
694  break;
695  case MESSAGE:
696  kind = "message";
697  break;
698  case CONDITION:
699  kind = "condition";
700  break;
701  case UPDATE:
702  kind = "update";
703  break;
704  case LSCINSTANCE:
705  kind = "LSC instance";
706  break;
707  case PROCESSVAR:
708  kind ="PROCESSVAR";
709  break;
710  default:
711  kind = (boost::format("type(%1%)") % getKind()).str();
712  break;
713  }
714 
715  auto str = std::string("(");
716 
717  str += kind;
718  for (uint32_t i = 0; i < size(); i++)
719  {
720  str += " ";
721  if (!getLabel(i).empty())
722  {
723  str += getLabel(i);
724  str += ":";
725  }
726  str += get(i).toString();
727  }
728  str += ")";
729 
730  return str;
731 }
732 
733 
735 {
736  auto kind = std::string();
737  auto range = false;
738  auto array = false;
739  auto label = false;
740  auto typeDef = false;
741 
742  if (data == NULL)
743  {
744  return "unknown";
745  }
746 
747  if (!data->expr.empty())
748  {
749  return "";
750  }
751 
752  switch (getKind())
753  {
754  case Constants::UNKNOWN:
755  kind = "unknown";
756  break;
757 
758  case Constants::RANGE:
759  kind = "";
760  range = true;
761  break;
762 
763  case Constants::ARRAY:
764  kind = "";
765  array = true;
766  break;
767 
768  case Constants::RECORD:
769  kind = "struct";
770  break;
771 
772  case Constants::CONSTANT:
773  kind = "const";
774  break;
775 
776  case Constants::REF:
777  kind = "ref";
778  break;
779 
780  case Constants::URGENT:
781  kind = "urgent";
782  break;
783 
785  kind = "committed";
786  break;
787 
789  kind = "broadcast";
790  break;
791 
793  kind = "void";
794  break;
795 
796  case Constants::CLOCK:
797  kind = "clock";
798  break;
799 
800  case Constants::INT:
801  kind = "int";
802  break;
803 
804  case Constants::DOUBLE:
805  kind = "double";
806  break;
807 
808  case Constants::BOOL:
809  kind = "bool";
810  break;
811 
812  case Constants::SCALAR:
813  kind = "scalar";
814  break;
815 
816  case Constants::CHANNEL:
817  kind = "chan";
818  break;
819 
821  kind = "invariant";
822  break;
823 
824  case Constants::GUARD:
825  kind = "guard";
826  break;
827 
828  case Constants::DIFF:
829  kind = "diff";
830  break;
831 
833  kind = "constraint";
834  break;
835 
836  case Constants::FORMULA:
837  kind = "formula";
838  break;
839 
840  case Constants::COST:
841  kind = "cost";
842  break;
843 
844  case Constants::RATE:
845  kind = "rate";
846  break;
847 
848  case Constants::TYPEDEF:
849  kind = "typedef";
850  typeDef = true;
851  break;
852 
853  case Constants::PROCESS:
854  kind = "process";
855  break;
856 
857  case Constants::INSTANCE:
858  kind = "instance";
859  break;
860 
861  case Constants::LABEL:
862  label = true;
863  break;
864 
865  case Constants::FUNCTION:
866  kind = "function";
867  break;
868 
869  default:
870  kind = (boost::format("type(%1%)") % getKind()).str();
871  break;
872  }
873 
874  auto str = std::string();
875 
876  if (range)
877  {
878  str += get(0).toDeclarationString();
879  if (getRange().first.getValue() != -32768 ||
880  getRange().second.getValue() != 32767)
881  {
882  str += "[";
883  str += getRange().first.toString();
884  str += ",";
885  str += getRange().second.toString();
886  str += "]";
887  str += get(1).toDeclarationString();
888  }
889  }
890  else if (array)
891  {
892  str += get(0).toDeclarationString();
893  str += "[";
894  str += getArraySize().getRange().second.get(0).toString();
895  str += "]";
896  }
897  else if (label)
898  {
899  str += getLabel(0);
900  }
901  else if (typeDef)
902  {
903  str += kind;
904  str += " ";
905  str += get(0).toDeclarationString();
906  str += " ";
907  str += getLabel(0);
908  }
909  else {
910  str += kind;
911  for (uint32_t i = 0; i < size(); i++)
912  {
913  str += " ";
914  if (!getLabel(i).empty())
915  {
916  str += getLabel(i);
917  str += ":";
918  }
919  str += get(i).toDeclarationString();
920  }
921  }
922  return str;
923 }
924 
925 std::ostream &operator << (std::ostream &o, type_t t)
926 {
927  o << t.toString();
928  return o;
929 }
bool isPrefix() const
Returns false for non-prefix types and true otherwise.
Definition: type.cpp:125
const type_t & operator=(const type_t &)
Assignment operator.
Definition: type.cpp:60
static bool isInvariant(expression_t expr)
static bool isIntegral(expression_t expr)
Definition: typechecker.cpp:82
bool unknown() const
Returns true if this is null-type or of kind UNKNOWN.
Definition: type.cpp:171
bool isIntegral() const
Returns true if this is a boolean or integer.
Definition: type.cpp:343
uint32_t getSize() const
Returns the number of symbols in this frame.
Definition: symbols.cpp:328
bool isInvariant() const
Returns true if this is an invariant, boolean or integer.
Definition: type.cpp:348
bool operator==(const type_t &) const
Equality operator.
Definition: type.cpp:66
static type_t createRange(type_t, expression_t, expression_t, position_t=position_t())
Definition: type.cpp:425
A reference to a symbol.
Definition: symbols.h:107
static type_t createInstance(frame_t, position_t=position_t())
Creates a new instance type.
Definition: type.cpp:483
type_t createPrefix(Constants::kind_t kind, position_t=position_t()) const
Creates a new type by adding a prefix to it.
Definition: type.cpp:532
std::string toDeclarationString() const
Definition: type.cpp:734
static type_t createPrimitive(Constants::kind_t, position_t=position_t())
Create a primitive type.
Definition: type.cpp:527
static type_t createLscInstance(frame_t, position_t=position_t())
Creates a new lsc instance type.
Definition: type.cpp:494
std::string toString() const
Generates string representation of the type.
Definition: type.cpp:547
std::pair< expression_t, expression_t > getRange() const
Returns the range of a RANGE type.
Definition: type.cpp:266
type_t rename(const std::string &from, const std::string &to) const
Replaces any LABEL labeled from occuring in the type with a LABEL to.
Definition: type.cpp:307
position_t getPosition() const
Returns the position of the type in the input file.
Definition: type.cpp:338
const std::string & getLabel(uint32_t) const
Returns the i&#39;th label.
Definition: type.cpp:99
std::ostream & operator<<(std::ostream &os, const SignalFlow::strs_t &s)
Definition: signalflow.h:189
bool operator<(const type_t &) const
Less-than operator.
Definition: type.cpp:76
bool isFormula() const
Returns true if this is a formula, constraint, guard, invariant, boolean or integer.
Definition: type.cpp:370
type_t strip() const
Removes any leading prefixes, RANGE, REF and LABEL types and returns the result.
Definition: type.cpp:285
static type_t createFunction(type_t, const std::vector< type_t > &, const std::vector< std::string > &, position_t=position_t())
Creates a new function type.
Definition: type.cpp:451
bool isConstant() const
Returns true if and only if all elements of the type are constant.
Definition: type.cpp:375
bool isConstraint() const
Returns true if this is a constraint, guard, invariant, boolean or integer.
Definition: type.cpp:365
type_t stripArray() const
Removes any leading prefixes, RANGE, REF, LABEL and ARRAY types and returns the result.
Definition: type.cpp:297
type_t getSub() const
Returns the element type of an array.
Definition: type.cpp:193
static string symbol(const char *str)
Extracts the alpha-numerical symbol used for variable/type identifiers.
Definition: xmlreader.cpp:107
static bool isGuard(expression_t expr)
expression_t getExpression() const
Returns the expression associated with the type.
Definition: type.cpp:279
static bool isInteger(expression_t expr)
Definition: typechecker.cpp:72
bool isNonConstant() const
Returns true if and only if all elements of the type are not constant.
Definition: type.cpp:400
type_t subst(symbol_t symbol, expression_t expr) const
Substitutes any occurence of symbol in any expression in the type (expressions that occur as ranges e...
Definition: type.cpp:323
static type_t createTypeDef(const std::string &, type_t, position_t=position_t())
Creates a new type definition.
Definition: type.cpp:475
static type_t createProcessSet(type_t instance, position_t=position_t())
Creates a new processset type.
Definition: type.cpp:516
const type_t operator[](uint32_t) const
Returns the i&#39;th child.
Definition: type.cpp:87
A reference to a frame.
Definition: symbols.h:183
static bool isConstraint(expression_t expr)
A reference to a type.
Definition: type.h:93
bool isGuard() const
Returns true if this is a guard, invariant, boolean or integer.
Definition: type.cpp:353
type_t()
Default constructor.
Definition: type.h:106
const type_t get(uint32_t) const
Returns the i&#39;th child.
Definition: type.cpp:93
size_t size() const
Returns the number of children.
Definition: type.cpp:81
int32_t findIndexOf(const std::string &) const
Returns the index of the record or process field with the given label.
Definition: type.cpp:105
std::string getRecordLabel(size_t i) const
Returns the label of the &#39;th field of a record.
Definition: type.cpp:253
type_t createLabel(const std::string &, position_t=position_t()) const
Creates a LABEL.
Definition: type.cpp:539
static type_t createRecord(const std::vector< type_t > &, const std::vector< std::string > &, position_t=position_t())
Creates a new record type.
Definition: type.cpp:437
bool operator!=(const type_t &) const
Inequality operator.
Definition: type.cpp:71
A reference to an expression.
Definition: expression.h:70
type_t getArraySize() const
Returns the size of an array (this is itself a type).
Definition: type.cpp:227
bool is(Constants::kind_t kind) const
Returns true if the type has kind kind or if type is a prefix, RANGE or REF type and the getChild()...
Definition: type.cpp:176
Definition: lexer.cc:817
static int types
Definition: parser.cc:127
static type_t createArray(type_t sub, type_t size, position_t=position_t())
Creates an array type.
Definition: type.cpp:467
static type_t createProcess(frame_t, position_t=position_t())
Creates a new process type.
Definition: type.cpp:505
Constants::kind_t getKind() const
Returns the kind of type object.
Definition: type.cpp:120
size_t getRecordSize() const
Returns the number of fields of a record.
Definition: type.cpp:240