no more special case for core C

This commit is contained in:
2026-02-14 22:00:12 -06:00
parent 86609c27f8
commit eee06009b9
38 changed files with 14471 additions and 14967 deletions

View File

@@ -42,12 +42,12 @@ static char *compute_blake2_hex(const char *data, size_t size) {
return hex;
}
// Build cache path: shop_path/build/<hex>.mach (caller must free)
// Build cache path: shop_path/build/<hex> (caller must free)
static char *build_cache_path(const char *hex) {
if (!shop_path) return NULL;
size_t len = strlen(shop_path) + strlen("/build/") + 64 + strlen(".mach") + 1;
size_t len = strlen(shop_path) + strlen("/build/") + 64 + 1;
char *path = malloc(len);
snprintf(path, len, "%s/build/%s.mach", shop_path, hex);
snprintf(path, len, "%s/build/%s", shop_path, hex);
return path;
}
@@ -225,11 +225,8 @@ void actor_disrupt(cell_rt *crt)
actor_free(crt);
}
JSValue js_os_use(JSContext *js);
JSValue js_math_use(JSContext *js);
JSValue js_json_use(JSContext *js);
JSValue js_nota_use(JSContext *js);
JSValue js_wota_use(JSContext *js);
JSValue js_core_os_use(JSContext *js);
JSValue js_core_json_use(JSContext *js);
void script_startup(cell_rt *prt)
{
@@ -255,7 +252,7 @@ void script_startup(cell_rt *prt)
prt->actor_sym_ref.val = JS_NULL;
cell_rt *crt = JS_GetContextOpaque(js);
JS_FreeValue(js, js_blob_use(js));
JS_FreeValue(js, js_core_blob_use(js));
// Load pre-compiled bootstrap .mcode
size_t boot_size;
@@ -276,10 +273,8 @@ void script_startup(cell_rt *prt)
// Create hidden environment
JSValue hidden_env = JS_NewObject(js);
JS_SetPropertyStr(js, hidden_env, "os", js_os_use(js));
JS_SetPropertyStr(js, hidden_env, "json", js_json_use(js));
JS_SetPropertyStr(js, hidden_env, "nota", js_nota_use(js));
JS_SetPropertyStr(js, hidden_env, "wota", js_wota_use(js));
JS_SetPropertyStr(js, hidden_env, "os", js_core_os_use(js));
JS_SetPropertyStr(js, hidden_env, "json", js_core_json_use(js));
crt->actor_sym_ref.val = JS_NewObject(js);
JS_SetPropertyStr(js, hidden_env, "actorsym", JS_DupValue(js, crt->actor_sym_ref.val));
@@ -502,17 +497,15 @@ int cell_init(int argc, char **argv)
root_cell = cli_rt;
JS_FreeValue(ctx, js_blob_use(ctx));
JS_FreeValue(ctx, js_core_blob_use(ctx));
JSValue hidden_env = JS_NewObject(ctx);
JS_SetPropertyStr(ctx, hidden_env, "os", js_os_use(ctx));
JS_SetPropertyStr(ctx, hidden_env, "os", js_core_os_use(ctx));
JS_SetPropertyStr(ctx, hidden_env, "core_path", JS_NewString(ctx, core_path));
JS_SetPropertyStr(ctx, hidden_env, "shop_path",
shop_path ? JS_NewString(ctx, shop_path) : JS_NULL);
JS_SetPropertyStr(ctx, hidden_env, "actorsym", JS_DupValue(ctx, cli_rt->actor_sym_ref.val));
JS_SetPropertyStr(ctx, hidden_env, "json", js_json_use(ctx));
JS_SetPropertyStr(ctx, hidden_env, "nota", js_nota_use(ctx));
JS_SetPropertyStr(ctx, hidden_env, "wota", js_wota_use(ctx));
JS_SetPropertyStr(ctx, hidden_env, "json", js_core_json_use(ctx));
JS_SetPropertyStr(ctx, hidden_env, "init", JS_NULL);
JSValue args_arr = JS_NewArray(ctx);
for (int i = arg_start; i < argc; i++) {

View File

@@ -9,7 +9,7 @@ extern "C" {
#endif
// blob fns
JSValue js_blob_use(JSContext *js);
JSValue js_core_blob_use(JSContext *js);
JSValue js_new_blob_stoned_copy(JSContext *js, void *data, size_t bytes);
void *js_get_blob_data(JSContext *js, size_t *size, JSValue v); // bytes
void *js_get_blob_data_bits(JSContext *js, size_t *bits, JSValue v); // bits
@@ -31,9 +31,7 @@ void *value2wota(JSContext *js, JSValue v, JSValue replacer, size_t *bytes);
JSValue nota2value(JSContext *js, void *nota);
void *value2nota(JSContext *js, JSValue v);
JSValue js_json_use(JSContext *js);
JSValue js_nota_use(JSContext *js);
JSValue js_wota_use(JSContext *js);
JSValue js_core_json_use(JSContext *js);
#define CELL_HOOK_ENTER 1
#define CELL_HOOK_EXIT 2

View File

@@ -155,7 +155,7 @@ static const JSCFunctionListEntry js_actor_funcs[] = {
MIST_FUNC_DEF(actor, clock, 1),
};
JSValue js_actor_use(JSContext *js) {
JSValue js_core_actor_use(JSContext *js) {
JSValue mod = JS_NewObject(js);
JS_SetPropertyFunctionList(js,mod,js_actor_funcs,countof(js_actor_funcs));
return mod;

View File

@@ -9443,7 +9443,7 @@ static const JSCFunctionListEntry js_blob_proto_funcs[] = {
/* Initialize blob - called during context setup (but we do it in
* JS_AddIntrinsicBaseObjects now) */
JSValue js_blob_use (JSContext *js) {
JSValue js_core_blob_use (JSContext *js) {
return JS_GetPropertyStr (js, js->global_obj, "blob");
}
@@ -10917,7 +10917,7 @@ static const JSCFunctionListEntry js_cell_json_funcs[] = {
JS_CFUNC_DEF ("decode", 1, js_cell_json_decode),
};
JSValue js_json_use (JSContext *ctx) {
JSValue js_core_json_use (JSContext *ctx) {
JSGCRef obj_ref;
JS_PushGCRef (ctx, &obj_ref);
obj_ref.val = JS_NewObject (ctx);
@@ -11329,7 +11329,7 @@ static const JSCFunctionListEntry js_nota_funcs[] = {
JS_CFUNC_DEF ("decode", 1, js_nota_decode),
};
JSValue js_nota_use (JSContext *js) {
JSValue js_core_nota_use (JSContext *js) {
JSGCRef export_ref;
JS_PushGCRef (js, &export_ref);
export_ref.val = JS_NewObject (js);
@@ -11763,7 +11763,7 @@ static const JSCFunctionListEntry js_wota_funcs[] = {
JS_CFUNC_DEF ("decode", 2, js_wota_decode),
};
JSValue js_wota_use (JSContext *ctx) {
JSValue js_core_wota_use (JSContext *ctx) {
JSGCRef exports_ref;
JS_PushGCRef (ctx, &exports_ref);
exports_ref.val = JS_NewObject (ctx);
@@ -11878,7 +11878,7 @@ static const JSCFunctionListEntry js_math_radians_funcs[]
JS_CFUNC_DEF ("sqrt", 1, js_math_sqrt),
JS_CFUNC_DEF ("e", 1, js_math_e) };
JSValue js_math_radians_use (JSContext *ctx) {
JSValue js_core_math_radians_use (JSContext *ctx) {
JSValue obj = JS_NewObject (ctx);
JS_SetPropertyFunctionList (ctx, obj, js_math_radians_funcs, countof (js_math_radians_funcs));
return obj;
@@ -11944,7 +11944,7 @@ static const JSCFunctionListEntry js_math_degrees_funcs[]
JS_CFUNC_DEF ("sqrt", 1, js_math_sqrt),
JS_CFUNC_DEF ("e", 1, js_math_e) };
JSValue js_math_degrees_use (JSContext *ctx) {
JSValue js_core_math_degrees_use (JSContext *ctx) {
JSValue obj = JS_NewObject (ctx);
JS_SetPropertyFunctionList (ctx, obj, js_math_degrees_funcs, countof (js_math_degrees_funcs));
return obj;
@@ -12009,7 +12009,7 @@ static const JSCFunctionListEntry js_math_cycles_funcs[]
JS_CFUNC_DEF ("sqrt", 1, js_math_sqrt),
JS_CFUNC_DEF ("e", 1, js_math_e) };
JSValue js_math_cycles_use (JSContext *ctx) {
JSValue js_core_math_cycles_use (JSContext *ctx) {
JSValue obj = JS_NewObject (ctx);
JS_SetPropertyFunctionList (ctx, obj, js_math_cycles_funcs, countof (js_math_cycles_funcs));
return obj;