Example #1
0
  u2_weak                                                         //  transfer
  j2_mci(Pt6, ut, tack)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain
                        u2_noun peh,                              //  retain
                        u2_noun mur)                              //  retain
  {
    u2_weak hoc = u2_ds_look(wir_r, van, "tack");

    if ( u2_none == hoc ) {
      c3_assert(!"register tack");
      return u2_none;
    } else {
      u2_weak von = u2_rl_molt(wir_r, van, u2_cv_sam, u2_rx(wir_r, sut), 0);
      u2_weak gat = u2_nk_soft(wir_r, von, hoc);
      u2_weak cor = u2_rl_molt(wir_r, gat, u2_cv_sam_2, u2_rx(wir_r, peh), 
                                           u2_cv_sam_3, u2_rx(wir_r, mur),
                                           0);

      if ( (u2_none == j2_mcj(Pt6, ut, tack)[0].xip) ) {
        u2_noun xip = u2_ds_find(wir_r, cor);
     
        c3_assert(u2_none != xip);
        j2_mcj(Pt6, ut, tack)[0].xip = xip;
      }
      u2_rl_lose(wir_r, gat);
      return cor;
    }
  }
Example #2
0
  u2_weak                                                         //  transfer
  j2_mci(Pt6, ut, fink)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain 
                        u2_noun dep,                              //  retain
                        u2_noun way,                              //  retain
                        u2_noun cog)                              //  retain
  {
    u2_weak hoc = u2_ds_look(wir_r, van, "fink");

    if ( u2_none == hoc ) {
      c3_assert(!"register fink");
      return u2_none;
    } else {
      u2_weak von = u2_rl_molt(wir_r, van, u2_cv_sam, u2_rx(wir_r, sut), 0);
      u2_weak gat = u2_nk_soft(wir_r, von, hoc);
      u2_weak cor = u2_rl_molt(wir_r, gat, 
                                      u2_cv_sam_2, u2_rx(wir_r, dep), 
                                      u2_cv_sam_6, u2_rx(wir_r, way), 
                                      u2_cv_sam_7, u2_rx(wir_r, cog), 
                                      0);

      if ( (u2_none == j2_mcj(Pt6, ut, fink)[0].xip) ) {
        u2_noun xip = u2_ds_find(wir_r, cor);
     
        c3_assert(u2_none != xip);
        j2_mcj(Pt6, ut, fink)[0].xip = xip;
      }
      u2_rl_lose(wir_r, gat);
      return cor;
    }
  }
Example #3
0
  u2_weak                                                         //  transfer
  j2_mci(Pt6, ut, bust)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain 
                        u2_noun dib)                              //  retain
  {
    u2_weak hoc = u2_ds_look(wir_r, van, "bust");

    if ( u2_none == hoc ) {
      c3_assert(!"register bust");
      return u2_none;
    } else {
      u2_weak von = u2_rl_molt(wir_r, van, u2_cw_sam, u2_rx(wir_r, sut), 0);
      u2_weak gat = u2_nk_soft(wir_r, von, hoc);
      u2_weak cor = u2_rl_molt(wir_r, gat, u2_cw_sam, u2_rx(wir_r, dib), 0);

      if ( (u2_none == j2_mcj(Pt6, ut, bust)[0].xip) ) {
        u2_noun xip = u2_ds_find(wir_r, cor);
     
        c3_assert(u2_none != xip);
        j2_mcj(Pt6, ut, bust)[0].xip = xip;
      }
      u2_rl_lose(wir_r, gat);
      return cor;
    }
  }
  u2_bean
  j2_mci(Pt6, ut, park)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain
                        u2_noun way,                              //  retain
                        u2_noun axe)                              //  retain
  {
    u2_weak hoc = u2_ds_look(wir_r, van, "park");

    if ( u2_none == hoc ) {
      c3_assert(!"register park");
      return u2_none;
    } else {
      u2_weak von = u2_rl_molt(wir_r, van, u2_cv_sam, u2_rx(wir_r, sut), 0);
      u2_weak gat = u2_nk_soft(wir_r, von, hoc);
      u2_weak cor = u2_rl_molt(wir_r, gat,
                                      u2_cv_sam_2, u2_rx(wir_r, way),
                                      u2_cv_sam_3, u2_rx(wir_r, axe),
                                      0);

      if ( (u2_none == j2_mcj(Pt6, ut, park)[0].xip) ) {
        u2_noun xip = u2_ds_find(wir_r, cor);

        c3_assert(u2_none != xip);
        j2_mcj(Pt6, ut, park)[0].xip = xip;
      }
      u2_rl_lose(wir_r, gat);
      return cor;
    }
  }
