diff options
| author | Cliff Click <cliffc@acm.org> | 2026-09-28 13:30:22 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-09-28 13:30:22 -0700 |
| commit | 586c8f65f2d0c0e1f73aadd0aa8d850aa653bddd (patch) | |
| tree | 2f539c308452ddf5fa37826da95b17ba557e8352 /chapter25/README.md | |
| parent | 8212a66ff27e56531e0b48807088f1c544d75756 (diff) | |
| download | Simple-586c8f65f2d0c0e1f73aadd0aa8d850aa653bddd.tar.gz Simple-586c8f65f2d0c0e1f73aadd0aa8d850aa653bddd.zip | |
Support extern C ver direct updates
FIx minor RISC encodings.
Diffstat (limited to 'chapter25/README.md')
| -rw-r--r-- | chapter25/README.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/chapter25/README.md b/chapter25/README.md index b6a7ded5..6d1d5e99 100644 --- a/chapter25/README.md +++ b/chapter25/README.md @@ -29,6 +29,26 @@ external Simple object search paths, including an object file or a directory. The compiler also resolves external C symbols for native linking. Names beginning with `_` control privacy; public reachability depends on enclosing names too. +Explicit numeric C declarations bind directly to mutable native storage: + +```java +i32 counter = "C"; +counter += 1; +return counter; +``` + +The native linker resolves `counter`. Reads and writes access that C variable; +the declaration neither copies nor initializes it. Repeated declarations and +module imports share the same storage alias. Integer and floating-point data +bindings are supported; pointer and aggregate data bindings are not yet supported. +External fields carry a storage flag and occupy no bytes in their declaring +class. Layout resolves their field offsets to `ExternOffset` symbols; instruction +selection replaces class-base-plus-offset with the native symbol address. +Native object output uses the existing AMD64 ELF writer; ARM and RISC-V support +these addresses through the in-memory linker. Thread-local variables and C macros +need accessor functions: the system library exposes `libc.errno()` through a small +native runtime accessor. + ## Object files contain ideal IR The ELF writer stores native code and a `.simple` section containing canonical @@ -47,6 +67,10 @@ expensive serialization bijection check is currently disabled, and the larger incremental-rebuild test `testModule0` is ignored. Neither is an active validation guarantee. +The external-field flag and symbolic offsets change the serialized layout. +The magic remains `C0DE`; there is no separate format version yet. Rebuild all +Simple object files before importing them with this compiler. + ## Constructing SSA before types are complete Simple still parses directly to SSA without an AST. Forward references mean an |
