Commit 6db99de6 authored by Rob Pike's avatar Rob Pike

add bytestorune and stringtorune to sys.

SVN=126321
parent 5352306f
......@@ -45,6 +45,8 @@ func mapassign1(hmap *map[any]any, key any, val any);
func mapassign2(hmap *map[any]any, key any, val any, pres bool);
func readfile(string) (string, bool); // read file into string; boolean status
func bytestorune(*byte, int32, int32) (int32, int32); // convert bytes to runes
func stringtorune(string, int32, int32) (int32, int32); // convert bytes to runes
func exit(int32);
......@@ -94,6 +96,10 @@ export
// files
readfile
// runes and utf-8
bytestorune
stringtorune
// system calls
exit
;
......@@ -3,10 +3,10 @@ char* sysimport =
"type sys._e002 {}\n"
"type sys.any 24\n"
"type sys._e003 *sys.any\n"
"type sys._o257 {_e255 sys._e003}\n"
"type sys._o262 {_e260 sys._e003}\n"
"type sys.uint32 6\n"
"type sys._i259 {_e256 sys.uint32}\n"
"type sys._e001 (sys._e002 sys._o257 sys._i259)\n"
"type sys._i264 {_e261 sys.uint32}\n"
"type sys._e001 (sys._e002 sys._o262 sys._i264)\n"
"var !sys.mal sys._e001\n"
"type sys._e005 {}\n"
"type sys._e006 {}\n"
......@@ -16,181 +16,192 @@ char* sysimport =
"type sys._e009 {}\n"
"type sys._e010 {}\n"
"type sys.int32 5\n"
"type sys._i265 {_e264 sys.int32}\n"
"type sys._e008 (sys._e009 sys._e010 sys._i265)\n"
"type sys._i270 {_e269 sys.int32}\n"
"type sys._e008 (sys._e009 sys._e010 sys._i270)\n"
"var !sys.panicl sys._e008\n"
"type sys._e012 {}\n"
"type sys._e013 {}\n"
"type sys.bool 12\n"
"type sys._i270 {_e269 sys.bool}\n"
"type sys._e011 (sys._e012 sys._e013 sys._i270)\n"
"type sys._i275 {_e274 sys.bool}\n"
"type sys._e011 (sys._e012 sys._e013 sys._i275)\n"
"var !sys.printbool sys._e011\n"
"type sys._e015 {}\n"
"type sys._e016 {}\n"
"type sys.float64 10\n"
"type sys._i275 {_e274 sys.float64}\n"
"type sys._e014 (sys._e015 sys._e016 sys._i275)\n"
"type sys._i280 {_e279 sys.float64}\n"
"type sys._e014 (sys._e015 sys._e016 sys._i280)\n"
"var !sys.printfloat sys._e014\n"
"type sys._e018 {}\n"
"type sys._e019 {}\n"
"type sys.int64 7\n"
"type sys._i280 {_e279 sys.int64}\n"
"type sys._e017 (sys._e018 sys._e019 sys._i280)\n"
"type sys._i285 {_e284 sys.int64}\n"
"type sys._e017 (sys._e018 sys._e019 sys._i285)\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._i285 {_e284 sys.string}\n"
"type sys._e020 (sys._e021 sys._e022 sys._i285)\n"
"type sys._i290 {_e289 sys.string}\n"
"type sys._e020 (sys._e021 sys._e022 sys._i290)\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._i290 {_e289 sys._e027}\n"
"type sys._e024 (sys._e025 sys._e026 sys._i290)\n"
"type sys._i295 {_e294 sys._e027}\n"
"type sys._e024 (sys._e025 sys._e026 sys._i295)\n"
"var !sys.printpointer sys._e024\n"
"type sys._e029 {}\n"
"type sys._o297 {_e294 sys.string}\n"
"type sys._i299 {_e295 sys.string _e296 sys.string}\n"
"type sys._e028 (sys._e029 sys._o297 sys._i299)\n"
"type sys._o302 {_e299 sys.string}\n"
"type sys._i304 {_e300 sys.string _e301 sys.string}\n"
"type sys._e028 (sys._e029 sys._o302 sys._i304)\n"
"var !sys.catstring sys._e028\n"
"type sys._e031 {}\n"
"type sys._o307 {_e304 sys.int32}\n"
"type sys._i309 {_e305 sys.string _e306 sys.string}\n"
"type sys._e030 (sys._e031 sys._o307 sys._i309)\n"
"type sys._o312 {_e309 sys.int32}\n"
"type sys._i314 {_e310 sys.string _e311 sys.string}\n"
"type sys._e030 (sys._e031 sys._o312 sys._i314)\n"
"var !sys.cmpstring sys._e030\n"
"type sys._e033 {}\n"
"type sys._o318 {_e314 sys.string}\n"
"type sys._i320 {_e315 sys.string _e316 sys.int32 _e317 sys.int32}\n"
"type sys._e032 (sys._e033 sys._o318 sys._i320)\n"
"type sys._o323 {_e319 sys.string}\n"
"type sys._i325 {_e320 sys.string _e321 sys.int32 _e322 sys.int32}\n"
"type sys._e032 (sys._e033 sys._o323 sys._i325)\n"
"var !sys.slicestring sys._e032\n"
"type sys._e035 {}\n"
"type sys._o329 {_e326 sys.uint8}\n"
"type sys._i331 {_e327 sys.string _e328 sys.int32}\n"
"type sys._e034 (sys._e035 sys._o329 sys._i331)\n"
"type sys._o334 {_e331 sys.uint8}\n"
"type sys._i336 {_e332 sys.string _e333 sys.int32}\n"
"type sys._e034 (sys._e035 sys._o334 sys._i336)\n"
"var !sys.indexstring sys._e034\n"
"type sys._e037 {}\n"
"type sys._o338 {_e336 sys.string}\n"
"type sys._i340 {_e337 sys.int64}\n"
"type sys._e036 (sys._e037 sys._o338 sys._i340)\n"
"type sys._o343 {_e341 sys.string}\n"
"type sys._i345 {_e342 sys.int64}\n"
"type sys._e036 (sys._e037 sys._o343 sys._i345)\n"
"var !sys.intstring sys._e036\n"
"type sys._e039 {}\n"
"type sys._o347 {_e344 sys.string}\n"
"type sys._o352 {_e349 sys.string}\n"
"type sys._e040 *sys.uint8\n"
"type sys._i349 {_e345 sys._e040 _e346 sys.int32}\n"
"type sys._e038 (sys._e039 sys._o347 sys._i349)\n"
"type sys._i354 {_e350 sys._e040 _e351 sys.int32}\n"
"type sys._e038 (sys._e039 sys._o352 sys._i354)\n"
"var !sys.byteastring sys._e038\n"
"type sys._e042 {}\n"
"type sys._e043 <>\n"
"type sys._o358 {_e354 sys._e043}\n"
"type sys._o363 {_e359 sys._e043}\n"
"type sys._e044 *sys.uint8\n"
"type sys._e045 *sys.uint8\n"
"type sys._s365 {}\n"
"type sys._e046 *sys._s365\n"
"type sys._i360 {_e355 sys._e044 _e356 sys._e045 _e357 sys._e046}\n"
"type sys._e041 (sys._e042 sys._o358 sys._i360)\n"
"type sys._s370 {}\n"
"type sys._e046 *sys._s370\n"
"type sys._i365 {_e360 sys._e044 _e361 sys._e045 _e362 sys._e046}\n"
"type sys._e041 (sys._e042 sys._o363 sys._i365)\n"
"var !sys.mkiface sys._e041\n"
"type sys._e048 {}\n"
"type sys._o369 {_e368 sys.int32}\n"
"type sys._o374 {_e373 sys.int32}\n"
"type sys._e049 {}\n"
"type sys._e047 (sys._e048 sys._o369 sys._e049)\n"
"type sys._e047 (sys._e048 sys._o374 sys._e049)\n"
"var !sys.argc sys._e047\n"
"type sys._e051 {}\n"
"type sys._o373 {_e372 sys.int32}\n"
"type sys._o378 {_e377 sys.int32}\n"
"type sys._e052 {}\n"
"type sys._e050 (sys._e051 sys._o373 sys._e052)\n"
"type sys._e050 (sys._e051 sys._o378 sys._e052)\n"
"var !sys.envc sys._e050\n"
"type sys._e054 {}\n"
"type sys._o378 {_e376 sys.string}\n"
"type sys._i380 {_e377 sys.int32}\n"
"type sys._e053 (sys._e054 sys._o378 sys._i380)\n"
"type sys._o383 {_e381 sys.string}\n"
"type sys._i385 {_e382 sys.int32}\n"
"type sys._e053 (sys._e054 sys._o383 sys._i385)\n"
"var !sys.argv sys._e053\n"
"type sys._e056 {}\n"
"type sys._o386 {_e384 sys.string}\n"
"type sys._i388 {_e385 sys.int32}\n"
"type sys._e055 (sys._e056 sys._o386 sys._i388)\n"
"type sys._o391 {_e389 sys.string}\n"
"type sys._i393 {_e390 sys.int32}\n"
"type sys._e055 (sys._e056 sys._o391 sys._i393)\n"
"var !sys.envv sys._e055\n"
"type sys._e058 {}\n"
"type sys._o395 {_e392 sys.int32 _e393 sys.float64}\n"
"type sys._i397 {_e394 sys.float64}\n"
"type sys._e057 (sys._e058 sys._o395 sys._i397)\n"
"type sys._o400 {_e397 sys.int32 _e398 sys.float64}\n"
"type sys._i402 {_e399 sys.float64}\n"
"type sys._e057 (sys._e058 sys._o400 sys._i402)\n"
"var !sys.frexp sys._e057\n"
"type sys._e060 {}\n"
"type sys._o404 {_e401 sys.float64}\n"
"type sys._i406 {_e402 sys.int32 _e403 sys.float64}\n"
"type sys._e059 (sys._e060 sys._o404 sys._i406)\n"
"type sys._o409 {_e406 sys.float64}\n"
"type sys._i411 {_e407 sys.int32 _e408 sys.float64}\n"
"type sys._e059 (sys._e060 sys._o409 sys._i411)\n"
"var !sys.ldexp sys._e059\n"
"type sys._e062 {}\n"
"type sys._o414 {_e411 sys.float64 _e412 sys.float64}\n"
"type sys._i416 {_e413 sys.float64}\n"
"type sys._e061 (sys._e062 sys._o414 sys._i416)\n"
"type sys._o419 {_e416 sys.float64 _e417 sys.float64}\n"
"type sys._i421 {_e418 sys.float64}\n"
"type sys._e061 (sys._e062 sys._o419 sys._i421)\n"
"var !sys.modf sys._e061\n"
"type sys._e064 {}\n"
"type sys._o423 {_e420 sys.bool}\n"
"type sys._i425 {_e421 sys.float64 _e422 sys.int32}\n"
"type sys._e063 (sys._e064 sys._o423 sys._i425)\n"
"type sys._o428 {_e425 sys.bool}\n"
"type sys._i430 {_e426 sys.float64 _e427 sys.int32}\n"
"type sys._e063 (sys._e064 sys._o428 sys._i430)\n"
"var !sys.isInf sys._e063\n"
"type sys._e066 {}\n"
"type sys._o432 {_e430 sys.bool}\n"
"type sys._i434 {_e431 sys.float64}\n"
"type sys._e065 (sys._e066 sys._o432 sys._i434)\n"
"type sys._o437 {_e435 sys.bool}\n"
"type sys._i439 {_e436 sys.float64}\n"
"type sys._e065 (sys._e066 sys._o437 sys._i439)\n"
"var !sys.isNaN sys._e065\n"
"type sys._e068 {}\n"
"type sys._o440 {_e438 sys.float64}\n"
"type sys._i442 {_e439 sys.int32}\n"
"type sys._e067 (sys._e068 sys._o440 sys._i442)\n"
"type sys._o445 {_e443 sys.float64}\n"
"type sys._i447 {_e444 sys.int32}\n"
"type sys._e067 (sys._e068 sys._o445 sys._i447)\n"
"var !sys.Inf sys._e067\n"
"type sys._e070 {}\n"
"type sys._o447 {_e446 sys.float64}\n"
"type sys._o452 {_e451 sys.float64}\n"
"type sys._e071 {}\n"
"type sys._e069 (sys._e070 sys._o447 sys._e071)\n"
"type sys._e069 (sys._e070 sys._o452 sys._e071)\n"
"var !sys.NaN sys._e069\n"
"type sys._e073 {}\n"
"type sys._e075 [sys.any] sys.any\n"
"type sys._e074 *sys._e075\n"
"type sys._o450 {hmap sys._e074}\n"
"type sys._i452 {keysize sys.uint32 valsize sys.uint32 keyalg sys.uint32 valalg sys.uint32 hint sys.uint32}\n"
"type sys._e072 (sys._e073 sys._o450 sys._i452)\n"
"type sys._o455 {hmap sys._e074}\n"
"type sys._i457 {keysize sys.uint32 valsize sys.uint32 keyalg sys.uint32 valalg sys.uint32 hint sys.uint32}\n"
"type sys._e072 (sys._e073 sys._o455 sys._i457)\n"
"var !sys.newmap sys._e072\n"
"type sys._e077 {}\n"
"type sys._o461 {val sys.any}\n"
"type sys._o466 {val sys.any}\n"
"type sys._e079 [sys.any] sys.any\n"
"type sys._e078 *sys._e079\n"
"type sys._i463 {hmap sys._e078 key sys.any}\n"
"type sys._e076 (sys._e077 sys._o461 sys._i463)\n"
"type sys._i468 {hmap sys._e078 key sys.any}\n"
"type sys._e076 (sys._e077 sys._o466 sys._i468)\n"
"var !sys.mapaccess1 sys._e076\n"
"type sys._e081 {}\n"
"type sys._o469 {val sys.any pres sys.bool}\n"
"type sys._o474 {val sys.any pres sys.bool}\n"
"type sys._e083 [sys.any] sys.any\n"
"type sys._e082 *sys._e083\n"
"type sys._i471 {hmap sys._e082 key sys.any}\n"
"type sys._e080 (sys._e081 sys._o469 sys._i471)\n"
"type sys._i476 {hmap sys._e082 key sys.any}\n"
"type sys._e080 (sys._e081 sys._o474 sys._i476)\n"
"var !sys.mapaccess2 sys._e080\n"
"type sys._e085 {}\n"
"type sys._e086 {}\n"
"type sys._e088 [sys.any] sys.any\n"
"type sys._e087 *sys._e088\n"
"type sys._i478 {hmap sys._e087 key sys.any val sys.any}\n"
"type sys._e084 (sys._e085 sys._e086 sys._i478)\n"
"type sys._i483 {hmap sys._e087 key sys.any val sys.any}\n"
"type sys._e084 (sys._e085 sys._e086 sys._i483)\n"
"var !sys.mapassign1 sys._e084\n"
"type sys._e090 {}\n"
"type sys._e091 {}\n"
"type sys._e093 [sys.any] sys.any\n"
"type sys._e092 *sys._e093\n"
"type sys._i484 {hmap sys._e092 key sys.any val sys.any pres sys.bool}\n"
"type sys._e089 (sys._e090 sys._e091 sys._i484)\n"
"type sys._i489 {hmap sys._e092 key sys.any val sys.any pres sys.bool}\n"
"type sys._e089 (sys._e090 sys._e091 sys._i489)\n"
"var !sys.mapassign2 sys._e089\n"
"type sys._e095 {}\n"
"type sys._o494 {_e491 sys.string _e492 sys.bool}\n"
"type sys._i496 {_e493 sys.string}\n"
"type sys._e094 (sys._e095 sys._o494 sys._i496)\n"
"type sys._o499 {_e496 sys.string _e497 sys.bool}\n"
"type sys._i501 {_e498 sys.string}\n"
"type sys._e094 (sys._e095 sys._o499 sys._i501)\n"
"var !sys.readfile sys._e094\n"
"type sys._e097 {}\n"
"type sys._e098 {}\n"
"type sys._i501 {_e500 sys.int32}\n"
"type sys._e096 (sys._e097 sys._e098 sys._i501)\n"
"var !sys.exit sys._e096\n"
"type sys._o510 {_e505 sys.int32 _e506 sys.int32}\n"
"type sys._e098 *sys.uint8\n"
"type sys._i512 {_e507 sys._e098 _e508 sys.int32 _e509 sys.int32}\n"
"type sys._e096 (sys._e097 sys._o510 sys._i512)\n"
"var !sys.bytestorune sys._e096\n"
"type sys._e100 {}\n"
"type sys._o523 {_e518 sys.int32 _e519 sys.int32}\n"
"type sys._i525 {_e520 sys.string _e521 sys.int32 _e522 sys.int32}\n"
"type sys._e099 (sys._e100 sys._o523 sys._i525)\n"
"var !sys.stringtorune sys._e099\n"
"type sys._e102 {}\n"
"type sys._e103 {}\n"
"type sys._i532 {_e531 sys.int32}\n"
"type sys._e101 (sys._e102 sys._e103 sys._i532)\n"
"var !sys.exit sys._e101\n"
"))\n"
;
......@@ -222,3 +222,22 @@ runetochar(byte *str, int32 rune) /* note: in original, arg2 was pointer */
str[3] = Tx | (c & Maskx);
return 4;
}
/*
* Wrappers for calling from go
*/
void
sys·bytestorune(byte *str, int32 off, int32 length, int32 outrune, int32 outcount)
{
outcount = charntorune(&outrune, str + off, length);
FLUSH(&outrune);
FLUSH(&outcount);
}
void
sys·stringtorune(string str, int32 off, int32 length, int32 outrune, int32 outcount)
{
outcount = charntorune(&outrune, str->str + off, length);
FLUSH(&outrune);
FLUSH(&outcount);
}
......@@ -142,4 +142,10 @@ void sys·intstring(int64, string);
void sys·ifaces2i(Sigi*, Sigs*, Map*, void*);
void sys·ifacei2i(Sigi*, Map*, void*);
void sys·ifacei2s(Sigs*, Map*, void*);
/*
* User go-called
*/
void sys·readfile(string, string, bool);
void sys·bytestorune(byte*, int32, int32, int32, int32);
void sys·stringtorune(string, int32, int32, int32, int32);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment