#include "c.h"
Include dependency graph for main.c:

Go to the source code of this file.
Functions | |
| int | main (int argc, char *argv[]) |
| void | main_init (int argc, char *argv[]) |
| void | stabend (Coordinate *, Symbol, Coordinate **, Symbol *, Symbol *) |
| void | stabline (Coordinate *) |
| void | typestab (Symbol, void *) |
Variables | |
| int | Aflag |
| char * | comment |
| char * | currentfile |
| int | currentline |
| int | glevel |
| Interface * | IR = NULL |
| int | Pflag |
| char | rcsid [] = "main.c - faked rcsid" |
| FILE * | srcfp |
| int | srcpos |
| Interface | stabIR |
| int | xref |
| Symbol | YYcheck |
| Symbol | YYnull |
|
||||||||||||
|
Definition at line 24 of file main.c. References apply(), argc, argv, bindings, Coordinate, deallocate(), Events::end, errcnt, events, exit(), EXIT_FAILURE, coord::file, finalize(), foreach(), fprint(), gettok(), glevel, GLOBAL, i, identifiers, init(), IR, binding::ir, j, loci, ltov(), memset(), name, binding::name, NULL, PERM, interface::progbeg, interface::progend, program(), s, src, interface::stabend, interface::stabinit, stderr, strchr(), strcmp(), strncmp(), Symbol, symbols, t, types, typestab(), coord::x, and coord::y. 00024 {
00025 int i, j;
00026 for (i = argc - 1; i > 0; i--)
00027 if (strncmp(argv[i], "-target=", 8) == 0)
00028 break;
00029 if (i > 0) {
00030 char *s = strchr(argv[i], '\\');
00031 if (s != NULL)
00032 *s = '/';
00033 for (j = 0; bindings[j].name && bindings[j].ir; j++)
00034 if (strcmp(&argv[i][8], bindings[j].name) == 0) {
00035 IR = bindings[j].ir;
00036 break;
00037 }
00038 if (s != NULL)
00039 *s = '\\';
00040 }
00041 if (!IR) {
00042 fprint(stderr, "%s: unknown target", argv[0]);
00043 if (i > 0)
00044 fprint(stderr, " `%s'", &argv[i][8]);
00045 fprint(stderr, "; must specify one of\n");
00046 for (i = 0; bindings[i].name; i++)
00047 fprint(stderr, "\t-target=%s\n", bindings[i].name);
00048 exit(EXIT_FAILURE);
00049 }
00050 init(argc, argv);
00051 t = gettok();
00052 (*IR->progbeg)(argc, argv);
00053 if (glevel && IR->stabinit)
00054 (*IR->stabinit)(firstfile, argc, argv);
00055 program();
00056 if (events.end)
00057 apply(events.end, NULL, NULL);
00058 memset(&events, 0, sizeof events);
00059 if (glevel || xref) {
00060 Symbol symroot = NULL;
00061 Coordinate src;
00062 foreach(types, GLOBAL, typestab, &symroot);
00063 foreach(identifiers, GLOBAL, typestab, &symroot);
00064 src.file = firstfile;
00065 src.x = 0;
00066 src.y = lineno;
00067 if ((glevel > 2 || xref) && IR->stabend)
00068 (*IR->stabend)(&src, symroot,
00069 ltov(&loci, PERM),
00070 ltov(&symbols, PERM), NULL);
00071 else if (IR->stabend)
00072 (*IR->stabend)(&src, NULL, NULL, NULL, NULL);
00073 }
00074 finalize();
00075 (*IR->progend)();
00076 deallocate(PERM);
00077 return errcnt > 0;
00078 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 80 of file main.c. References argc, argv, assert, atoi, comment, interface::defsymbol, density, errlimit, exit(), EXIT_FAILURE, f, fclose(), fopen(), fprint(), freopen(), func(), glevel, GLOBAL, globals, i, install(), IR, interface::left_to_right, interface::little_endian, interface::mulops_calls, NULL, p, PERM, Pflag, rcsid, symbol::sclass, interface::stabend, stabIR, interface::stabline, stderr, stdin, stdout, strchr(), strcmp(), string(), stringn(), strncmp(), strtod(), strtol(), symbol::type, type_init(), voidptype, interface::wants_argb, interface::wants_callb, interface::wants_dag, wflag, x, xref, YYcheck, and YYnull. 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:

|
||||||||||||||||||||||||
|
Definition at line 220 of file main.c. References Coordinate, fclose(), srcfp, interface::stabend, stabIR, and Symbol. 00220 {
00221 if (stabIR.stabend)
00222 (*stabIR.stabend)(cp, p, cpp, sp, stab);
00223 if (srcfp)
00224 fclose(srcfp);
00225 }
|
Here is the call graph for this function:

|
|
Definition at line 191 of file main.c. References comment, Coordinate, cp, currentfile, currentline, fclose(), fgets(), coord::file, fopen(), print(), rewind(), srcfp, srcpos, stabIR, interface::stabline, and coord::y. 00191 {
00192 if (cp->file && cp->file != currentfile) {
00193 if (srcfp)
00194 fclose(srcfp);
00195 currentfile = cp->file;
00196 srcfp = fopen(currentfile, "r");
00197 srcpos = 0;
00198 currentline = 0;
00199 }
00200 if (currentline != cp->y && srcfp) {
00201 char buf[512];
00202 if (srcpos > cp->y) {
00203 rewind(srcfp);
00204 srcpos = 0;
00205 }
00206 for ( ; srcpos < cp->y; srcpos++)
00207 if (fgets(buf, sizeof buf, srcfp) == NULL) {
00208 fclose(srcfp);
00209 srcfp = NULL;
00210 break;
00211 }
00212 if (srcfp && srcpos == cp->y)
00213 print("%s%s", comment, buf);
00214 }
00215 currentline = cp->y;
00216 if (stabIR.stabline)
00217 (*stabIR.stabline)(cp);
00218 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 183 of file main.c. References cl, IR, p, symbol::sclass, interface::stabtype, and Symbol. Referenced by main(). 00183 {
00184 if (*(Symbol *)cl == 0 && p->sclass && p->sclass != TYPEDEF)
00185 *(Symbol *)cl = p;
00186 if ((p->sclass == TYPEDEF || p->sclass == 0) && IR->stabtype)
00187 (*IR->stabtype)(p);
00188 }
|
|
|
|
|
|
Definition at line 18 of file main.c. Referenced by main_init(), and stabline(). |
|
|
Definition at line 20 of file main.c. Referenced by stabline(). |
|
|
Definition at line 21 of file main.c. Referenced by stabline(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 22 of file main.c. Referenced by stabend(), and stabline(). |
|
|
Definition at line 23 of file main.c. Referenced by stabline(). |
|
|
Definition at line 19 of file main.c. Referenced by main_init(), stabend(), and stabline(). |
|
|
|
|
|
|
|
|
|
1.3.9.1