Skip to content

Commit

Permalink
Fix indirection vector calculation
Browse files Browse the repository at this point in the history
It was broken in commit d14f487.

Fixes #63
  • Loading branch information
Zeex committed May 9, 2015
1 parent 56262f4 commit 1cca8af
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -2334,32 +2334,33 @@ static int base;
base=startlit;
size=1;
for (cur=0; cur<numdim-1; cur++) {
for (i=0; i<size; i++) {
/* 2 or more dimensions left, fill in an indirection vector */
if (dim[cur+1]>0) {
/* 2 or more dimensions left, fill in an indirection vector */
if (dim[cur+1]>0) {
for (i=0; i<size; i++)
for (d=0; d<dim[cur]; d++)
litq[base++]=((size+i)*dim[cur]+d*(dim[cur+1]-1)) * sizeof(cell);
} else {
/* final dimension is variable length */
constvalue *ld;
assert(dim[cur+1]==0);
assert(lastdim!=NULL);
assert(skipdim!=NULL);
accum=0;
litq[base++]=(size*dim[cur]+(dim[cur+1]-1)*(dim[cur]*i+d)) * sizeof(cell);
} else {
/* final dimension is variable length */
constvalue *ld;
assert(dim[cur+1]==0);
assert(lastdim!=NULL);
assert(skipdim!=NULL);
accum=0;
for (i=0; i<size; i++) {
/* skip the final dimension sizes for all earlier major dimensions */
for (d=0,ld=lastdim->next; d<*skipdim; d++,ld=ld->next) {
assert(ld!=NULL);
} /* for */
for (d=0; d<dim[cur]; d++) {
assert(ld!=NULL);
assert(strtol(ld->name,NULL,16)==d);
litq[base++]=((size+i)*dim[cur]+accum) * sizeof(cell);
litq[base++]=(size*dim[cur]+accum) * sizeof(cell);
accum+=ld->value-1;
*skipdim+=1;
ld=ld->next;
} /* for */
} /* if */
} /* for */
} /* for */
} /* if */
size*=dim[cur];
} /* for */
}
Expand Down

0 comments on commit 1cca8af

Please sign in to comment.