• R/O
  • SSH
  • HTTPS

jpl: Commit


Commit MetaInfo

Revision475 (tree)
Time2019-03-09 11:02:01
Authorjakobthomsen

Log Message

work on call with result

Change Summary

Incremental Difference

--- trunk/experimental2/compiler.source.c (revision 474)
+++ trunk/experimental2/compiler.source.c (revision 475)
@@ -374,6 +374,7 @@
374374 printf("{\n");
375375 printf(" uint64_t tmpaddr = 0; // assign temporary addresses highest first (pre-decrement)\n");
376376 printf(" mem_init();\n");
377+ printf(" uint64_t result = 0;");
377378 printf(" struct stack callstack = stack_alloc();\n");
378379 printf(" stack_push(&callstack, 0); // end marker\n");
379380 printf(" uint64_t state = tuple2_alloc(1/*main*/, 0/*arg*/);\n");
@@ -395,11 +396,12 @@
395396 printf(" }\n");
396397 printf("\n");
397398 printf(" tuple2_free(state);\n");
399+ printf(" result = stack_pop(&callstack);\n");
398400 printf(" stack_free(&callstack);\n");
399401 printf(" mem_show();\n");
400402 printf(" mem_check();\n");
401403 printf("\n");
402- printf(" return 0;\n");
404+ printf(" return (int)result;\n");
403405 printf("}\n");
404406 printf("\n");
405407 `
@@ -452,25 +454,34 @@
452454 {
453455 if(125 == c)
454456 {
455- printf("uint64_t closure = stack_pop(&callstack);\n");
456- printf(" memory[tuple2_access0(state)].value = memory[tuple2_access0(closure)].value;\n");
457- printf(" tuple2_free(closure);\n");
457+ printf("tuple2_free(state);\n");
458+ printf(" state = stack_pop(&callstack);\n");
459+ printf(" stack_push(&callstack, result);\n");
458460 break;
459461 }
460462 else if(isdigit(c))
461463 {
462464 uint64_t dest = --tmpaddr;
463- printf("uint64_t closure = tuple2_alloc(%lldLL, 0);\n", (long long)dest); // use negative to display numbers concisely
464- printf(" stack_push(&callstack, closure);\n");
465- printf(" memory[tuple2_access0(state)].value = %c", c);
465+ printf("memory[tuple2_access0(state)].value = %lldLL;\n", (long long)dest); // use negative to display numbers concisely
466+ printf(" stack_push(&callstack, state);\n");
467+ printf(" state = tuple2_alloc(%c", c);
466468 while(isdigit(ungetc(getchar(), stdin))) putchar(getchar()); // echo label
467- printf(";\n");
469+ printf(", 0);\n");
470+ printf(" result = 0;\n");
468471 printf(" break;\n");
469472 printf(" }\n");
470473 //printf(" case %lluLLU:\n", (unsigned long long)--tmpaddr);
471474 printf(" case %lldLL:\n", (long long)dest); // use negative to display numbers concisely
472475 printf(" {\n");
476+ printf(" result = stack_pop(&callstack);\n");
473477 }
478+ else if(64 == c)
479+ {
480+ printf(" result = ");
481+ while(isspace(ungetc(getchar(), stdin))) (void)getchar(); // skip WS
482+ while(isdigit(ungetc(getchar(), stdin))) putchar(getchar()); // echo number
483+ printf(";\n");
484+ }
474485 else if(!isspace(c))
475486 {
476487 fprintf(stderr, "unexpected char '%c'\n", c);
@@ -488,4 +499,6 @@
488499 // outro
489500 `
490501 3
502+
503+ @ 0
491504 }
Show on old repository browser