Mon, 13 Aug 2012 19:12:21 +0300
rename ObjWriter::RecordBuffer to SwitchBuffer, as it is designed specifically for switch and will break if used genericly
databuffer.h | file | annotate | diff | comparison | revisions | |
objwriter.cxx | file | annotate | diff | comparison | revisions | |
objwriter.h | file | annotate | diff | comparison | revisions | |
parser.cxx | file | annotate | diff | comparison | revisions |
--- a/databuffer.h Mon Aug 13 19:04:29 2012 +0300 +++ b/databuffer.h Mon Aug 13 19:12:21 2012 +0300 @@ -147,12 +147,7 @@ unsigned int u = 0; for (u = 0; u < MAX_MARKS; u++) { if (other->marks[u]) { - // Add the mark and offset its position. - /* str name = other->marks[u]->name; - unsigned int x = AddMark (name); - marks[x]->pos = other->marks[u]->pos + oldsize; - */ - + // Merge the mark and offset its position. if (marks[u]) error ("DataBuffer: duplicate mark %d!\n"); @@ -168,6 +163,7 @@ if (other->refs[u]) { // Same for references + // TODO: add a g_NextRef system like here, akin to marks! unsigned int r = AddMarkReference (other->refs[u]->num, false); refs[r]->pos = other->refs[u]->pos + oldsize; }
--- a/objwriter.cxx Mon Aug 13 19:04:29 2012 +0300 +++ b/objwriter.cxx Mon Aug 13 19:12:21 2012 +0300 @@ -55,7 +55,7 @@ MainBuffer = new DataBuffer; MainLoopBuffer = new DataBuffer; OnEnterBuffer = new DataBuffer; - RecordBuffer = NULL; // created on demand + SwitchBuffer = NULL; // created on demand numWrittenBytes = 0; numWrittenReferences = 0; filepath = path; @@ -146,7 +146,7 @@ } DataBuffer* ObjWriter::GetCurrentBuffer() { - return RecordBuffer ? RecordBuffer : + return SwitchBuffer ? SwitchBuffer : (g_CurMode == MODE_MAINLOOP) ? MainLoopBuffer : (g_CurMode == MODE_ONENTER) ? OnEnterBuffer : MainBuffer;
--- a/objwriter.h Mon Aug 13 19:04:29 2012 +0300 +++ b/objwriter.h Mon Aug 13 19:12:21 2012 +0300 @@ -59,7 +59,7 @@ DataBuffer* MainBuffer; DataBuffer* OnEnterBuffer; DataBuffer* MainLoopBuffer; - DataBuffer* RecordBuffer; + DataBuffer* SwitchBuffer; unsigned int numWrittenBytes; unsigned int numWrittenReferences;
--- a/parser.cxx Mon Aug 13 19:04:29 2012 +0300 +++ b/parser.cxx Mon Aug 13 19:12:21 2012 +0300 @@ -389,14 +389,17 @@ // Write down the expression and case-go-to. This builds // the case tree. The closing event will write the actual // blocks and move the marks appropriately. - info->casebuffers[info->casecursor] = w->RecordBuffer = NULL; + // + // NULL the switch buffer for the case-go-to statement, + // we want it all under the switch, not into the case-buffers. + w->SwitchBuffer = NULL; w->Write<word> (DH_CASEGOTO); w->Write<word> (num); w->AddReference (m); // Init a buffer for the case block, tell the object // writer to record all written data to it. - info->casebuffers[info->casecursor] = w->RecordBuffer = new DataBuffer; + info->casebuffers[info->casecursor] = w->SwitchBuffer = new DataBuffer; continue; } @@ -474,9 +477,9 @@ // the lower block. BlockInformation* previnfo = &blockstack[g_BlockStackCursor - 1]; if (previnfo->casecursor != -1) - w->RecordBuffer = previnfo->casebuffers[previnfo->casecursor]; + w->SwitchBuffer = previnfo->casebuffers[previnfo->casecursor]; else - w->RecordBuffer = NULL; + w->SwitchBuffer = NULL; // Go through all of the buffers we // recorded down and write them.