~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/f2c/src/defs.h

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************
 
2
Copyright 1990 - 1996 by AT&T, Lucent Technologies and Bellcore.
 
3
 
 
4
Permission to use, copy, modify, and distribute this software
 
5
and its documentation for any purpose and without fee is hereby
 
6
granted, provided that the above copyright notice appear in all
 
7
copies and that both that the copyright notice and this
 
8
permission notice and warranty disclaimer appear in supporting
 
9
documentation, and that the names of AT&T, Bell Laboratories,
 
10
Lucent or Bellcore or any of their entities not be used in
 
11
advertising or publicity pertaining to distribution of the
 
12
software without specific, written prior permission.
 
13
 
 
14
AT&T, Lucent and Bellcore disclaim all warranties with regard to
 
15
this software, including all implied warranties of
 
16
merchantability and fitness.  In no event shall AT&T, Lucent or
 
17
Bellcore be liable for any special, indirect or consequential
 
18
damages or any damages whatsoever resulting from loss of use,
 
19
data or profits, whether in an action of contract, negligence or
 
20
other tortious action, arising out of or in connection with the
 
21
use or performance of this software.
 
22
****************************************************************/
 
23
 
 
24
#include "sysdep.h"
 
25
 
 
26
#include "ftypes.h"
 
27
#include "defines.h"
 
28
#include "machdefs.h"
 
29
 
 
30
#define MAXDIM 20
 
31
#define MAXINCLUDES 10
 
32
#define MAXLITERALS 200         /* Max number of constants in the literal
 
33
                                   pool */
 
34
#define MAXCTL 20
 
35
#define MAXHASH 401
 
36
#define MAXSTNO 801
 
37
#define MAXEXT 200
 
38
#define MAXEQUIV 150
 
39
#define MAXLABLIST 258          /* Max number of labels in an alternate
 
40
                                   return CALL or computed GOTO */
 
41
#define MAXCONTIN 99            /* Max continuation lines */
 
42
 
 
43
/* These are the primary pointer types used in the compiler */
 
44
 
 
45
typedef union Expression *expptr, *tagptr;
 
46
typedef struct Chain *chainp;
 
47
typedef struct Addrblock *Addrp;
 
48
typedef struct Constblock *Constp;
 
49
typedef struct Exprblock *Exprp;
 
50
typedef struct Nameblock *Namep;
 
51
 
 
52
extern FILEP infile;
 
53
extern FILEP diagfile;
 
54
extern FILEP textfile;
 
55
extern FILEP asmfile;
 
56
extern FILEP c_file;            /* output file for all functions; extern
 
57
                                   declarations will have to be prepended */
 
58
extern FILEP pass1_file;        /* Temp file to hold the function bodies
 
59
                                   read on pass 1 */
 
60
extern FILEP expr_file;         /* Debugging file */
 
61
extern FILEP initfile;          /* Intermediate data file pointer */
 
62
extern FILEP blkdfile;          /* BLOCK DATA file */
 
63
 
 
64
extern int current_ftn_file;
 
65
extern int maxcontin;
 
66
 
 
67
extern char *blkdfname, *initfname, *sortfname;
 
68
extern long headoffset;         /* Since the header block requires data we
 
69
                                   don't know about until AFTER each
 
70
                                   function has been processed, we keep a
 
71
                                   pointer to the current (dummy) header
 
72
                                   block (at the top of the assembly file)
 
73
                                   here */
 
74
 
 
75
extern char main_alias[];       /* name given to PROGRAM psuedo-op */
 
76
extern char *token;
 
77
extern int maxtoklen, toklen;
 
78
extern long err_lineno, lineno;
 
79
extern char *infname;
 
80
extern int needkwd;
 
81
extern struct Labelblock *thislabel;
 
82
 
 
83
/* Used to allow runtime expansion of internal tables.  In particular,
 
84
   these values can exceed their associated constants */
 
85
 
 
86
extern int maxctl;
 
87
extern int maxequiv;
 
88
extern int maxstno;
 
89
extern int maxhash;
 
90
extern int maxext;
 
91
 
 
92
extern flag nowarnflag;
 
93
extern flag ftn66flag;          /* Generate warnings when weird f77
 
94
                                   features are used (undeclared dummy
 
95
                                   procedure, non-char initialized with
 
96
                                   string, 1-dim subscript in EQUIV) */
 
97
extern flag no66flag;           /* Generate an error when a generic
 
98
                                   function (f77 feature) is used */
 
99
extern flag noextflag;          /* Generate an error when an extension to
 
100
                                   Fortran 77 is used (hex/oct/bin
 
101
                                   constants, automatic, static, double
 
102
                                   complex types) */
 
103
extern flag zflag;              /* enable double complex intrinsics */
 
104
extern flag shiftcase;
 
105
extern flag undeftype;
 
106
extern flag shortsubs;          /* Use short subscripts on arrays? */
 
107
extern flag onetripflag;        /* if true, always execute DO loop body */
 
108
extern flag checksubs;
 
109
extern flag debugflag;
 
110
extern int nerr;
 
111
extern int nwarn;
 
112
 
 
113
extern int parstate;
 
114
extern flag headerdone;         /* True iff the current procedure's header
 
115
                                   data has been written */
 
116
extern int blklevel;
 
117
extern flag saveall;
 
118
extern flag substars;           /* True iff some formal parameter is an
 
119
                                   asterisk */
 
120
extern int impltype[ ];
 
121
extern ftnint implleng[ ];
 
122
extern int implstg[ ];
 
123
 
 
124
extern int tycomplex, tyint, tyioint, tyreal;
 
125
extern int tylog, tylogical;    /* TY____ of the implementation of   logical.
 
126
                                   This will be LONG unless '-2' is given
 
127
                                   on the command line */
 
128
extern int type_choice[];
 
129
extern char *typename[];
 
130
 
 
131
extern int typesize[];  /* size (in bytes) of an object of each
 
132
                                   type.  Indexed by TY___ macros */
 
133
extern int typealign[];
 
134
extern int proctype;    /* Type of return value in this procedure */
 
135
extern char * procname; /* External name of the procedure, or last ENTRY name */
 
136
extern int rtvlabel[ ]; /* Return value labels, indexed by TY___ macros */
 
