Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

c.h File Reference

#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include "config.h"
#include "token.h"

Include dependency graph for c.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  binding
struct  code
struct  coord
struct  Events
struct  field
struct  interface
struct  list
struct  metrics
struct  node
struct  swtch
struct  symbol
struct  tree
struct  type
struct  value
struct  Xtype

Defines

#define BUFSIZE   4096
#define extend(x, ty)   ((x)&(1<<(8*(ty)->size-1)) ? (x)|((~0UL)<<(8*(ty)->size-1)) : (x)&ones(8*(ty)->size))
#define fieldleft(p)
#define fieldmask(p)   (~(~(unsigned)0<<fieldsize(p)))
#define fieldright(p)   ((p)->lsb - 1)
#define fieldsize(p)   (p)->bitsize
#define generic(op)   ((op)&0x3F0)
#define gop(name, value)   name=value<<4,
#define isaddrop(op)
#define isarith(t)   (unqual(t)->op <= UNSIGNED)
#define isarray(t)   (unqual(t)->op == ARRAY)
#define ischar(t)   ((t)->size == 1 && isint(t))
#define isconst(t)
#define isenum(t)   (unqual(t)->op == ENUM)
#define isfloat(t)   (unqual(t)->op == FLOAT)
#define isfunc(t)   (unqual(t)->op == FUNCTION)
#define isint(t)
#define isptr(t)   (unqual(t)->op == POINTER)
#define isqual(t)   ((t)->op >= CONST)
#define isscalar(t)
#define isstruct(t)
#define istypename(t, tsym)
#define isunion(t)   (unqual(t)->op == UNION)
#define isunsigned(t)   (unqual(t)->op == UNSIGNED)
#define isvolatile(t)
#define MAXLINE   512
#define mkop(op, ty)   (specific((op) + ttob(ty)))
#define NELEMS(a)   ((int)(sizeof (a)/sizeof ((a)[0])))
#define NEW(p, a)   ((p) = allocate(sizeof *(p), (a)))
#define NEW0(p, a)   memset(NEW((p),(a)), 0, sizeof *(p))
#define ones(n)   ((n)>=8*sizeof (unsigned long) ? ~0UL : ~((~0UL)<<(n)))
#define op(name, type, sizes)
#define opindex(op)   (((op)>>4)&0x3F)
#define opkind(op)   ((op)&~0x3F0)
#define opsize(op)   ((op)>>10)
#define optype(op)   ((op)&0xF)
#define roundup(x, n)   (((x)+((n)-1))&(~((n)-1)))
#define sizeop(n)   ((n)<<10)
#define specific(op)   ((op)&0x3FF)
#define unqual(t)   (isqual(t) ? (t)->type : (t))
#define xx(a, b, c, d, e, f, g)   a=b,
#define yy(a, b, c, d, e, f, g)

Typedefs

typedef void(* Apply )(void *, void *, void *)
typedef binding Binding
typedef codeCode
typedef coord Coordinate
typedef fieldField
typedef interface Interface
typedef listList
typedef metrics Metrics
typedef nodeNode
typedef swtchSwtch
typedef symbolSymbol
typedef tableTable
typedef treeTree
typedef typeType
typedef value Value

Enumerations

enum  {
  a, b, c, d,
  e, f, a, b,
  c, d, e, f,
  yy, FLOAT, CHAR, DOUBLE,
  CHAR, CHAR, CHAR, SHORT,
  CHAR, INT, CHAR, UNSIGNED,
  CHAR, POINTER, VOID, CHAR,
  STRUCT, CHAR, UNION, CHAR,
  FUNCTION, ARRAY, ENUM, CHAR,
  LONG, CHAR, CONST, CHAR,
  VOLATILE, CHAR, yy, yy,
  yy, yy, yy, yy,
  yy, yy, yy, yy,
  yy, yy, yy, yy,
  yy, ID, ID, yy,
  ID, FCON, ID, ICON,
  ID, SCON, ID, yy,
  MOD, bittree, yy, BAND,
  bittree, ID, INCR, ADD,
  addtree, ID, yy, ID,
  yy, yy, MUL, multree,
  ID, yy, ADD, addtree,
  ID, yy, yy, SUB,
  subtree, ID, yy, yy,
  DIV, multree, DECR, SUB,
  subtree, ID, DEREF, DEREF,
  ANDAND, AND = 38<<4, andtree, ANDAND,
  OROR, OR = 40<<4, andtree, OROR,
  LEQ, LE, cmptree, LEQ,
  yy, LT, cmptree, yy,
  ASGN, asgntree
}
enum  {
  F = FLOAT, I = INT, U = UNSIGNED, P = POINTER,
  V = VOID, B = STRUCT
}
enum  {
  CNST, CNST, F = FLOAT, CNST,
  I = INT, CNST, P = POINTER, CNST,
  U = UNSIGNED, ARG, ARG, B = STRUCT,
  ARG, F = FLOAT, ARG, I = INT,
  ARG, P = POINTER, ARG, U = UNSIGNED,
  ASGN, ASGN, B = STRUCT, ASGN,
  F = FLOAT, ASGN, I = INT, ASGN,
  P = POINTER, ASGN, U = UNSIGNED, INDIR,
  INDIR, B = STRUCT, INDIR, F = FLOAT,
  INDIR, I = INT, INDIR, P = POINTER,
  INDIR, U = UNSIGNED, CVF, CVF,
  F = FLOAT, CVF, I = INT, CVI,
  CVI, F = FLOAT, CVI, I = INT,
  CVI, U = UNSIGNED, CVP, CVP,
  U = UNSIGNED, CVU, CVU, I = INT,
  CVU, P = POINTER, CVU, U = UNSIGNED,
  NEG, NEG, F = FLOAT, NEG,
  I = INT, CALL, CALL, B = STRUCT,
  CALL, F = FLOAT, CALL, I = INT,
  CALL, P = POINTER, CALL, U = UNSIGNED,
  CALL, V = VOID, RET, RET,
  F = FLOAT, RET, I = INT, RET,
  P = POINTER, RET, U = UNSIGNED, RET,
  V = VOID, ADDRG, ADDRG, P = POINTER,
  ADDRF, ADDRF, P = POINTER, ADDRL,
  ADDRL, P = POINTER, ADD, ADD,
  F = FLOAT, ADD, I = INT, ADD,
  P = POINTER, ADD, U = UNSIGNED, SUB,
  SUB, F = FLOAT, SUB, I = INT,
  SUB, P = POINTER, SUB, U = UNSIGNED,
  LSH, LSH, I = INT, LSH,
  U = UNSIGNED, MOD, MOD, I = INT,
  MOD, U = UNSIGNED, RSH, RSH,
  I = INT, RSH, U = UNSIGNED, BAND,
  BAND, I = INT, BAND, U = UNSIGNED,
  BCOM, BCOM, I = INT, BCOM,
  U = UNSIGNED, BOR, BOR, I = INT,
  BOR, U = UNSIGNED, BXOR, BXOR,
  I = INT, BXOR, U = UNSIGNED, DIV,
  DIV, F = FLOAT, DIV, I = INT,
  DIV, U = UNSIGNED, MUL, MUL,
  F = FLOAT, MUL, I = INT, MUL,
  U = UNSIGNED, EQ, EQ, F = FLOAT,
  EQ, I = INT, EQ, U = UNSIGNED,
  GE, GE, F = FLOAT, GE,
  I = INT, GE, U = UNSIGNED, GT,
  GT, F = FLOAT, GT, I = INT,
  GT, U = UNSIGNED, LE, LE,
  F = FLOAT, LE, I = INT, LE,
  U = UNSIGNED, LT, LT, F = FLOAT,
  LT, I = INT, LT, U = UNSIGNED,
  NE, NE, F = FLOAT, NE,
  I = INT, NE, U = UNSIGNED, JUMP,
  JUMP, V = VOID, LABEL, LABEL,
  V = VOID, LOAD, LOAD, B = STRUCT,
  LOAD, F = FLOAT, LOAD, I = INT,
  LOAD, P = POINTER, LOAD, U = UNSIGNED,
  LASTOP
}
enum  { CODE = 1, BSS, DATA, LIT }
enum  { PERM = 0, FUNC, STMT }
enum  {
  CONSTANTS = 1, LABELS, GLOBAL, PARAM,
  LOCAL
}
enum  {
  AND = 38<<4, NOT = 39<<4, OR = 40<<4, COND = 41<<4,
  RIGHT = 42<<4, FIELD = 43<<4
}

Functions

void addlocal (Symbol)
Tree addrof (Tree)
void * allocate (unsigned long n, unsigned a)
Symbol allsymbols (Table)
List append (void *x, List list)
void apply (List event, void *arg1, void *arg2)
Type array (Type, int, int)
Tree asgn (Symbol, Tree)
Tree asgntree (int, Tree, Tree)
Type assign (Type, Tree)
Type atop (Type)
void attach (Apply, void *, List *)
Type binary (Type, Type)
Tree bittree (int, Tree, Tree)
void branch (int)
Type btot (int, int)
Tree call (Tree, Type, Coordinate)
Tree calltree (Tree, Type, Tree, Symbol)
Tree cast (Tree, Type)
void check (Node)
void checklab (Symbol p, void *cl)
Tree cnsttree (Type,...)
Code code (int)
Type compose (Type, Type)
void compound (int, Swtch, int)
Tree cond (Tree)
Tree condtree (Tree, Tree, Tree)
Symbol constant (Type, Value)
Tree constexpr (int)
Tree consttree (unsigned int, Type)
Tree cvtconst (Tree)
void deallocate (unsigned a)
void defglobal (Symbol, int)
void definelab (int)
void definept (Coordinate *)
void defpointer (Symbol)
Type deref (Type)
void emitcode (void)
void enterscope (void)
Type enumdcl (void)
Tree eqtree (int, Tree, Tree)
int eqtype (Type, Type, int)
void equatelab (Symbol, Symbol)
void error (const char *,...)
void exitscope (void)
void expect (int tok)
Tree expr (int)
Tree expr0 (int)
Tree expr1 (int)
int fatal (const char *, const char *, int)
Tree field (Tree, const char *)
Field fieldlist (Type)
Field fieldref (const char *name, Type ty)
void fillbuf (void)
void finalize (void)
int findcount (char *, int, int)
int findfunc (char *, char *)
Symbol findlabel (int)
Symbol findtype (Type)
void foreach (Table, int, void(*)(Symbol, void *), void *)
void fprint (FILE *f, const char *fmt,...)
Type freturn (Type)
Type ftype (Type, Type)
Type func (Type, Type *, int)
char * funcname (Tree)
void gencode (Symbol[], Symbol[])
Symbol genident (int, Type, int)
int genlabel (int)
int getchr (void)
int gettok (void)
int hascall (Tree p)
int hasproto (Type)
Tree idtree (Symbol)
Tree incr (int, Tree, Tree)
void init (int, char *[])
Type initializer (Type, int)
void input_init (int, char *[])
Symbol install (const char *, Table *, int, int)
Symbol intconst (int)
int intexpr (int, int)
int iscallb (Tree)
int ispow2 (unsigned long u)
Node jump (int)
int length (List list)
Node listnodes (Tree e, int tlab, int flab)
void locus (Table tp, Coordinate *cp)
Symbol lookup (const char *, Table)
void * ltov (List *list, unsigned a)
Tree lvalue (Tree)
int main (int, char *[])
void main_init (int, char *[])
Symbol mkstr (char *)
Symbol mksymbol (int, const char *, Type)
void * newarray (unsigned long m, unsigned long n, unsigned a)
Field newfield (char *, Type, Type)
Node newnode (int op, Node left, Node right, Symbol p)
Type newstruct (int, char *)
Symbol newtemp (int, int, int)
void nextline (void)
int nodeid (Tree)
Tree nullcall (Type, Symbol, Tree, Tree)
char * opname (int)
void outtype (Type, FILE *)
Tree pointer (Tree)
void print (const char *,...)
void printdag (Node, int)
void printdecl (Symbol p, Type ty)
int * printed (int)
void printproto (Symbol p, Symbol args[])
void printtree (Tree, int)
void printtype (Type, int)
int process (char *)
void program (void)
Type promote (Type)
Type ptr (Type)
Type qual (int, Type)
int reachable (int)
Symbol relocate (const char *name, Table src, Table dst)
void retcode (Tree)
Tree retype (Tree p, Type ty)
Tree rightkid (Tree p)
void rmtypes (int)
Tree root (Tree)
Tree rvalue (Tree)
Tree shtree (int, Tree, Tree)
Type signedint (Type)
Tree simplify (int, Type, Tree, Tree)
void skipto (int tok, char set[])
void statement (int, Swtch, int)
char * string (const char *str)
char * stringd (long n)
char * stringf (const char *,...)
char * stringn (const char *str, int len)
void swcode (Swtch, int *, int, int)
void swgen (Swtch)
void swtoseg (int)
Table table (Table, int)
Symbol temporary (int, Type)
void test (int tok, char set[])
Tree texpr (Tree(*)(int), int, int)
Tree tree (int, Type, Tree, Tree)
int ttob (Type)
void type_init (int, char *[])
void typeerror (int, Tree, Tree)
Type typename (void)
char * typestring (Type ty, char *id)
void use (Symbol p, Coordinate src)
Tree value (Tree)
int variadic (Type)
Tree vcall (Symbol func, Type ty,...)
void vfprint (FILE *, char *, const char *, va_list)
char * vtoa (Type, Value)
void walk (Tree e, int tlab, int flab)
void warning (const char *,...)

Variables

int Aflag
int assignargs
Binding bindings []
Symbol cfunc
Type charptype
Type chartype
code codehead
Code codelist
Table constants
unsigned char * cp
float density
Type doubletype
int errcnt
int errlimit
Events events
int explicitCast
Table externals
char * file
char * firstfile
Type floattype
Type funcptype
int glevel
Table globals
Table identifiers
Type inttype
InterfaceIR
char kind []
Table labels
int level
unsigned char * limit
char * line
int lineno
List loci
Type longdouble
Type longlong
Type longtype
int ncalled
int needconst
int nodecount
int npoints
Tree(* optree [])(int, Tree, Tree)
int Pflag
int prunetemps
float refinc
Symbol retv
Type shorttype
Type signedchar
Type signedptr
Coordinate src
Table stmtlabs
List symbols
int t
char * token
Symbol tsym
Table types
Type unsignedchar
Type unsignedlong
Type unsignedlonglong
Type unsignedptr
Type unsignedshort
Type unsignedtype
Type voidptype
Type voidtype
int wflag
int where
Type widechar
int xref
Symbol YYcheck
Symbol YYnull


Define Documentation

#define BUFSIZE   4096
 

Definition at line 14 of file c.h.

Referenced by fillbuf().

#define extend x,
ty   )     ((x)&(1<<(8*(ty)->size-1)) ? (x)|((~0UL)<<(8*(ty)->size-1)) : (x)&ones(8*(ty)->size))
 

Definition at line 35 of file c.h.

Referenced by gettok(), simplify(), and statement().

#define fieldleft p   ) 
 

Value:

(8*(p)->type->size - \
                        fieldsize(p) - fieldright(p))

Definition at line 62 of file c.h.

Referenced by emittype(), initfields(), and listnodes().

#define fieldmask p   )     (~(~(unsigned)0<<fieldsize(p)))
 

Definition at line 64 of file c.h.

Referenced by cnsttree(), initfields(), and listnodes().

#define fieldright p   )     ((p)->lsb - 1)
 

Definition at line 61 of file c.h.

Referenced by emittype(), initfields(), listnodes(), printtree1(), and prtype().

#define fieldsize p   )     (p)->bitsize
 

Definition at line 60 of file c.h.

Referenced by cnsttree(), emittype(), initfields(), listnodes(), printtree1(), and prtype().

#define generic op   )     ((op)&0x3F0)
 

Definition at line 19 of file c.h.

Referenced by bbcall(), dumptree(), fixup(), foldcond(), gen(), gen02(), genconst(), initvalue(), kill(), listnodes(), localaddr(), mayrecalc(), opname(), prelabel(), printnode(), printtree1(), prune(), replace(), requate(), reuse(), root1(), simplify(), statement(), swstmt(), undag(), and visit().

#define gop name,
value   )     name=value<<4,
 

Definition at line 190 of file c.h.

#define isaddrop op   ) 
 

Value:

(specific(op)==ADDRG+P || specific(op)==ADDRL+P \
    || specific(op)==ADDRF+P)

Definition at line 10 of file c.h.

Referenced by foldcond(), kill(), listnodes(), prune(), replace(), simplify(), and swstmt().

#define isarith t   )     (unqual(t)->op <= UNSIGNED)
 

Definition at line 55 of file c.h.

Referenced by genconst().

#define isarray t   )     (unqual(t)->op == ARRAY)
 

Definition at line 45 of file c.h.

Referenced by addrtree(), array(), atop(), cvtconst(), dbxout(), dcllocal(), dclparam(), doconst(), doglobal(), func(), genconst(), initglobal(), initializer(), outtype(), qual(), tracevalue(), and typestring().

#define ischar t   )     ((t)->size == 1 && isint(t))
 

Definition at line 51 of file c.h.

Referenced by initializer(), and typestring().

#define isconst t   ) 
 

Value:

((t)->op == CONST \
                    || (t)->op == CONST+VOLATILE)

Definition at line 43 of file c.h.

Referenced by compose(), dcllocal(), emittype(), initglobal(), qual(), specifier(), and uid2type().

#define isenum t   )     (unqual(t)->op == ENUM)
 

Definition at line 59 of file c.h.

Referenced by dbxout(), decl(), deref(), eqtype(), funcdefn(), and iscallb().

#define isfloat t   )     (unqual(t)->op == FLOAT)
 

Definition at line 54 of file c.h.

Referenced by retcode().

#define isfunc t   )     (unqual(t)->op == FUNCTION)
 

Definition at line 49 of file c.h.

Referenced by array(), checkref(), conditional(), dbxout(), dclglobal(), dcllocal(), dclparam(), decl(), doglobal(), freturn(), func(), funcdefn(), listnodes(), qual(), stabsym(), typestab(), typestring(), and variadic().

#define isint t   ) 
 

Value:

(unqual(t)->op == INT \
                    || unqual(t)->op == UNSIGNED)

Definition at line 52 of file c.h.

Referenced by condtree(), funcdefn(), listnodes(), statement(), and swstmt().

#define isptr t   )     (unqual(t)->op == POINTER)
 

Definition at line 50 of file c.h.

Referenced by addrtree(), dbxout(), deref(), expr1(), funcdefn(), listnodes(), retcode(), root1(), stabsym(), tracevalue(), and typestring().

#define isqual t   )     ((t)->op >= CONST)
 

Definition at line 38 of file c.h.

Referenced by qual(), and specifier().

#define isscalar t   ) 
 

Value:

(unqual(t)->op <= POINTER \
                    || unqual(t)->op == ENUM)

Definition at line 57 of file c.h.

Referenced by askregvar(), checkref(), dcllocal(), and initializer().

#define isstruct t   ) 
 

Value:

(unqual(t)->op == STRUCT \
                    || unqual(t)->op == UNION)

Definition at line 46 of file c.h.

Referenced by compound(), dbxout(), dcllocal(), dclparam(), decl(), expr1(), funcdefn(), initializer(), listnodes(), and stabsym().

#define istypename t,
tsym   ) 
 

Value:

(kind[t] == CHAR \
    || t == ID && tsym && tsym->sclass == TYPEDEF)

Definition at line 16 of file c.h.

Referenced by compound(), dclr1(), decl(), funcdefn(), parameters(), specifier(), and structdcl().

#define isunion t   )     (unqual(t)->op == UNION)
 

Definition at line 48 of file c.h.

Referenced by initializer().

#define isunsigned t   )     (unqual(t)->op == UNSIGNED)
 

Definition at line 56 of file c.h.

Referenced by cnsttree(), and swcode().

#define isvolatile t   ) 
 

Value:

((t)->op == VOLATILE \
                    || (t)->op == CONST+VOLATILE)

Definition at line 41 of file c.h.

Referenced by checkref(), compose(), dcllocal(), dclparam(), emittype(), listnodes(), qual(), root1(), specifier(), swstmt(), and uid2type().

#define MAXLINE   512
 

Definition at line 13 of file c.h.

Referenced by fillbuf(), and input_init().

#define mkop op,
ty   )     (specific((op) + ttob(ty)))
 

Definition at line 33 of file c.h.

Referenced by calltree(), retcode(), simplify(), and tracevalue().

#define NELEMS  )     ((int)(sizeof (a)/sizeof ((a)[0])))
 

Definition at line 30 of file c.h.

#define NEW p,
 )     ((p) = allocate(sizeof *(p), (a)))
 

Definition at line 8 of file c.h.

#define NEW0 p,
 )     memset(NEW((p),(a)), 0, sizeof *(p))
 

Definition at line 9 of file c.h.

Referenced by addrtree(), constant(), dagnode(), findlabel(), genident(), genspill(), install(), listnodes(), mkreg(), mksymbol(), mkwildcard(), newfield(), table(), temporary(), tnode(), tree(), uid2symbol(), uid2type(), and visit().

#define ones n   )     ((n)>=8*sizeof (unsigned long) ? ~0UL : ~((~0UL)<<(n)))
 

Definition at line 36 of file c.h.

Referenced by backslash(), CG_DrawOldTourneyScoreboard(), simplify(), type_init(), and xxinit().

#define op name,
type,
sizes   ) 
 

Definition at line 191 of file c.h.

#define opindex op   )     (((op)>>4)&0x3F)
 

Definition at line 21 of file c.h.

Referenced by do_op(), gen(), genspill(), node(), opname(), prelabel(), and ralloc().

#define opkind op   )     ((op)&~0x3F0)
 

Definition at line 22 of file c.h.

Referenced by gen(), genreload(), genspill(), listnodes(), prelabel(), ralloc(), and rtarget().

#define opsize op   )     ((op)>>10)
 

Definition at line 23 of file c.h.

Referenced by opname(), prelabel(), spillr(), and visit().

#define optype op   )     ((op)&0xF)
 

Definition at line 24 of file c.h.

Referenced by btot(), dumptree(), listnodes(), opname(), prelabel(), simplify(), spillr(), and visit().

#define roundup x,
n   )     (((x)+((n)-1))&(~((n)-1)))
 

Definition at line 32 of file c.h.

Referenced by allocate(), initstruct(), mkactual(), and mkauto().

#define sizeop n   )     ((n)<<10)
 

Definition at line 18 of file c.h.

Referenced by doop(), genreload(), genspill(), listnodes(), ttob(), and visit().

#define specific op   )     ((op)&0x3FF)
 

Definition at line 20 of file c.h.

Referenced by asdl_gen(), definelab(), dumptree(), fixup(), range(), and visit().

#define unqual t   )     (isqual(t) ? (t)->type : (t))
 

Definition at line 39 of file c.h.

Referenced by array(), calltree(), compatible(), compose(), constant(), dbxout(), decl(), deref(), eqtype(), fieldref(), funcdefn(), initializer(), iscallb(), listnodes(), promote(), root1(), specifier(), tracevalue(), vcall(), and vtoa().

#define xx a,
b,
c,
d,
e,
f,
 )     a=b,
 

#define yy a,
b,
c,
d,
e,
f,
 ) 
 


Typedef Documentation

typedef void(* Apply)(void *, void *, void *)
 

Definition at line 584 of file c.h.

Referenced by prof_init(), and trace_init().

typedef struct binding Binding
 

typedef struct code* Code
 

Definition at line 69 of file c.h.

Referenced by addrtree(), branch(), code(), compound(), definelab(), definept(), doAddress(), doBlockbeg(), emitcode(), funcdefn(), gencode(), reachable(), and swstmt().

typedef struct coord Coordinate
 

Referenced by bbcall(), bbincr(), dclglobal(), dcllocal(), dclparam(), decl(), definept(), emitcode(), emitCoord(), enumdcl(), foreach(), forstmt(), funcdefn(), gencode(), locus(), main(), stabend(), stabline(), structdcl(), use(), vfprint(), and whilestmt().

typedef struct field* Field
 

Definition at line 92 of file c.h.

Referenced by asgncode(), emittype(), fieldlist(), fieldref(), initfields(), initstruct(), isfield(), listnodes(), newfield(), prtype(), tracevalue(), typeuid(), and uid2type().

typedef struct interface Interface
 

typedef struct list* List
 

Definition at line 67 of file c.h.

typedef struct metrics Metrics
 

Referenced by xxinit().

typedef struct node* Node
 

Definition at line 65 of file c.h.

Referenced by asdl_emit(), asdl_gen(), asgnnode(), dagnode(), docall(), doForest(), dumpcover(), dumptree(), emit(), emitasm(), fixup(), gen(), gen01(), gen02(), genreload(), genspill(), getreg(), getregnum(), getrule(), jump(), linearize(), list(), listnodes(), mayrecalc(), move(), moveself(), newnode(), node(), notarget(), prelabel(), printdag(), printdag1(), printnode(), prune(), ralloc(), range(), reduce(), replace(), reprune(), requate(), reuse(), rewrite(), rtarget(), setreg(), spill(), spillee(), spillr(), tmpnode(), undag(), unlist(), uses(), visit(), and walk().

typedef struct swtch* Swtch
 

Definition at line 71 of file c.h.

Referenced by caselabel(), dostmt(), forstmt(), ifstmt(), statement(), swcode(), swgen(), and whilestmt().

typedef struct symbol* Symbol
 

Definition at line 73 of file c.h.

