summaryrefslogtreecommitdiff
path: root/src/runtime/cnv.r
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/cnv.r')
-rw-r--r--src/runtime/cnv.r187
1 files changed, 18 insertions, 169 deletions
diff --git a/src/runtime/cnv.r b/src/runtime/cnv.r
index 23e1767..5661deb 100644
--- a/src/runtime/cnv.r
+++ b/src/runtime/cnv.r
@@ -14,9 +14,6 @@
* Assumed: the C compiler must handle assignments of C integers to
* C double variables and vice-versa. Hopefully production C compilers
* have managed to eliminate bugs related to these assignments.
- *
- * Note: calls beginning with EV are empty macros unless EventMon
- * is defined.
*/
#define tonum(c) (isdigit(c) ? (c)-'0' : 10+(((c)|(040))-'a'))
@@ -46,15 +43,10 @@ double *d;
return 1;
}
integer: {
-
-#ifdef LargeInts
if (Type(*s) == T_Lrgint)
*d = bigtoreal(s);
else
-#endif /* LargeInts */
-
*d = IntVal(*s);
-
return 1;
}
string: {
@@ -76,15 +68,11 @@ double *d;
case T_Integer:
*d = numrc.integer;
return 1;
-
-#ifdef LargeInts
case T_Lrgint:
result.dword = D_Lrgint;
BlkLoc(result) = (union block *)numrc.big;
*d = bigtoreal(&result);
return 1;
-#endif /* LargeInts */
-
case T_Real:
*d = numrc.real;
return 1;
@@ -106,13 +94,9 @@ C_integer *d;
type_case *s of {
integer: {
-
-#ifdef LargeInts
if (Type(*s) == T_Lrgint) {
return 0;
}
-#endif /* LargeInts */
-
*d = IntVal(*s);
return 1;
}
@@ -212,12 +196,8 @@ dptr s, d;
register C_integer l;
register char *s1; /* does not need to be tended */
- EVValD(s, E_Aconv);
- EVValD(&csetdesc, E_Tconv);
-
if (is:cset(*s)) {
*d = *s;
- EVValD(s, E_Nconv);
return 1;
}
/*
@@ -232,11 +212,9 @@ dptr s, d;
Setb(*s1, *d);
s1++;
}
- EVValD(d, E_Sconv);
return 1;
}
else {
- EVValD(s, E_Fconv);
return 0;
}
}
@@ -254,12 +232,9 @@ C_integer *d;
type_case *s of {
integer: {
-
-#ifdef LargeInts
if (Type(*s) == T_Lrgint) {
return 0;
}
-#endif /* LargeInts */
*d = IntVal(*s);
return 1;
}
@@ -321,14 +296,10 @@ dptr s, d;
case T_Integer:
MakeInt(numrc.integer, d);
return 1;
-
-#ifdef LargeInts
case T_Lrgint:
d->dword = D_Lrgint;
BlkLoc(*d) = (union block *)numrc.big;
return 1;
-#endif /* LargeInts */
-
default:
return 0;
}
@@ -344,36 +315,23 @@ dptr s, d;
char sbuf[MaxCvtLen];
union numeric numrc;
- EVValD(s, E_Aconv);
- EVValD(&zerodesc, E_Tconv);
-
type_case *s of {
integer: {
*d = *s;
- EVValD(s, E_Nconv);
return 1;
}
real: {
double dbl;
GetReal(s,dbl);
if (dbl > MaxLong || dbl < MinLong) {
-
-#ifdef LargeInts
if (realtobig(s, d) == Succeeded) {
- EVValD(d, E_Sconv);
return 1;
}
else {
- EVValD(s, E_Fconv);
return 0;
}
-#else /* LargeInts */
- EVValD(s, E_Fconv);
- return 0;
-#endif /* LargeInts */
}
MakeInt((word)dbl,d);
- EVValD(d, E_Sconv);
return 1;
}
string: {
@@ -384,7 +342,6 @@ dptr s, d;
s = &cnvstr;
}
default: {
- EVValD(s, E_Fconv);
return 0;
}
}
@@ -393,43 +350,25 @@ dptr s, d;
* s is now a string.
*/
switch( ston(s, &numrc) ) {
-
-#ifdef LargeInts
case T_Lrgint:
d->dword = D_Lrgint;
BlkLoc(*d) = (union block *)numrc.big;
- EVValD(d, E_Sconv);
return 1;
-#endif /* LargeInts */
-
case T_Integer:
MakeInt(numrc.integer,d);
- EVValD(d, E_Sconv);
return 1;
case T_Real: {
double dbl = numrc.real;
if (dbl > MaxLong || dbl < MinLong) {
-
-#ifdef LargeInts
- if (realtobig(s, d) == Succeeded) {
- EVValD(d, E_Sconv);
+ if (realtobig(s, d) == Succeeded)
return 1;
- }
- else {
- EVValD(s, E_Fconv);
+ else
return 0;
- }
-#else /* LargeInts */
- EVValD(s, E_Fconv);
- return 0;
-#endif /* LargeInts */
- }
+ }
MakeInt((word)dbl,d);
- EVValD(d, E_Sconv);
return 1;
}
default:
- EVValD(s, E_Fconv);
return 0;
}
}
@@ -442,17 +381,12 @@ dptr s, d;
{
double dbl;
- EVValD(s, E_Aconv);
- EVValD(&rzerodesc, E_Tconv);
-
if (cnv_c_dbl(s, &dbl)) {
Protect(BlkLoc(*d) = (union block *)alcreal(dbl), fatalerr(0,NULL));
d->dword = D_Real;
- EVValD(d, E_Sconv);
return 1;
}
else
- EVValD(s, E_Fconv);
return 0;
}
@@ -464,31 +398,23 @@ dptr s, d;
{
char sbuf[MaxCvtLen];
- EVValD(s, E_Aconv);
- EVValD(&emptystr, E_Tconv);
-
type_case *s of {
string: {
*d = *s;
- EVValD(s, E_Nconv);
return 1;
}
integer: {
-
-#ifdef LargeInts
if (Type(*s) == T_Lrgint) {
word slen;
word dlen;
slen = (BlkLoc(*s)->bignumblk.lsd - BlkLoc(*s)->bignumblk.msd +1);
dlen = slen * NB * 0.3010299956639812; /* 1 / log2(10) */
- bigtos(s,d);
- }
+ bigtos(s,d);
+ }
else
-#endif /* LargeInts */
-
- itos(IntVal(*s), d, sbuf);
- }
+ itos(IntVal(*s), d, sbuf);
+ }
real: {
double res;
GetReal(s, res);
@@ -497,12 +423,10 @@ dptr s, d;
cset:
cstos(BlkLoc(*s)->cset.bits, d, sbuf);
default: {
- EVValD(s, E_Fconv);
return 0;
}
}
Protect(StrLoc(*d) = alcstr(StrLoc(*d), StrLen(*d)), fatalerr(0,NULL));
- EVValD(d, E_Sconv);
return 1;
}
@@ -518,12 +442,8 @@ dptr s, d;
register char *s1;
C_integer l;
- EVValD(s, E_Aconv);
- EVValD(&csetdesc, E_Tconv);
-
if (is:cset(*s)) {
*d = *s;
- EVValD(s, E_Nconv);
return 1;
}
if (tmp_str(sbuf, s, &tmpstr)) {
@@ -537,11 +457,9 @@ dptr s, d;
Setb(*s1, *d);
s1++;
}
- EVValD(d, E_Sconv);
return 1;
}
else {
- EVValD(s, E_Fconv);
return 0;
}
}
@@ -554,20 +472,14 @@ char *sbuf;
dptr s;
dptr d;
{
- EVValD(s, E_Aconv);
- EVValD(&emptystr, E_Tconv);
-
if (is:string(*s)) {
*d = *s;
- EVValD(s, E_Nconv);
return 1;
}
else if (tmp_str(sbuf, s, d)) {
- EVValD(d, E_Sconv);
return 1;
}
else {
- EVValD(s, E_Fconv);
return 0;
}
}
@@ -661,21 +573,17 @@ dptr d;
string:
*d = *s;
integer: {
-
-#ifdef LargeInts
if (Type(*s) == T_Lrgint) {
word slen;
word dlen;
slen = (BlkLoc(*s)->bignumblk.lsd - BlkLoc(*s)->bignumblk.msd +1);
dlen = slen * NB * 0.3010299956639812; /* 1 / log2(10) */
- bigtos(s,d);
- }
+ bigtos(s,d);
+ }
else
-#endif /* LargeInts */
-
- itos(IntVal(*s), d, sbuf);
- }
+ itos(IntVal(*s), d, sbuf);
+ }
real: {
double res;
GetReal(s, res);
@@ -731,16 +639,10 @@ C_integer arity;
/*
* See if the string represents a built-in function.
*/
-#if COMPILER
- for (i = 0; i < n_globals; ++i)
- if (eq(s, &gnames[i]))
- return builtins[i]; /* may be null */
-#else /* COMPILER */
pp = (struct pstrnm *)qsearch((char *)s,(char *)pntab,pnsize,
sizeof(struct pstrnm),dp_pnmcmp);
if (pp!=NULL)
return (struct b_proc *)pp->pblock;
-#endif /* !COMPILER */
return NULL;
}
@@ -887,13 +789,9 @@ union numeric *result;
*/
if (c == 'r' || c == 'R') {
int rv;
-#ifdef LargeInts
rv = bigradix((int)msign, (int)mantissa, s, end_s, result);
if (rv == Error)
fatalerr(0, NULL);
-#else /* LargeInts */
- rv = radix((int)msign, (int)mantissa, s, end_s, result);
-#endif /* LargeInts */
return rv;
}
@@ -959,21 +857,16 @@ union numeric *result;
return T_Integer;
}
-#ifdef LargeInts
/*
* Test for bignum.
*/
-#if COMPILER
- if (largeints)
-#endif /* COMPILER */
- if (!realflag) {
- int rv;
- rv = bigradix((int)msign, 10, ssave, end_s, result);
- if (rv == Error)
- fatalerr(0, NULL);
- return rv;
- }
-#endif /* LargeInts */
+ if (!realflag) {
+ int rv;
+ rv = bigradix((int)msign, 10, ssave, end_s, result);
+ if (rv == Error)
+ fatalerr(0, NULL);
+ return rv;
+ }
if (!realflag)
return CvtFail; /* don't promote to real if integer format */
@@ -1023,50 +916,6 @@ union numeric *result;
result->real = mantissa;
return T_Real;
}
-
-#if COMPILER || !(defined LargeInts)
-/*
- * radix - convert string s in radix r into an integer in *result. sign
- * will be either '+' or '-'.
- */
-int radix(sign, r, s, end_s, result)
-int sign;
-register int r;
-register char *s;
-register char *end_s;
-union numeric *result;
- {
- register int c;
- long num;
-
- if (r < 2 || r > 36)
- return CvtFail;
- c = (s < end_s) ? *s++ : ' ';
- num = 0L;
- while (isalnum(c)) {
- c = tonum(c);
- if (c >= r)
- return CvtFail;
- num = num * r + c;
- c = (s < end_s) ? *s++ : ' ';
- }
-
- /*
- * Skip trailing white space and make sure there is nothing else left
- * in the string. Note, if we have already reached end-of-string,
- * c has been set to a space.
- */
- while (isspace(c) && s < end_s)
- c = *s++;
- if (!isspace(c))
- return CvtFail;
-
- result->integer = (sign == '+' ? num : -num);
-
- return T_Integer;
- }
-#endif /* COMPILER || !(defined LargeInts) */
-
/*
* cvpos - convert position to strictly positive position