Exemplo n.º 1
0
  static u2_flag
  _nest_dext(u2_wire wir_r,
             u2_noun van,
             u2_noun sut,
             u2_noun ref,
             u2_noun gil)
  {
    if ( (u2_yes == u2_sing(sut, ref)) ) {
      return u2_yes;
    }

    {
      u2_ho_jet *jet_j = &j2_mcj(Pt6, ut, nest)[0];

      if ( !(jet_j->sat_s & u2_jet_memo) ) {
        return _nest_dext_in(wir_r, van, sut, ref, gil);
      } else {
        c3_m    fun_m = u2_jet_fun_m(jet_j);
        u2_noun pro   = u2_rl_find_cell(wir_r, fun_m, sut, ref);

        if ( u2_none != pro ) {
          return pro;
        }
        else {
          pro = _nest_dext_in(wir_r, van, sut, ref, gil);

          return u2_rl_save_cell(wir_r, fun_m, sut, ref, pro);
        }
      }
    }
  }
Exemplo n.º 2
0
  u2_noun                                                         //  transfer
  j2_mcy(Pt6, ut, bust)(u2_wire wir_r,
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain
                        u2_noun dib)                              //  retain
  {
    u2_ho_jet *jet_j = &j2_mcj(Pt6, ut, bust)[0];

    if ( (jet_j->sat_s & u2_jet_live) && !(jet_j->sat_s & u2_jet_test) ) {
      if ( !(jet_j->sat_s & u2_jet_memo) ) {
        return j2_mcx(Pt6, ut, bust)(wir_r, van, sut, dib);
      }
      else {
        c3_m    fun_m = c3__bust;
        u2_noun pro   = u2_rl_find_cell(wir_r, fun_m, sut, dib);

        if ( u2_none != pro ) {
          return pro;
        }
        else {
          pro = j2_mcx(Pt6, ut, bust)(wir_r, van, sut, dib);

          return u2_rl_save_cell(wir_r, fun_m, sut, dib, pro);
        }
      }
    }
    else {
      u2_noun cor, fol, pro;

      cor = j2_mci(Pt6, ut, bust)(wir_r, van, sut, dib);
      fol = u2_h(cor);

      pro = u2_ho_use(wir_r, jet_j, cor, fol);
      if ( u2_none == pro ) return u2_bl_bail(wir_r, c3__fail);

      u2_rz(wir_r, cor);
      u2_rz(wir_r, fol);

      return pro;
    }
  }
