From d5513476683eedf03703c78c8b5b86d14ca222a9 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sat, 27 Nov 2010 02:46:26 +0200 Subject: [PATCH] fixed bug in SmallInt math primitives --- imgsrc/defs/base/collections/array.st | 7 ++----- src/lstcore/lst_interp.c | 16 +++++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/imgsrc/defs/base/collections/array.st b/imgsrc/defs/base/collections/array.st index 77113b9..d1529c1 100644 --- a/imgsrc/defs/base/collections/array.st +++ b/imgsrc/defs/base/collections/array.st @@ -231,11 +231,8 @@ from: low [ hash [ | sz | - ((sz := self size) < 2) ifTrue: [ - (sz = 1) ifTrue: [ ^(self at: 1) hash + sz ]. - ^0 - ]. - ^(self at: 1) hash + (self at: sz) hash + (sz := self size) < 2 ifTrue: [ sz = 1 ifTrue: [ ^((self at: 1) hash + sz) truncSmallInt ]. ^0 ]. + ^((self at: 1) hash + (self at: sz) hash) truncSmallInt ] elementsExchangeIdentityWith: otherArray [ diff --git a/src/lstcore/lst_interp.c b/src/lstcore/lst_interp.c index 4b581eb..3fb46e3 100644 --- a/src/lstcore/lst_interp.c +++ b/src/lstcore/lst_interp.c @@ -1101,8 +1101,11 @@ markArgsCompleteNoPush: retValue = i<=j ? lstTrueObj : lstFalseObj; break; case 2: /* + */ - /* no possibility of garbage col */ itmp = (int64_t)i+j; + if (i == 60567372) { + fprintf(stderr, "PLUS: %d %d\n", i, j); + fprintf(stderr, "RES: %lld (%d)\n", itmp, LST_64FITS_SMALLINT(itmp)); + } retValue = lstNewInteger(itmp); break; case 3: /* - */ @@ -1965,13 +1968,12 @@ doBlockInvocation: l0 = lstIntValue(op); if (high <= 30) { switch (high) { - case 26: itmp = (int64_t)l0+l1; break; - case 27: itmp = (int64_t)l0-l1; break; - case 28: itmp = (int64_t)l0*l1; break; - case 29: if (l1 == 0) goto failPrimitive; l0 /= l1; break; - case 30: if (l1 == 0) goto failPrimitive; l0 %= l1; break; + case 26: itmp = (int64_t)l0+l1; retValue = lstNewInteger(itmp); break; + case 27: itmp = (int64_t)l0-l1; retValue = lstNewInteger(itmp); break; + case 28: itmp = (int64_t)l0*l1; retValue = lstNewInteger(itmp); break; + case 29: if (l1 == 0) goto failPrimitive; l0 /= l1; retValue = lstNewInt(l0); break; + case 30: if (l1 == 0) goto failPrimitive; l0 %= l1; retValue = lstNewInt(l0); break; } - retValue = lstNewInt(l0); } else { switch (high) { case 31: retValue = l0