Annotation of gcc/cp-edsel.c, revision 1.1.1.2

1.1       root        1: /* Interface to LUCID Cadillac system for GNU compiler.
                      2:    Copyright (C) 1988, 1992 Free Software Foundation, Inc.
                      3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: GNU CC is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: #include "config.h"
                     21: 
                     22: #include "tree.h"
                     23: #include "flags.h"
                     24: #include <stdio.h>
                     25: #include "cp-tree.h"
                     26: #include "assert.h"
                     27: #include "obstack.h"
                     28: 
                     29: #ifdef CADILLAC
                     30: #include <compilerreq.h>
                     31: #include <compilerconn.h>
                     32: #include <sys/time.h>
                     33: #include <sys/types.h>
                     34: #include <errno.h>
                     35: #include <sys/file.h>
                     36: 
                     37: #define obstack_chunk_alloc xmalloc
                     38: #define obstack_chunk_free free
                     39: 
                     40: extern int xmalloc ();
                     41: extern void free ();
                     42: 
                     43: void init_cadillac ();
                     44: 
                     45: extern char *input_filename;
                     46: extern int lineno;
                     47: 
                     48: /* Put random information we might want to get back from
                     49:    Cadillac here.  */
                     50: typedef struct
                     51: {
                     52:   /* The connection to the Cadillac kernel.  */
                     53:   Connection *conn;
                     54: 
                     55:   /* Input and output file descriptors for Cadillac.  */
                     56:   short fd_input, fd_output;
                     57: 
                     58:   /* #include nesting of current file.  */
                     59:   short depth;
                     60: 
                     61:   /* State variables for the connection.  */
                     62:   char messages;
                     63:   char conversion;
                     64:   char emission;
                     65:   char process_until;
                     66: 
                     67:   /* #if level of current file.  */
                     68:   int iflevel;
                     69: 
                     70:   /* Line number that starts current source file.  */
                     71:   int lineno;
                     72: 
                     73:   /* Name of current file.  */
                     74:   char *filename;
                     75: 
                     76:   /* Where to stop processing (if process_until is set).  */
                     77:   char *end_filename;
                     78:   int end_position;
                     79: 
                     80: } cadillac_struct;
                     81: static cadillac_struct cadillacObj;
                     82: 
                     83: /* Nonzero if in the process of exiting.  */
                     84: static int exiting;
                     85: 
                     86: void cadillac_note_source ();
                     87: static void CWriteLanguageDecl ();
                     88: static void CWriteLanguageType ();
                     89: static void CWriteTopLevel ();
                     90: static void cadillac_note_filepos ();
                     91: static void cadillac_process_request (), cadillac_process_requests ();
                     92: static void cadillac_switch_source ();
                     93: static void exit_cadillac ();
                     94: 
                     95: /* Blocking test.  */
                     96: static int
                     97: readable_p (fd)
                     98:      int fd;
                     99: {
                    100:   fd_set f;
                    101: 
                    102:   FD_ZERO (&f);
                    103:   FD_SET (fd, &f);
                    104: 
                    105:   return select (32, &f, NULL, NULL, 0) == 1;
                    106: }
                    107: 
                    108: static CObjectType *tree_to_cadillac_map;
                    109: struct obstack cadillac_obstack;
                    110: 
                    111: 
                    112: #include "stack.h"
                    113: 
                    114: struct context_level
                    115: {
                    116:   struct stack_level base;
                    117: 
                    118:   tree context;
                    119: };
                    120: 
                    121: /* Stack for maintaining contexts (in case functions or types are nested).
                    122:    When defining a struct type, the `context' field is the RECORD_TYPE.
                    123:    When defining a function, the `context' field is the FUNCTION_DECL.  */
                    124: 
                    125: static struct context_level *context_stack;
                    126: 
                    127: static struct context_level *
                    128: push_context_level (stack, obstack)
                    129:      struct stack_level *stack;
                    130:      struct obstack *obstack;
                    131: {
                    132:   struct context_level tem;
                    133: 
                    134:   tem.base.prev = stack;
                    135:   return (struct context_level *)push_stack_level (obstack, &tem, sizeof (tem));
                    136: }
                    137: 
                    138: /* Discard a level of search allocation.  */
                    139: 
                    140: static struct context_level *
                    141: pop_context_level (stack)
                    142:      struct context_level *stack;
                    143: {
                    144:   stack = (struct context_level *)pop_stack_level (stack);
                    145:   return stack;
                    146: }
                    147: 
                    148: void
                    149: init_cadillac ()
                    150: {
                    151:   extern FILE *finput;
                    152:   extern int errno;
                    153:   CCompilerMessage* req;
                    154:   cadillac_struct *cp = &cadillacObj;
                    155:   int i;
                    156: 
                    157:   if (! flag_cadillac)
                    158:     return;
                    159: 
                    160:   tree_to_cadillac_map = (CObjectType*) xmalloc (sizeof (CObjectType) * LAST_CPLUS_TREE_CODE);
                    161:   for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
                    162:     tree_to_cadillac_map[i] = MiscOType;
                    163:   tree_to_cadillac_map[RECORD_TYPE] = StructOType;
                    164:   tree_to_cadillac_map[UNION_TYPE] = UnionOType;
                    165:   tree_to_cadillac_map[ENUMERAL_TYPE] = EnumTypeOType;
                    166:   tree_to_cadillac_map[TYPE_DECL] = TypedefOType;
                    167:   tree_to_cadillac_map[VAR_DECL] = VariableOType;
                    168:   tree_to_cadillac_map[CONST_DECL] = EnumConstantOType;
                    169:   tree_to_cadillac_map[FUNCTION_DECL] = FunctionOType;
                    170:   tree_to_cadillac_map[FIELD_DECL] = FieldOType;
                    171: 
                    172: #ifdef sun
                    173:   on_exit (&exit_cadillac, 0);
                    174: #endif
                    175: 
                    176:   gcc_obstack_init (&cadillac_obstack);
                    177: 
                    178:   /* Yow!  This is the way Cadillac was designed to deal with
                    179:      Oregon C++ compiler!  */
                    180:   cp->fd_input = flag_cadillac;
                    181:   cp->fd_output = flag_cadillac;
                    182: 
                    183:   /* Start in "turned-on" state.  */
                    184:   cp->messages = 1;
                    185:   cp->conversion = 1;
                    186:   cp->emission = 1;
                    187: 
                    188:   /* Establish a connection with Cadillac here.  */
                    189:   cp->conn = NewConnection (cp, cp->fd_input, cp->fd_output);
                    190: 
                    191:   CWriteHeader (cp->conn, WaitingMType, 0);
                    192:   CWriteRequestBuffer (cp->conn);
                    193: 
                    194:   if (!readable_p (cp->fd_input))
                    195:     ;
                    196: 
                    197:   req = CReadCompilerMessage (cp->conn);
                    198: 
                    199:   if (!req)
                    200:     switch (errno)
                    201:       {
                    202:       case EWOULDBLOCK:
                    203:        sleep (5);
                    204:        return;
                    205:       
                    206:       case 0:
                    207:        fatal ("init_cadillac: EOF on connection to kernel, exiting\n");
                    208:        break;
                    209: 
                    210:       default:
                    211:        perror ("Editor to kernel connection");
                    212:        exit (0);
                    213:       }
                    214: }
                    215: 
                    216: static void
                    217: cadillac_process_requests (conn)
                    218:      Connection *conn;
                    219: {
                    220:   CCompilerMessage *req;
                    221:   while (req = (CCompilerMessage*) CPeekNextRequest (conn))
                    222:     {
                    223:       req = CReadCompilerMessage (conn);
                    224:       cadillac_process_request (&cadillacObj, req);
                    225:     }
                    226: }
                    227: 
                    228: static void
                    229: cadillac_process_request (cp, req)
                    230:      cadillac_struct *cp;
                    231:      CCompilerMessage *req;
                    232: {
                    233:   if (! req)
                    234:     return;
                    235: 
                    236:   switch (req->reqType)
                    237:     {
                    238:     case ProcessUntilMType:
                    239:       if (cp->process_until)
1.1.1.2 ! root      240:        my_friendly_abort (23);
1.1       root      241:       cp->process_until = 1;
                    242:       /* This is not really right.  */
                    243:       cp->end_position = ((CCompilerCommand*)req)->processuntil.position;
                    244: #if 0
                    245:       cp->end_filename = req->processuntil.filename;
                    246: #endif
                    247:       break;
                    248: 
                    249:     case CommandMType:
                    250:       switch (req->header.data)
                    251:        {
                    252:        case MessagesOnCType:
                    253:          cp->messages = 1;
                    254:          break;
                    255:        case MessagesOffCType:
                    256:          cp->messages = 0;
                    257:          break;
                    258:        case ConversionOnCType:
                    259:          cp->conversion = 1;
                    260:          break;
                    261:        case ConversionOffCType:
                    262:          cp->conversion = 0;
                    263:          break;
                    264:        case EmissionOnCType:
                    265:          cp->emission = 1;
                    266:          break;
                    267:        case EmissionOffCType:
                    268:          cp->emission = 0;
                    269:          break;
                    270: 
                    271:        case FinishAnalysisCType:
                    272:          return;
                    273: 
                    274:        case PuntAnalysisCType:
                    275:        case ContinueAnalysisCType:
                    276:        case GotoFileposCType:
                    277:        case OpenSucceededCType:
                    278:        case OpenFailedCType:
                    279:          fprintf (stderr, "request type %d not implemented\n", req->reqType);
                    280:          return;
                    281: 
                    282:        case DieCType:
                    283:          if (! exiting)
1.1.1.2 ! root      284:            my_friendly_abort (24);
1.1       root      285:          return;
                    286: 
                    287:        }
                    288:       break;
                    289: 
                    290:     default:
                    291:       fatal ("unknown request type %d", req->reqType);
                    292:     }
                    293: }
                    294: 
                    295: void
                    296: cadillac_start ()
                    297: {
                    298:   Connection *conn = cadillacObj.conn;
                    299:   CCompilerMessage *req;
                    300: 
                    301:   /* Let Cadillac know that we start in C++ language scope.  */
                    302:   CWriteHeader (conn, ForeignLinkageMType, LinkCPlus);
                    303:   CWriteLength (conn);
                    304:   CWriteRequestBuffer (conn);
                    305: 
                    306:   cadillac_process_requests (conn);
                    307: }
                    308: 
                    309: static void
                    310: cadillac_printf (msg, name)
                    311: {
                    312:   if (cadillacObj.messages)
                    313:     printf ("[%s,%4d] %s `%s'\n", input_filename, lineno, msg, name);
                    314: }
                    315: 
                    316: void
                    317: cadillac_start_decl (decl)
                    318:      tree decl;
                    319: {
                    320:   Connection *conn = cadillacObj.conn;
                    321:   CObjectType object_type = tree_to_cadillac_map [TREE_CODE (decl)];
                    322: 
                    323:   if (context_stack)
                    324:     switch (TREE_CODE (context_stack->context))
                    325:       {
                    326:       case FUNCTION_DECL:
                    327:        /* Currently, cadillac only implements top-level forms.  */
                    328:        return;
                    329:       case RECORD_TYPE:
                    330:       case UNION_TYPE:
                    331:        cadillac_printf ("start class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
                    332:        break;
                    333:       default:
1.1.1.2 ! root      334:        my_friendly_abort (25);
1.1       root      335:       }
                    336:   else
                    337:     {
                    338:       cadillac_printf ("start top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
                    339:       CWriteTopLevel (conn, StartMType);
                    340:     }
                    341: 
                    342:   CWriteLanguageDecl (conn, decl, tree_to_cadillac_map[TREE_CODE (decl)]);
                    343:   CWriteRequestBuffer (conn);
                    344:   cadillac_process_requests (conn);
                    345: }
                    346: 
                    347: void
                    348: cadillac_finish_decl (decl)
                    349:      tree decl;
                    350: {
                    351:   Connection *conn = cadillacObj.conn;
                    352: 
                    353:   if (context_stack)
                    354:     switch (TREE_CODE (context_stack->context))
                    355:       {
                    356:       case FUNCTION_DECL:
                    357:        return;
                    358:       case RECORD_TYPE:
                    359:       case UNION_TYPE:
                    360:        cadillac_printf ("end class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
                    361:        CWriteHeader (conn, EndDefMType, 0);
                    362:        CWriteLength (conn);
                    363:        break;
                    364:       default:
1.1.1.2 ! root      365:        my_friendly_abort (26);
1.1       root      366:       }
                    367:   else
                    368:     {
                    369:       cadillac_printf ("end top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
                    370:       CWriteHeader (conn, EndDefMType, 0);
                    371:       CWriteLength (conn);
                    372:       CWriteTopLevel (conn, StopMType);
                    373:     }
                    374: 
                    375:   CWriteRequestBuffer (conn);
                    376:   cadillac_process_requests (conn);
                    377: }
                    378: 
                    379: void
                    380: cadillac_start_function (fndecl)
                    381:      tree fndecl;
                    382: {
                    383:   Connection *conn = cadillacObj.conn;
                    384: 
                    385:   if (context_stack)
                    386:     /* nested functions not yet handled.  */
1.1.1.2 ! root      387:     my_friendly_abort (27);
1.1       root      388: 
                    389:   cadillac_printf ("start top-level function", lang_printable_name (fndecl));
                    390:   context_stack = push_context_level (context_stack, &cadillac_obstack);
                    391:   context_stack->context = fndecl;
                    392: 
                    393:   CWriteTopLevel (conn, StartMType);
                    394:   assert (TREE_CODE (fndecl) == FUNCTION_DECL);
                    395:   CWriteLanguageDecl (conn, fndecl,
                    396:                      (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE
                    397:                       ? MemberFnOType : FunctionOType));
                    398:   CWriteRequestBuffer (conn);
                    399:   cadillac_process_requests (conn);
                    400: }
                    401: 
                    402: void
                    403: cadillac_finish_function (fndecl)
                    404:      tree fndecl;
                    405: {
                    406:   Connection *conn = cadillacObj.conn;
                    407: 
                    408:   cadillac_printf ("end top-level function", lang_printable_name (fndecl));
                    409:   context_stack = pop_context_level (context_stack);
                    410: 
                    411:   if (context_stack)
                    412:     /* nested functions not yet implemented.  */
1.1.1.2 ! root      413:     my_friendly_abort (28);
1.1       root      414: 
                    415:   CWriteHeader (conn, EndDefMType, 0);
                    416:   CWriteLength (conn);
                    417:   CWriteTopLevel (conn, StopMType);
                    418:   CWriteRequestBuffer (conn);
                    419:   cadillac_process_requests (conn);
                    420: }
                    421: 
                    422: void
                    423: cadillac_finish_anon_union (decl)
                    424:      tree decl;
                    425: {
                    426:   Connection *conn = cadillacObj.conn;
                    427: 
                    428:   if (! global_bindings_p ())
                    429:     return;
                    430:   cadillac_printf ("finish top-level anon union", "");
                    431:   CWriteHeader (conn, EndDefMType, 0);
                    432:   CWriteLength (conn);
                    433:   CWriteTopLevel (conn, StopMType);
                    434:   CWriteRequestBuffer (conn);
                    435:   cadillac_process_requests (conn);
                    436: }
                    437: 
                    438: void
                    439: cadillac_start_enum (type)
                    440:      tree type;
                    441: {
                    442:   Connection *conn = cadillacObj.conn;
                    443: 
                    444:   tree name = TYPE_NAME (type);
                    445: 
                    446:   if (TREE_CODE (name) == TYPE_DECL)
                    447:     name = DECL_NAME (name);
                    448: 
                    449:   if (context_stack)
                    450:     switch (TREE_CODE (context_stack->context))
                    451:       {
                    452:       case FUNCTION_DECL:
                    453:        return;
                    454:       case RECORD_TYPE:
                    455:       case UNION_TYPE:
                    456:        break;
                    457:       default:
1.1.1.2 ! root      458:        my_friendly_abort (29);
1.1       root      459:       }
                    460:   else
                    461:     {
                    462:       cadillac_printf ("start top-level enum", IDENTIFIER_POINTER (name));
                    463:       CWriteTopLevel (conn, StartMType);
                    464:     }
                    465: 
                    466:   CWriteLanguageType (conn, type, tree_to_cadillac_map[ENUMERAL_TYPE]);
                    467: }
                    468: 
                    469: void
                    470: cadillac_finish_enum (type)
                    471:      tree type;
                    472: {
                    473:   Connection *conn = cadillacObj.conn;
                    474:   tree name = TYPE_NAME (type);
                    475: 
                    476:   if (TREE_CODE (name) == TYPE_DECL)
                    477:     name = DECL_NAME (name);
                    478: 
                    479:   if (context_stack)
                    480:     switch (TREE_CODE (context_stack->context))
                    481:       {
                    482:       case FUNCTION_DECL:
                    483:        return;
                    484:       case RECORD_TYPE:
                    485:       case UNION_TYPE:
                    486:        CWriteHeader (conn, EndDefMType, 0);
                    487:        CWriteLength (conn);
                    488:        break;
                    489:       default:
1.1.1.2 ! root      490:        my_friendly_abort (30);
1.1       root      491:       }
                    492:   else
                    493:     {
                    494:       CWriteHeader (conn, EndDefMType, 0);
                    495:       CWriteLength (conn);
                    496:       cadillac_printf ("finish top-level enum", IDENTIFIER_POINTER (name));
                    497:       CWriteTopLevel (conn, StopMType);
                    498:     }
                    499: 
                    500:   CWriteRequestBuffer (conn);
                    501:   cadillac_process_requests (conn);
                    502: }
                    503: 
                    504: void
                    505: cadillac_start_struct (type)
                    506:      tree type;
                    507: {
                    508:   Connection *conn = cadillacObj.conn;
                    509:   tree name = TYPE_NAME (type);
                    510: 
                    511:   if (TREE_CODE (name) == TYPE_DECL)
                    512:     name = DECL_NAME (name);
                    513: 
                    514:   if (context_stack)
                    515:     switch (TREE_CODE (context_stack->context))
                    516:       {
                    517:       case FUNCTION_DECL:
                    518:        return;
                    519:       case RECORD_TYPE:
                    520:       case UNION_TYPE:
                    521:        return;
                    522:       default:
1.1.1.2 ! root      523:        my_friendly_abort (31);
1.1       root      524:       }
                    525:   else
                    526:     {
                    527:       cadillac_printf ("start struct", IDENTIFIER_POINTER (name));
                    528:       CWriteTopLevel (conn, StartMType);
                    529:     }
                    530: 
                    531:   context_stack = push_context_level (context_stack, &cadillac_obstack);
                    532:   context_stack->context = type;
                    533: 
                    534:   CWriteLanguageType (conn, type,
                    535:                      TYPE_LANG_SPECIFIC (type) && CLASSTYPE_DECLARED_CLASS (type) ? ClassOType : tree_to_cadillac_map[TREE_CODE (type)]);
                    536: }
                    537: 
                    538: void
                    539: cadillac_finish_struct (type)
                    540:      tree type;
                    541: {
                    542:   Connection *conn = cadillacObj.conn;
                    543:   tree name = TYPE_NAME (type);
                    544: 
                    545:   if (TREE_CODE (name) == TYPE_DECL)
                    546:     name = DECL_NAME (name);
                    547: 
                    548:   context_stack = pop_context_level (context_stack);
                    549:   if (context_stack)
                    550:     return;
                    551: 
                    552:   cadillac_printf ("finish struct", IDENTIFIER_POINTER (name));
                    553:   CWriteHeader (conn, EndDefMType, 0);
                    554:   CWriteLength (conn);
                    555:   CWriteTopLevel (conn, StopMType);
                    556:   CWriteRequestBuffer (conn);
                    557:   cadillac_process_requests (conn);
                    558: }
                    559: 
                    560: void
                    561: cadillac_finish_exception (type)
                    562:      tree type;
                    563: {
                    564:   Connection *conn = cadillacObj.conn;
                    565: 
                    566:   fatal ("cadillac_finish_exception");
                    567:   CWriteHeader (conn, EndDefMType, 0);
                    568:   CWriteLength (conn);
                    569:   CWriteTopLevel (conn, StopMType);
                    570:   CWriteRequestBuffer (conn);
                    571:   cadillac_process_requests (conn);
                    572: }
                    573: 
                    574: void
                    575: cadillac_push_class (type)
                    576:      tree type;
                    577: {
                    578: }
                    579: 
                    580: void
                    581: cadillac_pop_class ()
                    582: {
                    583: }
                    584: 
                    585: void
                    586: cadillac_push_lang (name)
                    587:      tree name;
                    588: {
                    589:   Connection *conn = cadillacObj.conn;
                    590:   CLinkLanguageType m;
                    591: 
                    592:   if (name == lang_name_cplusplus)
                    593:     m = LinkCPlus;
                    594:   else if (name == lang_name_c)
                    595:     m = LinkC;
                    596:   else
1.1.1.2 ! root      597:     my_friendly_abort (32);
1.1       root      598:   CWriteHeader (conn, ForeignLinkageMType, m);
                    599:   CWriteRequestBuffer (conn);
                    600:   cadillac_process_requests (conn);
                    601: }
                    602: 
                    603: void
                    604: cadillac_pop_lang ()
                    605: {
                    606:   Connection *conn = cadillacObj.conn;
                    607: 
                    608:   CWriteHeader (conn, ForeignLinkageMType, LinkPop);
                    609:   CWriteRequestBuffer (conn);
                    610:   cadillac_process_requests (conn);
                    611: }
                    612: 
                    613: void
                    614: cadillac_finish_stmt ()
                    615: {
                    616: }
                    617: 
                    618: void
                    619: cadillac_note_source ()
                    620: {
                    621:   cadillacObj.lineno = lineno;
                    622:   cadillacObj.filename = input_filename;
                    623: }
                    624: 
                    625: static void
                    626: CWriteTopLevel (conn, m)
                    627:      Connection *conn;
                    628:      CMessageSubType m;
                    629: {
                    630:   static context_id = 0;
                    631:   CWriteHeader (conn, TopLevelFormMType, m);
                    632:   cadillac_note_filepos ();
                    633: 
                    634:   /* Eventually, this will point somewhere into the digest file.  */
                    635:   context_id += 1;
                    636:   CWriteSomething (conn, &context_id, sizeof (BITS32));
                    637: 
                    638:   CWriteSomething (conn, &cadillacObj.iflevel, sizeof (BITS32));
                    639:   CWriteLength (conn);
                    640: }
                    641: 
                    642: static void
                    643: cadillac_note_filepos ()
                    644: {
                    645:   extern FILE *finput;
                    646:   int pos = ftell (finput);
                    647:   CWriteSomething (cadillacObj.conn, &pos, sizeof (BITS32));
                    648: }
                    649: 
                    650: void
                    651: cadillac_switch_source (startflag)
                    652:      int startflag;
                    653: {
                    654:   Connection *conn = cadillacObj.conn;
                    655:   /* Send out the name of the source file being compiled.  */
                    656: 
                    657:   CWriteHeader (conn, SourceFileMType, startflag ? StartMType : StopMType);
                    658:   CWriteSomething (conn, &cadillacObj.depth, sizeof (BITS16));
                    659:   CWriteVstring0 (conn, input_filename);
                    660:   CWriteLength (conn);
                    661:   CWriteRequestBuffer (conn);
                    662:   cadillac_process_requests (conn);
                    663: }
                    664: 
                    665: void
                    666: cadillac_push_source ()
                    667: {
                    668:   cadillacObj.depth += 1;
                    669:   cadillac_switch_source (1);
                    670: }
                    671: 
                    672: void
                    673: cadillac_pop_source ()
                    674: {
                    675:   cadillacObj.depth -= 1;
                    676:   cadillac_switch_source (0);
                    677: }
                    678: 
                    679: struct cadillac_mdep
                    680: {
                    681:   short object_type;
                    682:   char linkage;
                    683:   char access;
                    684:   short length;
                    685: };
                    686: 
                    687: static void
                    688: CWriteLanguageElem (conn, p, name)
                    689:      Connection *conn;
                    690:      struct cadillac_mdep *p;
                    691:      char *name;
                    692: {
                    693:   CWriteSomething (conn, &p->object_type, sizeof (BITS16));
                    694:   CWriteSomething (conn, &p->linkage, sizeof (BITS8));
                    695:   CWriteSomething (conn, &p->access, sizeof (BITS8));
                    696:   CWriteSomething (conn, &p->length, sizeof (BITS16));
                    697:   CWriteVstring0 (conn, name);
                    698: 
                    699: #if 0
                    700:   /* Don't write date_type.  */
                    701:   CWriteVstring0 (conn, "");
                    702: #endif
                    703:   CWriteLength (conn);
                    704: }
                    705: 
                    706: static void
                    707: CWriteLanguageDecl (conn, decl, object_type)
                    708:      Connection *conn;
                    709:      tree decl;
                    710:      CObjectType object_type;
                    711: {
                    712:   struct cadillac_mdep foo;
                    713:   tree name;
                    714: 
                    715:   CWriteHeader (conn, LanguageElementMType, StartDefineMType);
                    716:   foo.object_type = object_type;
                    717:   if (decl_type_context (decl))
                    718:     {
                    719:       foo.linkage = ParentLinkage;
                    720:       if (TREE_PRIVATE (decl))
                    721:        foo.access = PrivateAccess;
                    722:       else if (TREE_PROTECTED (decl))
                    723:        foo.access = ProtectedAccess;
                    724:       else
                    725:        foo.access = PublicAccess;
                    726:     }
                    727:   else
                    728:     {
                    729:       if (TREE_PUBLIC (decl))
                    730:        foo.linkage = GlobalLinkage;
                    731:       else
                    732:        foo.linkage = FileLinkage;
                    733:       foo.access = PublicAccess;
                    734:     }
                    735:   name = DECL_NAME (decl);
                    736:   foo.length = IDENTIFIER_LENGTH (name);
                    737: 
                    738:   CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
                    739:   CWriteRequestBuffer (conn);
                    740:   cadillac_process_requests (conn);
                    741: }
                    742: 
                    743: static void
                    744: CWriteLanguageType (conn, type, object_type)
                    745:      Connection *conn;
                    746:      tree type;
                    747:      CObjectType object_type;
                    748: {
                    749:   struct cadillac_mdep foo;
                    750:   tree name = TYPE_NAME (type);
                    751: 
                    752:   CWriteHeader (conn, LanguageElementMType, StartDefineMType);
                    753:   foo.object_type = object_type;
                    754:   if (current_class_type)
                    755:     {
                    756:       foo.linkage = ParentLinkage;
                    757:       if (TREE_PRIVATE (type))
                    758:        foo.access = PrivateAccess;
                    759:       else if (TREE_PROTECTED (type))
                    760:        foo.access = ProtectedAccess;
                    761:       else
                    762:        foo.access = PublicAccess;
                    763:     }
                    764:   else
                    765:     {
                    766:       foo.linkage = NoLinkage;
                    767:       foo.access = PublicAccess;
                    768:     }
                    769:   if (TREE_CODE (name) == TYPE_DECL)
                    770:     name = DECL_NAME (name);
                    771: 
                    772:   foo.length = IDENTIFIER_LENGTH (name);
                    773: 
                    774:   CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
                    775:   CWriteRequestBuffer (conn);
                    776:   cadillac_process_requests (conn);
                    777: }
                    778: 
                    779: static void
                    780: CWriteUseObject (conn, type, object_type, use)
                    781:      Connection *conn;
                    782:      tree type;
                    783:      CObjectType object_type;
                    784:      CMessageSubType use;
                    785: {
                    786:   struct cadillac_mdep foo;
                    787:   tree name = NULL_TREE;
                    788: 
                    789:   CWriteHeader (conn, LanguageElementMType, use);
                    790:   foo.object_type = object_type;
                    791:   if (current_class_type)
                    792:     {
                    793:       foo.linkage = ParentLinkage;
                    794:       if (TREE_PRIVATE (type))
                    795:        foo.access = PrivateAccess;
                    796:       else if (TREE_PROTECTED (type))
                    797:        foo.access = ProtectedAccess;
                    798:       else
                    799:        foo.access = PublicAccess;
                    800:     }
                    801:   else
                    802:     {
                    803:       foo.linkage = NoLinkage;
                    804:       foo.access = PublicAccess;
                    805:     }
                    806:   switch (TREE_CODE (type))
                    807:     {
                    808:     case VAR_DECL:
                    809:     case FIELD_DECL:
                    810:     case TYPE_DECL:
                    811:     case CONST_DECL:
                    812:     case FUNCTION_DECL:
                    813:       name = DECL_NAME (type);
                    814:       break;
                    815: 
                    816:     default:
1.1.1.2 ! root      817:       my_friendly_abort (33);
1.1       root      818:   }
                    819: 
                    820:   foo.length = IDENTIFIER_LENGTH (name);
                    821: 
                    822:   CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
                    823:   CWriteRequestBuffer (conn);
                    824:   cadillac_process_requests (conn);
                    825: }
                    826: 
                    827: /* Here's how we exit under cadillac.  */
                    828: 
                    829: static void
                    830: exit_cadillac ()
                    831: {
                    832:   extern int errorcount;
                    833: 
                    834:   Connection *conn = cadillacObj.conn;
                    835: 
                    836:   if (flag_cadillac)
                    837:     {
                    838:       CCompilerMessage *req;
                    839: 
                    840:       CWriteHeader (conn, FinishedMType,
                    841:                    errorcount ? 0 : CsObjectWritten | CsComplete);
                    842:       /* Bye, bye!  */
                    843:       CWriteRequestBuffer (conn);
                    844: 
                    845:       /* Block on read.  */
                    846:       while (! readable_p (cadillacObj.fd_input))
                    847:        {
                    848:          if (exiting)
1.1.1.2 ! root      849:            my_friendly_abort (34);
1.1       root      850:          exiting = 1;
                    851:        }
                    852:       exiting = 1;
                    853: 
                    854:       req = CReadCompilerMessage (conn);
                    855:       cadillac_process_request (&cadillacObj, req);
                    856:     }
                    857: }
                    858: 
                    859: #else
                    860: /* Stubs.  */
                    861: void init_cadillac () {}
                    862: void cadillac_start () {}
                    863: void cadillac_start_decl (decl)
                    864:      tree decl;
                    865: {}
                    866: void
                    867: cadillac_finish_decl (decl)
                    868:      tree decl;
                    869: {}
                    870: void
                    871: cadillac_start_function (fndecl)
                    872:      tree fndecl;
                    873: {}
                    874: void
                    875: cadillac_finish_function (fndecl)
                    876:      tree fndecl;
                    877: {}
                    878: void
                    879: cadillac_finish_anon_union (decl)
                    880:      tree decl;
                    881: {}
                    882: void
                    883: cadillac_start_enum (type)
                    884:      tree type;
                    885: {}
                    886: void
                    887: cadillac_finish_enum (type)
                    888:      tree type;
                    889: {}
                    890: void
                    891: cadillac_start_struct (type)
                    892:      tree type;
                    893: {}
                    894: void
                    895: cadillac_finish_struct (type)
                    896:      tree type;
                    897: {}
                    898: void
                    899: cadillac_finish_exception (type)
                    900:      tree type;
                    901: {}
                    902: void
                    903: cadillac_push_class (type)
                    904:      tree type;
                    905: {}
                    906: void
                    907: cadillac_pop_class ()
                    908: {}
                    909: void
                    910: cadillac_push_lang (name)
                    911:      tree name;
                    912: {}
                    913: void
                    914: cadillac_pop_lang ()
                    915: {}
                    916: void
                    917: cadillac_note_source ()
                    918: {}
                    919: void
                    920: cadillac_finish_stmt ()
                    921: {}
                    922: void
                    923: cadillac_switch_source ()
                    924: {}
                    925: void
                    926: cadillac_push_source ()
                    927: {}
                    928: void
                    929: cadillac_pop_source ()
                    930: {}
                    931: #endif

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.