Referenced by addlocal(), addrtree(), allsymbols(), asdl_address(), asdl_defaddress(), asdl_defsymbol(), asdl_export(), asdl_function(), asdl_global(), asdl_import(), asdl_local(), asgnnode(), askfixedreg(), askreg(), askregvar(), bbcall(), bbentry(), bbexit(), bbfile(), bbfunc(), bbincr(), bbvars(), branch(), caselabel(), checklab(), checkref(), cmp(), compound(), constant(), cvtconst(), dagnode(), dclglobal(), dcllocal(), dclparam(), dclr(), dclr1(), decl(), defglobal(), definelab(), defpointer(), do_item(), doAddress(), doconst(), doextern(), doFunction(), doGlobal(), doglobal(), doImport(), dopending(), emitSymbol(), emitSymRef(), emittype(), enumdcl(), equal(), equated(), equatelab(), exitparams(), exitscope(), expr2(), fcon(), fieldref(), findlabel(), findtype(), foldcond(), foreach(), funcdefn(), gencode(), genident(), genreload(), genspill(), getreg(), icon(), idtree(), initglobal(), install(), intconst(), jump(), kill(), localaddr(), lookup(), main(), mk_symbol(), mkauto(), mkreg(), mkstr(), mksymbol(), mkwildcard(), newnode(), newstruct(), newtemp(), node(), oldparam(), outtype(), parameters(), printdecl(), printproto(), prtype(), prune(), putreg(), ralloc(), range(), regloc(), relocate(), requate(), retcode(), reuse(), rtarget(), setreg(), spill(), spillee(), spillr(), stabblock(), stabend(), stabfend(), stabinit(), stabsym(), stabtype(), statement(), stmtlabel(), structdcl(), swcode(), symboluid(), temporary(), tmpnode(), trace_init(), tracecall(), tracefinis(), tracereturn(), tracevalue(), type_init(), typestab(), typestring(), uid2symbol(), uid2type(), use(), visit(), and xxinit().

typedef struct table* Table
 

Definition at line 79 of file c.h.

Referenced by allsymbols(), findtype(), foreach(), install(), locus(), lookup(), relocate(), and table().

typedef struct tree* Tree
 

Definition at line 88 of file c.h.

typedef struct type* Type
 

Definition at line 90 of file c.h.

Referenced by addrtree(), array(), asgncode(), atop(), btot(), calltree(), cmp(), compose(), condtree(), constant(), dbxout(), dbxtype(), dclglobal(), dcllocal(), dclparam(), dclr(), dclr1(), decl(), deref(), do_item(), emittype(), enumdcl(), eqtype(), fieldlist(), fieldref(), findtype(), freturn(), ftype(), func(), funcdefn(), genident(), hasproto(), initarray(), initchar(), initglobal(), initializer(), initstruct(), initvalue(), iscallb(), listnodes(), mksymbol(), newfield(), newstruct(), outtype(), parameters(), postfix(), printdecl(), printtype(), promote(), prtype(), ptr(), qual(), retcode(), signedint(), simplify(), specifier(), statement(), structdcl(), swcode(), temporary(), tnode(), tracevalue(), tree(), ttob(), typename(), typestring(), typeuid(), uid2type(), variadic(), vfprint(), vtoa(), and xxinit().

typedef union value Value
 

Referenced by asdl_defconst(), bbcall(), bbfunc(), bbvars(), constant(), defpointer(), doconst(), doDefconst(), doDefconstf(), initfields(), initializer(), intconst(), mk_real(), mkstr(), visit(), and vtoa().


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
a 
b 
c 
d 
e 
f 
a 
b 
c 
d 
e 
f 
yy 
FLOAT 
CHAR 
DOUBLE 
CHAR 
CHAR 
CHAR 
SHORT 
CHAR 
INT 
CHAR 
UNSIGNED 
CHAR 
POINTER 
VOID 
CHAR 
STRUCT 
CHAR 
UNION 
CHAR 
FUNCTION 
ARRAY 
ENUM 
CHAR 
LONG 
CHAR 
CONST 
CHAR 
VOLATILE 
CHAR 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
yy 
ID 
ID 
yy 
ID 
FCON 
ID 
ICON 
ID 
SCON 
ID 
yy 
MOD 
bittree 
yy 
BAND 
bittree 
ID 
INCR 
ADD 
addtree 
ID 
yy 
ID 
yy 
yy 
MUL 
multree 
ID 
yy 
ADD 
addtree 
ID 
yy 
yy 
SUB 
subtree 
ID 
yy 
yy 
DIV 
multree 
DECR 
SUB 
subtree 
ID 
DEREF 
DEREF 
ANDAND 
AND 
andtree 
ANDAND 
OROR 
OR 
andtree 
OROR 
LEQ 
LE 
cmptree 
LEQ 
yy 
LT 
cmptree 
yy 
ASGN 
asgntree 

Definition at line 168 of file c.h.

00168      {
00169 #define xx(a,b,c,d,e,f,g) a=b,
00170 #define yy(a,b,c,d,e,f,g)
00171 #include "token.h"
00172     LAST
00173 };

anonymous enum
 

Enumeration values:
F 
I 
U 
P 
V 
B 

Definition at line 182 of file c.h.

00182      {
00183     F=FLOAT,
00184     I=INT,
00185     U=UNSIGNED,
00186     P=POINTER,
00187     V=VOID,
00188     B=STRUCT
00189 };

anonymous enum
 

Enumeration values:
CNST 
CNST 
F 
CNST 
I 
CNST 
P 
CNST 
U 
ARG 
ARG 
B 
ARG 
F 
ARG 
I 
ARG 
P 
ARG 
U 
ASGN 
ASGN 
B 
ASGN 
F 
ASGN 
I 
ASGN 
P 
ASGN 
U 
INDIR 
INDIR 
B 
INDIR 
F 
INDIR 
I 
INDIR 
P 
INDIR 
U 
CVF 
CVF 
F 
CVF 
I 
CVI 
CVI 
F 
CVI 
I 
CVI 
U 
CVP 
CVP 
U 
CVU 
CVU 
I 
CVU 
P 
CVU 
U 
NEG 
NEG 
F 
NEG 
I 
CALL 
CALL 
B 
CALL 
F 
CALL 
I 
CALL 
P 
CALL 
U 
CALL 
V 
RET 
RET 
F 
RET 
I 
RET 
P 
RET 
U 
RET 
V 
ADDRG 
ADDRG 
P 
ADDRF 
ADDRF 
P 
ADDRL 
ADDRL 
P 
ADD 
ADD 
F 
ADD 
I 
ADD 
P 
ADD 
U 
SUB 
SUB 
F 
SUB 
I 
SUB 
P 
SUB 
U 
LSH 
LSH 
I 
LSH 
U 
MOD 
MOD 
I 
MOD 
U 
RSH 
RSH 
I 
RSH 
U 
BAND 
BAND 
I 
BAND 
U 
BCOM 
BCOM 
I 
BCOM 
U 
BOR 
BOR 
I 
BOR 
U 
BXOR 
BXOR 
I 
BXOR 
U 
DIV 
DIV 
F 
DIV 
I 
DIV 
U 
MUL 
MUL 
F 
MUL 
I 
MUL 
U 
EQ 
EQ 
F 
EQ 
I 
EQ 
U 
GE 
GE 
F 
GE 
I 
GE 
U 
GT 
GT 
F 
GT 
I 
GT 
U 
LE 
LE 
F 
LE 
I 
LE 
U 
LT 
LT 
F 
LT 
I 
LT 
U 
NE 
NE 
F 
NE 
I 
NE 
U 
JUMP 
JUMP 
V 
LABEL 
LABEL 
V 
LOAD 
LOAD 
B 
LOAD 
F 
LOAD 
I 
LOAD 
P 
LOAD 
U 
LASTOP 

Definition at line 193 of file c.h.

00193      { gop(CNST,1)
00194         op(CNST,F,fdx)
00195         op(CNST,I,csilh)
00196         op(CNST,P,p)
00197         op(CNST,U,csilh)
00198        gop(ARG,2)
00199         op(ARG,B,-)
00200         op(ARG,F,fdx)
00201         op(ARG,I,ilh)
00202         op(ARG,P,p)
00203         op(ARG,U,ilh)
00204        gop(ASGN,3)
00205         op(ASGN,B,-)
00206         op(ASGN,F,fdx)
00207         op(ASGN,I,csilh)
00208         op(ASGN,P,p)
00209         op(ASGN,U,csilh)
00210        gop(INDIR,4)
00211         op(INDIR,B,-)
00212         op(INDIR,F,fdx)
00213         op(INDIR,I,csilh)
00214         op(INDIR,P,p)
00215         op(INDIR,U,csilh)
00216        gop(CVF,7)
00217         op(CVF,F,fdx)
00218         op(CVF,I,ilh)
00219        gop(CVI,8)
00220         op(CVI,F,fdx)
00221         op(CVI,I,csilh)
00222         op(CVI,U,csilhp)
00223        gop(CVP,9)
00224         op(CVP,U,p)
00225        gop(CVU,11)
00226         op(CVU,I,csilh)
00227         op(CVU,P,p)
00228         op(CVU,U,csilh)
00229        gop(NEG,12)
00230         op(NEG,F,fdx)
00231         op(NEG,I,ilh)
00232        gop(CALL,13)
00233         op(CALL,B,-)
00234         op(CALL,F,fdx)
00235         op(CALL,I,ilh)
00236         op(CALL,P,p)
00237         op(CALL,U,ilh)
00238         op(CALL,V,-)
00239        gop(RET,15)
00240         op(RET,F,fdx)
00241         op(RET,I,ilh)
00242         op(RET,P,p)
00243         op(RET,U,ilh)
00244         op(RET,V,-)
00245        gop(ADDRG,16)
00246         op(ADDRG,P,p)
00247        gop(ADDRF,17)
00248         op(ADDRF,P,p)
00249        gop(ADDRL,18)
00250         op(ADDRL,P,p)
00251        gop(ADD,19)
00252         op(ADD,F,fdx)
00253         op(ADD,I,ilh)
00254         op(ADD,P,p)
00255         op(ADD,U,ilhp)
00256        gop(SUB,20)
00257         op(SUB,F,fdx)
00258         op(SUB,I,ilh)
00259         op(SUB,P,p)
00260         op(SUB,U,ilhp)
00261        gop(LSH,21)
00262         op(LSH,I,ilh)
00263         op(LSH,U,ilh)
00264        gop(MOD,22)
00265         op(MOD,I,ilh)
00266         op(MOD,U,ilh)
00267        gop(RSH,23)
00268         op(RSH,I,ilh)
00269         op(RSH,U,ilh)
00270        gop(BAND,24)
00271         op(BAND,I,ilh)
00272         op(BAND,U,ilh)
00273        gop(BCOM,25)
00274         op(BCOM,I,ilh)
00275         op(BCOM,U,ilh)
00276        gop(BOR,26)
00277         op(BOR,I,ilh)
00278         op(BOR,U,ilh)
00279        gop(BXOR,27)
00280         op(BXOR,I,ilh)
00281         op(BXOR,U,ilh)
00282        gop(DIV,28)
00283         op(DIV,F,fdx)
00284         op(DIV,I,ilh)
00285         op(DIV,U,ilh)
00286        gop(MUL,29)
00287         op(MUL,F,fdx)
00288         op(MUL,I,ilh)
00289         op(MUL,U,ilh)
00290        gop(EQ,30)
00291         op(EQ,F,fdx)
00292         op(EQ,I,ilh)
00293         op(EQ,U,ilhp)
00294        gop(GE,31)
00295         op(GE,F,fdx)
00296         op(GE,I,ilh)
00297         op(GE,U,ilhp)
00298        gop(GT,32)
00299         op(GT,F,fdx)
00300         op(GT,I,ilh)
00301         op(GT,U,ilhp)
00302        gop(LE,33)
00303         op(LE,F,fdx)
00304         op(LE,I,ilh)
00305         op(LE,U,ilhp)
00306        gop(LT,34)
00307         op(LT,F,fdx)
00308         op(LT,I,ilh)
00309         op(LT,U,ilhp)
00310        gop(NE,35)
00311         op(NE,F,fdx)
00312         op(NE,I,ilh)
00313         op(NE,U,ilhp)
00314        gop(JUMP,36)
00315         op(JUMP,V,-)
00316        gop(LABEL,37)
00317         op(LABEL,V,-)
00318        gop(LOAD,14)
00319         op(LOAD,B,-)
00320         op(LOAD,F,fdx)
00321         op(LOAD,I,csilh)
00322         op(LOAD,P,p)
00323         op(LOAD,U,csilhp) LASTOP };

anonymous enum
 

Enumeration values:
CODE 
BSS 
DATA 
LIT 

Definition at line 327 of file c.h.

00327 { CODE=1, BSS, DATA, LIT };

anonymous enum
 

Enumeration values:
PERM 
FUNC 
STMT 

Definition at line 328 of file c.h.

00328 { PERM=0, FUNC, STMT };

anonymous enum
 

Enumeration values:
CONSTANTS 
LABELS 
GLOBAL 
PARAM 
LOCAL 

Definition at line 431 of file c.h.

00431 { CONSTANTS=1, LABELS, GLOBAL, PARAM, LOCAL };

anonymous enum
 

Enumeration values:
AND 
NOT 
OR 
COND 
RIGHT 
FIELD 

Definition at line 444 of file c.h.

00444      {
00445     AND=38<<4,
00446     NOT=39<<4,
00447     OR=40<<4,
00448     COND=41<<4,
00449     RIGHT=42<<4,
00450     FIELD=43<<4
00451 };


Function Documentation

void addlocal Symbol   ) 
 

Definition at line 51 of file stmt.c.

References code(), symbol::defined, p, symbol::scope, Symbol, code::u, and code::var.

Referenced by addrtree(), doLocal(), listnodes(), retcode(), swstmt(), tracecall(), and undag().

00051                         {
00052     if (!p->defined) {
00053         code(Local)->u.var = p;
00054         p->defined = 1;
00055         p->scope = level;
00056     }
00057 }

Here is the call graph for this function:

Tree addrof Tree   ) 
 

Definition at line 521 of file enode.c.

Referenced by tracevalue().

00528                                             :",
00529         0, 0
00530     };
00531 
00532     op = generic(op);
00533     for (i = 0; ops[i].op; i++)
00534         if (op == ops[i].op)
00535             break;
00536     assert(ops[i].name);
00537     if (r)
00538         error("operands of %s have illegal types `%t' and `%t'\n",
00539             ops[i].name, l->type, r->type);
00540     else
00541         error("operand of unary %s has illegal type `%t'\n", ops[i].name,
00542             l->type);
00543 }
00544 }

void* allocate unsigned long  n,
unsigned  a
 

Definition at line 53 of file alloc.c.

References a, assert, block::avail, error(), exit(), freeblocks, block::limit, m, malloc(), n, NELEMS, block::next, and roundup.

Referenced by appendstr(), newarray(), prof_init(), and stringn().

00053                                             {
00054     struct block *ap;
00055 
00056     assert(a < NELEMS(arena));
00057     assert(n > 0);
00058     ap = arena[a];
00059     n = roundup(n, sizeof (union align));
00060     while (n > ap->limit - ap->avail) {
00061         if ((ap->next = freeblocks) != NULL) {
00062             freeblocks = freeblocks->next;
00063             ap = ap->next;
00064         } else
00065             {
00066                 unsigned m = sizeof (union header) + n + roundup(10*1024, sizeof (union align));
00067                 ap->next = malloc(m);
00068                 ap = ap->next;
00069                 if (ap == NULL) {
00070                     error("insufficient memory\n");
00071                     exit(1);
00072                 }
00073                 ap->limit = (char *)ap + m;
00074             }
00075         ap->avail = (char *)((union header *)ap + 1);
00076         ap->next = NULL;
00077         arena[a] = ap;
00078 
00079     }
00080     ap->avail += n;
00081     return ap->avail - n;
00082 }

Here is the call graph for this function:

Symbol allsymbols Table   ) 
 

Definition at line 235 of file sym.c.

References table::all, Symbol, and Table.

Referenced by locus().

00235                             {
00236     return tp->all;
00237 }

List append void *  x,
List  list
 

Definition at line 7 of file list.c.

References freenodes, list::link, List, NEW, PERM, and list::x.

Referenced by attach(), bbfile(), bbincr(), compile(), compose(), compound(), dcllocal(), enumdcl(), filename(), ftype(), initinputs(), locus(), idStr::operator+=(), opt(), parameters(), path2list(), printproto(), prof_init(), tempname(), and use().

00007                                 {
00008     List new;
00009 
00010     if ((new = freenodes) != NULL)
00011         freenodes = freenodes->link;
00012     else
00013         NEW(new, PERM);
00014     if (list) {
00015         new->link = list->link;
00016         list->link = new;
00017     } else
00018         new->link = new;
00019     new->x = x;
00020     return new;
00021 }

void apply List  event,
void *  arg1,
void *  arg2
 

Definition at line 18 of file event.c.

References entry::cl, entry::func, list::link, List, p, and list::x.

Referenced by compound(), definept(), funcdefn(), main(), and retcode().

00018                                                {
00019     if (event) {
00020         List lp = event;
00021         do {
00022             struct entry *p = lp->x;
00023             (*p->func)(p->cl, arg1, arg2);
00024             lp = lp->link;
00025         } while (lp != event);
00026     }
00027 }

Type array Type  ,
int  ,
int 
 

Definition at line 202 of file types.c.

Referenced by CreateSmartEntity(), FinishSmartCreation(), Group_RemoveListFromWorld(), logDisableClientState(), logEnableClientState(), ltov(), qglDisableClientState(), qglEnableClientState(), and Test_Ray().

00202                                   {
00203     assert(ty);
00204     if (isfunc(ty)) {
00205         error("illegal type `array of %t'\n", ty);
00206         return array(inttype, n, 0);
00207     }
00208     if (isarray(ty) && ty->size == 0)
00209         error("missing array size\n");
00210     if (ty->size == 0) {
00211         if (unqual(ty) == voidtype)
00212             error("illegal type `array of %t'\n", ty);
00213         else if (Aflag >= 2)
00214             warning("declaring type array of %t' is undefined\n", ty);
00215 
00216     } else if (n > INT_MAX/ty->size) {
00217         error("size of `array of %t' exceeds %d bytes\n",
00218             ty, INT_MAX);
00219         n = 1;
00220     }
00221     return type(ARRAY, ty, n*ty->size,
00222         a ? a : ty->align, NULL);
00223 }

Tree asgn Symbol  ,
Tree 
 

Definition at line 558 of file enode.c.

Referenced by bbcall(), dcllocal(), gencode(), retcode(), swstmt(), and tracecall().

Tree asgntree int  ,
Tree  ,
Tree 
 

Definition at line 420 of file enode.c.

Referenced by retcode().

00424                             {
00425     if (isarray(p->type))
00426         e = tree(ASGN+B, p->type, idtree(p),
00427             tree(INDIR+B, e->type, e, NULL));
00428     else {
00429         Type ty = p->type;
00430         p->type = unqual(p->type);
00431         if (isstruct(p->type) && p->type->u.sym->u.s.cfields) {
00432             p->type->u.sym->u.s.cfields = 0;
00433             e = asgntree(ASGN, idtree(p), e);
00434             p->type->u.sym->u.s.cfields = 1;
00435         } else
00436             e = asgntree(ASGN, idtree(p), e);
00437         p->type = ty;
00438     }
00439     return e;
00440 }
00441 
00442 /* bittree - construct tree for l [& | ^ %] r */
00443 Tree bittree(int op, Tree l, Tree r) {
00444     Type ty = inttype;
00445 
00446     if (isint(l->type) && isint(r->type)) {
00447         ty = binary(l->type, r->type);
00448         l = cast(l, ty);
00449         r = cast(r, ty);        
00450     } else
00451         typeerror(op, l, r);
00452     return simplify(op, ty, l, r);
00453 }
00454 
00455 /* multree - construct tree for l [* /] r */
00456 static Tree multree(int op, Tree l, Tree r) {
00457     Type ty = inttype;
00458 
00459     if (isarith(l->type) && isarith(r->type)) {
00460         ty = binary(l->type, r->type);
00461         l = cast(l, ty);
00462         r = cast(r, ty);        
00463     } else
00464         typeerror(op, l, r);
00465     return simplify(op, ty, l, r);
00466 }
00467 
00468 /* shtree - construct tree for l [>> <<] r */

Type assign Type  ,
Tree 
 

Definition at line 382 of file enode.c.

References p.

Referenced by initializer(), initvalue(), and retcode().

00387                     {
00388     Tree q = p;
00389 
00390     for (;;)
00391         switch (generic(q->op)) {
00392         case RIGHT:
00393             assert(q->kids[0] || q->kids[1]);
00394             q = q->kids[1] ? q->kids[1] : q->kids[0];
00395             continue;
00396         case ASGN:
00397             q = q->kids[1];
00398             continue;
00399         case COND: {
00400             Symbol t1 = q->u.sym;
00401             q->u.sym = 0;
00402             q = idtree(t1);
00403             /* fall thru */
00404             }
00405         case INDIR:
00406             if (p == q)
00407                 return q->kids[0];
00408             q = q->kids[0];
00409             return tree(RIGHT, q->type, root(p), q);
00410         default:
00411             error("addressable object required\n");
00412             return value(p);
00413         }
00414 }
00415 
00416 /* andtree - construct tree for l [&& ||] r */
00417 static Tree andtree(int op, Tree l, Tree r) {
00418     if (!isscalar(l->type) || !isscalar(r->type))
00419         typeerror(op, l, r);

Type atop Type   ) 
 

Definition at line 224 of file types.c.

References error(), isarray, ptr(), Type, and type::type.

Referenced by cvtconst(), and dclparam().

00224                    {
00225     if (isarray(ty))
00226         return ptr(ty->type);
00227     error("type error: %s\n", "array expected");
00228     return ptr(ty);
00229 }

Here is the call graph for this function:

void attach Apply  ,
void *  ,
List
 

Definition at line 10 of file event.c.

References append(), entry::cl, entry::func, List, NEW, p, and PERM.

Referenced by prof_init(), and trace_init().

00010                                               {
00011     struct entry *p;
00012 
00013     NEW(p, PERM);
00014     p->func = func;
00015     p->cl = cl;
00016     *list = append(p, *list);
00017 }

Here is the call graph for this function:

Type binary Type  ,
Type 
 

Definition at line 760 of file expr.c.

Tree bittree int  ,
Tree  ,
Tree 
 

Definition at line 577 of file enode.c.

Referenced by cnsttree(), listnodes(), and simplify().

void branch int   ) 
 

Definition at line 565 of file stmt.c.

References assert, Code, code(), codelist, cp, equal(), equatelab(), findlabel(), code::forest, jump(), code::kind, LABEL, code::next, NULL, node::op, p, code::prev, symbol::ref, Symbol, node::syms, code::u, V, walk(), and warning().

Referenced by forstmt(), ifstmt(), statement(), swcode(), swstmt(), and whilestmt().

00565                      {
00566     Code cp;
00567     Symbol p = findlabel(lab);
00568 
00569     assert(lab);
00570     walk(NULL, 0, 0);
00571     code(Label)->u.forest = jump(lab);
00572     for (cp = codelist->prev; cp->kind < Label; )
00573         cp = cp->prev;
00574     while (   cp->kind == Label
00575            && cp->u.forest->op == LABEL+V
00576            && !equal(cp->u.forest->syms[0], p)) {
00577         equatelab(cp->u.forest->syms[0], p);
00578         assert(cp->next);
00579         assert(cp->prev);
00580         cp->prev->next = cp->next;
00581         cp->next->prev = cp->prev;
00582         cp = cp->prev;
00583         while (cp->kind < Label)
00584             cp = cp->prev;
00585     }
00586     if (cp->kind == Jump || cp->kind == Switch) {
00587         p->ref--;
00588         codelist->prev->next = NULL;
00589         codelist = codelist->prev;
00590     } else {
00591         codelist->kind = Jump;
00592         if (cp->kind == Label
00593         &&  cp->u.forest->op == LABEL+V
00594         &&  equal(cp->u.forest->syms[0], p))
00595             warning("source code specifies an infinite loop");
00596     }
00597 }

Here is the call graph for this function:

Type btot int  ,
int 
 

Definition at line 447 of file types.c.

References assert, chartype, doubletype, F, floattype, funcptype, I, inttype, longdouble, longlong, longtype, op, type::op, optype, P, shorttype, signedchar, Type, U, unsignedchar, unsignedlong, unsignedlonglong, unsignedshort, unsignedtype, voidptype, and xx.

Referenced by newtemp(), uid2type(), and visit().

00447                             {
00448 #define xx(ty) if (size == (ty)->size) return ty;
00449     switch (optype(op)) {
00450     case F:
00451         xx(floattype);
00452         xx(doubletype);
00453         xx(longdouble);
00454         assert(0); return 0;
00455     case I:
00456         if (chartype->op == INT)
00457             xx(chartype);
00458         xx(signedchar);
00459         xx(shorttype);
00460         xx(inttype);
00461         xx(longtype);
00462         xx(longlong);
00463         assert(0); return 0;
00464     case U:
00465         if (chartype->op == UNSIGNED)
00466             xx(chartype);
00467         xx(unsignedchar);
00468         xx(unsignedshort);
00469         xx(unsignedtype);
00470         xx(unsignedlong);
00471         xx(unsignedlonglong);
00472         assert(0); return 0;
00473     case P:
00474         xx(voidptype);
00475         xx(funcptype);
00476         assert(0); return 0;
00477     }
00478 #undef xx
00479     assert(0); return 0;
00480 }

Tree call Tree  ,
Type  ,
Coordinate 
 

Definition at line 153 of file enode.c.

References l, and r.

Referenced by VM_CallCompiled().

