コード例 #1
0
ファイル: ut_tack.c プロジェクト: Gruelty/urbit
/* internals
*/
  static u2_noun                                                  //  transfer
  _tack_in(u2_wire wir_r, 
           u2_noun van,                                           //  retain
           u2_noun sut,                                           //  retain
           u2_noun peh,                                           //  retain
           u2_noun mur,                                           //  retain
           u2_atom axe)                                           //  retain
  {
    if ( u2_no == u2_dust(peh) ) {
      return u2_bc(wir_r, u2_rx(wir_r, axe), u2_rx(wir_r, mur));
    } 
    else {
      u2_noun i_peh = u2_h(peh);
      u2_noun t_peh = u2_t(peh);

      if ( (u2_yes == u2_stud(i_peh)) || (u2_no == u2_h(i_peh)) ) 
      {
        u2_noun pi_peh = (u2_yes == u2_stud(i_peh)) ? 0 : u2_h(u2_t(i_peh));
        u2_noun qi_peh = (u2_yes == u2_stud(i_peh)) ? i_peh : u2_t(u2_t(i_peh));
        u2_noun pok   = j2_mcy(Pt6, ut, fink)
                              (wir_r, van, sut, pi_peh, c3__rite, qi_peh);
        u2_noun wuf   = j2_mby(Pt6, flay)(wir_r, pok);
        u2_noun p_wuf = u2_h(wuf);
        u2_noun q_wuf = u2_t(wuf);
        u2_noun nax   = j2_mbc(Pt3, peg)(wir_r, axe, p_wuf); 
        u2_noun gav   = _tack_in(wir_r, van, q_wuf, t_peh, mur, nax);
        u2_noun p_gav = u2_h(gav);
        u2_noun q_gav = u2_t(gav);
        u2_noun qog   = u2_bc(wir_r, u2_nul, u2_rx(wir_r, qi_peh));
        u2_noun ret   = u2_bc
          (wir_r, u2_rx(wir_r, p_gav),
                  j2_mcy(Pt6, ut, heal)(wir_r, van, sut, qog, p_wuf, q_gav));

        u2_rz(wir_r, qog);
        u2_rz(wir_r, gav);
        u2_rz(wir_r, nax);
        u2_rz(wir_r, wuf);
        u2_rz(wir_r, pok);

        return ret;
      }
      else {
        u2_noun bax   = u2_t(i_peh);
        u2_noun vas   = j2_mcy(Pt6, ut, peek)(wir_r, van, sut, c3__rite, bax);
        u2_noun nax   = j2_mbc(Pt3, peg)(wir_r, axe, bax); 
        u2_noun gav   = _tack_in(wir_r, van, vas, t_peh, mur, nax);
        u2_noun p_gav = u2_h(gav);
        u2_noun q_gav = u2_t(gav);
        u2_noun ret   = u2_bc
          (wir_r, u2_rx(wir_r, p_gav),
                  j2_mcy(Pt6, ut, heal)(wir_r, van, sut, u2_nul, bax, q_gav));
        
        u2_rz(wir_r, gav);
        u2_rz(wir_r, nax);
        u2_rz(wir_r, vas);

        return ret;
      }
    }
  }
