Beispiel #1
0
/* u2_bn_hook():
**
**   Execute hook from core.
*/
u2_noun
u2_bn_hook(u2_wire     wir_r,
           u2_noun     cor,
           const c3_c* tam_c)
{
  u2_weak vib = u2_ds_look(wir_r, cor, tam_c);

  if ( u2_none == vib ) {
    fprintf(stderr, "no hook: %s\n", tam_c);
    c3_assert(0);
    return u2_bl_bail(wir_r, c3__fail);
  } else {
    if ( u2_nul == u2_h(vib) ) {
      u2_noun rag = u2_frag(u2_t(vib), cor);

      // printf("%s %d\n", tam_c, u2_t(vib));
      u2_rz(wir_r, vib);

      return u2_rx(wir_r, rag);
    }
    else {
      u2_noun ret = u2_bn_nock(wir_r, cor, vib);

      u2_rz(wir_r, vib);
      return ret;
    }
  }
}
Beispiel #2
0
  u2_weak                                                         //  produce
  j2_mb(Pt5, shas)(u2_wire wir_r, 
                   u2_noun cor)                                    //  retain
  {
    u2_noun sal, ruz;

    if ( (u2_none == (sal = u2_frag(u2_cv_sam_2, cor))) ||
         (u2_none == (ruz = u2_frag(u2_cv_sam_3, cor))) ||
         (u2_no == u2_stud(sal)) ||
         (u2_no == u2_stud(ruz)) ) 
    {
      return u2_bl_bail(wir_r, c3__exit);
    } else {
      return j2_mbc(Pt5, shas)(wir_r, sal, ruz);
    }
  }
  u2_weak                                                         //  produce
  j2_mb(Pt5, shal)(u2_wire wir_r,
                   u2_noun cor)                                   //  retain
  {
    u2_noun a, b;

    if ( (u2_none == (a = u2_frag(u2_cv_sam_2, cor))) ||
         (u2_none == (b = u2_frag(u2_cv_sam_3, cor))) ||
         (u2_no == u2_stud(a)) ||
         (u2_no == u2_fly_is_cat(a)) ||
         (u2_no == u2_stud(b)) )
    {
      return u2_bl_bail(wir_r, c3__exit);
    } else {
      return j2_mbc(Pt5, shal)(wir_r, a, b);
    }
  }
