• R/O
  • SSH
  • HTTPS

jpl: Commit


Commit MetaInfo

Revision472 (tree)
Time2019-03-09 09:42:02
Authorjakobthomsen

Log Message

wrap called function in closures

Change Summary

Incremental Difference

--- trunk/experimental2/compiler.compiled.c (revision 471)
+++ trunk/experimental2/compiler.compiled.c (revision 472)
@@ -753,7 +753,9 @@
753753 printf(" {\n");
754754 printf(" switch(state)\n");
755755 printf(" {\n");
756- state = stack_pop(&callstack);
756+ uint64_t closure = stack_pop(&callstack);
757+state = memory[tuple2_access0(closure)].value;
758+tuple2_free(closure);
757759
758760 break;
759761 }
@@ -775,7 +777,9 @@
775777 printf(" return 0;\n");
776778 printf("}\n");
777779 printf("\n");
778- state = stack_pop(&callstack);
780+ uint64_t closure = stack_pop(&callstack);
781+state = memory[tuple2_access0(closure)].value;
782+tuple2_free(closure);
779783
780784 break;
781785 }
@@ -783,7 +787,8 @@
783787 {
784788
785789 // intro
786- stack_push(&callstack, -1LL);
790+ uint64_t closure = tuple2_alloc(-1LL, 0);
791+ stack_push(&callstack, closure);
787792 state = 2;
788793 break;
789794 }
@@ -831,13 +836,16 @@
831836 {
832837 if(125 == c)
833838 {
834- printf("state = stack_pop(&callstack);\n");
839+ printf("uint64_t closure = stack_pop(&callstack);\n");
840+ printf("state = memory[tuple2_access0(closure)].value;\n");
841+ printf("tuple2_free(closure);\n");
835842 break;
836843 }
837844 else if(isdigit(c))
838845 {
839846 uint64_t dest = --tmpaddr;
840- printf("stack_push(&callstack, %lldLL);\n", (long long)dest); // use negative to display numbers concisely
847+ printf("uint64_t closure = tuple2_alloc(%lldLL, 0);\n", (long long)dest); // use negative to display numbers concisely
848+ printf(" stack_push(&callstack, closure);\n");
841849 printf(" state = %c", c);
842850 while(isdigit(ungetc(getchar(), stdin))) putchar(getchar()); // echo label
843851 printf(";\n");
@@ -862,13 +870,16 @@
862870 state = 0;
863871
864872 // outro
865- stack_push(&callstack, -2LL);
873+ uint64_t closure = tuple2_alloc(-2LL, 0);
874+ stack_push(&callstack, closure);
866875 state = 3;
867876 break;
868877 }
869878 case -2LL:
870879 {
871-state = stack_pop(&callstack);
880+uint64_t closure = stack_pop(&callstack);
881+state = memory[tuple2_access0(closure)].value;
882+tuple2_free(closure);
872883
873884 break;
874885 }
--- trunk/experimental2/compiler.source.c (revision 471)
+++ trunk/experimental2/compiler.source.c (revision 472)
@@ -451,13 +451,16 @@
451451 {
452452 if(125 == c)
453453 {
454- printf("state = stack_pop(&callstack);\n");
454+ printf("uint64_t closure = stack_pop(&callstack);\n");
455+ printf("state = memory[tuple2_access0(closure)].value;\n");
456+ printf("tuple2_free(closure);\n");
455457 break;
456458 }
457459 else if(isdigit(c))
458460 {
459461 uint64_t dest = --tmpaddr;
460- printf("stack_push(&callstack, %lldLL);\n", (long long)dest); // use negative to display numbers concisely
462+ printf("uint64_t closure = tuple2_alloc(%lldLL, 0);\n", (long long)dest); // use negative to display numbers concisely
463+ printf(" stack_push(&callstack, closure);\n");
461464 printf(" state = %c", c);
462465 while(isdigit(ungetc(getchar(), stdin))) putchar(getchar()); // echo label
463466 printf(";\n");
Show on old repository browser