LEFT | RIGHT |
(no file at all) | |
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 "a.h" | 5 #include "a.h" |
6 | 6 |
7 /* | 7 /* |
8 * Translate a .goc file into a .c file. A .goc file is a combination | 8 * Translate a .goc file into a .c file. A .goc file is a combination |
9 * of a limited form of Go with C. | 9 * of a limited form of Go with C. |
10 */ | 10 */ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 {"byte", 1}, | 104 {"byte", 1}, |
105 {"int8", 1}, | 105 {"int8", 1}, |
106 {"uint8", 1}, | 106 {"uint8", 1}, |
107 {"int16", 2}, | 107 {"int16", 2}, |
108 {"uint16", 2}, | 108 {"uint16", 2}, |
109 {"int32", 4}, | 109 {"int32", 4}, |
110 {"uint32", 4}, | 110 {"uint32", 4}, |
111 {"int64", 8}, | 111 {"int64", 8}, |
112 {"uint64", 8}, | 112 {"uint64", 8}, |
113 | 113 |
114 » {nil}, | 114 » {nil, 0}, |
115 }; | 115 }; |
116 | 116 |
117 /* Fixed structure alignment (non-gcc only) */ | 117 /* Fixed structure alignment (non-gcc only) */ |
118 int structround = 4; | 118 int structround = 4; |
119 | 119 |
120 /* Unexpected EOF. */ | 120 /* Unexpected EOF. */ |
121 static void | 121 static void |
122 bad_eof(void) | 122 bad_eof(void) |
123 { | 123 { |
124 fatal("%s:%ud: unexpected EOF\n", file, lineno); | 124 fatal("%s:%ud: unexpected EOF\n", file, lineno); |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 write_params(params, &first); | 563 write_params(params, &first); |
564 bwritef(output, ")\n{\n"); | 564 bwritef(output, ")\n{\n"); |
565 for (p = rets; p != nil; p = p->next) | 565 for (p = rets; p != nil; p = p->next) |
566 bwritef(output, " %s %s;\n", p->type, p->name); | 566 bwritef(output, " %s %s;\n", p->type, p->name); |
567 } | 567 } |
568 | 568 |
569 /* Write out a gcc function trailer. */ | 569 /* Write out a gcc function trailer. */ |
570 static void | 570 static void |
571 write_gcc_func_trailer(char *package, char *name, struct params *rets) | 571 write_gcc_func_trailer(char *package, char *name, struct params *rets) |
572 { | 572 { |
573 » if (rets == nil) | 573 » if (rets == nil) { |
574 » » ; | 574 » » // nothing to do |
| 575 » } |
575 else if (rets->next == nil) | 576 else if (rets->next == nil) |
576 bwritef(output, "return %s;\n", rets->name); | 577 bwritef(output, "return %s;\n", rets->name); |
577 else { | 578 else { |
578 struct params *p; | 579 struct params *p; |
579 | 580 |
580 bwritef(output, " {\n struct %s_%s_ret __ret;\n", package, n
ame); | 581 bwritef(output, " {\n struct %s_%s_ret __ret;\n", package, n
ame); |
581 for (p = rets; p != nil; p = p->next) | 582 for (p = rets; p != nil; p = p->next) |
582 bwritef(output, " __ret.%s = %s;\n", p->name, p->name
); | 583 bwritef(output, " __ret.%s = %s;\n", p->name, p->name
); |
583 bwritef(output, " return __ret;\n }\n"); | 584 bwritef(output, " return __ret;\n }\n"); |
584 } | 585 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 } | 727 } |
727 | 728 |
728 bprintf(&out, "// auto generated by go tool dist\n// goos=%s goarch=%s\n
\n", goos, goarch); | 729 bprintf(&out, "// auto generated by go tool dist\n// goos=%s goarch=%s\n
\n", goos, goarch); |
729 input = bstr(&in); | 730 input = bstr(&in); |
730 output = &out; | 731 output = &out; |
731 | 732 |
732 process_file(); | 733 process_file(); |
733 ········ | 734 ········ |
734 writefile(&out, c, 0); | 735 writefile(&out, c, 0); |
735 } | 736 } |
LEFT | RIGHT |