Example #5
0
  u2_weak                                                         //  produce
  j2_mci(Pt6, ut, mint)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain 
                        u2_noun gol,                              //  retain
                        u2_noun gen)                              //  retain
  {
    u2_weak hoc = u2_ds_look(wir_r, van, "mint");

    if ( u2_none == hoc ) {
      c3_assert(!"register mint");
      return u2_none;
    } else {
      u2_weak von = u2_rl_molt(wir_r, van, u2_cw_sam, u2_rx(wir_r, sut), 0);
      u2_weak gat = u2_nk_soft(wir_r, von, hoc);
      u2_weak cor = u2_rl_molt(wir_r, gat, 
                                      u2_cw_sam_2, u2_rx(wir_r, gol), 
                                      u2_cw_sam_3, u2_rx(wir_r, gen), 
                                      0);

      if ( (u2_none == j2_mcj(Pt6, ut, mint)[0].xip) ) {
        u2_noun xip = u2_ds_find(wir_r, cor);
     
        c3_assert(u2_none != xip);
        j2_mcj(Pt6, ut, mint)[0].xip = xip;
      }
      u2_rl_lose(wir_r, gat);
      return cor;
    }
  }
Example #6
0
  u2_weak                                                         //  transfer
  j2_mci(Pt6, ut, cull)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain 
                        u2_flag pol,                              //  retain
                        u2_atom axe,                              //  retain
                        u2_noun ref)                              //  retain
  {
    u2_weak hoc = u2_ds_look(wir_r, van, "cull");

    if ( u2_none == hoc ) {
      c3_assert(!"register cull");
      return u2_none;
    } else {
      u2_weak von = u2_rl_molt(wir_r, van, u2_cw_sam, u2_rx(wir_r, sut), 0);
      u2_weak gat = u2_nk_soft(wir_r, von, hoc);
      u2_weak cor = u2_rl_molt(wir_r, gat, 
                                      u2_cw_sam_2, pol,
                                      u2_cw_sam_6, u2_rx(wir_r, axe), 
                                      u2_cw_sam_7, u2_rx(wir_r, ref), 
                                      0);

      if ( (u2_none == j2_mcj(Pt6, ut, cull)[0].xip) ) {
        u2_noun xip = u2_ds_find(wir_r, cor);
     
        c3_assert(u2_none != xip);
        j2_mcj(Pt6, ut, cull)[0].xip = xip;
      }
      u2_rl_lose(wir_r, gat);
      return cor;
    }
  }