コード例 #2
0
ファイル: hill.c プロジェクト: aaronlifton/urbit
/* _hill_print_spot(): print wrapper for file location, at tab of 2.
*/
static void
_hill_print_spot(u2_wire wir_r,
                 FILE*   fil_f,                                   //  retain
                 u2_noun sot)                                     //  retain
{
  u2_noun p_sot, q_sot, r_sot, pq_sot, qq_sot, pr_sot, qr_sot;

  if ( (u2_yes == u2_as_trel(sot, &p_sot, &q_sot, &r_sot)) &&
       (u2_yes == u2_as_cell(q_sot, &pq_sot, &qq_sot)) &&
       (u2_yes == u2_as_cell(r_sot, &pr_sot, &qr_sot)) &&
       (u2_yes == u2_stud(pq_sot)) &&
       (u2_yes == u2_stud(qq_sot)) &&
       (u2_yes == u2_stud(pr_sot)) &&
       (u2_yes == u2_stud(qr_sot)) )
  {
    u2_noun blt = _hill_a_term(wir_r, Hill->soa, p_sot);
    u2_noun bla = _hill_a_delm(wir_r, Hill->soa, pq_sot);
    u2_noun blb = _hill_a_delm(wir_r, Hill->soa, qq_sot);
    u2_noun blc = _hill_a_delm(wir_r, Hill->soa, pr_sot);
    u2_noun bld = _hill_a_delm(wir_r, Hill->soa, qr_sot);
    u2_noun tlt = _hill_a_ram(wir_r, Hill->soa, blt);
    u2_noun tla = _hill_a_ram(wir_r, Hill->soa, bla);
    u2_noun tlb = _hill_a_ram(wir_r, Hill->soa, blb);
    u2_noun tlc = _hill_a_ram(wir_r, Hill->soa, blc);
    u2_noun tld = _hill_a_ram(wir_r, Hill->soa, bld);

    fprintf(fil_f, " {");
    if ( u2_nul != tlt ) {
      _hill_print_tape(wir_r, fil_f, tlt);
      fprintf(fil_f, ": ");
    }

    _hill_print_tape(wir_r, fil_f, tla);
    fprintf(fil_f, ".");
    _hill_print_tape(wir_r, fil_f, tlb);
    fprintf(fil_f, ":");
    _hill_print_tape(wir_r, fil_f, tlc);
    fprintf(fil_f, ".");
    _hill_print_tape(wir_r, fil_f, tld);
    fprintf(fil_f, "}\n");
     
    u2_rz(wir_r, blt);
    u2_rz(wir_r, bla);
    u2_rz(wir_r, blb);
    u2_rz(wir_r, blc);
    u2_rz(wir_r, bld);

    u2_rz(wir_r, tlt);
    u2_rz(wir_r, tla);
    u2_rz(wir_r, tlb);
    u2_rz(wir_r, tlc);
    u2_rz(wir_r, tld);

    return;
  }
  fprintf(fil_f, "  {spot!}\n");
  u2_err(wir_r, "{{invalid}}", sot);
}
コード例 #3
0
  u2_noun                                                         //  transfer
  j2_mb(Pt5, rub)(u2_wire wir_r,
                  u2_noun cor)                                    //  retain
  {
    u2_noun a, b;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0)) ||
         (u2_no == u2_stud(a)) ||
         (u2_no == u2_stud(b)) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mby(Pt5, rub)(wir_r, a, b);
    }
  }
コード例 #4
0
ファイル: mod.c プロジェクト: mnemnion/urbit
  u2_weak                                                         //  transfer
  j2_mb(Pt1, mod)(u2_wire wir_r, 
                  u2_noun cor)                                    //  retain
  {
    u2_noun a, b;

    if ( (u2_no == u2_mean(cor, u2_cw_sam_2, &a, u2_cw_sam_3, &b, 0)) ||
         (u2_no == u2_stud(a)) ||
         (u2_no == u2_stud(b)) )
    {
      return u2_none;
    } else {
      return j2_mbc(Pt1, mod)(wir_r, a, b);
    }
  }
コード例 #5
0
ファイル: met.c プロジェクト: mnemnion/urbit
  u2_weak                                                         //  transfer
  j2_mb(Pt3, met)(u2_wire wir_r, 
                  u2_noun cor)                                    //  retain
  {
    u2_noun a, b;

    if ( (u2_no == u2_mean(cor, u2_cw_sam_2, &a, u2_cw_sam_3, &b, 0)) ||
         (u2_no == u2_stud(a)) ||
         (u2_no == u2_stud(b)) )
    {
      return u2_bl_bail(wir_r, c3__exit);
    } else {
      return j2_mbc(Pt3, met)(wir_r, a, b);
    }
  }
コード例 #6
0
ファイル: shax.c プロジェクト: aaronlifton/urbit
  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);
    }
  }
コード例 #7
0
  u2_weak
  j2_mc(Pt5, aesc, en)(u2_wire wir_r,
                       u2_noun cor)
  {
    u2_noun a, b;

    if ( u2_no == u2_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
         u2_no == u2_stud(a) ||
         u2_no == u2_stud(b) )
    {
      return u2_bl_bail(wir_r, c3__exit);
    }
    else {
      return j2_mcd(Pt5, aesc, en)(wir_r, a, b);
    }
  }
