• R/O
  • SSH
  • HTTPS

jpl: Commit


Commit MetaInfo

Revision469 (tree)
Time2019-03-09 06:58:24
Authorjakobthomsen

Log Message

fix stack pop

Change Summary

Incremental Difference

--- trunk/experimental2/compiler.compiled.c (revision 468)
+++ trunk/experimental2/compiler.compiled.c (revision 469)
@@ -303,7 +303,7 @@
303303 {
304304 if(!tree->height)
305305 {
306- fprintf(stderr, "ERROR: full_tree_with_height_half UNDERFLOW\\n");
306+ fprintf(stderr, "ERROR: full_tree_with_height_half UNDERFLOW\n");
307307 exit(-1);
308308 }
309309 else
@@ -352,14 +352,11 @@
352352 }
353353
354354 stack->fill--;
355- if((stack->fill << 2) <= (1 << stack->tree.height))
355+ // NOTE: stack is halved only if fill is quarter full
356+ // NOTE: varying combinations of fill & height depending (push resp. pull)
357+ if((stack->fill << 2) < (1 << stack->tree.height) - 1)
356358 full_tree_with_height_half(&stack->tree);
357359
358- // NOTE: stack is halved only if fill is quarter full, e.g.
359- // size 8, fill 3 -> size 4, fill 2
360- // size 4, fill 2 -> size 2, fill 1
361- // size 2, fill 1 -> size 1, fill 0
362- // (size 1, fill 0 -> ERROR)
363360 return memory[full_tree_with_height_access(stack->tree, stack->fill)].value;
364361 }
365362
@@ -686,7 +683,7 @@
686683 printf("{\n");
687684 printf(" if(!tree->height)\n");
688685 printf(" {\n");
689- printf(" fprintf(stderr, \"ERROR: full_tree_with_height_half UNDERFLOW\\\\n\");\n");
686+ printf(" fprintf(stderr, \"ERROR: full_tree_with_height_half UNDERFLOW\\n\");\n");
690687 printf(" exit(-1);\n");
691688 printf(" }\n");
692689 printf(" else\n");
@@ -735,14 +732,11 @@
735732 printf(" }\n");
736733 printf("\n");
737734 printf(" stack->fill--;\n");
738- printf(" if((stack->fill << 2) <= (1 << stack->tree.height))\n");
735+ printf(" // NOTE: stack is halved only if fill is quarter full\n");
736+ printf(" // NOTE: varying combinations of fill & height depending (push resp. pull)\n");
737+ printf(" if((stack->fill << 2) < (1 << stack->tree.height) - 1)\n");
739738 printf(" full_tree_with_height_half(&stack->tree);\n");
740739 printf("\n");
741- printf(" // NOTE: stack is halved only if fill is quarter full, e.g.\n");
742- printf(" // size 8, fill 3 -> size 4, fill 2\n");
743- printf(" // size 4, fill 2 -> size 2, fill 1\n");
744- printf(" // size 2, fill 1 -> size 1, fill 0\n");
745- printf(" // (size 1, fill 0 -> ERROR)\n");
746740 printf(" return memory[full_tree_with_height_access(stack->tree, stack->fill)].value;\n");
747741 printf("}\n");
748742 printf("\n");
--- trunk/experimental2/compiler.source.c (revision 468)
+++ trunk/experimental2/compiler.source.c (revision 469)
@@ -312,7 +312,7 @@
312312 printf("{\n");
313313 printf(" if(!tree->height)\n");
314314 printf(" {\n");
315- printf(" fprintf(stderr, \"ERROR: full_tree_with_height_half UNDERFLOW\\\\n\");\n");
315+ printf(" fprintf(stderr, \"ERROR: full_tree_with_height_half UNDERFLOW\\n\");\n");
316316 printf(" exit(-1);\n");
317317 printf(" }\n");
318318 printf(" else\n");
@@ -361,14 +361,11 @@
361361 printf(" }\n");
362362 printf("\n");
363363 printf(" stack->fill--;\n");
364- printf(" if((stack->fill << 2) <= (1 << stack->tree.height))\n");
364+ printf(" // NOTE: stack is halved only if fill is quarter full\n");
365+ printf(" // NOTE: varying combinations of fill & height depending (push resp. pull)\n");
366+ printf(" if((stack->fill << 2) < (1 << stack->tree.height) - 1)\n");
365367 printf(" full_tree_with_height_half(&stack->tree);\n");
366368 printf("\n");
367- printf(" // NOTE: stack is halved only if fill is quarter full, e.g.\n");
368- printf(" // size 8, fill 3 -> size 4, fill 2\n");
369- printf(" // size 4, fill 2 -> size 2, fill 1\n");
370- printf(" // size 2, fill 1 -> size 1, fill 0\n");
371- printf(" // (size 1, fill 0 -> ERROR)\n");
372369 printf(" return memory[full_tree_with_height_access(stack->tree, stack->fill)].value;\n");
373370 printf("}\n");
374371 printf("\n");
Show on old repository browser