cmpstr(a
, b
, la
, lb
) /* compare two strings */
register char *aend
, *bend
;
for(p
= x
; p
->nextp
; p
= p
->nextp
)
struct listblock
*mklist(p
)
register struct listblock
*q
;
for(i
=0; i
<n
&& *s
!=' ' && *s
!='\0' ; ++i
)
for(i
=0; i
<n
&& *s
!=' ' && *s
!='\0' ; ++i
)
for(i
=0; i
<n
&& *s
!=' ' && *s
!='\0' ; ++s
)
return( copyn( strlen(s
)+1 , s
) );
sum
= 10*sum
+ (*s
++ - '0');
err("too many digits in floating constant");
for(t
= v
; n
-- > 0 ; s
++)
*t
++ = (*s
=='d' ? 'e' : *s
);
struct nameblock
*mkname(l
, s
)
register struct nameblock
*q
;
for(i
= 0 ; i
<l
&& *s
!='\0' ; ++i
)
if( hash
==hp
->hashval
&& eqn(VL
,n
,q
->varname
) )
else if(++hp
>= lasthash
)
if(++nintnames
>= MAXHASH
-1)
fatal("hash table full");
hp
->varp
= q
= ALLOC(nameblock
);
struct labelblock
*mklabel(l
)
register struct labelblock
*lp
;
for(lp
= labeltab
; lp
< highlabtab
; ++lp
)
if(++highlabtab
>= labtabend
)
fatal("too many statement numbers");
lp
->labelno
= newlabel();
lp
->labtype
= LABUNKNOWN
;
/* find or put a name in the external symbol table */
for(p
= extsymtab
; p
<nextext
; ++p
)
if(eqn(XL
, n
, p
->extname
))
fatal("too many external symbols");
cpn(XL
, n
, nextext
->extname
);
nextext
->extstg
= STGUNKNOWN
;
struct addrblock
*builtin(t
, s
)
register struct extsym
*p
;
register struct addrblock
*q
;
if(p
->extstg
== STGUNKNOWN
)
else if(p
->extstg
!= STGEXT
)
err1("improper use of builtin %s", s
);
q
->memno
= p
- extsymtab
;
for(q
= *p
; q
->nextp
; q
= q
->nextp
)
if(t
==TYCOMPLEX
&& (t1
==TYDREAL
|| t2
==TYDREAL
) )
/* return log base 2 of n if n a power of 2; otherwise -1 */
/* trick based on binary representation */
if(n
<=0 || (n
& (n
-1))!=0)
for(k
= 0 ; n
>>= 1 ; ++k
)
fatal("popstack: stack empty");
struct exprblock
*callk(type
, name
, args
)
register struct exprblock
*p
;
p
= mkexpr(OPCALL
, builtin(type
,name
), args
);
struct exprblock
*call4(type
, name
, arg1
, arg2
, arg3
, arg4
)
expptr arg1
, arg2
, arg3
, arg4
;
args
= mklist( mkchain(arg1
, mkchain(arg2
, mkchain(arg3
, mkchain(arg4
, NULL
)) ) ) );
return( callk(type
, name
, args
) );
struct exprblock
*call3(type
, name
, arg1
, arg2
, arg3
)
args
= mklist( mkchain(arg1
, mkchain(arg2
, mkchain(arg3
, NULL
) ) ) );
return( callk(type
, name
, args
) );
struct exprblock
*call2(type
, name
, arg1
, arg2
)
args
= mklist( mkchain(arg1
, mkchain(arg2
, NULL
) ) );
return( callk(type
,name
, args
) );
struct exprblock
*call1(type
, name
, arg
)
return( callk(type
,name
, mklist(mkchain(arg
,0)) ));
struct exprblock
*call0(type
, name
)
return( callk(type
, name
, NULL
) );
struct impldoblock
*mkiodo(dospec
, list
)
register struct impldoblock
*q
;
if( p
= calloc(1, (unsigned) n
) )
return( isaddr(p
->rightp
) );
return( isaddr(p
->leftp
) );
return( addressable(p
->memoffset
) );
static char p0
[17] = "0123456789abcdef";