Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e09139b
ska: integration wip
dozreg-toplud Sep 23, 2025
4e80d77
ska: integration wip
dozreg-toplud Sep 23, 2025
a8a1bec
ska: rest of integration
dozreg-toplud Sep 23, 2025
19094b2
Merge branch 'develop' into dozreg/ska-integrate-409-2
dozreg-toplud Oct 22, 2025
2e91f0e
update ska_core
dozreg-toplud Oct 22, 2025
859d611
verbose ska core
dozreg-toplud Oct 22, 2025
5995d18
check is sub/fol is present in boil before analysis
dozreg-toplud Oct 22, 2025
9bedb87
make _n_comp_direct use same stack protocol as _n_comp (eager subject…
dozreg-toplud Oct 22, 2025
c4f0566
Merge branch 'develop' into dozreg/ska-integrate-409-2
dozreg-toplud Nov 4, 2025
4b7cabd
ska: direct programs road promotion WIP
dozreg-toplud Nov 4, 2025
93eecb5
Merge branch 'develop' into dozreg/ska-integrate-409-2
dozreg-toplud Nov 12, 2025
5a1e477
ska: check formula-formula for crashing
dozreg-toplud Nov 12, 2025
add83be
ska: bugfixes
dozreg-toplud Nov 12, 2025
96c40a9
ska: skip %2 formula-formula compilation/execution if it is safe to d…
dozreg-toplud Nov 13, 2025
5855673
Merge branch 'develop' into dozreg/ska-integrate-409-2
dozreg-toplud Nov 13, 2025
32de749
ska: search parent roads for code (not tested)
dozreg-toplud Nov 13, 2025
bb01d2f
ska: bail harder
dozreg-toplud Nov 15, 2025
340a59f
jets: preserve old map if put:by nooped
dozreg-toplud Nov 16, 2025
dafec28
ska: refactor direct.c, assert harder
dozreg-toplud Nov 16, 2025
bf7516a
jets: cleanup, assertion
dozreg-toplud Nov 16, 2025
13aa1c6
ska: don't forget to free bells
dozreg-toplud Nov 16, 2025
a0da1e9
ska: assert & use read-only nature of SKA programs
dozreg-toplud Nov 16, 2025
da8c87e
ska: cleanup
dozreg-toplud Nov 16, 2025
e9cab1d
ska: EOF
dozreg-toplud Nov 16, 2025
83f3171
jets: comment
dozreg-toplud Nov 16, 2025
ebb2968
ci: use LFS
dozreg-toplud Nov 16, 2025
4810044
ska: ream pointers in u3n_dire, don't forget to take stuff
dozreg-toplud Nov 17, 2025
724c2cf
ska: simple migration
dozreg-toplud Nov 17, 2025
5a527bb
ska: free bytecode properly during nock bytecode migration
dozreg-toplud Nov 17, 2025
66d476f
ska: EOF
dozreg-toplud Nov 17, 2025
e9d111e
Merge branch 'develop' into dozreg/ska-integrate-409-2
dozreg-toplud Nov 24, 2025
8df1f92
cleanup
dozreg-toplud Nov 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg/noun/ska_core.c filter=lfs diff=lfs merge=lfs -text
pkg/noun/ska_core_verb.c filter=lfs diff=lfs merge=lfs -text
2 changes: 2 additions & 0 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
# BUILD AND TEST
#
- uses: actions/checkout@v3
with:
lfs: true

- name: Set swap space
run: |
Expand Down
1 change: 1 addition & 0 deletions pkg/c3/motes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,7 @@
# define c3__site c3_s4('s','i','t','e')
# define c3__sith c3_s4('s','i','t','h')
# define c3__size c3_s4('s','i','z','e')
# define c3__ska c3_s3('s','k','a')
# define c3__slam c3_s4('s','l','a','m')
# define c3__slap c3_s4('s','l','a','p')
# define c3__slat c3_s4('s','l','a','t')
Expand Down
1 change: 1 addition & 0 deletions pkg/noun/allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,7 @@ u3a_rewrite_compact(void)
u3a_relocate_noun(&(u3R->pro.day));
u3a_relocate_noun(&(u3R->pro.trace));
u3a_relocate_noun(&(u3R->tim));
u3a_relocate_noun(&(u3R->dir_ka));
u3h_relocate(&(u3R->cax.har_p));
u3h_relocate(&(u3R->cax.per_p));
u3h_relocate(&(u3R->lop_p));
Expand Down
10 changes: 9 additions & 1 deletion pkg/noun/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,15 @@ STATIC_ASSERT( u3a_vits <= u3a_min_log,
u3p(u3h_root) lop_p; // %loop hint set
u3_noun tim; // list of absolute deadlines

c3_w fut_w[28]; // futureproof buffer
/* ska-related things
** XX move to appropriate places with an actual migration
*/
u3p(u3h_root) jed_pax_p; // [path axis] -> arm jet (home road only)
u3p(u3h_root) byc_dar_p; // [less fol]->post of bytecode
u3p(u3h_root) byc_lar_p; // fol->(list [less post]) of bytecode
u3_noun dir_ka; // ~ | +ka core vase XX raw noun

c3_w fut_w[24]; // futureproof buffer

struct { // escape buffer
union {
Expand Down
11 changes: 10 additions & 1 deletion pkg/noun/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ pub fn build(b: *std.Build) !void {

const c_source_files = [_][]const u8{
"allocate.c",
"direct.c",
"events.c",
"hashtable.c",
"imprison.c",
Expand Down Expand Up @@ -399,10 +400,13 @@ const c_source_files = [_][]const u8{
"manage.c",
"palloc.c",
"nock.c",
"nock_migrate/v2.c",
"options.c",
"retrieve.c",
"ship.c",
"serial.c",
"ship.c",
"ska_core.c",
"ska_core_verb.c",
"trace.c",
"urth.c",
"vortex.c",
Expand All @@ -412,6 +416,7 @@ const c_source_files = [_][]const u8{

const install_headers = [_][]const u8{
"allocate.h",
"direct.h",
"error.h",
"events.h",
"hashtable.h",
Expand All @@ -423,11 +428,15 @@ const install_headers = [_][]const u8{
"log.h",
"manage.h",
"nock.h",
"nock_migrate.h",
"nock_migrate/v2.h",
"noun.h",
"options.h",
"retrieve.h",
"serial.h",
"ship.h",
"ska_core.h",
"ska_core_verb.h",
"trace.h",
"types.h",
"urth.h",
Expand Down
225 changes: 225 additions & 0 deletions pkg/noun/direct.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
/// @file

#include "direct.h"

static inline c3_o
_assert_loob(u3_noun som)
{
u3_assert(som <= 1);
return som;
}

// RETAINS
//
static void
_ca_rip(u3_noun cape, u3_noun* l, u3_noun* r)
{
if ( c3y == u3ud(cape) )
{
*l = *r = _assert_loob(cape);
}
else
{
u3r_cell(cape, l, r);
}
}

// RETAINS arguments
// (here it is ok since deduplication will always happen on each iteration, so
// inductive argument of validity of uncounted refs applies)
//
static c3_o
_so_huge(u3_noun cape_one,
u3_noun data_one,
u3_noun cape_two,
u3_noun data_two)
{
if ( c3y == u3r_sing(cape_one, cape_two)
&& c3y == u3r_sing(data_one, data_two) )
{
return c3y;
}

if ( c3y == u3ud(data_one) )
{
if ( c3n == _assert_loob(cape_one) ) return c3y;
return c3a(u3ud(cape_two),
c3a(_assert_loob(cape_two),
u3r_sing(data_one, data_two)));
}

u3_assert(c3n != cape_one);

if ( c3y == u3ud(data_two) )
{
_assert_loob(cape_two);
return c3n;
}

u3_noun lope, rope, loop, roop;
u3_noun l_data_one, r_data_one;
u3_noun l_data_two, r_data_two;

u3r_cell(data_one, &l_data_one, &r_data_one);
u3r_cell(data_two, &l_data_two, &r_data_two);

_ca_rip(cape_one, &lope, &rope);
_ca_rip(cape_two, &loop, &roop);

return c3a(_so_huge(lope, l_data_one, loop, l_data_two),
_so_huge(rope, r_data_one, roop, r_data_two));
}

void
u3d_prep_ka()
{
if ( u3R->dir_ka ) {
return;
}
// [sock=hoon soak=hoon noir=hoon skan=hoon]
//
// u3_noun hoons = u3s_cue_bytes((c3_d)u3_Ka_core_len, u3_Ka_core);
u3_noun hoons = u3s_cue_bytes((c3_d)u3_Ka_core_verb_len, u3_Ka_core_verb);
u3_noun sock, soak, noir, skan;
if ( c3n == u3r_mean(hoons,
2, &sock,
6, &soak,
14, &noir,
15, &skan, 0) ) {
u3m_bail(c3__fail);
}

u3_noun bild = u3v_wish("!>(..zuse)");
u3_noun slap = u3v_wish("slap");

bild = u3n_slam_on(u3k(slap), u3nc(bild, u3k(sock)));
bild = u3n_slam_on(u3k(slap), u3nc(bild, u3k(soak)));
bild = u3n_slam_on(u3k(slap), u3nc(bild, u3k(noir)));
bild = u3n_slam_on(u3k(slap), u3nc(bild, u3k(skan)));

u3_noun ka = u3n_slam_on(slap,
u3nc(bild, u3nt(c3__wing, c3_s2('k', 'a'), u3_nul)));

u3z(hoons);
u3R->dir_ka = ka;
}

// XX: reentrance?
//
static void
_d_rout(u3_noun sub, u3_noun fol)
{
// ( [%wing p=~[%rout]] )
//
u3_noun gen = u3nt(c3__wing, c3_s4('r','o','u','t'), u3_nul),
rout = u3dc("slap", u3R->dir_ka, gen);

u3_noun typ = u3nt(c3__cell, c3__noun, c3__noun);
u3_noun sam = u3nt(typ, sub, fol); // !>([sub=* fol=*])

u3_noun slam = u3v_wish("slam");
u3_noun gul = u3nt(u3nc(1, 0), u3nc(0, 0), 0); // |~(^ ~)

u3_noun pro = u3n_slam_et(gul, slam, u3nc(rout, sam));

u3_assert(_(u3du(pro)));
if ( 0 != u3h(pro) )
{
u3m_bail(c3__fail);
}
u3R->dir_ka = u3k(u3t(pro));
u3z(pro);
}

// RETAINS
// `list` is (list pro=[sock *])
//
u3_weak
u3d_match_sock(u3_noun cape, u3_noun data, u3_noun list)
{
u3_weak pro = u3_none;
u3_noun cape_max, data_max;
u3_noun i, cape_i, data_i;
while ( u3_nul != list )
{
u3x_cell(list, &i, &list);
u3x_mean(i, 4, &cape_i,
5, &data_i,
0);
if ( c3n == _so_huge(cape_i, data_i, cape, data) ) continue;
// first match or better match
//
if ( (u3_none == pro)
|| (c3y == _so_huge(cape_max, data_max, cape_i, data_i)) )
{
pro = i;
cape_max = cape_i;
data_max = data_i;
}
}
return pro;
}

static u3_noun
_d_get_boil()
{
u3_noun gul = u3nt(u3nc(1, 0), u3nc(0, 0), 0); // |~(^ ~)
u3_noun slap = u3v_wish("slap");

// ( [%wing p=~[%lon]] )
//
u3_noun gen = u3nt(c3__wing, c3_s3('l','o','n'), u3_nul);
u3_noun vax = u3n_slam_on(u3k(slap), u3nc(u3k(u3R->dir_ka), gen));
u3_noun lon = u3k(u3t(vax));
u3z(vax);

// ( [%wing p=~[%cook]] )
//
gen = u3nt(c3__wing, c3__cook, u3_nul);
vax = u3n_slam_on(slap, u3nc(u3k(u3R->dir_ka), gen));
u3_noun gat = u3k(u3t(vax));
u3z(vax);

u3_noun pro = u3n_slam_et(gul, gat, lon);
u3_assert(_(u3du(pro)));
if ( 0 != u3h(pro) )
{
u3m_bail(c3__fail);
}

u3_noun boil = u3k(u3t(pro));
u3z(pro);
return boil;
}

// RETAINS arguments
// XX remove u3dc, use hard-coded axes
//
u3n_prog*
u3d_search(u3_noun sub, u3_noun fol)
{
u3d_prep_ka();

u3n_prog* pog_u = u3n_look_direct(sub, fol);
if ( pog_u ) return pog_u;

u3_noun cole, code, fols;
u3_noun boil = _d_get_boil();
u3_assert( c3y == u3r_mean(boil, 2, &cole, 6, &code, 7, &fols, 0) );

u3_noun lit = u3kdb_get(u3k(fols), u3k(fol));
if (u3_none == lit || u3_none == u3d_match_sock(c3y, sub, lit))
{
u3z(boil);
_d_rout(u3k(sub), u3k(fol));
boil = _d_get_boil();

u3_assert( c3y == u3r_mean(boil, 2, &cole, 6, &code, 7, &fols, 0) );
}
// may be u3_none
//
u3z(lit);
pog_u = u3n_build_direct(sub, fol, cole, code, fols);
u3z(boil);
return pog_u;
}
22 changes: 22 additions & 0 deletions pkg/noun/direct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef U3_DIRECT_H
#define U3_DIRECT_H

#include "error.h"
#include "hashtable.h"
#include "manage.h"
#include "nock.h"
#include "retrieve.h"
#include "serial.h"
#include "ska_core.h"
#include "ska_core_verb.h"
#include "vortex.h"
#include "xtract.h"
#include "jets/k.h"

u3n_prog*
u3d_search(u3_noun sub, u3_noun fol);

u3_weak
u3d_match_sock(u3_noun cape, u3_noun data, u3_noun list);

#endif /* ifndef U3_DIRECT_H */
17 changes: 17 additions & 0 deletions pkg/noun/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,23 @@ u3h_put(u3p(u3h_root) har_p, u3_noun key, u3_noun val)
}
}

/* u3h_jib(): update a hashtable value
**
** `key` is RETAINED
** `fun_f` must transfer the noun argument
** XX make it in-place?
*/
void
u3h_jib(u3p(u3h_root) har_p,
u3_noun key,
u3_noun(*fun_f)(u3_weak, void*),
void* ptr_v)
{
u3h_put(har_p,
key,
fun_f(u3h_get(har_p, key), ptr_v));
}

/* _ch_buck_del(): delete from bucket
*/
static c3_o
Expand Down
12 changes: 12 additions & 0 deletions pkg/noun/hashtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@
*/
void
u3h_put(u3p(u3h_root) har_p, u3_noun key, u3_noun val);

/* u3h_jib(): update a hashtable value or insert `val`
**
** `key` is RETAINED
** `fun_f` must transfer the noun argument
** XX make it in-place?
*/
void
u3h_jib(u3p(u3h_root) har_p,
u3_noun key,
u3_noun(*fun_f)(u3_weak, void*),
void* ptr_v);

/* u3h_put_get(): insert in caching hashtable, returning deleted entry
**
Expand Down
Loading