diff options
| author | Cliff Click <cliffc@acm.org> | 2026-08-10 11:11:18 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-16 14:25:14 -0800 |
| commit | 5a0630a75000573aa210b95f1af68662ab37af1b (patch) | |
| tree | 2296e2c37dd06240894a3ed685c391302d3edcfb /src/main/smp/sys/rt | |
| parent | 1e059c4f96f61a6e967e920e8c0b1c9e6216b186 (diff) | |
| download | Simple-5a0630a75000573aa210b95f1af68662ab37af1b.tar.gz Simple-5a0630a75000573aa210b95f1af68662ab37af1b.zip | |
Chapter 30: Text Formatting and Diagnostics
Co-authored-by: Hsiang-Ying Fu <66062782+fuhsnn@users.noreply.github.com>
Co-authored-by: fuhsnn <66062782+fuhsnn@users.noreply.github.com>
Co-authored-by: Symious <14933944+symious@users.noreply.github.com>
Co-authored-by: Jun Kawasaki <jun784@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/main/smp/sys/rt')
| -rw-r--r-- | src/main/smp/sys/rt/simple_args.smp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/main/smp/sys/rt/simple_args.smp b/src/main/smp/sys/rt/simple_args.smp new file mode 100644 index 00000000..3f630e54 --- /dev/null +++ b/src/main/smp/sys/rt/simple_args.smp @@ -0,0 +1,22 @@ +// Native startup support, compiled independently and linked with the CRT. +// Raw native addresses stay i64; only the arrays allocated here are Simple objects. +{ i64 i64 -> i64 } simple_argv = "C"; +{ i64 -> i64 } strlen = "C"; +{ i64 i64 i64 -> i64 } memcpy = "C"; + +val simple_args = { i64 argc, i64 argv -> + if( argc < 0 || argc > 4294967295 ) return null; + // Zero-filled reference arrays require nullable elements. Every slot is + // filled before returning; the native entry bridge publishes u8[~][]. + val args = new u8[~]?[argc]; + for( i64 i=0; i<argc; i++ ) { + i64 src = simple_argv(argv,i); + i64 len = strlen(src); + if( len < 0 || len > 4294967295 ) return null; + val bytes = new u8[len]; + i64 dst = bytes; + memcpy(dst,src,len); + args[i] = bytes; + } + return args; +}; |
