diff options
-rw-r--r-- | colm/bytecode.c | 14 | ||||
-rw-r--r-- | colm/tree.c | 27 |
2 files changed, 23 insertions, 18 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c index ab904adf..ab9fd754 100644 --- a/colm/bytecode.c +++ b/colm/bytecode.c @@ -388,7 +388,7 @@ void uiterInit( Program *prg, Tree **sp, UserIter *uiter, { /* Set up the first yeild so when we resume it starts at the beginning. */ uiter->ref.kid = 0; - uiter->yieldSize = uiter->stackRoot - vm_ptop(); + uiter->yieldSize = vm_ssize() - uiter->rootSize; uiter->frame = &uiter->stackRoot[-IFR_AA]; if ( revertOn ) @@ -400,7 +400,7 @@ void uiterInit( Program *prg, Tree **sp, UserIter *uiter, void treeIterDestroy( Program *prg, Tree ***psp, TreeIter *iter ) { Tree **sp = *psp; - long curStackSize = iter->stackRoot - vm_ptop(); + long curStackSize = vm_ssize() - iter->rootSize; assert( iter->yieldSize == curStackSize ); vm_popn( iter->yieldSize ); *psp = sp; @@ -412,12 +412,12 @@ void userIterDestroy( Program *prg, Tree ***psp, UserIter *uiter ) /* We should always be coming from a yield. The current stack size will be * nonzero and the stack size in the iterator will be correct. */ - long curStackSize = uiter->stackRoot - vm_ptop(); + long curStackSize = vm_ssize() - uiter->rootSize; assert( uiter->yieldSize == curStackSize ); long argSize = uiter->argSize; - vm_popn( uiter->stackRoot - vm_ptop() ); + vm_popn( uiter->yieldSize ); vm_popn( sizeof(UserIter) / sizeof(Word) ); vm_popn( argSize ); @@ -1207,7 +1207,7 @@ again: /* Get the iterator. */ UserIter *uiter = (UserIter*) vm_local(field); - long yieldSize = uiter->stackRoot - vm_ptop(); + long yieldSize = vm_ssize() - uiter->rootSize; assert( uiter->yieldSize == yieldSize ); /* Fix the return instruction pointer. */ @@ -1918,7 +1918,7 @@ again: debug( REALM_BYTECODE, "IN_REV_TRITER_DESTROY\n" ); RevTreeIter *iter = (RevTreeIter*) vm_plocal(field); - long curStackSize = iter->stackRoot - vm_ptop(); + long curStackSize = vm_ssize() - iter->rootSize; assert( iter->yieldSize == curStackSize ); vm_popn( iter->yieldSize ); break; @@ -3342,7 +3342,7 @@ again: /* Store the yeilded value. */ uiter->ref.kid = kid; uiter->ref.next = next; - uiter->yieldSize = uiter->stackRoot - vm_ptop(); + uiter->yieldSize = vm_ssize() - uiter->rootSize; uiter->resume = instr; uiter->frame = exec->framePtr; diff --git a/colm/tree.c b/colm/tree.c index 8e518884..43519660 100644 --- a/colm/tree.c +++ b/colm/tree.c @@ -1704,7 +1704,8 @@ rec_call: Tree *treeIterAdvance( Program *prg, Tree ***psp, TreeIter *iter ) { - assert( iter->yieldSize == iter->stackRoot - *psp ); + Tree **sp = *psp; + assert( iter->yieldSize == (vm_ssize() - iter->rootSize) ); if ( iter->ref.kid == 0 ) { /* Kid is zero, start from the root. */ @@ -1716,7 +1717,8 @@ Tree *treeIterAdvance( Program *prg, Tree ***psp, TreeIter *iter ) iterFind( prg, psp, iter, false ); } - iter->yieldSize = iter->stackRoot - *psp; + sp = *psp; + iter->yieldSize = vm_ssize() - iter->rootSize; return (iter->ref.kid ? prg->trueVal : prg->falseVal ); } @@ -1724,7 +1726,7 @@ Tree *treeIterAdvance( Program *prg, Tree ***psp, TreeIter *iter ) Tree *treeIterNextChild( Program *prg, Tree ***psp, TreeIter *iter ) { Tree **sp = *psp; - assert( iter->yieldSize == iter->stackRoot - vm_ptop() ); + assert( iter->yieldSize == (vm_ssize() - iter->rootSize) ); Kid *kid = 0; if ( iter->ref.kid == 0 ) { @@ -1755,7 +1757,7 @@ Tree *treeIterNextChild( Program *prg, Tree ***psp, TreeIter *iter ) } iter->ref.kid = kid; - iter->yieldSize = iter->stackRoot - vm_ptop(); + iter->yieldSize = vm_ssize() - iter->rootSize; *psp = sp; return ( iter->ref.kid ? prg->trueVal : prg->falseVal ); } @@ -1763,8 +1765,7 @@ Tree *treeIterNextChild( Program *prg, Tree ***psp, TreeIter *iter ) Tree *treeRevIterPrevChild( Program *prg, Tree ***psp, RevTreeIter *iter ) { Tree **sp = *psp; - - assert( iter->yieldSize == iter->stackRoot - vm_ptop() ); + assert( iter->yieldSize == ( vm_ssize() - iter->rootSize ) ); if ( iter->kidAtYield != iter->ref.kid ) { /* Need to reload the kids. */ @@ -1799,7 +1800,7 @@ Tree *treeRevIterPrevChild( Program *prg, Tree ***psp, RevTreeIter *iter ) /* We will use this to detect a split above the iterated tree. */ iter->kidAtYield = iter->ref.kid; - iter->yieldSize = iter->stackRoot - vm_ptop(); + iter->yieldSize = vm_ssize() - iter->rootSize; *psp = sp; @@ -1852,7 +1853,8 @@ rec_call: Tree *treeIterNextRepeat( Program *prg, Tree ***psp, TreeIter *iter ) { - assert( iter->yieldSize == iter->stackRoot - *psp ); + Tree **sp = *psp; + assert( iter->yieldSize == ( vm_ssize() - iter->rootSize ) ); if ( iter->ref.kid == 0 ) { /* Kid is zero, start from the root. */ @@ -1864,7 +1866,8 @@ Tree *treeIterNextRepeat( Program *prg, Tree ***psp, TreeIter *iter ) iterFindRepeat( prg, psp, iter, false ); } - iter->yieldSize = iter->stackRoot - *psp; + sp = *psp; + iter->yieldSize = vm_ssize() - iter->rootSize; return (iter->ref.kid ? prg->trueVal : prg->falseVal ); } @@ -1928,7 +1931,8 @@ first: Tree *treeIterPrevRepeat( Program *prg, Tree ***psp, TreeIter *iter ) { - assert( iter->yieldSize == iter->stackRoot - *psp ); + Tree **sp = *psp; + assert( iter->yieldSize == (vm_ssize() - iter->rootSize) ); if ( iter->ref.kid == 0 ) { /* Kid is zero, start from the root. */ @@ -1940,7 +1944,8 @@ Tree *treeIterPrevRepeat( Program *prg, Tree ***psp, TreeIter *iter ) iterFindRevRepeat( prg, psp, iter, false ); } - iter->yieldSize = iter->stackRoot - *psp; + sp = *psp; + iter->yieldSize = vm_ssize() - iter->rootSize; return (iter->ref.kid ? prg->trueVal : prg->falseVal ); } |