00159         {
00160             long n;
00161             ty = unqual(r->type);
00162             n = unqual(ty->type)->size;
00163             if (n == 0)
00164                 error("unknown size for type `%t'\n", ty->type);
00165             l = cast(l, promote(l->type));
00166             if (n > 1)
00167                 l = multree(MUL, cnsttree(signedptr, n), l);
00168             if (YYcheck && !isaddrop(r->op))        /* omit */
00169                 return nullcall(ty, YYcheck, r, l); /* omit */
00170             return simplify(ADD, ty, l, r);
00171         }
00172 
00173     else
00174         typeerror(op, l, r);
00175     return simplify(op, ty, l, r);
00176 }
00177 
00178 Tree cnsttree(Type ty, ...) {
00179     Tree p = tree(mkop(CNST,ty), ty, NULL, NULL);
00180     va_list ap;
00181 
00182     va_start(ap, ty);
00183     switch (ty->op) {
00184     case INT:     p->u.v.i = va_arg(ap, long); break;
00185     case UNSIGNED:p->u.v.u = va_arg(ap, unsigned long)&ones(8*ty->size); break;
00186     case FLOAT:   p->u.v.d = va_arg(ap, long double); break;
00187     case POINTER: p->u.v.p = va_arg(ap, void *); break;
00188     default: assert(0);
00189     }
00190     va_end(ap);
00191     return p;
00192 }
00193 
00194 Tree consttree(unsigned n, Type ty) {
00195     if (isarray(ty))
00196         ty = atop(ty);
00197     else assert(isint(ty));
00198     return cnsttree(ty, (unsigned long)n);
00199 }
00200 static Tree cmptree(int op, Tree l, Tree r) {
00201     Type ty;
00202 
00203     if (isarith(l->type) && isarith(r->type)) {
00204         ty = binary(l->type, r->type);
00205         l = cast(l, ty);
00206         r = cast(r, ty);
00207     } else if (compatible(l->type, r->type)) {
00208         ty = unsignedptr;
00209         l = cast(l, ty);
00210         r = cast(r, ty);
00211     } else {
00212         ty = unsignedtype;
00213         typeerror(op, l, r);
00214     }
00215     return simplify(mkop(op,ty), inttype, l, r);
00216 }
00217 static int compatible(Type ty1, Type ty2) {
00218     return isptr(ty1) && !isfunc(ty1->type)
00219         && isptr(ty2) && !isfunc(ty2->type)
00220         && eqtype(unqual(ty1->type), unqual(ty2->type), 0);
00221 }
00222 static int isnullptr(Tree e) {
00223     Type ty = unqual(e->type);
00224 
00225     return generic(e->op) == CNST
00226         && (ty->op == INT      && e->u.v.i == 0
00227          || ty->op == UNSIGNED && e->u.v.u == 0
00228          || isvoidptr(ty)      && e->u.v.p == NULL);
00229 }
00230 Tree eqtree(int op, Tree l, Tree r) {
00231     Type xty = l->type, yty = r->type;
00232 
00233     if (isptr(xty) && isnullptr(r)

Tree calltree Tree  ,
Type  ,
Tree  ,
Symbol 
 

Definition at line 234 of file enode.c.

References cast(), inttype, l, mkop, op, r, simplify(), Type, and unqual.

Referenced by tracefinis().

00236                                                              {
00237         Type ty = unsignedptr;
00238         l = cast(l, ty);
00239         r = cast(r, ty);
00240         return simplify(mkop(op,ty), inttype, l, r);
00241     }
00242     if (isptr(yty) && isnullptr(l)
00243     ||  isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))
00244         return eqtree(op, r, l);
00245     return cmptree(op, l, r);
00246 }
00247 
00248 Type assign(Type xty, Tree e) {
00249     Type yty = unqual(e->type);
00250 
00251     xty = unqual(xty);
00252     if (isenum(xty))
00253         xty = xty->type;
00254     if (xty->size == 0 || yty->size == 0)
00255         return NULL;

Here is the call graph for this function:

Tree cast Tree  ,
Type 
 

Definition at line 797 of file expr.c.

Referenced by calltree(), cmp(), condtree(), initializer(), initvalue(), intexpr(), listnodes(), retcode(), simplify(), statement(), swcode(), swstmt(), and tracevalue().

void check Node   ) 
 

Referenced by CheckParm(), G_CheckProxMinePosition(), G_MoverPush(), G_TryPushingEntity(), G_TryPushingProxMine(), idCameraPosition::getVelocity(), PatchMapDrawSurfs(), SelectSplitPlaneNum(), SV_AreaEntities_r(), and Svcmd_EntityList_f().

void checklab Symbol  p,
void *  cl
 

Definition at line 1071 of file decl.c.

References symbol::defined, error(), symbol::name, p, and Symbol.

Referenced by funcdefn().

01071                                   {
01072     if (!p->defined)
01073         error("undefined label `%s'\n", p->name);
01074     p->defined = 1;
01075 }

Here is the call graph for this function:

Tree cnsttree Type  ,
  ...
 

Definition at line 312 of file enode.c.

References BAND, bittree(), CNST, tree::field, fieldmask, fieldsize, value::i, inttype, isunsigned, l, LSH, n, tree::op, r, RSH, shtree(), type::size, field::type, tree::type, tree::u, and tree::v.

Referenced by cmp(), funcdefn(), idtree(), listnodes(), simplify(), and swcode().

00312                         {
00313         long n = 8*l->u.field->type->size - fieldsize(l->u.field);
00314         if (n > 0 && isunsigned(l->u.field->type))
00315             r = bittree(BAND, r,
00316                 cnsttree(r->type, (unsigned long)fieldmask(l->u.field)));
00317         else if (n > 0) {
00318             if (r->op == CNST+I) {
00319                 n = r->u.v.i;
00320                 if (n&(1<<(fieldsize(l->u.field)-1)))
00321                     n |= ~0UL<<fieldsize(l->u.field);
00322                 r = cnsttree(r->type, n);
00323             } else
00324                 r = shtree(RSH,
00325                     shtree(LSH, r, cnsttree(inttype, n)),
00326                     cnsttree(inttype, n));

Here is the call graph for this function:

Code code int   ) 
 

Definition at line 25 of file stmt.c.

References Code, codelist, cp, FUNC, kind, code::kind, NEW, code::next, code::prev, reachable(), and warning().

Referenced by addlocal(), addrtree(), branch(), compound(), definelab(), definept(), doAddress(), doBlockbeg(), doBlockend(), doForest(), swcode(), swstmt(), and walk().

00025                     {
00026     Code cp;
00027 
00028     if (!reachable(kind))
00029         warning("unreachable code\n");
00030 
00031     NEW(cp, FUNC);
00032     cp->kind = kind;
00033     cp->prev = codelist;
00034     cp->next = NULL;
00035     codelist->next = cp;
00036     codelist = cp;
00037     return cp;
00038 }

Here is the call graph for this function:

Type compose Type  ,
Type 
 

Definition at line 390 of file types.c.

References type::align, append(), ARRAY, array(), assert, compose(), CONST, type::f, func(), FUNCTION, isconst, isvolatile, List, ltov(), NULL, type::oldstyle, type::op, p2, PERM, POINTER, type::proto, ptr(), qual(), type::size, Type, type::type, type::u, unqual, and VOLATILE.

Referenced by compile(), compose(), dclglobal(), dcllocal(), and filename().

00390                                  {
00391     if (ty1 == ty2)
00392         return ty1;
00393     assert(ty1->op == ty2->op);
00394     switch (ty1->op) {
00395     case POINTER:
00396         return ptr(compose(ty1->type, ty2->type));
00397     case CONST+VOLATILE:
00398         return qual(CONST, qual(VOLATILE,
00399             compose(ty1->type, ty2->type)));
00400     case CONST: case VOLATILE:
00401         return qual(ty1->op, compose(ty1->type, ty2->type));
00402     case ARRAY:    { Type ty = compose(ty1->type, ty2->type);
00403              if (ty1->size && (ty1->type->size && ty2->size == 0 || ty1->size == ty2->size))
00404                 return array(ty, ty1->size/ty1->type->size, ty1->align);
00405              if (ty2->size && ty2->type->size && ty1->size == 0)
00406                 return array(ty, ty2->size/ty2->type->size, ty2->align);
00407              return array(ty, 0, 0);    }
00408     case FUNCTION: { Type *p1  = ty1->u.f.proto, *p2 = ty2->u.f.proto;
00409              Type ty   = compose(ty1->type, ty2->type);
00410              List tlist = NULL;
00411              if (p1 == NULL && p2 == NULL)
00412                 return func(ty, NULL, 1);
00413              if (p1 && p2 == NULL)
00414                 return func(ty, p1, ty1->u.f.oldstyle);
00415              if (p2 && p1 == NULL)
00416                 return func(ty, p2, ty2->u.f.oldstyle);
00417              for ( ; *p1 && *p2; p1++, p2++) {
00418                 Type ty = compose(unqual(*p1), unqual(*p2));
00419                 if (isconst(*p1)    || isconst(*p2))
00420                     ty = qual(CONST, ty);
00421                 if (isvolatile(*p1) || isvolatile(*p2))
00422                     ty = qual(VOLATILE, ty);
00423                 tlist = append(ty, tlist);
00424              }
00425              assert(*p1 == NULL && *p2 == NULL);
00426              return func(ty, ltov(&tlist, PERM), 0); }
00427     }
00428     assert(0); return NULL;
00429 }

Here is the call graph for this function:

void compound int  ,
Swtch  ,
int 
 

Tree cond Tree   ) 
 

Definition at line 787 of file expr.c.

Referenced by addd(), addi(), conditional(), divd(), divi(), lookup(), muld(), muli(), and simplify().

Tree condtree Tree  ,
Tree  ,
Tree 
 

Definition at line 469 of file enode.c.

References cast(), inttype, isint, l, op, promote(), r, simplify(), Tree, Type, tree::type, and typeerror().

Referenced by tracevalue().

00469                                     {
00470     Type ty = inttype;
00471 
00472     if (isint(l->type) && isint(r->type)) {
00473         ty = promote(l->type);
00474         l = cast(l, ty);
00475         r = cast(r, inttype);
00476     } else
00477         typeerror(op, l, r);
00478     return simplify(op, ty, l, r);
00479 }
00480 
00481 /* subtree - construct tree for l - r */
00482 static Tree subtree(int op, Tree l, Tree r) {
00483     long n;
00484     Type ty = inttype;
00485 
00486     if (isarith(l->type) && isarith(r->type)) {
00487         ty = binary(l->type, r->type);
00488         l = cast(l, ty);
00489         r = cast(r, ty);        
00490     } else if (isptr(l->type) && !isfunc(l->type->type) && isint(r->type)) {
00491         ty = unqual(l->type);
00492         n = unqual(ty->type)->size;
00493         if (n == 0)
00494             error("unknown size for type `%t'\n", ty->type);
00495         r = cast(r, promote(r->type));
00496         if (n > 1)
00497             r = multree(MUL, cnsttree(signedptr, n), r);
00498         if (isunsigned(r->type))
00499             r = cast(r, unsignedptr);
00500         else
00501             r = cast(r, signedptr);
00502         return simplify(SUB+P, ty, l, r);
00503     } else if (compatible(l->type, r->type)) {
00504         ty = unqual(l->type);
00505         n = unqual(ty->type)->size;
00506         if (n == 0)
00507             error("unknown size for type `%t'\n", ty->type);
00508         l = simplify(SUB+U, unsignedptr,
00509             cast(l, unsignedptr), cast(r, unsignedptr));
00510         return simplify(DIV+I, longtype,
00511             cast(l, longtype), cnsttree(longtype, n));
00512     } else
00513         typeerror(op, l, r);
00514     return simplify(op, ty, l, r);
00515 }
00516 
00517 /* typeerror - issue "operands of op have illegal types `l' and `r'" */
00518 void typeerror(int op, Tree l, Tree r) {
00519     int i;

Here is the call graph for this function:

Symbol constant Type  ,
Value 
 

Definition at line 164 of file sym.c.

References symbol::addressed, table::all, ARRAY, assert, table::buckets, constants, d, interface::defsymbol, eqtype(), equalp, FLOAT, FUNCTION, g(), h(), HASHSIZE, i, INT, IR, entry::link, entry::name, NEW0, type::op, p, PERM, POINTER, entry::sym, type::sym, Symbol, Type, entry::type, value::u, type::u, unqual, UNSIGNED, v, Value, and vtoa().

Referenced by cvtconst(), intconst(), listnodes(), mkstr(), and visit().

00164                                   {
00165     struct entry *p;
00166     unsigned h = v.u&(HASHSIZE-1);
00167 
00168     ty = unqual(ty);
00169     for (p = constants->buckets[h]; p; p = p->link)
00170         if (eqtype(ty, p->sym.type, 1))
00171             switch (ty->op) {
00172             case INT:      if (equalp(i)) return &p->sym; break;
00173             case UNSIGNED: if (equalp(u)) return &p->sym; break;
00174             case FLOAT:    if (equalp(d)) return &p->sym; break;
00175             case FUNCTION: if (equalp(g)) return &p->sym; break;
00176             case ARRAY:
00177             case POINTER:  if (equalp(p)) return &p->sym; break;
00178             default: assert(0);
00179             }
00180     NEW0(p, PERM);
00181     p->sym.name = vtoa(ty, v);
00182     p->sym.scope = CONSTANTS;
00183     p->sym.type = ty;
00184     p->sym.sclass = STATIC;
00185     p->sym.u.c.v = v;
00186     p->link = constants->buckets[h];
00187     p->sym.up = constants->all;
00188     constants->all = &p->sym;
00189     constants->buckets[h] = p;
00190     if (ty->u.sym && !ty->u.sym->addressed)
00191         (*IR->defsymbol)(&p->sym);
00192     p->sym.defined = 1;
00193     return &p->sym;
00194 }

Here is the call graph for this function:

Tree constexpr int   ) 
 

Definition at line 185 of file simp.c.

References expr1(), needconst, p, and Tree.

Referenced by intexpr(), and statement().

00185                         {
00186     Tree p;
00187 
00188     needconst++;
00189     p = expr1(tok);
00190     needconst--;
00191     return p;
00192 }

Here is the call graph for this function:

Tree consttree unsigned  int,
Type 
 

Definition at line 328 of file enode.c.

Referenced by bbincr(), genconst(), initvalue(), tracecall(), and tracevalue().

00335                                       {

Tree cvtconst Tree   ) 
 

Definition at line 405 of file dag.c.

References ADDRG, atop(), symbol::c, constant(), e, genident(), GLOBAL, idtree(), isarray, symbol::loc, NULL, p, q, simplify(), tree::sym, Symbol, Tree, tree::type, tree::u, symbol::u, and tree::v.

Referenced by genconst(), and listnodes().

00405                       {
00406     Symbol q = constant(p->type, p->u.v);
00407     Tree e;
00408 
00409     if (q->u.c.loc == NULL)
00410         q->u.c.loc = genident(STATIC, p->type, GLOBAL);
00411     if (isarray(p->type)) {
00412         e = simplify(ADDRG, atop(p->type), NULL, NULL);
00413         e->u.sym = q->u.c.loc;
00414     } else
00415         e = idtree(q->u.c.loc);
00416     return e;
00417 }

Here is the call graph for this function:

void deallocate unsigned  a  ) 
 

Definition at line 87 of file alloc.c.

References a, assert, first, freeblocks, NELEMS, and block::next.

Referenced by initializer(), main(), program(), statement(), and walk().

00087                             {
00088     assert(a < NELEMS(arena));
00089     arena[a]->next = freeblocks;
00090     freeblocks = first[a].next;
00091     first[a].next = NULL;
00092     arena[a] = &first[a];
00093 }

void defglobal Symbol  ,
int 
 

Definition at line 284 of file decl.c.

References symbol::defined, interface::export, interface::global, IR, p, symbol::sclass, symbol::seg, swtoseg(), Symbol, and symbol::u.

Referenced by bbcall(), bbfunc(), bbvars(), dcllocal(), doconst(), doglobal(), emitcode(), initglobal(), and tracecall().

00284                                   {
00285     p->u.seg = seg;
00286     swtoseg(p->u.seg);
00287     if (p->sclass != STATIC)
00288         (*IR->export)(p);
00289     (*IR->global)(p);
00290     p->defined = 1;
00291 }

Here is the call graph for this function:

void definelab int   ) 
 

Definition at line 534 of file stmt.c.

References ADDRG, assert, Code, code(), codelist, cp, findlabel(), code::forest, node::kids, code::kind, symbol::l, LABEL, symbol::label, newnode(), code::next, NULL, node::op, p, P, code::prev, symbol::ref, specific, Symbol, node::syms, code::u, symbol::u, V, and walk().

Referenced by dostmt(), forstmt(), funcdefn(), ifstmt(), statement(), stmtlabel(), swcode(), swstmt(), and whilestmt().

00534                         {
00535     Code cp;
00536     Symbol p = findlabel(lab);
00537 
00538     assert(lab);
00539     walk(NULL, 0, 0);
00540     code(Label)->u.forest = newnode(LABEL+V, NULL, NULL, p);
00541     for (cp = codelist->prev; cp->kind <= Label; )
00542         cp = cp->prev;
00543     while (   cp->kind == Jump
00544            && cp->u.forest->kids[0]
00545            && specific(cp->u.forest->kids[0]->op) == ADDRG+P
00546            && cp->u.forest->kids[0]->syms[0] == p) {
00547         assert(cp->u.forest->kids[0]->syms[0]->u.l.label == lab);
00548         p->ref--;
00549         assert(cp->next);
00550         assert(cp->prev);
00551         cp->prev->next = cp->next;
00552         cp->next->prev = cp->prev;
00553         cp = cp->prev;
00554         while (cp->kind <= Label)
00555             cp = cp->prev;
00556     }
00557 }

Here is the call graph for this function:

void definept Coordinate  ) 
 

Definition at line 58 of file stmt.c.

References apply(), Code, code(), Coordinate, cp, e, events, coord::file, findcount(), glevel, identifiers, listnodes(), locus(), n, ncalled, p, code::point, Events::points, reachable(), refinc, code::src, Tree, code::u, coord::x, and coord::y.

Referenced by compound(), dcllocal(), dostmt(), forstmt(), ifstmt(), statement(), swstmt(), and whilestmt().

00058                              {
00059     Code cp = code(Defpoint);
00060 
00061     cp->u.point.src = p ? *p : src;
00062     cp->u.point.point = npoints;
00063     if (ncalled > 0) {
00064         int n = findcount(cp->u.point.src.file,
00065             cp->u.point.src.x, cp->u.point.src.y);
00066         if (n > 0)
00067             refinc = (float)n/ncalled;
00068     }
00069     if (glevel > 2) locus(identifiers, &cp->u.point.src);
00070     if (events.points && reachable(Gen))
00071         {
00072             Tree e = NULL;
00073             apply(events.points, &cp->u.point.src, &e);
00074             if (e)
00075                 listnodes(e, 0, 0);
00076         }
00077 }

Here is the call graph for this function:

void defpointer Symbol   ) 
 

Definition at line 7 of file init.c.

References interface::defaddress, interface::defconst, IR, p, symbol::ref, type::size, Symbol, Value, and voidptype.

Referenced by bbcall(), bbfunc(), and bbvars().

00007                           {
00008     if (p) {
00009         (*IR->defaddress)(p);
00010         p->ref++;
00011     } else {
00012         static Value v;
00013         (*IR->defconst)(P, voidptype->size, v);
00014     }
00015 }

Type deref Type   ) 
 

Definition at line 195 of file types.c.

References error(), isenum, isptr, Type, type::type, and unqual.

00195                     {
00196     if (isptr(ty))
00197         ty = ty->type;
00198     else
00199         error("type error: %s\n", "pointer expected");
00200     return isenum(ty) ? unqual(ty)->type : ty;
00201 }

Here is the call graph for this function:

void emitcode void   ) 
 

Definition at line 495 of file dag.c.

References assert, code::begin, code::block, Code, CODE, codehead, Coordinate, cp, interface::defaddress, defglobal(), code::deflab, interface::emit, equated(), errcnt, foreach(), code::forest, glevel, i, code::identifiers, IR, k, code::kind, code::labels, code::level, LIT, code::locals, LONG_MAX, code::next, NULL, code::point, code::size, src, code::src, interface::stabblock, interface::stabline, interface::stabsym, code::swtch, swtoseg(), code::table, code::types, typestab(), code::u, code::values, and code::var.

Referenced by asdl_function().

00495                     {
00496     Code cp;
00497     Coordinate save;
00498 
00499     save = src;
00500     cp = codehead.next;
00501     for ( ; errcnt <= 0 && cp; cp = cp->next)
00502         switch (cp->kind) {
00503         case Address: break;
00504         case Blockbeg: if (glevel && IR->stabblock) {
00505                     (*IR->stabblock)('{',  cp->u.block.level - LOCAL, cp->u.block.locals);
00506                     swtoseg(CODE);
00507                    }
00508  break;
00509         case Blockend: if (glevel && IR->stabblock) {
00510                     Code bp = cp->u.begin;
00511                     foreach(bp->u.block.identifiers, bp->u.block.level, typestab, NULL);
00512                     foreach(bp->u.block.types,       bp->u.block.level, typestab, NULL);
00513                     (*IR->stabblock)('}', bp->u.block.level - LOCAL, bp->u.block.locals);
00514                     swtoseg(CODE);
00515                    }
00516  break;
00517         case Defpoint: src = cp->u.point.src;
00518                    if (glevel > 0 && IR->stabline) {
00519                     (*IR->stabline)(&cp->u.point.src); swtoseg(CODE); } break;
00520         case Gen: case Jump:
00521         case Label:    if (cp->u.forest)
00522                     (*IR->emit)(cp->u.forest); break;
00523         case Local:    if (glevel && IR->stabsym) {
00524                     (*IR->stabsym)(cp->u.var);
00525                     swtoseg(CODE);
00526                    } break;
00527         case Switch:   {    int i;
00528                     defglobal(cp->u.swtch.table, LIT);
00529                     (*IR->defaddress)(equated(cp->u.swtch.labels[0]));
00530                     for (i = 1; i < cp->u.swtch.size; i++) {
00531                         long k = cp->u.swtch.values[i-1];
00532                         while (++k < cp->u.swtch.values[i])
00533                             assert(k < LONG_MAX),
00534                             (*IR->defaddress)(equated(cp->u.swtch.deflab));
00535                         (*IR->defaddress)(equated(cp->u.swtch.labels[i]));
00536                     }
00537                     swtoseg(CODE);
00538                    } break;
00539         default: assert(0);
00540         }
00541     src = save;
00542 }

Here is the call graph for this function:

void enterscope void   ) 
 

Definition at line 57 of file sym.c.

References level, and tempid.

Referenced by compound(), dclr1(), doBlockbeg(), doFunction(), and funcdefn().

00057                       {
00058     if (++level == LOCAL)
00059         tempid = 0;
00060 }

Type enumdcl void   ) 
 

Definition at line 1077 of file decl.c.

References Aflag, type::align, append(), Coordinate, symbol::defined, ENUM, error(), FUNC, gettok(), value::i, identifiers, symbol::idlist, install(), intexpr(), inttype, k, level, symbol::limits, List, LOCAL, lookup(), ltov(), symbol::max, n, newstruct(), NULL, type::op, p, PERM, s, symbol::sclass, symbol::scope, type::size, symbol::src, type::sym, Symbol, t, test(), tsym, Type, symbol::type, type::type, types, type::u, symbol::u, use(), symbol::value, and warning().

Referenced by specifier().

01077                    {
01078     char *tag;
01079     Type ty;
01080     Symbol p;
01081     Coordinate pos;
01082 
01083     t = gettok();
01084     pos = src;
01085     if (t == ID) {
01086         tag = token;
01087         t = gettok();
01088     } else
01089         tag = "";
01090     if (t == '{') {
01091         static char follow[] = { IF, 0 };
01092         int n = 0;
01093         long k = -1;
01094         List idlist = 0;
01095         ty = newstruct(ENUM, tag);
01096         t = gettok();
01097         if (t != ID)
01098             error("expecting an enumerator identifier\n");
01099         while (t == ID) {
01100             char *id = token;
01101             Coordinate s;
01102             if (tsym && tsym->scope == level)
01103                 error("redeclaration of `%s' previously declared at %w\n",
01104                     token, &tsym->src);
01105             s = src;
01106             t = gettok();
01107             if (t == '=') {
01108                 t = gettok();
01109                 k = intexpr(0, 0);
01110             } else {
01111                 if (k == inttype->u.sym->u.limits.max.i)
01112                     error("overflow in value for enumeration constant `%s'\n", id);
01113                 k++;
01114             }
01115             p = install(id, &identifiers, level,  level < LOCAL ? PERM : FUNC);
01116             p->src = s;
01117             p->type = ty;
01118             p->sclass = ENUM;
01119             p->u.value = k;
01120             idlist = append(p, idlist);
01121             n++;
01122             if (Aflag >= 2 && n == 128)
01123                 warning("more than 127 enumeration constants in `%t'\n", ty);
01124             if (t != ',')
01125                 break;
01126             t = gettok();
01127             if (Aflag >= 2 && t == '}')
01128                 warning("non-ANSI trailing comma in enumerator list\n");
01129         }
01130         test('}', follow);
01131         ty->type = inttype;
01132         ty->size = ty->type->size;
01133         ty->align = ty->type->align;
01134         ty->u.sym->u.idlist = ltov(&idlist, PERM);
01135         ty->u.sym->defined = 1;
01136     } else if ((p = lookup(tag, types)) != NULL && p->type->op == ENUM) {
01137         ty = p->type;
01138         if (t == ';')
01139             error("empty declaration\n");
01140     } else {
01141         error("unknown enumeration `%s'\n",  tag);
01142         ty = newstruct(ENUM, tag);
01143         ty->type = inttype;
01144     }
01145     if (*tag && xref)
01146         use(p, pos);
01147     return ty;
01148 }

Here is the call graph for this function:

Tree eqtree int  ,
Tree  ,
Tree 
 

Definition at line 364 of file enode.c.

Referenced by cmp(), and simplify().

00368                    {
00369     case CNST+I: return cast(e->u.v.i != 0   ? l : r, ty);
00370     case CNST+U: return cast(e->u.v.u != 0   ? l : r, ty);
00371     case CNST+P: return cast(e->u.v.p != 0   ? l : r, ty);
00372     case CNST+F: return cast(e->u.v.d != 0.0 ? l : r, ty);
00373     }
00374     if (ty != voidtype && ty->size > 0) {
00375         t1 = genident(REGISTER, unqual(ty), level);
00376     /*  t1 = temporary(REGISTER, unqual(ty)); */
00377         l = asgn(t1, l);
00378         r = asgn(t1, r);
00379     } else
00380         t1 = NULL;

int eqtype Type  ,
Type  ,
int 
 

Definition at line 312 of file types.c.

References ARRAY, assert, CONST, ENUM, type::f, FLOAT, FUNCTION, INT, isenum, NULL, type::op, p2, POINTER, promote(), type::proto, type::size, STRUCT, Type, type::type, type::u, UNION, unqual, UNSIGNED, variadic(), and VOLATILE.

Referenced by constant(), dclglobal(), dcllocal(), and funcdefn().