137
extern Addrp retslot;
 
138
extern Addrp xretslot[];
 
139
extern int cxslot;      /* Complex return argument slot (frame pointer offset)*/
 
140
extern int chslot;      /* Character return argument slot (fp offset) */
 
141
extern int chlgslot;    /* Argument slot for length of character buffer */
 
142
extern int procclass;   /* Class of the current procedure:  either CLPROC,
 
143
                           CLMAIN, CLBLOCK or CLUNKNOWN */
 
144
extern ftnint procleng; /* Length of function return value (e.g. char
 
145
                           string length).  If this is -1, then the length is
 
146
                           not known at compile time */
 
147
extern int nentry;      /* Number of entry points (other than the original
 
148
                           function call) into this procedure */
 
149
extern flag multitype;  /* YES iff there is more than one return value
 
150
                           possible */
 
151
extern int blklevel;
 
152
extern long lastiolabno;
 
153
extern long lastlabno;
 
154
extern int lastvarno;
 
155
extern int lastargslot; /* integer offset pointing to the next free
 
156
                           location for an argument to the current routine */
 
157
extern int argloc;
 
158
extern int autonum[];           /* for numbering
 
159
                                   automatic variables, e.g. temporaries */
 
160
extern int retlabel;
 
161
extern int ret0label;
 
162
extern int dorange;             /* Number of the label which terminates
 
163
                                   the innermost DO loop */
 
164
extern int regnum[ ];           /* Numbers of DO indicies named in
 
165
                                   regnamep   (below) */
 
166
extern Namep regnamep[ ];       /* List of DO indicies in registers */
 
167
extern int maxregvar;           /* number of elts in   regnamep   */
 
168
extern int highregvar;          /* keeps track of the highest register
 
169
                                   number used by DO index allocator */
 
170
extern int nregvar;             /* count of DO indicies in registers */
 
171
 
 
172
extern chainp templist[];
 
173
extern int maxdim;
 
174
extern chainp earlylabs;
 
175
extern chainp holdtemps;
 
176
extern struct Entrypoint *entries;
 
177
extern struct Rplblock *rpllist;
 
178
extern struct Chain *curdtp;
 
179
extern ftnint curdtelt;
 
180
extern chainp allargs;          /* union of args in entries */
 
181
extern int nallargs;            /* total number of args */
 
182
extern int nallchargs;          /* total number of character args */
 
183
extern flag toomanyinit;        /* True iff too many initializers in a
 
184
                                   DATA statement */
 
185
 
 
186
extern flag inioctl;
 
187
extern int iostmt;
 
188
extern Addrp ioblkp;
 
189
extern int nioctl;
 
190
extern int nequiv;
 
191
extern int eqvstart;    /* offset to eqv number to guarantee uniqueness
 
192
                           and prevent <something> from going negative */
 
193
extern int nintnames;
 
194
 
 
195
/* Chain of tagged blocks */
 
196
 
 
197
struct Chain
 
198
        {
 
199
        chainp nextp;
 
200
        char * datap;           /* Tagged block */
 
201
        };
 
202
 
 
203
extern chainp chains;
 
204
 
 
205
/* Recall that   field   is intended to hold four-bit characters */
 
206
 
 
207
/* This structure exists only to defeat the type checking */
 
208
 
 
209
struct Headblock
 
210
        {
 
211
        field tag;
 
212
        field vtype;
 
213
        field vclass;
 
214
        field vstg;
 
215
        expptr vleng;           /* Expression for length of char string -
 
216
                                   this may be a constant, or an argument
 
217
                                   generated by mkarg() */
 
218
        } ;
 
219
 
 
220
/* Control construct info (for do loops, else, etc) */
 
221
 
 
222
struct Ctlframe
 
223
        {
 
224
        unsigned ctltype:8;
 
225
        unsigned dostepsign:8;  /* 0 - variable, 1 - pos, 2 - neg */
 
226
        unsigned dowhile:1;
 
227
        int ctlabels[4];        /* Control labels, defined below */
 
228
        int dolabel;            /* label marking end of this DO loop */
 
229
        Namep donamep;          /* DO index variable */
 
230
        expptr doinit;          /* for use with -onetrip */
 
231
        expptr domax;           /* constant or temp variable holding MAX
 
232
                                   loop value; or expr of while(expr) */
 
233
        expptr dostep;          /* expression */
 
234
        Namep loopname;
 
235
        };
 
236
#define endlabel ctlabels[0]
 
237
#define elselabel ctlabels[1]
 
238
#define dobodylabel ctlabels[1]
 
239
#define doposlabel ctlabels[2]
 
240
#define doneglabel ctlabels[3]
 
241
extern struct Ctlframe *ctls;           /* Keeps info on DO and BLOCK IF
 
242
                                           structures - this is the stack
 
243
                                           bottom */
 
244
extern struct Ctlframe *ctlstack;       /* Pointer to current nesting
 
245
                                           level */
 
246
extern struct Ctlframe *lastctl;        /* Point to end of
 
247
                                           dynamically-allocated array */
 
248
 
 
249
typedef struct {
 
250
        int type;
 
251
        chainp cp;
 
252
        } Atype;
 
253
 
 
254
typedef struct {
 
255
        int defined, dnargs, nargs, changes;
 
256
        Atype atypes[1];
 
257
        } Argtypes;
 
258
 
 
259
/* External Symbols */
 
260
 
 
261
struct Extsym
 
262
        {
 
263
        char *fextname;         /* Fortran version of external name */
 
264
        char *cextname;         /* C version of external name */
 
265
        field extstg;           /* STG -- should be COMMON, UNKNOWN or EXT
 
266
                                   */
 
267
        unsigned extype:4;      /* for transmitting type to output routines */
 
268
        unsigned used_here:1;   /* Boolean - true on the second pass
 
269
                                   through a function if the block has
 
270
                                   been referenced */
 
271
        unsigned exused:1;      /* Has been used (for help with error msgs
 
272
                                   about externals typed differently in
 
273
                                   different modules) */
 
274
        unsigned exproto:1;     /* type specified in a .P file */
 
275
        unsigned extinit:1;     /* Procedure has been defined,
 
276
                                   or COMMON has DATA */
 
277
        unsigned extseen:1;     /* True if previously referenced */
 
278
        chainp extp;            /* List of identifiers in the common
 
279
                                   block for this function, stored as
 
280
                                   Namep (hash table pointers) */
 
281
        chainp allextp;         /* List of lists of identifiers; we keep one
 
282
                                   list for each layout of this common block */
 
283
        int curno;              /* current number for this common block,
 
284
                                   used for constructing appending _nnn
 
285
                                   to the common block name */
 
286
        int maxno;              /* highest curno value for this common block */
 
287
        ftnint extleng;
 
288
        ftnint maxleng;
 
289
        Argtypes *arginfo;
 
290
        };
 