Beispiel #4
0
  u2_weak                                                         //  produce
  j2_mb(Pt5, repg)(u2_wire wir_r,
                   u2_noun cor)                                   //  retain
  {
    u2_noun lub;
    u2_noun rad;
    u2_noun rep;

    if ( (u2_none == (lub = u2_frag(u2_cv_sam_2, cor))) ||
         (u2_none == (rad = u2_frag(u2_cv_sam_6, cor))) ||
         (u2_none == (rep = u2_frag(u2_cv_sam_7, cor))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mbc(Pt5, repg)(wir_r, lub, rad, rep);
    }
  }
Beispiel #5
0
/* u2_bi_frag():
**
**   Return fragment (a) of (b).
*/
u2_noun
u2_bi_frag(u2_ray  wir_r,
           u2_atom a,
           u2_noun b)
{
  u2_weak c = u2_frag(a, b);

  if ( u2_none == c ) {
    return u2_bl_bail(wir_r, c3__exit);
  } else return c;
}
  u2_weak                                                         //  transfer
  j2_mb(Pt2, flop)(u2_wire wir_r,
                   u2_noun cor)                                   //  retain
  {
    u2_noun a;

    if ( u2_none == (a = u2_frag(u2_cv_sam, cor)) ) {
      return u2_bl_bail(wir_r, c3__exit);
    } else {
      return j2_mbc(Pt2, flop)(wir_r, a);
    }
  }
Beispiel #7
0
  u2_weak
  j2_mck(Pt6, ut, moot)(u2_wire wir_r,
                        u2_noun cor)
  {
    u2_noun sut;

    if ( (u2_none == (sut = u2_frag(u2_cv_sam, cor))) ) {
      return u2_none;
    } else {
      return u2_rx(wir_r, sut);
    }
  }
/* logic
*/
  u2_bean                                                         //  transfer
  j2_mcx(Pt6, ut, park)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain
                        u2_noun way,                              //  retain
                        u2_atom axe)                              //  retain
  {
    if ( u2_no == u2_dust(sut) || c3__core != u2_h(sut) ) {
      return u2_bl_bail(wir_r, c3__fail);
    }
    // else if ( u2_no == u2_bn_hook(wir_r, van, "vet") ) {
    else if ( u2_no == u2_frag(j2_ut_van_vet, van) ) {
      return u2_yes;
    }
    else {
      u2_noun p_sut, q_sut, pq_sut;

      u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      u2_bi_cell(wir_r, q_sut, &pq_sut, 0);

      if ( c3__both == way ) {
        if ( c3__gold == pq_sut ) {
          return u2_yes;
        } else return u2_no;
      }
      if ( c3__read == way ) {
        switch ( pq_sut ) {
          default: return u2_bl_bail(wir_r, c3__fail);

          case c3__gold: return u2_yes;
          case c3__lead: return u2_no;
          case c3__iron: return u2_no;
          case c3__zinc: return
                          u2_and(u2_not(u2_sing(_1, axe)),
                                 u2_sing(_2, j2_mbc(Pt3, cap)(wir_r, axe)));
        }
      }
      else if ( c3__rite == way ) {
        switch ( pq_sut ) {
          default: return u2_bl_bail(wir_r, c3__fail);

          case c3__gold: return u2_yes;
          case c3__lead: return u2_no;
          case c3__iron: return
                          u2_and(u2_not(u2_sing(_1, axe)),
                                 u2_sing(_2, j2_mbc(Pt3, cap)(wir_r, axe)));
          case c3__zinc: return u2_no;
        }
      }
      else if ( c3__free == way ) { return u2_yes; }
      else return u2_bl_bail(wir_r, c3__fail);
    }
  }
Beispiel #9
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, repo)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut;

    if ( u2_none == (sut = u2_frag(u2_cv_sam, cor)) ) {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcy(Pt6, ut, repo)(wir_r, cor, sut);
    }
  }
/* functions
*/
  u2_weak                                                         //  transfer
  j2_mb(Pt3, mug)(u2_wire wir_r,
                  u2_noun cor)                                    //  retain
  {
    u2_noun sam;

    if ( u2_none == (sam = u2_frag(u2_cv_sam, cor)) ) {
      return u2_bl_bail(wir_r, c3__exit);
    } else {
      return u2_mug(sam);
    }
  }
Beispiel #11
0
  u2_noun                                                         //  transfer
  j2_mb(Pt5, mat)(u2_wire wir_r, 
                  u2_noun cor)                                    //  retain
  {
    u2_noun a;

    if ( (u2_none == (a = u2_frag(u2_cw_sam, cor))) ) {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mby(Pt5, mat)(wir_r, a);
    }
  }
Beispiel #12
0
  static u2_flag
  _mint_vet(u2_wire wir_r, 
            u2_noun van)
  {
    // u2_flag vet = u2_bn_hook(wir_r, van, "vet");
    u2_flag vet = u2_frag(j2_ut_van_vet, van);

    switch ( vet ) {
      case u2_no: 
      case u2_yes: return vet;
      default: return u2_bl_bail(wir_r, c3__fail); 
    }
  }
Beispiel #13
0
/* structures
*/
  u2_weak
  j2_mck(Pt6, ut, mint)(u2_wire wir_r,
                        u2_noun cor)
  {
    u2_noun sut, gol, gen, van;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, 
                                u2_cw_sam_2, &gol, 
                                u2_cw_sam_3, &gen,
                                0)) ||
         (u2_none == (sut = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      u2_noun vrf = u2_frag(j2_ut_van_vrf, van);

      return u2_rq(wir_r, u2_rx(wir_r, vrf),
                          u2_rx(wir_r, sut),
                          u2_rx(wir_r, gol),
                          u2_rx(wir_r, gen));
    }
  }
