LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include <u.h> | 5 #include <u.h> |
6 #include <libc.h> | 6 #include <libc.h> |
7 #include "go.h" | 7 #include "go.h" |
8 #include "y.tab.h" | 8 #include "y.tab.h" |
9 #include <ar.h> | 9 #include <ar.h> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 static void lexinit1(void); | 22 static void lexinit1(void); |
23 static void lexfini(void); | 23 static void lexfini(void); |
24 static void yytinit(void); | 24 static void yytinit(void); |
25 static int getc(void); | 25 static int getc(void); |
26 static void ungetc(int); | 26 static void ungetc(int); |
27 static int32 getr(void); | 27 static int32 getr(void); |
28 static int escchar(int, int*, vlong*); | 28 static int escchar(int, int*, vlong*); |
29 static void addidir(char*); | 29 static void addidir(char*); |
30 static int getlinepragma(void); | 30 static int getlinepragma(void); |
31 static char *goos, *goarch, *goroot; | 31 static char *goos, *goarch, *goroot; |
32 char* the386; | |
33 | 32 |
34 #define BOM 0xFEFF | 33 #define BOM 0xFEFF |
35 | 34 |
36 // Compiler experiments. | 35 // Compiler experiments. |
37 // These are controlled by the GOEXPERIMENT environment | 36 // These are controlled by the GOEXPERIMENT environment |
38 // variable recorded when the compiler is built. | 37 // variable recorded when the compiler is built. |
39 static struct { | 38 static struct { |
40 char *name; | 39 char *name; |
41 int *val; | 40 int *val; |
42 } exper[] = { | 41 } exper[] = { |
43 // {"rune32", &rune32}, | 42 // {"rune32", &rune32}, |
44 {"fieldtrack", &fieldtrack_enabled}, | 43 {"fieldtrack", &fieldtrack_enabled}, |
45 {"zerostack", &zerostack_enabled}, | |
46 {nil, nil}, | 44 {nil, nil}, |
47 }; | 45 }; |
48 | 46 |
49 static void | 47 static void |
50 addexp(char *s) | 48 addexp(char *s) |
51 { | 49 { |
52 int i; | 50 int i; |
53 ········ | 51 ········ |
54 for(i=0; exper[i].name != nil; i++) { | 52 for(i=0; exper[i].name != nil; i++) { |
55 if(strcmp(exper[i].name, s) == 0) { | 53 if(strcmp(exper[i].name, s) == 0) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 trackpkg = mkpkg(strlit("go.track")); | 232 trackpkg = mkpkg(strlit("go.track")); |
235 trackpkg->name = "go.track"; | 233 trackpkg->name = "go.track"; |
236 trackpkg->prefix = "go.track"; // not go%2etrack | 234 trackpkg->prefix = "go.track"; // not go%2etrack |
237 | 235 |
238 typepkg = mkpkg(strlit("type")); | 236 typepkg = mkpkg(strlit("type")); |
239 typepkg->name = "type"; | 237 typepkg->name = "type"; |
240 | 238 |
241 goroot = getgoroot(); | 239 goroot = getgoroot(); |
242 goos = getgoos(); | 240 goos = getgoos(); |
243 goarch = thestring; | 241 goarch = thestring; |
244 the386 = getgo386(); | 242 » use_sse = strcmp(getgo386(), "sse") == 0; |
245 ········ | 243 ········ |
246 setexp(); | 244 setexp(); |
247 | 245 |
248 outfile = nil; | 246 outfile = nil; |
249 ARGBEGIN { | 247 ARGBEGIN { |
250 default: | 248 default: |
251 c = ARGC(); | 249 c = ARGC(); |
252 if(c >= 0 && c < sizeof(debug)) | 250 if(c >= 0 && c < sizeof(debug)) |
253 debug[c]++; | 251 debug[c]++; |
254 break; | 252 break; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // enable inlining. for now: | 287 // enable inlining. for now: |
290 // default: inlining on. (debug['l'] == 1) | 288 // default: inlining on. (debug['l'] == 1) |
291 // -l: inlining off (debug['l'] == 0) | 289 // -l: inlining off (debug['l'] == 0) |
292 // -ll, -lll: inlining on again, with extra debugging (debug['l'] >
1) | 290 // -ll, -lll: inlining on again, with extra debugging (debug['l'] >
1) |
293 if(debug['l'] <= 1) | 291 if(debug['l'] <= 1) |
294 debug['l'] = 1 - debug['l']; | 292 debug['l'] = 1 - debug['l']; |
295 | 293 |
296 if(argc < 1) | 294 if(argc < 1) |
297 usage(); | 295 usage(); |
298 | 296 |
299 » // special flag to detect compilation of package runtime | 297 » // special flags used during build. |
300 » compiling_runtime = debug['+']; | 298 » compiling_runtime = debug['+']; // detect compilation of package runtime |
| 299 » pure_go = debug['=']; // package is completely go (no C or assembly) |
301 | 300 |
302 pathname = mal(1000); | 301 pathname = mal(1000); |
303 if(getwd(pathname, 999) == 0) | 302 if(getwd(pathname, 999) == 0) |
304 strcpy(pathname, "/???"); | 303 strcpy(pathname, "/???"); |
305 | 304 |
306 if(yy_isalpha(pathname[0]) && pathname[1] == ':') { | 305 if(yy_isalpha(pathname[0]) && pathname[1] == ':') { |
307 // On Windows. | 306 // On Windows. |
308 windows = 1; | 307 windows = 1; |
309 | 308 |
310 // Canonicalize path by converting \ to / (Windows accepts both)
. | 309 // Canonicalize path by converting \ to / (Windows accepts both)
. |
(...skipping 1980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2291 p = infile; | 2290 p = infile; |
2292 else | 2291 else |
2293 p = p+1; | 2292 p = p+1; |
2294 snprint(namebuf, sizeof(namebuf), "%s", p); | 2293 snprint(namebuf, sizeof(namebuf), "%s", p); |
2295 p = strrchr(namebuf, '.'); | 2294 p = strrchr(namebuf, '.'); |
2296 if(p != nil) | 2295 if(p != nil) |
2297 *p = 0; | 2296 *p = 0; |
2298 outfile = smprint("%s.%c", namebuf, thechar); | 2297 outfile = smprint("%s.%c", namebuf, thechar); |
2299 } | 2298 } |
2300 } | 2299 } |
LEFT | RIGHT |