291
typedef struct Extsym Extsym;
 
292
 
 
293
extern Extsym *extsymtab;       /* External symbol table */
 
294
extern Extsym *nextext;
 
295
extern Extsym *lastext;
 
296
extern int complex_seen, dcomplex_seen;
 
297
 
 
298
/* Statement labels */
 
299
 
 
300
struct Labelblock
 
301
        {
 
302
        int labelno;            /* Internal label */
 
303
        unsigned blklevel:8;    /* level of nesting, for branch-in-loop
 
304
                                   checking */
 
305
        unsigned labused:1;
 
306
        unsigned fmtlabused:1;
 
307
        unsigned labinacc:1;    /* inaccessible? (i.e. has its scope
 
308
                                   vanished) */
 
309
        unsigned labdefined:1;  /* YES or NO */
 
310
        unsigned labtype:2;     /* LAB{FORMAT,EXEC,etc} */
 
311
        ftnint stateno;         /* Original label */
 
312
        char *fmtstring;        /* format string */
 
313
        };
 
314
 
 
315
extern struct Labelblock *labeltab;     /* Label table - keeps track of
 
316
                                           all labels, including undefined */
 
317
extern struct Labelblock *labtabend;
 
318
extern struct Labelblock *highlabtab;
 
319
 
 
320
/* Entry point list */
 
321
 
 
322
struct Entrypoint
 
323
        {
 
324
        struct Entrypoint *entnextp;
 
325
        Extsym *entryname;      /* Name of this ENTRY */
 
326
        chainp arglist;
 
327
        int typelabel;                  /* Label for function exit; this
 
328
                                           will return the proper type of
 
329
                                           object */
 
330
        Namep enamep;                   /* External name */
 
331
        };
 
332
 
 
333
/* Primitive block, or Primary block.  This is a general template returned
 
334
   by the parser, which will be interpreted in context.  It is a template
 
335
   for an identifier (variable name, function name), parenthesized
 
336
   arguments (array subscripts, function parameters) and substring
 
337
   specifications. */
 
338
 
 
339
struct Primblock
 
340
        {
 
341
        field tag;
 
342
        field vtype;
 
343
        unsigned parenused:1;           /* distinguish (a) from a */
 
344
        Namep namep;                    /* Pointer to structure Nameblock */
 
345
        struct Listblock *argsp;
 
346
        expptr fcharp;                  /* first-char-index-pointer (in
 
347
                                           substring) */
 
348
        expptr lcharp;                  /* last-char-index-pointer (in
 
349
                                           substring) */
 
350
        };
 
351
 
 
352
 
 
353
struct Hashentry
 
354
        {
 
355
        int hashval;
 
356
        Namep varp;
 
357
        };
 
358
extern struct Hashentry *hashtab;       /* Hash table */
 
359
extern struct Hashentry *lasthash;
 
360
 
 
361
struct Intrpacked       /* bits for intrinsic function description */
 
362
        {
 
363
        unsigned f1:4;
 
364
        unsigned f2:4;
 
365
        unsigned f3:7;
 
366
        unsigned f4:1;
 
367
        };
 
368
 
 
369
struct Nameblock
 
