summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/cp/edsel.c
blob: 35099d523f76a3ec994291a0fdeb2010f096be44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
/* Interface to LUCID Cadillac system for GNU compiler.
   Copyright (C) 1988, 1992, 1993 Free Software Foundation, Inc.

This file is part of GNU CC.

GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */

#include "config.h"

#include "tree.h"
#include "flags.h"
#include <stdio.h>
#include "cp-tree.h"
#include "obstack.h"

#ifdef CADILLAC
#include <compilerreq.h>
#include <compilerconn.h>
#include <sys/time.h>
#include <sys/types.h>
#include <errno.h>
#include <sys/file.h>

#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free

void init_cadillac ();

extern char *input_filename;
extern int lineno;

/* Put random information we might want to get back from
   Cadillac here.  */
typedef struct
{
  /* The connection to the Cadillac kernel.  */
  Connection *conn;

  /* Input and output file descriptors for Cadillac.  */
  short fd_input, fd_output;

  /* #include nesting of current file.  */
  short depth;

  /* State variables for the connection.  */
  char messages;
  char conversion;
  char emission;
  char process_until;

  /* #if level of current file.  */
  int iflevel;

  /* Line number that starts current source file.  */
  int lineno;

  /* Name of current file.  */
  char *filename;

  /* Where to stop processing (if process_until is set).  */
  char *end_filename;
  int end_position;

} cadillac_struct;
static cadillac_struct cadillacObj;

/* Nonzero if in the process of exiting.  */
static int exiting;

void cadillac_note_source ();
static void CWriteLanguageDecl ();
static void CWriteLanguageType ();
static void CWriteTopLevel ();
static void cadillac_note_filepos ();
static void cadillac_process_request (), cadillac_process_requests ();
static void cadillac_switch_source ();
static void exit_cadillac ();

/* Blocking test.  */
static int
readable_p (fd)
     int fd;
{
  fd_set f;

  FD_ZERO (&f);
  FD_SET (fd, &f);

  return select (32, &f, NULL, NULL, 0) == 1;
}

static CObjectType *tree_to_cadillac_map;
struct obstack cadillac_obstack;


#include "stack.h"

struct context_level
{
  struct stack_level base;

  tree context;
};

/* Stack for maintaining contexts (in case functions or types are nested).
   When defining a struct type, the `context' field is the RECORD_TYPE.
   When defining a function, the `context' field is the FUNCTION_DECL.  */

static struct context_level *context_stack;

static struct context_level *
push_context_level (stack, obstack)
     struct stack_level *stack;
     struct obstack *obstack;
{
  struct context_level tem;

  tem.base.prev = stack;
  return (struct context_level *)push_stack_level (obstack, &tem, sizeof (tem));
}

/* Discard a level of search allocation.  */

static struct context_level *
pop_context_level (stack)
     struct context_level *stack;
{
  stack = (struct context_level *)pop_stack_level (stack);
  return stack;
}

void
init_cadillac ()
{
  extern FILE *finput;
  extern int errno;
  CCompilerMessage* req;
  cadillac_struct *cp = &cadillacObj;
  int i;

  if (! flag_cadillac)
    return;

  tree_to_cadillac_map = (CObjectType*) xmalloc (sizeof (CObjectType) * LAST_CPLUS_TREE_CODE);
  for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
    tree_to_cadillac_map[i] = MiscOType;
  tree_to_cadillac_map[RECORD_TYPE] = StructOType;
  tree_to_cadillac_map[UNION_TYPE] = UnionOType;
  tree_to_cadillac_map[ENUMERAL_TYPE] = EnumTypeOType;
  tree_to_cadillac_map[TYPE_DECL] = TypedefOType;
  tree_to_cadillac_map[VAR_DECL] = VariableOType;
  tree_to_cadillac_map[CONST_DECL] = EnumConstantOType;
  tree_to_cadillac_map[FUNCTION_DECL] = FunctionOType;
  tree_to_cadillac_map[FIELD_DECL] = FieldOType;

#ifdef sun
  on_exit (&exit_cadillac, 0);
#endif

  gcc_obstack_init (&cadillac_obstack);

  /* Yow!  This is the way Cadillac was designed to deal with
     Oregon C++ compiler!  */
  cp->fd_input = flag_cadillac;
  cp->fd_output = flag_cadillac;

  /* Start in "turned-on" state.  */
  cp->messages = 1;
  cp->conversion = 1;
  cp->emission = 1;

  /* Establish a connection with Cadillac here.  */
  cp->conn = NewConnection (cp, cp->fd_input, cp->fd_output);

  CWriteHeader (cp->conn, WaitingMType, 0);
  CWriteRequestBuffer (cp->conn);

  if (!readable_p (cp->fd_input))
    ;

  req = CReadCompilerMessage (cp->conn);

  if (!req)
    switch (errno)
      {
      case EWOULDBLOCK:
	sleep (5);
	return;
      
      case 0:
	fatal ("init_cadillac: EOF on connection to kernel, exiting\n");
	break;

      default:
	perror ("Editor to kernel connection");
	exit (0);
      }
}

