ACT Library
Loading...
Searching...
No Matches
inst.h
Go to the documentation of this file.
1/*************************************************************************
2 *
3 * This file is part of the ACT library
4 *
5 * Copyright (c) 2012, 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 __INST_H__
25#define __INST_H__
26
27#include <act/expr.h>
28#include <act/basetype.h>
29
37class Scope;
38class Type;
39class Array;
40class AExpr;
41class InstType;
42
52struct inst_param {
53 unsigned int isatype:1;
54 union {
65 } u;
66};
67
68
92class InstType {
93 public:
94
104 InstType (Scope *_s, Type *_t, int is_temp = 1);
105
115 InstType (InstType *i, int skip_array = 0);
116
122
129 void MkArray (Array *a);
130
134 Array *arrayInfo () { return a; }
135
139 void clrArray () { a = NULL; }
140
162 int isEqual (InstType *t, int weak = 0);
163
168 int isEqualDir (InstType *t, int weak = 0);
169
170
171 Type *isConnectable (InstType *t, int weak = 0);
177 void Print (FILE *fp, int nl_mode = 0);
179 void sPrint (char *buf, int sz, int nl_mode = 0);
181 Type *BaseType () const { return t; }
187 void setNumParams (int n);
188
195 void appendParams (int na, inst_param *a);
196
204 void setParam (int pn, AExpr *a);
205
213 void setParam (int pn, Expr *e);
214
222 void setParam (int pn, InstType *t);
223
230
237
241 int getNumParams() { return nt; }
242
246 inst_param *allParams() { return u; }
247
252 void SetDir (Type::direction d) { dir = d; }
253
258
262 void MkCached () { temp_type = 0; }
263
267 int isTemp() { return temp_type; }
268
269 void *operator new (size_t count ) { return malloc (count); }
270 void operator delete (void *ptr) { InstType *t = (InstType *)ptr; if (t->temp_type == 0) return; free (ptr); }
271
281
286 int isExpanded() const;
287
291 int israwExpanded() const { return expanded; }
292
296 void mkExpanded() { expanded = 1; }
297
302
307 UserDef *getUserDef () { return s->getUserDef(); }
308
312 int isParamAType (int k);
313
323 Type *isRelated (InstType *it, InstType **common = NULL);
324
329 int hasinstGlobal() { return 0; }
330
339
348
358 void setPTypeID (char *s) { ptype_id = string_cache (s); }
359
363 const char *getPTypeID () { return ptype_id; }
364
370
375
376 private:
377
378
386
391
392 /* the following are optional */
394 int nt;
397 unsigned int temp_type:1;
399 unsigned int expanded:1;
401 const char *ptype_id;
406 friend class TypeFactory;
407};
408
409
410#endif /* __INST_H__ */
Array expressions.
Definition: act_array.h:529
The ActNamespace class holds all the information about a namespace.
Definition: namespaces.h:469
Dense arrays, sparse arrays, and array dereferences.
Definition: act_array.h:65
An instance type.
Definition: inst.h:92
const char * ptype_id
Definition: inst.h:401
ActNamespace * getNamespace()
Definition: inst.h:301
void setParam(int pn, InstType *t)
void clrArray()
Definition: inst.h:139
int hasinstGlobal()
Definition: inst.h:329
int isEqualDir(InstType *t, int weak=0)
AExpr * getAExprParam(int pn)
int israwExpanded() const
Definition: inst.h:291
Type * isConnectable(InstType *t, int weak=0)
void appendParams(int na, inst_param *a)
inst_param * u
Definition: inst.h:395
InstType(InstType *i, int skip_array=0)
InstType * getTypeParam(int pn)
void sPrint(char *buf, int sz, int nl_mode=0)
void Print(FILE *fp, int nl_mode=0)
void setParam(int pn, AExpr *a)
InstType(Scope *_s, Type *_t, int is_temp=1)
InstType * refineBaseType(Type *update)
void MkArray(Array *a)
unsigned int expanded
Definition: inst.h:399
int nt
Definition: inst.h:394
void mkExpanded()
Definition: inst.h:296
Array * a
Definition: inst.h:393
void setIfaceType(InstType *x)
Definition: inst.h:369
InstType * refineBaseType(InstType *update)
int isTemp()
Definition: inst.h:267
InstType * iface_type
Definition: inst.h:403
void MkCached()
Definition: inst.h:262
int isExpanded() const
Array * arrayInfo()
Definition: inst.h:134
InstType * Expand(ActNamespace *ns, Scope *s)
const char * getPTypeID()
Definition: inst.h:363
void setNumParams(int n)
void SetDir(Type::direction d)
Definition: inst.h:252
int isParamAType(int k)
int getNumParams()
Definition: inst.h:241
Type * t
Definition: inst.h:379
Type * BaseType() const
Definition: inst.h:181
unsigned int temp_type
Definition: inst.h:397
Type * isRelated(InstType *it, InstType **common=NULL)
InstType * getIfaceType()
Definition: inst.h:374
inst_param * allParams()
Definition: inst.h:246
void setParam(int pn, Expr *e)
void setPTypeID(char *s)
Definition: inst.h:358
Type::direction dir
Definition: inst.h:385
Type::direction getDir()
Definition: inst.h:257
UserDef * getUserDef()
Definition: inst.h:307
int isEqual(InstType *t, int weak=0)
Scope * s
Definition: inst.h:390
This is the data structure that holds all instances and their associated types within a scope....
Definition: namespaces.h:77
ActNamespace * getNamespace()
Definition: namespaces.h:248
UserDef * getUserDef()
Definition: namespaces.h:236
This is the class used to create all instance types. It also caches types to reduce memory usage.
Definition: types.h:1415
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
Definition: expr.h:79
This holds a single template parameter. A template parameter is either an array expression,...
Definition: inst.h:52
unsigned int isatype
Definition: inst.h:53
union inst_param::@17 u
InstType * tt
Definition: inst.h:61
AExpr * tp
Definition: inst.h:55