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> |
| 6 #include <libc.h> |
5 #include "go.h" | 7 #include "go.h" |
6 #include "y.tab.h" | 8 #include "y.tab.h" |
7 #include <ar.h> | 9 #include <ar.h> |
8 | 10 |
9 #undef getc | 11 #undef getc |
10 #undef ungetc | 12 #undef ungetc |
11 #define getc ccgetc | 13 #define getc ccgetc |
12 #define ungetc ccungetc | 14 #define ungetc ccungetc |
13 | 15 |
14 extern int yychar; | 16 extern int yychar; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 EOF = -1, | 71 EOF = -1, |
70 }; | 72 }; |
71 | 73 |
72 void | 74 void |
73 usage(void) | 75 usage(void) |
74 { | 76 { |
75 print("gc: usage: %cg [flags] file.go...\n", thechar); | 77 print("gc: usage: %cg [flags] file.go...\n", thechar); |
76 print("flags:\n"); | 78 print("flags:\n"); |
77 // -A is allow use of "any" type, for bootstrapping | 79 // -A is allow use of "any" type, for bootstrapping |
78 print(" -I DIR search for packages in DIR\n"); | 80 print(" -I DIR search for packages in DIR\n"); |
| 81 print(" -L show full path in file:line prints\n"); |
| 82 print(" -N disable optimizer\n"); |
| 83 print(" -S print the assembly language\n"); |
| 84 print(" -V print the compiler version\n"); |
79 print(" -d print declarations\n"); | 85 print(" -d print declarations\n"); |
80 print(" -e no limit on number of errors printed\n"); | 86 print(" -e no limit on number of errors printed\n"); |
81 print(" -f print stack frame structure\n"); | 87 print(" -f print stack frame structure\n"); |
82 print(" -h panic on an error\n"); | 88 print(" -h panic on an error\n"); |
| 89 print(" -m print about moves to heap\n"); |
83 print(" -o file specify output file\n"); | 90 print(" -o file specify output file\n"); |
84 » print(" -S print the assembly language\n"); | 91 » print(" -s disable escape analysis\n"); |
85 » print(" -V print the compiler version\n"); | |
86 print(" -u disable package unsafe\n"); | 92 print(" -u disable package unsafe\n"); |
87 print(" -w print the parse tree after typing\n"); | 93 print(" -w print the parse tree after typing\n"); |
88 print(" -x print lex tokens\n"); | 94 print(" -x print lex tokens\n"); |
89 exit(0); | 95 exit(0); |
90 } | 96 } |
91 | 97 |
92 void | 98 void |
93 fault(int s) | 99 fault(int s) |
94 { | 100 { |
| 101 USED(s); |
| 102 |
95 // If we've already complained about things | 103 // If we've already complained about things |
96 // in the program, don't bother complaining | 104 // in the program, don't bother complaining |
97 // about the seg fault too; let the user clean up | 105 // about the seg fault too; let the user clean up |
98 // the code and try again. | 106 // the code and try again. |
99 if(nsavederrors + nerrors > 0) | 107 if(nsavederrors + nerrors > 0) |
100 errorexit(); | 108 errorexit(); |
101 fatal("fault"); | 109 fatal("fault"); |
102 } | 110 } |
103 | 111 |
104 int | 112 int |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 446 |
439 void | 447 void |
440 importfile(Val *f, int line) | 448 importfile(Val *f, int line) |
441 { | 449 { |
442 Biobuf *imp; | 450 Biobuf *imp; |
443 char *file, *p, *q; | 451 char *file, *p, *q; |
444 int32 c; | 452 int32 c; |
445 int len; | 453 int len; |
446 Strlit *path; | 454 Strlit *path; |
447 char *cleanbuf; | 455 char *cleanbuf; |
| 456 |
| 457 USED(line); |
448 | 458 |
449 // TODO(rsc): don't bother reloading imports more than once? | 459 // TODO(rsc): don't bother reloading imports more than once? |
450 | 460 |
451 if(f->ctype != CTSTR) { | 461 if(f->ctype != CTSTR) { |
452 yyerror("import statement not a string"); | 462 yyerror("import statement not a string"); |
453 return; | 463 return; |
454 } | 464 } |
455 | 465 |
456 if(strlen(f->u.sval->s) != f->u.sval->len) { | 466 if(strlen(f->u.sval->s) != f->u.sval->len) { |
457 yyerror("import path contains NUL"); | 467 yyerror("import path contains NUL"); |
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 p = infile; | 1962 p = infile; |
1953 else | 1963 else |
1954 p = p+1; | 1964 p = p+1; |
1955 snprint(namebuf, sizeof(namebuf), "%s", p); | 1965 snprint(namebuf, sizeof(namebuf), "%s", p); |
1956 p = strrchr(namebuf, '.'); | 1966 p = strrchr(namebuf, '.'); |
1957 if(p != nil) | 1967 if(p != nil) |
1958 *p = 0; | 1968 *p = 0; |
1959 outfile = smprint("%s.%c", namebuf, thechar); | 1969 outfile = smprint("%s.%c", namebuf, thechar); |
1960 } | 1970 } |
1961 } | 1971 } |
LEFT | RIGHT |