370
        {
 
371
        field tag;
 
372
        field vtype;
 
373
        field vclass;
 
374
        field vstg;
 
375
        expptr vleng;           /* length of character string, if applicable */
 
376
        char *fvarname;         /* name in the Fortran source */
 
377
        char *cvarname;         /* name in the resulting C */
 
378
        chainp vlastdim;        /* datap points to new_vars entry for the */
 
379
                                /* system variable, if any, storing the final */
 
380
                                /* dimension; we zero the datap if this */
 
381
                                /* variable is needed */
 
382
        unsigned vprocclass:3;  /* P____ macros - selects the   varxptr
 
383
                                   field below */
 
384
        unsigned vdovar:1;      /* "is it a DO variable?" for register
 
385
                                   and multi-level loop checking */
 
386
        unsigned vdcldone:1;    /* "do I think I'm done?" - set when the
 
387
                                   context is sufficient to determine its
 
388
                                   status */
 
389
        unsigned vadjdim:1;     /* "adjustable dimension?" - needed for
 
390
                                   information about copies */
 
391
        unsigned vsave:1;
 
392
        unsigned vimpldovar:1;  /* used to prevent erroneous error messages
 
393
                                   for variables used only in DATA stmt
 
394
                                   implicit DOs */
 
395
        unsigned vis_assigned:1;/* True if this variable has had some
 
396
                                   label ASSIGNED to it; hence
 
397
                                   varxptr.assigned_values is valid */
 
398
        unsigned vimplstg:1;    /* True if storage type is assigned implicitly;
 
399
                                   this allows a COMMON variable to participate
 
400
                                   in a DIMENSION before the COMMON declaration.
 
401
                                   */
 
402
        unsigned vcommequiv:1;  /* True if EQUIVALENCEd onto STGCOMMON */
 
403
        unsigned vfmt_asg:1;    /* True if char *var_fmt needed */
 
404
        unsigned vpassed:1;     /* True if passed as a character-variable arg */
 
405
        unsigned vknownarg:1;   /* True if seen in a previous entry point */
 
406
        unsigned visused:1;     /* True if variable is referenced -- so we */
 
407
                                /* can omit variables that only appear in DATA */
 
408
        unsigned vnamelist:1;   /* Appears in a NAMELIST */
 
409
        unsigned vimpltype:1;   /* True if implicitly typed and not
 
410
                                   invoked as a function or subroutine
 
411
                                   (so we can consistently type procedures
 
412
                                   declared external and passed as args
 
413
                                   but never invoked).
 
414
                                   */
 
415
        unsigned vtypewarned:1; /* so we complain just once about
 
416
                                   changed types of external procedures */
 
417
        unsigned vinftype:1;    /* so we can restore implicit type to a
 
418
                                   procedure if it is invoked as a function
 
419
                                   after being given a different type by -it */
 
420
        unsigned vinfproc:1;    /* True if -it infers this to be a procedure */
 
421
        unsigned vcalled:1;     /* has been invoked */
 
422
        unsigned vdimfinish:1;  /* need to invoke dim_finish() */
 
423
        unsigned vrefused:1;    /* Need to #define name_ref (for -s) */
 
424
        unsigned vsubscrused:1; /* Need to #define name_subscr (for -2) */
 
425
        unsigned veqvadjust:1;  /* voffset has been adjusted for equivalence */
 
426
 
 
427
/* The   vardesc   union below is used to store the number of an intrinsic
 
428
   function (when vstg == STGINTR and vprocclass == PINTRINSIC), or to
 
429
   store the index of this external symbol in   extsymtab   (when vstg ==
 
430
   STGEXT and vprocclass == PEXTERNAL) */
 
431
 
 
432
        union   {
 
433
                int varno;              /* Return variable for a function.
 
434
                                           This is used when a function is
 
435
                                           assigned a return value.  Also
 
436
                                           used to point to the COMMON
 
437
                                           block, when this is a field of
 
438
                                           that block.  Also points to
 
439
                                           EQUIV block when STGEQUIV */
 
440
                struct Intrpacked intrdesc;     /* bits for intrinsic function*/
 
441
                } vardesc;
 
442
        struct Dimblock *vdim;  /* points to the dimensions if they exist */
 
443
        ftnint voffset;         /* offset in a storage block (the variable
 
444
                                   name will be "v.%d", voffset in a
 
445
                                   common blck on the vax).  Also holds
 
446
                                   pointers for automatic variables.  When
 
447
                                   STGEQUIV, this is -(offset from array
 
448
                                   base) */
 
449
        union   {
 
450
                chainp namelist;        /* points to names in the NAMELIST,
 
451
                                           if this is a NAMELIST name */
 
452
                chainp vstfdesc;        /* points to (formals, expr) pair */
 
453
                chainp assigned_values; /* list of integers, each being a
 
454
                                           statement label assigned to
 
455
                                           this variable in the current function */
 
456
                } varxptr;
 
457
        int argno;              /* for multiple entries */
 
458
        Argtypes *arginfo;
 
459
        };
 
460
 
 
461
 
 
462
/* PARAMETER statements */
 
463
 
 
464
struct Paramblock
 
465
        {
 
466
        field tag;
 
467
        field vtype;
 
468
        field vclass;
 
469
        field vstg;
 
470
        expptr vleng;
 
471
        char *fvarname;
 
472
        char *cvarname;
 
473
        expptr paramval;
 
474
        } ;
 
475
 
 
476
 
 
477
/* Expression block */
 
478
 
 
479
struct Exprblock
 
480
        {
 
481
        field tag;
 
482
        field vtype;
 
483
        field vclass;
 
484
        field vstg;
 
485
        expptr vleng;           /* in the case of a character expression, this
 
486
                                   value is inherited from the children */
 
487
        unsigned opcode;
 
488
        expptr leftp;
 
489
        expptr rightp;
 
490
        int typefixed;
 
491
        };
 
492
 
 
493
 
 
494
union Constant
 
495
        {
 
496
        struct {
 
497
                char *ccp0;
 
498
                ftnint blanks;
 
499
                } ccp1;
 
500
        ftnint ci;              /* Constant longeger */
 
501
        double cd[2];
 
502
        char *cds[2];
 
503
        };
 
504
#define ccp ccp1.ccp0
 
505
 
 
506
struct Constblock
 
507
        {
 
508
        field tag;
 
509
        field vtype;
 
510
        field vclass;
 
511
        field vstg;             /* vstg = 1 when using Const.cds */
 
512
        expptr vleng;
 
513
        union Constant Const;
 
514
        };
 
515
 
 
516
 
 
517
struct Listblock
 
518
        {
 
519
        field tag;
 
520
        field vtype;
 
521
        chainp listp;
 
522
        };
 
523
 
 
524
 
 
525
 
 
526
/* Address block - this is the FINAL form of identifiers before being
 
527
   sent to pass 2.  We'll want to add the original identifier here so that it can
 
528
   be preserved in the translation.
 
529
 
 
530
   An example identifier is q.7.  The "q" refers to the storage class
 
531
   (field vstg), the 7 to the variable number (int memno). */
 
532
 
 
533
struct Addrblock
 
534
        {
 
535
        field tag;
 
536
        field vtype;
 
537
        field vclass;
 
538
        field vstg;
 
539
        expptr vleng;
 
540
        /* put union...user here so the beginning of an Addrblock
 
541
         * is the same as a Constblock.
 
542
         */
 
543
        union {
 
544
            Namep name;         /* contains a pointer into the hash table */
 
545
            char ident[IDENT_LEN + 1];  /* C string form of identifier */
 
546
            char *Charp;
 
547
            union Constant Const;       /* Constant value */
 
548
            struct {
 
549
                double dfill[2];
 
550
                field vstg1;
 
551
                } kludge;       /* so we can distinguish string vs binary
 
552
                                 * floating-point constants */
 
553
        } user;
 
554
        long memno;             /* when vstg == STGCONST, this is the
 
555
                                   numeric part of the assembler label
 
556
                                   where the constant value is stored */
 
557
        expptr memoffset;       /* used in subscript computations, usually */
 
558
        unsigned istemp:1;      /* used in stack management of temporary
 
559
                                   variables */
 
560
        unsigned isarray:1;     /* used to show that memoffset is
 
561
                                   meaningful, even if zero */
 
562
        unsigned ntempelt:10;   /* for representing temporary arrays, as
 
563
                                   in concatenation */
 
564
        unsigned dbl_builtin:1; /* builtin to be declared double */
 
565
        unsigned charleng:1;    /* so saveargtypes can get i/o calls right */
 
566
        unsigned cmplx_sub:1;   /* used in complex arithmetic under -s */
 
567
        unsigned skip_offset:1; /* used in complex arithmetic under -s */
 
568
        unsigned parenused:1;   /* distinguish (a) from a */
 
569
        ftnint varleng;         /* holds a copy of a constant length which
 
570
                                   is stored in the   vleng   field (e.g.
 
571
                                   a double is 8 bytes) */
 
572
        int uname_tag;          /* Tag describing which of the unions()
 
573
                                   below to use */
 
574
        char *Field;            /* field name when dereferencing a struct */
 
575
}; /* struct Addrblock */
 