00312                                         {
00313     if (ty1 == ty2)
00314         return 1;
00315     if (ty1->op != ty2->op)
00316         return 0;
00317     switch (ty1->op) {
00318     case ENUM: case UNION: case STRUCT:
00319     case UNSIGNED: case INT: case FLOAT:
00320         return 0;
00321     case POINTER:  return eqtype(ty1->type, ty2->type, 1);
00322     case VOLATILE: case CONST+VOLATILE:
00323     case CONST:    return eqtype(ty1->type, ty2->type, 1);
00324     case ARRAY:    if (eqtype(ty1->type, ty2->type, 1)) {
00325                 if (ty1->size == ty2->size)
00326                     return 1;
00327                 if (ty1->size == 0 || ty2->size == 0)
00328                     return ret;
00329                }
00330                return 0;
00331     case FUNCTION: if (eqtype(ty1->type, ty2->type, 1)) {
00332                 Type *p1 = ty1->u.f.proto, *p2 = ty2->u.f.proto;
00333                 if (p1 == p2)
00334                     return 1;
00335                 if (p1 && p2) {
00336                     for ( ; *p1 && *p2; p1++, p2++)
00337                     if (eqtype(unqual(*p1), unqual(*p2), 1) == 0)
00338                         return 0;
00339                 if (*p1 == NULL && *p2 == NULL)
00340                     return 1;
00341                 } else {
00342                     if (variadic(p1 ? ty1 : ty2))
00343                     return 0;
00344                 if (p1 == NULL)
00345                     p1 = p2;
00346                 for ( ; *p1; p1++) {
00347                     Type ty = unqual(*p1);
00348                     if (promote(ty) != (isenum(ty) ? ty->type : ty))
00349                         return 0;
00350                 }
00351                 return 1;
00352                 }
00353                }
00354                return 0;
00355     }
00356     assert(0); return 0;
00357 }

Here is the call graph for this function:

void equatelab Symbol  ,
Symbol 
 

Definition at line 598 of file stmt.c.

References assert, symbol::equatedto, symbol::l, NULL, symbol::ref, Symbol, and symbol::u.

Referenced by branch(), labelnode(), and listnodes().

00598                                        {
00599     assert(old->u.l.equatedto == NULL);
00600     old->u.l.equatedto = new;
00601     new->ref++;
00602 }

void error const char *  ,
  ...
 

Definition at line 167 of file error.c.

Referenced by allocate(), array(), atop(), backslash(), builtin(), caselabel(), checklab(), checkref(), control(), dclglobal(), dcllocal(), dclparam(), dclr1(), decl(), deref(), doadefine(), doconcat(), dodefine(), doglobal(), doinclude(), domalloc(), enumdcl(), eval(), evalop(), exitparams(), expand(), expandrow(), expr1(), fcon(), fillbuf(), freturn(), func(), funcdefn(), gatherargs(), genconst(), gettok(), gettokens(), growtokenrow(), initializer(), initvalue(), intexpr(), newfield(), newhideset(), newstruct(), oldparam(), opt(), parameters(), ppnumber(), process(), program(), qual(), retcode(), scon(), setup(), specifier(), statement(), stmtlabel(), stringify(), structdcl(), substargs(), swstmt(), and tokval().

void exitscope void   ) 
 

Definition at line 61 of file sym.c.

References Aflag, table::all, assert, GLOBAL, identifiers, level, table::level, n, p, table::previous, rmtypes(), symbol::scope, Symbol, types, symbol::up, and warning().

Referenced by compound(), decl(), doBlockend(), doFunction(), exitparams(), and funcdefn().

00061                      {
00062     rmtypes(level);
00063     if (types->level == level)
00064         types = types->previous;
00065     if (identifiers->level == level) {
00066         if (Aflag >= 2) {
00067             int n = 0;
00068             Symbol p;
00069             for (p = identifiers->all; p && p->scope == level; p = p->up)
00070                 if (++n > 127) {
00071                     warning("more than 127 identifiers declared in a block\n");
00072                     break;
00073                 }
00074         }
00075         identifiers = identifiers->previous;
00076     }
00077     assert(level >= GLOBAL);
00078     --level;
00079 }

Here is the call graph for this function:

void expect int  tok  ) 
 

Definition at line 158 of file error.c.

Referenced by compound(), dcllocal(), dclr1(), dostmt(), forstmt(), funcdefn(), ifstmt(), parameters(), statement(), stmtlabel(), swstmt(), and whilestmt().

Tree expr int   ) 
 

Definition at line 306 of file expr.c.

Referenced by conditional(), statement(), and swstmt().

00307                 :   t = gettok();
00308                 if (t == ID) {
00309                     if (isstruct(p->type)) {
00310                         Tree q = addrof(p);
00311                         p = field(q, token);
00312                         q = rightkid(q);
00313                         if (isaddrop(q->op) && q->u.sym->temporary)
00314                             p = tree(RIGHT, p->type, p, NULL);
00315                     } else
00316                         error("left operand of . has incompatible type `%t'\n",
00317                             p->type);
00318                     t = gettok();
00319                 } else

Tree expr0 int   ) 
 

Definition at line 320 of file expr.c.

References DEREF, p, and t.

Referenced by forstmt(), and statement().

00321                   : t = gettok();
00322                 p = pointer(p);

Tree expr1 int   ) 
 

Definition at line 323 of file expr.c.

References error(), field(), gettok(), isptr, isstruct, nullcheck(), p, t, tree::type, and type::type.

Referenced by constexpr(), dcllocal(), dclparam(), initializer(), and initvalue().

00323                              {
00324                     if (isptr(p->type) && isstruct(p->type->type)) {
00325                         if (YYnull)
00326                             p = nullcheck(p);
00327                         p = field(p, token);
00328                     } else
00329                         error("left operand of -> has incompatible type `%t'\n", p->type);
00330 
00331                     t = gettok();
00332                 } else
00333                     error("field name expected\n"); break;
00334         default:
00335             return p;
00336         }
00337 }
00338 static Tree primary(void) {
00339     Tree p;
00340 
00341     assert(t != '(');
00342     switch (t) {
00343     case ICON:

Here is the call graph for this function:

int fatal const char *  ,
const char *  ,
int 
 

Definition at line 208 of file error.c.

Tree field Tree  ,
const char * 
 

Definition at line 901 of file expr.c.

Referenced by expr1(), MSG_ReadDeltaEntity(), MSG_ReadDeltaPlayerstate(), MSG_WriteDeltaEntity(), MSG_WriteDeltaPlayerstate(), tracevalue(), and uid2type().

Field fieldlist Type   ) 
 

Definition at line 497 of file types.c.

References Field, symbol::flist, symbol::s, type::sym, Type, type::u, and symbol::u.

Referenced by asgncode(), emittype(), and typeuid().

00497                          {
00498     return ty->u.sym->u.s.flist;
00499 }

Field fieldref const char *  name,
Type  ty
 

Definition at line 502 of file types.c.

References assert, Field, isfield(), lookup(), name, p, q, src, Symbol, Type, unqual, and use().

00502                                           {
00503     Field p = isfield(name, unqual(ty)->u.sym->u.s.flist);
00504 
00505     if (p && xref) {
00506         Symbol q;
00507         assert(unqual(ty)->u.sym->u.s.ftab);
00508         q = lookup(name, unqual(ty)->u.sym->u.s.ftab);
00509         assert(q);
00510         use(q, src);
00511     }
00512     return p;
00513 }

Here is the call graph for this function:

void fillbuf void   ) 
 

Definition at line 35 of file input.c.

References assert, bsize, buffer, BUFSIZE, cp, error(), exit(), EXIT_FAILURE, feof, fread(), limit, line, MAXLINE, n, s, and stdin.

Referenced by foldline(), gettok(), gettokens(), input_init(), nextline(), resynch(), scon(), and trigraph().

00035                    {
00036     if (bsize == 0)
00037         return;
00038     if (cp >= limit)
00039         cp = &buffer[MAXLINE+1];
00040     else
00041         {
00042             int n = limit - cp;
00043             unsigned char *s = &buffer[MAXLINE+1] - n;
00044             assert(s >= buffer);
00045             line = (char *)s - ((char *)cp - line);
00046             while (cp < limit)
00047                 *s++ = *cp++;
00048             cp = &buffer[MAXLINE+1] - n;
00049         }
00050     if (feof(stdin))
00051         bsize = 0;
00052     else
00053         bsize = fread(&buffer[MAXLINE+1], 1, BUFSIZE, stdin);
00054     if (bsize < 0) {
00055         error("read error\n");
00056         exit(EXIT_FAILURE);
00057     }
00058     limit = &buffer[MAXLINE+1+bsize];
00059     *limit = '\n';
00060 }

Here is the call graph for this function:

void finalize void   ) 
 

Definition at line 1019 of file decl.c.

References checkref(), constants, CONSTANTS, doconst(), doextern(), doglobal(), externals, foreach(), GLOBAL, identifiers, and NULL.

Referenced by main().

01019                     {
01020     foreach(externals,   GLOBAL,    doextern, NULL);
01021     foreach(identifiers, GLOBAL,    doglobal, NULL);
01022     foreach(identifiers, GLOBAL,    checkref, NULL);
01023     foreach(constants,   CONSTANTS, doconst,  NULL);
01024 }

Here is the call graph for this function:

int findcount char *  ,
int  ,
int 
 

Definition at line 143 of file profio.c.

References c, file::count, count::count, file::counts, file, findfile(), k, l, file::name, count::x, count::y, and y.

Referenced by definept().

00143                                         {
00144     static struct file *cursor;
00145 
00146     if (cursor == 0 || cursor->name != file)
00147         cursor = findfile(file);
00148     if (cursor) {
00149         int l, u;
00150         struct count *c = cursor->counts;
00151         for (l = 0, u = cursor->count - 1; l <= u; ) {
00152             int k = (l + u)/2;
00153             if (c[k].y > y || c[k].y == y && c[k].x > x)
00154                 u = k - 1;
00155             else if (c[k].y < y || c[k].y == y && c[k].x < x)
00156                 l = k + 1;
00157             else
00158                 return c[k].count;
00159         }
00160     }
00161     return -1;
00162 }

Here is the call graph for this function:

int findfunc char *  ,
char * 
 

Definition at line 165 of file profio.c.

References file, findfile(), file::funcs, func::link, file::name, func::name, and p.

Referenced by funcdefn().

00165                                      {
00166     static struct file *cursor;
00167 
00168     if (cursor == 0 || cursor->name != file)
00169         cursor = findfile(file);
00170     if (cursor) {
00171         struct func *p;
00172         for (p = cursor->funcs; p; p = p->link)
00173             if (p->name == name)
00174                 return p->count.count;
00175     }
00176     return -1;
00177 }

Here is the call graph for this function:

Symbol findlabel int   ) 
 

Definition at line 145 of file sym.c.

References table::all, table::buckets, interface::defsymbol, FUNC, h(), HASHSIZE, IR, labels, entry::link, entry::name, NEW0, p, stringd(), entry::sym, and Symbol.

Referenced by branch(), caselabel(), definelab(), doDeflabel(), dostmt(), forstmt(), ifstmt(), jump(), labelnode(), listnodes(), statement(), swstmt(), visit(), and whilestmt().

00145                           {
00146     struct entry *p;
00147     unsigned h = lab&(HASHSIZE-1);
00148 
00149     for (p = labels->buckets[h]; p; p = p->link)
00150         if (lab == p->sym.u.l.label)
00151             return &p->sym;
00152     NEW0(p, FUNC);
00153     p->sym.name = stringd(lab);
00154     p->sym.scope = LABELS;
00155     p->sym.up = labels->all;
00156     labels->all = &p->sym;
00157     p->link = labels->buckets[h];
00158     labels->buckets[h] = p;
00159     p->sym.generated = 1;
00160     p->sym.u.l.label = lab;
00161     (*IR->defsymbol)(&p->sym);
00162     return &p->sym;
00163 }

Here is the call graph for this function:

Symbol findtype Type   ) 
 

Definition at line 252 of file sym.c.

References assert, table::buckets, i, entry::link, p, table::previous, entry::sym, Symbol, Table, Type, and entry::type.

Referenced by outtype(), and typestring().

00252                          {
00253     Table tp = identifiers;
00254     int i;
00255     struct entry *p;
00256 
00257     assert(tp);
00258     do
00259         for (i = 0; i < HASHSIZE; i++)
00260             for (p = tp->buckets[i]; p; p = p->link)
00261                 if (p->sym.type == ty && p->sym.sclass == TYPEDEF)
00262                     return &p->sym;
00263     while ((tp = tp->previous) != NULL);
00264     return NULL;
00265 }

void foreach Table  ,
int  ,
void(*)(Symbol, void *)  ,
void * 
 

Definition at line 42 of file sym.c.

References table::all, assert, Coordinate, table::level, p, table::previous, symbol::scope, src, symbol::src, Symbol, Table, and symbol::up.

Referenced by compound(), emitcode(), finalize(), funcdefn(), main(), and stabinit().

00042                                                                          {
00043     assert(tp);
00044     while (tp && tp->level > lev)
00045         tp = tp->previous;
00046     if (tp && tp->level == lev) {
00047         Symbol p;
00048         Coordinate sav;
00049         sav = src;
00050         for (p = tp->all; p && p->scope == lev; p = p->up) {
00051             src = p->src;
00052             (*apply)(p, cl);
00053         }
00054         src = sav;
00055     }
00056 }

void fprint FILE f,
const char *  fmt,
  ...
 

Definition at line 47 of file output.c.

References f, NULL, va_end, va_list, va_start, and vfprint().

Referenced by dumpcover(), dumpregs(), dumprule(), dumptree(), genreload(), genspill(), getrule(), linearize(), main(), main_init(), outtype(), printdag(), printdecl(), printnode(), printtree1(), printtype(), prtype(), prune(), ralloc(), reduce(), reprune(), requate(), rewrite(), and rtarget().

00047                                            {
00048     va_list ap;
00049 
00050     va_start(ap, fmt);
00051     vfprint(f, NULL, fmt, ap);
00052     va_end(ap);
00053 }

Here is the call graph for this function:

Type freturn Type   ) 
 

Definition at line 256 of file types.c.

References error(), isfunc, Type, and type::type.

Referenced by compound(), funcdefn(), printproto(), retcode(), stabsym(), statement(), tracefinis(), and tracereturn().

00256                       {
00257     if (isfunc(ty))
00258         return ty->type;
00259     error("type error: %s\n", "function expected");
00260     return inttype;
00261 }

Here is the call graph for this function:

Type ftype Type  ,
Type 
 

Definition at line 516 of file types.c.

References append(), func(), List, ltov(), NULL, PERM, Type, and voidtype.

Referenced by bbentry(), bbexit(), and trace_init().

00516                               {
00517     List list = append(ty, NULL);
00518 
00519     list = append(voidtype, list);
00520     return func(rty, ltov(&list, PERM), 0);
00521 }

Here is the call graph for this function:

Type func Type  ,
Type ,
int 
 

Definition at line 248 of file types.c.

References error(), type::f, FUNCTION, isarray, isfunc, NULL, type::oldstyle, type::proto, Type, type(), and type::u.

Referenced by AddThread(), compose(), CPUID(), dclr(), ftype(), funcdefn(), logAlphaFunc(), logDepthFunc(), logStencilFunc(), main_init(), printproto(), qglAlphaFunc(), qglDepthFunc(), qglStencilFunc(), RunThreadsOn(), TableForFunc(), type_init(), and uid2type().

00248                                            {
00249     if (ty && (isarray(ty) || isfunc(ty)))
00250         error("illegal return type `%t'\n", ty);
00251     ty = type(FUNCTION, ty, 0, 0, NULL);
00252     ty->u.f.proto = proto;
00253     ty->u.f.oldstyle = style;
00254     return ty;
00255 }

Here is the call graph for this function:

char* funcname Tree   ) 
 

Definition at line 943 of file expr.c.

Referenced by conditional(), NameToAFunc(), and NameToGenFunc().

void gencode Symbol  [],
Symbol  []
 

Definition at line 418 of file dag.c.

References code::addr, interface::address, asgn(), assert, code::base, code::begin, code::block, interface::blockbeg, interface::blockend, Code, CODE, codehead, codelist, Coordinate, cp, errcnt, fixup(), code::forest, interface::gen, glevel, i, idtree(), IR, code::kind, interface::local, code::locals, code::next, NULL, code::offset, p, code::point, code::prev, prune(), prunetemps, q, symbol::sclass, src, code::src, interface::stabsym, swtoseg(), code::sym, Symbol, symbol::type, type::type, code::u, code::var, walk(), interface::wants_dag, and code::x.

Referenced by asdl_function().

00418                                                {
00419     Code cp;
00420     Coordinate save;
00421 
00422     if (prunetemps == -1)
00423         prunetemps = !IR->wants_dag;
00424     save = src;
00425     if (assignargs) {
00426         int i;
00427         Symbol p, q;
00428         cp = codehead.next->next;
00429         codelist = codehead.next;
00430         for (i = 0; (p = callee[i]) != NULL
00431                  && (q = caller[i]) != NULL; i++)
00432             if (p->sclass != q->sclass || p->type != q->type)
00433                 walk(asgn(p, idtree(q)), 0, 0);
00434         codelist->next = cp;
00435         cp->prev = codelist;
00436     }
00437     if (glevel && IR->stabsym) {
00438         int i;
00439         Symbol p, q;
00440         for (i = 0; (p = callee[i]) != NULL
00441                  && (q = caller[i]) != NULL; i++) {
00442             (*IR->stabsym)(p);
00443             if (p->sclass != q->sclass || p->type != q->type)
00444                 (*IR->stabsym)(q);
00445         }
00446         swtoseg(CODE);
00447     }
00448     cp = codehead.next;
00449     for ( ; errcnt <= 0 && cp; cp = cp->next)
00450         switch (cp->kind) {
00451         case Address:  (*IR->address)(cp->u.addr.sym, cp->u.addr.base,
00452                     cp->u.addr.offset); break;
00453         case Blockbeg: {
00454                     Symbol *p = cp->u.block.locals;
00455                     (*IR->blockbeg)(&cp->u.block.x);
00456                     for ( ; *p; p++)
00457                         if ((*p)->ref != 0.0)
00458                             (*IR->local)(*p);
00459                         else if (glevel) (*IR->local)(*p);
00460                    }
00461  break;
00462         case Blockend: (*IR->blockend)(&cp->u.begin->u.block.x); break;
00463         case Defpoint: src = cp->u.point.src; break;
00464         case Gen: case Jump:
00465         case Label:    if (prunetemps)
00466                     cp->u.forest = prune(cp->u.forest);
00467                    fixup(cp->u.forest);
00468                    cp->u.forest = (*IR->gen)(cp->u.forest); break;
00469         case Local:    (*IR->local)(cp->u.var); break;
00470         case Switch:   break;
00471         default: assert(0);
00472         }
00473     src = save;
00474 }

Here is the call graph for this function:

Symbol genident int  ,
Type  ,
int 
 

Definition at line 201 of file sym.c.

References interface::defsymbol, FUNC, symbol::generated, genlabel(), IR, LOCAL, symbol::name, NEW0, p, PERM, symbol::sclass, symbol::scope, stringd(), Symbol, Type, and symbol::type.

Referenced by bbcall(), bbentry(), bbvars(), compound(), cvtconst(), dcllocal(), funcdefn(), mkstr(), prof_init(), retcode(), swcode(), swstmt(), and tracecall().

00201                                             {
00202     Symbol p;
00203 
00204     NEW0(p, lev >= LOCAL ? FUNC : PERM);
00205     p->name = stringd(genlabel(1));
00206     p->scope = lev;
00207     p->sclass = scls;
00208     p->type = ty;
00209     p->generated = 1;
00210     if (lev == GLOBAL)
00211         (*IR->defsymbol)(p);
00212     return p;
00213 }

Here is the call graph for this function:

int genlabel int   ) 
 

Definition at line 139 of file sym.c.

Referenced by addrtree(), asdl_progend(), funcdefn(), genident(), listnodes(), main(), newfield(), newstruct(), stabblock(), stabline(), statement(), stmtlabel(), and swcode().

00139                     {
00140     static int label = 1;
00141 
00142     label += n;
00143     return label - n;
00144 }

int getchr void   ) 
 

Definition at line 859 of file lex.c.

References cp, map, and nextline().

Referenced by compound(), scon(), and statement().

00859                  {
00860     for (;;) {
00861         while (map[*cp]&BLANK)
00862             cp++;
00863         if (!(map[*cp]&NEWLINE))
00864             return *cp;
00865         cp++;
00866         nextline();
00867         if (cp == limit)
00868             return EOI;
00869     }
00870 }

Here is the call graph for this function:

int gettok void   ) 
 

Definition at line 155 of file lex.c.

References ANDAND, array(), assert, c, symbol::c, cbuf, chartype, cp, cput(), d, DIGIT, doubletype, EQL, err(), error(), extend, fcon(), coord::file, fillbuf(), floattype, value::i, icon(), identifiers, INCR, inttype, limit, LONG, lookup(), map, n, NEQ, nextline(), type::op, OROR, value::p, s, scon(), src, stringn(), type::sym, token, tsym, tval, symbol::type, type::u, symbol::u, value::u, ULONG_MAX, symbol::v, voidtype, warning(), wcbuf, wcput(), widechar, coord::x, and coord::y.

Referenced by dclglobal(), dcllocal(), dclparam(), dclr1(), decl(), dostmt(), enumdcl(), expr1(), forstmt(), ifstmt(), initarray(), initchar(), initend(), initfields(), initglobal(), initializer(), initstruct(), main(), parameters(), pragma(), program(), specifier(), statement(), stmtlabel(), structdcl(), swstmt(), and whilestmt().

