summaryrefslogtreecommitdiff
path: root/vere/pkg/noun/jets/e/jam.c
blob: 2291bc0ac0b25b318448e2dec5dc5ec3159a97eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/// @file

#include "jets/k.h"
#include "jets/q.h"
#include "jets/w.h"

#include "noun.h"

u3_noun
u3qe_jam(u3_atom a)
{
#if 0
  if (c3y == u3du(a) && 1337 == u3h(a)) {
    c3_w siz_w, tot_w = 0;
    u3_noun som;
    for ( som = u3t(a); c3y == u3du(som); som = u3t(som) ) {
      siz_w = u3a_count_noun(u3h(som));
      tot_w += siz_w;
      if ( 0 == siz_w ) {
        u3l_log("item: B/0");
      }
      else {
        u3a_print_memory(stderr, "item", siz_w);
      }
    }
    if ( u3_blip != som ) {
      u3l_log("forgot to terminate list!");
    }
    c3_w mem_w = u3h_count(u3R->cax.har_p);

    for ( som = u3t(a); c3y == u3du(som); som = u3t(som) ) u3a_discount_noun(u3h(som));
    u3h_discount(u3R->cax.har_p);

    u3a_print_memory(stderr, "total", tot_w);
    u3a_print_memory(stderr, "memoization cache", mem_w);
    u3h_root* har_u = u3to(u3h_root, u3R->cax.har_p);
    u3l_log("memoization entries: %d", har_u->use_w);
		u3a_print_memory(stderr, "unused free", u3a_open(u3R));
    return tot_w;
  }
#endif

  u3i_slab sab_u;
  u3s_jam_fib(&sab_u, a);
  return u3i_slab_mint(&sab_u);
}

u3_noun
u3we_jam(u3_noun cor)
{
  return u3qe_jam(u3x_at(u3x_sam, cor));
}

u3_atom
u3ke_jam(u3_noun a)
{
  u3_atom b = u3qe_jam(a);
  u3z(a);
  return b;
}