1
0
mirror of https://github.com/golang/go synced 2024-11-22 04:54:42 -07:00

export sys.exit

update tests to use exit rather than return
ignore return value from main (actually done in prior CL)

SVN=125173
This commit is contained in:
Rob Pike 2008-06-27 14:15:06 -07:00
parent 3719aa4d9a
commit 34cb7c299e
16 changed files with 107 additions and 105 deletions

View File

@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#!/bin/bash
6g sys.go
echo '1,/((/d
/))/+1,$d

View File

@ -42,6 +42,8 @@ func mapassign2(hmap *map[any]any, key any, val any, pres bool);
func readfile(string) (string, bool); // read file into string; boolean status
func exit(int32);
export
mal
breakpoint
@ -84,4 +86,6 @@ export
// files
readfile
// system calls
exit
;

View File

@ -3,10 +3,10 @@ char* sysimport =
"type sys._e002 {}\n"
"type sys.any 24\n"
"type sys._e003 *sys.any\n"
"type sys._o207 {_e205 sys._e003}\n"
"type sys._o214 {_e212 sys._e003}\n"
"type sys.uint32 6\n"
"type sys._i209 {_e206 sys.uint32}\n"
"type sys._e001 (sys._e002 sys._o207 sys._i209)\n"
"type sys._i216 {_e213 sys.uint32}\n"
"type sys._e001 (sys._e002 sys._o214 sys._i216)\n"
"var !sys.mal sys._e001\n"
"type sys._e005 {}\n"
"type sys._e006 {}\n"
@ -16,156 +16,161 @@ char* sysimport =
"type sys._e009 {}\n"
"type sys._e010 {}\n"
"type sys.int32 5\n"
"type sys._i215 {_e214 sys.int32}\n"
"type sys._e008 (sys._e009 sys._e010 sys._i215)\n"
"type sys._i222 {_e221 sys.int32}\n"
"type sys._e008 (sys._e009 sys._e010 sys._i222)\n"
"var !sys.panicl sys._e008\n"
"type sys._e012 {}\n"
"type sys._e013 {}\n"
"type sys.bool 12\n"
"type sys._i220 {_e219 sys.bool}\n"
"type sys._e011 (sys._e012 sys._e013 sys._i220)\n"
"type sys._i227 {_e226 sys.bool}\n"
"type sys._e011 (sys._e012 sys._e013 sys._i227)\n"
"var !sys.printbool sys._e011\n"
"type sys._e015 {}\n"
"type sys._e016 {}\n"
"type sys.float64 10\n"
"type sys._i225 {_e224 sys.float64}\n"
"type sys._e014 (sys._e015 sys._e016 sys._i225)\n"
"type sys._i232 {_e231 sys.float64}\n"
"type sys._e014 (sys._e015 sys._e016 sys._i232)\n"
"var !sys.printfloat sys._e014\n"
"type sys._e018 {}\n"
"type sys._e019 {}\n"
"type sys.int64 7\n"
"type sys._i230 {_e229 sys.int64}\n"
"type sys._e017 (sys._e018 sys._e019 sys._i230)\n"
"type sys._i237 {_e236 sys.int64}\n"
"type sys._e017 (sys._e018 sys._e019 sys._i237)\n"
"var !sys.printint sys._e017\n"
"type sys._e021 {}\n"
"type sys._e022 {}\n"
"type sys._e023 25\n"
"type sys.string *sys._e023\n"
"type sys._i235 {_e234 sys.string}\n"
"type sys._e020 (sys._e021 sys._e022 sys._i235)\n"
"type sys._i242 {_e241 sys.string}\n"
"type sys._e020 (sys._e021 sys._e022 sys._i242)\n"
"var !sys.printstring sys._e020\n"
"type sys._e025 {}\n"
"type sys._e026 {}\n"
"type sys.uint8 2\n"
"type sys._e027 *sys.uint8\n"
"type sys._i240 {_e239 sys._e027}\n"
"type sys._e024 (sys._e025 sys._e026 sys._i240)\n"
"type sys._i247 {_e246 sys._e027}\n"
"type sys._e024 (sys._e025 sys._e026 sys._i247)\n"
"var !sys.printpointer sys._e024\n"
"type sys._e029 {}\n"
"type sys._o247 {_e244 sys.string}\n"
"type sys._i249 {_e245 sys.string _e246 sys.string}\n"
"type sys._e028 (sys._e029 sys._o247 sys._i249)\n"
"type sys._o254 {_e251 sys.string}\n"
"type sys._i256 {_e252 sys.string _e253 sys.string}\n"
"type sys._e028 (sys._e029 sys._o254 sys._i256)\n"
"var !sys.catstring sys._e028\n"
"type sys._e031 {}\n"
"type sys._o257 {_e254 sys.int32}\n"
"type sys._i259 {_e255 sys.string _e256 sys.string}\n"
"type sys._e030 (sys._e031 sys._o257 sys._i259)\n"
"type sys._o264 {_e261 sys.int32}\n"
"type sys._i266 {_e262 sys.string _e263 sys.string}\n"
"type sys._e030 (sys._e031 sys._o264 sys._i266)\n"
"var !sys.cmpstring sys._e030\n"
"type sys._e033 {}\n"
"type sys._o268 {_e264 sys.string}\n"
"type sys._i270 {_e265 sys.string _e266 sys.int32 _e267 sys.int32}\n"
"type sys._e032 (sys._e033 sys._o268 sys._i270)\n"
"type sys._o275 {_e271 sys.string}\n"
"type sys._i277 {_e272 sys.string _e273 sys.int32 _e274 sys.int32}\n"
"type sys._e032 (sys._e033 sys._o275 sys._i277)\n"
"var !sys.slicestring sys._e032\n"
"type sys._e035 {}\n"
"type sys._o279 {_e276 sys.uint8}\n"
"type sys._i281 {_e277 sys.string _e278 sys.int32}\n"
"type sys._e034 (sys._e035 sys._o279 sys._i281)\n"
"type sys._o286 {_e283 sys.uint8}\n"
"type sys._i288 {_e284 sys.string _e285 sys.int32}\n"
"type sys._e034 (sys._e035 sys._o286 sys._i288)\n"
"var !sys.indexstring sys._e034\n"
"type sys._e037 {}\n"
"type sys._o288 {_e286 sys.string}\n"
"type sys._i290 {_e287 sys.int64}\n"
"type sys._e036 (sys._e037 sys._o288 sys._i290)\n"
"type sys._o295 {_e293 sys.string}\n"
"type sys._i297 {_e294 sys.int64}\n"
"type sys._e036 (sys._e037 sys._o295 sys._i297)\n"
"var !sys.intstring sys._e036\n"
"type sys._e039 {}\n"
"type sys._o297 {_e294 sys.string}\n"
"type sys._o304 {_e301 sys.string}\n"
"type sys._e040 *sys.uint8\n"
"type sys._i299 {_e295 sys._e040 _e296 sys.int32}\n"
"type sys._e038 (sys._e039 sys._o297 sys._i299)\n"
"type sys._i306 {_e302 sys._e040 _e303 sys.int32}\n"
"type sys._e038 (sys._e039 sys._o304 sys._i306)\n"
"var !sys.byteastring sys._e038\n"
"type sys._e042 {}\n"
"type sys._e043 <>\n"
"type sys._o308 {_e304 sys._e043}\n"
"type sys._o315 {_e311 sys._e043}\n"
"type sys._e044 *sys.uint8\n"
"type sys._e045 *sys.uint8\n"
"type sys._s315 {}\n"
"type sys._e046 *sys._s315\n"
"type sys._i310 {_e305 sys._e044 _e306 sys._e045 _e307 sys._e046}\n"
"type sys._e041 (sys._e042 sys._o308 sys._i310)\n"
"type sys._s322 {}\n"
"type sys._e046 *sys._s322\n"
"type sys._i317 {_e312 sys._e044 _e313 sys._e045 _e314 sys._e046}\n"
"type sys._e041 (sys._e042 sys._o315 sys._i317)\n"
"var !sys.mkiface sys._e041\n"
"type sys._e048 {}\n"
"type sys._o319 {_e318 sys.int32}\n"
"type sys._o326 {_e325 sys.int32}\n"
"type sys._e049 {}\n"
"type sys._e047 (sys._e048 sys._o319 sys._e049)\n"
"type sys._e047 (sys._e048 sys._o326 sys._e049)\n"
"var !sys.argc sys._e047\n"
"type sys._e051 {}\n"
"type sys._o323 {_e322 sys.int32}\n"
"type sys._o330 {_e329 sys.int32}\n"
"type sys._e052 {}\n"
"type sys._e050 (sys._e051 sys._o323 sys._e052)\n"
"type sys._e050 (sys._e051 sys._o330 sys._e052)\n"
"var !sys.envc sys._e050\n"
"type sys._e054 {}\n"
"type sys._o328 {_e326 sys.string}\n"
"type sys._i330 {_e327 sys.int32}\n"
"type sys._e053 (sys._e054 sys._o328 sys._i330)\n"
"type sys._o335 {_e333 sys.string}\n"
"type sys._i337 {_e334 sys.int32}\n"
"type sys._e053 (sys._e054 sys._o335 sys._i337)\n"
"var !sys.argv sys._e053\n"
"type sys._e056 {}\n"
"type sys._o336 {_e334 sys.string}\n"
"type sys._i338 {_e335 sys.int32}\n"
"type sys._e055 (sys._e056 sys._o336 sys._i338)\n"
"type sys._o343 {_e341 sys.string}\n"
"type sys._i345 {_e342 sys.int32}\n"
"type sys._e055 (sys._e056 sys._o343 sys._i345)\n"
"var !sys.envv sys._e055\n"
"type sys._e058 {}\n"
"type sys._o345 {_e342 sys.int32 _e343 sys.float64}\n"
"type sys._i347 {_e344 sys.float64}\n"
"type sys._e057 (sys._e058 sys._o345 sys._i347)\n"
"type sys._o352 {_e349 sys.int32 _e350 sys.float64}\n"
"type sys._i354 {_e351 sys.float64}\n"
"type sys._e057 (sys._e058 sys._o352 sys._i354)\n"
"var !sys.frexp sys._e057\n"
"type sys._e060 {}\n"
"type sys._o354 {_e351 sys.float64}\n"
"type sys._i356 {_e352 sys.int32 _e353 sys.float64}\n"
"type sys._e059 (sys._e060 sys._o354 sys._i356)\n"
"type sys._o361 {_e358 sys.float64}\n"
"type sys._i363 {_e359 sys.int32 _e360 sys.float64}\n"
"type sys._e059 (sys._e060 sys._o361 sys._i363)\n"
"var !sys.ldexp sys._e059\n"
"type sys._e062 {}\n"
"type sys._o364 {_e361 sys.float64 _e362 sys.float64}\n"
"type sys._i366 {_e363 sys.float64}\n"
"type sys._e061 (sys._e062 sys._o364 sys._i366)\n"
"type sys._o371 {_e368 sys.float64 _e369 sys.float64}\n"
"type sys._i373 {_e370 sys.float64}\n"
"type sys._e061 (sys._e062 sys._o371 sys._i373)\n"
"var !sys.modf sys._e061\n"
"type sys._e064 {}\n"
"type sys._e066 [sys.any] sys.any\n"
"type sys._e065 *sys._e066\n"
"type sys._o370 {hmap sys._e065}\n"
"type sys._i372 {keysize sys.uint32 valsize sys.uint32 keyalg sys.uint32 valalg sys.uint32 hint sys.uint32}\n"
"type sys._e063 (sys._e064 sys._o370 sys._i372)\n"
"type sys._o377 {hmap sys._e065}\n"
"type sys._i379 {keysize sys.uint32 valsize sys.uint32 keyalg sys.uint32 valalg sys.uint32 hint sys.uint32}\n"
"type sys._e063 (sys._e064 sys._o377 sys._i379)\n"
"var !sys.newmap sys._e063\n"
"type sys._e068 {}\n"
"type sys._o380 {val sys.any}\n"
"type sys._o387 {val sys.any}\n"
"type sys._e070 [sys.any] sys.any\n"
"type sys._e069 *sys._e070\n"
"type sys._i382 {hmap sys._e069 key sys.any}\n"
"type sys._e067 (sys._e068 sys._o380 sys._i382)\n"
"type sys._i389 {hmap sys._e069 key sys.any}\n"
"type sys._e067 (sys._e068 sys._o387 sys._i389)\n"
"var !sys.mapaccess1 sys._e067\n"
"type sys._e072 {}\n"
"type sys._o387 {val sys.any pres sys.bool}\n"
"type sys._o394 {val sys.any pres sys.bool}\n"
"type sys._e074 [sys.any] sys.any\n"
"type sys._e073 *sys._e074\n"
"type sys._i389 {hmap sys._e073 key sys.any}\n"
"type sys._e071 (sys._e072 sys._o387 sys._i389)\n"
"type sys._i396 {hmap sys._e073 key sys.any}\n"
"type sys._e071 (sys._e072 sys._o394 sys._i396)\n"
"var !sys.mapaccess2 sys._e071\n"
"type sys._e076 {}\n"
"type sys._e077 {}\n"
"type sys._e079 [sys.any] sys.any\n"
"type sys._e078 *sys._e079\n"
"type sys._i394 {hmap sys._e078 key sys.any val sys.any}\n"
"type sys._e075 (sys._e076 sys._e077 sys._i394)\n"
"type sys._i401 {hmap sys._e078 key sys.any val sys.any}\n"
"type sys._e075 (sys._e076 sys._e077 sys._i401)\n"
"var !sys.mapassign1 sys._e075\n"
"type sys._e081 {}\n"
"type sys._e082 {}\n"
"type sys._e084 [sys.any] sys.any\n"
"type sys._e083 *sys._e084\n"
"type sys._i400 {hmap sys._e083 key sys.any val sys.any pres sys.bool}\n"
"type sys._e080 (sys._e081 sys._e082 sys._i400)\n"
"type sys._i407 {hmap sys._e083 key sys.any val sys.any pres sys.bool}\n"
"type sys._e080 (sys._e081 sys._e082 sys._i407)\n"
"var !sys.mapassign2 sys._e080\n"
"type sys._e086 {}\n"
"type sys._o410 {_e407 sys.string _e408 sys.bool}\n"
"type sys._i412 {_e409 sys.string}\n"
"type sys._e085 (sys._e086 sys._o410 sys._i412)\n"
"type sys._o417 {_e414 sys.string _e415 sys.bool}\n"
"type sys._i419 {_e416 sys.string}\n"
"type sys._e085 (sys._e086 sys._o417 sys._i419)\n"
"var !sys.readfile sys._e085\n"
"type sys._e088 {}\n"
"type sys._e089 {}\n"
"type sys._i424 {_e423 sys.int32}\n"
"type sys._e087 (sys._e088 sys._e089 sys._i424)\n"
"var !sys.exit sys._e087\n"
"))\n"
;