コード例 #8
0
ファイル: bail.c プロジェクト: MacTop/urbit
/* u2_bn_cook():
**
**   Reverse hook as molt.
*/
u2_noun                                                           //  transfer
u2_bn_cook(u2_wire     wir_r,
           u2_noun     cor,                                       //  retain
           const c3_c* tam_c,
           u2_noun     som)                                       //  transfer
{
  u2_weak vib = u2_ds_look(wir_r, cor, tam_c);
  u2_noun axe;

  if ( (u2_none == vib) ||
       (u2_no == u2_dust(vib)) ||
       (u2_nul != u2_h(vib)) ||
       (u2_no == u2_stud(axe = u2_t(vib)) ) )
  {
    u2_rz(wir_r, vib);

    return u2_bl_bail(wir_r, c3__fail);
  } else {
    u2_noun gon = u2_bn_molt(wir_r, cor, axe, som, 0);

    u2_rz(wir_r, vib);
    u2_rz(wir_r, som);
    return gon;
  }
}
コード例 #9
0
  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);
    }
  }
コード例 #10
0
ファイル: dash.c プロジェクト: MacTop/urbit
/* _ds_good_cop()::
*/
static u2_bean
_ds_good_cop(u2_noun cop)
{
  c3_w i_w = 0;

  while ( i_w < 4 ) {
    if ( u2_yes == u2_stud(cop) ) {
      return u2_yes;
    }
    if ( u2_no == u2_stud(u2_h(cop)) ) {
      return u2_no;
    }
    cop = u2_t(cop);
    i_w++;
  }
  return u2_no;
}
コード例 #11
0
ファイル: bail.c プロジェクト: MacTop/urbit
/* u2_bi_mp():
**
**   Copy (b) into (a_mp).
*/
void
u2_bi_mp(u2_ray  wir_r,
         mpz_t   a_mp,
         u2_noun b)
{
  if ( u2_no == u2_stud(b) ) u2_bl_bail(wir_r, c3__exit);

  u2_mp(a_mp, b);
}
コード例 #12
0
ファイル: bail.c プロジェクト: MacTop/urbit
/* u2_bi_byte():
**
**   Return byte (a_w) of (b).
*/
c3_y
u2_bi_byte(u2_ray  wir_r,
           c3_w    a_w,
           u2_noun b)
{
  if ( u2_no == u2_stud(b) ) return u2_bl_bail(wir_r, c3__exit);

  return u2_byte(a_w, b);
}
コード例 #13
0
ファイル: bail.c プロジェクト: MacTop/urbit
/* u2_bi_word():
**
**   Return word (a_w) of (b).
*/
c3_w
u2_bi_word(u2_ray  wir_r,
           c3_w    a_w,
           u2_noun b)
{
  if ( u2_no == u2_stud(b) ) return u2_bl_bail(wir_r, c3__exit);

  return u2_word(a_w, b);
}
コード例 #14
0
  u2_weak                                                         //  transfer
  j2_mb(Pt3, cat)(u2_wire wir_r,
                  u2_noun cor)                                    //  retain
  {
    u2_noun a, b, c;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &a,
                                u2_cv_sam_6, &b,
                                u2_cv_sam_7, &c, 0)) ||
         (u2_no == u2_stud(a)) ||
         (u2_no == u2_stud(b)) ||
         (u2_no == u2_stud(c)) )
    {
      return u2_bl_bail(wir_r, c3__exit);
    } else {
      return j2_mbc(Pt3, cat)(wir_r, a, b, c);
    }
  }
