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

output.c File Reference

#include "c.h"
#include "token.h"

Include dependency graph for output.c:

Include dependency graph

Go to the source code of this file.

Defines

#define xx(a, b, c, d, e, f, g)   g,
#define yy(a, b, c, d, e, f, g)   g,

Functions

void fprint (FILE *f, const char *fmt,...)
char * outd (long n, FILE *f, char *bp)
char * outs (const char *str, FILE *f, char *bp)
char * outu (unsigned long n, int base, FILE *f, char *bp)
void print (const char *fmt,...)
char * stringf (const char *fmt,...)
void vfprint (FILE *f, char *bp, const char *fmt, va_list ap)


Define Documentation

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

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


Function Documentation

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:

char* outd long  n,
FILE f,
char *  bp
[static]
 

Definition at line 13 of file output.c.

References f, m, n, outs(), and s.

Referenced by vfprint().

00013                                              {
00014     unsigned long m;
00015     char buf[25], *s = buf + sizeof buf;
00016 
00017     *--s = '\0';
00018     if (n < 0)
00019         m = -n;
00020     else
00021         m = n;
00022     do
00023         *--s = m%10 + '0';
00024     while ((m /= 10) != 0);
00025     if (n < 0)
00026         *--s = '-';
00027     return outs(s, f, bp);
00028 }

Here is the call graph for this function:

char* outs const char *  str,
FILE f,
char *  bp
[static]
 

Definition at line 4 of file output.c.

References f, and fputs().

Referenced by outd(), outu(), and vfprint().

00004                                                       {
00005     if (f)
00006         fputs(str, f);
00007     else
00008         while (*bp = *str++)
00009             bp++;
00010     return bp;
00011 }

Here is the call graph for this function:

char* outu unsigned long  n,
int  base,
FILE f,
char *  bp
[static]
 

Definition at line 30 of file output.c.

References f, n, outs(), and s.

Referenced by vfprint().

00030                                                                 {
00031     char buf[25], *s = buf + sizeof buf;
00032 
00033     *--s = '\0';
00034     do
00035         *--s = "0123456789abcdef"[n%base];
00036     while ((n /= base) != 0);
00037     return outs(s, f, bp);
00038 }

Here is the call graph for this function:

void print const char *  fmt,
  ...
 

Definition at line 39 of file output.c.

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

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

Here is the call graph for this function:

char* stringf const char *  fmt,
  ...
 

Definition at line 56 of file output.c.

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

Referenced by callsys(), dclparam(), initinputs(), mkreg(), opname(), rule(), tempname(), typestring(), and vtoa().

00056                                     {
00057     char buf[1024];
00058     va_list ap;
00059 
00060     va_start(ap, fmt);
00061     vfprint(NULL, buf, fmt, ap);
00062     va_end(ap);
00063     return string(buf);
00064 }

Here is the call graph for this function:

void vfprint FILE f,
char *  bp,
const char *  fmt,
va_list  ap
 

Definition at line 67 of file output.c.

References assert, Coordinate, f, coord::file, format, fputc(), n, outd(), outs(), outtype(), outu(), p, putc, s, sprintf(), t, Type, va_arg, va_list, voidtype, and coord::y.

Referenced by fprint(), print(), and stringf().

00067                                                              {
00068     for (; *fmt; fmt++)
00069         if (*fmt == '%')
00070             switch (*++fmt) {
00071             case 'd': bp = outd(va_arg(ap, int), f, bp); break;
00072             case 'D': bp = outd(va_arg(ap, long), f, bp); break;
00073             case 'U': bp = outu(va_arg(ap, unsigned long), 10, f, bp); break;
00074             case 'u': bp = outu(va_arg(ap, unsigned), 10, f, bp); break;
00075             case 'o': bp = outu(va_arg(ap, unsigned), 8, f, bp); break;
00076             case 'X': bp = outu(va_arg(ap, unsigned long), 16, f, bp); break;
00077             case 'x': bp = outu(va_arg(ap, unsigned), 16, f, bp); break;
00078             case 'f': case 'e':
00079             case 'g': {
00080                     static char format[] = "%f";
00081                     char buf[128];
00082                     format[1] = *fmt;
00083                     sprintf(buf, format, va_arg(ap, double));
00084                     bp = outs(buf, f, bp);
00085                   }
00086 ; break;
00087             case 's': bp = outs(va_arg(ap, char *), f, bp); break;
00088             case 'p': {
00089                 void *p = va_arg(ap, void *);
00090                 if (p)
00091                     bp = outs("0x", f, bp);
00092                 bp = outu((unsigned long)p, 16, f, bp);
00093                 break;
00094                   }
00095             case 'c': if (f) fputc(va_arg(ap, int), f); else *bp++ = va_arg(ap, int); break;
00096             case 'S': { char *s = va_arg(ap, char *);
00097                     int n = va_arg(ap, int);
00098                     if (s)
00099                         for ( ; n-- > 0; s++)
00100                             if (f) (void)putc(*s, f); else *bp++ = *s;
00101  } break;
00102             case 'k': { int t = va_arg(ap, int);
00103                     static char *tokens[] = {
00104 #define xx(a,b,c,d,e,f,g) g,
00105 #define yy(a,b,c,d,e,f,g) g,
00106 #include "token.h"
00107                     };
00108                     assert(tokens[t&0177]);
00109                     bp = outs(tokens[t&0177], f, bp);
00110  } break;
00111             case 't': { Type ty = va_arg(ap, Type);
00112                     assert(f);
00113                     outtype(ty ? ty : voidtype, f);
00114  } break;
00115             case 'w': { Coordinate *p = va_arg(ap, Coordinate *);
00116                     if (p->file && *p->file) {
00117                         bp = outs(p->file, f, bp);
00118                         bp = outs(":", f, bp);
00119                     }
00120                     bp = outd(p->y, f, bp);
00121  } break;
00122             case 'I': { int n = va_arg(ap, int);
00123                     while (--n >= 0)
00124                         if (f) (void)putc(' ', f); else *bp++ = ' ';
00125  } break;
00126             default:  if (f) (void)putc(*fmt, f); else *bp++ = *fmt; break;
00127             }
00128         else if (f)
00129             (void)putc(*fmt, f);
00130         else
00131             *bp++ = *fmt;
00132     if (!f)
00133         *bp = '\0';
00134 }

Here is the call graph for this function:


Generated on Thu Aug 25 15:55:01 2005 for Quake III Arena by  doxygen 1.3.9.1