00155                  {
00156     for (;;) {
00157         register unsigned char *rcp = cp;
00158         while (map[*rcp]&BLANK)
00159             rcp++;
00160         if (limit - rcp < MAXTOKEN) {
00161             cp = rcp;
00162             fillbuf();
00163             rcp = cp;
00164         }
00165         src.file = file;
00166         src.x = (char *)rcp - line;
00167         src.y = lineno;
00168         cp = rcp + 1;
00169         switch (*rcp++) {
00170         case '/': if (*rcp == '*') {
00171                 int c = 0;
00172                 for (rcp++; *rcp != '/' || c != '*'; )
00173                     if (map[*rcp]&NEWLINE) {
00174                         if (rcp < limit)
00175                             c = *rcp;
00176                         cp = rcp + 1;
00177                         nextline();
00178                         rcp = cp;
00179                         if (rcp == limit)
00180                             break;
00181                     } else
00182                         c = *rcp++;
00183                 if (rcp < limit)
00184                     rcp++;
00185                 else
00186                     error("unclosed comment\n");
00187                 cp = rcp;
00188                 continue;
00189               }
00190               return '/';
00191         case '<':
00192             if (*rcp == '=') return cp++, LEQ;
00193             if (*rcp == '<') return cp++, LSHIFT;
00194             return '<';
00195         case '>':
00196             if (*rcp == '=') return cp++, GEQ;
00197             if (*rcp == '>') return cp++, RSHIFT;
00198             return '>';
00199         case '-':
00200             if (*rcp == '>') return cp++, DEREF;
00201             if (*rcp == '-') return cp++, DECR;
00202             return '-';
00203         case '=': return *rcp == '=' ? cp++, EQL    : '=';
00204         case '!': return *rcp == '=' ? cp++, NEQ    : '!';
00205         case '|': return *rcp == '|' ? cp++, OROR   : '|';
00206         case '&': return *rcp == '&' ? cp++, ANDAND : '&';
00207         case '+': return *rcp == '+' ? cp++, INCR   : '+';
00208         case ';': case ',': case ':':
00209         case '*': case '~': case '%': case '^': case '?':
00210         case '[': case ']': case '{': case '}': case '(': case ')': 
00211             return rcp[-1];
00212         case '\n': case '\v': case '\r': case '\f':
00213             nextline();
00214             if (cp == limit) {
00215                 tsym = NULL;
00216                 return EOI;
00217             }
00218             continue;
00219 
00220         case 'i':
00221             if (rcp[0] == 'f'
00222             && !(map[rcp[1]]&(DIGIT|LETTER))) {
00223                 cp = rcp + 1;
00224                 return IF;
00225             }
00226             if (rcp[0] == 'n'
00227             &&  rcp[1] == 't'
00228             && !(map[rcp[2]]&(DIGIT|LETTER))) {
00229                 cp = rcp + 2;
00230                 tsym = inttype->u.sym;
00231                 return INT;
00232             }
00233             goto id;
00234         case 'h': case 'j': case 'k': case 'm': case 'n': case 'o':
00235         case 'p': case 'q': case 'x': case 'y': case 'z':
00236         case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
00237         case 'G': case 'H': case 'I': case 'J': case 'K':
00238         case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
00239         case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
00240         case 'Y': case 'Z':
00241         id:
00242             if (limit - rcp < MAXLINE) {
00243                 cp = rcp - 1;
00244                 fillbuf();
00245                 rcp = ++cp;
00246             }
00247             assert(cp == rcp);
00248             token = (char *)rcp - 1;
00249             while (map[*rcp]&(DIGIT|LETTER))
00250                 rcp++;
00251             token = stringn(token, (char *)rcp - token);
00252             tsym = lookup(token, identifiers);
00253             cp = rcp;
00254             return ID;
00255         case '0': case '1': case '2': case '3': case '4':
00256         case '5': case '6': case '7': case '8': case '9': {
00257             unsigned long n = 0;
00258             if (limit - rcp < MAXLINE) {
00259                 cp = rcp - 1;
00260                 fillbuf();
00261                 rcp = ++cp;
00262             }
00263             assert(cp == rcp);
00264             token = (char *)rcp - 1;
00265             if (*token == '0' && (*rcp == 'x' || *rcp == 'X')) {
00266                 int d, overflow = 0;
00267                 while (*++rcp) {
00268                     if (map[*rcp]&DIGIT)
00269                         d = *rcp - '0';
00270                     else if (*rcp >= 'a' && *rcp <= 'f')
00271                         d = *rcp - 'a' + 10;
00272                     else if (*rcp >= 'A' && *rcp <= 'F')
00273                         d = *rcp - 'A' + 10;
00274                     else
00275                         break;
00276                     if (n&~(~0UL >> 4))
00277                         overflow = 1;
00278                     else
00279                         n = (n<<4) + d;
00280                 }
00281                 if ((char *)rcp - token <= 2)
00282                     error("invalid hexadecimal constant `%S'\n", token, (char *)rcp-token);
00283                 cp = rcp;
00284                 tsym = icon(n, overflow, 16);
00285             } else if (*token == '0') {
00286                 int err = 0, overflow = 0;
00287                 for ( ; map[*rcp]&DIGIT; rcp++) {
00288                     if (*rcp == '8' || *rcp == '9')
00289                         err = 1;
00290                     if (n&~(~0UL >> 3))
00291                         overflow = 1;
00292                     else
00293                         n = (n<<3) + (*rcp - '0');
00294                 }
00295                 if (*rcp == '.' || *rcp == 'e' || *rcp == 'E') {
00296                     cp = rcp;
00297                     tsym = fcon();
00298                     return FCON;
00299                 }
00300                 cp = rcp;
00301                 tsym = icon(n, overflow, 8);
00302                 if (err)
00303                     error("invalid octal constant `%S'\n", token, (char*)cp-token);
00304             } else {
00305                 int overflow = 0;
00306                 for (n = *token - '0'; map[*rcp]&DIGIT; ) {
00307                     int d = *rcp++ - '0';
00308                     if (n > (ULONG_MAX - d)/10)
00309                         overflow = 1;
00310                     else
00311                         n = 10*n + d;
00312                 }
00313                 if (*rcp == '.' || *rcp == 'e' || *rcp == 'E') {
00314                     cp = rcp;
00315                     tsym = fcon();
00316                     return FCON;
00317                 }
00318                 cp = rcp;
00319                 tsym = icon(n, overflow, 10);
00320             }
00321             return ICON;
00322         }
00323         case '.':
00324             if (rcp[0] == '.' && rcp[1] == '.') {
00325                 cp += 2;
00326                 return ELLIPSIS;
00327             }
00328             if ((map[*rcp]&DIGIT) == 0)
00329                 return '.';
00330             if (limit - rcp < MAXLINE) {
00331                 cp = rcp - 1;
00332                 fillbuf();
00333                 rcp = ++cp;
00334             }
00335             assert(cp == rcp);
00336             cp = rcp - 1;
00337             token = (char *)cp;
00338             tsym = fcon();
00339             return FCON;
00340         case 'L':
00341             if (*rcp == '\'') {
00342                 unsigned int *s = scon(*cp, wcput, wcbuf);
00343                 if (s - wcbuf > 2)
00344                     warning("excess characters in wide-character literal ignored\n");
00345                 tval.type = widechar;
00346                 tval.u.c.v.u = wcbuf[0];
00347                 tsym = &tval;
00348                 return ICON;
00349             } else if (*rcp == '"') {
00350                 unsigned int *s = scon(*cp, wcput, wcbuf);
00351                 tval.type = array(widechar, s - wcbuf, 0);
00352                 tval.u.c.v.p = wcbuf;
00353                 tsym = &tval;
00354                 return SCON;
00355             } else
00356                 goto id;
00357         case '\'': {
00358             char *s = scon(*--cp, cput, cbuf);
00359             if (s - cbuf > 2)
00360                 warning("excess characters in multibyte character literal ignored\n");
00361             tval.type = inttype;
00362             if (chartype->op == INT)
00363                 tval.u.c.v.i = extend(cbuf[0], chartype);
00364             else
00365                 tval.u.c.v.i = cbuf[0]&0xFF;
00366             tsym = &tval;
00367             return ICON;
00368             }
00369         case '"': {
00370             char *s = scon(*--cp, cput, cbuf);
00371             tval.type = array(chartype, s - cbuf, 0);
00372             tval.u.c.v.p = cbuf;
00373             tsym = &tval;
00374             return SCON;
00375             }
00376         case 'a':
00377             if (rcp[0] == 'u'
00378             &&  rcp[1] == 't'
00379             &&  rcp[2] == 'o'
00380             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00381                 cp = rcp + 3;
00382                 return AUTO;
00383             }
00384             goto id;
00385         case 'b':
00386             if (rcp[0] == 'r'
00387             &&  rcp[1] == 'e'
00388             &&  rcp[2] == 'a'
00389             &&  rcp[3] == 'k'
00390             && !(map[rcp[4]]&(DIGIT|LETTER))) {
00391                 cp = rcp + 4;
00392                 return BREAK;
00393             }
00394             goto id;
00395         case 'c':
00396             if (rcp[0] == 'a'
00397             &&  rcp[1] == 's'
00398             &&  rcp[2] == 'e'
00399             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00400                 cp = rcp + 3;
00401                 return CASE;
00402             }
00403             if (rcp[0] == 'h'
00404             &&  rcp[1] == 'a'
00405             &&  rcp[2] == 'r'
00406             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00407                 cp = rcp + 3;
00408                 tsym = chartype->u.sym;
00409                 return CHAR;
00410             }
00411             if (rcp[0] == 'o'
00412             &&  rcp[1] == 'n'
00413             &&  rcp[2] == 's'
00414             &&  rcp[3] == 't'
00415             && !(map[rcp[4]]&(DIGIT|LETTER))) {
00416                 cp = rcp + 4;
00417                 return CONST;
00418             }
00419             if (rcp[0] == 'o'
00420             &&  rcp[1] == 'n'
00421             &&  rcp[2] == 't'
00422             &&  rcp[3] == 'i'
00423             &&  rcp[4] == 'n'
00424             &&  rcp[5] == 'u'
00425             &&  rcp[6] == 'e'
00426             && !(map[rcp[7]]&(DIGIT|LETTER))) {
00427                 cp = rcp + 7;
00428                 return CONTINUE;
00429             }
00430             goto id;
00431         case 'd':
00432             if (rcp[0] == 'e'
00433             &&  rcp[1] == 'f'
00434             &&  rcp[2] == 'a'
00435             &&  rcp[3] == 'u'
00436             &&  rcp[4] == 'l'
00437             &&  rcp[5] == 't'
00438             && !(map[rcp[6]]&(DIGIT|LETTER))) {
00439                 cp = rcp + 6;
00440                 return DEFAULT;
00441             }
00442             if (rcp[0] == 'o'
00443             &&  rcp[1] == 'u'
00444             &&  rcp[2] == 'b'
00445             &&  rcp[3] == 'l'
00446             &&  rcp[4] == 'e'
00447             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00448                 cp = rcp + 5;
00449                 tsym = doubletype->u.sym;
00450                 return DOUBLE;
00451             }
00452             if (rcp[0] == 'o'
00453             && !(map[rcp[1]]&(DIGIT|LETTER))) {
00454                 cp = rcp + 1;
00455                 return DO;
00456             }
00457             goto id;
00458         case 'e':
00459             if (rcp[0] == 'l'
00460             &&  rcp[1] == 's'
00461             &&  rcp[2] == 'e'
00462             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00463                 cp = rcp + 3;
00464                 return ELSE;
00465             }
00466             if (rcp[0] == 'n'
00467             &&  rcp[1] == 'u'
00468             &&  rcp[2] == 'm'
00469             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00470                 cp = rcp + 3;
00471                 return ENUM;
00472             }
00473             if (rcp[0] == 'x'
00474             &&  rcp[1] == 't'
00475             &&  rcp[2] == 'e'
00476             &&  rcp[3] == 'r'
00477             &&  rcp[4] == 'n'
00478             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00479                 cp = rcp + 5;
00480                 return EXTERN;
00481             }
00482             goto id;
00483         case 'f':
00484             if (rcp[0] == 'l'
00485             &&  rcp[1] == 'o'
00486             &&  rcp[2] == 'a'
00487             &&  rcp[3] == 't'
00488             && !(map[rcp[4]]&(DIGIT|LETTER))) {
00489                 cp = rcp + 4;
00490                 tsym = floattype->u.sym;
00491                 return FLOAT;
00492             }
00493             if (rcp[0] == 'o'
00494             &&  rcp[1] == 'r'
00495             && !(map[rcp[2]]&(DIGIT|LETTER))) {
00496                 cp = rcp + 2;
00497                 return FOR;
00498             }
00499             goto id;
00500         case 'g':
00501             if (rcp[0] == 'o'
00502             &&  rcp[1] == 't'
00503             &&  rcp[2] == 'o'
00504             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00505                 cp = rcp + 3;
00506                 return GOTO;
00507             }
00508             goto id;
00509         case 'l':
00510             if (rcp[0] == 'o'
00511             &&  rcp[1] == 'n'
00512             &&  rcp[2] == 'g'
00513             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00514                 cp = rcp + 3;
00515                 return LONG;
00516             }
00517             goto id;
00518         case 'r':
00519             if (rcp[0] == 'e'
00520             &&  rcp[1] == 'g'
00521             &&  rcp[2] == 'i'
00522             &&  rcp[3] == 's'
00523             &&  rcp[4] == 't'
00524             &&  rcp[5] == 'e'
00525             &&  rcp[6] == 'r'
00526             && !(map[rcp[7]]&(DIGIT|LETTER))) {
00527                 cp = rcp + 7;
00528                 return REGISTER;
00529             }
00530             if (rcp[0] == 'e'
00531             &&  rcp[1] == 't'
00532             &&  rcp[2] == 'u'
00533             &&  rcp[3] == 'r'
00534             &&  rcp[4] == 'n'
00535             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00536                 cp = rcp + 5;
00537                 return RETURN;
00538             }
00539             goto id;
00540         case 's':
00541             if (rcp[0] == 'h'
00542             &&  rcp[1] == 'o'
00543             &&  rcp[2] == 'r'
00544             &&  rcp[3] == 't'
00545             && !(map[rcp[4]]&(DIGIT|LETTER))) {
00546                 cp = rcp + 4;
00547                 return SHORT;
00548             }
00549             if (rcp[0] == 'i'
00550             &&  rcp[1] == 'g'
00551             &&  rcp[2] == 'n'
00552             &&  rcp[3] == 'e'
00553             &&  rcp[4] == 'd'
00554             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00555                 cp = rcp + 5;
00556                 return SIGNED;
00557             }
00558             if (rcp[0] == 'i'
00559             &&  rcp[1] == 'z'
00560             &&  rcp[2] == 'e'
00561             &&  rcp[3] == 'o'
00562             &&  rcp[4] == 'f'
00563             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00564                 cp = rcp + 5;
00565                 return SIZEOF;
00566             }
00567             if (rcp[0] == 't'
00568             &&  rcp[1] == 'a'
00569             &&  rcp[2] == 't'
00570             &&  rcp[3] == 'i'
00571             &&  rcp[4] == 'c'
00572             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00573                 cp = rcp + 5;
00574                 return STATIC;
00575             }
00576             if (rcp[0] == 't'
00577             &&  rcp[1] == 'r'
00578             &&  rcp[2] == 'u'
00579             &&  rcp[3] == 'c'
00580             &&  rcp[4] == 't'
00581             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00582                 cp = rcp + 5;
00583                 return STRUCT;
00584             }
00585             if (rcp[0] == 'w'
00586             &&  rcp[1] == 'i'
00587             &&  rcp[2] == 't'
00588             &&  rcp[3] == 'c'
00589             &&  rcp[4] == 'h'
00590             && !(map[rcp[5]]&(DIGIT|LETTER))) {
00591                 cp = rcp + 5;
00592                 return SWITCH;
00593             }
00594             goto id;
00595         case 't':
00596             if (rcp[0] == 'y'
00597             &&  rcp[1] == 'p'
00598             &&  rcp[2] == 'e'
00599             &&  rcp[3] == 'd'
00600             &&  rcp[4] == 'e'
00601             &&  rcp[5] == 'f'
00602             && !(map[rcp[6]]&(DIGIT|LETTER))) {
00603                 cp = rcp + 6;
00604                 return TYPEDEF;
00605             }
00606             goto id;
00607         case 'u':
00608             if (rcp[0] == 'n'
00609             &&  rcp[1] == 'i'
00610             &&  rcp[2] == 'o'
00611             &&  rcp[3] == 'n'
00612             && !(map[rcp[4]]&(DIGIT|LETTER))) {
00613                 cp = rcp + 4;
00614                 return UNION;
00615             }
00616             if (rcp[0] == 'n'
00617             &&  rcp[1] == 's'
00618             &&  rcp[2] == 'i'
00619             &&  rcp[3] == 'g'
00620             &&  rcp[4] == 'n'
00621             &&  rcp[5] == 'e'
00622             &&  rcp[6] == 'd'
00623             && !(map[rcp[7]]&(DIGIT|LETTER))) {
00624                 cp = rcp + 7;
00625                 return UNSIGNED;
00626             }
00627             goto id;
00628         case 'v':
00629             if (rcp[0] == 'o'
00630             &&  rcp[1] == 'i'
00631             &&  rcp[2] == 'd'
00632             && !(map[rcp[3]]&(DIGIT|LETTER))) {
00633                 cp = rcp + 3;
00634                 tsym = voidtype->u.sym;
00635                 return VOID;
00636             }
00637             if (rcp[0] == 'o'
00638             &&  rcp[1] == 'l'
00639             &&  rcp[2] == 'a'
00640             &&  rcp[3] == 't'
00641             &&  rcp[4] == 'i'
00642             &&  rcp[5] == 'l'
00643             &&  rcp[6] == 'e'
00644             && !(map[rcp[7]]&(DIGIT|LETTER))) {
00645                 cp = rcp + 7;
00646                 return VOLATILE;
00647             }
00648             goto id;
00649         case 'w':
00650             if (rcp[0] == 'h'
00651             &&  rcp[1] == 'i'
00652             &&  rcp[2] == 'l'
00653             &&  rcp[3] == 'e'
00654             && !(map[rcp[4]]&(DIGIT|LETTER))) {
00655                 cp = rcp + 4;
00656                 return WHILE;
00657             }
00658             goto id;
00659         case '_':
00660             if (rcp[0] == '_'
00661             &&  rcp[1] == 't'
00662             &&  rcp[2] == 'y'
00663             &&  rcp[3] == 'p'
00664             &&  rcp[4] == 'e'
00665             &&  rcp[5] == 'c'
00666             &&  rcp[6] == 'o'
00667             &&  rcp[7] == 'd'
00668             &&  rcp[8] == 'e'
00669             && !(map[rcp[9]]&(DIGIT|LETTER))) {
00670                 cp = rcp + 9;
00671                 return TYPECODE;
00672             }
00673             if (rcp[0] == '_'
00674             &&  rcp[1] == 'f'
00675             &&  rcp[2] == 'i'
00676             &&  rcp[3] == 'r'
00677             &&  rcp[4] == 's'
00678             &&  rcp[5] == 't'
00679             &&  rcp[6] == 'a'
00680             &&  rcp[7] == 'r'
00681             &&  rcp[8] == 'g'
00682             && !(map[rcp[9]]&(DIGIT|LETTER))) {
00683                 cp = rcp + 9;
00684                 return FIRSTARG;
00685             }
00686             goto id;
00687         default:
00688             if ((map[cp[-1]]&BLANK) == 0)
00689                 if (cp[-1] < ' ' || cp[-1] >= 0177)
00690                     error("illegal character `\\0%o'\n", cp[-1]);
00691                 else
00692                     error("illegal character `%c'\n", cp[-1]);
00693         }
00694     }
00695 }

Here is the call graph for this function:

int hascall Tree  p  ) 
 

Definition at line 751 of file expr.c.

int hasproto Type   ) 
 

Definition at line 481 of file types.c.

References ARRAY, assert, CONST, ENUM, type::f, FLOAT, FUNCTION, INT, type::op, POINTER, type::proto, STRUCT, Type, type::type, type::u, UNION, UNSIGNED, VOID, and VOLATILE.

Referenced by decl(), parameters(), and typename().

00481                       {
00482     if (ty == 0)
00483         return 1;
00484     switch (ty->op) {
00485     case CONST: case VOLATILE: case CONST+VOLATILE: case POINTER:
00486     case ARRAY:
00487         return hasproto(ty->type);
00488     case FUNCTION:
00489         return hasproto(ty->type) && ty->u.f.proto;
00490     case STRUCT: case UNION:
00491     case VOID:   case FLOAT: case ENUM:  case INT: case UNSIGNED:
00492         return 1;
00493     }
00494     assert(0); return 0;
00495 }

Tree idtree Symbol   ) 
 

Definition at line 682 of file expr.c.

References cnsttree(), p, Symbol, and YYnull.

Referenced by bbcall(), bbentry(), bbexit(), bbincr(), cmp(), cvtconst(), dcllocal(), gencode(), listnodes(), retcode(), swcode(), tracecall(), tracefinis(), tracereturn(), and tracevalue().

00683                                                   {
00684             Symbol t1 = temporary(REGISTER, voidptype);
00685             p = tree(RIGHT, p->type,
00686                 tree(OR, voidtype,
00687                     cond(asgn(t1, cast(p, voidptype))),
00688                     vcall(YYnull, voidtype, (file && *file ? pointer(idtree(mkstr(file)->u.c.loc)) : cnsttree(voidptype, NULL)), cnsttree(inttype, (long)lineno)        , NULL)),
00689                 idtree(t1));
00690         }
00691 
00692         else
00693             p = nullcall(p->type, YYnull, p, cnsttree(inttype, 0L));
00694 
00695     }
00696     return p;
00697 }
00698 Tree nullcall(Type pty, Symbol f, Tree p, Tree e) {
00699     Type ty;
00700 
00701     if (isarray(pty))
00702         return retype(nullcall(atop(pty), f, p, e), pty);
00703     ty = unqual(unqual(p->type)->type);
00704     return vcall(f, pty,
00705         p, e,
00706         cnsttree(inttype, (long)ty->size),
00707         cnsttree(inttype, (long)ty->align),
00708         (file && *file ? pointer(idtree(mkstr(file)->u.c.loc)) : cnsttree(voidptype, NULL)), cnsttree(inttype, (long)lineno)        , NULL);
00709 }
00710 }

Here is the call graph for this function:

Tree incr int  ,
Tree  ,
Tree 
 

Definition at line 344 of file expr.c.

References FCON, p, and tsym.

Referenced by bbincr(), and tracecall().

00344              : p = tree(mkop(CNST,tsym->type), tsym->type, NULL, NULL);
00345            p->u.v = tsym->u.c.v;
00346  break;

void init int  ,
char *  []
 

Definition at line 1 of file inits.c.

References argc, argv, main_init(), prof_init(), trace_init(), and type_init().

Referenced by Draw_ClearWindow(), Eclass_ForName(), main(), SV_RankBegin(), SV_RankUserCreate(), SV_RankUserLogin(), SV_RankUserValidate(), and UI_HeadCountByTeam().

00001                                   {
00002     {extern void input_init(int, char *[]); input_init(argc, argv);}
00003     {extern void main_init(int, char *[]); main_init(argc, argv);}
00004     {extern void prof_init(int, char *[]); prof_init(argc, argv);}
00005     {extern void trace_init(int, char *[]); trace_init(argc, argv);}
00006     {extern void type_init(int, char *[]); type_init(argc, argv);}
00007     {extern void x86linux_init(int, char *[]); x86linux_init(argc, argv);}
00008 }

Here is the call graph for this function:

Type initializer Type  ,
int 
 

Definition at line 196 of file init.c.

References array(), assign(), symbol::c, cast(), chartype, deallocate(), interface::defconst, interface::defstring, e, error(), expr1(), symbol::flist, genconst(), gettok(), i, initarray(), initchar(), initend(), initstruct(), IR, isarray, ischar, isscalar, isstruct, isunion, n, needconst, type::op, value::p, pointer(), symbol::s, s, SCON, type::size, skipto(), interface::space, STMT, type::sym, t, test(), Tree, tsym, Type, tree::type, field::type, type::type, symbol::type, type::u, symbol::u, value::u, unqual, symbol::v, v, Value, and widechar.

Referenced by dclglobal(), initarray(), initglobal(), and initstruct().

00196                                    {
00197     int n = 0;
00198     Tree e;
00199     Type aty = NULL;
00200     static char follow[] = { IF, CHAR, STATIC, 0 };
00201 
00202     ty = unqual(ty);
00203     if (isscalar(ty)) {
00204         needconst++;
00205         if (t == '{') {
00206             t = gettok();
00207             e = expr1(0);
00208             initend(lev, follow);
00209         } else
00210             e = expr1(0);
00211         e = pointer(e);
00212         if ((aty = assign(ty, e)) != NULL)
00213             e = cast(e, aty);
00214         else
00215             error("invalid initialization type; found `%t' expected `%t'\n",
00216                 e->type, ty);
00217         n = genconst(e, 1);
00218         deallocate(STMT);
00219         needconst--;
00220     }
00221     if ((isunion(ty) || isstruct(ty)) && ty->size == 0) {
00222         static char follow[] = { CHAR, STATIC, 0 };
00223         error("cannot initialize undefined `%t'\n", ty);
00224         skipto(';', follow);
00225         return ty;
00226     } else if (isunion(ty)) {
00227         if (t == '{') {
00228             t = gettok();
00229             n = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);
00230             initend(lev, follow);
00231         } else {
00232             if (lev == 0)
00233                 error("missing { in initialization of `%t'\n", ty);
00234             n = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);
00235         }
00236     } else if (isstruct(ty)) {
00237         if (t == '{') {
00238             t = gettok();
00239             n = initstruct(0, ty, lev + 1);
00240             test('}', follow);
00241         } else if (lev > 0)
00242             n = initstruct(ty->size, ty, lev + 1);
00243         else {
00244             error("missing { in initialization of `%t'\n", ty);
00245             n = initstruct(ty->u.sym->u.s.flist->type->size, ty, lev + 1);
00246         }
00247     }
00248     if (isarray(ty))
00249         aty = unqual(ty->type);
00250     if (isarray(ty) && ischar(aty)) {
00251         if (t == SCON) {
00252             if (ty->size > 0 && ty->size == tsym->type->size - 1)
00253                 tsym->type = array(chartype, ty->size, 0);
00254             n = tsym->type->size;
00255             (*IR->defstring)(tsym->type->size, tsym->u.c.v.p);
00256             t = gettok();
00257         } else if (t == '{') {
00258             t = gettok();
00259             if (t == SCON) {
00260                 ty = initializer(ty, lev + 1);
00261                 initend(lev, follow);
00262                 return ty;
00263             }
00264             n = initchar(0, aty);
00265             test('}', follow);
00266         } else if (lev > 0 && ty->size > 0)
00267             n = initchar(ty->size, aty);
00268         else {  /* eg, char c[] = 0; */
00269             error("missing { in initialization of `%t'\n", ty);
00270             n = initchar(1, aty);
00271         }
00272     } else if (isarray(ty)) {
00273         if (t == SCON && aty == widechar) {
00274             int i;
00275             unsigned int *s = tsym->u.c.v.p;
00276             if (ty->size > 0 && ty->size == tsym->type->size - widechar->size)
00277                 tsym->type = array(widechar, ty->size/widechar->size, 0);
00278             n = tsym->type->size;
00279             for (i = 0; i < n; i += widechar->size) {
00280                 Value v;
00281                 v.u = *s++;
00282                 (*IR->defconst)(widechar->op, widechar->size, v);
00283             }
00284             t = gettok();
00285         } else if (t == '{') {
00286             t = gettok();
00287             if (t == SCON && aty == widechar) {
00288                 ty = initializer(ty, lev + 1);
00289                 initend(lev, follow);
00290                 return ty;
00291             }
00292             n = initarray(0, aty, lev + 1);
00293             test('}', follow);
00294         } else if (lev > 0 && ty->size > 0)
00295             n = initarray(ty->size, aty, lev + 1);
00296         else {
00297             error("missing { in initialization of `%t'\n", ty);
00298             n = initarray(aty->size, aty, lev + 1);
00299         }
00300     }   
00301     if (ty->size) {
00302         if (n > ty->size)
00303             error("too many initializers\n");
00304         else if (n < ty->size)
00305             (*IR->space)(ty->size - n);
00306     } else if (isarray(ty) && ty->type->size > 0)
00307         ty = array(ty->type, n/ty->type->size, 0);
00308     else
00309         ty->size = n;
00310     return ty;
00311 }

Here is the call graph for this function:

void input_init int  ,
char *  []
 

Definition at line 61 of file input.c.

References argc, argv, bsize, buffer, cp, file, fillbuf(), limit, lineno, main_init(), MAXLINE, and nextline().

Referenced by init().

00061                                         {
00062     static int inited;
00063 
00064     if (inited)
00065         return;
00066     inited = 1;
00067     main_init(argc, argv);
00068     limit = cp = &buffer[MAXLINE+1];
00069     bsize = -1;
00070     lineno = 0;
00071     file = NULL;
00072     fillbuf();
00073     if (cp >= limit)
00074         cp = limit;
00075     nextline();
00076 }

Here is the call graph for this function:

Symbol install const char *  ,
Table ,
int  ,
int 
 

Definition at line 80 of file sym.c.

References table::all, assert, table::buckets, h(), HASHSIZE, level, table::level, entry::link, name, entry::name, NEW0, p, entry::sym, Symbol, Table, and table().

Referenced by dclglobal(), dcllocal(), dclparam(), decl(), enumdcl(), main_init(), mksymbol(), newfield(), newstruct(), nonterm(), statement(), stmtlabel(), term(), type_init(), uid2type(), and xxinit().

00080                                                                    {
00081     Table tp = *tpp;
00082     struct entry *p;
00083     unsigned h = (unsigned long)name&(HASHSIZE-1);
00084 
00085     assert(level == 0 || level >= tp->level);
00086     if (level > 0 && tp->level < level)
00087         tp = *tpp = table(tp, level);
00088     NEW0(p, arena);
00089     p->sym.name = (char *)name;
00090     p->sym.scope = level;
00091     p->sym.up = tp->all;
00092     tp->all = &p->sym;
00093     p->link = tp->buckets[h];
00094     tp->buckets[h] = p;
00095     return &p->sym;
00096 }

Here is the call graph for this function:

Symbol intconst int   ) 
 

Definition at line 195 of file sym.c.

References constant(), value::i, inttype, Symbol, v, and Value.

Referenced by asgnnode(), docall(), listnodes(), and visit().

00195                        {
00196     Value v;
00197 
00198     v.i = n;
00199     return constant(inttype, v);
00200 }

