summaryrefslogtreecommitdiff
path: root/vere/pkg/noun/nock.c
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-07 02:24:42 +0700
committerpolwex <polwex@sortug.com>2025-10-07 02:24:42 +0700
commitca8a67a583ad39bdb4cf36d635536e099af21bdf (patch)
treea61661da51a9e03c970a6d280fd39ba4044badd7 /vere/pkg/noun/nock.c
parent23a57eed38d560f0c2d84cc7803fafc74dbcc1dd (diff)
solved NOCK issue, fucking bytecode man. but solid pill working!!
Diffstat (limited to 'vere/pkg/noun/nock.c')
-rw-r--r--vere/pkg/noun/nock.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/vere/pkg/noun/nock.c b/vere/pkg/noun/nock.c
index eef211b..87fcf2c 100644
--- a/vere/pkg/noun/nock.c
+++ b/vere/pkg/noun/nock.c
@@ -22,7 +22,7 @@
// along with some other debugging info
# undef VERBOSE_BYTECODE
-#if 0
+#if 1
// Retained for debugging purposes.
static u3_noun _n_nock_on(u3_noun bus, u3_noun fol);
@@ -118,7 +118,7 @@ _n_hint(u3_noun zep,
case c3__memo: {
u3z(hod);
-#if 0
+#if 1
return _n_nock_on(bus, nex);
#else
{
@@ -168,9 +168,9 @@ _n_nock_on(u3_noun bus, u3_noun fol)
u3R->pro.nox_d += 1;
#endif
- // Trace first 30 opcodes
+ // Trace first 200 opcodes
static c3_w opcode_count = 0;
- if ( opcode_count < 30 ) {
+ if ( opcode_count < 200 ) {
if ( c3y == u3du(hib) ) {
u3l_log("[C-Nock:%u] cell-cell formula", opcode_count);
} else {
@@ -213,8 +213,29 @@ _n_nock_on(u3_noun bus, u3_noun fol)
u3_assert(!"not reached");
case 2: {
- u3_noun nex = _n_nock_on(u3k(bus), u3k(u3t(gal)));
- u3_noun seb = _n_nock_on(bus, u3k(u3h(gal)));
+ static c3_w op2_debug = 0;
+ u3_noun c_gal = u3t(gal);
+ u3_noun b_gal = u3h(gal);
+
+ if (op2_debug == 0) {
+ u3l_log("[Op2 Debug] Computing formula (tail gal):");
+ u3l_log(" c_gal mug: 0x%x", u3r_mug(c_gal));
+ }
+
+ u3_noun nex = _n_nock_on(u3k(bus), u3k(c_gal));
+
+ if (op2_debug == 0) {
+ u3l_log(" nex mug: 0x%x", u3r_mug(nex));
+ u3l_log("[Op2 Debug] Computing subject (head gal):");
+ u3l_log(" b_gal mug: 0x%x", u3r_mug(b_gal));
+ }
+
+ u3_noun seb = _n_nock_on(bus, u3k(b_gal));
+
+ if (op2_debug == 0) {
+ u3l_log(" seb mug: 0x%x", u3r_mug(seb));
+ op2_debug = 1;
+ }
u3a_lose(fol);
bus = seb;
@@ -372,35 +393,15 @@ _n_nock_on(u3_noun bus, u3_noun fol)
}
case 11: {
- u3_noun ref = _n_nock_on(u3k(bus), u3k(u3h(gal)));
- u3_noun gof = _n_nock_on(bus, u3k(u3t(gal)));
- u3_noun val;
-
- u3t_off(noc_o);
- val = u3m_soft_esc(u3k(ref), u3k(gof));
- u3t_on(noc_o);
-
- if ( !_(u3du(val)) ) {
- u3m_bail(u3nt(1, gof, 0));
- }
- if ( !_(u3du(u3t(val))) ) {
- //
- // replace with proper error stack push
- //
- u3t_push(u3nt(c3__hunk, ref, gof));
- return u3m_bail(c3__exit);
- }
- else {
- u3_noun pro;
-
- u3z(ref);
- u3z(gof);
- u3z(fol);
- pro = u3k(u3t(u3t(val)));
- u3z(val);
+ // Simplified opcode 11: just ignore the hint and evaluate q_gal
+ // This matches OCaml's implementation
+ u3_noun q_gal = u3t(gal);
+ u3_noun pro;
- return pro;
- }
+ // Ignore the hint (head of gal), just evaluate q_gal
+ pro = _n_nock_on(bus, u3k(q_gal));
+ u3a_lose(fol);
+ return pro;
}
u3_assert(!"not reached");
}