static void
cadillac_process_requests (conn)
     Connection *conn;
{
  CCompilerMessage *req;
  while (req = (CCompilerMessage*) CPeekNextRequest (conn))
    {
      req = CReadCompilerMessage (conn);
      cadillac_process_request (&cadillacObj, req);
    }
}

static void
cadillac_process_request (cp, req)
     cadillac_struct *cp;
     CCompilerMessage *req;
{
  if (! req)
    return;

  switch (req->reqType)
    {
    case ProcessUntilMType:
      if (cp->process_until)
	my_friendly_abort (23);
      cp->process_until = 1;
      /* This is not really right.  */
      cp->end_position = ((CCompilerCommand*)req)->processuntil.position;
#if 0
      cp->end_filename = req->processuntil.filename;
#endif
      break;

    case CommandMType:
      switch (req->header.data)
	{
	case MessagesOnCType:
	  cp->messages = 1;
	  break;
	case MessagesOffCType:
	  cp->messages = 0;
	  break;
	case ConversionOnCType:
	  cp->conversion = 1;
	  break;
	case ConversionOffCType:
	  cp->conversion = 0;
	  break;
	case EmissionOnCType:
	  cp->emission = 1;
	  break;
	case EmissionOffCType:
	  cp->emission = 0;
	  break;

	case FinishAnalysisCType:
	  return;

	case PuntAnalysisCType:
	case ContinueAnalysisCType:
	case GotoFileposCType:
	case OpenSucceededCType:
	case OpenFailedCType:
	  fprintf (stderr, "request type %d not implemented\n", req->reqType);
	  return;

	case DieCType:
	  if (! exiting)
	    my_friendly_abort (24);
	  return;

	}
      break;

    default:
      fatal ("unknown request type %d", req->reqType);
    }
}

void
cadillac_start ()
{
  Connection *conn = cadillacObj.conn;
  CCompilerMessage *req;

  /* Let Cadillac know that we start in C++ language scope.  */
  CWriteHeader (conn, ForeignLinkageMType, LinkCPlus);
  CWriteLength (conn);
  CWriteRequestBuffer (conn);

  cadillac_process_requests (conn);
}

static void
cadillac_printf (msg, name)
{
  if (cadillacObj.messages)
    printf ("[%s,%4d] %s `%s'\n", input_filename, lineno, msg, name);
}

