extern char *symbol2str();
int
-chk_variable(expp)
+ChkVariable(expp)
register struct node *expp;
{
- if (! chk_designator(expp)) return 0;
+ if (! ChkDesignator(expp)) return 0;
if (expp->nd_class == Def &&
!(expp->nd_def->df_kind & (D_FIELD|D_VARIABLE))) {
}
STATIC int
-chk_arrow(expp)
+ChkArrow(expp)
register struct node *expp;
{
register struct type *tp;
expp->nd_type = error_type;
- if (! chk_variable(expp->nd_right)) return 0;
+ if (! ChkVariable(expp->nd_right)) return 0;
tp = expp->nd_right->nd_type;
}
STATIC int
-chk_arr(expp)
+ChkArr(expp)
register struct node *expp;
{
register struct type *tpl, *tpr;
expp->nd_type = error_type;
if (
- !chk_variable(expp->nd_left)
+ !ChkVariable(expp->nd_left)
||
- !chk_expr(expp->nd_right)
+ !ChkExpression(expp->nd_right)
||
expp->nd_left->nd_type == error_type
) return 0;
}
STATIC int
-chk_value(expp)
+ChkValue(expp)
struct node *expp;
{
switch(expp->nd_symb) {
return 1;
default:
- crash("(chk_value)");
+ crash("(ChkValue)");
}
/*NOTREACHED*/
}
STATIC int
-chk_linkorname(expp)
+ChkLinkOrName(expp)
register struct node *expp;
{
register struct def *df;
assert(expp->nd_symb == '.');
- if (! chk_designator(left)) return 0;
+ if (! ChkDesignator(left)) return 0;
if (left->nd_type->tp_fund != T_RECORD ||
(left->nd_class == Def &&
}
STATIC int
-chk_ex_linkorname(expp)
+ChkExLinkOrName(expp)
register struct node *expp;
{
register struct def *df;
- if (! chk_linkorname(expp)) return 0;
+ if (! ChkLinkOrName(expp)) return 0;
if (expp->nd_class != Def) return 1;
df = expp->nd_def;
RemoveSet(set)
arith **set;
{
- /* This routine is only used for error exits of chk_el.
+ /* This routine is only used for error exits of ChkElement.
It frees the set indicated by "set", and returns 0.
*/
if (*set) {
}
STATIC int
-chk_el(expp, tp, set)
+ChkElement(expp, tp, set)
register struct node *expp;
register struct type *tp;
arith **set;
/* { ... , expr1 .. expr2, ... }
First check expr1 and expr2, and try to compute them.
*/
- if (!chk_el(left, tp, set) || !chk_el(right, tp, set)) {
+ if (!ChkElement(left, tp, set) || !ChkElement(right, tp, set)) {
return 0;
}
/* Here, a single element is checked
*/
- if (!chk_expr(expp)) {
+ if (!ChkExpression(expp)) {
return RemoveSet(set);
}
}
STATIC int
-chk_set(expp)
+ChkSet(expp)
register struct node *expp;
{
/* Check the legality of a SET aggregate, and try to evaluate it
if (nd = expp->nd_left) {
/* A type was given. Check it out
*/
- if (! chk_designator(nd)) return 0;
+ if (! ChkDesignator(nd)) return 0;
assert(nd->nd_class == Def);
df = nd->nd_def;
while (nd) {
assert(nd->nd_class == Link && nd->nd_symb == ',');
- if (!chk_el(nd->nd_left, ElementType(tp), &set)) return 0;
+ if (!ChkElement(nd->nd_left, ElementType(tp), &set)) return 0;
nd = nd->nd_right;
}
arg = arg->nd_right;
left = arg->nd_left;
- if ((!designator && !chk_expr(left)) ||
- (designator && !chk_variable(left))) {
+ if ((!designator && !ChkExpression(left)) ||
+ (designator && !ChkVariable(left))) {
return 0;
}
}
arg = arg->nd_right;
- if (! chk_designator(arg->nd_left)) return 0;
+ if (! ChkDesignator(arg->nd_left)) return 0;
if (arg->nd_left->nd_class != Def && arg->nd_left->nd_class != LinkDef) {
node_error(arg, "identifier expected");
}
STATIC int
-chk_proccall(expp)
+ChkProcCall(expp)
register struct node *expp;
{
/* Check a procedure call
}
int
-chk_call(expp)
+ChkCall(expp)
register struct node *expp;
{
/* Check something that looks like a procedure or function call.
it may also be a cast or a standard procedure call.
*/
register struct node *left;
- STATIC int chk_std();
- STATIC int chk_cast();
+ STATIC int ChkStandard();
+ STATIC int ChkCast();
/* First, get the name of the function or procedure
*/
expp->nd_type = error_type;
left = expp->nd_left;
- if (! chk_designator(left)) return 0;
+ if (! ChkDesignator(left)) return 0;
if (IsCast(left)) {
/* It was a type cast. This is of course not portable.
*/
- return chk_cast(expp, left);
+ return ChkCast(expp, left);
}
if (IsProcCall(left)) {
if (left->nd_type == std_type) {
/* A standard procedure
*/
- return chk_std(expp, left);
+ return ChkStandard(expp, left);
}
/* Here, we have found a real procedure call. The left hand
side may also represent a procedure variable.
*/
- return chk_proccall(expp);
+ return ChkProcCall(expp);
}
node_error(left, "procedure, type, or function expected");
}
STATIC int
-chk_address(tpl, tpr)
+ChkAddress(tpl, tpr)
register struct type *tpl, *tpr;
{
}
STATIC int
-chk_oper(expp)
+ChkBinOper(expp)
register struct node *expp;
{
/* Check a binary operation.
left = expp->nd_left;
right = expp->nd_right;
- if (!chk_expr(left) || !chk_expr(right)) return 0;
+ if (!ChkExpression(left) || !ChkExpression(right)) return 0;
tpl = BaseType(left->nd_type);
tpr = BaseType(right->nd_type);
(tpl != bool_type && Boolean(expp->nd_symb))) {
if (!(tpl->tp_fund == T_POINTER &&
(T_CARDINAL & allowed) &&
- chk_address(tpl, tpr))) {
+ ChkAddress(tpl, tpr))) {
node_error(expp,"operator \"%s\": illegal operand type(s)", symbol2str(expp->nd_symb));
return 0;
}
+ expp->nd_type = card_type;
}
if (tpl->tp_fund == T_SET) {
}
STATIC int
-chk_uoper(expp)
+ChkUnOper(expp)
register struct node *expp;
{
/* Check an unary operation.
register struct node *right = expp->nd_right;
register struct type *tpr;
- if (! chk_expr(right)) return 0;
+ if (! ChkExpression(right)) return 0;
tpr = BaseType(right->nd_type);
+ if (tpr == address_type) tpr = card_type;
expp->nd_type = tpr;
switch(expp->nd_symb) {
break;
default:
- crash("chk_uoper");
+ crash("ChkUnOper");
}
node_error(expp, "illegal operand for unary operator \"%s\"",
symbol2str(expp->nd_symb));
return 0;
}
- if (! chk_variable(arg->nd_left)) return 0;
+ if (! ChkVariable(arg->nd_left)) return 0;
*argp = arg;
return arg->nd_left;
}
STATIC int
-chk_std(expp, left)
+ChkStandard(expp, left)
register struct node *expp, *left;
{
/* Check a call of a standard procedure or function
"ALLOCATE" : "DEALLOCATE", 0);
expp->nd_left = MkLeaf(Name, &dt);
}
- return chk_call(expp);
+ return ChkCall(expp);
case S_TSIZE: /* ??? */
case S_SIZE:
}
default:
- crash("(chk_std)");
+ crash("(ChkStandard)");
}
if (arg->nd_right) {
}
STATIC int
-chk_cast(expp, left)
+ChkCast(expp, left)
register struct node *expp, *left;
{
/* Check a cast and perform it if the argument is constant.
}
arg = arg->nd_left;
- if (! chk_expr(arg)) return 0;
+ if (! ChkExpression(arg)) return 0;
if (arg->nd_type->tp_size != left->nd_type->tp_size &&
(arg->nd_type->tp_size > word_size ||
extern int NodeCrash();
int (*ExprChkTable[])() = {
- chk_value,
- chk_arr,
- chk_oper,
- chk_uoper,
- chk_arrow,
- chk_call,
- chk_ex_linkorname,
+ ChkValue,
+ ChkArr,
+ ChkBinOper,
+ ChkUnOper,
+ ChkArrow,
+ ChkCall,
+ ChkExLinkOrName,
NodeCrash,
- chk_set,
+ ChkSet,
NodeCrash,
NodeCrash,
- chk_ex_linkorname,
+ ChkExLinkOrName,
NodeCrash
};
int (*DesigChkTable[])() = {
- chk_value,
- chk_arr,
+ ChkValue,
+ ChkArr,
no_desig,
no_desig,
- chk_arrow,
+ ChkArrow,
no_desig,
- chk_linkorname,
+ ChkLinkOrName,
NodeCrash,
no_desig,
done_before,
NodeCrash,
- chk_linkorname,
+ ChkLinkOrName,
done_before
};
assert(nd->nd_class == Call);
if (! options['L']) C_lin((arith) nd->nd_lineno);
- if (chk_call(nd)) {
+ if (ChkCall(nd)) {
if (nd->nd_type != 0) {
node_error(nd, "procedure call expected");
return;
*/
struct desig ds;
- if (!chk_expr(nd)) return;
+ if (!ChkExpression(nd)) return;
if (nd->nd_type != bool_type && nd->nd_type != error_type) {
node_error(nd, "boolean expression expected");
/* Check an expression and generate code for it
*/
- if (! chk_expr(nd)) return;
+ if (! ChkExpression(nd)) return;
CodePExpr(nd);
}
/* Check designator and generate code for it
*/
- if (! chk_variable(nd)) return;
+ if (! ChkVariable(nd)) return;
*ds = InitDesig;
CodeDesig(nd, ds);
nd->nd_class = Name;
nd->nd_symb = IDENT;
- if (! chk_variable(nd) ||
- ! chk_expr(left->nd_left) ||
- ! chk_expr(left->nd_right)) return 0;
+ if (! ChkVariable(nd) ||
+ ! ChkExpression(left->nd_left) ||
+ ! ChkExpression(left->nd_right)) return 0;
df = nd->nd_def;
if (df->df_kind == D_FIELD) {
}
}
- if (nd->nd_type->tp_size > word_size ||
- !(nd->nd_type->tp_fund & T_DISCRETE)) {
+ if (df->df_type->tp_size > word_size ||
+ !(df->df_type->tp_fund & T_DISCRETE)) {
node_error(nd, "illegal type of FOR loop variable");
return 0;
}
- if (!TstCompat(nd->nd_type, left->nd_left->nd_type) ||
- !TstCompat(nd->nd_type, left->nd_right->nd_type)) {
- if (!TstAssCompat(nd->nd_type, left->nd_left->nd_type) ||
- !TstAssCompat(nd->nd_type, left->nd_right->nd_type)) {
+ if (!TstCompat(df->df_type, left->nd_left->nd_type) ||
+ !TstCompat(df->df_type, left->nd_right->nd_type)) {
+ if (!TstAssCompat(df->df_type, left->nd_left->nd_type) ||
+ !TstAssCompat(df->df_type, left->nd_right->nd_type)) {
node_error(nd, "type incompatibility in FOR statement");
return 0;
}
/* May we do it in this order (expression first) ??? */
struct desig dsl, dsr;
- if (!chk_expr(right)) return;
- if (! chk_variable(left)) return;
+ if (!ChkExpression(right)) return;
+ if (! ChkVariable(left)) return;
TryToString(right, left->nd_type);
dsr = InitDesig;
CodeExpr(right, &dsr, NO_LABEL, NO_LABEL);