コード例 #15
0
ファイル: bail.c プロジェクト: MacTop/urbit
/* u2_bi_met():
**
**   Return the size of (b) in bits, rounded up to
**   (1 << a_y).
**
**   For example, (a_y == 3) returns the size in bytes.
*/
c3_w
u2_bi_met(u2_ray  wir_r,
          c3_y    a_y,
          u2_noun b)
{
  if ( u2_no == u2_stud(b) ) return u2_bl_bail(wir_r, c3__exit);

  return u2_met(a_y, b);
}
コード例 #16
0
ファイル: bail.c プロジェクト: MacTop/urbit
/* u2_bi_words():
**
**  Copy words (a_w) through (a_w + b_w - 1) from (d) to (c).
*/
void
u2_bi_words(u2_ray  wir_r,
            c3_w    a_w,
            c3_w    b_w,
            c3_w*   c_w,
            u2_noun d)
{
  if ( u2_no == u2_stud(d) ) u2_bl_bail(wir_r, c3__exit);

  u2_words(a_w, b_w, c_w, d);
}
コード例 #17
0
ファイル: bail.c プロジェクト: MacTop/urbit
/* u2_bi_bytes():
**
**  Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c).
*/
void
u2_bi_bytes(u2_ray  wir_r,
            c3_w    a_w,
            c3_w    b_w,
            c3_y*   c_y,
            u2_noun d)
{
  if ( u2_no == u2_stud(d) ) u2_bl_bail(wir_r, c3__exit);

  u2_bytes(a_w, b_w, c_y, d);
}
コード例 #18
0
ファイル: benx.c プロジェクト: Gruelty/urbit
/* u2_bx_bean_print(): print bean stack to FILE *.
*/
void
u2_bx_bean_print(u2_ray  wir_r,
                 FILE *  fil_F,
                 u2_noun zof)                                     //  retain
{
  while ( u2_yes == u2_dust(zof) ) {
    u2_noun i_zof = u2_h(zof);
    u2_noun t_zof = u2_t(zof);

    if ( u2_yes == u2_stud(i_zof) ) {
      _print_term(i_zof, fil_F);
      fprintf(fil_F, "\n");
    } else {
      u2_noun hi_zof = u2_h(i_zof);
      u2_noun ti_zof = u2_t(i_zof);
      u2_weak gol;

      gol = u2_nk_kick(wir_r, ti_zof);
      if ( u2_none == gol ) {
        _print_term(hi_zof, fil_F);
        fprintf(fil_F, ":!\n");
      }
      else {
        u2_noun gal = gol;

        if ( u2_nul == hi_zof ) {
          while ( u2_yes == u2_dust(gal) ) {
            _print_tape(u2_h(gal), fil_F);
            fprintf(fil_F, "\n");
            gal = u2_t(gal);
          }
        }
        else {
          c3_w feq_w = u2_met(3, hi_zof);

          _print_term(hi_zof, fil_F);
          printf(": ");

          while ( u2_yes == u2_dust(gal) ) {
            if ( gal != gol ) {
              _print_space(feq_w + 2, fil_F);
            }
            _print_tape(u2_h(gal), fil_F);
            fprintf(fil_F, "\n");
            gal = u2_t(gal);
          }
        }
        u2_rl_lose(wir_r, gol);
      }
    }
    zof = t_zof;
  }
}
コード例 #19
0
ファイル: benx.c プロジェクト: Gruelty/urbit
/* _print_term(): print a terminal.
*/
static void
_print_term(u2_noun som,
            FILE*   fil_F)
{
  if ( u2_yes == u2_stud(som) ) {
    c3_w len_w = u2_met(3, som);
    c3_y *som_y = alloca(len_w) + 1;

    u2_bytes(0, len_w, som_y, som);
    som_y[len_w] = 0;
    fprintf(fil_F, "%s", (c3_c *)som_y);
  }
}
コード例 #20
0
ファイル: shax.c プロジェクト: aaronlifton/urbit
  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);
    }
  }
コード例 #21
0
ファイル: dec.c プロジェクト: mnemnion/urbit
  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);
    }
  }
コード例 #22
0
  u2_noun                                                         //  transfer
  j2_mb(Pt6, hike)(u2_wire wir_r,
                   u2_noun cor)                                   //  retain
  {
    u2_noun axe, pac;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &axe, u2_cv_sam_3, &pac, 0)) ||
         (u2_no == u2_stud(axe)) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mby(Pt6, hike)(wir_r, axe, pac);
    }
  }
コード例 #23
0
ファイル: ut_nest.c プロジェクト: mnemnion/urbit
/* boilerplate
*/
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, nest)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, tel, ref, van;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van, 
                                u2_cw_sam_2, &tel, 
                                u2_cw_sam_3, &ref, 0)) ||
         (u2_no == u2_stud(tel)) || (tel > 1) ||
         (u2_none == (sut = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, nest)(wir_r, van, sut, tel, ref);
    }
  }
