33 using namespace Constants;
46 struct expression_t::expression_data
59 std::vector<expression_t> sub;
62 position(p), kind(k), value(v) {}
67 data = std::make_shared<expression_data>(pos, kind, 0);
84 expr.data->value = data->value;
85 expr.data->type = data->type;
86 expr.data->symbol = data->symbol;
87 expr.data->sub.reserve(data->sub.size());
88 expr.data->sub.assign(data->sub.begin(), data->sub.end());
95 expr.data->value = data->value;
96 expr.data->type = data->type;
97 expr.data->symbol = data->symbol;
98 if (!data->sub.empty())
100 expr.data->sub.reserve(data->sub.size());
101 for (
const auto& s: data->sub)
102 expr.data->sub.push_back(s.deeperClone());
110 expr.data->value = data->value;
111 expr.data->type = data->type;
112 expr.data->symbol = (data->symbol == from) ? to : data->symbol;
114 if (!data->sub.empty())
116 expr.data->sub.reserve(data->sub.size());
117 for (
const auto& s: data->sub)
118 expr.data->sub.push_back(s.deeperClone(from, to));
126 expr.data->value = data->value;
127 expr.data->type = data->type;
131 bool res = frame.
resolve(data->symbol.getName(), uid);
132 if (!res && select !=
frame_t())
134 res = select.
resolve(data->symbol.getName(), uid);
137 expr.data->symbol = uid;
141 expr.data->symbol = data->symbol;
144 if (!data->sub.empty())
146 expr.data->sub.reserve(data->sub.size());
147 for (
const auto& s: data->sub)
148 expr.data->sub.push_back(s.deeperClone(frame, select));
159 else if (getKind() ==
IDENTIFIER && getSymbol() == symbol)
163 else if (getSize() == 0)
170 for (
size_t i = 0; i < getSize(); i++)
172 e[i] = e[i].
subst(symbol, expr);
191 return data->position;
285 auto&
symbol =
get(0).getSymbol();
289 if (fun && fun->body &&
checkForFP(fun->body))
296 size_t n = getSize();
297 for(
size_t i = 0; i < n; ++i)
318 size_t n = getSize();
319 for(
size_t i = 0; i < n; ++i)
321 if (
get(i).usesClock())
356 size_t n = getSize ();
363 for (
size_t i = 0;i<n;++i)
365 if (
get(i).isDynamic ())
371 hasIt |=
get(i).hasDynamicSub ();
450 assert(data->sub.size() == 2);
508 assert(data->sub.size() == 1);
514 assert(data->sub.size() == 0);
520 assert(data->sub.size() == 3);
544 assert(data->sub.size() == 1);
554 assert(data->sub.size() == 2);
559 assert(data->sub.size() == 3);
565 assert(data->sub.size() == 5);
569 assert(data->sub.size() == 5);
573 assert(data->sub.size() == 8);
578 assert(data->sub.size() == 1);
582 assert(data->sub.size() == 2);
586 assert(data->sub.size() == 4);
589 assert(data->sub.size() == 0);
592 assert(data->sub.size() == 1);
600 assert(data->sub.size() == 3);
603 assert(data->sub.size() == 2);
625 assert(data && data->kind ==
CONSTANT && data->type.isIntegral());
626 return data->type.isInteger() ? data->value : (data->value ? 1 : 0);
632 return data->doubleValue;
637 assert(data && data->kind ==
DOT);
643 assert(data && data->kind ==
SYNC);
649 assert(data && 0 <= i && i < getSize());
655 assert(data && 0 <= i && i < getSize());
661 assert(data && 0 <= i && i < getSize());
667 assert(data && 0 <= i && i < getSize());
678 return data == NULL || (getType().isIntegral() && data->kind ==
CONSTANT && getValue() == 1);
693 || data->kind != e.data->kind
694 || data->value != e.data->value
695 || data->symbol != e.data->symbol)
700 for (uint32_t i = 0; i < getSize(); i++)
702 if (!data->sub[i].equal(e[i]))
733 return get(0).getSymbol();
736 return get(0).getSymbol();
740 return get(0).getSymbol();
743 return get(1).getSymbol();
746 return get(1).getSymbol();
759 return get(0).getSymbol();
762 return get(0).getSymbol();
765 return get(0).getSymbol();
768 return get(0).getSymbol();
785 symbols.insert(data->symbol);
789 get(0).getSymbols(symbols);
793 get(0).getSymbols(symbols);
798 get(0).getSymbols(symbols);
802 get(1).getSymbols(symbols);
803 get(2).getSymbols(symbols);
807 get(1).getSymbols(symbols);
821 get(0).getSymbols(symbols);
825 get(0).getSymbols(symbols);
838 std::set<symbol_t> s;
840 return find_first_of(symbols.begin(), symbols.end(), s.begin(), s.end())
846 std::set<symbol_t> changes;
847 collectPossibleWrites(changes);
848 return find_first_of(symbols.begin(), symbols.end(),
849 changes.begin(), changes.end()) != symbols.end();
854 std::set<symbol_t> changes;
855 collectPossibleWrites(changes);
856 return !changes.empty();
861 std::set<symbol_t> dependencies;
862 collectPossibleReads(dependencies);
863 return find_first_of(
864 symbols.begin(), symbols.end(),
865 dependencies.begin(), dependencies.end()) != symbols.end();
868 int expression_t::getPrecedence()
const 870 return getPrecedence(data->kind);
873 int expression_t::getPrecedence(
kind_t kind)
1100 throw std::runtime_error(
"Strange expression");
1106 static void ensure(
char *&str,
char *&end,
int &size,
int len)
1113 char *nstr =
new char[size];
1114 strncpy(nstr, str, end - str);
1115 end = nstr + (end - str);
1121 static void append(
char *&str,
char *&end,
int &size,
const char *s)
1123 while (end < str + size && *s)
1128 if (end == str + size)
1130 ensure(str, end, size, 2 * size);
1131 append(str, end, size, s);
1139 static void append(
char *&str,
char *&end,
int &size,
char c)
1141 if (size - (end - str) < 2)
1143 ensure(str, end, size, size + 2);
1150 void expression_t::appendBoundType(
char *&str,
char*&end,
int &size,
expression_t e)
const 1158 append(str, end, size,
"#");
1165 append(str, end, size,
"<=");
1172 static const char* funNames[] = {
1173 "abs",
"fabs",
"fmod",
"fma",
"fmax",
"fmin",
"fdim",
1174 "exp",
"exp2",
"expm1",
"ln",
"log",
"log10",
"log2",
"log1p",
1175 "pow",
"sqrt",
"cbrt",
"hypot",
1176 "sin",
"cos",
"tan",
"asin",
"acos",
"atan",
"atan2",
1177 "sinh",
"cosh",
"tanh",
"asinh",
"acosh",
"atanh",
1178 "erf",
"erfc",
"tgamma",
"lgamma",
1179 "ceil",
"floor",
"trunc",
"round",
"fint",
1180 "ldexp",
"ilogb",
"logb",
"nextafter",
"copysign",
1181 "fpclassify",
"isfinite",
"isinf",
"isnan",
"isnormal",
"signbit",
1182 "isunordered",
"random",
"random_arcsine",
"random_beta",
1183 "random_gamma",
"random_normal",
"random_poisson",
1184 "random_weibull",
"random_tri" 1187 "Builtin function name list is wrong");
1189 return funNames[kind-
ABS_F];
1195 int precedence = getPrecedence();
1204 append(str,end, size,
"Pr[");
1205 appendBoundType(str, end, size,
get(1));
1206 get(2).toString(old, str, end, size);
1207 if (
get(0).getValue()>0)
1208 get(0).toString(old, str, end, size);
1209 append(str,end, size, flag ?
"]([] " :
"](<> ");
1210 get(3).toString(old, str, end, size);
1211 append(str,end, size,
") >= ");
1212 snprintf(s,
sizeof(s),
"%f",
get(4).getDoubleValue());
1213 append(str,end, size, s);
1219 append(str, end, size,
"Pr[");
1220 appendBoundType(str, end, size,
get(1));
1221 get(2).toString(old, str, end, size);
1222 if (
get(0).getValue()>0)
1223 get(0).toString(old, str, end, size);
1224 append(str, end, size, flag ?
"]([] " :
"](<> ");
1225 get(3).toString(old, str, end, size);
1226 append(str, end, size,
") ?");
1230 append(str, end, size,
"E[");
1231 appendBoundType(str, end, size,
get(1));
1232 get(2).toString(old, str, end, size);
1233 append(str, end, size,
"; ");
1234 get(0).toString(old, str, end, size);
1235 append(str, end, size,
"] (");
1236 append(str, end, size,
get(3).getValue() ?
"max: " :
"min: ");
1237 get(4).toString(old, str, end, size);
1238 append(str, end, size,
")");
1242 append(str, end, size,
"simulate[");
1243 get(0).toString(old, str, end, size);
1244 append(str, end, size,
"x ");
1245 appendBoundType(str, end, size,
get(1));
1246 get(2).toString(old, str, end, size);
1247 append(str, end, size,
"]{");
1248 nb = getValue() - 3;
1249 for(
int i = 0; i < nb; ++i)
1252 append(str, end, size,
", ");
1253 get(3+i).toString(old, str, end, size);
1255 append(str, end, size,
"}");
1261 append(str, end, size,
"(");
1262 get(0).toString(old, str, end, size);
1263 for (uint32_t i = 1; i < getSize(); i++)
1265 append(str, end, size, flag ?
" && " :
" || ");
1266 get(i).toString(old, str, end, size);
1268 append(str, end, size,
")");
1272 append(str, end, size,
"(");
1273 get(0).toString(old, str, end, size);
1274 for (uint32_t i = 1; i < getSize(); i++)
1276 append(str, end, size,
" + ");
1277 get(i).toString(old, str, end, size);
1279 append(str, end, size,
")");
1283 append(str, end, size,
"implementation: ");
1284 get(0).toString(old, str, end, size);
1288 append(str, end, size,
"specification: ");
1289 get(0).toString(old, str, end, size);
1293 append(str, end, size,
"consistency: ");
1294 get(0).toString(old, str, end, size);
1295 if (!(
get(1).getKind() ==
AG &&
1296 get(1).
get(0).getKind() ==
CONSTANT &&
1297 get(1).
get(0).getValue() == 1))
1299 append(str, end, size,
" : ");
1300 get(1).toString(old, str, end, size);
1307 append(str, end, size, flag ?
"simulation: {" :
"refinement: {");
1308 get(0).toString(old, str, end, size);
1309 append(str, end, size, flag ?
"} >= " :
" >= ");
1310 get(1).toString(old, str, end, size);
1316 append(str, end, size, flag ?
"simulation: " :
"refinement: ");
1317 get(0).toString(old, str, end, size);
1318 append(str, end, size, flag ?
" <= {" :
" <= ");
1319 get(1).toString(old, str, end, size);
1320 if (flag)
append(str, end, size,
"}");
1324 append(str, end, size,
"{");
1325 get(0).toString(old, str, end, size);
1326 append(str, end, size,
"}\{");
1327 get(1).toString(old, str, end, size);
1328 append(str, end, size,
"}");
1365 if (precedence >
get(0).getPrecedence())
1367 append(str, end, size,
'(');
1369 get(0).toString(old, str, end, size);
1370 if (precedence >
get(0).getPrecedence())
1372 append(str, end, size,
')');
1378 append(str, end, size,
" : ");
1381 append(str, end, size,
" + ");
1384 append(str, end, size,
" - ");
1387 append(str, end, size,
" * ");
1390 append(str, end, size,
" / ");
1393 append(str, end, size,
" % ");
1396 append(str, end, size,
" & ");
1399 append(str, end, size,
" | ");
1402 append(str, end, size,
" ^ ");
1405 append(str, end, size,
" << ");
1408 append(str, end, size,
" >> ");
1411 append(str, end, size,
" && ");
1414 append(str, end, size,
" || ");
1417 append(str, end, size,
" < ");
1420 append(str, end, size,
" <= ");
1423 append(str, end, size,
" == ");
1426 append(str, end, size,
" != ");
1429 append(str, end, size,
" >= ");
1432 append(str, end, size,
" > ");
1437 append(str, end, size,
" := ");
1441 append(str, end, size,
" = ");
1445 append(str, end, size,
" += ");
1448 append(str, end, size,
" -= ");
1451 append(str, end, size,
" /= ");
1454 append(str, end, size,
" %= ");
1457 append(str, end, size,
" *= ");
1460 append(str, end, size,
" &= ");
1463 append(str, end, size,
" |= ");
1466 append(str, end, size,
" ^= ");
1469 append(str, end, size,
" <<= ");
1472 append(str, end, size,
" >>= ");
1475 append(str, end, size,
" <? ");
1478 append(str, end, size,
" >? ");
1481 append(str, end, size,
" \\ ");
1487 if (precedence >=
get(1).getPrecedence())
1489 append(str, end, size,
'(');
1491 get(1).toString(old, str, end, size);
1492 if (precedence >=
get(1).getPrecedence())
1494 append(str, end, size,
')');
1499 append(str, end, size, data->symbol.getName().c_str());
1505 snprintf(s,
sizeof(s),
"%f",getDoubleValue());
1509 snprintf(s,
sizeof(s),
"%d", data->value);
1514 snprintf(s,
sizeof(s),
"%s", data->value ?
"true" :
"false");
1520 if (precedence >
get(0).getPrecedence())
1522 append(str, end, size,
'(');
1523 get(0).toString(old, str, end, size);
1524 append(str, end, size,
')');
1528 get(0).toString(old, str, end, size);
1530 append(str, end, size,
'[');
1531 get(1).toString(old, str, end, size);
1532 append(str, end, size,
']');
1536 append(str, end, size,
'-');
1537 if (precedence >
get(0).getPrecedence())
1539 append(str, end, size,
'(');
1540 get(0).toString(old, str, end, size);
1541 append(str, end, size,
')');
1545 get(0).toString(old, str, end, size);
1551 if (precedence >
get(0).getPrecedence())
1553 append(str, end, size,
'(');
1554 get(0).toString(old, str, end, size);
1555 append(str, end, size,
')');
1559 get(0).toString(old, str, end, size);
1609 append(str, end, size,
"(");
1610 get(0).toString(old, str, end, size);
1611 append(str, end, size,
')');
1630 append(str, end, size,
"(");
1631 get(0).toString(old, str, end, size);
1632 append(str, end, size,
',');
1633 get(1).toString(old, str, end, size);
1634 append(str, end, size,
')');
1640 append(str, end, size,
"(");
1641 get(0).toString(old, str, end, size);
1642 append(str, end, size,
',');
1643 get(1).toString(old, str, end, size);
1644 append(str, end, size,
',');
1645 get(2).toString(old, str, end, size);
1646 append(str, end, size,
')');
1650 append(str, end, size,
'(');
1651 get(0).toString(old, str, end, size);
1652 append(str, end, size,
") xor (");
1653 get(1).toString(old, str, end, size);
1654 append(str, end, size,
')');
1660 if (precedence >
get(0).getPrecedence())
1662 append(str, end, size,
'(');
1663 get(0).toString(old, str, end, size);
1664 append(str, end, size,
')');
1668 get(0).toString(old, str, end, size);
1673 append(str, end, size,
'!');
1674 if (precedence >
get(0).getPrecedence())
1676 append(str, end, size,
'(');
1677 get(0).toString(old, str, end, size);
1678 append(str, end, size,
')');
1682 get(0).toString(old, str, end, size);
1688 type_t type =
get(0).getType();
1691 if (precedence >
get(0).getPrecedence())
1693 append(str, end, size,
'(');
1694 get(0).toString(old, str, end, size);
1695 append(str, end, size,
')');
1699 get(0).toString(old, str, end, size);
1701 append(str, end, size,
'.');
1712 if (precedence >=
get(0).getPrecedence())
1714 append(str, end, size,
'(');
1715 get(0).toString(old, str, end, size);
1716 append(str, end, size,
')');
1720 get(0).toString(old, str, end, size);
1723 append(str, end, size,
" ? ");
1725 if (precedence >=
get(1).getPrecedence())
1727 append(str, end, size,
'(');
1728 get(1).toString(old, str, end, size);
1729 append(str, end, size,
')');
1733 get(1).toString(old, str, end, size);
1736 append(str, end, size,
" : ");
1738 if (precedence >=
get(2).getPrecedence())
1740 append(str, end, size,
'(');
1741 get(2).toString(old, str, end, size);
1742 append(str, end, size,
')');
1746 get(2).toString(old, str, end, size);
1752 get(0).toString(old, str, end, size);
1753 append(str, end, size,
", ");
1754 get(1).toString(old, str, end, size);
1758 get(0).toString(old, str, end, size);
1762 append(str, end, size,
'?');
1765 append(str, end, size,
'!');
1774 append(str, end, size,
"deadlock");
1778 get(0).toString(old, str, end, size);
1779 for (uint32_t i = 1; i < getSize(); i++)
1781 append(str, end, size,
", ");
1782 get(i).toString(old, str, end, size);
1787 get(0).toString(old, str, end, size);
1788 append(str, end, size,
'(');
1791 get(1).toString(old, str, end, size);
1792 for (uint32_t i = 2; i < getSize(); i++)
1794 append(str, end, size,
", ");
1795 get(i).toString(old, str, end, size);
1798 append(str, end, size,
')');
1802 get(0).toString(old, str, end, size);
1803 append(str, end, size,
"'");
1807 append(str, end, size,
"E<> ");
1808 get(0).toString(old, str, end, size);
1812 append(str, end, size,
"E<>* ");
1813 get(0).toString(old, str, end, size);
1817 append(str, end, size,
"E[] ");
1818 get(0).toString(old, str, end, size);
1822 append(str, end, size,
"A<> ");
1823 get(0).toString(old, str, end, size);
1827 append(str, end, size,
"A[] ");
1828 get(0).toString(old, str, end, size);
1832 append(str, end, size,
"A[]* ");
1833 get(0).toString(old, str, end, size);
1837 get(0).toString(old, str, end, size);
1838 append(str, end, size,
" --> ");
1839 get(1).toString(old, str, end, size);
1843 append(str, end, size,
"A[");
1844 get(0).toString(old, str, end, size);
1845 append(str, end, size,
" U ");
1846 get(1).toString(old, str, end, size);
1847 append(str, end, size,
"] ");
1851 append(str, end, size,
"A[");
1852 get(0).toString(old, str, end, size);
1853 append(str, end, size,
" W ");
1854 get(1).toString(old, str, end, size);
1855 append(str, end, size,
"] ");
1859 append(str, end, size,
"A[] ((");
1860 get(0).toString(old, str, end, size);
1861 append(str, end, size,
") and A<> ");
1862 get(1).toString(old, str, end, size);
1863 append(str, end, size,
") ");
1867 append(str, end, size,
"forall (");
1868 append(str, end, size,
get(0).getSymbol().getName().c_str());
1869 append(str, end, size,
":");
1870 append(str, end, size,
get(0).getSymbol().getType().toString().c_str());
1871 append(str, end, size,
") ");
1872 get(1).toString(old, str, end, size);
1876 append(str, end, size,
"exists (");
1877 append(str, end, size,
get(0).getSymbol().getName().c_str());
1878 append(str, end, size,
":");
1879 append(str, end, size,
get(0).getSymbol().getType().toString().c_str());
1880 append(str, end, size,
") ");
1881 get(1).toString(old, str, end, size);
1885 append(str, end, size,
"sum (");
1886 append(str, end, size,
get(0).getSymbol().getName().c_str());
1887 append(str, end, size,
":");
1888 append(str, end, size,
get(0).getSymbol().getType().toString().c_str());
1889 append(str, end, size,
") ");
1890 get(1).toString(old, str, end, size);
1894 append(str, end, size,
"control[");
1895 appendBoundType(str, end, size,
get(0));
1896 get(1).toString(old, str, end, size);
1897 append(str, end, size,
"]: ");
1898 get(2).toString(old, str, end, size);
1902 append(str, end, size,
"{ ");
1903 get(0).toString(old, str, end, size);
1904 append(str, end, size,
"} control: ");
1905 get(1).toString(old, str, end, size);
1909 append(str, end, size,
"E<> ");
1911 append(str, end, size,
"control: ");
1912 get(0).toString(old, str, end, size);
1916 append(str, end, size,
"control_t*(");
1917 get(0).toString(old, str, end, size);
1918 append(str, end, size,
",");
1919 get(1).toString(old, str, end, size);
1920 append(str, end, size,
"): ");
1921 get(2).toString(old, str, end, size);
1925 append(str, end, size,
"control_t*(");
1926 get(0).toString(old, str, end, size);
1927 append(str, end, size,
"): ");
1928 get(1).toString(old, str, end, size);
1932 append(str, end, size,
"control_t*: ");
1933 get(0).toString(old, str, end, size);
1937 append(str, end, size,
"sup{");
1938 get(0).toString(old, str, end, size);
1939 append(str, end, size,
"}: ");
1940 get(1).toString(old, str, end, size);
1944 append(str, end, size,
"inf{");
1945 get(0).toString(old, str, end, size);
1946 append(str, end, size,
"}: ");
1947 get(1).toString(old, str, end, size);
1951 append (str,end,size,
"MITL: ");
1952 get(0).toString (old,str,end,size);
1956 get(0).toString (old,str,end,size);
1957 append (str,end,size,
"U[");
1958 get(1).toString (old,str,end,size);
1959 append (str,end,size,
";");
1960 get(2).toString (old,str,end,size);
1961 append (str,end,size,
"]");
1962 get(3).toString (old,str,end,size);
1966 get(0).toString (old,str,end,size);
1967 append (str,end,size,
"\\/");
1968 get(1).toString (old,str,end,size);
1971 get(0).toString (old,str,end,size);
1972 append (str,end,size,
"/\\");
1973 get(1).toString (old,str,end,size);
1976 get(0).toString (old,str,end,size);
1979 append (str,end,size,
"X(");
1980 get(0).toString (old,str,end,size);
1981 append (str,end,size,
")");
1984 append (str,end,size,
"SPAWN");
1988 append (str,end,size,
"EXIT");
1993 append (str,end,size,
"numof(");
1994 get(0).toString(old,str,end,size);
1995 append (str,end,size,
")");
1998 append (str,end,size,
"forall (");
1999 get(0).toString (old,str,end,size);
2000 append (str,end,size,
" : ");
2001 get(1).toString (old,str,end,size);
2002 append (str,end,size,
" )( ");
2003 get(2).toString (old,str,end,size);
2004 append (str,end,size,
")");
2007 append (str,end,size,
"sum (");
2008 get(0).toString (old,str,end,size);
2009 append (str,end,size,
" : ");
2010 get(1).toString (old,str,end,size);
2011 append (str,end,size,
" )( ");
2012 get(2).toString (old,str,end,size);
2013 append (str,end,size,
")");
2016 append (str,end,size,
"foreach (");
2017 get(0).toString (old,str,end,size);
2018 append (str,end,size,
" : ");
2019 get(1).toString (old,str,end,size);
2020 append (str,end,size,
" )( ");
2021 get(2).toString (old,str,end,size);
2022 append (str,end,size,
")");
2025 get(1).toString (old,str,end,size);
2026 append (str,end,size,
".");
2027 get(0).toString (old,str,end,size);
2030 get(0).toString (old,str,end,size);
2034 append (str,end,size,
"exists (");
2035 get(0).toString (old,str,end,size);
2036 append (str,end,size,
" : ");
2037 get(1).toString (old,str,end,size);
2038 append (str,end,size,
" )( ");
2039 get(2).toString (old,str,end,size);
2040 append (str,end,size,
")");
2044 throw std::runtime_error(
"Strange exception");
2050 return data != NULL && e.data != NULL && data < e.data;
2055 return data == e.data;
2066 return std::string();
2072 s = end =
new char[size];
2074 toString(old, s, end, size);
2075 std::string result(s);
2092 for (uint32_t i = 0; i < getSize(); i++)
2094 get(i).collectPossibleWrites(symbols);
2114 get(0).getSymbols(symbols);
2119 symbol =
get(0).getSymbol();
2128 for (uint32_t i = 1; i < min(getSize(), type.
size()); i++)
2132 get(i).getSymbols(symbols);
2154 for (uint32_t i = 0; i < getSize(); i++)
2156 get(i).collectPossibleReads(symbols);
2162 symbols.insert(getSymbol());
2167 symbol =
get(0).getSymbol();
2212 expr.data->value = value;
2220 expr.data->value = 0;
2228 expr.data->doubleValue = value;
2236 expr.data->symbol =
symbol;
2239 expr.data->type = symbol.
getType();
2243 expr.data->type =
type_t();
2252 expr.data->value = sub.size();
2253 expr.data->sub.reserve(sub.size());
2254 expr.data->sub.assign(sub.begin(), sub.end());
2255 expr.data->type = type;
2263 expr.data->sub.push_back(sub);
2264 expr.data->type = type;
2273 expr.data->sub.reserve(2);
2274 expr.data->sub.push_back(left);
2275 expr.data->sub.push_back(right);
2276 expr.data->type = type;
2285 expr.data->sub.reserve(3);
2286 expr.data->sub.push_back(e1);
2287 expr.data->sub.push_back(e2);
2288 expr.data->sub.push_back(e3);
2289 expr.data->type = type;
2297 expr.data->index = idx;
2298 expr.data->sub.push_back(e);
2299 expr.data->type = type;
2307 expr.data->sync = s;
2308 expr.data->sub.push_back(e);
static expression_t createDouble(double, position_t=position_t())
expression_t()
Default constructor.
static bool isClock(expression_t expr)
Constants::kind_t getKind() const
Returns the kind of the expression.
bool resolve(const std::string &name, symbol_t &symbol)
Resolves a name in this frame or a parent frame.
void getSymbols(std::set< symbol_t > &symbols) const
Returns the set of symbols this expression might resolve into.
static expression_t createExit(position_t=position_t())
bool changesVariable(const std::set< symbol_t > &) const
True if this expression can change any of the variables identified by the given symbols.
int32_t getIndex() const
Returns the index field of this expression.
bool empty() const
Returns true if this is an empty expression.
expression_t clone() const
Make a shallow clone of the expression.
std::set< symbol_t > changes
Variables changed by this function.
static void append(char *&str, char *&end, int &size, const char *s)
static expression_t createNary(Constants::kind_t, const std::vector< expression_t > &, position_t=position_t(), type_t=type_t())
Create an n-ary expression.
symbol_t getSymbol()
Returns the symbol of a variable reference.
double getDoubleValue() const
Returns the value field of this expression.
static type_t createPrimitive(Constants::kind_t, position_t=position_t())
Create a primitive type.
static const char * getBuiltinFunName(kind_t kind)
expression_t & operator=(const expression_t &)
Assignment operator.
expression_t & operator[](uint32_t)
Returns the ith subexpression.
static expression_t createDot(expression_t, int32_t=-1, position_t=position_t(), type_t=type_t())
Create a DOT expression.
std::set< symbol_t > depends
Variables the function depends on.
expression_t & get(uint32_t)
Returns the ith subexpression.
expression_t subst(symbol_t, expression_t) const
static expression_t createUnary(Constants::kind_t, expression_t, position_t=position_t(), type_t=type_t())
Create a unary expression.
std::ostream & operator<<(std::ostream &os, const SignalFlow::strs_t &s)
const position_t & getPosition() const
Returns the position of this expression.
bool isConstant() const
Returns true if and only if all elements of the type are constant.
static string symbol(const char *str)
Extracts the alpha-numerical symbol used for variable/type identifiers.
std::string toString(bool old=false) const
Returns a string representation of the expression.
bool isFunction() const
Shortcut for is(FUNCTION).
static expression_t createTernary(Constants::kind_t, expression_t, expression_t, expression_t, position_t=position_t(), type_t=type_t())
Create a ternary expression.
bool dependsOn(const std::set< symbol_t > &) const
True if the evaluation of this expression depends on any of the symbols in the given set...
void collectPossibleWrites(std::set< symbol_t > &) const
type_t getType() const
Returns the type of this symbol.
static expression_t createDeadlock(position_t=position_t())
Create a DEADLOCK expression.
size_t size() const
Returns the number of children.
symbol_t uid
The symbol of the function.
std::string getRecordLabel(size_t i) const
Returns the label of the 'th field of a record.
expression_t deeperClone() const
Makes a deep clone of the expression.
A reference to an expression.
bool hasDynamicSub() const
Information about a function.
type_t getType() const
Returns the type of the expression.
void * getData()
Returns the user data of this symbol.
virtual int32_t accept(StatementVisitor *visitor)=0
int32_t getValue() const
Returns the value field of this expression.
static void ensure(char *&str, char *&end, int &size, int len)
size_t getSize() const
Returns the number of subexpression.
~expression_t()
Destructor.
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()...
static expression_t createSync(expression_t, Constants::synchronisation_t, position_t=position_t())
Create a SYNC expression.
static expression_t createConstant(int32_t, position_t=position_t())
Create a CONSTANT expression.
void setType(type_t)
Sets the type of the expression.
Constants::synchronisation_t getSync() const
Returns the synchronisation type of SYNC operations.
static expression_t createBinary(Constants::kind_t, expression_t, expression_t, position_t=position_t(), type_t=type_t())
Create a binary expression.
void collectPossibleReads(std::set< symbol_t > &, bool collectRandom=false) const
bool operator<(const expression_t) const
Less-than operator.
bool checkForFP(Statement *s)
bool isRecord() const
Shortcut for is(RECORD).
static expression_t createIdentifier(symbol_t, position_t=position_t())
Create an IDENTIFIER expression.
bool isReferenceTo(const std::set< symbol_t > &) const
Returns true if this expression is a reference to a symbol in the given set.
bool isProcess() const
Shortcut for is(PROCESS).
bool operator==(const expression_t) const
Equality operator.
bool equal(const expression_t &) const
Equality operator.
bool changesAnyVariable() const
True if this expression can change any variable at all.