ACT Library
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1/*************************************************************************
2 *
3 * This file is part of the ACT library
4 *
5 * Copyright (c) 2018-2019 Rajit Manohar
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 **************************************************************************
23 */
24#ifndef __ACT_TYPES_H__
25#define __ACT_TYPES_H__
26
27#include <act/basetype.h>
28#include <act/namespaces.h>
29#include <act/act_array.h>
30#include <act/expr.h>
31#include <act/expr_extra.h>
32#include <common/mstring.h>
33#include <act/inst.h>
34#include <string.h>
35
36class ActBody;
37struct act_chp_lang;
38struct act_chp;
39struct act_prs;
40struct act_spec;
41struct act_attr;
42
49class PInt : public Type {
53 const char *getName() { return "pint"; }
54
58 Type *Expand (ActNamespace */*ns*/, Scope */*s*/, int /*nt*/, inst_param */*u*/) {
59 return this;
60 }
61
65 int isEqual (const Type *t) const { return t == this ? 1 : 0; }
66};
67
68
75class PInts : public Type {
76 const char *getName() { return "pints"; }
77 Type *Expand (ActNamespace */*ns*/, Scope */*s*/, int /*nt*/, inst_param */*u*/) {
78 return this;
79 }
80 int isEqual (const Type *t) const { return t == this ? 1 : 0; }
81};
82
83
89class PBool : public Type {
93 const char *getName() { return "pbool"; }
94
98 Type *Expand (ActNamespace */*ns*/, Scope */*s*/, int /*nt*/, inst_param */*u*/) {
99 return this;
100 }
101
105 int isEqual (const Type *t) const { return t == this ? 1 : 0; }
106};
107
108
114class PReal : public Type {
118 const char *getName() { return "preal"; }
119
123 Type *Expand (ActNamespace */*ns*/, Scope */*s*/, int /*nt*/, inst_param */*u*/) {
124 return this;
125 }
126
130 int isEqual (const Type *t) const { return t == this ? 1 : 0; }
131};
132
139class PType : public Type {
140public:
144 const char *getName();
145
155 PType *Expand (ActNamespace *ns, Scope *s, int nt, inst_param *u);
156
157 PType() { i = NULL; name = NULL; };
158
159 /* wrong */
160 int isEqual (const Type *t) const { return t == this ? 1 : 0; }
161
165 InstType *getType () { return i; }
166
167private:
170
171 const char *name;
173
174 friend class TypeFactory;
175};
176
182class Bool : public Type {
186 const char *getName() { return "bool"; }
187
188 Type *Expand (ActNamespace */*ns*/, Scope */*s*/, int /*nt*/, inst_param */*u*/) {
189 return this;
190 }
191 int isEqual (const Type *t) const { return t == this ? 1 : 0; }
192};
193
194
201class Int : public Type {
205 const char *getName();
206
215 Int *Expand (ActNamespace *ns, Scope *s, int nt, inst_param *u);
216
220 int isEqual (const Type *t) const;
221
222 unsigned int kind:2;
223 int w;
225
226 const char *name;
227
228 friend class TypeFactory;
229};
230
237class Chan : public Type {
241 const char *getName ();
242
253 Chan *Expand (ActNamespace *ns, Scope *s, int nt, inst_param *u);
254
258 int isEqual (const Type *t) const;
259
260
261 const char *name;
264
265public:
269 InstType *datatype() const { return p; }
270
274 InstType *acktype() const { return ack; }
275
279 int isBiDirectional() { return ack == NULL ? 0 : 1; }
280
281 friend class TypeFactory;
282};
283
284
285class InstType;
286class UserMacro;
287
288
289
310class UserDef : public Type {
311 public:
316
323
324 virtual ~UserDef ();
325
330 const char *getFile() { return file; }
331
336 void setFile(const char *s) { file = string_cache (s); }
337
341 int getLine() { return lineno; }
342
347 void setLine(int num) { lineno = num; }
348
354 int IsExported () { return exported; }
355
359 void MkExported () { exported = 1; }
360
364 int isExpanded() const { return expanded; }
365
366
375 int AddMetaParam (InstType *t, const char *id);
376
385 int AddPort (InstType *t, const char *id);
386
387
402 int FindPort (const char *id);
403
413 const char *getPortName (int pos) const;
414
415
425 InstType *getPortType (int pos) const;
426
434 void refinePortType (int pos, InstType *u);
435
440 const char *getName ();
441
446 char *getFullName();
447
448
454 void printActName (FILE *fp);
455
456 int isEqual (const Type *t) const;
457
464 void setName (const char *s) { name = s; }
465
471 void MkCopy (UserDef *u);
472
478 int isEqual (const UserDef *u) const;
479
487
491 InstType *getParent () const { return parent; }
492
499 int isDefined () { return defined; }
500
504 void MkDefined () { defined = 1; }
505
512 int isPort(const char *name);
513
517 int getNumParams () const { return nt; }
518
527 int getRemainingParams() const { return nt - inherited_templ; }
528
532 int getNumPorts () const { return nports; }
533
541 InstType *Lookup (ActId *id) { return I->Lookup (id, 0); }
542
550 InstType *Lookup (const char *nm) { return I->Lookup (nm); }
551
555 Scope *CurScope() { return I; }
556
563 int isStrictPort (const char *name);
564
568 virtual void Print (FILE */*fp*/) { }
569
578 void PrintHeader (FILE *fp, const char *type);
579
584 void setBody (ActBody *x) { b = x; }
585
591
595 ActBody *getBody () { return b; }
596
600 UserDef *Expand (ActNamespace */*ns*/, Scope */*s*/, int /*nt*/, inst_param */*u*/) {
601 Assert (0, "Don't call this ever");
602 }
603
616 UserDef *Expand (ActNamespace *ns, Scope *s, int nt, inst_param *u, int *cache_hit, int is_process = 0);
617
621 ActNamespace *getns() { return _ns; }
622
630 InstType *root() const;
631
636
641
645 act_languages *getlang () { return lang; }
646
651 int isLeaf();
652
656 void mkRefined() { has_refinement = 1; }
657
662
668 UserMacro *newMacro (const char *name);
669
675 UserMacro *getMacro (const char *name);
676
677 protected:
679
680 unsigned int defined:1;
681 unsigned int expanded:1;
682
683 unsigned int pending:1;
684
685 unsigned int exported:1;
686
688
689 int nt;
691 const char **pn;
692
693 int nports;
695 const char **port_n;
696
698
699 const char *name;
700
703
705
706 int level;
707
708 const char *file;
709 int lineno;
711
714
720 int emitMacros (FILE *fp);
721
723};
724
725
734class Interface : public UserDef {
735 public:
738
740};
741
742
750class Process : public UserDef {
751 public:
757 virtual ~Process ();
758
762 void MkCell () { is_cell = 1; }
763
767 int isCell() { return is_cell; }
768
770
771 void Print (FILE *fp);
772
777
788
797 void addIface (InstType *iface, list_t *imap);
798
802 int hasIface (InstType *x, int weak);
803
808 list_t *findMap (InstType *iface);
809
810 /*-- edit API --*/
811
819 bool updateInst (char *name, Process *t);
820
839 const char *addBuffer (char *name, ActId *port, Process *buf);
840
847 const char *addBuffer (Process *buf, list_t *inst_ports);
848
853
858 void recordGlobal (ActId *id);
859
865 int findGlobal (ActId *id);
866
872 int findGlobal (const char *s);
873
874 private:
875 unsigned int is_cell:1;
876 list_t *ifaces;
879
880 list_t *used_globals;
882
883 int bufcnt;
885};
886
887
912class Function : public UserDef {
913 public:
916
921 void setRetType (InstType *i) { ret_type = i; }
922
927
932
936 void Print (FILE *fp);
937
948 Expr *eval (ActNamespace *ns, int nargs, Expr **args);
949
961 Expr **toInline (int nargs, Expr **args);
962
967
974
978 void chkInline ();
979
980 private:
983
984 void _chk_inline (Expr *e);
985 void _chk_inline (struct act_chp_lang *c);
986};
987
988
989#define ACT_NUM_STD_METHODS 8
991
992#define ACT_NUM_EXPR_METHODS 2
994
1000
1006
1012
1013
1019 ACT_METHOD_SET = 0,
1021
1022 ACT_METHOD_GET = 1,
1024
1027
1030
1031 ACT_METHOD_SEND_UP = 4,
1033
1034 ACT_METHOD_RECV_UP = 5,
1036
1039
1042
1046
1050
1051
1062class Data : public UserDef {
1063 public:
1065 virtual ~Data();
1066
1067 int isEqual (const Type *t) const;
1068
1075 void MkEnum (int is_int) { is_enum = 1; is_eint = is_int ? 1 : 0; }
1076
1080 int isEnum () const { return is_enum; }
1081
1086 int isPureEnum() const { return (is_enum && !is_eint) ? 1 : 0; }
1087
1092 void addEnum (const char *s) {
1093 if (!enum_vals) {
1094 enum_vals = list_new ();
1095 }
1096 list_append (enum_vals, s);
1097 }
1098
1102 int numEnums() const {
1103 if (enum_vals) {
1104 return list_length (enum_vals);
1105 }
1106 return 0;
1107 }
1108
1115 int enumVal (const char *s) const {
1116 int i = 0;
1117 if (!enum_vals) return -1;
1118 for (listitem_t *li = list_first (enum_vals); li; li = list_next (li)) {
1119 if (strcmp ((const char *)list_value (li), s) == 0) {
1120 return i;
1121 }
1122 i++;
1123 }
1124 return -1;
1125 }
1126
1132 void setMethod (int t, struct act_chp_lang *h) { methods[t] = h; }
1133
1138 struct act_chp_lang *getMethod (int t) { return methods[t]; }
1139
1146
1151
1155 void Print (FILE *fp);
1156
1163 void getStructCount (int *nbools, int *nints);
1164
1178 int getStructOffset (ActId *field, int *sz);
1179
1189 ActId **getStructFields (int **types);
1190
1191private:
1192 void _get_struct_count (int *nbools, int *nints);
1193 void _get_struct_fields (ActId **a, int *types, int *pos, ActId *prefix);
1194
1195 unsigned int is_enum:1;
1197 unsigned int is_eint:1;
1198
1203
1204 list_t *enum_vals;
1206};
1207
1208
1215class Channel : public UserDef {
1216 public:
1218 virtual ~Channel();
1219
1223 void setMethod (int t, act_chp_lang *h) { methods[t] = h; }
1224
1231 void setMethod (int t, Expr *e) { emethods[t-ACT_NUM_STD_METHODS] = e; }
1232
1236 act_chp_lang *getMethod(int t) { return methods[t]; }
1237
1243
1250
1252
1253 void Print (FILE *fp);
1254
1269 int chanDir (ActId *id, int isinput);
1270
1281
1292
1298 Assert (parent, "what?");
1299 Channel *p = dynamic_cast<Channel *>(parent->BaseType());
1300 if (p) {
1301 return p->isBiDirectional();
1302 }
1303 else {
1304 Chan *p = dynamic_cast<Chan *>(parent->BaseType());
1305 Assert (p, "What?");
1306 return p->isBiDirectional();
1307 }
1308 }
1309 private:
1312};
1313
1314
1315struct act_inline_table;
1316
1317
1325public:
1332 UserMacro (UserDef *u, const char *name);
1334
1335 void Print (FILE *fp);
1336
1343 UserMacro *Expand (UserDef *ux, ActNamespace *ns, Scope *s, int is_proc);
1344
1350 int addPort (InstType *it, const char *name);
1351
1355 const char *getName () { return _nm; }
1356
1360 int getNumPorts() const { return nports; }
1361
1367 const char *getPortName (int i) const { return port_n[i]; }
1368
1374 InstType *getPortType (int i) const { return port_t[i]; }
1375
1379 void setBody (struct act_chp_lang *);
1380
1389 struct act_chp_lang *substitute (ActId *instnm, act_inline_table *tab);
1390
1391private:
1392 const char *_nm;
1394
1397 const char **port_n;
1398
1399 struct act_chp_lang *c;
1400};
1401
1402
1416 private:
1417 static TypeFactory *tf;
1419
1425
1431
1437
1443
1447 static InstType *bools[5];
1448
1453
1458
1463 static struct iHashtable *expr_int;
1464
1469 static struct cHashtable *inthash;
1470
1475 static struct cHashtable *enumhash;
1476
1480 static struct cHashtable *ptypehash;
1481
1486 static int inthashfn (int, void *);
1487 static int intmatchfn (void *, void *);
1488 static void *intdupfn (void *);
1489 static void intfreefn (void *);
1490
1495 static struct cHashtable *chanhash;
1496
1500 static int chanhashfn (int, void *);
1501 static int chanmatchfn (void *, void *);
1502 static void *chandupfn (void *);
1503 static void chanfreefn (void *);
1504
1505 public:
1508
1509 void *operator new (size_t);
1510 void operator delete (void *);
1511
1515 InstType *NewPInt () { return pint; }
1516
1520 InstType *NewPInts () { return pints; }
1521
1525 InstType *NewPBool () { return pbool; }
1526
1530 InstType *NewPReal () { return preal; }
1531
1536
1541
1548
1561 InstType *NewInt (Scope *s, Type::direction dir, int sig, Expr *w);
1562 Int *NewInt (int sig, int w);
1563
1576
1588
1593
1601
1602
1609 static Expr *NewExpr (Expr *e);
1610
1614 static TypeFactory *Factory() { return tf; }
1615
1619 static void Init ();
1620
1621
1629 static int isDataType (const Type *t);
1630
1632 static int isDataType (const InstType *t);
1633
1640 static int isIntType (const Type *t);
1641
1643 static int isIntType (const InstType *t);
1644
1651 static int isPIntType (const Type *t);
1652
1654 static int isPIntType (const InstType *t);
1655
1662 static int isPIntsType (const Type *t);
1663
1665 static int isPIntsType (const InstType *t);
1666
1673 static int isBoolType (const Type *t);
1674
1676 static int isBoolType (const InstType *it);
1677
1684 static int isPBoolType (const Type *t);
1685
1687 static int isPBoolType (const InstType *it);
1688
1695 static int isPRealType (const Type *t);
1696
1698 static int isPRealType (const InstType *it);
1699
1706 static int isUserType (const Type *t);
1707
1709 static int isUserType (const InstType *it);
1710
1718 static int isChanType (const Type *t);
1719
1721 static int isChanType (const InstType *it);
1722
1729 static int isExactChanType (const Type *t);
1730
1732 static int isExactChanType (const InstType *it);
1733
1743 static int isValidChannelDataType (const Type *t);
1744
1746 static int isValidChannelDataType (const InstType *t);
1747
1754 static int isProcessType (const Type *t);
1755
1757 static int isProcessType (const InstType *it);
1758
1765 static int isFuncType (const Type *t);
1766
1768 static int isFuncType (const InstType *it);
1769
1770
1777 static int isInterfaceType (const Type *t);
1778
1780 static int isInterfaceType (const InstType *it);
1781
1788 static int isPTypeType (const Type *t);
1789
1791 static int isPTypeType (const InstType *it);
1792
1793
1801 static int isParamType (const Type *t);
1802
1804 static int isParamType (const InstType *it);
1805
1816 static int bitWidth (const Type *t);
1817
1819 static int bitWidth (const InstType *t);
1820
1828 static int bitWidthTwo (const Type *t);
1829
1831 static int bitWidthTwo (const InstType *t);
1832
1840 static int boolType (const Type *t);
1841
1843 static int boolType (const InstType *t);
1844
1851 static int isStructure (const Type *t);
1852
1854 static int isStructure (const InstType *it);
1855
1860 static int isUserEnum (const Type *t);
1861
1863 static int isUserEnum (const InstType *it);
1864
1870 static int isUserPureEnum (const Type *t);
1871
1873 static int isUserPureEnum (const InstType *it);
1874
1883 static int enumNum (const Type *t);
1884 static int enumNum (const InstType *t);
1885
1891 static int isEnum (const Type *t);
1892
1894 static int isEnum (const InstType *t);
1895
1901 static int isBaseBoolType (const Type *t);
1902
1904 static int isBaseBoolType (const InstType *t);
1905
1912 static int isBaseIntType (const Type *t);
1913
1915 static int isBaseIntType (const InstType *t);
1916
1921
1928};
1929
1930#include <act/typecheck.h>
1931
1932/*------------------------------------------------------------------------
1933 *
1934 * Helper functions for expression manipulation
1935 *
1936 *------------------------------------------------------------------------
1937 */
1938
1946int expr_equal (const Expr *a, const Expr *b);
1947
1956void print_expr (FILE *fp, const Expr *e);
1957
1967void sprint_expr (char *buf, int sz, const Expr *e);
1968
1969
1977void print_uexpr (FILE *fp, const Expr *e);
1978
1979
1988void sprint_uexpr (char *buf, int sz, const Expr *e);
1989
1997
2009
2016const char *expr_op_name (int);
2017
2018/* unified expression expansion code, with flags to control
2019 different variations */
2020#define ACT_EXPR_EXFLAG_ISLVAL 0x1
2022
2023#define ACT_EXPR_EXFLAG_PARTIAL 0x2
2026
2027#define ACT_EXPR_EXFLAG_CHPEX 0x4
2029
2030#define ACT_EXPR_EXFLAG_DUPONLY 0x8
2031
2032extern int _act_chp_is_synth_flag;
2037
2051Expr *expr_expand (Expr *e, ActNamespace *ns, Scope *s, unsigned int flag = 0x2);
2052
2056#define expr_dup(e) expr_expand ((e), NULL, NULL, ACT_EXPR_EXFLAG_DUPONLY)
2057
2062
2063/*
2064 External functions for core act library must
2065 be of the form
2066
2067 long function_name (int nargs, long *args);
2068*/
2069
2070struct ExtLibs;
2071
2081void *act_find_dl_func (struct ExtLibs *el, ActNamespace *ns, const char *f);
2082
2091struct ExtLibs *act_read_extern_table (const char *prefix);
2092
2093
2094
2102void act_error_push (const char *s, const char *file, int line);
2103
2113void act_error_update (const char *file, int line); // set file to
2114 // NULL to keep
2115 // the file name
2116
2119
2120void act_error_ctxt (FILE *);
2122
2123const char *act_error_top ();
2125
2126void act_error_setline (int line);
2127
2128#endif /* __ACT_TYPES_H__ */
This class is used to hold the contents of the body of any user-defined type or namespace....
Definition: body.h:52
This class is used to store Act identifiers that correspond to instances. Identifiers have an optiona...
Definition: act_id.h:56
The ActNamespace class holds all the information about a namespace.
Definition: namespaces.h:469
Used to represent the built-in ACT bool datatype.
Definition: types.h:182
int isEqual(const Type *t) const
Definition: types.h:191
const char * getName()
Definition: types.h:186
Type * Expand(ActNamespace *, Scope *, int, inst_param *)
Definition: types.h:188
Used to represent the built-in ACT Paramterized chan(foo) type or chan(foo,foo) bi-directional/exchan...
Definition: types.h:237
InstType * ack
second data type for exchange channel
Definition: types.h:263
Chan * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
InstType * p
data type for expanded channel
Definition: types.h:262
int isEqual(const Type *t) const
InstType * acktype() const
Definition: types.h:274
int isBiDirectional()
Definition: types.h:279
const char * name
the string name for the type
Definition: types.h:261
InstType * datatype() const
Definition: types.h:269
const char * getName()
User-defined channel type. Channels can be unidirectional or bi-directional (sometimes called exchang...
Definition: types.h:1215
void copyMethods(Channel *c)
Expr * emethods[ACT_NUM_EXPR_METHODS]
emethods table
Definition: types.h:1311
int mustbeActiveRecv()
struct act_chp_lang * methods[ACT_NUM_STD_METHODS]
methods table
Definition: types.h:1310
void setMethod(int t, act_chp_lang *h)
Definition: types.h:1223
Channel(UserDef *u)
act_chp_lang * getMethod(int t)
Definition: types.h:1236
int mustbeActiveSend()
Expr * geteMethod(int t)
Definition: types.h:1242
void setMethod(int t, Expr *e)
Definition: types.h:1231
int isBiDirectional()
Definition: types.h:1297
int chanDir(ActId *id, int isinput)
void Print(FILE *fp)
virtual ~Channel()
Channel * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
A user-defined data types.
Definition: types.h:1062
int enumVal(const char *s) const
Definition: types.h:1115
int getStructOffset(ActId *field, int *sz)
Data * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
void Print(FILE *fp)
Data(UserDef *u)
struct act_chp_lang * methods[ACT_NUM_STD_METHODS]
Definition: types.h:1199
void copyMethods(Data *d)
int numEnums() const
Definition: types.h:1102
unsigned int is_eint
1 if this enum can be treated as an int
Definition: types.h:1197
void _get_struct_count(int *nbools, int *nints)
void addEnum(const char *s)
Definition: types.h:1092
list_t * enum_vals
Definition: types.h:1204
virtual ~Data()
int isEnum() const
Definition: types.h:1080
unsigned int is_enum
Definition: types.h:1195
int isEqual(const Type *t) const
equality test
int isPureEnum() const
Definition: types.h:1086
void getStructCount(int *nbools, int *nints)
struct act_chp_lang * getMethod(int t)
Definition: types.h:1138
ActId ** getStructFields(int **types)
void setMethod(int t, struct act_chp_lang *h)
Definition: types.h:1132
void MkEnum(int is_int)
Definition: types.h:1075
void _get_struct_fields(ActId **a, int *types, int *pos, ActId *prefix)
This holds information about ACT functions. ACT functions are of two types:
Definition: types.h:912
InstType * ret_type
holds return type
Definition: types.h:981
int isSimpleInline()
Definition: types.h:973
Expr ** toInline(int nargs, Expr **args)
void chkInline()
int is_simple_inline
holds the simple inline flag
Definition: types.h:982
void _chk_inline(struct act_chp_lang *c)
used to check simple inline
int isExternal()
void Print(FILE *fp)
Function(UserDef *u)
void setRetType(InstType *i)
Definition: types.h:921
void _chk_inline(Expr *e)
used to check simple inline
InstType * getRetType()
Definition: types.h:926
Function * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
Expr * eval(ActNamespace *ns, int nargs, Expr **args)
An instance type.
Definition: inst.h:92
Type * BaseType() const
Definition: inst.h:181
Used to represent the built-in ACT int< > datatype. This is also used to represent enumerations.
Definition: types.h:201
int w
Definition: types.h:223
Int * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
unsigned int kind
0 = unsigned, 1 = signed, 2 = enum
Definition: types.h:222
const char * name
string name for the type (for printing)
Definition: types.h:226
const char * getName()
int isEqual(const Type *t) const
Holds the interface definition. Looks like a process. Body is empty.
Definition: types.h:734
Interface * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
Interface(UserDef *u)
Used for Boolean parameters.
Definition: types.h:89
Type * Expand(ActNamespace *, Scope *, int, inst_param *)
Definition: types.h:98
int isEqual(const Type *t) const
Definition: types.h:105
const char * getName()
Definition: types.h:93
Integer parameter type.
Definition: types.h:49
const char * getName()
Definition: types.h:53
Type * Expand(ActNamespace *, Scope *, int, inst_param *)
Definition: types.h:58
int isEqual(const Type *t) const
Definition: types.h:65
Unused. Originally pint and pints were supposed to be unsigned and signed integers....
Definition: types.h:75
const char * getName()
destructor
Definition: types.h:76
int isEqual(const Type *t) const
Definition: types.h:80
Type * Expand(ActNamespace *, Scope *, int, inst_param *)
Definition: types.h:77
Used for real parameters.
Definition: types.h:114
const char * getName()
Definition: types.h:118
Type * Expand(ActNamespace *, Scope *, int, inst_param *)
Definition: types.h:123
int isEqual(const Type *t) const
Definition: types.h:130
Used for ptype( ) parameters. ptype parameters take an interface type as a template parameter.
Definition: types.h:139
InstType * i
Definition: types.h:168
PType()
Definition: types.h:157
const char * name
Definition: types.h:171
int isEqual(const Type *t) const
Definition: types.h:160
PType * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
const char * getName()
InstType * getType()
Definition: types.h:165
User-defined processes.
Definition: types.h:750
int hasIface(InstType *x, int weak)
void MkCell()
Definition: types.h:762
void addIface(InstType *iface, list_t *imap)
const char * addBuffer(Process *buf, list_t *inst_ports)
bool updateInst(char *name, Process *t)
int findGlobal(const char *s)
int isLowLevelBlackBox()
int isBlackBox()
const char * addBuffer(char *name, ActId *port, Process *buf)
Process * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u)
unsigned int is_cell
1 if this is a defcell, 0 otherwise
Definition: types.h:875
list_t * ifaces
Definition: types.h:876
Process(UserDef *u)
virtual ~Process()
void recordGlobal(ActId *id)
int bufcnt
Definition: types.h:883
int isCell()
Definition: types.h:767
list_t * used_globals
Definition: types.h:880
int findGlobal(ActId *id)
void Print(FILE *fp)
list_t * findMap(InstType *iface)
Process * getUnexpanded()
This is the data structure that holds all instances and their associated types within a scope....
Definition: namespaces.h:77
InstType * Lookup(const char *s)
This is the class used to create all instance types. It also caches types to reduce memory usage.
Definition: types.h:1415
static struct cHashtable * chanhash
Definition: types.h:1495
static int isBoolType(const InstType *it)
static int isValidChannelDataType(const InstType *t)
InstType * NewPType(Scope *s, InstType *t)
InstType * NewPInts()
Definition: types.h:1520
static int isInterfaceType(const Type *t)
Chan * NewChan(InstType *l, InstType *ack)
static void chanfreefn(void *)
static int intmatchfn(void *, void *)
static InstType * getChanAckType(const InstType *t)
static int isInterfaceType(const InstType *it)
static int isPTypeType(const Type *t)
InstType * NewBool(Type::direction dir)
static InstType * pint
Definition: types.h:1424
static int isBoolType(const Type *t)
static int isValidChannelDataType(const Type *t)
static int isUserPureEnum(const Type *t)
static int isExactChanType(const InstType *it)
static TypeFactory * Factory()
Definition: types.h:1614
static int boolType(const InstType *t)
static struct cHashtable * enumhash
Definition: types.h:1475
static Expr * expr_true
Definition: types.h:1452
static int isBaseIntType(const Type *t)
static int isPIntsType(const Type *t)
static int chanmatchfn(void *, void *)
static int isParamType(const InstType *it)
static int isProcessType(const Type *t)
static int enumNum(const Type *t)
static InstType * pbool
Definition: types.h:1442
InstType * NewInt(Scope *s, Type::direction dir, int sig, Expr *w)
static int isBaseBoolType(const InstType *t)
static int isIntType(const Type *t)
static struct cHashtable * inthash
Definition: types.h:1469
static int isDataType(const Type *t)
static InstType * bools[5]
Definition: types.h:1447
static int isPBoolType(const InstType *it)
static int bitWidthTwo(const Type *t)
static int isDataType(const InstType *t)
static void intfreefn(void *)
static int isEnum(const InstType *t)
static int isProcessType(const InstType *it)
static Expr * NewExpr(Expr *e)
static void * chandupfn(void *)
Int * NewInt(int sig, int w)
static int bitWidthTwo(const InstType *t)
static int isBaseIntType(const InstType *t)
static void Init()
InstType * NewChan(Scope *s, Type::direction dir, InstType *l, InstType *ack)
static struct iHashtable * expr_int
Definition: types.h:1463
static int isPIntType(const Type *t)
static InstType * pints
Definition: types.h:1430
static int isUserType(const Type *t)
static struct cHashtable * ptypehash
Definition: types.h:1480
static int isPIntsType(const InstType *t)
static InstType * getChanDataType(const InstType *t)
static int isParamType(const Type *t)
static TypeFactory * tf
Definition: types.h:1417
static void * intdupfn(void *)
InstType * NewPInt()
Definition: types.h:1515
static int isPIntType(const InstType *t)
static InstType * preal
Definition: types.h:1436
static int inthashfn(int, void *)
static int bitWidth(const InstType *t)
static int isUserEnum(const InstType *it)
InstType * NewPBool()
Definition: types.h:1525
static int boolType(const Type *t)
InstType * NewUserDef(Scope *s, InstType *it)
static int isPRealType(const InstType *it)
static int isPRealType(const Type *t)
static int isBaseBoolType(const Type *t)
static int isIntType(const InstType *t)
InstType * NewPReal()
Definition: types.h:1530
static int isChanType(const InstType *it)
static int isEnum(const Type *t)
static int isChanType(const Type *t)
static int bitWidth(const Type *t)
InstType * NewEnum(Scope *s, Type::direction dir, Expr *w)
static int enumNum(const InstType *t)
static Expr * expr_false
Definition: types.h:1457
static int isStructure(const Type *t)
static int isStructure(const InstType *it)
static int isUserEnum(const Type *t)
static int isUserType(const InstType *it)
PType * NewPType(InstType *t)
static int isFuncType(const Type *t)
static int isExactChanType(const Type *t)
static int isPBoolType(const Type *t)
static int chanhashfn(int, void *)
static int isPTypeType(const InstType *it)
static int isFuncType(const InstType *it)
static int isUserPureEnum(const InstType *it)
The abstract base class for all types in the system.
Definition: basetype.h:45
direction
Definition: basetype.h:87
UserDef stores information that is common to all user-defined types. User-defined types are more comp...
Definition: types.h:310
Scope * I
instances
Definition: types.h:697
int isLeaf()
int isDefined()
Definition: types.h:499
int isPort(const char *name)
void AppendBody(ActBody *x)
void PrintHeader(FILE *fp, const char *type)
const char * getName()
void setName(const char *s)
Definition: types.h:464
UserDef(UserDef *x)
InstType * Lookup(ActId *id)
Definition: types.h:541
int isEqual(const Type *t) const
UserMacro * newMacro(const char *name)
InstType * root() const
int getNumParams() const
Definition: types.h:517
int nports
number of ports
Definition: types.h:693
void SetParent(InstType *t)
int inherited_templ
number of inherited template parameters
Definition: types.h:712
InstType * parent
implementation relationship, if any
Definition: types.h:678
UserDef * Expand(ActNamespace *, Scope *, int, inst_param *)
Definition: types.h:600
int getNumPorts() const
Definition: types.h:532
act_languages * getlang()
Definition: types.h:645
ActBody * b
body of user-defined type
Definition: types.h:701
const char ** port_n
port names
Definition: types.h:695
int getRemainingParams() const
Definition: types.h:527
int isStrictPort(const char *name)
void printActName(FILE *fp)
UserDef * Expand(ActNamespace *ns, Scope *s, int nt, inst_param *u, int *cache_hit, int is_process=0)
ActNamespace * _ns
namespace within which this type is defined
Definition: types.h:702
unsigned int defined
1 if this has been defined, 0 otherwise
Definition: types.h:680
UserDef(ActNamespace *ns)
inst_param ** inherited_param
the inherited parameters
Definition: types.h:713
InstType ** pt
parameter types
Definition: types.h:690
void refinePortType(int pos, InstType *u)
act_languages * lang
sub-languages within this type
Definition: types.h:687
ActBody * getBody()
Definition: types.h:595
virtual void Print(FILE *)
Definition: types.h:568
virtual ~UserDef()
destructor, releases storage
int hasRefinement()
Definition: types.h:661
InstType * getParent() const
Definition: types.h:491
void setFile(const char *s)
Definition: types.h:336
unsigned int expanded
1 if this has been expanded, 0 otherwise
Definition: types.h:681
void setLine(int num)
Definition: types.h:347
int AddPort(InstType *t, const char *id)
act_prs * getprs()
void MkDefined()
Definition: types.h:504
int FindPort(const char *id)
int AddMetaParam(InstType *t, const char *id)
int level
default modeling level for the type
Definition: types.h:706
int isExpanded() const
Definition: types.h:364
InstType * getPortType(int pos) const
const char * getPortName(int pos) const
int lineno
line number (if known) where this was defined
Definition: types.h:709
int nt
number of template parameters
Definition: types.h:689
const char ** pn
parameter names
Definition: types.h:691
unsigned int exported
1 if the type is exported, 0 otherwise
Definition: types.h:685
int IsExported()
Definition: types.h:354
void MkExported()
Definition: types.h:359
A_DECL(UserMacro *, um)
user-defined macros
ActNamespace * getns()
Definition: types.h:621
Scope * CurScope()
Definition: types.h:555
act_spec * getspec()
int isEqual(const UserDef *u) const
const char * name
Name of the user-defined type.
Definition: types.h:699
const char * file
file name (if known) where this was defined
Definition: types.h:708
int getLine()
Definition: types.h:341
void mkRefined()
Definition: types.h:656
const char * getFile()
Definition: types.h:330
unsigned int pending
1 if this is currently being expanded, 0 otherwise
Definition: types.h:683
void MkCopy(UserDef *u)
char * getFullName()
int emitMacros(FILE *fp)
InstType ** port_t
port types
Definition: types.h:694
UserMacro * getMacro(const char *name)
UserDef * unexpanded
unexpanded type, if any
Definition: types.h:704
int has_refinement
1 if there is a refinement body
Definition: types.h:710
void setBody(ActBody *x)
Definition: types.h:584
InstType * Lookup(const char *nm)
Definition: types.h:550
Used to hold a user-defined macro. These macros provide more convenient methods to interface with pro...
Definition: types.h:1324
int getNumPorts() const
Definition: types.h:1360
int nports
number of ports
Definition: types.h:1395
const char ** port_n
port names
Definition: types.h:1397
UserMacro(UserDef *u, const char *name)
const char * getName()
Definition: types.h:1355
InstType * getPortType(int i) const
Definition: types.h:1374
const char * _nm
name of the macro
Definition: types.h:1392
UserDef * parent
user-defined type with this macro
Definition: types.h:1393
InstType ** port_t
port types
Definition: types.h:1396
struct act_chp_lang * substitute(ActId *instnm, act_inline_table *tab)
void Print(FILE *fp)
int addPort(InstType *it, const char *name)
const char * getPortName(int i) const
Definition: types.h:1367
UserMacro * Expand(UserDef *ux, ActNamespace *ns, Scope *s, int is_proc)
struct act_chp_lang * c
body
Definition: types.h:1399
void setBody(struct act_chp_lang *)
This holds all the sub-langugae bodies in a namespace/user-defined type definition.
Definition: lang.h:641
Contains extra expression types beyond the standard ones from expr.h defined in the generic expressio...
This contains the definition of InstType, the core data structure used to hold the type of any instan...
This contains the defintions of the ActNamespace class as well as the Scope classes....
Attribute list associated with an instance.
Definition: lang.h:44
Data structure for the chp sub-language body.
Definition: lang.h:286
Holds a CHP sub-language.
Definition: lang.h:367
Structure that holds all the prs { } blocks in a particular scope. This is a linked-list of blocks,...
Definition: lang.h:194
The specification sub-language.
Definition: lang.h:397
Definition: expr.h:79
This holds a single template parameter. A template parameter is either an array expression,...
Definition: inst.h:52
Typechecking identifiers and expression.
void act_error_setline(int line)
set the current line number
#define ACT_NUM_STD_METHODS
Definition: types.h:989
const char * act_error_top()
void act_error_push(const char *s, const char *file, int line)
int _act_chp_is_synth_flag
void print_uexpr(FILE *fp, const Expr *e)
int expr_equal(const Expr *a, const Expr *b)
void act_error_pop()
void sprint_expr(char *buf, int sz, const Expr *e)
void act_error_update(const char *file, int line)
void act_error_ctxt(FILE *)
void print_expr(FILE *fp, const Expr *e)
#define ACT_NUM_EXPR_METHODS
Definition: types.h:992
Expr * expr_expand(Expr *e, ActNamespace *ns, Scope *s, unsigned int flag=0x2)
Expr * expr_dup_const(Expr *e)
const char * expr_op_name(int)
int expr_is_a_const(Expr *e)
const int act_builtin_method_boolret[ACT_NUM_EXPR_METHODS]
struct ExtLibs * act_read_extern_table(const char *prefix)
const char * act_builtin_method_name[ACT_NUM_STD_METHODS]
void * act_find_dl_func(struct ExtLibs *el, ActNamespace *ns, const char *f)
const char * act_builtin_method_expr[ACT_NUM_EXPR_METHODS]
void expr_ex_free(Expr *)
datatype_methods
Definition: types.h:1018
@ ACT_METHOD_SET
Definition: types.h:1019
@ ACT_METHOD_RECV_INIT
Definition: types.h:1040
@ ACT_METHOD_RECV_REST
Definition: types.h:1028
@ ACT_METHOD_RECV_PROBE
Definition: types.h:1047
@ ACT_METHOD_SEND_UP
Definition: types.h:1031
@ ACT_METHOD_SEND_INIT
Definition: types.h:1037
@ ACT_METHOD_SEND_PROBE
Definition: types.h:1043
@ ACT_METHOD_RECV_UP
Definition: types.h:1034
@ ACT_METHOD_SEND_REST
Definition: types.h:1025
@ ACT_METHOD_GET
Definition: types.h:1022
void sprint_uexpr(char *buf, int sz, const Expr *e)