コード例 #24
0
ファイル: dash.c プロジェクト: MacTop/urbit
/* _ds_good_pic()::
*/
static u2_bean
_ds_good_pic(u2_noun pic)
{
  if ( u2_nul == pic ) {
    return u2_yes;
  } else {
    u2_noun i_pic, t_pic;
    u2_noun pi_pic, qi_pic;

    if ( (u2_no == u2_as_cell(pic, &i_pic, &t_pic)) ||
         (u2_no == u2_as_cell(i_pic, &pi_pic, &qi_pic)) ||
         (u2_no == u2_stud(pi_pic)) )
    {
      return u2_no;
    }
    else return u2_yes;
  }
}
コード例 #25
0
ファイル: ut_cull.c プロジェクト: mnemnion/urbit
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, cull)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, axe, pol, ref, van;

    if ( (u2_no == u2_mean(cor, u2_cw_con, &van,
                                u2_cw_sam_2, &pol,
                                u2_cw_sam_6, &axe, 
                                u2_cw_sam_7, &ref, 0)) ||
         (u2_no == u2_stud(axe)) ||
         (u2_none == (sut = u2_frag(u2_cw_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, cull)(wir_r, van, sut, pol, axe, ref);
    }
  }
コード例 #26
0
ファイル: shed.c プロジェクト: Gruelty/urbit
/* _sh_good_nut()::
*/
static u2_flag
_sh_good_nut(u2_noun nut)
{
  if ( u2_nul == nut ) {
    return u2_yes;
  } else {
    u2_noun i_nut, t_nut;
    u2_noun pi_nut, qi_nut;

    if ( (u2_no == u2_as_cell(nut, &i_nut, &t_nut)) ||
         (u2_no == u2_as_cell(i_nut, &pi_nut, &qi_nut)) ||
         (u2_no == u2_stud(pi_nut)) )
    {
      return u2_no;
    }
    else return u2_yes;
  }
}
コード例 #27
0
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, park)(u2_wire wir_r,
                       u2_noun cor)                               //  retain
  {
    u2_noun sut, way, axe, van;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &way,
                                u2_cv_sam_3, &axe,
                                u2_cv_con, &van,
                                0)) ||
         (u2_no == u2_stud(axe)) ||
         (u2_none == (sut = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, park)(wir_r, van, sut, way, axe);
    }
  }
コード例 #28
0
ファイル: shed.c プロジェクト: Gruelty/urbit
/* _sh_good_bud()::
*/
static u2_flag
_sh_good_bud(u2_noun bud)
{
  u2_noun p_bud, q_bud;

  if ( _0 == bud ) {
    return u2_yes;
  }
  else if ( (u2_no == u2_as_cell(bud, &p_bud, &q_bud)) ) {
    return u2_no;
  }
  if ( (u2_nock_bone == p_bud) && (_0 == q_bud) ) {
    return u2_yes;
  }
  if ( (u2_nock_frag == p_bud) && (u2_yes == u2_stud(q_bud)) ) {
    return u2_yes;
  }
  else return u2_no;
}
コード例 #29
0
ファイル: ut_heal.c プロジェクト: Gruelty/urbit
  u2_noun                                                         //  transfer
  j2_mc(Pt6, ut, heal)(u2_wire wir_r, 
                       u2_noun cor)                               //  retain
  {
    u2_noun van, sut, qog, axe, ref;

    if ( (u2_no == u2_mean(cor, u2_cv_sam_2, &qog, 
                                u2_cv_sam_6, &axe,
                                u2_cv_sam_7, &ref,
                                u2_cv_con, &van, 
                                0)) ||
         (u2_no == u2_stud(axe)) ||
         (u2_none == (sut = u2_frag(u2_cv_sam, van))) )
    {
      return u2_bl_bail(wir_r, c3__fail);
    } else {
      return j2_mcx(Pt6, ut, heal)(wir_r, van, sut, qog, axe, ref);
    }
  }
コード例 #30
0
ファイル: dash.c プロジェクト: MacTop/urbit
/* _ds_good_bud()::
*/
static u2_bean
_ds_good_bud(u2_noun bud)
{
  u2_noun p_bud, q_bud;

  if ( _0 == bud ) {
    return u2_yes;
  }
  else if ( (u2_no == u2_as_cell(bud, &p_bud, &q_bud)) ) {
    return u2_no;
  }
  if ( (u2_nock_bone == p_bud) && (_0 == q_bud) ) {
    return u2_yes;
  }
  if ( (u2_nock_frag == p_bud) && (u2_yes == u2_stud(q_bud)) ) {
    return u2_yes;
  }
  if ( u2_nock_hint == p_bud ) {
    return u2_yes == u2_dust(u2_t(bud)) ? _ds_good_bud(u2_t(u2_t(bud))) : u2_no;
  }
  else return u2_no;
}