~ubuntu-branches/ubuntu/saucy/golang/saucy

« back to all changes in this revision

Viewing changes to src/cmd/cc/lex.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-07-08 05:52:37 UTC
  • mfrom: (29.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130708055237-at01839e0hp8z3ni
Tags: 2:1.1-1ubuntu1
016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
 */
87
87
 
88
88
void
 
89
usage(void)
 
90
{
 
91
        print("usage: %cc [options] file.c...\n", thechar);
 
92
        flagprint(1);
 
93
        errorexit();
 
94
}
 
95
 
 
96
void
 
97
dospim(void)
 
98
{
 
99
        thechar = '0';
 
100
        thestring = "spim";
 
101
}
 
102
 
 
103
char **defs;
 
104
int ndef;
 
105
 
 
106
void
 
107
dodef(char *p)
 
108
{
 
109
        if(ndef%8 == 0)
 
110
                defs = allocn(defs, ndef*sizeof(char *),
 
111
                        8*sizeof(char *));
 
112
        defs[ndef++] = p;
 
113
        dodefine(p);
 
114
}
 
115
 
 
116
void
89
117
main(int argc, char *argv[])
90
118
{
91
 
        char **defs, *p;
92
 
        int c, ndef;
 
119
        int c;
93
120
 
94
121
        ensuresymb(NSYMB);
95
122
        memset(debug, 0, sizeof(debug));
97
124
        cinit();
98
125
        ginit();
99
126
        arginit();
 
127
        
 
128
        fmtstrinit(&pragcgobuf);
 
129
        quotefmtinstall();
100
130
 
101
131
        tufield = simplet((1L<<tfield->etype) | BUNSIGNED);
102
132
        ndef = 0;
103
133
        defs = nil;
104
134
        outfile = 0;
105
135
        setinclude(".");
106
 
        ARGBEGIN {
107
 
        default:
108
 
                c = ARGC();
109
 
                if(c >= 0 && c < sizeof(debug))
110
 
                        debug[c]++;
111
 
                break;
112
 
 
113
 
        case 'l':                       /* for little-endian mips */
114
 
                if(thechar != 'v'){
115
 
                        print("can only use -l with vc\n");
116
 
                        errorexit();
117
 
                }
118
 
                thechar = '0';
119
 
                thestring = "spim";
120
 
                break;
121
 
 
122
 
        case 'o':
123
 
                outfile = ARGF();
124
 
                break;
125
 
 
126
 
        case 'D':
127
 
                p = ARGF();
128
 
                if(p) {
129
 
                        if(ndef%8 == 0)
130
 
                                defs = allocn(defs, ndef*sizeof(char *),
131
 
                                        8*sizeof(char *));
132
 
                        defs[ndef++] = p;
133
 
                        dodefine(p);
134
 
                }
135
 
                break;
136
 
 
137
 
        case 'I':
138
 
                p = ARGF();
139
 
                setinclude(p);
140
 
                break;
141
 
        } ARGEND
142
 
        if(argc < 1 && outfile == 0) {
143
 
                print("usage: %cc [-options] files\n", thechar);
144
 
                errorexit();
145
 
        }
 
136
 
 
137
        flagcount("+", "pass -+ to preprocessor", &debug['+']); 
 
138
        flagcount(".", "pass -. to preprocessor", &debug['.']); 
 
139
        flagcount("<", "debug shift", &debug['<']);
 
140
        flagcount("A", "debug alignment", &debug['A']);
 
141
        flagcount("B", "allow pre-ANSI code", &debug['B']);
 
142
        if(thechar == '5')
 
143
                flagcount("C", "debug constant propagation", &debug['C']);
 
144
        flagfn1("D", "name[=value]: add #define", dodef);
 
145
        flagcount("F", "enable print format checks", &debug['F']);
 
146
        if(thechar == '5')
 
147
                flagcount("H", "debug shift propagation", &debug['H']);
 
148
        flagfn1("I", "dir: add dir to include path", setinclude);
 
149
        flagcount("L", "debug lexer", &debug['L']);
 
150
        flagcount("M", "debug move generation", &debug['M']);
 
151
        flagcount("N", "disable optimizations", &debug['N']);
 
152
        flagcount("P", "debug peephole optimizer", &debug['P']);
 
153
        flagcount("Q", "print exported Go definitions", &debug['Q']);
 
154
        flagcount("R", "debug register optimizer", &debug['R']);
 
155
        flagcount("S", "print assembly", &debug['S']);
 
156
        flagcount("T", "enable type signatures", &debug['T']);
 
157
        flagcount("V", "enable pointer type checks", &debug['V']);
 
158
        flagcount("W", "debug switch generation", &debug['W']);
 
159
        flagcount("X", "abort on error", &debug['X']);
 
160
        flagcount("Y", "debug index generation", &debug['Y']);
 
161
        flagcount("Z", "skip code generation", &debug['Z']);
 
162
        flagcount("a", "print acid definitions", &debug['a']);
 
163
        flagcount("c", "debug constant evaluation", &debug['c']);
 
164
        flagcount("d", "debug declarations", &debug['d']);
 
165
        flagcount("e", "debug macro expansion", &debug['e']);
 
166
        flagcount("f", "debug pragmas", &debug['f']);
 
167
        flagcount("g", "debug code generation", &debug['g']);
 
168
        flagcount("i", "debug initialization", &debug['i']);
 
169
        if(thechar == 'v')
 
170
                flagfn0("l", "little-endian mips mode", dospim);
 
171
        flagcount("m", "debug multiplication", &debug['m']);
 
172
        flagcount("n", "print acid/Go to file, not stdout", &debug['n']);
 
173
        flagstr("o", "file: set output file", &outfile);
 
174
        flagcount("p", "invoke C preprocessor", &debug['p']);   
 
175
        flagcount("q", "print Go definitions", &debug['q']);
 
176
        flagcount("s", "print #define assembly offsets", &debug['s']);
 
177
        flagcount("t", "debug code generation", &debug['t']);
 
178
        flagcount("w", "enable warnings", &debug['w']);
 
179
        flagcount("v", "increase debug verbosity", &debug['v']);        
 
180
        if(thechar == '6')
 
181
                flagcount("largemodel", "generate code that assumes a large memory model", &flag_largemodel);
 
182
        
 
183
        flagparse(&argc, &argv, usage);
 
184
 
 
185
        if(argc < 1 && outfile == 0)
 
186
                usage();
 
187
 
146
188
        if(argc > 1){
147
189
                print("can't compile multiple files\n");
148
190
                errorexit();
377
419
                symb[1] = '"';
378
420
        }
379
421
 
380
 
        // turn · into .
381
422
        for(r=w=symb; *r; r++) {
 
423
                // turn · (U+00B7) into .
 
424
                // turn ∕ (U+2215) into /
382
425
                if((uchar)*r == 0xc2 && (uchar)*(r+1) == 0xb7) {
383
426
                        *w++ = '.';
384
427
                        r++;
 
428
                }else if((uchar)*r == 0xe2 && (uchar)*(r+1) == 0x88 && (uchar)*(r+2) == 0x95) {
 
429
                        *w++ = '/';
 
430
                        r++;
 
431
                        r++;
385
432
                }else
386
433
                        *w++ = *r;
387
434
        }
1174
1221
        "inline",       LINLINE,        0,
1175
1222
        "int",          LINT,           TINT,
1176
1223
        "long",         LLONG,          TLONG,
 
1224
        "PREFETCH",     LPREFETCH,      0,
1177
1225
        "register",     LREGISTER,      0,
1178
1226
        "restrict",     LRESTRICT,      0,
1179
1227
        "return",       LRETURN,        0,