Beispiel #14
0
  u2_weak
  j2_mck(Pt6, ut, nest)(u2_wire wir_r,
                        u2_noun cor)
  {
    u2_noun sut, ref, van;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, u2_cw_sam, &ref, 0)) ||
         (u2_none == (sut = u2_frag(u2_cw_sam, van))) )
    {
      return u2_none;
    } else {
      return u2_rc(wir_r, u2_rx(wir_r, sut), u2_rx(wir_r, ref));
    }
  }
Beispiel #15
0
  u2_noun                                                         //  produce
  j2_mc(Pt5, mask, fun)(u2_wire wir_r, 
                        u2_noun cor)                              //  retain
  {
    u2_noun van, bud, tub;

    if ( (u2_no == u2_mean(cor, u2_cv_sam, &tub, u2_cv_con, &van, 0)) ||
         (u2_none == (bud = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt5, mask, fun)(wir_r, bud, tub);
    }
  }
Beispiel #16
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, fuse)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, ref, van;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, u2_cw_sam, &ref, 0)) ||
         (u2_none == (sut = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, fuse)(wir_r, van, sut, ref);
    }
  }
Beispiel #17
0
  u2_weak                                                         //  produce
  j2_mb(Pt5, shax)(u2_wire wir_r, 
                  u2_noun cor)                                    //  retain
  {
    u2_noun a;

    if ( (u2_none == (a = u2_frag(u2_cv_sam, cor))) ||
         (u2_no == u2_stud(a)) ) 
    {
      return u2_bl_bail(wir_r, c3__exit);
    } else {
      return j2_mbc(Pt5, shax)(wir_r, a);
    }
  }
Beispiel #18
0
  u2_weak                                                         //  transfer
  j2_mb(Pt1, dec)(u2_wire wir_r, 
                  u2_noun cor)                                    //  retain
  {
    u2_noun a;

    if ( (u2_none == (a = u2_frag(u2_cw_sam, cor))) ||
         (u2_no == u2_stud(a)) ) 
    {
      return u2_none;
    } else {
      return j2_mbc(Pt1, dec)(wir_r, a);
    }
  }
Beispiel #19
0
  u2_weak
  j2_mck(Pt6, ut, bust)(u2_wire wir_r,
                        u2_noun cor)
  {
    u2_noun sut, dib, van;

    if ( (u2_no == u2_mean(cor, u2_cv_sam, &dib, u2_cv_con, &van, 0)) ||
         (u2_none == (sut = u2_frag(u2_cv_sam, van))) )
    {
      return u2_none;
    } else {
      return u2_rc(wir_r, u2_rx(wir_r, sut), u2_rx(wir_r, dib));
    }
  }
Beispiel #20
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, bust)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, dib, van;

    if ( (u2_no == u2_mean(cor, u2_cv_sam, &dib, u2_cv_con, &van, 0)) ||
         (u2_none == (sut = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, bust)(wir_r, van, sut, dib);
    }
  }
Beispiel #21
0
  u2_noun                                                         //  produce
  j2_mc(Pt5, stew, fun)(u2_wire wir_r, 
                        u2_noun cor)                              //  retain
  {
    u2_noun con, hel, tub;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &con, u2_cw_sam, &tub, 0)) ||
         (u2_none == (hel = u2_frag(3, con))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt5, stew, fun)(wir_r, hel, tub);
    }
  }
Beispiel #22
0
  u2_noun                                                         //  produce
  j2_mc(Pt5, shim, fun)(u2_wire wir_r, 
                        u2_noun cor)                              //  retain
  {
    u2_noun van, zep, tub;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, u2_cw_sam, &tub, 0)) ||
         (u2_none == (zep = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt5, shim, fun)(wir_r, zep, tub);
    }
  }