576
 
 
577
 
 
578
/* Errorbock - placeholder for errors, to allow the compilation to
 
579
   continue */
 
580
 
 
581
struct Errorblock
 
582
        {
 
583
        field tag;
 
584
        field vtype;
 
585
        };
 
586
 
 
587
 
 
588
/* Implicit DO block, especially related to DATA statements.  This block
 
589
   keeps track of the compiler's location in the implicit DO while it's
 
590
   running.  In particular, the   isactive and isbusy   flags tell where
 
591
   it is */
 
592
 
 
593
struct Impldoblock
 
594
        {
 
595
        field tag;
 
596
        unsigned isactive:1;
 
597
        unsigned isbusy:1;
 
598
        Namep varnp;
 
599
        Constp varvp;
 
600
        chainp impdospec;
 
601
        expptr implb;
 
602
        expptr impub;
 
603
        expptr impstep;
 
604
        ftnint impdiff;
 
605
        ftnint implim;
 
606
        struct Chain *datalist;
 
607
        };
 
608
 
 
609
 
 
610
/* Each of these components has a first field called   tag.   This union
 
611
   exists just for allocation simplicity */
 
612
 
 
613
union Expression
 
614
        {
 
615
        field tag;
 
616
        struct Addrblock addrblock;
 
617
        struct Constblock constblock;
 
618
        struct Errorblock errorblock;
 
619
        struct Exprblock exprblock;
 
620
        struct Headblock headblock;
 
621
        struct Impldoblock impldoblock;
 
622
        struct Listblock listblock;
 
623
        struct Nameblock nameblock;
 
624
        struct Paramblock paramblock;
 
625
        struct Primblock primblock;
 
626
        } ;
 
627
 
 
628
 
 
629
 
 
630
struct Dimblock
 
631
        {
 
632
        int ndim;
 
633
        expptr nelt;            /* This is NULL if the array is unbounded */
 
634
        expptr baseoffset;      /* a constant or local variable holding
 
635
                                   the offset in this procedure */
 
636
        expptr basexpr;         /* expression for comuting the offset, if
 
637
                                   it's not constant.  If this is
 
638
                                   non-null, the register named in
 
639
                                   baseoffset will get initialized to this
 
640
                                   value in the procedure's prolog */
 
641
        struct
 
642
                {
 
643
                expptr dimsize; /* constant or register holding the size
 
644
                                   of this dimension */
 
645
                expptr dimexpr; /* as above in basexpr, this is an
 
646
                                   expression for computing a variable
 
647
                                   dimension */
 
648
                } dims[1];      /* Dimblocks are allocated with enough
 
649
                                   space for this to become dims[ndim] */
 
650
        };
 
651
 
 
652
 
 
653
/* Statement function identifier stack - this holds the name and value of
 
654
   the parameters in a statement function invocation.  For example,
 
655
 
 
656
        f(x,y,z)=x+y+z
 
657
                .
 
658
                .
 
659
        y = f(1,2,3)
 
660
 
 
661
   generates a stack of depth 3, with <x 1>, <y 2>, <z 3> AT THE INVOCATION, NOT
 
662
   at the definition */
 
663
 
 
664
struct Rplblock /* name replacement block */
 
665
        {
 
666
        struct Rplblock *rplnextp;
 
667
        Namep rplnp;            /* Name of the formal parameter */
 
668
        expptr rplvp;           /* Value of the actual parameter */
 
669
        expptr rplxp;           /* Initialization of temporary variable,
 
670
                                   if required; else null */
 
671
        int rpltag;             /* Tag on the value of the actual param */
 
672
        };
 
673
 
 
674
 
 
675
 
 
676
/* Equivalence block */
 
677
 
 
678
struct Equivblock
 
679
        {
 
680
        struct Eqvchain *equivs;        /* List (Eqvchain) of primblocks
 
681
                                           holding variable identifiers */
 
682
        flag eqvinit;
 
683
        long eqvtop;
 
684
        long eqvbottom;
 
685
        int eqvtype;
 
686
        } ;
 
687
#define eqvleng eqvtop
 
688
 
 
689
extern struct Equivblock *eqvclass;
 
690
 
 
691
 
 
692
struct Eqvchain
 
693
        {
 
694
        struct Eqvchain *eqvnextp;
 
695
        union
 
696
                {
 
697
                struct Primblock *eqvlhs;
 
698
                Namep eqvname;
 
699
                } eqvitem;
 
700
        long eqvoffset;
 
701
        } ;
 
702
 
 
703
 
 
704
 
 
705
/* For allocation purposes only, and to keep lint quiet.  In particular,
 
706
   don't count on the tag being able to tell you which structure is used */
 
707
 
 
708
 
 
709
/* There is a tradition in Fortran that the compiler not generate the same
 
710
   bit pattern more than is necessary.  This structure is used to do just
 
711
   that; if two integer constants have the same bit pattern, just generate
 
712
   it once.  This could be expanded to optimize without regard to type, by
 
713
   removing the type check in   putconst()   */
 
714
 
 
715
struct Literal
 
716
        {
 
717
        short littype;
 
718
        short lituse;           /* usage count */
 
719
        long litnum;                    /* numeric part of the assembler
 
720
                                           label for this constant value */
 
721
        union   {
 
722
                ftnint litival;
 
723
                double litdval[2];
 
724
                ftnint litival2[2];     /* length, nblanks for strings */
 
725
                } litval;
 
726
        char *cds[2];
 
727
        };
 
728
 
 
729
extern struct Literal *litpool;
 
730
extern int maxliterals, nliterals;
 
731
extern char Letters[];
 
732
#define letter(x) Letters[x]
 