Here is the call graph for this function:

int intexpr int  ,
int 
 

Definition at line 194 of file simp.c.

References cast(), CNST, constexpr(), error(), I, value::i, inttype, n, needconst, tree::op, p, Tree, tree::u, and tree::v.

Referenced by dclr1(), and enumdcl().

00194                             {
00195     Tree p = constexpr(tok);
00196 
00197     needconst++;
00198     if (p->op == CNST+I || p->op == CNST+U)
00199         n = cast(p, inttype)->u.v.i;
00200     else
00201         error("integer expression must be constant\n");
00202     needconst--;
00203     return n;
00204 }

Here is the call graph for this function:

int iscallb Tree   ) 
 

Definition at line 274 of file enode.c.

References Aflag, inttype, isenum, Type, type::type, unqual, and warning().

Referenced by retcode().

00274                                                               {
00275         Type lty = unqual(xty->type), rty = unqual(yty->type);
00276         if (isenum(lty) && rty == inttype
00277         ||  isenum(rty) && lty == inttype) {
00278             if (Aflag >= 1)
00279                 warning("assignment between `%t' and `%t' is compiler-dependent\n",
00280                     xty, yty);

Here is the call graph for this function:

int ispow2 unsigned long  u  ) 
 

Definition at line 578 of file simp.c.

References n.

Referenced by simplify().

00578                             {
00579     int n;
00580 
00581     if (u > 1 && (u&(u-1)) == 0)
00582         for (n = 0; u; u >>= 1, n++)
00583             if (u&1)
00584                 return n;
00585     return 0;
00586 }

Node jump int   ) 
 

Definition at line 558 of file stmt.c.

References ADDRG, findlabel(), JUMP, newnode(), Node, NULL, p, symbol::ref, Symbol, ttob(), V, and voidptype.

Referenced by branch(), and listnodes().

00558                    {
00559     Symbol p = findlabel(lab);
00560 
00561     p->ref++;
00562     return newnode(JUMP+V, newnode(ADDRG+ttob(voidptype), NULL, NULL, p),
00563         NULL, NULL);
00564 }

Here is the call graph for this function:

int length List  list  ) 
 

Definition at line 24 of file list.c.

References list::link, List, and n.

Referenced by __VectorNormalize(), AAS_LoadAASFile(), AAS_LoadAASLump(), AAS_Reachability_EqualFloorHeight(), AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(), AAS_WriteAASLump(), AddSeperators(), idStr::append(), AppendPathSeperator(), idStr::CapLength(), CG_FindClientHeadFile(), CG_FindClientModelFile(), CG_ParticleBloodCloud(), CG_ParticleDust(), ClipToSeperators(), CM_LoadMap(), CM_TraceThroughSphere(), CM_TraceThroughVerticalCylinder(), Com_BlockChecksum(), Com_BlockChecksumKey(), compound(), CopyLump(), emit_dac(), emit_dht(), idStr::EnsureDataWritable(), FS_ListFilteredFiles(), get_app0(), get_app14(), get_dac(), get_dht(), get_dqt(), get_dri(), get_sof(), get_sos(), HL_CopyLump(), HL_LoadBSPFile(), HL_LoadMapFromBSP(), Hunk_Trash(), inflateSetDictionary(), idVec3_t::Length(), quat_t::Length(), LoadBMP(), LoadFile(), LoadFileBlock(), LoadFileNoCrash(), LoadQuakeFile(), LoadScriptFile(), LoadScriptMemory(), LoadSourceFile(), LoadSourceMemory(), ltov(), MSG_Copy(), NET_SendLoopPacket(), NET_SendPacket(), Netchan_Transmit(), idVec3_t::Normalize(), quat_t::Normalize(), parameters(), ParseChunk(), Q1_CopyLump(), Q1_LoadBSPFile(), Q1_LoadMapFromBSP(), Q2_CopyLump(), Q2_LoadBSPFile(), Q2_LoadBSPFileTexinfo(), Q2_LoadMapFromBSP(), Q3_CopyLump(), QCopyFile(), Rankings_DrawName(), Rankings_DrawPassword(), Reached_Train(), ReadQuakeFile(), Sin_CopyLump(), Sin_LoadBSPFile(), Sin_LoadBSPFileTexinfo(), Sin_LoadMapFromBSP(), skip_variable(), SP_func_pendulum(), StripExtension(), StripFilename(), SubdivideMeshQuads(), Sys_SendPacket(), TryLoadFile(), UI_FindClientHeadFile(), VectorLength(), VectorNormalize(), VectorNormalize2(), VL_PlaneForEdgeToWinding(), VL_SmoothenLightmapEdges(), VM_Create(), VM_Restart(), VS_PlaneForEdgeToWinding(), VS_SmoothenLightmapEdges(), WriteLBMfile(), and WritePCXfile().

00024                       {
00025     int n = 0;
00026 
00027     if (list) {
00028         List lp = list;
00029         do
00030             n++;
00031         while ((lp = lp->link) != list);
00032     }
00033     return n;
00034 }

Node listnodes Tree  e,
int  tlab,
int  flab
 

Definition at line 101 of file dag.c.

References ADD, addlocal(), symbol::addressed, ADDRF, ADDRG, ADDRL, type::align, AND, ARG, ASGN, assert, B, BAND, BCOM, bittree(), BOR, BXOR, CALL, cast(), cfunc, CNST, cnsttree(), symbol::computed, COND, constant(), CVF, CVI, CVP, cvtconst(), CVU, depth, DIV, EQ, equatelab(), errcnt, symbol::f, f, FIELD, Field, tree::field, fieldleft, fieldmask, fieldright, fieldsize, findlabel(), firstarg, forest, FUNC, GE, generic, genlabel(), GT, value::i, I, idtree(), INDIR, intconst(), inttype, IR, isaddrop, isfunc, isint, isptr, isstruct, isvolatile, jump(), JUMP, tree::kids, kill(), l, LABEL, labelnode(), LE, interface::left_to_right, list(), LSH, LT, lvalue(), mask, MOD, MUL, interface::mulops_calls, n, symbol::ncalls, NE, NEG, NEW0, newnode(), Node, tree::node, node(), NOT, NULL, op, tree::op, node::op, opkind, optype, OR, p, P, q, r, symbol::ref, reset(), RET, RIGHT, RSH, rvalue(), shtree(), type::size, sizeop, SUB, tree::sym, type::sym, node::syms, symbol::temporary, Tree, tree(), ttob(), tree::type, Type, type::type, symbol::type, field::type, tree::u, type::u, symbol::u, U, value::u, unlist(), unqual, unsignedtype, tree::v, V, voidptype, interface::wants_callb, and x.

Referenced by cmp(), definept(), statement(), and walk().

00101                                             {
00102     Node p = NULL, l, r;
00103     int op;
00104 
00105     assert(tlab || flab || tlab == 0 && flab == 0);
00106     if (tp == NULL)
00107         return NULL;
00108     if (tp->node)
00109         return tp->node;
00110     op = tp->op + sizeop(tp->type->size);
00111     switch (generic(tp->op)) {
00112     case AND:   { if (depth++ == 0) reset();
00113               if (flab) {
00114                 listnodes(tp->kids[0], 0, flab);
00115                 listnodes(tp->kids[1], 0, flab);
00116               } else {
00117                 listnodes(tp->kids[0], 0, flab = genlabel(1));
00118                 listnodes(tp->kids[1], tlab, 0);
00119                 labelnode(flab);
00120               }
00121               depth--; } break;
00122     case OR:    { if (depth++ == 0)
00123                 reset();
00124               if (tlab) {
00125                 listnodes(tp->kids[0], tlab, 0);
00126                 listnodes(tp->kids[1], tlab, 0);
00127               } else {
00128                 tlab = genlabel(1);
00129                 listnodes(tp->kids[0], tlab, 0);
00130                 listnodes(tp->kids[1], 0, flab);
00131                 labelnode(tlab);
00132               }
00133               depth--;
00134  } break;
00135     case NOT:   { return listnodes(tp->kids[0], flab, tlab); }
00136     case COND:  { Tree q = tp->kids[1];
00137               assert(tlab == 0 && flab == 0);
00138               if (tp->u.sym)
00139                 addlocal(tp->u.sym);
00140               flab = genlabel(2);
00141               listnodes(tp->kids[0], 0, flab);
00142               assert(q && q->op == RIGHT);
00143               reset();
00144               listnodes(q->kids[0], 0, 0);
00145               if (forest->op == LABEL+V) {
00146                 equatelab(forest->syms[0], findlabel(flab + 1));
00147                 unlist();
00148               }
00149               list(jump(flab + 1));
00150               labelnode(flab);
00151               listnodes(q->kids[1], 0, 0);
00152               if (forest->op == LABEL+V) {
00153                 equatelab(forest->syms[0], findlabel(flab + 1));
00154                 unlist();
00155               }
00156               labelnode(flab + 1);
00157 
00158               if (tp->u.sym)
00159                 p = listnodes(idtree(tp->u.sym), 0, 0); } break;
00160     case CNST:  { Type ty = unqual(tp->type);
00161               assert(ty->u.sym);
00162               if (tlab || flab) {
00163                 assert(ty == inttype);
00164                 if (tlab && tp->u.v.i != 0)
00165                     list(jump(tlab));
00166                 else if (flab && tp->u.v.i == 0)
00167                     list(jump(flab));
00168               }
00169               else if (ty->u.sym->addressed)
00170                 p = listnodes(cvtconst(tp), 0, 0);
00171               else
00172                 p = node(op, NULL, NULL, constant(ty, tp->u.v)); } break;
00173     case RIGHT: { if (   tp->kids[0] && tp->kids[1]
00174               &&  generic(tp->kids[1]->op) == ASGN
00175               && (generic(tp->kids[0]->op) == INDIR
00176               && tp->kids[0]->kids[0] == tp->kids[1]->kids[0]
00177               || (tp->kids[0]->op == FIELD
00178               &&  tp->kids[0] == tp->kids[1]->kids[0]))) {
00179                 assert(tlab == 0 && flab == 0);
00180             if (generic(tp->kids[0]->op) == INDIR) {
00181                 p = listnodes(tp->kids[0], 0, 0);
00182                 list(p);
00183                 listnodes(tp->kids[1], 0, 0);
00184             }
00185             else {
00186                 assert(generic(tp->kids[0]->kids[0]->op) == INDIR);
00187                 list(listnodes(tp->kids[0]->kids[0], 0, 0));
00188                 p = listnodes(tp->kids[0], 0, 0);
00189                 listnodes(tp->kids[1], 0, 0);
00190             }
00191               } else if (tp->kids[1]) {
00192                 listnodes(tp->kids[0], 0, 0);
00193                 p = listnodes(tp->kids[1], tlab, flab);
00194               } else
00195                 p = listnodes(tp->kids[0], tlab, flab); } break;
00196     case JUMP:  { assert(tlab == 0 && flab == 0);
00197               assert(tp->u.sym == 0);
00198               assert(tp->kids[0]);
00199               l = listnodes(tp->kids[0], 0, 0);
00200               list(newnode(JUMP+V, l, NULL, NULL));
00201               reset(); } break;
00202     case CALL:  { Tree save = firstarg;
00203               firstarg = NULL;
00204               assert(tlab == 0 && flab == 0);
00205               if (tp->op == CALL+B && !IR->wants_callb) {
00206                 Tree arg0 = tree(ARG+P, tp->kids[1]->type,
00207                 tp->kids[1], NULL);
00208             if (IR->left_to_right)
00209                 firstarg = arg0;
00210             l = listnodes(tp->kids[0], 0, 0);
00211             if (!IR->left_to_right || firstarg) {
00212                 firstarg = NULL;
00213                 listnodes(arg0, 0, 0);
00214             }
00215                 p = newnode(CALL+V, l, NULL, NULL);
00216               } else {
00217                 l = listnodes(tp->kids[0], 0, 0);
00218                 r = listnodes(tp->kids[1], 0, 0);
00219                 p = newnode(tp->op == CALL+B ? tp->op : op, l, r, NULL);
00220               }
00221               NEW0(p->syms[0], FUNC);
00222               assert(isptr(tp->kids[0]->type));
00223               assert(isfunc(tp->kids[0]->type->type));
00224               p->syms[0]->type = tp->kids[0]->type->type;
00225               list(p);
00226               reset();
00227               cfunc->u.f.ncalls++;
00228               firstarg = save;
00229  } break;
00230     case ARG:   { assert(tlab == 0 && flab == 0);
00231               if (IR->left_to_right)
00232                 listnodes(tp->kids[1], 0, 0);
00233               if (firstarg) {
00234                 Tree arg = firstarg;
00235                 firstarg = NULL;
00236                 listnodes(arg, 0, 0);
00237               }
00238               l = listnodes(tp->kids[0], 0, 0);
00239               list(newnode(tp->op == ARG+B ? tp->op : op, l, NULL, NULL));
00240               forest->syms[0] = intconst(tp->type->size);
00241               forest->syms[1] = intconst(tp->type->align);
00242               if (!IR->left_to_right)
00243                 listnodes(tp->kids[1], 0, 0); } break;
00244     case EQ:  case NE: case GT: case GE: case LE:
00245     case LT:    { assert(tp->u.sym == 0);
00246               assert(errcnt || tlab || flab);
00247               l = listnodes(tp->kids[0], 0, 0);
00248               r = listnodes(tp->kids[1], 0, 0);
00249               assert(errcnt || opkind(l->op) == opkind(r->op));
00250               assert(errcnt || optype(op) == optype(l->op));
00251               if (tlab)
00252                 assert(flab == 0),
00253                 list(newnode(generic(tp->op) + opkind(l->op), l, r, findlabel(tlab)));
00254               else if (flab) {
00255                 switch (generic(tp->op)) {
00256                 case EQ: op = NE; break;
00257                 case NE: op = EQ; break;
00258                 case GT: op = LE; break;
00259                 case LT: op = GE; break;
00260                 case GE: op = LT; break;
00261                 case LE: op = GT; break;
00262                 default: assert(0);
00263                 }
00264                 list(newnode(op + opkind(l->op), l, r, findlabel(flab)));
00265               }
00266               if (forest && forest->syms[0])
00267                 forest->syms[0]->ref++; } break;
00268     case ASGN:  { assert(tlab == 0 && flab == 0);
00269               if (tp->kids[0]->op == FIELD) {
00270                 Tree  x = tp->kids[0]->kids[0];
00271             Field f = tp->kids[0]->u.field;
00272             assert(generic(x->op) == INDIR);
00273             reset();
00274             l = listnodes(lvalue(x), 0, 0);
00275             if (fieldsize(f) < 8*f->type->size) {
00276                 unsigned int fmask = fieldmask(f);
00277                 unsigned int  mask = fmask<<fieldright(f);
00278                 Tree q = tp->kids[1];
00279                 if (q->op == CNST+I && q->u.v.i == 0
00280                 ||  q->op == CNST+U && q->u.v.u == 0)
00281                     q = bittree(BAND, x, cnsttree(unsignedtype, (unsigned long)~mask));
00282                 else if (q->op == CNST+I && (q->u.v.i&fmask) == fmask
00283                 ||       q->op == CNST+U && (q->u.v.u&fmask) == fmask)
00284                     q = bittree(BOR, x, cnsttree(unsignedtype, (unsigned long)mask));
00285                 else {
00286                     listnodes(q, 0, 0);
00287                     q = bittree(BOR,
00288                         bittree(BAND, rvalue(lvalue(x)),
00289                             cnsttree(unsignedtype, (unsigned long)~mask)),
00290                         bittree(BAND, shtree(LSH, cast(q, unsignedtype),
00291                             cnsttree(unsignedtype, (unsigned long)fieldright(f))),
00292                             cnsttree(unsignedtype, (unsigned long)mask)));
00293                 }
00294                 r = listnodes(q, 0, 0);
00295                 op = ASGN + ttob(q->type);
00296             } else {
00297                 r = listnodes(tp->kids[1], 0, 0);
00298                 op = ASGN + ttob(tp->kids[1]->type);
00299             }
00300               } else {
00301                 l = listnodes(tp->kids[0], 0, 0);
00302                 r = listnodes(tp->kids[1], 0, 0);
00303               }
00304               list(newnode(tp->op == ASGN+B ? tp->op : op, l, r, NULL));
00305               forest->syms[0] = intconst(tp->kids[1]->type->size);
00306               forest->syms[1] = intconst(tp->kids[1]->type->align);
00307               if (isaddrop(tp->kids[0]->op)
00308               && !tp->kids[0]->u.sym->computed)
00309                 kill(tp->kids[0]->u.sym);
00310               else
00311                 reset();
00312               p = listnodes(tp->kids[1], 0, 0); } break;
00313     case BOR: case BAND: case BXOR:
00314     case ADD: case SUB:  case RSH:
00315     case LSH:   { assert(tlab == 0 && flab == 0);
00316               l = listnodes(tp->kids[0], 0, 0);
00317               r = listnodes(tp->kids[1], 0, 0);
00318               p = node(op, l, r, NULL); } break;
00319     case DIV: case MUL:
00320     case MOD:   { assert(tlab == 0 && flab == 0);
00321               l = listnodes(tp->kids[0], 0, 0);
00322               r = listnodes(tp->kids[1], 0, 0);
00323               p = node(op, l, r, NULL);
00324               if (IR->mulops_calls && isint(tp->type)) {
00325                 list(p);
00326                 cfunc->u.f.ncalls++;
00327               } } break;
00328     case RET:   { assert(tlab == 0 && flab == 0);
00329               l = listnodes(tp->kids[0], 0, 0);
00330               list(newnode(op, l, NULL, NULL)); } break;
00331     case CVF: case CVI: case CVP:
00332     case CVU:   { assert(tlab == 0 && flab == 0);
00333               assert(optype(tp->kids[0]->op) != optype(tp->op) || tp->kids[0]->type->size != tp->type->size);
00334               l = listnodes(tp->kids[0], 0, 0);
00335               p = node(op, l, NULL, intconst(tp->kids[0]->type->size));
00336  } break;
00337     case BCOM:
00338     case NEG:   { assert(tlab == 0 && flab == 0);
00339               l = listnodes(tp->kids[0], 0, 0);
00340               p = node(op, l, NULL, NULL); } break;
00341     case INDIR: { Type ty = tp->kids[0]->type;
00342               assert(tlab == 0 && flab == 0);
00343               l = listnodes(tp->kids[0], 0, 0);
00344               if (isptr(ty))
00345                 ty = unqual(ty)->type;
00346               if (isvolatile(ty)
00347               || (isstruct(ty) && unqual(ty)->u.sym->u.s.vfields))
00348                 p = newnode(tp->op == INDIR+B ? tp->op : op, l, NULL, NULL);
00349               else
00350                 p = node(tp->op == INDIR+B ? tp->op : op, l, NULL, NULL); } break;
00351     case FIELD: { Tree q = tp->kids[0];
00352               if (tp->type == inttype) {
00353                 long n = fieldleft(tp->u.field);
00354                 q = shtree(RSH,
00355                     shtree(LSH, q, cnsttree(inttype, n)),
00356                     cnsttree(inttype, n + fieldright(tp->u.field)));
00357               } else if (fieldsize(tp->u.field) < 8*tp->u.field->type->size)
00358                 q = bittree(BAND,
00359                     shtree(RSH, q, cnsttree(inttype, (long)fieldright(tp->u.field))),
00360                     cnsttree(unsignedtype, (unsigned long)fieldmask(tp->u.field)));
00361               assert(tlab == 0 && flab == 0);
00362               p = listnodes(q, 0, 0); } break;
00363     case ADDRG:
00364     case ADDRF: { assert(tlab == 0 && flab == 0);
00365               p = node(tp->op + sizeop(voidptype->size), NULL, NULL, tp->u.sym);
00366  } break;
00367     case ADDRL: { assert(tlab == 0 && flab == 0);
00368               if (tp->u.sym->temporary)
00369                 addlocal(tp->u.sym);
00370               p = node(tp->op + sizeop(voidptype->size), NULL, NULL, tp->u.sym); } break;
00371     default:assert(0);
00372     }
00373     tp->node = p;
00374     return p;
00375 }

Here is the call graph for this function:

void locus Table  tp,
Coordinate cp
 

Definition at line 239 of file sym.c.

References allsymbols(), append(), Coordinate, cp, loci, symbols, and Table.

Referenced by definept().

00239                                      {
00240     loci    = append(cp, loci);
00241     symbols = append(allsymbols(tp), symbols);
00242 }

Here is the call graph for this function:

Symbol lookup const char *  ,
Table 
 

Definition at line 127 of file sym.c.

00127                                           {
00128     struct entry *p;
00129     unsigned h = (unsigned long)name&(HASHSIZE-1);
00130 
00131     assert(tp);
00132     do
00133         for (p = tp->buckets[h]; p; p = p->link)
00134             if (name == p->sym.name)
00135                 return &p->sym;
00136     while ((tp = tp->previous) != NULL);
00137     return NULL;
00138 }

void* ltov List list,
unsigned  a
 

Definition at line 37 of file list.c.

References array(), freenodes, i, length(), list::link, List, newarray, and list::x.

Referenced by bbvars(), compose(), compound(), enumdcl(), ftype(), main(), parameters(), and printproto().

00037                                        {
00038     int i = 0;
00039     void **array = newarray(length(*list) + 1, sizeof array[0], arena);
00040 
00041     if (*list) {
00042         List lp = *list;
00043         do {
00044             lp = lp->link;
00045             array[i++] = lp->x;
00046         } while (lp != *list);
00047 #ifndef PURIFY
00048         lp = (*list)->link;
00049         (*list)->link = freenodes;
00050         freenodes = lp;
00051 #endif
00052     }
00053     *list = NULL;
00054     array[i] = NULL;
00055     return array;
00056 }

Here is the call graph for this function:

Tree lvalue Tree   ) 
 

Definition at line 722 of file expr.c.

Referenced by listnodes().

int main int  ,
char *  []
 

Definition at line 1223 of file unix_main.c.

References argc, argv, byte, Com_Frame(), Com_Init(), eventQue, i, InitSig(), malloc(), MAX_MSGLEN, MAX_QUED_EVENTS, memset(), NET_Init(), saved_euid, strcat(), strlen(), Sys_ConfigureFPU(), Sys_ConsoleInputInit(), sys_packetReceived, Sys_ParseArgs(), and Sys_SetDefaultCDPath().

01224 {
01225   // int    oldtime, newtime; // bk001204 - unused
01226   int   len, i;
01227   char  *cmdline;
01228   void Sys_SetDefaultCDPath(const char *path);
01229 
01230   // go back to real user for config loads
01231   saved_euid = geteuid();
01232   seteuid(getuid());
01233 
01234   Sys_ParseArgs( argc, argv );  // bk010104 - added this for support
01235 
01236   Sys_SetDefaultCDPath(argv[0]);
01237 
01238   // merge the command line, this is kinda silly
01239   for (len = 1, i = 1; i < argc; i++)
01240     len += strlen(argv[i]) + 1;
01241   cmdline = malloc(len);
01242   *cmdline = 0;
01243   for (i = 1; i < argc; i++)
01244   {
01245     if (i > 1)
01246       strcat(cmdline, " ");
01247     strcat(cmdline, argv[i]);
01248   }
01249 
01250   // bk000306 - clear queues
01251   memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); 
01252   memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );
01253 
01254   Com_Init(cmdline);
01255   NET_Init();
01256 
01257   Sys_ConsoleInputInit();
01258 
01259   fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
01260     
01261 #ifdef DEDICATED
01262     // init here for dedicated, as we don't have GLimp_Init
01263     InitSig();
01264 #endif
01265 
01266   while (1)
01267   {
01268 #ifdef __linux__
01269     Sys_ConfigureFPU();
01270 #endif
01271     Com_Frame ();
01272   }
01273 }

Here is the call graph for this function:

void main_init int  ,
char *  []
 

Definition at line 80 of file main.c.

References argv, assert, errlimit, exit(), EXIT_FAILURE, f, fclose(), fopen(), fprint(), freopen(), glevel, i, NULL, rcsid, stderr, strcmp(), strncmp(), strtol(), verbose, wflag, and x.

Referenced by init(), and input_init().

