more modifications due to lint
This commit is contained in:
parent
cc52343fbf
commit
61b8c3e9ec
15 changed files with 60 additions and 67 deletions
|
@ -27,7 +27,6 @@ struct token dot, ahead, aside;
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
int ReplaceMacros = 1; /* replacing macros */
|
int ReplaceMacros = 1; /* replacing macros */
|
||||||
int PreProcKeys = 0; /* return preprocessor key */
|
|
||||||
int AccDefined = 0; /* accept "defined(...)" */
|
int AccDefined = 0; /* accept "defined(...)" */
|
||||||
int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */
|
int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */
|
||||||
int Unstacked = 0; /* an unstack is done */
|
int Unstacked = 0; /* an unstack is done */
|
||||||
|
|
|
@ -51,7 +51,6 @@ extern struct token dot, ahead, aside;
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
extern int ReplaceMacros; /* "LLlex.c" */
|
extern int ReplaceMacros; /* "LLlex.c" */
|
||||||
extern int PreProcKeys; /* "LLlex.c" */
|
|
||||||
extern int AccDefined; /* "LLlex.c" */
|
extern int AccDefined; /* "LLlex.c" */
|
||||||
extern int Unstacked; /* "LLlex.c" */
|
extern int Unstacked; /* "LLlex.c" */
|
||||||
extern int UnknownIdIsZero; /* "LLlex.c" */
|
extern int UnknownIdIsZero; /* "LLlex.c" */
|
||||||
|
|
|
@ -3,4 +3,6 @@
|
||||||
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
*/
|
*/
|
||||||
|
#ifndef lint
|
||||||
static char Version[] = "ACK CEM compiler Version 3.1";
|
static char Version[] = "ACK CEM compiler Version 3.1";
|
||||||
|
#endif lint
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
extern char *symbol2str();
|
extern char *symbol2str();
|
||||||
extern char options[];
|
extern char options[];
|
||||||
|
|
||||||
int
|
|
||||||
arithbalance(e1p, oper, e2p) /* RM 6.6 */
|
arithbalance(e1p, oper, e2p) /* RM 6.6 */
|
||||||
register struct expr **e1p, **e2p;
|
register struct expr **e1p, **e2p;
|
||||||
int oper;
|
int oper;
|
||||||
|
@ -43,14 +42,16 @@ arithbalance(e1p, oper, e2p) /* RM 6.6 */
|
||||||
|
|
||||||
/* Now t1 and t2 are either INT or LONG or DOUBLE */
|
/* Now t1 and t2 are either INT or LONG or DOUBLE */
|
||||||
#ifndef NOFLOAT
|
#ifndef NOFLOAT
|
||||||
if (t1 == DOUBLE && t2 != DOUBLE)
|
if (t1 == DOUBLE) {
|
||||||
t2 = int2float(e2p, double_type);
|
if (t2 != DOUBLE)
|
||||||
else
|
int2float(e2p, double_type);
|
||||||
if (t2 == DOUBLE && t1 != DOUBLE)
|
return;
|
||||||
t1 = int2float(e1p, double_type);
|
}
|
||||||
else
|
if (t2 == DOUBLE) {
|
||||||
if (t1 == DOUBLE)
|
if (t1 != DOUBLE)
|
||||||
return DOUBLE;
|
int2float(e1p, double_type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif NOFLOAT
|
#endif NOFLOAT
|
||||||
|
|
||||||
/* Now they are INT or LONG */
|
/* Now they are INT or LONG */
|
||||||
|
@ -70,8 +71,6 @@ arithbalance(e1p, oper, e2p) /* RM 6.6 */
|
||||||
else
|
else
|
||||||
if (!u1 && u2)
|
if (!u1 && u2)
|
||||||
t1 = int2int(e1p, (t2 == LONG) ? ulong_type : uint_type);
|
t1 = int2int(e1p, (t2 == LONG) ? ulong_type : uint_type);
|
||||||
|
|
||||||
return t1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
relbalance(e1p, oper, e2p)
|
relbalance(e1p, oper, e2p)
|
||||||
|
@ -262,7 +261,6 @@ int2int(expp, tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NOFLOAT
|
#ifndef NOFLOAT
|
||||||
int
|
|
||||||
int2float(expp, tp)
|
int2float(expp, tp)
|
||||||
register struct expr **expp;
|
register struct expr **expp;
|
||||||
struct type *tp;
|
struct type *tp;
|
||||||
|
@ -273,7 +271,6 @@ int2float(expp, tp)
|
||||||
|
|
||||||
fp_used = 1;
|
fp_used = 1;
|
||||||
*expp = arith2arith(tp, INT2FLOAT, *expp);
|
*expp = arith2arith(tp, INT2FLOAT, *expp);
|
||||||
return (*expp)->ex_type->tp_fund;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float2int(expp, tp)
|
float2int(expp, tp)
|
||||||
|
|
|
@ -460,14 +460,16 @@ loc_init(expr, id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* not embraced */
|
else { /* not embraced */
|
||||||
struct value vl;
|
|
||||||
|
|
||||||
ch7cast(&expr, '=', tp); /* may modify expr */
|
ch7cast(&expr, '=', tp); /* may modify expr */
|
||||||
EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
{
|
||||||
vl.vl_class = Name;
|
struct value vl;
|
||||||
vl.vl_data.vl_idf = id;
|
|
||||||
vl.vl_value = (arith)0;
|
EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
store_val(&vl, tp);
|
vl.vl_class = Name;
|
||||||
|
vl.vl_data.vl_idf = id;
|
||||||
|
vl.vl_value = (arith)0;
|
||||||
|
store_val(&vl, tp);
|
||||||
|
}
|
||||||
free_expression(expr);
|
free_expression(expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,28 +20,29 @@
|
||||||
|
|
||||||
/* conversion() generates the EM code for a conversion between
|
/* conversion() generates the EM code for a conversion between
|
||||||
the types char, short, int, long, float, double and pointer.
|
the types char, short, int, long, float, double and pointer.
|
||||||
In case of integral type, the notion signed / unsigned is
|
There are three conversion types: signed, unsigned and floating.
|
||||||
taken into account.
|
|
||||||
The EM code to obtain this conversion looks like:
|
The EM code to obtain this conversion looks like:
|
||||||
LOC sizeof(from_type)
|
LOC sizeof(from_type)
|
||||||
LOC sizeof(to_type)
|
LOC sizeof(to_type)
|
||||||
C??
|
C??
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static int convtype();
|
||||||
|
|
||||||
conversion(from_type, to_type)
|
conversion(from_type, to_type)
|
||||||
register struct type *from_type, *to_type;
|
register struct type *from_type, *to_type;
|
||||||
{
|
{
|
||||||
register arith from_size = from_type->tp_size;
|
register arith from_size = from_type->tp_size;
|
||||||
register arith to_size = to_type->tp_size;
|
register arith to_size = to_type->tp_size;
|
||||||
int from_fund = fundamental(from_type);
|
int from_cnvtype = convtype(from_type);
|
||||||
int to_fund = fundamental(to_type);
|
int to_cnvtype = convtype(to_type);
|
||||||
|
|
||||||
if ((int)to_size < (int)word_size) to_size = word_size;
|
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;
|
return;
|
||||||
switch (from_fund) {
|
switch (from_cnvtype) {
|
||||||
case T_SIGNED:
|
case T_SIGNED:
|
||||||
switch (to_fund) {
|
switch (to_cnvtype) {
|
||||||
case T_SIGNED:
|
case T_SIGNED:
|
||||||
C_loc(from_size);
|
C_loc(from_size);
|
||||||
C_loc(to_size);
|
C_loc(to_size);
|
||||||
|
@ -59,7 +60,7 @@ conversion(from_type, to_type)
|
||||||
}
|
}
|
||||||
C_loc(from_size);
|
C_loc(from_size);
|
||||||
C_loc(to_size);
|
C_loc(to_size);
|
||||||
if (to_fund == T_UNSIGNED) C_ciu();
|
if (to_cnvtype == T_UNSIGNED) C_ciu();
|
||||||
else C_cif();
|
else C_cif();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,7 @@ conversion(from_type, to_type)
|
||||||
if ((int)from_size < (int)word_size) from_size = word_size;
|
if ((int)from_size < (int)word_size) from_size = word_size;
|
||||||
C_loc(from_size);
|
C_loc(from_size);
|
||||||
C_loc(to_size);
|
C_loc(to_size);
|
||||||
switch (to_fund) {
|
switch (to_cnvtype) {
|
||||||
case T_SIGNED:
|
case T_SIGNED:
|
||||||
C_cui();
|
C_cui();
|
||||||
break;
|
break;
|
||||||
|
@ -86,7 +87,7 @@ conversion(from_type, to_type)
|
||||||
case T_FLOATING:
|
case T_FLOATING:
|
||||||
C_loc(from_size);
|
C_loc(from_size);
|
||||||
C_loc(to_size);
|
C_loc(to_size);
|
||||||
switch (to_fund) {
|
switch (to_cnvtype) {
|
||||||
case T_SIGNED:
|
case T_SIGNED:
|
||||||
C_cfi();
|
C_cfi();
|
||||||
break;
|
break;
|
||||||
|
@ -104,12 +105,12 @@ conversion(from_type, to_type)
|
||||||
}
|
}
|
||||||
if ((int)(to_type->tp_size) < (int)word_size
|
if ((int)(to_type->tp_size) < (int)word_size
|
||||||
#ifndef NOFLOAT
|
#ifndef NOFLOAT
|
||||||
&& to_fund != T_FLOATING
|
&& to_cnvtype != T_FLOATING
|
||||||
#endif NOFLOAT
|
#endif NOFLOAT
|
||||||
) {
|
) {
|
||||||
extern long full_mask[];
|
extern long full_mask[];
|
||||||
|
|
||||||
if (to_fund == T_SIGNED) {
|
if (to_cnvtype == T_SIGNED) {
|
||||||
C_loc(to_type->tp_size);
|
C_loc(to_type->tp_size);
|
||||||
C_loc(word_size);
|
C_loc(word_size);
|
||||||
C_cii();
|
C_cii();
|
||||||
|
@ -121,11 +122,11 @@ conversion(from_type, to_type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fundamental() returns in which category a given type falls:
|
/* convtype() returns in which category a given type falls:
|
||||||
signed, unsigned or floating
|
signed, unsigned or floating
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
fundamental(tp)/* bad name ???*/
|
convtype(tp)/* bad name ???*/
|
||||||
register struct type *tp;
|
register struct type *tp;
|
||||||
{
|
{
|
||||||
switch (tp->tp_fund) {
|
switch (tp->tp_fund) {
|
||||||
|
@ -141,8 +142,8 @@ fundamental(tp)/* bad name ???*/
|
||||||
case DOUBLE:
|
case DOUBLE:
|
||||||
return T_FLOATING;
|
return T_FLOATING;
|
||||||
#endif NOFLOAT
|
#endif NOFLOAT
|
||||||
case POINTER: /* pointer : signed / unsigned ??? */
|
case POINTER:
|
||||||
return T_SIGNED;
|
return T_UNSIGNED;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,6 @@ struct declarator {
|
||||||
struct formal *dc_formal; /* params for function */
|
struct formal *dc_formal; /* params for function */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "declarator" 50 */
|
|
||||||
|
|
||||||
|
|
||||||
struct formal { /* list of formals */
|
struct formal { /* list of formals */
|
||||||
struct formal *next;
|
struct formal *next;
|
||||||
struct idf *fm_idf;
|
struct idf *fm_idf;
|
||||||
|
|
|
@ -42,7 +42,6 @@ do_decspecs(ds)
|
||||||
if (level == L_FORMAL2) {
|
if (level == L_FORMAL2) {
|
||||||
if (ds->ds_sc_given &&
|
if (ds->ds_sc_given &&
|
||||||
ds->ds_sc != REGISTER){
|
ds->ds_sc != REGISTER){
|
||||||
extern char *symbol2str();
|
|
||||||
error("%s formal illegal", symbol2str(ds->ds_sc));
|
error("%s formal illegal", symbol2str(ds->ds_sc));
|
||||||
ds->ds_sc = FORMAL;
|
ds->ds_sc = FORMAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,4 @@ struct decspecs {
|
||||||
int ds_unsigned; /* 0 or 1 */
|
int ds_unsigned; /* 0 or 1 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ALLOCDEF "decspecs" 50 */
|
|
||||||
|
|
||||||
extern struct decspecs null_decspecs;
|
extern struct decspecs null_decspecs;
|
||||||
|
|
|
@ -319,8 +319,6 @@ print_expr(msg, expr)
|
||||||
p1_expr(lvl, expr)
|
p1_expr(lvl, expr)
|
||||||
register struct expr *expr;
|
register struct expr *expr;
|
||||||
{
|
{
|
||||||
extern char *type2str(), *symbol2str();
|
|
||||||
|
|
||||||
p1_indent(lvl);
|
p1_indent(lvl);
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
print("NILEXPR\n");
|
print("NILEXPR\n");
|
||||||
|
|
|
@ -63,13 +63,13 @@ initial_value(register struct type **tpp; register struct expr **expp;) :
|
||||||
;
|
;
|
||||||
|
|
||||||
initial_value_pack(struct type **tpp; struct expr **expp;)
|
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)
|
initial_value_list(tpp, expp)
|
||||||
{ level--;
|
{ pack_level--;
|
||||||
if (! level) {
|
if (!pack_level) {
|
||||||
while (p_stack) {
|
while (p_stack) {
|
||||||
struct e_stack *p = p_stack->next;
|
struct e_stack *p = p_stack->next;
|
||||||
|
|
||||||
|
|
|
@ -371,12 +371,13 @@ preprocess()
|
||||||
#endif NOPP
|
#endif NOPP
|
||||||
#endif DEBUG
|
#endif DEBUG
|
||||||
|
|
||||||
No_Mem()
|
No_Mem() /* called by alloc package */
|
||||||
{
|
{
|
||||||
fatal("out of memory");
|
fatal("out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
C_failed()
|
C_failed() /* called by EM_code module */
|
||||||
{
|
{
|
||||||
fatal("write failed");
|
fatal("write failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ non_function(register struct decspecs *ds; register struct declarator *dc;)
|
||||||
/* 10.1 */
|
/* 10.1 */
|
||||||
function(struct declarator *dc;)
|
function(struct declarator *dc;)
|
||||||
{
|
{
|
||||||
arith fbytes, nbytes;
|
arith fbytes;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
{ register struct idf *idf = dc->dc_idf;
|
{ register struct idf *idf = dc->dc_idf;
|
||||||
|
|
|
@ -80,9 +80,9 @@ getactuals(idef)
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
copyact(ch1, ch2, level)
|
copyact(ch1, ch2, lvl)
|
||||||
char ch1, ch2;
|
char ch1, ch2;
|
||||||
int level;
|
int lvl;
|
||||||
{
|
{
|
||||||
/* copyact() is taken from Ceriel Jacobs' LLgen, with
|
/* copyact() is taken from Ceriel Jacobs' LLgen, with
|
||||||
permission. Its task is to build a list of actuals
|
permission. Its task is to build a list of actuals
|
||||||
|
@ -90,16 +90,16 @@ copyact(ch1, ch2, level)
|
||||||
which the parameters are separated by ',' if there are
|
which the parameters are separated by ',' if there are
|
||||||
more than 1. The balancing of '(',')' and '[',']' and
|
more than 1. The balancing of '(',')' and '[',']' and
|
||||||
'{','}' is taken care of by calling this function
|
'{','}' 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.
|
upto the corresponding closing bracket.
|
||||||
|
|
||||||
Opening bracket is ch1, closing bracket is ch2. If
|
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 ch; /* Current char */
|
||||||
register int match; /* used to read strings */
|
register int match; /* used to read strings */
|
||||||
|
|
||||||
if (level) {
|
if (lvl) {
|
||||||
copy(ch1);
|
copy(ch1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ copyact(ch1, ch2, level)
|
||||||
LoadChar(ch);
|
LoadChar(ch);
|
||||||
|
|
||||||
if (ch == ch2) {
|
if (ch == ch2) {
|
||||||
if (level) {
|
if (lvl) {
|
||||||
copy(ch);
|
copy(ch);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -124,7 +124,7 @@ copyact(ch1, ch2, level)
|
||||||
#endif __MATCHING_PAR__
|
#endif __MATCHING_PAR__
|
||||||
|
|
||||||
case '(':
|
case '(':
|
||||||
copyact('(', ')', level+1);
|
copyact('(', ')', lvl+1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef __MATCHING_PAR__
|
#ifdef __MATCHING_PAR__
|
||||||
|
@ -133,11 +133,11 @@ copyact(ch1, ch2, level)
|
||||||
#define declare(v, t) t v
|
#define declare(v, t) t v
|
||||||
declare(v, union{int i, j; float r;});
|
declare(v, union{int i, j; float r;});
|
||||||
*/
|
*/
|
||||||
copyact('{', '}', level+1);
|
copyact('{', '}', lvl+1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '[':
|
case '[':
|
||||||
copyact('[', ']', level+1);
|
copyact('[', ']', lvl+1);
|
||||||
break;
|
break;
|
||||||
#endif __MATCHING_PAR__
|
#endif __MATCHING_PAR__
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ copyact(ch1, ch2, level)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ',':
|
case ',':
|
||||||
if (!level) {
|
if (!lvl) {
|
||||||
/* next parameter encountered */
|
/* next parameter encountered */
|
||||||
copy(EOS);
|
copy(EOS);
|
||||||
|
|
||||||
|
|
|
@ -212,13 +212,13 @@ align(pos, al)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct type *
|
struct type *
|
||||||
standard_type(fund, sign, align, size)
|
standard_type(fund, sign, algn, size)
|
||||||
int align; arith size;
|
int algn; arith size;
|
||||||
{
|
{
|
||||||
register struct type *tp = create_type(fund);
|
register struct type *tp = create_type(fund);
|
||||||
|
|
||||||
tp->tp_unsigned = sign;
|
tp->tp_unsigned = sign;
|
||||||
tp->tp_align = align;
|
tp->tp_align = algn;
|
||||||
tp->tp_size = size;
|
tp->tp_size = size;
|
||||||
|
|
||||||
return tp;
|
return tp;
|
||||||
|
|
Loading…
Reference in a new issue