733
 
 
734
struct Dims { expptr lb, ub; };
 
735
 
 
736
extern int forcedouble;         /* force real functions to double */
 
737
extern int doin_setbound;       /* special handling for array bounds */
 
738
extern int Ansi;
 
739
extern char hextoi_tab[];
 
740
#define hextoi(x) hextoi_tab[(x) & 0xff]
 
741
extern char *casttypes[], *ftn_types[], *protorettypes[], *usedcasts[];
 
742
extern int Castargs, infertypes;
 
743
extern FILE *protofile;
 
744
extern char binread[], binwrite[], textread[], textwrite[];
 
745
extern char *ei_first, *ei_last, *ei_next;
 
746
extern char *wh_first, *wh_last, *wh_next;
 
747
extern char *halign, *outbuf, *outbtail;
 
748
extern flag keepsubs;
 
749
#ifdef TYQUAD
 
750
extern flag use_tyquad;
 
751
#endif
 
752
extern int n_keywords;
 
753
extern char *c_keywords[];
 
754
 
 
755
#ifdef KR_headers
 
756
#define Argdcl(x) ()
 
757
#define Void /* void */
 
758
#else
 
759
#define Argdcl(x) x
 
760
#define Void void
 
761
#endif
 
762
 
 
763
char*   Alloc Argdcl((int));
 
764
char*   Argtype Argdcl((int, char*));
 
765
void    Fatal Argdcl((char*));
 
766
struct  Impldoblock* mkiodo Argdcl((chainp, chainp));
 
767
tagptr  Inline Argdcl((int, int, chainp));
 
768
struct  Labelblock* execlab Argdcl((long));
 
769
struct  Labelblock* mklabel Argdcl((long));
 
770
struct  Listblock* mklist Argdcl((chainp));
 
771
void    Un_link_all Argdcl((int));
 
772
void    add_extern_to_list Argdcl((Addrp, chainp*));
 
773
int     addressable Argdcl((tagptr));
 
774
tagptr  addrof Argdcl((tagptr));
 
775
char*   addunder Argdcl((char*));
 
776
Addrp   autovar Argdcl((int, int, tagptr, char*));
 
777
void    backup Argdcl((char*, char*));
 
778
void    bad_atypes Argdcl((Argtypes*, char*, int, int, int, char*, char*));
 
779
int     badchleng Argdcl((tagptr));
 
780
void    badop Argdcl((char*, int));
 
781
void    badstg Argdcl((char*, int));
 
782
void    badtag Argdcl((char*, int));
 
783
void    badthing Argdcl((char*, char*, int));
 
784
void    badtype Argdcl((char*, int));
 
785
Addrp   builtin Argdcl((int, char*, int));
 
786
char*   c_name Argdcl((char*, int));
 
787
tagptr  call0 Argdcl((int, char*));
 
788
tagptr  call1 Argdcl((int, char*, tagptr));
 
789
tagptr  call2 Argdcl((int, char*, tagptr, tagptr));
 
790
tagptr  call3 Argdcl((int, char*, tagptr, tagptr, tagptr));
 
791
tagptr  call4 Argdcl((int, char*, tagptr, tagptr, tagptr, tagptr));
 
792
tagptr  callk Argdcl((int, char*, chainp));
 
793
void    cast_args Argdcl((int, chainp));
 
794
char*   cds Argdcl((char*, char*));
 
795
void    changedtype Argdcl((Namep));
 
796
ptr     ckalloc Argdcl((int));
 
797
int     cktype Argdcl((int, int, int));
 
798
void    clf Argdcl((FILEP*, char*, int));
 
799
int     cmpstr Argdcl((char*, char*, long, long));
 
800
char*   c_type_decl Argdcl((int, int));
 
801
Extsym* comblock Argdcl((char*));
 
802
char*   comm_union_name Argdcl((int));
 
803
void    consconv Argdcl((int, Constp, Constp));
 
804
void    consnegop Argdcl((Constp));
 
805
int     conssgn Argdcl((tagptr));
 
806
char*   convic Argdcl((long));
 
807
void    copy_data Argdcl((chainp));
 
808
char*   copyn Argdcl((int, char*));
 
809
char*   copys Argdcl((char*));
 
810
tagptr  cpblock Argdcl((int, char*));
 
811
tagptr  cpexpr Argdcl((tagptr));
 
812
void    cpn Argdcl((int, char*, char*));
 
813
char*   cpstring Argdcl((char*));
 
814
void    dataline Argdcl((char*, long, int));
 
815
char*   dataname Argdcl((int, long));
 
816
void    dataval Argdcl((tagptr, tagptr));
 
817
void    dclerr Argdcl((char*, Namep));
 
818
void    def_commons Argdcl((FILEP));
 
819
void    def_start Argdcl((FILEP, char*, char*, char*));
 
820
void    deregister Argdcl((Namep));
 
821
void    do_uninit_equivs Argdcl((FILEP, ptr));
 
822
void    doequiv(Void);
 
823
int     dofork(Void);
 
824
void    doinclude Argdcl((char*));
 
825
void    doio Argdcl((chainp));
 
826
void    done Argdcl((int));
 
827
void    donmlist(Void);
 
828
int     dsort Argdcl((char*, char*));
 
829
char*   dtos Argdcl((double));
 
830
void    elif_out Argdcl((FILEP, tagptr));
 
831
void    end_else_out Argdcl((FILEP));
 
832
void    enddcl(Void);
 
833
void    enddo Argdcl((int));
 
834
void    endio(Void);
 
835
void    endioctl(Void);
 
836
void    endproc(Void);
 
837
void    entrypt Argdcl((int, int, long, Extsym*, chainp));
 
838
int     eqn Argdcl((int, char*, char*));
 
839
char*   equiv_name Argdcl((int, char*));
 
840
void    err Argdcl((char*));
 
841
void    err66 Argdcl((char*));
 
842
void    errext Argdcl((char*));
 
843
void    erri Argdcl((char*, int));
 
844
void    errl Argdcl((char*, long));
 
845
tagptr  errnode(Void);
 
846
void    errstr Argdcl((char*, char*));
 
847
void    exarif Argdcl((tagptr, struct Labelblock*, struct Labelblock*, struct Labelblock*));
 