Example #7
0
File: dash.c Project: MacTop/urbit
/* u2_ds_look():
**
**   Produce hook formula from core, or u2_none.
*/
u2_weak                                                           //  produce
u2_ds_look(u2_wire     wir_r,
           u2_noun     cor,                                       //  retain
           const c3_c* tam_c)                                     //  retain
{
  u2_noun xip = u2_ds_find(wir_r, cor);

  if ( u2_none == xip ) {
    return u2_none;
  }
  else {
    c3_l axe_l = _1;

    while ( 1 ) {
      u2_noun fol = _ds_leap(wir_r, xip, tam_c);

      if ( u2_none == fol ) {
        u2_noun pet = u2_t(u2_t(xip));

        if ( _0 == pet ) {
          // printf("no joy - %s\n", tam_c);
          return u2_none;
        }
        else {
          u2_axis pax = u2_h(pet);

          c3_assert(u2_fly_is_cat(pax));
          c3_assert((u2_ax_dep(axe_l) + u2_ax_dep(pax)) <= 30);

          axe_l = u2_ax_peg(axe_l, pax);
          xip = u2_t(pet);
          continue;
        }
      }
      else {
        if ( _1 != axe_l ) {
          return u2_rt(wir_r, u2_nock_flac,
                              u2_rc(wir_r, u2_nock_frag, axe_l),
                              fol);
        }
        else return fol;
      }
    }
  }
}
Example #8
0
File: nock.c Project: sillsm/urbit
/* u2_nk_kick():
**
**   Fire `gat` without changing the sample.
*/
u2_weak                                                           //  transfer
u2_nk_kick(u2_wire wir_r,
           u2_weak gat)                                           //  retain
{
    u2_noun xip;

    if ( u2_none != (xip = u2_ds_find(wir_r, gat)) ) {
        u2_noun pro = u2_ho_kick(wir_r, xip, gat, u2_cv_noc);

        return pro;
    }
    else {
        return u2_nk_nock
               (wir_r,
                u2_rx(wir_r, gat),
                u2_sh(gat));
    }
}
Example #9
0
File: nock.c Project: sillsm/urbit
/* u2_nk_mong():
**
**   Call with new convention.
*/
u2_noun                                                           //  transfer
u2_nk_mong(u2_wire wir_r,
           u2_noun gat,                                           //  retain
           u2_noun sam)                                           //  transfer
{
    u2_noun cor, xip;

    cor = u2_rc
          (wir_r,
           u2_rx(wir_r, u2_sh(gat)),
           u2_rc(wir_r, sam, u2_rx(wir_r, u2_st(u2_st(gat)))));

    if ( u2_none != (xip = u2_ds_find(wir_r, cor)) ) {
        u2_noun pro = u2_ho_kick(wir_r, xip, cor, u2_cv_noc);

        u2_rz(wir_r, cor);
        return pro;
    }
    else return u2_nk_nock(wir_r, cor, u2_sh(gat));
}
Example #10
0
File: nock.c Project: sillsm/urbit
/* nock_mool(): fast internal mink interface.  Arguments transferred.
*/
u2_noun
_nock_mool(u2_noun  bus,
           u2_noun  fol,
           u2_kode* pon)
{
    u2_noun hib, gal;

    c3_assert(u2_yes == *pon);

    while ( 1 ) {
        u2_tx_did_hop(u2_Wire, 1);

        if ( u2_no == u2du(fol) ) {
            *pon = 2;
            u2z(bus);
            u2z(fol);
            return u2_cm_wail();
        }
        else {
            hib = u2fh(fol);
            gal = u2ft(fol);
        }

        if ( u2_yes == u2du(hib) ) {
            u2_noun poz, riv;
            u2_kode h_pon = 0, t_pon = 0;

            poz = _nock_mool(u2k(bus), u2k(hib), &h_pon);
            if ( 2 == h_pon ) {
                *pon = 2;
                u2z(bus);
                u2z(fol);
                return poz;
            }

            riv = _nock_mool(bus, u2k(gal), &t_pon);
            u2z(fol);
            if ( 2 == t_pon ) {
                *pon = 2;
                u2z(poz);
                return riv;
            }

            if ( (1 == h_pon) || (1 == t_pon) ) {
                u2_noun lal;

                *pon = 1;

                if ( 0 == h_pon ) {
                    u2z(poz);
                    lal = riv;
                } else if ( 0 == t_pon ) {
                    u2z(riv);
                    lal = poz;
                } else {
                    lal = u2_ckb_weld(poz, riv);
                }
                return lal;
            }
            return u2_cn_cell(poz, riv);
        }
        else switch ( hib ) {
            default:
                *pon = 2;
                u2z(bus);
                u2z(fol);
                return u2_cm_wail();

            case 0: {
                if ( u2_no == u2_cr_ud(gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_weak pro = u2_cr_at(gal, bus);

                    if ( u2_none == pro ) {
                        *pon = 2;
                        u2z(bus);
                        u2z(fol);
                        return u2_cm_wail();
                    }
                    else {
                        pro = u2k(pro);
                        u2z(bus);
                        u2z(fol);

                        return pro;
                    }
                }
            }
            case 1: {
                u2_noun pro = u2k(gal);

                u2z(bus);
                u2z(fol);
                return pro;
            }
            c3_assert(!"not reached");

            case 2: {
                if ( (u2_no == u2du(gal)) || (u2_no == u2du(u2fh(gal))) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun neb;

                    neb = _nock_mool(bus, u2k(gal), pon);
                    u2z(fol);
                    if ( 0 != *pon ) {
                        return neb;
                    }

                    bus = u2k(u2fh(neb));
                    fol = u2k(u2ft(neb));
                    u2z(neb);
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 3: {
                u2_noun gof, pro;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                pro = u2du(gof);
                u2z(gof);

                return pro;
            }
            c3_assert(!"not reached");

            case 4: {
                u2_noun gof, pro;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                if ( u2_none == (pro = u2_rl_vint(u2_Wire, gof)) ) {
                    *pon = 2;
                    u2z(gof);
                    return u2_cm_wail();
                }
                u2z(gof);

                return pro;
            }
            c3_assert(!"not reached");

            case 5: {
                u2_noun gof, pro;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                if ( u2_no == u2du(gof) ) {
                    *pon = 2;
                    u2z(gof);
                    return u2_cm_wail();
                }
                pro = u2_cr_sing(u2h(gof), u2t(gof));
                u2z(gof);

                return pro;
            }
            c3_assert(!"not reached");

            case 6: {
                u2_noun b_gal, cd_gal, c_gal, d_gal;

                if ( u2_no == u2_cr_cell(gal, &b_gal, &cd_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun tys, nex;

                    tys = _nock_mool(u2k(bus), u2k(b_gal), pon);
                    if ( 0 != *pon ) {
                        u2z(bus);
                        u2z(fol);
                        return tys;
                    }

                    if ( u2_no == u2_cr_cell(cd_gal, &c_gal, &d_gal) ) {
                        *pon = 2;
                        u2z(bus);
                        u2z(fol);
                        return u2_cm_wail();
                    }

                    if ( 0 == tys ) {
                        nex = u2k(c_gal);
                    } else if ( 1 == tys ) {
                        nex = u2k(d_gal);
                    } else {
                        *pon = 2;
                        u2z(bus);
                        u2z(fol);
                        return u2_cm_wail();
                    }

                    u2z(fol);
                    fol = nex;
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 7: {
                u2_noun b_gal, c_gal;

                if ( u2_no == u2_cr_cell(gal, &b_gal, &c_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun bod, nex;

                    bod = _nock_mool(bus, u2k(b_gal), pon);
                    if ( 0 != *pon ) {
                        u2z(fol);
                        return bod;
                    }

                    nex = u2k(c_gal);
                    u2z(fol);

                    bus = bod;
                    fol = nex;
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 8: {
                u2_noun b_gal, c_gal;

                // c3_assert(!"got 8 (mink)!");
                if ( u2_no == u2_cr_cell(gal, &b_gal, &c_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun wib, bod, nex;

                    wib = _nock_mool(u2k(bus), u2k(b_gal), pon);
                    if ( 0 != *pon ) {
                        u2z(bus);
                        u2z(fol);
                        return wib;
                    }

                    bod = u2nc(wib, bus);
                    nex = u2k(c_gal);
                    u2z(fol);

                    bus = bod;
                    fol = nex;
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 9: {
                u2_noun b_gal, c_gal;

                if ( (u2_no == u2_cr_cell(gal, &b_gal, &c_gal)) ||
                        (u2_no == u2ud(b_gal)) )
                {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun seb;
                    u2_weak xip;

                    seb = _nock_mool(bus, u2k(c_gal), pon);
                    u2z(fol);
                    if ( 0 != *pon ) {
                        return seb;
                    }

                    u2_tx_sys_bit(u2_Wire, u2_yes);
                    xip = u2_ds_find(u2_Wire, seb);
                    u2_tx_sys_bit(u2_Wire, u2_no);

                    if ( u2_none != xip ) {
                        u2_noun pro;

                        u2_tx_sys_bit(u2_Wire, u2_yes);
                        pro = u2_ho_kicq(u2_Wire, xip, seb, b_gal, pon);
                        u2_tx_sys_bit(u2_Wire, u2_no);
                        u2z(seb);

                        if ( u2_none == pro ) {
                            *pon = 2;
                            return u2_cm_wail();
                        }
                        else return pro;
                    }
                    else {
                        u2_noun nex = u2_cr_at(b_gal, seb);

                        if ( u2_none == nex ) {
                            *pon = 2;
                            u2z(seb);
                            return u2_cm_wail();
                        }
                        bus = seb;
                        fol = u2k(nex);
                        continue;
                    }
                }
            }
            c3_assert(!"not reached");

            case 10: {
                u2_noun p_gal, q_gal;

                if ( u2_no == u2_cr_cell(gal, &p_gal, &q_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun zep, hod, nex;

                    if ( u2_yes == u2du(p_gal) ) {
                        u2_noun b_gal = u2fh(p_gal);
                        u2_noun c_gal = u2ft(p_gal);
                        u2_noun d_gal = q_gal;

                        hod = _nock_mool(u2k(bus), u2_ct(c_gal), pon);
                        if ( 0 != *pon ) {
                            u2z(fol);
                            return hod;
                        }

                        zep = u2k(b_gal);
                        nex = u2k(d_gal);
                        u2z(fol);
                    }
                    else {
                        u2_noun b_gal = p_gal;
                        u2_noun c_gal = q_gal;

                        zep = u2k(b_gal);
                        hod = u2_nul;
                        nex = u2k(c_gal);

                        u2z(fol);
                    }

                    return _nock_hint(zep, hod, bus, nex, pon);
                }
            }

            case 11: {
                u2_noun gof;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                return _nock_pray_mool(gof, pon);
            }
            c3_assert(!"not reached");
            }
    }
}
Example #11
0
File: nock.c Project: sillsm/urbit
/* _nock_cool(): nock, transferring arguments.
*/
static u2_noun
_nock_cool(u2_noun bus,
           u2_noun fol)
{
    u2_noun hib, gal;

    while ( 1 ) {
        u2_tx_did_hop(u2_Wire, 1);

        if ( u2_no == u2du(fol) ) {
            return u2_cm_bail(c3__exit);
        }
        else {
            hib = u2fh(fol);
            gal = u2ft(fol);
        }

        if ( u2_yes == u2du(hib) ) {
            u2_noun poz, riv;

            poz = _nock_cool(u2k(bus), u2k(hib));
            riv = _nock_cool(bus, u2k(gal));

            u2z(fol);
            return u2_cn_cell(poz, riv);
        }
        else switch ( hib ) {
            default:
                return u2_cm_bail(c3__exit);

            case 0: {
                if ( u2_no == u2_cr_ud(gal) ) {
                    return u2_cm_bail(c3__exit);
                }
                else {
                    u2_noun pro = u2k(u2at(gal, bus));

                    u2z(bus);
                    u2z(fol);
                    return pro;
                }
            }
            case 1: {
                u2_noun pro = u2k(gal);

                u2z(bus);
                u2z(fol);
                return pro;
            }
            c3_assert(!"not reached");

            case 2: {
                if ( u2_no == u2du(gal) ) {
                    return u2_cm_bail(c3__exit);
                }
                else {
                    u2_noun nex = _nock_cool(u2k(bus), u2k(u2ft(gal)));
                    u2_noun seb = _nock_cool(bus, u2k(u2fh(gal)));

                    u2z(fol);
                    bus = seb;
                    fol = nex;
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 3: {
                u2_noun gof, pro;

                gof = _nock_cool(bus, u2k(gal));
                pro = u2du(gof);

                u2z(gof);
                u2z(fol);
                return pro;
            }
            c3_assert(!"not reached");

            case 4: {
                u2_noun gof, pro;

                gof = _nock_cool(bus, u2k(gal));
                if ( (u2_none == (pro = u2_rl_vint(u2_Wire, gof))) ) {
                    return u2_cm_bail(c3__exit);
                }

                u2z(gof);
                u2z(fol);
                return pro;
            }
            c3_assert(!"not reached");

            case 5: {
                if ( u2_no == u2du(gal) ) {
                    return u2_cm_bail(c3__exit);
                }
                else {
                    u2_noun wim = _nock_cool(bus, u2k(gal));
                    u2_noun pro;

                    if ( u2_no == u2du(wim) ) {
                        return u2_cm_bail(c3__exit);
                    }
                    else pro = u2_cr_sing(u2h(wim), u2t(wim));

                    u2z(wim);
                    u2z(fol);
                    return pro;
                }
            }
            c3_assert(!"not reached");

            case 6: {
                u2_noun b_gal, c_gal, d_gal;

                u2_cx_trel(gal, &b_gal, &c_gal, &d_gal);
                {
                    u2_noun tys = _nock_cool(u2k(bus), u2k(b_gal));
                    u2_noun nex;

                    if ( 0 == tys ) {
                        nex = u2k(c_gal);
                    } else if ( 1 == tys ) {
                        nex = u2k(d_gal);
                    } else return u2_cm_bail(c3__exit);

                    u2z(fol);
                    fol = nex;
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 7: {
                u2_noun b_gal, c_gal;

                u2_cx_cell(gal, &b_gal, &c_gal);
                {
                    u2_noun bod = _nock_cool(bus, u2k(b_gal));
                    u2_noun nex = u2k(c_gal);

                    u2z(fol);
                    bus = bod;
                    fol = nex;
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 8: {
                u2_noun b_gal, c_gal;

                // c3_assert(!"got 8 (nock)!");
                u2_cx_cell(gal, &b_gal, &c_gal);
                {
                    u2_noun bod = u2nc(_nock_cool(u2k(bus), u2k(b_gal)), bus);
                    u2_noun nex = u2k(c_gal);

                    u2z(fol);
                    bus = bod;
                    fol = nex;
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 9: {
                u2_noun b_gal, c_gal;

                u2_cx_cell(gal, &b_gal, &c_gal);
                if ( u2_no == u2ud(b_gal) ) {
                    return u2_cm_bail(c3__exit);
                }
                else {
                    u2_noun seb = _nock_cool(bus, u2k(c_gal));
                    u2_weak xip;

                    u2_tx_sys_bit(u2_Wire, u2_yes);
                    xip = u2_ds_find(u2_Wire, seb);

                    if ( u2_none != xip ) {
                        u2_noun pro = u2_ho_kick(u2_Wire, xip, seb, b_gal);

                        u2_tx_sys_bit(u2_Wire, u2_no);
                        if ( u2_none == pro ) {
                            return u2_cm_bail(c3__exit);
                        }
                        else {
                            u2z(seb);
                            u2z(fol);
                            return pro;
                        }
                    }
                    else {
                        u2_tx_sys_bit(u2_Wire, u2_no);
                        {
                            u2_noun nex = u2_ct(u2at(b_gal, seb));

                            u2z(fol);
                            bus = seb;
                            fol = nex;
                            continue;
                        }
                    }
                }
            }
            c3_assert(!"not reached");

            case 10: {
                u2_noun p_gal, q_gal;

                u2_cx_cell(gal, &p_gal, &q_gal);
                {
                    u2_noun zep, hod, nex, pro;

                    if ( u2_yes == u2du(p_gal) ) {
                        u2_noun b_gal = u2fh(p_gal);
                        u2_noun c_gal = u2ft(p_gal);
                        u2_noun d_gal = q_gal;

                        zep = u2k(b_gal);
                        hod = _nock_cool(u2k(bus), u2_ct(c_gal));
                        nex = u2_ct(d_gal);
                    }
                    else {
                        u2_noun b_gal = p_gal;
                        u2_noun c_gal = q_gal;

                        zep = u2k(b_gal);
                        hod = u2_nul;
                        nex = u2_ct(c_gal);
                    }

                    u2_cz(fol);
                    pro = _nock_hint(zep, hod, bus, nex, 0);
                    return pro;
                }
            }

            case 11: {
                u2_noun gof, pro;

                gof = _nock_cool(bus, u2k(gal));
                pro = _nock_pray_cool(gof);

                u2z(fol);
                return pro;
            }
            c3_assert(!"not reached");
            }
    }
}
Example #12
0
File: dash.c Project: MacTop/urbit
/* _ds_chip(): fabricate chip from clue and core.
*/
static u2_weak                                                    //  senior
_ds_chip(u2_wire wir_r,
         u2_noun clu,                                             //  retain
         u2_noun cor)                                             //  retain
{
  u2_rail bas_r = u2_wire_bas_r(wir_r);
  u2_noun bud_clu, cop_clu, pic_clu;

  if ( (u2_no == u2_as_trel(clu, &bud_clu, &cop_clu, &pic_clu)) ||
       (u2_no == _ds_good_bud(bud_clu)) ||
       (u2_no == _ds_good_cop(cop_clu)) ||
       (u2_no == _ds_good_pic(pic_clu)) )
  {
    return u2_none;
  }
  else {
    u2_noun dac, bat, pet;

    /* disc: dac
    */
    {
      if ( u2_none == (dac = u2_rx(bas_r, u2_t(clu))) ) {
        u2_ho_warn_here();
        return u2_none;
      }
    }
#if 1
    /* battery: bat
    */
    {
      if ( u2_none == (bat = u2_rx(bas_r, u2_h(cor))) ) {
        u2_ho_warn_here();
        u2_rz(bas_r, dac); return u2_none;
      }
    }
#endif
#if 0
    /* bat: battery
    */
    {
      // Important to reuse existing battery even if it does not match
      // the whole chip - since battery is a comparison key, we don't
      // want duplicates, which compare slowly.
      //
      if ( u2_nul == pug ) {
        bat = u2_rx(bas_r, u2_h(cor));
      }
      else {
        u2_noun i_pug = u2_h(pug);
        bat = u2_rx(bas_r, u2_h(u2_t(i_pug)));
      }

      if ( u2_none == bat ) {
        u2_ho_warn_here();
        u2_rz(bas_r, dac); return u2_none;
      }
    }
#endif
    /* trunk: pet
    */
    {
      if ( _0 == bud_clu ) {
        pet = u2_nul;
      }
      else {
        while ( _10 == u2_h(bud_clu) ) {
          bud_clu = u2_t(u2_t(bud_clu));
        }

        if ( _1 == u2_h(bud_clu) ) {
          pet = u2_nul;
        }
        else {
          u2_atom axe = u2_t(bud_clu);
          u2_noun ruc = u2_frag(axe, cor);
          u2_noun led;

          if ( u2_none == ruc ) {
            // u2_err(wir_r, "clu", clu);
            u2_ho_warn_here();
            u2_rz(bas_r, dac); u2_rz(bas_r, bat); return u2_none;
          } else {
            if ( u2_none == (led = u2_ds_find(wir_r, ruc)) ) {
              u2_lo_show("clu", clu);
              u2_ho_warn_here();
              c3_assert(0);
              u2_rz(bas_r, dac); u2_rz(bas_r, bat); return u2_none;
            }
            pet = u2_rc(bas_r, u2_rx(bas_r, axe), u2_rx(bas_r, led));
          }
        }
      }
    }
    return u2_rt(bas_r, dac, bat, pet);
  }
}