View File

@ -54,9 +54,8 @@ TEXT FLUSH(SB),7,$-8
TEXT sys·exit(SB),1,$-8
MOVL 8(SP), DI // arg 1 exit status
MOVL $(0x2000000+1), AX
MOVL $(0x2000000+1), AX // syscall entry
SYSCALL
JCC 2(PC)
CALL notok(SB)
RET

View File

@ -11,8 +11,7 @@ const (
g float = 4.5 * iota;
);
func main() int {
func main() {
if g == 0.0 { print "zero\n";}
if g != 4.5 { print " fail\n"; return 1; }
return 0;
if g != 4.5 { print " fail\n"; sys.exit(1); }
}

View File

@ -6,7 +6,7 @@
package main
func main() int {
func main() {
var i uint64 =
' ' +
'a' +
@ -33,10 +33,10 @@ func main() int {
;
if '\Ucafebabe' != 0xcafebabe {
print "cafebabe wrong\n";
return 1;
sys.exit(1)
}
if i != 0xcc238de1 {
print "number is ", i, " should be ", 0xcc238de1, "\n";
return 1;
sys.exit(1)
}
}

View File

@ -36,8 +36,6 @@ hello, world
=========== ./int_lit.go
=========== ./integer.go
=========== ./iota.go
=========== ./literal.go

View File

@ -6,7 +6,6 @@
package main
func main() int {
func main() {
print "hello, world\n";
return 0;
}

View File

@ -6,14 +6,13 @@
package main
func main() int {
func main() {
count := 7;
if one := 1; {
count = count + one
}
if count != 8 {
print count, " should be 8\n";
return 1
sys.exit(1)
}
return 0
}

View File

@ -6,7 +6,7 @@
package main
func main() int {
func main() {
s :=
0 +
123 +
@ -18,6 +18,6 @@ func main() int {
0X123;
if s != 788 {
print "s is ", s, "; should be 788\n";
return 1;
sys.exit(1);
}
}

View File

@ -67,7 +67,7 @@ Print_BUG()
}
func
main() int32
main()
{
list := new(List);
list.Init();
@ -78,5 +78,4 @@ main() int32
}
list.Print();
return 0;
}

View File

@ -77,7 +77,7 @@ var tokenlen int = 0;
const EOF int = -1;
func main() int32
func main()
{
var list *Slist;
@ -91,8 +91,6 @@ func main() int32
list.Free();
break;
}
return 0;
}
func (slist *Slist) PrintOne(doparen bool)

View File

@ -16,7 +16,7 @@ func assert(cond bool, msg string) {
}
}
func main() int {
func main() {
code = 0;
// bool
@ -216,5 +216,5 @@ func main() int {
assert(sj0 == sj2, "sj2");
assert(sj0 == sj3, "sj3");
return code;
sys.exit(code);
}

View File

@ -7,14 +7,14 @@
package main
func main() int {
func main() {
var s string
var ok bool
s, ok = sys.readfile("readfile.go");
if !ok {
print "couldn't readfile\n";
return 1
sys.exit(1)
}
start_of_file :=
"// $G $F.go && $L $F.$A && ./$A.out readfile.go\n" +
@ -23,6 +23,6 @@ func main() int {
"package main\n";
if s[0:102] != start_of_file {
print "wrong data\n";
return 1
sys.exit(1)
}
}

View File

@ -32,7 +32,7 @@ func assert(a, b, c string) {
}
}
func main() int {
func main() {
ecode = 0;
s :=
""
@ -75,5 +75,5 @@ func main() int {
`\000\123\x00\312\xFE\u0123\ubabe\U0000babe`,
"backslashes 2 (backquote)");
assert("\\x\\u\\U\\", `\x\u\U\`, "backslash 3 (backquote)");
return ecode;
sys.exit(ecode);
}

View File

@ -6,13 +6,13 @@
package main
func main() int {
func main() {
i := 0;
switch x := 5; {
case i < x:
return 0;
sys.exit(0);
case i == x:
case i > x:
return 1;
sys.exit(1);
}
}