From cea5a9315d2209573d1c04a8f220aa2902feb26d Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 15 Feb 2009 11:11:00 -0700 Subject: [PATCH] fix block delimiting code in compile.cpp to avoid cycles and nested blocks --- src/compiler.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compiler.cpp b/src/compiler.cpp index 7d2015af81..a9c2443569 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -4318,16 +4318,21 @@ compile(Context* c) LogicalInstruction* nextInstruction = next(c, e->logicalInstruction); if (e->next == 0 or (e->next->logicalInstruction != e->logicalInstruction - and e->next->logicalInstruction != nextInstruction)) + and (e->next->logicalInstruction != nextInstruction + or e != e->logicalInstruction->lastEvent))) { Block* b = e->logicalInstruction->firstEvent->block; + + while (b->nextBlock) { + b = b->nextBlock; + } + if (b != block) { - while (b->nextBlock) b = b->nextBlock; b->nextBlock = block; } + block->nextInstruction = nextInstruction; block->assemblerBlock = a->endBlock(e->next != 0); -// fprintf(stderr, "end block %p at %d\n", block->assemblerBlock, e->logicalInstruction->index); if (e->next) { block = ::block(c, e->next); @@ -4340,9 +4345,10 @@ compile(Context* c) Block* next = block->nextBlock ? block->nextBlock : block->nextInstruction->firstEvent->block; + next->start = block->assemblerBlock->resolve (block->start, next->assemblerBlock); -// fprintf(stderr, "resolve block %p\n", block->assemblerBlock); + block = next; }