From: Tony v. d. H. <to...@us...> - 2004-05-03 15:04:19
|
Update of /cvsroot/ro-oslib/OSLib/!OsLib/Tools/DefMod2/defmod/sources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13995/!OsLib/Tools/DefMod2/defmod/sources Modified Files: cheader.c cstrong.c defmod.y hdr.c objasm.c Log Message: merged Unix-Build back into trunk (20040503-1) Index: defmod.y =================================================================== RCS file: /cvsroot/ro-oslib/OSLib/!OsLib/Tools/DefMod2/defmod/sources/defmod.y,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** defmod.y 14 Jan 2004 12:29:55 -0000 1.3 --- defmod.y 3 May 2004 15:03:33 -0000 1.4 *************** *** 32,38 **** --- 32,40 ---- /*From CLib*/ #include <ctype.h> + #include <errno.h> #include <stddef.h> #include <stdlib.h> #include <string.h> + #include <kernel.h> #include <swis.h> *************** *** 179,184 **** { os_error *error; if ((error = lookup_insert (needses, $1, NULL)) != NULL) ! { yyerror (error->errmess); YYERROR; } --- 181,189 ---- { os_error *error; + tracef( "needs: Inserting \"%s\"\n" _ $1 ); if ((error = lookup_insert (needses, $1, NULL)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 190,195 **** { os_error *error; if ((error = lookup_insert (needsatends, $1, NULL)) != NULL) ! { yyerror (error->errmess); YYERROR; } --- 195,203 ---- { os_error *error; + tracef( "needsatend: Inserting \"%s\"\n" _ $1 ); if ((error = lookup_insert (needsatends, $1, NULL)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 201,204 **** --- 209,213 ---- ID EQUALS type COLON const DESCRIPTION_OPTION { os_error *error; + tracef( "const_defn\n"); def_c c = qalloc (sizeof *c); def_t t = qalloc (def_sizeof_TYPE ($3.tag)); *************** *** 209,214 **** c->description = EMPTY ($6)? NULL: qstrdup ($6); if ((error = lookup_insert (consts, $1, c)) != NULL) ! { yyerror (error->errmess); YYERROR; } --- 218,226 ---- c->description = EMPTY ($6)? NULL: qstrdup ($6); + tracef( "Inserting \"%s\"\n" _ $1 ); if ((error = lookup_insert (consts, $1, c)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 221,226 **** def_c c; if ((error = lookup (consts, $1, (void **) &c)) != NULL) ! { yyerror (error->errmess); YYERROR; } --- 233,241 ---- def_c c; + tracef( "const: looking up: \"%s\"\n" _ $1 ); if ((error = lookup (consts, $1, (void **) &c)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 242,245 **** --- 257,261 ---- ID DESCRIPTION_OPTION { os_error *error; + tracef( "type_defn\n" ); def_t t = qalloc (def_sizeof_TYPE (def_TYPE_ABSTRACT)); *************** *** 249,254 **** t->description = EMPTY ($2)? NULL: qstrdup ($2); if ((error = lookup_insert (types, $1, t)) != NULL) ! { yyerror (error->errmess); YYERROR; } --- 265,273 ---- t->description = EMPTY ($2)? NULL: qstrdup ($2); + tracef( "Inserting \"%s\"\n" _ $1 ); if ((error = lookup_insert (types, $1, t)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 256,259 **** --- 275,279 ---- ID EQUALS type DESCRIPTION_OPTION { os_error *error; + tracef( "type_defn\n" ); def_t t = qalloc (def_sizeof_TYPE ($3.tag)); *************** *** 261,266 **** t->description = EMPTY ($4)? NULL: qstrdup ($4); if ((error = lookup_insert (types, $1, t)) != NULL) ! { yyerror (error->errmess); YYERROR; } --- 281,289 ---- t->description = EMPTY ($4)? NULL: qstrdup ($4); + tracef( "Inserting \"%s\"\n" _ $1 ); if ((error = lookup_insert (types, $1, t)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 274,280 **** def_t t; if ((error = lookup (types, $2, (void **) &t)) != NULL && error->errnum != os_GLOBAL_NO_ANY) ! { yyerror (error->errmess); YYERROR; } --- 297,306 ---- def_t t; + tracef( "base_type: looking up: \"%s\"\n" _ $2 ); if ((error = lookup (types, $2, (void **) &t)) != NULL && error->errnum != os_GLOBAL_NO_ANY) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 318,322 **** $$.value = def_VALUE_REGISTER; $$.description = NULL;} | REF type ! { def_t t = qalloc (def_sizeof_TYPE ($2.tag)); memcpy (t, &$2, def_sizeof_TYPE ($2.tag)); --- 344,350 ---- $$.value = def_VALUE_REGISTER; $$.description = NULL;} | REF type ! { ! tracef( "type\n" ); ! def_t t = qalloc (def_sizeof_TYPE ($2.tag)); memcpy (t, &$2, def_sizeof_TYPE ($2.tag)); *************** *** 345,349 **** $$.description = NULL; if ($2.tag != def_TYPE_VOID) ! { $$.data AS list.base = qalloc (def_sizeof_TYPE ($2.tag)); memcpy ($$.data AS list.base, &$2, def_sizeof_TYPE ($2.tag)); } --- 373,379 ---- $$.description = NULL; if ($2.tag != def_TYPE_VOID) ! { ! tracef( "type\n" ); ! $$.data AS list.base = qalloc (def_sizeof_TYPE ($2.tag)); memcpy ($$.data AS list.base, &$2, def_sizeof_TYPE ($2.tag)); } *************** *** 358,362 **** } | SUB const BUS type ! { def_t t = qalloc (def_sizeof_TYPE ($4.tag)); if ($4.value == def_VALUE_VARIABLE) --- 388,394 ---- } | SUB const BUS type ! { ! tracef( "type\n" ); ! def_t t = qalloc (def_sizeof_TYPE ($4.tag)); if ($4.value == def_VALUE_VARIABLE) *************** *** 379,385 **** def_t t; if ((error = lookup (types, $1, (void **) &t)) != NULL && error->errnum != os_GLOBAL_NO_ANY) ! { yyerror (error->errmess); YYERROR; } --- 411,420 ---- def_t t; + tracef( "type: looking up ID: \"%s\"\n" _ $1 ); if ((error = lookup (types, $1, (void **) &t)) != NULL && error->errnum != os_GLOBAL_NO_ANY) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 390,393 **** --- 425,429 ---- { /*have to make an optimistic assumption*/ $$.value = def_VALUE_REGISTER; + tracef( "type \"%s\" undefined\n" _ $1 ); if (Verbose && !Quiet) fprintf (stderr, "warning: type \"%s\" undefined at line " *************** *** 398,401 **** --- 434,439 ---- $$.description = NULL; strcpy ($$.data AS id, $1); + + tracef( "type: ID done\n" ); }; *************** *** 404,408 **** typed_var: type COLON ID DESCRIPTION_OPTION ! { $$ = $1; $$.name = qstrdup ($3); $$.description = EMPTY ($4)? NULL: qstrdup ($4); --- 442,448 ---- typed_var: type COLON ID DESCRIPTION_OPTION ! { ! tracef( "type\n" ); ! $$ = $1; $$.name = qstrdup ($3); $$.description = EMPTY ($4)? NULL: qstrdup ($4); *************** *** 410,414 **** toided_var: toid COLON ID DESCRIPTION_OPTION ! { $$ = $1; $$.name = qstrdup ($3); $$.description = EMPTY ($4)? NULL: qstrdup ($4); --- 450,456 ---- toided_var: toid COLON ID DESCRIPTION_OPTION ! { ! tracef( "type\n" ); ! $$ = $1; $$.name = qstrdup ($3); $$.description = EMPTY ($4)? NULL: qstrdup ($4); *************** *** 420,429 **** ID EQUALS swi { os_error *error; def_s s = qalloc (sizeof *s); *s = $3; if ((error = lookup_insert (swis, $1, s)) != NULL) ! { yyerror (error->errmess); YYERROR; } --- 462,475 ---- ID EQUALS swi { os_error *error; + tracef( "type\n" ); def_s s = qalloc (sizeof *s); *s = $3; + tracef( "Inserting \"%s\"\n" _ $1 ); if ((error = lookup_insert (swis, $1, s)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! yyerror (error->errmess); YYERROR; } *************** *** 447,452 **** entry_condition: REG CONTAINS typed_var ! { if ($3.value != def_VALUE_REGISTER) ! { yyerror ("type cannot occur in a register"); YYERROR; } --- 493,502 ---- entry_condition: REG CONTAINS typed_var ! { ! tracef( "entry_condition\n" ); ! if ($3.value != def_VALUE_REGISTER) ! { ! tracef( "Error: type cannot occur in a register\n" ); ! yyerror ("type cannot occur in a register"); YYERROR; } *************** *** 454,461 **** $$.i |= 1 << $1; $$.inputs [$1] = qalloc (def_sizeof_TYPE ($3.tag)); memcpy ($$.inputs [$1], &$3, def_sizeof_TYPE ($3.tag)); } | REG REFERENCES typed_var ! { $$ = Empty; $$.i |= 1 << $1; $$.ri |= 1 << $1; --- 504,515 ---- $$.i |= 1 << $1; $$.inputs [$1] = qalloc (def_sizeof_TYPE ($3.tag)); + tracef( "memcpy to 0x%x\n" _ $$.inputs [$1] ); memcpy ($$.inputs [$1], &$3, def_sizeof_TYPE ($3.tag)); + tracef( "done\n" ); } | REG REFERENCES typed_var ! { ! tracef( "entry_condition\n" ); ! $$ = Empty; $$.i |= 1 << $1; $$.ri |= 1 << $1; *************** *** 463,467 **** memcpy ($$.inputs [$1], &$3, def_sizeof_TYPE ($3.tag)); } | - /* REG CONSTANT NUM description_OPTION */ /* TV 990418 */ REG CONSTANT const description_OPTION { $$ = $4; --- 517,520 ---- *************** *** 473,477 **** } | REG DISJOINS typed_var ! { if ($3.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; --- 526,532 ---- } | REG DISJOINS typed_var ! { ! tracef( "entry_condition\n" ); ! if ($3.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; *************** *** 488,492 **** } | REG ADDS typed_var ! { if ($3.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; --- 543,549 ---- } | REG ADDS typed_var ! { ! tracef( "entry_condition\n" ); ! if ($3.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; *************** *** 499,503 **** } | REG EXCLUSIVELY_DISJOINS typed_var ! { if ($3.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; --- 556,562 ---- } | REG EXCLUSIVELY_DISJOINS typed_var ! { ! tracef( "entry_condition\n" ); ! if ($3.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; *************** *** 516,520 **** exit_condition: REG pling_OPTION CONTAINS typed_var ! { if ($4.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; --- 575,581 ---- exit_condition: REG pling_OPTION CONTAINS typed_var ! { ! tracef( "exit_condition\n" ); ! if ($4.value != def_VALUE_REGISTER) { yyerror ("type cannot occur in a register"); YYERROR; *************** *** 527,531 **** } | REG pling_OPTION REFERENCES typed_var ! { $$ = Empty; if ($2) $$.value = 1 << $1; $$.o |= 1 << $1; --- 588,594 ---- } | REG pling_OPTION REFERENCES typed_var ! { ! tracef( "exit_condition\n" ); ! $$ = Empty; if ($2) $$.value = 1 << $1; $$.o |= 1 << $1; *************** *** 568,573 **** TITLE: t i t l e ws {tracef ("TITLE\n");}; AUTHOR: a u t h o r ws {tracef ("AUTHOR\n");}; - /* TV 20021116 fix the 16 shift/reduce errors - NEEDS: n e e d s ws {tracef ("NEEDS\n");};*/ NEEDS: n e e d s ws_item_SEQUENCE {tracef ("NEEDS\n");}; NEEDSATEND: n e e d s a t e n d ws {tracef ("NEEDSATEND\n");}; --- 631,634 ---- *************** *** 961,971 **** /* perform a malloc with error checking */ void *qalloc (size_t t) ! { void *p; ! if ((p = malloc (t)) == NULL) ! { yyerror ("not enough memory for |qalloc()|"); exit (1); } return p; } --- 1022,1036 ---- /* perform a malloc with error checking */ void *qalloc (size_t t) ! { void *p = 0; ! //tracef( "qalloc(0x%x)\n" _ t ); ! p = malloc (t); ! if (!p) ! { ! yyerror ("not enough memory for |qalloc()|"); exit (1); } + //tracef( "qalloc returns 0x%x\n" _ p ); return p; } *************** *** 1031,1034 **** --- 1096,1112 ---- trace_initialise ("Trace$To"); + #if TRACE + { + int ii; + tracef( "Main:" ); + for ( ii = 0; ii<argc; ++ii ) + { + os_writec( ' ' ); + os_write0( argv[ii] ); + } + os_new_line(); + } + #endif + if ( (error = lookup_new (&needses, 16)) != NULL || (error = lookup_new (&needsatends, 16)) != NULL || *************** *** 1038,1042 **** (error = lookup_new (&main_byte_wide, 16)) != NULL ) ! goto finish; yydebug = 0; --- 1116,1123 ---- (error = lookup_new (&main_byte_wide, 16)) != NULL ) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! goto finish; ! } yydebug = 0; *************** *** 1108,1116 **** "\t-s\t\t" "ObjAsm source file\r"; ! if ((error = xos_pretty_print (helptext, NULL, NULL)) != NULL) ! goto finish; } else if (strcmp (argv [i], "-byte_wide") == 0) ! { /*Add the contents of the given file to the byte wide table.*/ char buffer [256], *cc; #ifdef EXECUTE_ON_UNIX --- 1189,1198 ---- "\t-s\t\t" "ObjAsm source file\r"; ! if ((error = xos_pretty_print (helptext, NULL, NULL)) != NULL) ! goto finish; } else if (strcmp (argv [i], "-byte_wide") == 0) ! { ! /*Add the contents of the given file to the byte wide table.*/ char buffer [256], *cc; #ifdef EXECUTE_ON_UNIX *************** *** 1119,1122 **** --- 1201,1205 ---- bits psr; int f; + bits psr; #endif enum {Copying, Skipping} state = Skipping; *************** *** 1124,1127 **** --- 1207,1212 ---- i++; + // tracef( "Main opening file: %s\n" _ argv[i] ); + #ifdef EXECUTE_ON_UNIX if ((f = fopen(argv[i],"r")) == NULL) { *************** *** 1142,1146 **** #ifdef EXECUTE_ON_UNIX *cc = c = getc(f); ! if (ferror(f)) { error = (os_error *)_kernel_last_oserror(); goto finish; --- 1227,1233 ---- #ifdef EXECUTE_ON_UNIX *cc = c = getc(f); ! if (ferror(f)) ! { ! // tracef( "Error reading character from input stream: %d\n" _ errno ); error = (os_error *)_kernel_last_oserror(); goto finish; *************** *** 1156,1159 **** --- 1243,1248 ---- #endif + // tracef( "State = %d\n" _ state ); + switch (state) { case Skipping: *************** *** 1169,1177 **** else { *cc = '\0'; ! if ((error = lookup_insert (main_byte_wide, buffer, (void *) 1)) != NULL) ! goto finish; ! cc = buffer; state = Skipping; --- 1258,1269 ---- else { *cc = '\0'; ! tracef( "Inserting \"%s\"\n" _ buffer ); if ((error = lookup_insert (main_byte_wide, buffer, (void *) 1)) != NULL) ! { ! tracef( "Error %s\n" _ error -> errmess ); ! goto finish; ! } ! tracef( "Done: \"%s\"\n" _ buffer ); cc = buffer; state = Skipping; *************** *** 1204,1216 **** if (option == None) ! { Parse_Error = TRUE; goto finish; } yyparse (); ! if (Parse_Error) goto finish; switch (option) { case Objasm: if ((error = objasm_output (stdout, Title, Author, needses, needsatends, consts, types, swis, /*separate?*/ FALSE, --- 1296,1316 ---- if (option == None) ! { ! tracef( "Parse error: No option\n" ); ! Parse_Error = TRUE; goto finish; } + tracef( "yyparse\n" ); yyparse (); ! if (Parse_Error) ! { ! tracef( "yyparse error\n" ); ! goto finish; ! } switch (option) { case Objasm: + tracef( "Objasm\n" ); if ((error = objasm_output (stdout, Title, Author, needses, needsatends, consts, types, swis, /*separate?*/ FALSE, *************** *** 1220,1223 **** --- 1320,1324 ---- case C_Header: + tracef( "C_Header\n" ); if ((error = cheader_output (stdout, Title, Author, needses, needsatends, consts, types, swis, /*C++?*/ FALSE)) != NULL) *************** *** 1226,1229 **** --- 1327,1331 ---- case C_Plus_Plus_Header: + tracef( "C_Plus_Plus_Header\n" ); if ((error = cheader_output (stdout, Title, Author, needses, needsatends, consts, types, swis, /*C++?*/ TRUE)) != NULL) *************** *** 1232,1235 **** --- 1334,1338 ---- case C_Help: + tracef( "C_Help\n" ); if ((error = chelp_output (stdout, Title, Author, needses, needsatends, consts, types, swis)) != NULL) *************** *** 1238,1241 **** --- 1341,1345 ---- case Asm_Help: + tracef( "Asm_Help\n" ); if ((error = asmhelp_output (stdout, Title, Author, needses, needsatends, consts, types, swis)) != NULL) *************** *** 1244,1247 **** --- 1348,1352 ---- case Library: + tracef( "Library\n" ); if (output != NULL) if ((error = objasm_output (SKIP, Title, Author, needses, *************** *** 1253,1256 **** --- 1358,1362 ---- case Hdr: + tracef( "Hdr\n" ); if ((error = hdr_output (stdout, Title, Author, needses, needsatends, consts, types, swis)) != NULL) *************** *** 1259,1262 **** --- 1365,1369 ---- case C_Strong: + tracef( "C_Strong\n" ); if (output != NULL) if ((error = cstrong_output (output, Title, Author, needses, *************** *** 1266,1270 **** default: ! break; } --- 1373,1378 ---- default: ! tracef( "default\n" ); ! break; } *************** *** 1287,1292 **** */ int yylex (void) ! { int c; return (c = getchar ()) == EOF? --- 1395,1402 ---- */ int yylex (void) ! { ! int c; + #if 0 return (c = getchar ()) == EOF? *************** *** 1308,1311 **** --- 1418,1448 ---- c ); + #else + c = getchar (); + if ( c == EOF ) c = 0; + + if ( Verbose /* && (c != 0) */ ) + { + if ( ' ' <= c && c <= '~' ) + fputc( c, stderr ); + else if ( c == '\n' ) + { + fputc ('\n', stderr); + fputc ('\r', stderr); + } + else + { + fputc ('\\', stderr); + fputc ('x', stderr); + fputc (UCHAR (c/0x10), stderr); + fputc (UCHAR (c%0x10), stderr); + } + } + + if ( c == 0 ) + tracef( "\nyylex: End of file\n" ); + + return c; + #endif } Index: objasm.c =================================================================== RCS file: /cvsroot/ro-oslib/OSLib/!OsLib/Tools/DefMod2/defmod/sources/objasm.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** objasm.c 14 Jan 2004 12:29:55 -0000 1.2 --- objasm.c 3 May 2004 15:03:33 -0000 1.3 *************** *** 21,24 **** --- 21,45 ---- */ + #undef ASSEMBLER + + #define OBJASM 1 + #define GCC 2 + #define ARMASM 3 + + #if (defined USE_OBJASM) && !(defined USE_GCC) && !(defined USE_ARMASM) + #define ASSEMBLER OBJASM + #elif !(defined USE_OBJASM) && (defined USE_GCC) && !(defined USE_ARMASM) + #define ASSEMBLER GCC + #elif !(defined USE_OBJASM) && !(defined USE_GCC) && (defined USE_ARMASM) + #define ASSEMBLER ARMASM + #endif + + #ifndef ASSEMBLER + #error Target Assembler Undefined + #endif + + #undef TRACE + #define TRACE 0 + /*From CLib*/ #include <ctype.h> *************** *** 45,56 **** #define MEM_FOR_OBJASM (1024*1024) - #if 0 - #ifdef EXECUTE_ON_UNIX - # define ASMCMD "armasm" - #else - # define ASMCMD "ObjAsm" - #endif - #endif - static char *Local; --- 66,69 ---- *************** *** 672,676 **** { if (!nonx) ! if ((rc = Emit1 (file, "BVS", "%99")) < 0) goto finish; --- 685,689 ---- { if (!nonx) ! if ((rc = Emit1 (file, "BVS", "%a99")) < 0) goto finish; *************** *** 1008,1012 **** #endif ! #ifndef EXECUTE_ON_UNIX if ((via_file = fopen ("ViaFile", "w+")) == NULL) { --- 1021,1025 ---- #endif ! //#ifndef EXECUTE_ON_UNIX if ((via_file = fopen ("ViaFile", "w+")) == NULL) { *************** *** 1015,1019 **** } done_fopen_via_file = TRUE; ! #endif context = 0; --- 1028,1032 ---- } done_fopen_via_file = TRUE; ! //#endif context = 0; *************** *** 1113,1129 **** done_fopen_object = FALSE; ! #if 0 ! if ((rc = sprintf (cmd, "ObjAsm -from %s.%s -to %s.%s " ! "-stamp -quit -apcs 3/%dbit/SWstackcheck", prefix_dir, ! name1, prefix_dir, name2, apcs32 ? 32 : 26)) ! < 0) ! goto finish; ! #elif 0 ! if ((rc = sprintf (cmd, ASMCMD " -from %s -to %s " ! "-stamp -quit -apcs 3/%dbit/SWstackcheck", name1, name2, apcs32 ? 32 : 26)) < 0) goto finish; ! #else ! if ((rc = sprintf (cmd, STR(ASMCMD) " -from %s -to %s " "-apcs 3/%dbit/SWstackcheck", name1, name2, apcs32 ? 32 : 26)) < 0) --- 1126,1144 ---- done_fopen_object = FALSE; ! #if ASSEMBLER == GCC ! if ((rc = sprintf( cmd, ! "gcc -c -xassembler -Wa,-objasm%s -o %s %s", ! apcs32 ? ",-apcs32,-target,SA110" : ",-apcs26", ! name2, name1)) < 0) ! goto finish; ! ! #elif ASSEMBLER == OBJASM ! if ((rc = sprintf (cmd, "ObjAsm -from %s -to %s " ! "-apcs 3/%dbit/SWstackcheck", name1, name2, apcs32 ? 32 : 26)) < 0) goto finish; ! ! #elif ASSEMBLER == ARMASM ! if ((rc = sprintf (cmd, "armasm -from %s -to %s " "-apcs 3/%dbit/SWstackcheck", name1, name2, apcs32 ? 32 : 26)) < 0) *************** *** 1133,1137 **** tracef ("%s ...\n" _ cmd); if (!Quiet) ! if ((rc = printf ("Assembling %s\n", name1)) < 0) goto finish; --- 1148,1152 ---- tracef ("%s ...\n" _ cmd); if (!Quiet) ! if ((rc = printf ("%s\n", cmd)) < 0) goto finish; Index: hdr.c =================================================================== RCS file: /cvsroot/ro-oslib/OSLib/!OsLib/Tools/DefMod2/defmod/sources/hdr.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** hdr.c 14 Jan 2004 12:29:55 -0000 1.4 --- hdr.c 3 May 2004 15:03:33 -0000 1.5 *************** *** 21,24 **** --- 21,27 ---- Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, U S A. */ + #ifndef TRACE + #define TRACE 0 + #endif #include <ctype.h> *************** *** 33,36 **** --- 36,40 ---- #include "lookup.h" + #include "trace.h" #include "def.h" *************** *** 157,160 **** --- 161,198 ---- } + /* Prints a declaration of |v| as an object of type |t|. + called by Emit_Decl + */ + static int Emit_Decl1 + ( + FILE *file, // output file + char *type, // object type + char *v, // object name + osbool top_level, // if true then equate, else assign storage + char *cs // number of elements in array + ) + { + int rc = 0; + + tracef( "Emit_Decl1: %s; %s; %s\n" _ v _ type _ top_level?"TRUE":"FALSE" ); + + if ( top_level ) + { + if ((rc = EmitD (file, "", "^", 0)) < 0) + goto finish; + if ((rc = EmitSS (file, "", "#", cs, type)) < 0) + goto finish; + if ((rc = EmitS (file, v, "*", "@")) < 0) + goto finish; + } + else + { + if ((rc = EmitSS (file, v, "#", cs, type)) < 0) + goto finish; + } + + finish: + return rc; + } /* Prints a declaration of |v| as an object of type |t|.*/ *************** *** 180,224 **** { case def_TYPE_INT: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Int")) < 0) goto finish; break; case def_TYPE_SHORT: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Short")) < 0) goto finish; break; case def_TYPE_BYTE: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Byte")) < 0) goto finish; break; case def_TYPE_CHAR: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Char")) < 0) goto finish; break; case def_TYPE_BITS: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Bits")) < 0) goto finish; break; case def_TYPE_BYTES: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Bytes")) < 0) goto finish; break; case def_TYPE_BOOL: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Bool")) < 0) goto finish; break; case def_TYPE_REF: ! if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Ptr")) < 0) goto finish; break; ! case def_TYPE_STRING: case def_TYPE_ASM: case def_TYPE_DATA: case ! def_TYPE_VOID: if ((rc = EmitS (file, v, top_level? "*": "#", "Skip")) < 0) goto finish; --- 218,272 ---- { case def_TYPE_INT: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Int")) < 0) ! if (( rc = Emit_Decl1 ( file, "Int", v, top_level, cs )) < 0 ) goto finish; break; case def_TYPE_SHORT: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Short")) < 0) ! if (( rc = Emit_Decl1 ( file, "Short", v, top_level, cs )) < 0 ) goto finish; break; case def_TYPE_BYTE: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Byte")) < 0) ! if (( rc = Emit_Decl1 ( file, "Byte", v, top_level, cs )) < 0 ) goto finish; break; case def_TYPE_CHAR: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Char")) < 0) ! if (( rc = Emit_Decl1 ( file, "Char", v, top_level, cs )) < 0 ) goto finish; break; case def_TYPE_BITS: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Bits")) < 0) ! if (( rc = Emit_Decl1 ( file, "Bits", v, top_level, cs )) < 0 ) goto finish; break; case def_TYPE_BYTES: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Bytes")) < 0) ! if (( rc = Emit_Decl1 ( file, "Bytes", v, top_level, cs )) < 0 ) goto finish; break; case def_TYPE_BOOL: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Bool")) < 0) ! if (( rc = Emit_Decl1 ( file, "Bool", v, top_level, cs )) < 0 ) goto finish; break; case def_TYPE_REF: ! // if ((rc = EmitSS (file, v, top_level? "*": "#", cs, "Ptr")) < 0) ! if (( rc = Emit_Decl1 ( file, "Ptr", v, top_level, cs )) < 0 ) goto finish; break; ! case def_TYPE_STRING: ! case def_TYPE_ASM: ! case def_TYPE_DATA: ! case def_TYPE_VOID: if ((rc = EmitS (file, v, top_level? "*": "#", "Skip")) < 0) goto finish; *************** *** 250,253 **** --- 298,303 ---- goto finish; + tracef( "Emit_Decl: %s\n" _ v1 ); + if ((rc = Emit_Decl (file, t->data AS list.members [i], v1, FALSE, 0)) < 0) *************** *** 300,303 **** --- 350,354 ---- // recurse to declare each list member + tracef( "Emit_Decl: %s\n" _ v1 ); if ((rc = Emit_Decl (file, t->data AS list.members [i], v1, FALSE, 0)) < 0) goto finish; *************** *** 367,370 **** --- 418,422 ---- goto finish; + tracef( "Emit_Decl: %s\n" _ v1 ); if ((rc = Emit_Decl (file, t->data AS list.members [i], v1, FALSE, 0)) < 0) *************** *** 379,384 **** case def_TYPE_ROW: ! if ((rc = Emit_Decl (file, t->data AS row.base, v, ! FALSE, (count == 0? 1: count)*t->data AS row.count)) < 0) goto finish; break; --- 431,444 ---- case def_TYPE_ROW: ! tracef( "Emit_Decl: %s\n" _ v ); ! #if 0 ! if ((rc = Emit_Decl (file, t->data AS row.base, v, FALSE, ! (count == 0? 1: count)*t->data AS row.count ! )) < 0) ! #else ! if ((rc = Emit_Decl (file, t->data AS row.base, v, top_level, ! (count == 0? 1: count)*t->data AS row.count ! )) < 0) ! #endif goto finish; break; *************** *** 540,544 **** #ifdef EXECUTE_ON_UNIX ! if ((rc = sprintf (s, "\"GET oslib/Hdr/%s\"", name)) < 0) #else if ((rc = sprintf (s, "\"GET oslib.Hdr.%s\"", name)) < 0) --- 600,604 ---- #ifdef EXECUTE_ON_UNIX ! if ((rc = sprintf (s, "\"GET oslib/%s.Hdr\"", name)) < 0) #else if ((rc = sprintf (s, "\"GET oslib.Hdr.%s\"", name)) < 0) *************** *** 665,669 **** --- 725,733 ---- else { + #if 0 if ((rc = sprintf (v1, ":CHR: &%.2X", c->value)) < 0) + #else + if ((rc = sprintf (v1, "&%.2X", c->value)) < 0) + #endif goto finish; } *************** *** 718,721 **** --- 782,786 ---- { /* emit declaration of |type| for non-abstract type |t| */ + tracef( "Emit_Decl: %s\n" _ type ); if ((rc = Emit_Decl (file, t, type, TRUE, 0)) < 0) goto finish; Index: cheader.c =================================================================== RCS file: /cvsroot/ro-oslib/OSLib/!OsLib/Tools/DefMod2/defmod/sources/cheader.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cheader.c 14 Jan 2004 12:29:55 -0000 1.2 --- cheader.c 3 May 2004 15:03:33 -0000 1.3 *************** *** 27,33 **** #include <kernel.h> /* TV 980115 */ #include "oslib/types.h" #include "oslib/macros.h" - #include "oslib/os.h" #include "lookup.h" --- 27,33 ---- #include <kernel.h> /* TV 980115 */ + #include "oslib/os.h" #include "oslib/types.h" #include "oslib/macros.h" #include "lookup.h" Index: cstrong.c =================================================================== RCS file: /cvsroot/ro-oslib/OSLib/!OsLib/Tools/DefMod2/defmod/sources/cstrong.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cstrong.c 14 Jan 2004 12:29:55 -0000 1.2 --- cstrong.c 3 May 2004 15:03:33 -0000 1.3 *************** *** 134,137 **** --- 134,148 ---- } + /****************************************************************/ + /* convert the string to lower case in situ + */ + static char* ToLower( char *string ) + { + char* p; + for ( p = string; *p != '\0'; ++p ) + *p = tolower( *p ); + + return string; + } /****************************************************************/ *************** *** 146,153 **** --- 157,174 ---- { char prefix[ FILENAME_MAX + 1 ]; + + #if 0 /* FILENAME_MAX is only 80 in C:stdio.h */ char data_name[ FILENAME_MAX + 1 ]; + #else + char data_name[ 256 ]; + #endif + FILE *help_data = NULL; char *suffix; + tracef( "open_file: path \"%s"\; name \"%s\"\n" \ + _ path_name _ name \ + ); + /* extract the module name prefix */ suffix = strchr( name, '_' ); *************** *** 155,172 **** if( suffix ) { ! strncat( prefix, name, suffix-name ); } /* ensure the directory exists */ sprintf( data_name, "%s" DIRSEP "%s" SEP, path_name, prefix ); ! tracef( "open_file - creating %s\n" _ data_name ); osfile_create_dir( data_name, 0 ); /* create the file */ sprintf( data_name, "%s" DIRSEP "%s" SEP DIRSEP "%s", path_name, prefix, ! suffix? suffix + 1 : name ); tracef( "open_file - opening %s\n" _ data_name ); --- 176,200 ---- if( suffix ) { ! strncat( prefix, name, suffix - name ); ! ToLower( prefix ); } /* ensure the directory exists */ sprintf( data_name, "%s" DIRSEP "%s" SEP, path_name, prefix ); ! tracef( "open_file - creating dir %s\n" _ data_name ); osfile_create_dir( data_name, 0 ); /* create the file */ + tracef( "path_name: %s\n" \ + "prefix: %s\n" \ + "suffix: %s\n" \ + "name: %s\n" \ + _ path_name _ prefix _ suffix _ name \ + ); sprintf( data_name, "%s" DIRSEP "%s" SEP DIRSEP "%s", path_name, prefix, ! suffix ? suffix + 1 : name ); tracef( "open_file - opening %s\n" _ data_name ); *************** *** 1644,1648 **** if( error ) ! fprintf( stderr, "DefMod CStrong: %d:", error -> errnum ); return error; --- 1672,1676 ---- if( error ) ! fprintf( stderr, "DefMod CStrong: 0x%8x ", error -> errnum ); return error; |