Exemplo n.º 3
0
Arquivo: nock.c Projeto: sillsm/urbit
/* _nock_hint(): hint with code, data, subject, formula.  nock/mink.
*/
static u2_noun                                                    //  produce
_nock_hint(u2_noun  zep,                                          //  transfer
           u2_noun  hod,                                          //  transfer
           u2_noun  bus,                                          //  transfer
           u2_noun  nex,                                          //  transfer
           u2_bean* pon)
{
    u2_noun pro;

    switch ( zep ) {
    default:
        u2z(zep);
        u2z(hod);
        return pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);

    case c3__lose:
    case c3__yelp:
    case c3__bean:
    case c3__mean:
    case c3__spot: {
        u2_noun tax = u2_wire_tax(u2_Wire);
        u2_noun tac = u2nc(zep, hod);

#if 0
        if ( c3__spot == zep ) {
            printf("spot %d/%d : %d/%d\n",
                   u2h(u2h(u2t(hod))),
                   u2t(u2h(u2t(hod))),
                   u2h(u2t(u2t(hod))),
                   u2t(u2t(u2t(hod))));
        }
#endif
        u2_wire_tax(u2_Wire) = u2nc(tac, tax);
        {
            pro = pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);
        }
        tax = u2k(tax);
        u2z(u2_wire_tax(u2_Wire));
        u2_wire_tax(u2_Wire) = tax;

        return pro;
    }

    case c3__slog: {
        u2_tx_sys_bit(u2_Wire, u2_yes);
        u2_tx_slog(u2_Wire, hod);
        u2_tx_sys_bit(u2_Wire, u2_no);

        u2z(hod);
        return pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);
    }

    case c3__mine: {
        pro = pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);

        if ( !pon || (u2_no != *pon) ) {
            u2_tx_sys_bit(u2_Wire, u2_yes);
            pro = u2_ds_mine(u2_Wire, hod, pro);
            u2_tx_sys_bit(u2_Wire, u2_no);
        }
        u2z(hod);
        return pro;
    }

    case c3__germ: {
        pro = pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);

        if ( u2_yes == u2_sing(pro, hod) ) {
            u2z(pro);
            return hod;
        } else {
            u2z(hod);
            return pro;
        }
    }

    case c3__fast: {
        pro = pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);

        if ( !pon || (u2_no != *pon) ) {
            u2_noun p_hod, q_hod, r_hod;

            /* XX: translate hod to old clue form.
            */
            if ( u2_no == u2_as_trel(hod, &p_hod, &q_hod, &r_hod) ) {
                u2z(hod);
                return pro;
            }
            else {
                u2_noun xod;

                if ( u2_yes == u2_dust(q_hod) &&
                        (_1 == u2_h(q_hod)) &&
                        (_0 == u2_t(q_hod)) ) {
                    q_hod = 0;
                }
                xod = u2_rt(u2_Wire, u2k(q_hod),
                            u2k(p_hod),
                            u2k(r_hod));
                u2z(hod);
                hod = xod;
            }
            u2_tx_sys_bit(u2_Wire, u2_yes);
            pro = u2_ds_mine(u2_Wire, hod, pro);
            u2_tx_sys_bit(u2_Wire, u2_no);
        }
        u2z(hod);
        return pro;
    }

    case c3__memo: {
        u2z(hod);
        {
            pro = u2_rl_find_cell(u2_Wire, 0, bus, nex);

            if ( pro != u2_none ) {
                u2_tx_did_fin(u2_Wire, 1);
                u2z(bus);
                u2z(nex);

                return pro;
            } else {
                u2_noun sav;

                pro = pon ? _nock_mool(u2k(bus), u2k(nex), pon)
                      : _nock_cool(u2k(bus), u2k(nex));

                if ( !pon || (u2_no != *pon) ) {
                    u2_tx_sys_bit(u2_Wire, u2_yes);
                    sav = u2_rl_save_cell(u2_Wire, 0, bus, nex, pro);
                    u2_tx_sys_bit(u2_Wire, u2_no);

                    u2_tx_did_pod(u2_Wire, 1);
                    u2_tx_did_fin(u2_Wire, 1);
                }
                else sav = pro;

                u2z(bus);
                u2z(nex);
                return sav;
            }
        }
    }

    case c3__ping: {
        u2_tx_sys_bit(u2_Wire, u2_yes);
        u2_tx_did_act(u2_Wire, hod);
        u2_tx_sys_bit(u2_Wire, u2_no);
        u2z(hod);

        return pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);
    }

    case c3__live: {
        u2_bean qox;

        u2_tx_sys_bit(u2_Wire, u2_yes);
        qox = u2_tx_task_in(u2_Wire, hod);
        u2_tx_sys_bit(u2_Wire, u2_no);

        u2z(hod);
        if ( u2_no == qox ) {
            return pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);
        } else {
            pro = pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);

            u2_tx_task_out(u2_Wire);
            return pro;
        }
    }

    case c3__sole: {
        u2z(hod);
        {
            pro = pon ? _nock_mool(bus, nex, pon) : _nock_cool(bus, nex);

            if ( u2_none == pro ) {
                return u2_none;
            }
            else if ( !pon || (u2_no != *pon) ) {
                u2_noun nuu;

                u2_tx_sys_bit(u2_Wire, u2_yes);
                nuu = u2_rl_uniq(u2_Wire, pro);
                u2_tx_sys_bit(u2_Wire, u2_no);

                u2_tx_did_fin(u2_Wire, 1);
                if ( nuu == pro ) {
                    u2_tx_did_pod(u2_Wire, 1);
                }
            }
            return pro;
        }
    }
    }
}