ACT Library
|
Typechecking identifiers and expression. More...
Go to the source code of this file.
Macros | |
#define | T_ERR -1 |
#define | T_ARRAYOF 0x20 |
array flag | |
#define | T_STRICT 0x40 |
#define | T_PARAM 0x80 |
a parameter type flag for pint/... etc | |
#define | T_INT 0x1 |
an integer (data or parameter type) | |
#define | T_REAL 0x2 |
a real number | |
#define | T_BOOL 0x4 |
a Boolean (data or parameter) | |
#define | T_PROC 0x5 |
a process | |
#define | T_CHAN 0x6 |
a channel | |
#define | T_DATA_INT 0x7 |
an integer within a channel | |
#define | T_DATA_BOOL 0x8 |
a bool within a channel | |
#define | T_SELF 0x9 |
special type, "self" | |
#define | T_DATA 0xa |
a structure | |
#define | T_DATA_ENUM 0xb |
an enum that is not an int | |
#define | T_PTYPE 0x10 |
used when the expression is a type | |
#define | T_MASK 0x1f |
mask for the list of options | |
#define | T_FIXBASETYPE(x) ((((x) & T_MASK) == T_DATA_BOOL) ? T_BOOL : ((((x) & T_MASK) == T_DATA_INT) ? T_INT : ((x) & T_MASK))) |
#define | T_BASETYPE(x) ((x) & T_MASK) |
#define | T_BASETYPE_ISNUM(x) (T_FIXBASETYPE (x) == T_INT || T_BASETYPE (x) == T_REAL) |
#define | T_BASETYPE_INT(x) (T_FIXBASETYPE(x) == T_INT) |
#define | T_BASETYPE_BOOL(x) (T_FIXBASETYPE(x) == T_BOOL) |
#define | T_BASETYPE_ISINTBOOL(x) (T_BASETYPE_INT(x) || T_BASETYPE_BOOL(x)) |
Functions | |
int | act_type_expr (Scope *s, Expr *e, int *width, int only_chan=0) |
int | act_type_var (Scope *s, ActId *id, InstType **xit) |
int | act_type_chan (Scope *sc, Chan *ch, int is_send, Expr *e, ActId *id, int override_id) |
int | act_type_conn (Scope *, ActId *, AExpr *) |
int | act_type_conn (Scope *, AExpr *, AExpr *) |
int | type_connectivity_check (InstType *lhs, InstType *rhs, int skip_last_array=0) |
int | type_chp_check_assignable (InstType *lhs, InstType *rhs) |
InstType * | act_expr_insttype (Scope *s, Expr *e, int *islocal, int only_chan) |
InstType * | act_actual_insttype (Scope *s, ActId *id, int *islocal) |
void | type_set_position (int l, int c, char *n) |
const char * | act_type_errmsg (void) |
void | typecheck_err (const char *s,...) |
Typechecking identifiers and expression.
The typechecking functions return an integer code. This code is T_ERR on an error, or a flag that is used to summarize the type of the result.
The function act_type_errmsg() can be used to get a string that corresponds to a more verbose message corresponding to the last error that was encountered during type-checking.
#define T_ARRAYOF 0x20 |
array flag
#define T_BASETYPE | ( | x | ) | ((x) & T_MASK) |
Used to extract the type case minus any flags (the "base type")
#define T_BASETYPE_BOOL | ( | x | ) | (T_FIXBASETYPE(x) == T_BOOL) |
Check if the processed base type is a bool
#define T_BASETYPE_INT | ( | x | ) | (T_FIXBASETYPE(x) == T_INT) |
Check if the processed base type is an int
#define T_BASETYPE_ISINTBOOL | ( | x | ) | (T_BASETYPE_INT(x) || T_BASETYPE_BOOL(x)) |
Check if the processed base type is an integer or a boolean. This means it could be a chan(bool) or a chan(int) as well.
#define T_BASETYPE_ISNUM | ( | x | ) | (T_FIXBASETYPE (x) == T_INT || T_BASETYPE (x) == T_REAL) |
Check if the base type is an integer or real number, i.e. a numeric value
#define T_BOOL 0x4 |
a Boolean (data or parameter)
#define T_CHAN 0x6 |
a channel
#define T_DATA 0xa |
a structure
#define T_DATA_BOOL 0x8 |
a bool within a channel
#define T_DATA_ENUM 0xb |
an enum that is not an int
#define T_DATA_INT 0x7 |
an integer within a channel
#define T_ERR -1 |
return if the checking function returns an error
#define T_FIXBASETYPE | ( | x | ) | ((((x) & T_MASK) == T_DATA_BOOL) ? T_BOOL : ((((x) & T_MASK) == T_DATA_INT) ? T_INT : ((x) & T_MASK))) |
Used to process return types by converting T_DATA_BOOL to T_BOOL, and T_DATA_INT to T_INT.
#define T_INT 0x1 |
an integer (data or parameter type)
#define T_MASK 0x1f |
mask for the list of options
#define T_PARAM 0x80 |
a parameter type flag for pint/... etc
#define T_PROC 0x5 |
a process
#define T_PTYPE 0x10 |
used when the expression is a type
#define T_REAL 0x2 |
a real number
#define T_SELF 0x9 |
special type, "self"
#define T_STRICT 0x40 |
a port parameter flag that is in the "strict" list... i.e. not optional, i.e. before the vertical bar (NOT USED)
Returns the actual type of the identifier.
s | is the scope |
id | is the identifier |
islocal | is used to return 1 if the identifier is only accessible within the local scope specified, 0 otherwise |
Returns the actual type of the expression. only_chan is the same flag as act_type_expr(), and can be 0, 1, 2, or 3.
s | is the scope |
e | is the expression |
islocal | is used to return 1 if all identifiers within this expression are local to the scope and cannot be accessed from outside the scope, 0 otherwise |
only_chan | is the same as the only_chan flag for act_type_expr() |
Used to type-check a channel operation. The channel operation is of one of the following forms: ch!e ch?v ch!e?v ch?v!e
An identifier could also be of the form bool(v) or int(v), which is used to implicitly convert the identifier type from int to bool or bool to int. The override_id flag is used for this purpose.
sc | is the scope in which the type-checking is performed |
ch | is the channel type |
is_send | is 1 for a send operation, 0 for a receive operation |
e | is the (optional) expression being sent |
id | is the (optional) identifer for the receive operation |
override_id | is -1 if int/bool overrides are absent, 0 for bool(.), and 1 for int(.) |
Used to type-check a connection between an identifier and an array expression
Used to type-check a connection between two array expressions
const char * act_type_errmsg | ( | void | ) |
Used to return the type-checking error message
Typecheck an expression, and return the result type if the type-checking succeeds.
The only_chan flag is used to set the mode of the check.
s | is the scope in which the type-checking is performed |
e | is the expression |
width | if non-NULL, this is used to return the bit-width of the result |
only_chan | is a flag that determines valid identifiers. |
Used to type-check a variable
s | is the scope in which to peform the type-checking |
id | is the variable to be checked |
xit | is used to return the actual InstType * for the identifier, if xit is non-NULL |
This checks if a value with a type corresponding to the rhs can be assigned to one on the lhs in a CHP program
lhs | is the left-hand side type: the type of the id |
rhs | is the right-hand side type: the type of the expression |
Used to check if two types can be connected to each other. If a type is an array type, then for unexpanded types this only checks that the number of dimensions are equal. For expanded types, it checks that the dimension sizes also match.
If skip_last_array is set to 1, this will skip checking the size of the first dimension.
Return values:
lhs | is the first type to check |
rhs | is the second type to check |
skip_last_array | is used to omit the first dimension check |
void type_set_position | ( | int | l, |
int | c, | ||
char * | n | ||
) |
Used to record the line, column, and file for error reporting
l | is the line number |
c | is the column number |
n | is the file name |
void typecheck_err | ( | const char * | s, |
... | |||
) |
Use this to set the type-checking error message that is later returned by act_type_errmsg()
s | is the printf-style format string |