00080                                        {
00081     char *infile = NULL, *outfile = NULL;
00082     int i;
00083     static int inited;
00084 
00085     if (inited)
00086         return;
00087     inited = 1;
00088     type_init(argc, argv);
00089     for (i = 1; i < argc; i++)
00090         if (strcmp(argv[i], "-g") == 0 || strcmp(argv[i], "-g2") == 0)
00091             glevel = 2;
00092         else if (strncmp(argv[i], "-g", 2) == 0) {  /* -gn[,x] */
00093             char *p = strchr(argv[i], ',');
00094             glevel = atoi(argv[i]+2);
00095             if (p) {
00096                 comment = p + 1;
00097                 if (glevel == 0)
00098                     glevel = 1;
00099                 if (stabIR.stabline == NULL) {
00100                     stabIR.stabline = IR->stabline;
00101                     stabIR.stabend = IR->stabend;
00102                     IR->stabline = stabline;
00103                     IR->stabend = stabend;
00104                 }
00105             }   
00106         } else if (strcmp(argv[i], "-x") == 0)
00107             xref++;
00108         else if (strcmp(argv[i], "-A") == 0) {
00109             ++Aflag;
00110         } else if (strcmp(argv[i], "-P") == 0)
00111             Pflag++;
00112         else if (strcmp(argv[i], "-w") == 0)
00113             wflag++;
00114         else if (strcmp(argv[i], "-n") == 0) {
00115             if (!YYnull) {
00116                 YYnull = install(string("_YYnull"), &globals, GLOBAL, PERM);
00117                 YYnull->type = func(voidptype, NULL, 1);
00118                 YYnull->sclass = EXTERN;
00119                 (*IR->defsymbol)(YYnull);
00120             }
00121         } else if (strncmp(argv[i], "-n", 2) == 0) {    /* -nvalid[,check] */
00122             char *p = strchr(argv[i], ',');
00123             if (p) {
00124                 YYcheck = install(string(p+1), &globals, GLOBAL, PERM);
00125                 YYcheck->type = func(voidptype, NULL, 1);
00126                 YYcheck->sclass = EXTERN;
00127                 (*IR->defsymbol)(YYcheck);
00128                 p = stringn(argv[i]+2, p - (argv[i]+2));
00129             } else
00130                 p = string(argv[i]+2);
00131             YYnull = install(p, &globals, GLOBAL, PERM);
00132             YYnull->type = func(voidptype, NULL, 1);
00133             YYnull->sclass = EXTERN;
00134             (*IR->defsymbol)(YYnull);
00135         } else if (strcmp(argv[i], "-v") == 0)
00136             fprint(stderr, "%s %s\n", argv[0], rcsid);
00137         else if (strncmp(argv[i], "-s", 2) == 0)
00138             density = strtod(&argv[i][2], NULL);
00139         else if (strncmp(argv[i], "-errout=", 8) == 0) {
00140             FILE *f = fopen(argv[i]+8, "w");
00141             if (f == NULL) {
00142                 fprint(stderr, "%s: can't write errors to `%s'\n", argv[0], argv[i]+8);
00143                 exit(EXIT_FAILURE);
00144             }
00145             fclose(f);
00146             f = freopen(argv[i]+8, "w", stderr);
00147             assert(f);
00148         } else if (strncmp(argv[i], "-e", 2) == 0) {
00149             int x;
00150             if ((x = strtol(&argv[i][2], NULL, 0)) > 0)
00151                 errlimit = x;
00152         } else if (strncmp(argv[i], "-little_endian=", 15) == 0)
00153             IR->little_endian = argv[i][15] - '0';
00154         else if (strncmp(argv[i], "-mulops_calls=", 18) == 0)
00155             IR->mulops_calls = argv[i][18] - '0';
00156         else if (strncmp(argv[i], "-wants_callb=", 13) == 0)
00157             IR->wants_callb = argv[i][13] - '0';
00158         else if (strncmp(argv[i], "-wants_argb=", 12) == 0)
00159             IR->wants_argb = argv[i][12] - '0';
00160         else if (strncmp(argv[i], "-left_to_right=", 15) == 0)
00161             IR->left_to_right = argv[i][15] - '0';
00162         else if (strncmp(argv[i], "-wants_dag=", 11) == 0)
00163             IR->wants_dag = argv[i][11] - '0';
00164         else if (*argv[i] != '-' || strcmp(argv[i], "-") == 0) {
00165             if (infile == NULL)
00166                 infile = argv[i];
00167             else if (outfile == NULL)
00168                 outfile = argv[i];
00169         }
00170 
00171     if (infile != NULL && strcmp(infile, "-") != 0
00172     && freopen(infile, "r", stdin) == NULL) {
00173         fprint(stderr, "%s: can't read `%s'\n", argv[0], infile);
00174         exit(EXIT_FAILURE);
00175     }
00176     if (outfile != NULL && strcmp(outfile, "-") != 0
00177     && freopen(outfile, "w", stdout) == NULL) {
00178         fprint(stderr, "%s: can't write `%s'\n", argv[0], outfile);
00179         exit(EXIT_FAILURE);
00180     }
00181 }

Here is the call graph for this function:

Symbol mkstr char *   ) 
 

Definition at line 268 of file sym.c.

References array(), symbol::c, chartype, constant(), genident(), GLOBAL, symbol::loc, value::p, p, strlen(), Symbol, symbol::type, symbol::u, v, and Value.

Referenced by bbcall(), bbfile(), bbfunc(), tracefinis(), and tracevalue().

00268                         {
00269     Value v;
00270     Symbol p;
00271 
00272     v.p = str;
00273     p = constant(array(chartype, strlen(v.p) + 1, 0), v);
00274     if (p->u.c.loc == NULL)
00275         p->u.c.loc = genident(STATIC, p->type, GLOBAL);
00276     return p;
00277 }

Here is the call graph for this function:

Symbol mksymbol int  ,
const char *  ,
Type 
 

Definition at line 280 of file sym.c.

References symbol::defined, interface::defsymbol, GLOBAL, globals, install(), IR, name, symbol::name, NEW0, p, PERM, symbol::sclass, symbol::scope, string(), Symbol, Type, and symbol::type.

Referenced by bbcall(), bbentry(), bbexit(), and trace_init().

00280                                                        {
00281     Symbol p;
00282 
00283     if (sclass == EXTERN)
00284         p = install(string(name), &globals, GLOBAL, PERM);
00285     else {
00286         NEW0(p, PERM);
00287         p->name = string(name);
00288         p->scope = GLOBAL;
00289     }
00290     p->sclass = sclass;
00291     p->type = ty;
00292     (*IR->defsymbol)(p);
00293     p->defined = 1;
00294     return p;
00295 }

Here is the call graph for this function:

void* newarray unsigned long  m,
unsigned long  n,
unsigned  a
 

Definition at line 84 of file alloc.c.

References a, allocate(), m, and n.

00084                                                              {
00085     return allocate(m*n, a);
00086 }

Here is the call graph for this function:

Field newfield char *  ,
Type  ,
Type 
 

Definition at line 292 of file types.c.

References error(), Field, symbol::flist, symbol::ftab, genlabel(), install(), level, field::link, name, field::name, NEW0, NULL, p, PERM, q, symbol::s, symbol::src, stringd(), type::sym, table(), Type, field::type, type::u, and symbol::u.

00292                                               {
00293     Field p, *q = &ty->u.sym->u.s.flist;
00294 
00295     if (name == NULL)
00296         name = stringd(genlabel(1));
00297     for (p = *q; p; q = &p->link, p = *q)
00298         if (p->name == name)
00299             error("duplicate field name `%s' in `%t'\n",
00300                 name, ty);
00301     NEW0(p, PERM);
00302     *q = p;
00303     p->name = name;
00304     p->type = fty;
00305     if (xref) {                         /* omit */
00306         if (ty->u.sym->u.s.ftab == NULL)            /* omit */
00307             ty->u.sym->u.s.ftab = table(NULL, level);   /* omit */
00308         install(name, &ty->u.sym->u.s.ftab, 0, PERM)->src = src;/* omit */
00309     }                               /* omit */
00310     return p;
00311 }

Here is the call graph for this function:

Node newnode int  op,
Node  left,
Node  right,
Symbol  p
 

Definition at line 79 of file dag.c.

References dagnode(), l, Node, dag::node, op, r, and Symbol.

Referenced by asgnnode(), BuildTree_r(), BuildTreeThread(), definelab(), genreload(), genspill(), jump(), labelnode(), listnodes(), replace(), rtarget(), tmpnode(), and visit().

00079                                                  {
00080     return &dagnode(op, l, r, sym)->node;
00081 }

Here is the call graph for this function:

Type newstruct int  ,
char * 
 

Definition at line 271 of file types.c.

References assert, symbol::defined, error(), genlabel(), install(), level, lookup(), maxlevel, symbol::name, NULL, type::op, op, p, PARAM, PERM, symbol::scope, symbol::src, stringd(), Symbol, Type, symbol::type, type(), and types.

Referenced by enumdcl(), structdcl(), and uid2type().

00271                                   {
00272     Symbol p;
00273 
00274     assert(tag);
00275     if (*tag == 0)
00276         tag = stringd(genlabel(1));
00277     else
00278         if ((p = lookup(tag, types)) != NULL && (p->scope == level
00279         || p->scope == PARAM && level == PARAM+1)) {
00280             if (p->type->op == op && !p->defined)
00281                 return p->type;
00282             error("redefinition of `%s' previously defined at %w\n",
00283                 p->name, &p->src);
00284         }
00285     p = install(tag, &types, level, PERM);
00286     p->type = type(op, NULL, 0, 0, p);
00287     if (p->scope > maxlevel)
00288         maxlevel = p->scope;
00289     p->src = src;
00290     return p->type;
00291 }

Here is the call graph for this function:

Symbol newtemp int  ,
int  ,
int 
 

Definition at line 227 of file sym.c.

References btot(), symbol::defined, IR, interface::local, p, Symbol, and temporary().

Referenced by spillr().

00227                                              {
00228     Symbol p = temporary(sclass, btot(tc, size));
00229 
00230     (*IR->local)(p);
00231     p->defined = 1;
00232     return p;
00233 }

Here is the call graph for this function:

void nextline void   ) 
 

Definition at line 16 of file input.c.

References cp, fillbuf(), line, lineno, nextline(), and resynch().

Referenced by getchr(), gettok(), input_init(), nextline(), resynch(), and scon().

00016                     {
00017     do {
00018         if (cp >= limit) {
00019             fillbuf();
00020             if (cp >= limit)
00021                 cp = limit;
00022             if (cp == limit)
00023                 return;
00024         } else {
00025             lineno++;
00026             for (line = (char *)cp; *cp==' ' || *cp=='\t'; cp++)
00027                 ;
00028             if (*cp == '#') {
00029                 resynch();
00030                 nextline();
00031             }
00032         }
00033     } while (*cp == '\n' && cp == limit);
00034 }

Here is the call graph for this function:

int nodeid Tree   ) 
 

Definition at line 172 of file tree.c.

References i, ids, nid, nodeid::node, nodeid::printed, and Tree.

Referenced by printdag(), printdag1(), printnode(), and printtree1().

00172                    {
00173     int i = 1;
00174 
00175     ids[nid].node = p;
00176     while (ids[i].node != p)
00177         i++;
00178     if (i == nid)
00179         ids[nid++].printed = 0;
00180     return i;
00181 }

Tree nullcall Type  ,
Symbol  ,
Tree  ,
Tree 
 

Definition at line 966 of file expr.c.

char* opname int   ) 
 

Definition at line 113 of file tree.c.

References AND, FIELD, generic, NELEMS, op, opindex, opsize, optype, stringd(), stringf(), and suffixes.

Referenced by doop(), dumptree(), Emit4(), getrule(), Inst(), Inst4(), InstImm(), InstImmU(), printnode(), and printtree1().

00113                      {
00114     static char *opnames[] = {
00115     "",
00116     "CNST",
00117     "ARG",
00118     "ASGN",
00119     "INDIR",
00120     "CVC",
00121     "CVD",
00122     "CVF",
00123     "CVI",
00124     "CVP",
00125     "CVS",
00126     "CVU",
00127     "NEG",
00128     "CALL",
00129     "*LOAD*",
00130     "RET",
00131     "ADDRG",
00132     "ADDRF",
00133     "ADDRL",
00134     "ADD",
00135     "SUB",
00136     "LSH",
00137     "MOD",
00138     "RSH",
00139     "BAND",
00140     "BCOM",
00141     "BOR",
00142     "BXOR",
00143     "DIV",
00144     "MUL",
00145     "EQ",
00146     "GE",
00147     "GT",
00148     "LE",
00149     "LT",
00150     "NE",
00151     "JUMP",
00152     "LABEL",
00153     "AND",
00154     "NOT",
00155     "OR",
00156     "COND",
00157     "RIGHT",
00158     "FIELD"
00159     }, *suffixes[] = {
00160         "0", "F", "D", "C", "S", "I", "U", "P", "V", "B",
00161         "10","11","12","13","14","15"
00162     };
00163 
00164     if (generic(op) >= AND && generic(op) <= FIELD && opsize(op) == 0)
00165         return opnames[opindex(op)];
00166     return stringf("%s%s%s",
00167         opindex(op) > 0 && opindex(op) < NELEMS(opnames) ?
00168             opnames[opindex(op)] : stringd(opindex(op)),
00169         suffixes[optype(op)], opsize(op) > 0 ? stringd(opsize(op)) : "");
00170 }

Here is the call graph for this function:

void outtype Type  ,
FILE
 

Definition at line 532 of file types.c.

References ARRAY, assert, CONST, ENUM, f, type::f, findtype(), FLOAT, fprint(), FUNCTION, i, INT, isarray, symbol::name, type::op, p, POINTER, type::proto, type::size, symbol::src, STRUCT, type::sym, Symbol, Type, type::type, type::u, UNION, UNSIGNED, VOID, and VOLATILE.

Referenced by vfprint().

00532                                {
00533     switch (ty->op) {
00534     case CONST+VOLATILE: case CONST: case VOLATILE:
00535         fprint(f, "%k %t", ty->op, ty->type);
00536         break;
00537     case STRUCT: case UNION: case ENUM:
00538         assert(ty->u.sym);
00539         if (ty->size == 0)
00540             fprint(f, "incomplete ");
00541         assert(ty->u.sym->name);
00542         if (*ty->u.sym->name >= '1' && *ty->u.sym->name <= '9') {
00543             Symbol p = findtype(ty);
00544             if (p == 0)
00545                 fprint(f, "%k defined at %w", ty->op, &ty->u.sym->src);
00546             else
00547                 fprint(f, p->name);
00548         } else {
00549             fprint(f, "%k %s", ty->op, ty->u.sym->name);
00550             if (ty->size == 0)
00551                 fprint(f, " defined at %w", &ty->u.sym->src);
00552         }
00553         break;
00554     case VOID: case FLOAT: case INT: case UNSIGNED:
00555         fprint(f, ty->u.sym->name);
00556         break;
00557     case POINTER:
00558         fprint(f, "pointer to %t", ty->type);
00559         break;
00560     case FUNCTION:
00561         fprint(f, "%t function", ty->type);
00562         if (ty->u.f.proto && ty->u.f.proto[0]) {
00563             int i;
00564             fprint(f, "(%t", ty->u.f.proto[0]);
00565             for (i = 1; ty->u.f.proto[i]; i++)
00566                 if (ty->u.f.proto[i] == voidtype)
00567                     fprint(f, ",...");
00568                 else
00569                     fprint(f, ",%t", ty->u.f.proto[i]);
00570             fprint(f, ")");
00571         } else if (ty->u.f.proto && ty->u.f.proto[0] == 0)
00572             fprint(f, "(void)");
00573 
00574         break;
00575     case ARRAY:
00576         if (ty->size > 0 && ty->type && ty->type->size > 0) {
00577             fprint(f, "array %d", ty->size/ty->type->size);
00578             while (ty->type && isarray(ty->type) && ty->type->type->size > 0) {
00579                 ty = ty->type;
00580                 fprint(f, ",%d", ty->size/ty->type->size);
00581             }
00582         } else
00583             fprint(f, "incomplete array");
00584         if (ty->type)
00585             fprint(f, " of %t", ty->type);
00586         break;
00587     default: assert(0);
00588     }
00589 }

Here is the call graph for this function:

Tree pointer Tree   ) 
 

Definition at line 779 of file expr.c.

Referenced by bbentry(), bbexit(), bbincr(), initializer(), retcode(), swcode(), tracefinis(), and tracevalue().

void print const char *  ,
  ...
 

Definition at line 39 of file output.c.

Referenced by emitSymbol(), MSG_ReadDeltaEntity(), and MSG_ReadDeltaPlayerstate().

00039                                  {
00040     va_list ap;
00041 
00042     va_start(ap, fmt);
00043     vfprint(stdout, NULL, fmt, ap);
00044     va_end(ap);
00045 }

void printdag Node  ,
int 
 

Definition at line 678 of file dag.c.

References f, fprint(), node::link, Node, nodeid(), p, printdag1(), printed(), stdout, and Tree.

00678                               {
00679     FILE *f = fd == 1 ? stdout : stderr;
00680 
00681     printed(0);
00682     if (p == 0) {
00683         if ((p = forest) != NULL)
00684             do {
00685                 p = p->link;
00686                 printdag1(p, fd, 0);
00687             } while (p != forest);
00688     } else if (*printed(nodeid((Tree)p)))
00689         fprint(f, "node'%d printed above\n", nodeid((Tree)p));
00690     else
00691         printdag1(p, fd, 0);
00692 }

Here is the call graph for this function:

void printdecl Symbol  p,
Type  ty
 

Definition at line 592 of file types.c.

References assert, ENUM, EXTERN, fprint(), symbol::name, p, symbol::sclass, stderr, Symbol, Type, and typestring().

Referenced by doglobal(), and printproto().

00592                                   {
00593     switch (p->sclass) {
00594     case AUTO:
00595         fprint(stderr, "%s;\n", typestring(ty, p->name));
00596         break;
00597     case STATIC: case EXTERN:
00598         fprint(stderr, "%k %s;\n", p->sclass, typestring(ty, p->name));
00599         break;
00600     case TYPEDEF: case ENUM:
00601         break;
00602     default: assert(0);
00603     }
00604 }

Here is the call graph for this function:

int* printed int   ) 
 

Definition at line 184 of file tree.c.

References ids, nid, and nodeid::printed.

Referenced by opt(), PointToPolygonFormFactor(), printdag(), printdag1(), printtree(), and printtree1().

00184                      {
00185     if (id)
00186         return &ids[id].printed;
00187     nid = 1;
00188     return 0;
00189 }

void printproto Symbol  p,
Symbol  args[]
 

Definition at line 607 of file types.c.

References append(), type::f, freturn(), func(), i, List, ltov(), p, PERM, printdecl(), type::proto, Symbol, symbol::type, type::u, and voidtype.

Referenced by funcdefn().

00607                                            {
00608     if (p->type->u.f.proto)
00609         printdecl(p, p->type);
00610     else {
00611         int i;
00612         List list = 0;
00613         if (callee[0] == 0)
00614             list = append(voidtype, list);
00615         else
00616             for (i = 0; callee[i]; i++)
00617                 list = append(callee[i]->type, list);
00618         printdecl(p, func(freturn(p->type), ltov(&list, PERM), 0));
00619     }
00620 }

Here is the call graph for this function:

void printtree Tree  ,
int 
 

Definition at line 192 of file tree.c.

References p, printed(), printtree1(), and Tree.

00192                                {
00193     (void)printed(0);
00194     printtree1(p, fd, 1);
00195 }

Here is the call graph for this function:

void printtype Type  ,
int 
 

Definition at line 684 of file types.c.

References fprint(), prtype(), stderr, stdout, and Type.

00684                                 {
00685     static unsigned mark;
00686     prtype(ty, fd == 1 ? stdout : stderr, 0, ++mark);
00687     fprint(fd == 1 ? stdout : stderr, "\n");
00688 }

Here is the call graph for this function:

int process char *   ) 
 

Definition at line 258 of file profio.c.

References compare(), file::count, file::counts, fclose(), file, fopen(), fp, gather(), int, file::link, p, and qsort().

Referenced by main(), and prof_init().

00258                         {
00259     int more;
00260 
00261     if ((fp = fopen(file, "r")) != NULL) {
00262         struct file *p;
00263         while ((more = gather()) > 0)
00264             ;
00265         fclose(fp);
00266         if (more < 0)
00267             return more;
00268         for (p = filelist; p; p = p->link)
00269             qsort(p->counts, p->count, sizeof *p->counts,
00270                 (int (*)(const void *, const void *))
00271                 compare);
00272         
00273         return 1;
00274     }
00275     return 0;
00276 }

Here is the call graph for this function:

void program void   ) 
 

Definition at line 32 of file decl.c.

References CHAR, dclglobal(), deallocate(), decl(), error(), FUNC, gettok(), glevel, ID, kind, level, n, STMT, t, and warning().

Referenced by Com_SkipBracedSection(), main(), and SkipBracedSection().

00032                    {
00033     int n;
00034     
00035     level = GLOBAL;
00036     for (n = 0; t != EOI; n++)
00037         if (kind[t] == CHAR || kind[t] == STATIC
00038         || t == ID || t == '*' || t == '(') {
00039             decl(dclglobal);
00040             deallocate(STMT);
00041             if (!(glevel >= 3 || xref))
00042             deallocate(FUNC);
00043         } else if (t == ';') {
00044             warning("empty declaration\n");
00045             t = gettok();
00046         } else {
00047             error("unrecognized declaration\n");
00048             t = gettok();
00049         }
00050     if (n == 0)
00051         warning("empty input file\n");
00052 }

Here is the call graph for this function:

Type promote Type   ) 
 

Definition at line 358 of file types.c.

References doubletype, ENUM, FLOAT, INT, inttype, type::op, type::size, Type, unqual, UNSIGNED, and unsignedtype.

Referenced by condtree(), eqtype(), funcdefn(), retcode(), swstmt(), and tracevalue().

00358                       {
00359     ty = unqual(ty);
00360     switch (ty->op) {
00361     case ENUM:
00362         return inttype;
00363     case INT:
00364         if (ty->size < inttype->size)
00365             return inttype;
00366         break;
00367     case UNSIGNED:
00368         if (ty->size < inttype->size)
00369             return inttype;
00370         if (ty->size < unsignedtype->size)
00371             return unsignedtype;
00372         break;
00373     case FLOAT:
00374         if (ty->size < doubletype->size)
00375             return doubletype;
00376     }
00377     return ty;
00378 }

Type ptr Type   ) 
 

Definition at line 191 of file types.c.

References metrics::align, IR, POINTER, pointersym, interface::ptrmetric, metrics::size, Type, and type().

Referenced by AAS_CalculateAreaTravelTimes(), AAS_CreateReversedReachability(), AAS_InitClusterAreaCache(), access_virt_barray(), access_virt_sarray(), atop(), bbcall(), BotCheckConsoleMessages(), BotExpandChatMessage(), BotImport_FreeMemory(), BotImport_GetMemory(), BotLoadChatMessage(), BotLoadInitialChat(), BotLoadRandomStrings(), BotLoadSynonyms(), BotVoiceChatCommand(), CG_DrawField(), CG_HeadModelVoiceChats(), CG_ParseVoiceChats(), Com_Dealloc(), Com_Filter(), compose(), compound(), Controls_ActionEvent(), dclparam(), dclr(), do_barray_io(), do_sarray_io(), EasyClientName(), expand_right_edge(), FileFilter(), FreeMemory(), funcdefn(), GetClearedHunkMemory(), GetClearedMemory(), GetHunkMemory(), GetMemory(), jzero_far(), LoadScriptMemory(), LoadSourceMemory(), MemorySize(), PC_ConvertPath(), R_Init(), select_file_name(), CMainFrame::ShowMenuItemKeyBindings(), trace_init(), type_init(), UI_StartServerRefresh(), uid2type(), UnifyWhiteSpaces(), VL_FixLightmapEdges(), VL_ShiftPatchLightmaps(), VS_FixLightmapEdges(), VS_ShiftPatchLightmaps(), YYDEFUN(), Z_Free(), Z_LogZoneHeap(), and zcfree().

00191                   {
00192     return type(POINTER, ty, IR->ptrmetric.size,
00193         IR->ptrmetric.align, pointersym);
00194 }

Here is the call graph for this function:

Type qual int  ,
Type 
 

Definition at line 230 of file types.c.

References type::align, ARRAY, CONST, error(), isarray, isconst, isfunc, isqual, isvolatile, NULL, op, type::op, type::size, Type, type(), type::type, and warning().

Referenced by compose(), dcllocal(), dclr(), specifier(), trace_init(), and uid2type().

00230                            {
00231     if (isarray(ty))
00232         ty = type(ARRAY, qual(op, ty->type), ty->size,
00233             ty->align, NULL);
00234     else if (isfunc(ty))
00235         warning("qualified function type ignored\n");
00236     else if (isconst(ty)    && op == CONST
00237     ||       isvolatile(ty) && op == VOLATILE)
00238         error("illegal type `%k %t'\n", op, ty);
00239     else {
00240         if (isqual(ty)) {
00241             op += ty->op;
00242             ty = ty->type;
00243         }
00244         ty = type(op, ty, ty->size, ty->align, NULL);
00245     }
00246     return ty;
00247 }

Here is the call graph for this function:

int reachable int   ) 
 

Definition at line 39 of file stmt.c.

References Code, cp, kind, code::kind, and code::prev.

Referenced by code(), compound(), and definept().

00039                         {
00040     Code cp;
00041 
00042     if (kind > Start) {
00043         Code cp;
00044         for (cp = codelist; cp->kind < Label; )
00045             cp = cp->prev;
00046         if (cp->kind == Jump || cp->kind == Switch)
00047             return 0;
00048     }
00049     return 1;
00050 }

Symbol relocate const char *  name,
Table  src,
Table  dst
 

Definition at line 97 of file sym.c.

References table::all, assert, table::buckets, h(), HASHSIZE, entry::link, name, p, q, r, src, entry::sym, Symbol, Table, and symbol::up.

Referenced by dclglobal().

00097                                                         {
00098     struct entry *p, **q;
00099     Symbol *r;
00100     unsigned h = (unsigned long)name&(HASHSIZE-1);
00101 
00102     for (q = &src->buckets[h]; *q; q = &(*q)->link)
00103         if (name == (*q)->sym.name)
00104             break;
00105     assert(*q);
00106     /*
00107      Remove the entry from src's hash chain
00108       and from its list of all symbols.
00109     */
00110     p = *q;
00111     *q = (*q)->link;
00112     for (r = &src->all; *r && *r != &p->sym; r = &(*r)->up)
00113         ;
00114     assert(*r == &p->sym);
00115     *r = p->sym.up;
00116     /*
00117      Insert the entry into dst's hash chain
00118       and into its list of all symbols.
00119       Return the symbol-table entry.
00120     */
00121     p->link = dst->buckets[h];
00122     dst->buckets[h] = p;
00123     p->sym.up = dst->all;
00124     dst->all = &p->sym;
00125     return &p->sym;
00126 }

Here is the call graph for this function:

void retcode Tree   ) 
 

Definition at line 482 of file stmt.c.

References addlocal(), apply(), ASGN, asgn(), asgntree(), assign(), B, CALL, cast(), cfunc, symbol::computed, error(), events, freturn(), symbol::generated, genident(), idtree(), iscallb(), isfloat, isptr, tree::kids, level, localaddr(), mkop, symbol::name, NULL, p, PARAM, pointer(), promote(), q, RET, Events::returns, retv, RIGHT, rvalue(), symbol::scope, Symbol, Tree, tree(), Type, symbol::type, tree::type, walk(), and warning().

Referenced by funcdefn(), jpeg_consume_input(), jpeg_read_coefficients(), jpeg_read_header(), jpeg_start_decompress(), and statement().