void
cadillac_start_decl (decl)
     tree decl;
{
  Connection *conn = cadillacObj.conn;
  CObjectType object_type = tree_to_cadillac_map [TREE_CODE (decl)];

  if (context_stack)
    switch (TREE_CODE (context_stack->context))
      {
      case FUNCTION_DECL:
	/* Currently, cadillac only implements top-level forms.  */
	return;
      case RECORD_TYPE:
      case UNION_TYPE:
	cadillac_printf ("start class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
	break;
      default:
	my_friendly_abort (25);
      }
  else
    {
      cadillac_printf ("start top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
      CWriteTopLevel (conn, StartMType);
    }

  CWriteLanguageDecl (conn, decl, tree_to_cadillac_map[TREE_CODE (decl)]);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_finish_decl (decl)
     tree decl;
{
  Connection *conn = cadillacObj.conn;

  if (context_stack)
    switch (TREE_CODE (context_stack->context))
      {
      case FUNCTION_DECL:
	return;
      case RECORD_TYPE:
      case UNION_TYPE:
	cadillac_printf ("end class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
	CWriteHeader (conn, EndDefMType, 0);
	CWriteLength (conn);
	break;
      default:
	my_friendly_abort (26);
      }
  else
    {
      cadillac_printf ("end top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
      CWriteHeader (conn, EndDefMType, 0);
      CWriteLength (conn);
      CWriteTopLevel (conn, StopMType);
    }

  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_start_function (fndecl)
     tree fndecl;
{
  Connection *conn = cadillacObj.conn;

  if (context_stack)
    /* nested functions not yet handled.  */
    my_friendly_abort (27);

  cadillac_printf ("start top-level function", lang_printable_name (fndecl));
  context_stack = push_context_level (context_stack, &cadillac_obstack);
  context_stack->context = fndecl;

  CWriteTopLevel (conn, StartMType);
  my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 202);
  CWriteLanguageDecl (conn, fndecl,
		      (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE
		       ? MemberFnOType : FunctionOType));
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_finish_function (fndecl)
     tree fndecl;
{
  Connection *conn = cadillacObj.conn;

  cadillac_printf ("end top-level function", lang_printable_name (fndecl));
  context_stack = pop_context_level (context_stack);

  if (context_stack)
    /* nested functions not yet implemented.  */
    my_friendly_abort (28);

  CWriteHeader (conn, EndDefMType, 0);
  CWriteLength (conn);
  CWriteTopLevel (conn, StopMType);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_finish_anon_union (decl)
     tree decl;
{
  Connection *conn = cadillacObj.conn;

  if (! global_bindings_p ())
    return;
  cadillac_printf ("finish top-level anon union", "");
  CWriteHeader (conn, EndDefMType, 0);
  CWriteLength (conn);
  CWriteTopLevel (conn, StopMType);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_start_enum (type)
     tree type;
{
  Connection *conn = cadillacObj.conn;

  tree name = TYPE_NAME (type);

  if (TREE_CODE (name) == TYPE_DECL)
    name = DECL_NAME (name);

  if (context_stack)
    switch (TREE_CODE (context_stack->context))
      {
      case FUNCTION_DECL:
	return;
      case RECORD_TYPE:
      case UNION_TYPE:
	break;
      default:
	my_friendly_abort (29);
      }
  else
    {
      cadillac_printf ("start top-level enum", IDENTIFIER_POINTER (name));
      CWriteTopLevel (conn, StartMType);
    }

  CWriteLanguageType (conn, type, tree_to_cadillac_map[ENUMERAL_TYPE]);
}

void
cadillac_finish_enum (type)
     tree type;
{
  Connection *conn = cadillacObj.conn;
  tree name = TYPE_NAME (type);

  if (TREE_CODE (name) == TYPE_DECL)
    name = DECL_NAME (name);

  if (context_stack)
    switch (TREE_CODE (context_stack->context))
      {
      case FUNCTION_DECL:
	return;
      case RECORD_TYPE:
      case UNION_TYPE:
	CWriteHeader (conn, EndDefMType, 0);
	CWriteLength (conn);
	break;
      default:
	my_friendly_abort (30);
      }
  else
    {
      CWriteHeader (conn, EndDefMType, 0);
      CWriteLength (conn);
      cadillac_printf ("finish top-level enum", IDENTIFIER_POINTER (name));
      CWriteTopLevel (conn, StopMType);
    }

  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_start_struct (type)
     tree type;
{
  Connection *conn = cadillacObj.conn;
  tree name = TYPE_NAME (type);

  if (TREE_CODE (name) == TYPE_DECL)
    name = DECL_NAME (name);

  if (context_stack)
    switch (TREE_CODE (context_stack->context))
      {
      case FUNCTION_DECL:
	return;
      case RECORD_TYPE:
      case UNION_TYPE:
	return;
      default:
	my_friendly_abort (31);
      }
  else
    {
      cadillac_printf ("start struct", IDENTIFIER_POINTER (name));
      CWriteTopLevel (conn, StartMType);
    }

  context_stack = push_context_level (context_stack, &cadillac_obstack);
  context_stack->context = type;

  CWriteLanguageType (conn, type,
		      TYPE_LANG_SPECIFIC (type) && CLASSTYPE_DECLARED_CLASS (type) ? ClassOType : tree_to_cadillac_map[TREE_CODE (type)]);
}

void
cadillac_finish_struct (type)
     tree type;
{
  Connection *conn = cadillacObj.conn;
  tree name = TYPE_NAME (type);

  if (TREE_CODE (name) == TYPE_DECL)
    name = DECL_NAME (name);

  context_stack = pop_context_level (context_stack);
  if (context_stack)
    return;

  cadillac_printf ("finish struct", IDENTIFIER_POINTER (name));
  CWriteHeader (conn, EndDefMType, 0);
  CWriteLength (conn);
  CWriteTopLevel (conn, StopMType);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_finish_exception (type)
     tree type;
{
  Connection *conn = cadillacObj.conn;

  fatal ("cadillac_finish_exception");
  CWriteHeader (conn, EndDefMType, 0);
  CWriteLength (conn);
  CWriteTopLevel (conn, StopMType);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_push_class (type)
     tree type;
{
}

void
cadillac_pop_class ()
{
}

void
cadillac_push_lang (name)
     tree name;
{
  Connection *conn = cadillacObj.conn;
  CLinkLanguageType m;

  if (name == lang_name_cplusplus)
    m = LinkCPlus;
  else if (name == lang_name_c)
    m = LinkC;
  else
    my_friendly_abort (32);
  CWriteHeader (conn, ForeignLinkageMType, m);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_pop_lang ()
{
  Connection *conn = cadillacObj.conn;

  CWriteHeader (conn, ForeignLinkageMType, LinkPop);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_finish_stmt ()
{
}

void
cadillac_note_source ()
{
  cadillacObj.lineno = lineno;
  cadillacObj.filename = input_filename;
}

static void
CWriteTopLevel (conn, m)
     Connection *conn;
     CMessageSubType m;
{
  static context_id = 0;
  CWriteHeader (conn, TopLevelFormMType, m);
  cadillac_note_filepos ();

  /* Eventually, this will point somewhere into the digest file.  */
  context_id += 1;
  CWriteSomething (conn, &context_id, sizeof (BITS32));

  CWriteSomething (conn, &cadillacObj.iflevel, sizeof (BITS32));
  CWriteLength (conn);
}

static void
cadillac_note_filepos ()
{
  extern FILE *finput;
  int pos = ftell (finput);
  CWriteSomething (cadillacObj.conn, &pos, sizeof (BITS32));
}

void
cadillac_switch_source (startflag)
     int startflag;
{
  Connection *conn = cadillacObj.conn;
  /* Send out the name of the source file being compiled.  */

  CWriteHeader (conn, SourceFileMType, startflag ? StartMType : StopMType);
  CWriteSomething (conn, &cadillacObj.depth, sizeof (BITS16));
  CWriteVstring0 (conn, input_filename);
  CWriteLength (conn);
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

void
cadillac_push_source ()
{
  cadillacObj.depth += 1;
  cadillac_switch_source (1);
}

void
cadillac_pop_source ()
{
  cadillacObj.depth -= 1;
  cadillac_switch_source (0);
}

struct cadillac_mdep
{
  short object_type;
  char linkage;
  char access;
  short length;
};

static void
CWriteLanguageElem (conn, p, name)
     Connection *conn;
     struct cadillac_mdep *p;
     char *name;
{
  CWriteSomething (conn, &p->object_type, sizeof (BITS16));
  CWriteSomething (conn, &p->linkage, sizeof (BITS8));
  CWriteSomething (conn, &p->access, sizeof (BITS8));
  CWriteSomething (conn, &p->length, sizeof (BITS16));
  CWriteVstring0 (conn, name);

#if 0
  /* Don't write date_type.  */
  CWriteVstring0 (conn, "");
#endif
  CWriteLength (conn);
}

static void
CWriteLanguageDecl (conn, decl, object_type)
     Connection *conn;
     tree decl;
     CObjectType object_type;
{
  struct cadillac_mdep foo;
  tree name;

  CWriteHeader (conn, LanguageElementMType, StartDefineMType);
  foo.object_type = object_type;
  if (decl_type_context (decl))
    {
      foo.linkage = ParentLinkage;
      if (TREE_PRIVATE (decl))
	foo.access = PrivateAccess;
      else if (TREE_PROTECTED (decl))
	foo.access = ProtectedAccess;
      else
	foo.access = PublicAccess;
    }
  else
    {
      if (TREE_PUBLIC (decl))
	foo.linkage = GlobalLinkage;
      else
	foo.linkage = FileLinkage;
      foo.access = PublicAccess;
    }
  name = DECL_NAME (decl);
  foo.length = IDENTIFIER_LENGTH (name);

  CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

static void
CWriteLanguageType (conn, type, object_type)
     Connection *conn;
     tree type;
     CObjectType object_type;
{
  struct cadillac_mdep foo;
  tree name = TYPE_NAME (type);

  CWriteHeader (conn, LanguageElementMType, StartDefineMType);
  foo.object_type = object_type;
  if (current_class_type)
    {
      foo.linkage = ParentLinkage;
      if (TREE_PRIVATE (type))
	foo.access = PrivateAccess;
      else if (TREE_PROTECTED (type))
	foo.access = ProtectedAccess;
      else
	foo.access = PublicAccess;
    }
  else
    {
      foo.linkage = NoLinkage;
      foo.access = PublicAccess;
    }
  if (TREE_CODE (name) == TYPE_DECL)
    name = DECL_NAME (name);

  foo.length = IDENTIFIER_LENGTH (name);

  CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

static void
CWriteUseObject (conn, type, object_type, use)
     Connection *conn;
     tree type;
     CObjectType object_type;
     CMessageSubType use;
{
  struct cadillac_mdep foo;
  tree name = NULL_TREE;

  CWriteHeader (conn, LanguageElementMType, use);
  foo.object_type = object_type;
  if (current_class_type)
    {
      foo.linkage = ParentLinkage;
      if (TREE_PRIVATE (type))
	foo.access = PrivateAccess;
      else if (TREE_PROTECTED (type))
	foo.access = ProtectedAccess;
      else
	foo.access = PublicAccess;
    }
  else
    {
      foo.linkage = NoLinkage;
      foo.access = PublicAccess;
    }
  switch (TREE_CODE (type))
    {
    case VAR_DECL:
    case FIELD_DECL:
    case TYPE_DECL:
    case CONST_DECL:
    case FUNCTION_DECL:
      name = DECL_NAME (type);
      break;

    default:
      my_friendly_abort (33);
  }

  foo.length = IDENTIFIER_LENGTH (name);

  CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
  CWriteRequestBuffer (conn);
  cadillac_process_requests (conn);
}

/* Here's how we exit under cadillac.  */

static void
exit_cadillac ()
{
  extern int errorcount;

  Connection *conn = cadillacObj.conn;

  if (flag_cadillac)
    {
      CCompilerMessage *req;

      CWriteHeader (conn, FinishedMType,
		    errorcount ? 0 : CsObjectWritten | CsComplete);
      /* Bye, bye!  */
      CWriteRequestBuffer (conn);

      /* Block on read.  */
      while (! readable_p (cadillacObj.fd_input))
	{
	  if (exiting)
	    my_friendly_abort (34);
	  exiting = 1;
	}
      exiting = 1;

      req = CReadCompilerMessage (conn);
      cadillac_process_request (&cadillacObj, req);
    }
}

#else
/* Stubs.  */
void init_cadillac () {}
void cadillac_start () {}
void cadillac_start_decl (decl)
     tree decl;
{}
void
cadillac_finish_decl (decl)
     tree decl;
{}
void
cadillac_start_function (fndecl)
     tree fndecl;
{}
void
cadillac_finish_function (fndecl)
     tree fndecl;
{}
void
cadillac_finish_anon_union (decl)
     tree decl;
{}
void
cadillac_start_enum (type)
     tree type;
{}
void
cadillac_finish_enum (type)
     tree type;
{}
void
cadillac_start_struct (type)
     tree type;
{}
void
cadillac_finish_struct (type)
     tree type;
{}
void
cadillac_finish_exception (type)
     tree type;
{}
void
cadillac_push_class (type)
     tree type;
{}
void
cadillac_pop_class ()
{}
void
cadillac_push_lang (name)
     tree name;
{}
void
cadillac_pop_lang ()
{}
void
cadillac_note_source ()
{}
void
cadillac_finish_stmt ()
{}
void
cadillac_switch_source ()
{}
void
cadillac_push_source ()
{}
void
cadillac_pop_source ()
{}
#endif
OpenPOWER on IntegriCloud