• R/O
  • SSH
  • HTTPS

jpl: コミット


コミットメタ情報

リビジョン538 (tree)
日時2019-03-26 07:11:46
作者jakobthomsen

ログメッセージ

implement blocks

変更サマリ

差分

--- trunk/experimental_memfix/compiler.compiled.c (revision 537)
+++ trunk/experimental_memfix/compiler.compiled.c (revision 538)
@@ -134,7 +134,6 @@
134134 memory[*list + 1] = 0;
135135 memory[1] = *list;
136136 *list = next;
137-
138137 }
139138
140139 void list_free(uint64_t *memory, uint64_t *list)
@@ -152,7 +151,6 @@
152151 memory[1] = *list;
153152 *list = next;
154153 }
155-
156154 }
157155
158156 void init(struct state *state, uint64_t *memory);
@@ -314,7 +312,7 @@
314312 }
315313 if(!defref)
316314 {
317- fprintf(stderr, "no such function! ");
315+ fprintf(stderr, "no such function ");
318316 printid(stderr, 0xA1C929000000000LLU);
319317 fprintf(stderr, "\n");
320318 exit(-1);
@@ -640,8 +638,6 @@
640638
641639 printf(" *list = next;\n");
642640
643- printf("\n");
644-
645641 printf("}\n");
646642
647643 printf("\n");
@@ -676,8 +672,6 @@
676672
677673 printf(" }\n");
678674
679- printf("\n");
680-
681675 printf("}\n");
682676
683677 printf("\n");
@@ -733,14 +727,19 @@
733727
734728 break;
735729 }
736- case 0xADCB6E827AAAAC0LLU:
730+ case 0xADCB6E81F821B80LLU:
737731 {
738732
739- uint64_t *tmpaddr = &memory[memory[state.stackbase + 0]];
740- uint64_t *fndefs = &memory[memory[state.stackbase + 1]];
741- uint32_t c = 0;
742- while((c = (uint32_t)getchar()) <= 255)
733+ memory[state.stackbase + 2] = 0x0LLU;
734+
735+ memory[state.stackbase + 3] = 0x0LLU;
736+
737+ uint64_t *blocklist = &memory[state.stackbase + 2];
738+ while((memory[state.stackbase + 3] = (uint64_t)getchar()) <= 255)
743739 {
740+ uint32_t c = (uint32_t)memory[state.stackbase + 3];
741+ uint64_t *tmpaddr = &memory[memory[state.stackbase + 0]];
742+ uint64_t *fndefs = &memory[memory[state.stackbase + 1]];
744743 if(isalpha(c))
745744 {
746745 ungetc(c, stdin);
@@ -784,21 +783,54 @@
784783 while((c = getchar()) != '\n')
785784 ; // skip line
786785 }
787- else if('}' == c)
786+ else if('{' == c)
788787 {
788+ const uint64_t preaddr = --*tmpaddr;
789+ const uint64_t postaddr = --*tmpaddr;
790+ list_push(memory, blocklist, remain_size);
791+ list_push(memory, blocklist, preaddr);
792+ list_push(memory, blocklist, postaddr);
793+
794+ printf(" state.addr = 0x%0llXLLU;\n", (unsigned long long)preaddr);
789795 printf("\n");
790- printf(" state.addr = memory[--state.stackbase];\n");
791- printf(" state.stackbase = memory[state.stackbase - 1];\n");
792- printf("\n");
793796 printf(" break;\n");
794797 printf(" }\n");
798+ printf(" case 0x%0llXLLU:\n", (unsigned long long)preaddr);
799+ printf(" {\n");
800+ }
801+ else if('}' == c)
802+ {
803+ if(*blocklist)
804+ {
805+ uint64_t preaddr = 0;
806+ uint64_t postaddr = 0;
807+ list_pop(memory, blocklist, &postaddr);
808+ list_pop(memory, blocklist, &preaddr);
809+ list_pop(memory, blocklist, &remain_size);
795810
796- break;
811+ printf(" state.addr = 0x%0llXLLU;\n", (unsigned long long)postaddr);
812+ printf("\n");
813+ printf(" break;\n");
814+ printf(" }\n");
815+ printf(" case 0x%0llXLLU:\n", (unsigned long long)postaddr);
816+ printf(" {\n");
817+ }
818+ else
819+ {
820+ printf("\n");
821+ printf(" state.addr = memory[--state.stackbase];\n");
822+ printf(" state.stackbase = memory[state.stackbase - 1];\n");
823+ printf("\n");
824+ printf(" break;\n");
825+ printf(" }\n");
826+
827+ break;
828+ }
797829 }
798830 else if(isalpha(c))
799831 {
800832 ungetc(c, stdin);
801- const uint64_t id = parseid();
833+ uint64_t id = parseid();
802834
803835 /*if(0xB60BB09EF000000LLU == id) // result
804836 {
@@ -1015,7 +1047,7 @@
10151047 skipws();
10161048 matchid(")");
10171049 }
1018- else
1050+ else // CALL
10191051 {
10201052 uint64_t callee_id = 0;
10211053 uint64_t callee_arg_count = 0;
@@ -1076,12 +1108,11 @@
10761108 uint64_t arg_offset = 0;
10771109 for(uint64_t i = 0; i < callee_arg_count; i++)
10781110 {
1079- uint64_t par_size = 1; // XXX TODO: MAP SIZE XXX
10801111 skipws();
10811112 matchid("#");
10821113 uint64_t argnr = parsenr();
10831114 printf(" memory[state.stackbase + %llu] = state.stackbase + %llu;\n", (unsigned long long)(stackbase_offset + arg_offset), (unsigned long long)(argnr));
1084- arg_offset += par_size;
1115+ ++arg_offset;
10851116 }
10861117 printf(" state.stackbase += %llu;\n", (unsigned long long)stackbase_offset);
10871118
@@ -1314,7 +1345,7 @@
13141345 memory[state.stackbase + 7] = state.stackbase + 3;
13151346 memory[state.stackbase + 8] = state.stackbase + 4;
13161347 state.stackbase += 7;
1317- state.addr = 0xADCB6E827AAAAC0LLU;
1348+ state.addr = 0xADCB6E81F821B80LLU;
13181349
13191350 break;
13201351 }
--- trunk/experimental_memfix/compiler.source.c (revision 537)
+++ trunk/experimental_memfix/compiler.source.c (revision 538)
@@ -124,7 +124,7 @@
124124 }
125125 if(!defref)
126126 {
127- fprintf(stderr, "no such function! ");
127+ fprintf(stderr, "no such function ");
128128 printid(stderr, 0xA1C929000000000LLU);
129129 fprintf(stderr, "\n");
130130 exit(-1);
@@ -310,7 +310,6 @@
310310 print(" memory[*list + 1] = 0;\n") // clear previously stored element (TODO: call destructor in case of nested lists!)
311311 print(" memory[1] = *list;\n") // update free-list
312312 print(" *list = next;\n") // continue
313- print("\n")
314313 print("}\n")
315314 print("\n")
316315 print("void list_free(uint64_t *memory, uint64_t *list)\n") // TODO: destructor-argument for nested lists
@@ -328,7 +327,6 @@
328327 print(" memory[1] = *list;\n") // update free-list
329328 print(" *list = next;\n") // continue
330329 print(" }\n")
331- print("\n")
332330 print("}\n")
333331 print("\n")
334332 print("void init(struct state *state, uint64_t *memory);\n")
@@ -371,14 +369,20 @@
371369 `
372370 }
373371
374-parseloop(2)
372+parsedefs(2) 2
375373 {
374+==2== // scope
375+ let # = 0
376+==3== // c
377+ let # = 0
378+==4==
376379 `
377- uint64_t *tmpaddr = &memory[memory[state.stackbase + 0]];
378- uint64_t *fndefs = &memory[memory[state.stackbase + 1]];
379- uint32_t c = 0;
380- while((c = (uint32_t)getchar()) <= 255)
380+ uint64_t *blocklist = &memory[state.stackbase + 2];
381+ while((memory[state.stackbase + 3] = (uint64_t)getchar()) <= 255)
381382 {
383+ uint32_t c = (uint32_t)memory[state.stackbase + 3];
384+ uint64_t *tmpaddr = &memory[memory[state.stackbase + 0]];
385+ uint64_t *fndefs = &memory[memory[state.stackbase + 1]];
382386 if(isalpha(c))
383387 {
384388 ungetc(c, stdin);
@@ -422,21 +426,54 @@
422426 while((c = getchar()) != '\n')
423427 ; // skip line
424428 }
425- else if('}' == c)
429+ else if('{' == c)
426430 {
431+ const uint64_t preaddr = --*tmpaddr;
432+ const uint64_t postaddr = --*tmpaddr;
433+ list_push(memory, blocklist, remain_size);
434+ list_push(memory, blocklist, preaddr);
435+ list_push(memory, blocklist, postaddr);
436+
437+ printf(" state.addr = 0x%0llXLLU;\n", (unsigned long long)preaddr);
427438 printf("\n");
428- printf(" state.addr = memory[--state.stackbase];\n");
429- printf(" state.stackbase = memory[state.stackbase - 1];\n");
430- printf("\n");
431439 printf(" break;\n");
432440 printf(" }\n");
441+ printf(" case 0x%0llXLLU:\n", (unsigned long long)preaddr);
442+ printf(" {\n");
443+ }
444+ else if('}' == c)
445+ {
446+ if(*blocklist)
447+ {
448+ uint64_t preaddr = 0;
449+ uint64_t postaddr = 0;
450+ list_pop(memory, blocklist, &postaddr);
451+ list_pop(memory, blocklist, &preaddr);
452+ list_pop(memory, blocklist, &remain_size);
433453
434- break;
454+ printf(" state.addr = 0x%0llXLLU;\n", (unsigned long long)postaddr);
455+ printf("\n");
456+ printf(" break;\n");
457+ printf(" }\n");
458+ printf(" case 0x%0llXLLU:\n", (unsigned long long)postaddr);
459+ printf(" {\n");
460+ }
461+ else
462+ {
463+ printf("\n");
464+ printf(" state.addr = memory[--state.stackbase];\n");
465+ printf(" state.stackbase = memory[state.stackbase - 1];\n");
466+ printf("\n");
467+ printf(" break;\n");
468+ printf(" }\n");
469+
470+ break;
471+ }
435472 }
436473 else if(isalpha(c))
437474 {
438475 ungetc(c, stdin);
439- const uint64_t id = parseid();
476+ uint64_t id = parseid();
440477
441478 /*if(0xB60BB09EF000000LLU == id) // result
442479 {
@@ -653,7 +690,7 @@
653690 skipws();
654691 matchid(")");
655692 }
656- else
693+ else // CALL
657694 {
658695 uint64_t callee_id = 0;
659696 uint64_t callee_arg_count = 0;
@@ -714,12 +751,11 @@
714751 uint64_t arg_offset = 0;
715752 for(uint64_t i = 0; i < callee_arg_count; i++)
716753 {
717- uint64_t par_size = 1; // XXX TODO: MAP SIZE XXX
718754 skipws();
719755 matchid("#");
720756 uint64_t argnr = parsenr();
721757 printf(" memory[state.stackbase + %llu] = state.stackbase + %llu;\n", (unsigned long long)(stackbase_offset + arg_offset), (unsigned long long)(argnr));
722- arg_offset += par_size;
758+ ++arg_offset;
723759 }
724760 printf(" state.stackbase += %llu;\n", (unsigned long long)stackbase_offset);
725761
@@ -814,7 +850,7 @@
814850 print(" {\n")
815851 print(" switch(state.addr)\n")
816852 print(" {\n")
817- parseloop(#3 #4)
853+ parsedefs(#3 #4)
818854 print(" default:\n")
819855 print(" {\n")
820856 print(" fprintf(stderr, \"no such addr %%llu\\n\", (unsigned long long)state.addr);\n")
旧リポジトリブラウザで表示