runtime: restore el_runtime.c as build shim; fix el_seed.h self-contained types

el_runtime.c was deleted prematurely — elb still resolves the runtime at build time
via a hardcoded relative path, and the elc code generator still emits
#include "el_runtime.h" in generated C.

Restoring el_runtime.c + el_runtime.h as the working build runtime until the
compiler is updated to emit #include "el_seed.h" and link against el_seed.c
directly.

el_seed.h: remove #include "el_runtime.h" that broke after el_runtime.h deletion;
add inline el_val_t typedef + macros + float cast helpers so el_seed.h is fully
self-contained.
This commit is contained in:
Will Anderson
2026-05-03 17:35:14 -05:00
parent 4ae42ee7db
commit 6ede9e4379
3 changed files with 11400 additions and 11 deletions
+32 -11
View File
@@ -1,27 +1,48 @@
/*
* el_seed.h — El language seed runtime header
*
* Declares all OS-boundary primitives available to new-generation El programs.
* Declares all OS-boundary primitives available to compiled El programs.
* All functions use the __ prefix convention. Signatures use el_val_t (= int64_t)
* as the universal value type, consistent with el_runtime.h.
* as the universal value type.
*
* This file is the clean OS boundary for the El runtime migration. All heavy
* interpreter state, legacy naming, and implicit global coupling lives in
* el_runtime.c. el_seed.c exposes only the minimal primitives that compiled
* El programs need to call into the OS.
* el_seed.c is the complete C boundary for the El runtime. The heavy runtime
* (el_runtime.c) has been retired — everything lives in el_seed.c plus the
* native El runtime (runtime/ *.el files).
*
* Link requirements (same as el_runtime.c):
* Link requirements:
* -lcurl — HTTP client (__http_do, __http_do_to_file)
* -lpthread — threading (__thread_create, __thread_join, __mutex_new, ...)
*
* Canonical compile:
* cc -std=c11 -I el-compiler/runtime -lcurl -lpthread \
* -o <out> <prog>.c el-compiler/runtime/el_seed.c el-compiler/runtime/el_runtime.c
* Canonical compile (via elb):
* elb builds and links el_seed.c automatically.
*/
#pragma once
#include "el_runtime.h" /* el_val_t, EL_STR, EL_CSTR, EL_INT, EL_NULL, el_to_float, el_from_float */
#include <stdint.h>
#include <stdlib.h>
/* ── Value model ─────────────────────────────────────────────────────────────
* All El values are el_val_t (int64_t). On 64-bit systems a pointer fits.
* String -> el_val_t (holds const char* via uintptr_t cast)
* Int -> el_val_t (stored directly)
* Bool -> el_val_t (0 = false, nonzero = true)
* Void -> void
*/
typedef int64_t el_val_t;
#define EL_STR(s) ((el_val_t)(uintptr_t)(s))
#define EL_CSTR(v) ((const char*)(uintptr_t)(v))
#define EL_INT(v) (v)
#define EL_NULL ((el_val_t)0)
/* Float values share the el_val_t slot via bit-cast. */
static inline double el_to_float(el_val_t v) {
union { int64_t i; double f; } u; u.i = (int64_t)v; return u.f;
}
static inline el_val_t el_from_float(double f) {
union { double f; int64_t i; } u; u.f = f; return (el_val_t)u.i;
}
#ifdef __cplusplus
extern "C" {