#ifndef NOPP
int ReplaceMacros = 1; /* replacing macros */
-int PreProcKeys = 0; /* return preprocessor key */
int AccDefined = 0; /* accept "defined(...)" */
int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */
int Unstacked = 0; /* an unstack is done */
#ifndef NOPP
extern int ReplaceMacros; /* "LLlex.c" */
-extern int PreProcKeys; /* "LLlex.c" */
extern int AccDefined; /* "LLlex.c" */
extern int Unstacked; /* "LLlex.c" */
extern int UnknownIdIsZero; /* "LLlex.c" */
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
+#ifndef lint
static char Version[] = "ACK CEM compiler Version 3.1";
+#endif lint
extern char *symbol2str();
extern char options[];
-int
arithbalance(e1p, oper, e2p) /* RM 6.6 */
register struct expr **e1p, **e2p;
int oper;
/* Now t1 and t2 are either INT or LONG or DOUBLE */
#ifndef NOFLOAT
- if (t1 == DOUBLE && t2 != DOUBLE)
- t2 = int2float(e2p, double_type);
- else
- if (t2 == DOUBLE && t1 != DOUBLE)
- t1 = int2float(e1p, double_type);
- else
- if (t1 == DOUBLE)
- return DOUBLE;
+ if (t1 == DOUBLE) {
+ if (t2 != DOUBLE)
+ int2float(e2p, double_type);
+ return;
+ }
+ if (t2 == DOUBLE) {
+ if (t1 != DOUBLE)
+ int2float(e1p, double_type);
+ return;
+ }
#endif NOFLOAT
/* Now they are INT or LONG */
else
if (!u1 && u2)
t1 = int2int(e1p, (t2 == LONG) ? ulong_type : uint_type);
-
- return t1;
}
relbalance(e1p, oper, e2p)
}
#ifndef NOFLOAT
-int
int2float(expp, tp)
register struct expr **expp;
struct type *tp;
fp_used = 1;
*expp = arith2arith(tp, INT2FLOAT, *expp);
- return (*expp)->ex_type->tp_fund;
}
float2int(expp, tp)
}
}
else { /* not embraced */
- struct value vl;
-
ch7cast(&expr, '=', tp); /* may modify expr */
- EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL);
- vl.vl_class = Name;
- vl.vl_data.vl_idf = id;
- vl.vl_value = (arith)0;
- store_val(&vl, tp);
+ {
+ struct value vl;
+
+ EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL);
+ vl.vl_class = Name;
+ vl.vl_data.vl_idf = id;
+ vl.vl_value = (arith)0;
+ store_val(&vl, tp);
+ }
free_expression(expr);
}
}
/* conversion() generates the EM code for a conversion between
the types char, short, int, long, float, double and pointer.
- In case of integral type, the notion signed / unsigned is
- taken into account.
+ There are three conversion types: signed, unsigned and floating.
The EM code to obtain this conversion looks like:
LOC sizeof(from_type)
LOC sizeof(to_type)
C??
*/
+static int convtype();
+
conversion(from_type, to_type)
register struct type *from_type, *to_type;
{
register arith from_size = from_type->tp_size;
register arith to_size = to_type->tp_size;
- int from_fund = fundamental(from_type);
- int to_fund = fundamental(to_type);
+ int from_cnvtype = convtype(from_type);
+ int to_cnvtype = convtype(to_type);
if ((int)to_size < (int)word_size) to_size = word_size;
- if ((int)from_size == (int)to_size && from_fund == to_fund)
+ if ((int)from_size == (int)to_size && from_cnvtype == to_cnvtype)
return;
- switch (from_fund) {
+ switch (from_cnvtype) {
case T_SIGNED:
- switch (to_fund) {
+ switch (to_cnvtype) {
case T_SIGNED:
C_loc(from_size);
C_loc(to_size);
}
C_loc(from_size);
C_loc(to_size);
- if (to_fund == T_UNSIGNED) C_ciu();
+ if (to_cnvtype == T_UNSIGNED) C_ciu();
else C_cif();
break;
}
if ((int)from_size < (int)word_size) from_size = word_size;
C_loc(from_size);
C_loc(to_size);
- switch (to_fund) {
+ switch (to_cnvtype) {
case T_SIGNED:
C_cui();
break;
case T_FLOATING:
C_loc(from_size);
C_loc(to_size);
- switch (to_fund) {
+ switch (to_cnvtype) {
case T_SIGNED:
C_cfi();
break;
}
if ((int)(to_type->tp_size) < (int)word_size
#ifndef NOFLOAT
- && to_fund != T_FLOATING
+ && to_cnvtype != T_FLOATING
#endif NOFLOAT
) {
extern long full_mask[];
- if (to_fund == T_SIGNED) {
+ if (to_cnvtype == T_SIGNED) {
C_loc(to_type->tp_size);
C_loc(word_size);
C_cii();
}
}
-/* fundamental() returns in which category a given type falls:
+/* convtype() returns in which category a given type falls:
signed, unsigned or floating
*/
-int
-fundamental(tp)/* bad name ???*/
+static int
+convtype(tp)/* bad name ???*/
register struct type *tp;
{
switch (tp->tp_fund) {
case DOUBLE:
return T_FLOATING;
#endif NOFLOAT
- case POINTER: /* pointer : signed / unsigned ??? */
- return T_SIGNED;
+ case POINTER:
+ return T_UNSIGNED;
}
return 0;
}
struct formal *dc_formal; /* params for function */
};
-/* ALLOCDEF "declarator" 50 */
-
-
struct formal { /* list of formals */
struct formal *next;
struct idf *fm_idf;
if (level == L_FORMAL2) {
if (ds->ds_sc_given &&
ds->ds_sc != REGISTER){
- extern char *symbol2str();
error("%s formal illegal", symbol2str(ds->ds_sc));
ds->ds_sc = FORMAL;
}
int ds_unsigned; /* 0 or 1 */
};
-/* ALLOCDEF "decspecs" 50 */
-
extern struct decspecs null_decspecs;
p1_expr(lvl, expr)
register struct expr *expr;
{
- extern char *type2str(), *symbol2str();
-
p1_indent(lvl);
if (!expr) {
print("NILEXPR\n");
;
initial_value_pack(struct type **tpp; struct expr **expp;)
- { static int level; }
+ { static int pack_level; }
:
'{'
- { if (level == 0) gen_error = 0; level++; }
+ { if (pack_level == 0) gen_error = 0; pack_level++; }
initial_value_list(tpp, expp)
- { level--;
- if (! level) {
+ { pack_level--;
+ if (!pack_level) {
while (p_stack) {
struct e_stack *p = p_stack->next;
#endif NOPP
#endif DEBUG
-No_Mem()
+No_Mem() /* called by alloc package */
{
fatal("out of memory");
}
-C_failed()
+C_failed() /* called by EM_code module */
{
fatal("write failed");
}
+
/* 10.1 */
function(struct declarator *dc;)
{
- arith fbytes, nbytes;
+ arith fbytes;
}
:
{ register struct idf *idf = dc->dc_idf;
}
PRIVATE
-copyact(ch1, ch2, level)
+copyact(ch1, ch2, lvl)
char ch1, ch2;
- int level;
+ int lvl;
{
/* copyact() is taken from Ceriel Jacobs' LLgen, with
permission. Its task is to build a list of actuals
which the parameters are separated by ',' if there are
more than 1. The balancing of '(',')' and '[',']' and
'{','}' is taken care of by calling this function
- recursively. At each level, copyact() reads the input,
+ recursively. At each level lvl, copyact() reads the input,
upto the corresponding closing bracket.
Opening bracket is ch1, closing bracket is ch2. If
- level != 0, copy opening and closing parameters too.
+ lvl != 0, copy opening and closing parameters too.
*/
register int ch; /* Current char */
register int match; /* used to read strings */
- if (level) {
+ if (lvl) {
copy(ch1);
}
LoadChar(ch);
if (ch == ch2) {
- if (level) {
+ if (lvl) {
copy(ch);
}
return;
#endif __MATCHING_PAR__
case '(':
- copyact('(', ')', level+1);
+ copyact('(', ')', lvl+1);
break;
#ifdef __MATCHING_PAR__
#define declare(v, t) t v
declare(v, union{int i, j; float r;});
*/
- copyact('{', '}', level+1);
+ copyact('{', '}', lvl+1);
break;
case '[':
- copyact('[', ']', level+1);
+ copyact('[', ']', lvl+1);
break;
#endif __MATCHING_PAR__
break;
case ',':
- if (!level) {
+ if (!lvl) {
/* next parameter encountered */
copy(EOS);
}
struct type *
-standard_type(fund, sign, align, size)
- int align; arith size;
+standard_type(fund, sign, algn, size)
+ int algn; arith size;
{
register struct type *tp = create_type(fund);
tp->tp_unsigned = sign;
- tp->tp_align = align;
+ tp->tp_align = algn;
tp->tp_size = size;
return tp;