00482                      {
00483     Type ty;
00484 
00485     if (p == NULL) {
00486         if (events.returns)
00487             apply(events.returns, cfunc, NULL);
00488         return;
00489     }
00490     p = pointer(p);
00491     ty = assign(freturn(cfunc->type), p);
00492     if (ty == NULL) {
00493         error("illegal return type; found `%t' expected `%t'\n",
00494             p->type, freturn(cfunc->type));
00495         return;
00496     }
00497     p = cast(p, ty);
00498     if (retv)
00499         {
00500             if (iscallb(p))
00501                 p = tree(RIGHT, p->type,
00502                     tree(CALL+B, p->type,
00503                         p->kids[0]->kids[0], idtree(retv)),
00504                     rvalue(idtree(retv)));
00505             else
00506                 p = asgntree(ASGN, rvalue(idtree(retv)), p);
00507             walk(p, 0, 0);
00508             if (events.returns)
00509                 apply(events.returns, cfunc, rvalue(idtree(retv)));
00510             return;
00511         }
00512     if (events.returns)
00513         {
00514             Symbol t1 = genident(AUTO, p->type, level);
00515             addlocal(t1);
00516             walk(asgn(t1, p), 0, 0);
00517             apply(events.returns, cfunc, idtree(t1));
00518             p = idtree(t1);
00519         }
00520     if (!isfloat(p->type))
00521         p = cast(p, promote(p->type));
00522     if (isptr(p->type))
00523         {
00524             Symbol q = localaddr(p);
00525             if (q && (q->computed || q->generated))
00526                 warning("pointer to a %s is an illegal return value\n",
00527                     q->scope == PARAM ? "parameter" : "local");
00528             else if (q)
00529                 warning("pointer to %s `%s' is an illegal return value\n",
00530                     q->scope == PARAM ? "parameter" : "local", q->name);
00531         }
00532     walk(tree(mkop(RET,p->type), p->type, p, NULL), 0, 0);
00533 }

Here is the call graph for this function:

Tree retype Tree  p,
Type  ty
 

Definition at line 730 of file expr.c.

Referenced by initvalue(), simplify(), swstmt(), and tracevalue().

Tree rightkid Tree  p  ) 
 

Definition at line 740 of file expr.c.

void rmtypes int   ) 
 

Definition at line 171 of file types.c.

References i, entry::link, maxlevel, NELEMS, type::op, symbol::scope, type::sym, entry::type, typetable, and type::u.

Referenced by exitscope().

00171                       {
00172     if (maxlevel >= lev) {
00173         int i;
00174         maxlevel = 0;
00175         for (i = 0; i < NELEMS(typetable); i++) {
00176             struct entry *tn, **tq = &typetable[i];
00177             while ((tn = *tq) != NULL)
00178                 if (tn->type.op == FUNCTION)
00179                     tq = &tn->link;
00180                 else if (tn->type.u.sym && tn->type.u.sym->scope >= lev)
00181                     *tq = tn->link;
00182                 else {
00183                     if (tn->type.u.sym && tn->type.u.sym->scope > maxlevel)
00184                         maxlevel = tn->type.u.sym->scope;
00185                     tq = &tn->link;
00186                 }
00187 
00188         }
00189     }
00190 }

Tree root Tree   ) 
 

Definition at line 108 of file tree.c.

References p, root1(), Tree, and warn.

Referenced by CreateNullCursor(), dcllocal(), emitrecalc(), GLW_SetMode(), main(), and simplify().

00108                   {
00109     warn = 0;
00110     return root1(p);
00111 }

Here is the call graph for this function:

Tree rvalue Tree   ) 
 

Definition at line 716 of file expr.c.

Referenced by bbincr(), listnodes(), retcode(), swcode(), and tracevalue().

Tree shtree int  ,
Tree  ,
Tree 
 

Definition at line 603 of file enode.c.

Referenced by cnsttree(), and listnodes().

Type signedint Type   ) 
 

Definition at line 379 of file types.c.

References assert, inttype, longlong, longtype, type::op, Type, UNSIGNED, and xx.

Referenced by cmp(), and swcode().

00379                         {
00380     if (ty->op == INT)
00381         return ty;
00382     assert(ty->op == UNSIGNED);
00383 #define xx(t) if (ty->size == t->size) return t
00384     xx(inttype);
00385     xx(longtype);
00386     xx(longlong);
00387 #undef xx
00388     assert(0); return NULL;
00389 }

Tree simplify int  ,
Type  ,
Tree  ,
Tree 
 

Definition at line 205 of file simp.c.

References ADD, addd(), addi(), addrtree(), AND, assert, BAND, BCOM, bittree(), BOR, BXOR, cast(), cfoldcnst, CNST, cnsttree(), commute, cond(), CVF, CVI, CVP, CVU, d, value::d, DIV, divd(), divi(), EQ, eqtree(), explicitCast, extend, F, foldaddp, foldcnst, GE, generic, geu, GT, I, i, value::i, idempotent, identity, inttype, isaddrop, ispow2(), tree::kids, l, L, LE, symbol::limits, longtype, LSH, LT, symbol::max, symbol::min, mkop, MOD, MUL, muld(), muli(), n, NE, needconst, NEG, NOT, NULL, ones, op, tree::op, type::op, optype, OR, P, value::p, p, r, retype(), RIGHT, root(), RSH, sfoldcnst, simplify(), type::size, SUB, subd(), subi(), type::sym, Tree, tree(), Type, tree::type, U, tree::u, value::u, type::u, symbol::u, ufoldcnst, tree::v, warning(), xcvtcnst, xfoldcnst, and zerofield.

Referenced by calltree(), condtree(), cvtconst(), foldcond(), and simplify().

00205                                                {
00206     int n;
00207     Tree p;
00208 
00209     if (optype(op) == 0)
00210         op = mkop(op, ty);
00211     switch (op) {
00212         case ADD+U:
00213             foldcnst(U,u,+);
00214             commute(r,l);
00215             identity(r,l,U,u,0);
00216             break;
00217         case ADD+I:
00218             xfoldcnst(I,i,+,addi);
00219             commute(r,l);
00220             identity(r,l,I,i,0);
00221             break;
00222         case CVI+I:
00223             xcvtcnst(I,l->u.v.i,ty,i,(long)extend(l->u.v.i,ty));
00224             break;
00225         case CVU+I:
00226             if (l->op == CNST+U) {
00227                 if (!explicitCast && l->u.v.u > ty->u.sym->u.limits.max.i)
00228                     warning("overflow in converting constant expression from `%t' to `%t'\n", l->type, ty);
00229                 if (needconst || !(l->u.v.u > ty->u.sym->u.limits.max.i))
00230                     return cnsttree(ty, (long)extend(l->u.v.u,ty));
00231             }
00232             break;
00233         case CVP+U:
00234             xcvtcnst(P,(unsigned long)l->u.v.p,ty,u,(unsigned long)l->u.v.p);
00235             break;
00236         case CVU+P:
00237             xcvtcnst(U,(void*)l->u.v.u,ty,p,(void*)l->u.v.u);
00238             break;
00239         case CVP+P:
00240             xcvtcnst(P,l->u.v.p,ty,p,l->u.v.p);
00241             break;
00242         case CVI+U:
00243             xcvtcnst(I,l->u.v.i,ty,u,((unsigned long)l->u.v.i)&ones(8*ty->size));
00244             break;
00245         case CVU+U:
00246             xcvtcnst(U,l->u.v.u,ty,u,l->u.v.u&ones(8*ty->size));
00247             break;
00248 
00249         case CVI+F:
00250             xcvtcnst(I,l->u.v.i,ty,d,(long double)l->u.v.i);
00251         case CVU+F:
00252             xcvtcnst(U,l->u.v.u,ty,d,(long double)l->u.v.u);
00253             break;
00254         case CVF+I:
00255             xcvtcnst(F,l->u.v.d,ty,i,(long)l->u.v.d);
00256             break;
00257         case CVF+F: {
00258             float d;
00259             if (l->op == CNST+F)
00260                 if (l->u.v.d < ty->u.sym->u.limits.min.d)
00261                     d = ty->u.sym->u.limits.min.d;
00262                 else if (l->u.v.d > ty->u.sym->u.limits.max.d)
00263                     d = ty->u.sym->u.limits.max.d;
00264                 else
00265                     d = l->u.v.d;
00266             xcvtcnst(F,l->u.v.d,ty,d,(long double)d);
00267             break;
00268             }
00269         case BAND+U:
00270             foldcnst(U,u,&);
00271             commute(r,l);
00272             identity(r,l,U,u,ones(8*ty->size));
00273             if (r->op == CNST+U && r->u.v.u == 0)
00274                 return tree(RIGHT, ty, root(l), cnsttree(ty, 0UL));
00275             break;
00276         case BAND+I:
00277             foldcnst(I,i,&);
00278             commute(r,l);
00279             identity(r,l,I,i,ones(8*ty->size));
00280             if (r->op == CNST+I && r->u.v.u == 0)
00281                 return tree(RIGHT, ty, root(l), cnsttree(ty, 0L));
00282             break;
00283 
00284         case MUL+U:
00285             commute(l,r);
00286             if (l->op == CNST+U && (n = ispow2(l->u.v.u)) != 0)
00287                 return simplify(LSH, ty, r, cnsttree(inttype, (long)n));
00288             foldcnst(U,u,*);
00289             identity(r,l,U,u,1);
00290             break;
00291         case NE+I:
00292             cfoldcnst(I,i,!=);
00293             commute(r,l);
00294             zerofield(NE,I,i);
00295             break;
00296 
00297         case EQ+I:
00298             cfoldcnst(I,i,==);
00299             commute(r,l);
00300             zerofield(EQ,I,i);
00301             break;
00302         case ADD+P:
00303             foldaddp(l,r,I,i);
00304             foldaddp(l,r,U,u);
00305             foldaddp(r,l,I,i);
00306             foldaddp(r,l,U,u);
00307             commute(r,l);
00308             identity(r,retype(l,ty),I,i,0);
00309             identity(r,retype(l,ty),U,u,0);
00310             if (isaddrop(l->op)
00311             && (r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i
00312                 && r->u.v.i >= longtype->u.sym->u.limits.min.i
00313             || r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i))
00314                 return addrtree(l, cast(r, longtype)->u.v.i, ty);
00315             if (l->op == ADD+P && isaddrop(l->kids[1]->op)
00316             && (r->op == CNST+I && r->u.v.i <= longtype->u.sym->u.limits.max.i
00317                 && r->u.v.i >= longtype->u.sym->u.limits.min.i
00318             ||  r->op == CNST+U && r->u.v.u <= longtype->u.sym->u.limits.max.i))
00319                 return simplify(ADD+P, ty, l->kids[0],
00320                     addrtree(l->kids[1], cast(r, longtype)->u.v.i, ty));
00321             if ((l->op == ADD+I || l->op == SUB+I)
00322             && l->kids[1]->op == CNST+I && isaddrop(r->op))
00323                 return simplify(ADD+P, ty, l->kids[0],
00324                     simplify(generic(l->op)+P, ty, r, l->kids[1]));
00325             if (l->op == ADD+P && generic(l->kids[1]->op) == CNST
00326             && generic(r->op) == CNST)
00327                 return simplify(ADD+P, ty, l->kids[0],
00328                     simplify(ADD, l->kids[1]->type, l->kids[1], r));
00329             if (l->op == ADD+I && generic(l->kids[1]->op) == CNST
00330             &&  r->op == ADD+P && generic(r->kids[1]->op) == CNST)
00331                 return simplify(ADD+P, ty, l->kids[0],
00332                     simplify(ADD+P, ty, r->kids[0],
00333                     simplify(ADD, r->kids[1]->type, l->kids[1], r->kids[1])));
00334             if (l->op == RIGHT && l->kids[1])
00335                 return tree(RIGHT, ty, l->kids[0],
00336                     simplify(ADD+P, ty, l->kids[1], r));
00337             else if (l->op == RIGHT && l->kids[0])
00338                 return tree(RIGHT, ty,
00339                     simplify(ADD+P, ty, l->kids[0], r), NULL);
00340             break;
00341 
00342         case ADD+F:
00343             xfoldcnst(F,d,+,addd);
00344             commute(r,l);
00345             break;
00346         case AND+I:
00347             op = AND;
00348             ufoldcnst(I,l->u.v.i ? cond(r) : l);    /* 0&&r => 0, 1&&r => r */
00349             break;
00350         case OR+I:
00351             op = OR;
00352             /* 0||r => r, 1||r => 1 */
00353             ufoldcnst(I,l->u.v.i ? cnsttree(ty, 1L) : cond(r));
00354             break;
00355         case BCOM+I:
00356             ufoldcnst(I,cnsttree(ty, (long)extend((~l->u.v.i)&ones(8*ty->size), ty)));
00357             idempotent(BCOM+U);
00358             break;
00359         case BCOM+U:
00360             ufoldcnst(U,cnsttree(ty, (unsigned long)((~l->u.v.u)&ones(8*ty->size))));
00361             idempotent(BCOM+U);
00362             break;
00363         case BOR+U:
00364             foldcnst(U,u,|);
00365             commute(r,l);
00366             identity(r,l,U,u,0);
00367             break;
00368         case BOR+I:
00369             foldcnst(I,i,|);
00370             commute(r,l);
00371             identity(r,l,I,i,0);
00372             break;
00373         case BXOR+U:
00374             foldcnst(U,u,^);
00375             commute(r,l);
00376             identity(r,l,U,u,0);
00377             break;
00378         case BXOR+I:
00379             foldcnst(I,i,^);
00380             commute(r,l);
00381             identity(r,l,I,i,0);
00382             break;
00383         case DIV+F:
00384             xfoldcnst(F,d,/,divd);
00385             break;
00386         case DIV+I:
00387             identity(r,l,I,i,1);
00388             if (r->op == CNST+I && r->u.v.i == 0
00389             ||  l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i
00390             &&  r->op == CNST+I && r->u.v.i == -1)
00391                 break;
00392             xfoldcnst(I,i,/,divi);
00393             break;
00394         case DIV+U:     
00395             identity(r,l,U,u,1);
00396             if (r->op == CNST+U && r->u.v.u == 0)
00397                 break;
00398             if (r->op == CNST+U && (n = ispow2(r->u.v.u)) != 0)
00399                 return simplify(RSH, ty, l, cnsttree(inttype, (long)n));
00400             foldcnst(U,u,/);
00401             break;
00402         case EQ+F:
00403             cfoldcnst(F,d,==);
00404             commute(r,l);
00405             break;
00406         case EQ+U:
00407             cfoldcnst(U,u,==);
00408             commute(r,l);
00409             zerofield(EQ,U,u);
00410             break;
00411         case GE+F: cfoldcnst(F,d,>=); break;
00412         case GE+I: cfoldcnst(I,i,>=); break;
00413         case GE+U:
00414             geu(l,r,1); /* l >= 0 => (l,1) */
00415             cfoldcnst(U,u,>=);
00416             if (l->op == CNST+U && l->u.v.u == 0)   /* 0 >= r => r == 0 */
00417                 return eqtree(EQ, r, l);
00418             break;
00419         case GT+F: cfoldcnst(F,d, >); break;
00420         case GT+I: cfoldcnst(I,i, >); break;
00421         case GT+U:
00422             geu(r,l,0); /* 0 > r => (r,0) */
00423             cfoldcnst(U,u, >);
00424             if (r->op == CNST+U && r->u.v.u == 0)   /* l > 0 => l != 0 */
00425                 return eqtree(NE, l, r);
00426             break;
00427         case LE+F: cfoldcnst(F,d,<=); break;
00428         case LE+I: cfoldcnst(I,i,<=); break;
00429         case LE+U:
00430             geu(r,l,1); /* 0 <= r => (r,1) */
00431             cfoldcnst(U,u,<=);
00432             if (r->op == CNST+U && r->u.v.u == 0)   /* l <= 0 => l == 0 */
00433                 return eqtree(EQ, l, r);
00434             break;
00435         case LSH+I:
00436             identity(r,l,I,i,0);
00437             if (l->op == CNST+I && r->op == CNST+I
00438             && r->u.v.i >= 0 && r->u.v.i < 8*l->type->size
00439             && muli(l->u.v.i, 1<<r->u.v.i, ty->u.sym->u.limits.min.i, ty->u.sym->u.limits.max.i, needconst))
00440                 return cnsttree(ty, (long)(l->u.v.i<<r->u.v.i));
00441             if (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {
00442                 warning("shifting an `%t' by %d bits is undefined\n", ty, r->u.v.i);
00443                 break;
00444             }
00445 
00446             break;
00447         case LSH+U:
00448             identity(r,l,I,i,0);
00449             sfoldcnst(<<);
00450             if (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {
00451                 warning("shifting an `%t' by %d bits is undefined\n", ty, r->u.v.i);
00452                 break;
00453             }
00454 
00455             break;
00456 
00457         case LT+F: cfoldcnst(F,d, <); break;
00458         case LT+I: cfoldcnst(I,i, <); break;
00459         case LT+U:
00460             geu(l,r,0); /* l < 0 => (l,0) */
00461             cfoldcnst(U,u, <);
00462             if (l->op == CNST+U && l->u.v.u == 0)   /* 0 < r => r != 0 */
00463                 return eqtree(NE, r, l);
00464             break;
00465         case MOD+I:
00466             if (r->op == CNST+I && r->u.v.i == 1)   /* l%1 => (l,0) */
00467                 return tree(RIGHT, ty, root(l), cnsttree(ty, 0L));
00468             if (r->op == CNST+I && r->u.v.i == 0
00469             ||  l->op == CNST+I && l->u.v.i == ty->u.sym->u.limits.min.i
00470             &&  r->op == CNST+I && r->u.v.i == -1)
00471                 break;
00472             xfoldcnst(I,i,%,divi);
00473             break;
00474         case MOD+U:     
00475             if (r->op == CNST+U && ispow2(r->u.v.u)) /* l%2^n => l&(2^n-1) */
00476                 return bittree(BAND, l, cnsttree(ty, r->u.v.u - 1));
00477             if (r->op == CNST+U && r->u.v.u == 0)
00478                 break;
00479             foldcnst(U,u,%);
00480             break;
00481         case MUL+F:
00482             xfoldcnst(F,d,*,muld);
00483             commute(l,r);
00484             break;
00485         case MUL+I:
00486             commute(l,r);
00487             xfoldcnst(I,i,*,muli);
00488             if (l->op == CNST+I && r->op == ADD+I && r->kids[1]->op == CNST+I)
00489                 /* c1*(x + c2) => c1*x + c1*c2 */
00490                 return simplify(ADD, ty, simplify(MUL, ty, l, r->kids[0]),
00491                     simplify(MUL, ty, l, r->kids[1]));
00492             if (l->op == CNST+I && r->op == SUB+I && r->kids[1]->op == CNST+I)
00493                 /* c1*(x - c2) => c1*x - c1*c2 */
00494                 return simplify(SUB, ty, simplify(MUL, ty, l, r->kids[0]),
00495                     simplify(MUL, ty, l, r->kids[1]));
00496             if (l->op == CNST+I && l->u.v.i > 0 && (n = ispow2(l->u.v.i)) != 0)
00497                 /* 2^n * r => r<<n */
00498                 return simplify(LSH, ty, r, cnsttree(inttype, (long)n));
00499             identity(r,l,I,i,1);
00500             break;
00501         case NE+F:
00502             cfoldcnst(F,d,!=);
00503             commute(r,l);
00504             break;
00505         case NE+U:
00506             cfoldcnst(U,u,!=);
00507             commute(r,l);
00508             zerofield(NE,U,u);
00509             break;
00510         case NEG+F:
00511             ufoldcnst(F,cnsttree(ty, -l->u.v.d));
00512             idempotent(NEG+F);
00513             break;
00514         case NEG+I:
00515             if (l->op == CNST+I) {
00516                 if (needconst && l->u.v.i == ty->u.sym->u.limits.min.i)
00517                     warning("overflow in constant expression\n");
00518                 if (needconst || l->u.v.i != ty->u.sym->u.limits.min.i)
00519                     return cnsttree(ty, -l->u.v.i);
00520             }
00521             idempotent(NEG+I);
00522             break;
00523         case NOT+I:
00524             op = NOT;
00525             ufoldcnst(I,cnsttree(ty, !l->u.v.i));
00526             break;
00527         case RSH+I:
00528             identity(r,l,I,i,0);
00529             if (l->op == CNST+I && r->op == CNST+I
00530             && r->u.v.i >= 0 && r->u.v.i < 8*l->type->size) {
00531                 long n = l->u.v.i>>r->u.v.i;
00532                 if (l->u.v.i < 0)
00533                     n |= ~0UL<<(8*l->type->size - r->u.v.i);
00534                 return cnsttree(ty, n);
00535             }
00536             if (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {
00537                 warning("shifting an `%t' by %d bits is undefined\n", ty, r->u.v.i);
00538                 break;
00539             }
00540 
00541             break;
00542         case RSH+U:
00543             identity(r,l,I,i,0);
00544             sfoldcnst(>>);
00545             if (r->op == CNST+I && (r->u.v.i >= 8*ty->size || r->u.v.i < 0)) {
00546                 warning("shifting an `%t' by %d bits is undefined\n", ty, r->u.v.i);
00547                 break;
00548             }
00549 
00550             break;
00551         case SUB+F:
00552             xfoldcnst(F,d,-,subd);
00553             break;
00554         case SUB+I:
00555             xfoldcnst(I,i,-,subi);
00556             identity(r,l,I,i,0);
00557             break;
00558         case SUB+U:
00559             foldcnst(U,u,-);
00560             identity(r,l,U,u,0);
00561             break;
00562         case SUB+P:
00563             if (l->op == CNST+P && r->op == CNST+P)
00564                 return cnsttree(ty, (long)((char *)l->u.v.p - (char *)r->u.v.p));
00565             if (r->op == CNST+I || r->op == CNST+U)
00566                 return simplify(ADD, ty, l,
00567                     cnsttree(inttype, r->op == CNST+I ? -r->u.v.i : -(long)r->u.v.u));
00568             if (isaddrop(l->op) && r->op == ADD+I && r->kids[1]->op == CNST+I)
00569                 /* l - (x + c) => l-c - x */
00570                 return simplify(SUB, ty,
00571                     simplify(SUB, ty, l, r->kids[1]), r->kids[0]);
00572             break;
00573         default:assert(0);
00574     }
00575     return tree(op, ty, l, r);
00576 }

Here is the call graph for this function:

void skipto int  tok,
char  set[]
 

Definition at line 183 of file error.c.

Referenced by initializer(), parameters(), and statement().

void statement int  ,
Swtch  ,
int 
 

Definition at line 78 of file stmt.c.

References Aflag, branch(), caselabel, cast(), cfunc, CNST, compound(), constexpr(), deallocate(), definelab(), definept(), swtch::deflab, DO, dostmt(), e, error(), expect(), expr(), expr0(), extend, symbol::f, findlabel(), forstmt(), freturn(), FUNC, generic, genlabel(), getchr(), gettok(), value::i, ID, ifstmt(), install(), isint, kind, symbol::l, swtch::lab, symbol::label, listnodes(), lookup(), needconst, nodecount, NULL, tree::op, type::op, p, ref, refinc, retcode(), symbol::scope, skipto(), symbol::src, src, STMT, stmtlabel(), stmtlabs, swstmt(), Swtch, swtch::sym, Symbol, t, test(), Tree, tree::type, symbol::type, Type, tree::u, value::u, symbol::u, use(), tree::v, walk(), warning(), and whilestmt().

Referenced by compound(), dostmt(), forstmt(), ifstmt(), swstmt(), and whilestmt().

00078                                              {
00079     float ref = refinc;
00080 
00081     if (Aflag >= 2 && lev == 15)
00082         warning("more than 15 levels of nested statements\n");
00083     switch (t) {
00084     case IF:       ifstmt(genlabel(2), loop, swp, lev + 1);
00085  break;
00086     case WHILE:    whilestmt(genlabel(3), swp, lev + 1); break;
00087     case DO:       dostmt(genlabel(3), swp, lev + 1); expect(';');
00088                     break;
00089 
00090     case FOR:      forstmt(genlabel(4), swp, lev + 1);
00091  break;
00092     case BREAK:    walk(NULL, 0, 0);
00093                definept(NULL);
00094                if (swp && swp->lab > loop)
00095                 branch(swp->lab + 1);
00096                else if (loop)
00097                 branch(loop + 2);
00098                else
00099                 error("illegal break statement\n");
00100                t = gettok(); expect(';');
00101                        break;
00102 
00103     case CONTINUE: walk(NULL, 0, 0);
00104                definept(NULL);
00105                if (loop)
00106                 branch(loop + 1);
00107                else
00108                 error("illegal continue statement\n");
00109                t = gettok(); expect(';');
00110                           break;
00111 
00112     case SWITCH:   swstmt(loop, genlabel(2), lev + 1);
00113  break;
00114     case CASE:     {
00115                 int lab = genlabel(1);
00116                 if (swp == NULL)
00117                     error("illegal case label\n");
00118                 definelab(lab);
00119                 while (t == CASE) {
00120                     static char stop[] = { IF, ID, 0 };
00121                     Tree p;
00122                     t = gettok();
00123                     p = constexpr(0);
00124                     if (generic(p->op) == CNST && isint(p->type)) {
00125                         if (swp) {
00126                             needconst++;
00127                             p = cast(p, swp->sym->type);
00128                             if (p->type->op == UNSIGNED)
00129                                 p->u.v.i = extend(p->u.v.u, p->type);
00130                             needconst--;
00131                             caselabel(swp, p->u.v.i, lab);
00132                         }
00133                     } else
00134                         error("case label must be a constant integer expression\n");
00135 
00136                     test(':', stop);
00137                 }
00138                 statement(loop, swp, lev);
00139                } break;
00140     case DEFAULT:  if (swp == NULL)
00141                 error("illegal default label\n");
00142                else if (swp->deflab)
00143                 error("extra default label\n");
00144                else {
00145                 swp->deflab = findlabel(swp->lab);
00146                 definelab(swp->deflab->u.l.label);
00147                }
00148                t = gettok();
00149                expect(':');
00150                statement(loop, swp, lev); break;
00151     case RETURN:   {
00152                 Type rty = freturn(cfunc->type);
00153                 t = gettok();
00154                 definept(NULL);
00155                 if (t != ';')
00156                     if (rty == voidtype) {
00157                         error("extraneous return value\n");
00158                         expr(0);
00159                         retcode(NULL);
00160                     } else
00161                         retcode(expr(