Esempio n. 1
0
/* u2_cke_cue(): expand saved pill.
*/
  static u2_noun                                                  //  produce
  _cue_in(u2_wire wir_r,
          u2_atom a,                                              //  retain
          u2_atom b,                                              //  retain
          u2_ray  t_r)                                            //  retain
  {
    u2_noun p, q;

    if ( _0 == j2_mbc(Pt3, cut)(wir_r, 0, b, 1, a) ) {
      u2_noun x = j2_mbc(Pt1, inc)(wir_r, b);
      u2_noun c = j2_mby(Pt5, rub)(wir_r, x, a);

      p = j2_mbc(Pt1, inc)(wir_r, u2_h(c));
      q = u2_rx(wir_r, u2_t(c));
      q = u2_cs_save(wir_r, t_r, 0, b, q);

      u2_rz(wir_r, c);
      u2_rz(wir_r, x);
    }
    else {
      u2_noun c = j2_mbc(Pt1, add)(wir_r, _2, b);
      u2_noun l = j2_mbc(Pt1, inc)(wir_r, b);

      if ( _0 == j2_mbc(Pt3, cut)(wir_r, 0, l, 1, a) ) {
        u2_noun u, v, w;
        u2_noun x, y;

        u = _cue_in(wir_r, a, c, t_r);
        x = j2_mbc(Pt1, add)(wir_r, u2_h(u), c);
        v = _cue_in(wir_r, a, x, t_r);

        w = u2_bc(wir_r, u2_rx(wir_r, u2_t(u)),
                         u2_rx(wir_r, u2_t(v)));

        y = j2_mbc(Pt1, add)(wir_r, u2_h(u), u2_h(v));

        p = j2_mbc(Pt1, add)(wir_r, _2, y);
        q = u2_cs_save(wir_r, t_r, 0, b, w);

        u2_rz(wir_r, u); u2_rz(wir_r, v); u2_rz(wir_r, x); u2_rz(wir_r, y);
      }
      else {
        u2_noun d = j2_mby(Pt5, rub)(wir_r, c, a);
        u2_weak x = u2_cs_find(wir_r, t_r, 0, u2_t(d));

        p = j2_mbc(Pt1, add)(wir_r, _2, u2_h(d));

        if ( u2_none == x ) {
          return u2_bl_bail(wir_r, c3__fail);
        }
        q = u2_rx(wir_r, x);

        u2_rz(wir_r, d);
      }
      u2_rz(wir_r, l);
      u2_rz(wir_r, c);
    }
    return u2_bc(wir_r, p, q);
  }
Esempio n. 2
0
/* u2_ds_mine(): 
**
**   Register and/or save core.
*/
u2_noun                                                           //  transfer
u2_ds_mine(u2_wire wir_r,
           u2_noun clu,                                           //  retain
           u2_noun cor)                                           //  transfer
{
  u2_noun bas_r = u2_wire_bas_r(wir_r);

  if ( u2_no == u2_dust(cor) ) {
    return cor;
  } else {
    u2_noun pay = u2_t(cor);
    u2_noun bat = u2_h(cor);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat);
    u2_noun xip, bat_xip;
    u2_noun gop;

    if ( u2_none == pug ) {
      pug = u2_nul;
    }
    if ( u2_none == (xip = _ds_scan(pug, cor)) ) {
      gop = u2_rc(bas_r, (xip = _ds_chip(wir_r, clu, cor)), u2_rx(bas_r, pug));

      if ( u2_none == gop ) {
        return cor;
      } else {
        bat_xip = u2_h(u2_t(xip));

        // {c3_c* xip_c=u2_ho_cstring(xip); printf("%s\n", xip_c); free(xip_c);}
        gop = u2_cs_save(bas_r, u2_wire_des_r(wir_r), 0, bat_xip, gop);
        u2_rz(bas_r, gop);
      }
    }
    else bat_xip = u2_h(u2_t(xip));

    if ( bat_xip != bat ) {
      u2_noun cyr = u2_rc(wir_r, u2_rx(wir_r, pay), bat_xip);

      if ( u2_none == cyr ) {
        return cor;
      }
      else {
        u2_rz(wir_r, cor);
        return cyr;
      }
    }
    else return cor;
  }
}
Esempio n. 3
0
/* u2_ds_find(): find chip by core, or none.
*/
u2_weak                                                           //  senior
u2_ds_find(u2_wire wir_r,
           u2_noun cor)                                           //  retain
{
  if ( u2_no == u2_dust(cor) ) {
    return u2_none;
  } else {
    u2_rail bas_r = u2_wire_bas_r(wir_r);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, u2_h(cor));

    if ( u2_none == pug ) {
      return u2_none;
    }
    else return _ds_scan(pug, cor);
  }
}
Esempio n. 4
0
File: dash.c Progetto: MacTop/urbit
/* u2_ds_find(): find chip by core, or none.
*/
u2_weak                                                           //  senior
u2_ds_find(u2_wire wir_r,
           u2_noun cor)                                           //  retain
{
  if ( u2_no == u2_dust(cor) ) {
    return u2_none;
  } else {
    u2_rail bas_r = u2_wire_bas_r(wir_r);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, u2_h(cor));
    u2_noun out;

    if ( u2_none == pug ) {
      out = u2_none;
    }
    else out = _ds_scan(pug, cor);

#if 0
    if ( (u2_none == out) && (u2_none != pug) ) {
      fprintf(stderr, "half match\r\n");
    }
#endif
    return out;
  }
}
Esempio n. 5
0
File: dash.c Progetto: MacTop/urbit
/* u2_ds_mine():
**
**   Register and/or save core.
*/
u2_noun                                                           //  transfer
u2_ds_mine(u2_wire wir_r,
           u2_noun clu,                                           //  retain
           u2_noun cor)                                           //  transfer
{
  u2_noun bas_r = u2_wire_bas_r(wir_r);

  if ( u2_no == u2_dust(cor) ) {
    return cor;
  } else {
    u2_noun pay = u2_t(cor);
    u2_noun bat = u2_h(cor);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat);
    u2_noun xip, bat_xip;
    u2_noun gop;

    if ( u2_none == pug ) {
      pug = u2_nul;
    }
    if ( u2_none == (xip = _ds_scan(pug, cor)) ) {
      gop = u2_rc(bas_r, (xip = _ds_chip(wir_r, clu, cor)), u2_rx(bas_r, pug));

      if ( u2_none == gop ) {
        return cor;
      } else {
        bat_xip = u2_h(u2_t(xip));

#if 0
        {
          c3_c* xip_c = u2_ho_cstring(xip);

          fprintf(stderr, "!%s - lent %d\r\n", xip_c, u2_ckb_lent(gop));
          free(xip_c);
        }
#endif
        gop = u2_cs_save(bas_r, u2_wire_des_r(wir_r), 0, bat_xip, gop);
        {
          u2_noun poo = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat_xip);

          {
            _ds_scan(poo, cor);
          }
        }
        u2_rz(bas_r, gop);

      }
    }
    else {
      bat_xip = u2_h(u2_t(xip));
    }

    if ( bat_xip != bat ) {
      u2_noun cyr = u2_rc(wir_r, bat_xip, u2_rx(wir_r, pay));

      if ( u2_none == cyr ) {
        return cor;
      }
      else {
        u2_rz(wir_r, cor);
        return cyr;
      }
    }
    else return cor;
  }
}