848
void    exasgoto Argdcl((Namep));
 
849
void    exassign Argdcl((Namep, struct Labelblock*));
 
850
void    excall Argdcl((Namep, struct Listblock*, int, struct Labelblock**));
 
851
void    exdo Argdcl((int, Namep, chainp));
 
852
void    execerr Argdcl((char*, char*));
 
853
void    exelif Argdcl((tagptr));
 
854
void    exelse(Void);
 
855
void    exenddo Argdcl((Namep));
 
856
void    exendif(Void);
 
857
void    exequals Argdcl((struct Primblock*, tagptr));
 
858
void    exgoto Argdcl((struct Labelblock*));
 
859
void    exif Argdcl((tagptr));
 
860
void    exreturn Argdcl((tagptr));
 
861
void    exstop Argdcl((int, tagptr));
 
862
void    extern_out Argdcl((FILEP, Extsym*));
 
863
void    fatali Argdcl((char*, int));
 
864
void    fatalstr Argdcl((char*, char*));
 
865
void    ffilecopy Argdcl((FILEP, FILEP));
 
866
void    fileinit(Void);
 
867
int     fixargs Argdcl((int, struct Listblock*));
 
868
tagptr  fixexpr Argdcl((Exprp));
 
869
tagptr  fixtype Argdcl((tagptr));
 
870
char*   flconst Argdcl((char*, char*));
 
871
void    flline(Void);
 
872
void    fmt_init(Void);
 
873
void    fmtname Argdcl((Namep, Addrp));
 
874
int     fmtstmt Argdcl((struct Labelblock*));
 
875
tagptr  fold Argdcl((tagptr));
 
876
void    frchain Argdcl((chainp*));
 
877
void    frdata Argdcl((chainp));
 
878
void    freetemps(Void);
 
879
void    freqchain Argdcl((struct Equivblock*));
 
880
void    frexchain Argdcl((chainp*));
 
881
void    frexpr Argdcl((tagptr));
 
882
void    frrpl(Void);
 
883
void    frtemp Argdcl((Addrp));
 
884
char*   gmem Argdcl((int, int));
 
885
void    hashclear(Void);
 
886
chainp  hookup Argdcl((chainp, chainp));
 
887
expptr  imagpart Argdcl((Addrp));
 
888
void    impldcl Argdcl((Namep));
 
889
int     in_vector Argdcl((char*, char**, int));
 
890
void    incomm Argdcl((Extsym*, Namep));
 
891
void    inferdcl Argdcl((Namep, int));
 
892
int     inilex Argdcl((char*));
 
893
void    initkey(Void);
 
894
int     inregister Argdcl((Namep));
 
895
long    int commlen Argdcl((chainp));
 
896
long    int convci Argdcl((int, char*));
 
897
long    int iarrlen Argdcl((Namep));
 
898
long    int lencat Argdcl((expptr));
 
899
long    int lmax Argdcl((long, long));
 
900
long    int lmin Argdcl((long, long));
 
901
long    int wr_char_len Argdcl((FILEP, struct Dimblock*, int, int));
 
902
Addrp   intraddr Argdcl((Namep));
 
903
tagptr  intrcall Argdcl((Namep, struct Listblock*, int));
 
904
int     intrfunct Argdcl((char*));
 
905
void    ioclause Argdcl((int, expptr));
 
906
int     iocname(Void);
 
907
int     is_negatable Argdcl((Constp));
 
908
int     isaddr Argdcl((tagptr));
 
909
int     isnegative_const Argdcl((Constp));
 
910
int     isstatic Argdcl((tagptr));
 
911
chainp  length_comp Argdcl((struct Entrypoint*, int));
 
912
int     lengtype Argdcl((int, long));
 
913
char*   lexline Argdcl((ptr));
 
914
void    list_arg_types Argdcl((FILEP, struct Entrypoint*, chainp, int, char*));
 
915
void    list_decls Argdcl((FILEP));
 
916
void    list_init_data Argdcl((FILE **, char *, FILE *));
 
917
void    listargs Argdcl((FILEP, struct Entrypoint*, int, chainp));
 
918
char*   lit_name Argdcl((struct Literal*));
 
919
int     log_2 Argdcl((long));
 
920
char*   lower_string Argdcl((char*, char*));
 
921
int     main Argdcl((int, char**));
 
922
expptr  make_int_expr Argdcl((expptr));
 
923
void    make_param Argdcl((struct Paramblock*, tagptr));
 
924
void    many Argdcl((char*, char, int));
 
925
void    margin_printf Argdcl((FILEP, char*, ...));
 
926
int     maxtype Argdcl((int, int));
 
927
char*   mem Argdcl((int, int));
 
928
void    mem_init(Void);
 
929
char*   memname Argdcl((int, long));
 
930
Addrp   memversion Argdcl((Namep));
 
931
tagptr  mkaddcon Argdcl((long));
 
932
Addrp   mkaddr Argdcl((Namep));
 
933
Addrp   mkarg Argdcl((int, int));
 
934
tagptr  mkbitcon Argdcl((int, int, char*));
 
935
chainp  mkchain Argdcl((char*, chainp));
 
936
Constp  mkconst Argdcl((int));
 
937
tagptr  mkconv Argdcl((int, tagptr));
 
938
tagptr  mkcxcon Argdcl((tagptr, tagptr));
 
939
tagptr  mkexpr Argdcl((int, tagptr, tagptr));
 
940
Extsym* mkext Argdcl((char*, char*));
 
941
Extsym* mkext1 Argdcl((char*, char*));
 
942
Addrp   mkfield Argdcl((Addrp, char*, int));
 
943
tagptr  mkfunct Argdcl((tagptr));
 
944
tagptr  mkintcon Argdcl((long));
 
945
tagptr  mklhs Argdcl((struct Primblock*, int));
 
946
tagptr  mklogcon Argdcl((int));
 
947
Namep   mkname Argdcl((char*));
 
948
Addrp   mkplace Argdcl((Namep));
 
949
tagptr  mkprim Argdcl((Namep, struct Listblock*, chainp));
 
950
tagptr  mkrealcon Argdcl((int, char*));
 
951
Addrp   mkscalar Argdcl((Namep));
 
952
void    mkstfunct Argdcl((struct Primblock*, tagptr));
 
