• R/O
  • SSH
  • HTTPS

jpl: Commit


Commit MetaInfo

Revision470 (tree)
Time2019-03-09 07:33:36
Authorjakobthomsen

Log Message

work on calls

Change Summary

Incremental Difference

--- trunk/experimental2/compiler.compiled.c (revision 469)
+++ trunk/experimental2/compiler.compiled.c (revision 470)
@@ -362,8 +362,10 @@
362362
363363 int main()
364364 {
365+ uint64_t tmpaddr = 0; // assign temporary addresses highest first (pre-decrement)
365366 mem_init();
366367 struct stack callstack = stack_alloc();
368+ stack_push(&callstack, 0); // end marker
367369 uint64_t state = 1; // main function
368370 while(state)
369371 {
@@ -742,8 +744,10 @@
742744 printf("\n");
743745 printf("int main()\n");
744746 printf("{\n");
747+ printf(" uint64_t tmpaddr = 0; // assign temporary addresses highest first (pre-decrement)\n");
745748 printf(" mem_init();\n");
746749 printf(" struct stack callstack = stack_alloc();\n");
750+ printf(" stack_push(&callstack, 0); // end marker\n");
747751 printf(" uint64_t state = 1; // main function\n");
748752 printf(" while(state)\n");
749753 printf(" {\n");
@@ -790,8 +794,22 @@
790794 {
791795 if(125 == c)
792796 {
797+ printf("state = stack_pop(&callstack);\n");
793798 break;
794799 }
800+ else if(isdigit(c))
801+ {
802+ uint64_t dest = --tmpaddr;
803+ printf("stack_push(&callstack, %lldLL);\n", (long long)dest); // use negative to display numbers concisely
804+ printf(" state = %c", c);
805+ while(isdigit(ungetc(getchar(), stdin))) putchar(getchar()); // echo label
806+ printf(";\n");
807+ printf(" break;\n");
808+ printf(" }\n");
809+ //printf(" case %lluLLU:\n", (unsigned long long)--tmpaddr);
810+ printf(" case %lldLL:\n", (long long)dest); // use negative to display numbers concisely
811+ printf(" {\n");
812+ }
795813 else if(!isspace(c))
796814 {
797815 fprintf(stderr, "unexpected char '%c'\n", c);
@@ -821,7 +839,8 @@
821839 printf(" return 0;\n");
822840 printf("}\n");
823841 printf("\n");
824-
842+ state = stack_pop(&callstack);
843+
825844 break;
826845 }
827846 case 2:
@@ -830,7 +849,8 @@
830849 // test another state
831850
832851 // test another state x
833-
852+ state = stack_pop(&callstack);
853+
834854 break;
835855 }
836856 default:
--- trunk/experimental2/compiler.source.c (revision 469)
+++ trunk/experimental2/compiler.source.c (revision 470)
@@ -371,8 +371,10 @@
371371 printf("\n");
372372 printf("int main()\n");
373373 printf("{\n");
374+ printf(" uint64_t tmpaddr = 0; // assign temporary addresses highest first (pre-decrement)\n");
374375 printf(" mem_init();\n");
375376 printf(" struct stack callstack = stack_alloc();\n");
377+ printf(" stack_push(&callstack, 0); // end marker\n");
376378 printf(" uint64_t state = 1; // main function\n");
377379 printf(" while(state)\n");
378380 printf(" {\n");
@@ -419,8 +421,22 @@
419421 {
420422 if(125 == c)
421423 {
424+ printf("state = stack_pop(&callstack);\n");
422425 break;
423426 }
427+ else if(isdigit(c))
428+ {
429+ uint64_t dest = --tmpaddr;
430+ printf("stack_push(&callstack, %lldLL);\n", (long long)dest); // use negative to display numbers concisely
431+ printf(" state = %c", c);
432+ while(isdigit(ungetc(getchar(), stdin))) putchar(getchar()); // echo label
433+ printf(";\n");
434+ printf(" break;\n");
435+ printf(" }\n");
436+ //printf(" case %lluLLU:\n", (unsigned long long)--tmpaddr);
437+ printf(" case %lldLL:\n", (long long)dest); // use negative to display numbers concisely
438+ printf(" {\n");
439+ }
424440 else if(!isspace(c))
425441 {
426442 fprintf(stderr, "unexpected char '%c'\n", c);
Show on old repository browser