• R/O
  • SSH
  • HTTPS

bif-c: コミット


コミットメタ情報

リビジョン53 (tree)
日時2017-05-29 19:05:26
作者reiisi

ログメッセージ

Simple syntax in makecelltype.c, beginning to remove static i-code lists.

変更サマリ

差分

--- trunk/bif2b_a.c (revision 52)
+++ trunk/bif2b_a.c (revision 53)
@@ -373,7 +373,8 @@
373373 { (natural_t) &hBIF },
374374 { (natural_t) &hDO },
375375 { (natural_t) &hQUERY },
376- { (natural_t) XCOL },
376+ { (natural_t) IIF }
377+};
377378 /*
378379 05970 IF DOCOL
379380 05980 FDB COMP
@@ -386,16 +387,15 @@
386387 06060 FDB SEMIS
387388 06090 *
388389 */
389- { { (natural_t) &hCOMP },
390- { (natural_t) &hZBR },
391- { (natural_t) &hHERE }, /* adr */
392- { (natural_t) &hZERO },
393- { (natural_t) &hCOMMA },
394- { (natural_t) &hLIT },
395- { IF_FLAG },
396- { (natural_t) &hSEMIS }
397- }
398-};
390+void IIF( void )
391+{
392+ ( * --SP ).definitionp = &hZBR;
393+ COMMA();
394+ HERE(); /* mark the adr */
395+ ( * --SP ).integer = 0;
396+ COMMA();
397+ ( * --SP ).integer = IF_FLAG;
398+}
399399 /*
400400 06100 FCC 'ELSE'
401401 06110 FCB MIMM.OR.MCOMP.OR.4
@@ -414,7 +414,8 @@
414414 { (natural_t) &hBIF },
415415 { (natural_t) &hEDITOR },
416416 { 0 },
417- { (natural_t) XCOL },
417+ { (natural_t) IELSE }
418+};
418419 /*
419420 06170 ELSE DOCOL
420421 06172 FDB DUP
@@ -432,20 +433,33 @@
432433 06260 FDB SEMIS
433434 06290 *
434435 */
435- { { (natural_t) &hDUP },
436- { (natural_t) &hLIT },
437- { IF_FLAG },
438- { (natural_t) &hQPAIRS },
439- { (natural_t) &hCOMP },
440- { (natural_t) &hBRANCH },
441- { (natural_t) &hHERE }, /* adr */
442- { (natural_t) &hZERO },
443- { (natural_t) &hCOMMA },
444- { (natural_t) &hROT },
445- { (natural_t) &hFILLIN }, /* IF adr */
446- { (natural_t) &hSWAP }, /* for ENDIF */
447- { (natural_t) &hSEMIS }
448- }
436+void IELSE( void )
437+{
438+ DUP();
439+ ( * --SP ).integer = IF_FLAG;
440+ QPAIRS(); /* Can have an exception here. */
441+ ( * --SP ).definitionp = &hBRANCH;
442+ COMMA();
443+ HERE(); /* mark the adr */
444+ ( * --SP ).integer = 0;
445+ COMMA();
446+ ROT();
447+ FILLIN(); /* IF adr */
448+ SWAP(); /* for ENDIF */
449+}
450+
451+/* Clone ENDIF as THEN:
452+*/
453+static character_t sTHEN[] = "\x4" "THEN";
454+definition_header_s hTHEN =
455+{ { (natural_t) sTHEN },
456+ { MIMM | MCOMP },
457+ { (natural_t) &hELSE },
458+ { MFORE },
459+ { (natural_t) &hBIF },
460+ { (natural_t) 0 },
461+ { (natural_t) 0 },
462+ { (natural_t) IENDIF }
449463 };
450464 /*
451465 06300 FCC 'ENDIF'
@@ -460,12 +474,13 @@
460474 definition_header_s hENDIF =
461475 { { (natural_t) sENDIF },
462476 { MIMM | MCOMP },
463- { (natural_t) &hELSE },
477+ { (natural_t) &hTHEN },
464478 { MFORE },
465479 { (natural_t) &hBIF },
466480 { (natural_t) &hDROP },
467481 { (natural_t) &hFIND },
468- { (natural_t) XCOL },
482+ { (natural_t) IENDIF }
483+};
469484 /*
470485 06370 ENDIF DOCOL
471486 06380 FDB QCOMP
@@ -476,11 +491,13 @@
476491 06470 FDB SEMIS
477492 06490 *
478493 */
479- { { (natural_t) &hQCOMP },
480- { (natural_t) &hLIT },
481- { IF_FLAG },
482- { (natural_t) &hQPAIRS },
483- { (natural_t) &hFILLIN },
484- { (natural_t) &hSEMIS }
485- }
486-};
494+void IENDIF( void )
495+{
496+ QCOMP(); /* Can have an exception here. */
497+ ( * --SP ).integer = IF_FLAG;
498+ QPAIRS(); /* Can have an exception here, too. */
499+ FILLIN();
500+}
501+
502+
503+
--- trunk/bif2b_a.h (revision 52)
+++ trunk/bif2b_a.h (revision 53)
@@ -73,10 +73,15 @@
7373 /* #define IF_FLAG ( 'IFEL' ) */
7474
7575 extern definition_header_s hIF;
76+extern void IIF(void);
7677
7778 extern definition_header_s hELSE;
79+extern void IELSE(void);
7880
7981 extern definition_header_s hENDIF;
82+extern void IENDIF(void);
8083
84+extern definition_header_s hTHEN;
85+extern void ITHEN(void);
8186
8287 #endif /* !defined BIF2B_A_H */
--- trunk/configs/makecelltype.c (revision 52)
+++ trunk/configs/makecelltype.c (revision 53)
@@ -74,7 +74,7 @@
7474 fputs( "/* For now, assuming two's complement: */\n", outfile );
7575 fprintf( outfile, "#define UBYTE_MAX ((ubyte_t) 0x%x)\n", uch );
7676 for ( uch = (ubyte_t) -1, ui = 0;
77- ( ui <= 1024 ) && ( uch != 0 );
77+ ( ui <= 1023 ) && ( uch != 0 );
7878 )
7979 { memory = uch;
8080 uch <<= 1;
@@ -121,7 +121,7 @@
121121 fputs( "/* For now, assuming two's complement: */\n", outfile );
122122 fprintf( outfile, "#define USHORTW_MAX ((ushortw_t) 0x%x)\n", ush );
123123 for ( ush = (ushortw_t) -1, ui = 0;
124- ( ui <= 1024 ) && ( ush != 0 );
124+ ( ui <= 1023 ) && ( ush != 0 );
125125 )
126126 { memory = ush;
127127 ush <<= 1;
@@ -164,7 +164,7 @@
164164 fputs( "/* For now, assuming two's complement: */\n", outfile );
165165 fprintf( outfile, "#define UINTW_MAX ((uintw_t) 0x%x)\n", uiw );
166166 for ( uiw = (uintw_t) -1, ui = 0;
167- ( ui <= 1024 ) && ( uiw != 0 );
167+ ( ui <= 1023 ) && ( uiw != 0 );
168168 )
169169 { memory = uiw;
170170 uiw <<= 1;
@@ -207,7 +207,7 @@
207207 fputs( "/* For now, assuming two's complement: */\n", outfile );
208208 fprintf( outfile, "#define ULONGW_MAX ((ulongw_t) 0x%lxL)\n", ulw );
209209 for ( ulw = (ulongw_t) -1, ui = 0;
210- ( ui <= 1024 ) && ( ulw != 0 );
210+ ( ui <= 1023 ) && ( ulw != 0 );
211211 )
212212 { memory = ulw;
213213 ulw <<= 1;
@@ -261,7 +261,7 @@
261261 fputs( "/* For now, assuming two's complement: */\n", outfile );
262262 fprintf( outfile, "#define ULLONGW_MAX ((ullongw_t) 0x%llxLL)\n", udlw );
263263 for ( udlw = (ullongw_t) -1, ui = 0;
264- ( ui <= 1024 ) && ( udlw != 0 );
264+ ( ui <= 1023 ) && ( udlw != 0 );
265265 )
266266 { memory = udlw;
267267 udlw <<= 1;
@@ -290,8 +290,8 @@
290290 }
291291 else if ( ( sizeof (ulongw_t) * 2 ) != sizeof (ullongw_t) )
292292 { status = -1;
293- fprintf( outfile, "#error \"*** sizeof ullongw_t == %d, sizeof ulongw_t == %d, not double! ***\"\n",
294- sizeof (ullongw_t), sizeof (ulongw_t) );
293+ fprintf( outfile, "#error \"*** sizeof ullongw_t == %u, sizeof ulongw_t == %u, not double! ***\"\n",
294+ (unsigned) sizeof (ullongw_t), (unsigned) sizeof (ulongw_t) );
295295 }
296296 else if ( cellOrder.doublePart == 1 )
297297 { fputs( "#define HIGH_C_CELL_FIRST\n\n\n", outfile );
@@ -345,13 +345,13 @@
345345 {
346346 FILE * headerFile;
347347 FILE * sourceFile;
348- int fileNameLength;
349- int ptrSize = sizeof (icode_f);
348+ size_t fileNameLength;
349+ size_t ptrSize = sizeof (icode_f);
350350 int ptrSizeTypeX = PRVFPTR;
351351 char * cellSizeType = "longw_t";
352352 char * cellSizeString = "LONGW";
353353 int cellSize = sizeof (long);
354- int i;
354+ size_t i;
355355 int exitCode = EXIT_SUCCESS;
356356 typeBits_t typeBits = { 0 };
357357
@@ -359,11 +359,11 @@
359359 if ( argc > 1 )
360360 headerName = argv[ 1 ]; /* No error checking. */
361361 fileNameLength = strlen( headerName );
362- if ( ( sourceName = malloc( fileNameLength + 1 ) ) == NULL )
362+ if ( ( sourceName = (char *) malloc( fileNameLength + 1 ) ) == NULL )
363363 return EXIT_FAILURE;
364364 strncpy( sourceName, headerName, fileNameLength + 1 );
365365 sourceName[ fileNameLength - 1 ] = 'c';
366- if ( ( headerMacro = malloc( fileNameLength + 1 ) ) == NULL )
366+ if ( ( headerMacro = (char *) malloc( fileNameLength + 1 ) ) == NULL )
367367 return EXIT_FAILURE;
368368 for ( i = 0; i < fileNameLength; ++i )
369369 headerMacro[ i ] = toupper( headerName[ i ] );
@@ -388,8 +388,10 @@
388388 fputc( '\n', headerFile );
389389 }
390390
391- /* The source file must include the header file: */
392- fprintf( sourceFile, "#include %s\n", headerName );
391+ /* The source file must include the header file,
392+ // if it ever actually gets compiled, of course:
393+ */
394+ fprintf( sourceFile, "#include \"%s\"\n", headerName );
393395
394396 /* Add the probed pointer types to the header: */
395397 for ( i = 0;
@@ -415,7 +417,7 @@
415417 ptrSizeTypeX = PRVOIDPTR;
416418 }
417419 }
418- fprintf( headerFile, "#define PROBE_POINTER_BYTE %d\n", ptrSize );
420+ fprintf( headerFile, "#define PROBE_POINTER_BYTE %u\n", (unsigned) ptrSize );
419421 /* Assume that the pointer, in memory, is a byte multiple size. */
420422 typeBits.pointerSize = ptrSize * CHAR_BIT;
421423 fprintf( headerFile, "#define PROBE_POINTER_BIT %d\n",
@@ -453,9 +455,9 @@
453455 #endif /* defined ULLONG_MAX */
454456 else
455457 {
456- fprintf( headerFile, "#error \"*** Probed pointer size %d unsatisfiable! ***\"\n", ptrSize );
457- fprintf( sourceFile, "#error \"*** Probed pointer size %d unsatisfiable! ***\"\n", ptrSize );
458- printf( "*** Probed pointer size %d unsatisfiable! ***\n", ptrSize );
458+ fprintf( headerFile, "#error \"*** Probed pointer size %u unsatisfiable! ***\"\n", (unsigned) ptrSize );
459+ fprintf( sourceFile, "#error \"*** Probed pointer size %u unsatisfiable! ***\"\n", (unsigned) ptrSize );
460+ printf( "*** Probed pointer size %u unsatisfiable! ***\n", (unsigned) ptrSize );
459461 exitCode = EXIT_FAILURE;
460462 }
461463 typeBits.cellSize = cellSize * CHAR_BIT;
旧リポジトリブラウザで表示