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

unix.superglobalmegacorp.com

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