#define BIGGEST_CHAR 0x7f /* Assumes 32-bit arithmetic */
#define BIGGEST_SHORT 0x7fff /* Assumes 32-bit arithmetic */
#define BIGGEST_LONG 0x7fffffff /* Assumes 32-bit arithmetic */
#define M(x) (1<<x) /* Mask (x) returns 2^x */
#define ALLOC(x) (struct x *) ckalloc((int)sizeof(struct x))
#define ALLEXPR (expptr) ckalloc((int)sizeof(union Expression) )
typedef char field
; /* actually need only 4 bits */
#define CNULL (char *) 0 /* Character string null */
#define CHNULL (chainp) 0 /* Chain null */
/* BAD_MEMNO - used to distinguish between long string constants and other
constants in the table */
/* block tag values -- syntactic stuff */
#define TPRIM 5 /* Primitive datum - should not appear in an
expptr variable, it should have already been
/* parser states - order is important, since there are several tests for
/* storage classes -- vstg values. BSS and INIT are used in the later
merge pass over identifiers; and they are entered differently into the
#define STGARG 1 /* adjustable dimensions */
#define STGAUTO 2 /* for stack references */
#define STGBSS 3 /* uninitialized storage (normal variables) */
#define STGINIT 4 /* initialized storage */
#define STGEXT 6 /* external storage */
#define STGINTR 7 /* intrinsic (late decision) reference. See
chapter 5 of the Fortran 77 standard */
#define STGREG 11 /* register - the outermost DO loop index will be
in a register (because the compiler is one
pass, it can't know where the innermost loop is
#define STGMEMNO 14 /* interemediate-file pointer to constant table */
/* name classes -- vclass values, also procclass values */
#define CLPARAM 1 /* Parameter - macro definition */
#define CLVAR 2 /* variable */
#define CLNAMELIST 7 /* in data with this tag, the vdcldone flag should
be ignored (according to vardcl()) */
/* vprocclass values -- there is some overlap with the vclass values given
#define PTHISPROC 4 /* here to allow recursion - further distinction
is given in the CL tag (those just above).
This applies to the presence of the name of a
function used within itself. The function name
means either call the function again, or assign
some value to the storage allocated to the
function's return value. */
/* control stack codes - these are part of a state machine which handles
the nesting of blocks (i.e. what to do about the ELSE statement) */
/* operators for both Fortran input and C output. They are common because
so many are shared between the trees */
#define OPWHATSIN 40 /* dereferencing operator */
#define OPMINUSEQ 41 /* assignment operators */
#define OPPREINC 49 /* Preincrement (++x) operator */
#define OPPREDEC 50 /* Predecrement (--x) operator */
#define OPDOT 51 /* structure field reference */
#define OPARROW 52 /* structure pointer field reference */
#define OPNEG1 53 /* simple negation under forcedouble */
#define OPDMIN 54 /* min(a,b) macro under forcedouble */
#define OPDMAX 55 /* max(a,b) macro under forcedouble */
#define OPASSIGNI 56 /* assignment for inquire stmt */
#define OPIDENTITY 57 /* for turning TADDR into TEXPR */
#define OPCHARCAST 58 /* for casting to char * (in I/O stmts) */
#define OPDABS 59 /* abs macro under forcedouble */
#define OPMIN2 60 /* min(a,b) macro */
#define OPMAX2 61 /* max(a,b) macro */
/* label type codes -- used with the ASSIGN statement */
/* INTRINSIC function codes*/
#define INTRGEN 4 /* General intrinsic, e.g. cos v. dcos, zcos, ccos */
#define INTRCNST 7 /* constants, e.g. bigint(1.0) v. bigint (1d0) */
/* I/O statement codes - these all form Integer Constants, and are always
/* User name tags -- these identify the form of the original identifier
stored in a struct Addrblock structure (in the user field). */
#define UNAM_UNKNOWN 0 /* Not specified */
#define UNAM_NAME 1 /* Local symbol, store in the hash table */
#define UNAM_IDENT 2 /* Character string not stored elsewhere */
#define UNAM_EXTERN 3 /* External reference; check symbol table
#define UNAM_CONST 4 /* Constant value */
#define UNAM_CHARP 5 /* pointer to string */
#define UNAM_REF 6 /* subscript reference with -s */
#define IDENT_LEN 31 /* Maximum length user.ident */
/* type masks - TYLOGICAL defined in ftypes */
#define MSKLOGICAL M(TYLOGICAL)|M(TYLOGICAL1)|M(TYLOGICAL2)
#define MSKADDR M(TYADDR)
#define MSKCHAR M(TYCHAR)
#define MSKINT M(TYINT1)|M(TYSHORT)|M(TYLONG)|M(TYQUAD)
#define MSKINT M(TYINT1)|M(TYSHORT)|M(TYLONG)
#define MSKREAL M(TYREAL)|M(TYDREAL) /* DREAL means Double Real */
#define MSKCOMPLEX M(TYCOMPLEX)|M(TYDCOMPLEX)
#define MSKSTATIC (M(STGINIT)|M(STGBSS)|M(STGCOMMON)|M(STGEQUIV)|M(STGCONST))
/* miscellaneous macros */
/* ONEOF (x, y) -- x is the number of one of the OR'ed masks in y (i.e., x is
the log of one of the OR'ed masks in y) */
#define ONEOF(x,y) (M(x) & (y))
#define ISCOMPLEX(z) ONEOF(z, MSKCOMPLEX)
#define ISREAL(z) ONEOF(z, MSKREAL)
#define ISNUMERIC(z) ONEOF(z, MSKINT|MSKREAL|MSKCOMPLEX)
#define ISICON(z) (z->tag==TCONST && ISINT(z->constblock.vtype))
#define ISLOGICAL(z) ONEOF(z, MSKLOGICAL)
/* ISCHAR assumes that z has some kind of structure, i.e. is not null */
#define ISCHAR(z) (z->headblock.vtype==TYCHAR)
#define ISINT(z) ONEOF(z, MSKINT) /* z is a tag, i.e. a mask number */
#define ISCONST(z) (z->tag==TCONST)
#define ISERROR(z) (z->tag==TERROR)
#define ISPLUSOP(z) (z->tag==TEXPR && z->exprblock.opcode==OPPLUS)
#define ISSTAROP(z) (z->tag==TEXPR && z->exprblock.opcode==OPSTAR)
#define ISONE(z) (ISICON(z) && z->constblock.Const.ci==1)
#define INT(z) ONEOF(z, MSKINT|MSKCHAR) /* has INT storage in real life */
#define ICON(z) mkintcon( (ftnint)(z) )
/* NO66 -- F77 feature is being used
NOEXT -- F77 extension is being used */
#define NO66(s) if(no66flag) err66(s)
#define NOEXT(s) if(noextflag) errext(s)
/* round a up to the nearest multiple of b:
a = b * floor ( (a + (b - 1)) / b )*/
#define roundup(a,b) ( b * ( (a+b-1)/b) )