953
tagptr  mkstrcon Argdcl((int, char*));
 
954
Addrp   mktmp Argdcl((int, tagptr));
 
955
Addrp   mktmp0 Argdcl((int, tagptr));
 
956
Addrp   mktmpn Argdcl((int, int, tagptr));
 
957
void    namelist Argdcl((Namep));
 
958
int     ncat Argdcl((expptr));
 
959
void    negate_const Argdcl((Constp));
 
960
void    new_endif(Void);
 
961
Extsym* newentry Argdcl((Namep, int));
 
962
long    newlabel(Void);
 
963
void    newproc(Void);
 
964
Addrp   nextdata Argdcl((long*));
 
965
void    nice_printf Argdcl((FILEP, char*, ...));
 
966
void    not_both Argdcl((char*));
 
967
void    np_init(Void);
 
968
int     oneof_stg Argdcl((Namep, int, int));
 
969
int     op_assign Argdcl((int));
 
970
tagptr  opconv Argdcl((tagptr, int));
 
971
FILEP   opf Argdcl((char*, char*));
 
972
void    out_addr Argdcl((FILEP, Addrp));
 
973
void    out_asgoto Argdcl((FILEP, tagptr));
 
974
void    out_call Argdcl((FILEP, int, int, tagptr, tagptr, tagptr));
 
975
void    out_const Argdcl((FILEP, Constp));
 
976
void    out_else Argdcl((FILEP));
 
977
void    out_for Argdcl((FILEP, tagptr, tagptr, tagptr));
 
978
void    out_init(Void);
 
979
void    outbuf_adjust(Void);
 
980
void    p1_label Argdcl((long));
 
981
void    prcona Argdcl((FILEP, long));
 
982
void    prconi Argdcl((FILEP, long));
 
983
void    prconr Argdcl((FILEP, Constp, int));
 
984
void    procinit(Void);
 
985
void    procode Argdcl((FILEP));
 
986
void    prolog Argdcl((FILEP, chainp));
 
987
void    protowrite Argdcl((FILEP, int, char*, struct Entrypoint*, chainp));
 
988
expptr  prune_left_conv Argdcl((expptr));
 
989
int     put_one_arg Argdcl((int, char*, char**, char*, char*));
 
990
expptr  putassign Argdcl((expptr, expptr));
 
991
Addrp   putchop Argdcl((tagptr));
 
992
void    putcmgo Argdcl((tagptr, int, struct Labelblock**));
 
993
Addrp   putconst Argdcl((Constp));
 
994
tagptr  putcxop Argdcl((tagptr));
 
995
void    puteq Argdcl((expptr, expptr));
 
996
void    putexpr Argdcl((expptr));
 
997
void    puthead Argdcl((char*, int));
 
998
void    putif Argdcl((tagptr, int));
 
999
void    putout Argdcl((tagptr));
 
1000
expptr  putsteq Argdcl((Addrp, Addrp));
 
1001
void    putwhile Argdcl((tagptr));
 
1002
tagptr  putx Argdcl((tagptr));
 
1003
void    r8fix(Void);
 
1004
int     rdlong Argdcl((FILEP, long*));
 
1005
int     rdname Argdcl((FILEP, ptr, char*));
 
1006
void    read_Pfiles Argdcl((char**));
 
1007
Addrp   realpart Argdcl((Addrp));
 
1008
chainp  revchain Argdcl((chainp));
 
1009
int     same_expr Argdcl((tagptr, tagptr));
 
1010
int     same_ident Argdcl((tagptr, tagptr));
 
1011
void    save_argtypes Argdcl((chainp, Argtypes**, Argtypes**, int, char*, int, int, int, int));
 
1012
void    saveargtypes Argdcl((Exprp));
 
1013
void    set_externs(Void);
 
1014
void    set_tmp_names(Void);
 
1015
void    setbound Argdcl((Namep, int, struct Dims*));
 
1016
void    setdata Argdcl((Addrp, Constp, long));
 
1017
void    setext Argdcl((Namep));
 
1018
void    setfmt Argdcl((struct Labelblock*));
 
1019
void    setimpl Argdcl((int, long, int, int));
 
1020
void    setintr Argdcl((Namep));
 
1021
void    settype Argdcl((Namep, int, long));
 
1022
void    sigcatch Argdcl((int));
 
1023
void    sserr Argdcl((Namep));
 
1024
void    start_formatting(Void);
 
1025
void    startioctl(Void);
 
1026
void    startproc Argdcl((Extsym*, int));
 
1027
void    startrw(Void);
 
1028
char*   string_num Argdcl((char*, long));
 
1029
int     struct_eq Argdcl((chainp, chainp));
 
1030
tagptr  subcheck Argdcl((Namep, tagptr));
 
1031
tagptr  suboffset Argdcl((struct Primblock*));
 
1032
int     type_fixup Argdcl((Argtypes*, Atype*, int));
 
1033
void    unamstring Argdcl((Addrp, char*));
 
1034
void    unclassifiable(Void);
 
1035
void    vardcl Argdcl((Namep));
 
1036
void    warn Argdcl((char*));
 
1037
void    warn1 Argdcl((char*, char*));
 
1038
void    warni Argdcl((char*, int));
 
1039
void    wr_abbrevs Argdcl((FILEP, int, chainp));
 
1040
char*   wr_ardecls Argdcl((FILE*, struct Dimblock*, long));
 
1041
void    wr_array_init Argdcl((FILEP, int, chainp));
 
1042
void    wr_common_decls Argdcl((FILEP));
 
1043
void    wr_equiv_init Argdcl((FILEP, int, chainp*, int));
 
1044
void    wr_globals Argdcl((FILEP));
 
1045
void    wr_nv_ident_help Argdcl((FILEP, Addrp));
 
1046
void    wr_struct Argdcl((FILEP, chainp));
 
1047
void    wronginf Argdcl((Namep));
 
1048
void    yyerror Argdcl((char*));
 
1049
int     yylex(Void);
 
1050
int     yyparse(Void);
 
1051
 
 
1052
#ifdef USE_DTOA
 
1053
#define atof(x) strtod(x,0)
 
1054
void    g_fmt Argdcl((char*, double));
 
1055
#endif