Beispiel #23
0
  u2_noun                                                         //  produce
  j2_mc(Pt5, glue, fun)(u2_wire wir_r, 
                        u2_noun cor)                              //  retain
  {
    u2_noun van, bus, vex, sab;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, 
                                u2_cw_sam_2, &vex,
                                u2_cw_sam_3, &sab, 0)) ||
         (u2_none == (bus = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt5, glue, fun)(wir_r, bus, vex, sab);
    }
  }
Beispiel #24
0
  u2_noun                                                         //  produce
  j2_mc(Pt5, comp, fun)(u2_wire wir_r, 
                        u2_noun cor)                              //  retain
  {
    u2_noun van, raq, vex, sab;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &vex,
                                u2_cv_sam_3, &sab,
                                u2_cv_con, &van, 0)) ||
         (u2_none == (raq = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt5, comp, fun)(wir_r, raq, vex, sab);
    }
  }
Beispiel #25
0
/* logic
*/
  u2_bean                                                         //  transfer
  j2_mcx(Pt6, ut, conk)(u2_wire wir_r, 
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain
                        u2_noun got)                              //  retain
  {
    if ( u2_yes == u2ud(got) ) {
      return j2_mby(Pt6, face)(wir_r, got, sut);
    }
    else switch ( u2h(got) ) {
      default: return u2_cm_bail(c3__fail);

      case 0: {
        return u2k(sut);
      }
      case 1: {
        return j2_mby(Pt6, face)
          (wir_r, u2h(u2t(got)), 
                 j2_mcx(Pt6, ut, conk)(wir_r, van, sut, u2t(u2t(got))));
      }
      case 2: {
        u2_bean vet = u2_frag(j2_ut_van_vet, van); 
        u2_noun hed, tal, ret;

        if ( u2_yes == vet ) {
          u2_noun cel = u2nt(c3__cell, c3__noun, c3__noun);
          
          if ( u2_no == j2_mcy(Pt6, ut, nest)(wir_r, van, cel, u2_yes, sut) ) {
            return u2_bl_bail(wir_r, c3__fail);
          }
          u2z(cel);
        }
        hed = j2_mcy(Pt6, ut, peek)(wir_r, van, sut, c3__both, 2);
        tal = j2_mcy(Pt6, ut, peek)(wir_r, van, sut, c3__both, 3);

        ret = j2_mby(Pt6, cell)
          (wir_r, 
           j2_mcx(Pt6, ut, conk)(wir_r, van, hed, u2h(u2t(got))),
           j2_mcx(Pt6, ut, conk)(wir_r, van, tal, u2t(u2t(got))));

        u2z(hed);
        u2z(tal);

        return ret;
      }
    }
  }
Beispiel #26
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, tack)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun van, sut, peh, mur;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &peh, 
                                u2_cv_sam_3, &mur,
                                u2_cv_con, &van, 
                                0)) ||
         (u2_none == (sut = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, tack)(wir_r, van, sut, peh, mur);
    }
  }
Beispiel #27
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, swab)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun van, sut, men, har;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, 
                                u2_cw_sam_2, &men, 
                                u2_cw_sam_3, &har,
                                0)) ||
         (u2_none == (sut = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, swab)(wir_r, van, sut, men, har);
    }
  }
Beispiel #28
0
  u2_noun                                                         //  produce
  j2_mc(Pt6, ut, mint)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, gol, gen, van;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, 
                                u2_cw_sam_2, &gol, 
                                u2_cw_sam_3, &gen,
                                0)) ||
         (u2_none == (sut = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, mint)(wir_r, van, sut, gol, gen);
    }
  }
Beispiel #29
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, seek)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, way, hyp, van;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &way, 
                                u2_cv_sam_3, &hyp, 
                                u2_cv_con, &van, 
                                0)) ||
         (u2_none == (sut = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, seek)(wir_r, van, sut, way, hyp);
    }
  }
Beispiel #30
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, fink)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, dep, way, cog, van;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &dep, 
                                u2_cv_sam_6, &way, 
                                u2_cv_sam_7, &cog, 
                                u2_cv_con, &van, 
                                0)) ||
         (u2_none == (sut = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, fink)(wir_r, van, sut, dep, way, cog);
    }
  }