|
|
@@ -0,0 +1,44 @@
|
|
|
+# Step: stdlib — Strings additions, SysClock, more Math
|
|
|
+
|
|
|
+Tag `v3-stdlib-more`. Suite **151/151**; fixpoint **OK**
|
|
|
+(image **2,337,882 bytes**).
|
|
|
+
|
|
|
+## `Strings`
|
|
|
+
|
|
|
+- **`Slice(s, start, stop, dst)`** — Python-style `s[start:stop]`:
|
|
|
+ 0-based, negative indices count from the end (`-1` = last),
|
|
|
+ `stop` is exclusive, both clamp to `[0, Length]`; the result is
|
|
|
+ truncated to `dst`'s capacity. (`"Hello, World"[0:5]` → `Hello`,
|
|
|
+ `[-5:12]` → `World`, `[0:-8]` → `Hell`, `[3:3]` → `""`.)
|
|
|
+- **`Insert(src, dst, pos)`** — inserts `src` at 0-based `pos`
|
|
|
+ (clamped), truncated to `dst`'s capacity.
|
|
|
+- **`Replace(src, dst, pos)`** — overwrites `dst` from `pos` with
|
|
|
+ `src`, extending (and re-terminating) if it runs past the old end.
|
|
|
+- **`Capitalize(s)`** — first character upper, the rest lower (ASCII).
|
|
|
+
|
|
|
+## `SysClock` (new)
|
|
|
+
|
|
|
+- `Time() : LONGINT` — seconds since the Unix epoch.
|
|
|
+- `Clock() : LONGINT` — processor time in ticks,
|
|
|
+ `ClocksPerSec = 1000000`.
|
|
|
+- Bound to shim `m2time`/`m2clock` (libc `time`/`clock`); the shim
|
|
|
+ gained `#include <time.h>` and the two functions.
|
|
|
+
|
|
|
+## `Math`
|
|
|
+
|
|
|
+Added: `log10`, `atan2`, `sinh`, `cosh`, `tanh`, `hypot`, `floor`,
|
|
|
+`ceil`, `trunc`, `round`, `fmod` (all bound to libm).
|
|
|
+
|
|
|
+## Tests
|
|
|
+
|
|
|
+- `strings_slice_prog.mod` (255): `Slice` (incl. negatives and empty),
|
|
|
+ `Insert`, `Replace`, `Capitalize`.
|
|
|
+- `math2_prog.mod` (31): `hypot`/`floor`/`ceil`/`trunc`/`log10`.
|
|
|
+- `sysclock_prog.mod` (3): `Time` after 2020, `Clock` >= 0.
|
|
|
+
|
|
|
+## Files
|
|
|
+
|
|
|
+`stdlib/strings.def`/`.mod`, `stdlib/sysclock.def`/`.mod`,
|
|
|
+`stdlib/math.def`/`.mod`, `runtime/syslib/shim.c`,
|
|
|
+`compiler/tests/{strings_slice_prog,math2_prog,sysclock_prog}.mod`,
|
|
|
+`compiler/run_tests.sh`, `docs/features.md`.
|