示例#1
0
文件: parse.c 项目: mnemnion/urbit
/* comp
*/
  u2_noun                                                         //  produce
  j2_mcx(Pt5, comp, fun)(u2_wire wir_r,
                         u2_noun raq,                             //  retain
                         u2_noun vex,                             //  retain
                         u2_noun sab)                             //  retain
  {
    u2_noun p_vex, q_vex;

    u2_bi_cell(wir_r, vex, &p_vex, &q_vex);
    if ( u2_no == u2_dust(q_vex) ) {
      return u2_rx(wir_r, vex);
    } else {
      u2_noun uq_vex = u2_t(q_vex);
      u2_noun puq_vex, quq_vex;
      u2_noun yit, yur;
      u2_noun p_yit, q_yit;
      u2_noun ret;

      u2_bi_cell(wir_r, uq_vex, &puq_vex, &quq_vex);
      yit = u2_bl_good(wir_r, u2_nk_mong(wir_r, sab, u2_rx(wir_r, quq_vex)));
      
      u2_bi_cell(wir_r, yit, &p_yit, &q_yit);
      yur = _last(wir_r, p_vex, p_yit);

      if ( u2_no == u2_dust(q_yit) ) {
        ret = u2_bc(wir_r, yur, u2_rx(wir_r, q_yit));
      } 
      else {
        u2_noun uq_yit = u2_t(q_yit);
        u2_noun puq_yit, quq_yit;
         
        u2_bi_cell(wir_r, uq_yit, &puq_yit, &quq_yit);
        ret = u2_bq(wir_r, yur,
                           u2_nul,
                           u2_bl_good
                            (wir_r, 
                             u2_nk_mong
                               (wir_r, raq, 
                                       u2_bc(wir_r, u2_rx(wir_r, puq_vex),
                                                    u2_rx(wir_r, puq_yit)))),
                           u2_rx(wir_r, quq_yit));
      }
      u2_rz(wir_r, yit);
      return ret;
    }
  }
示例#2
0
文件: snag.c 项目: Gruelty/urbit
/* functions
*/
  u2_weak                                                         //  transfer
  j2_mbc(Pt2, snag)(u2_wire wir_r, 
                    u2_atom a,                                    //  retain
                    u2_noun b)                                    //  retain
  {
    if ( !u2_fly_is_cat(a) ) {
      return u2_bl_bail(wir_r, c3__fail);
    }
    else {
      c3_w len_w = a;

      while ( len_w ) {
        if ( u2_no == u2_dust(b) ) {
          return u2_bl_bail(wir_r, c3__exit);
        }
        b = u2_t(b);
        len_w--;
      }
      if ( u2_no == u2_dust(b) ) {
        return u2_bl_bail(wir_r, c3__exit);
      }
      return u2_rx(wir_r, u2_h(b));
    }
  }
示例#3
0
文件: zuse.c 项目: aaronlifton/urbit
/* zuse_fire_gene(): execute a stateless kernel expression, as a gene.
*/
void                                                              //  transfer
zuse_fire_gene(u2_wire wir_r, 
               u2_noun sho,                                       //  retain
               u2_noun hos,                                       //  retain
               u2_noun gen)                                       //  retain
{
  u2_noun gam = _zuse_nu_mint(wir_r, sho, u2_h(hos), c3__noun, gen); 

  if ( u2_none == gam ) {
    fprintf(stderr, "  {fire: mint failed}\n");
    return;
  }
  {
    u2_noun typ = u2_h(gam);
    u2_noun fol = u2_t(gam);

    _zuse_dump_type(wir_r, u2_t(sho), 0, typ);
    u2_bx_spot(wir_r, u2_nul);
    {
      u2_noun som = u2_nk_nock(wir_r, u2_rx(wir_r, u2_t(hos)), fol);

      if ( u2_none == som ) {
        fprintf(stderr, "  {fire: nock failed}\n");
      }
      else {
        u2_err(wir_r, 0, som);
        hos = u2_none;
      }
      u2_bx_show(wir_r);
      u2_bx_spot(wir_r, u2_nul);

      u2_rz(wir_r, gam);
      u2_rz(wir_r, som);
    }
  }
}
示例#4
0
文件: ut_mint.c 项目: mnemnion/urbit
  static u2_noun 
  _mint_grow(u2_wire wir_r,
             u2_noun van,
             u2_noun sut,
             u2_noun gol,
             u2_atom mel,
             u2_noun ruf,
             u2_noun dab)
  {
    u2_noun dan = _mint_in(wir_r, van, sut, c3__noun, ruf);
    u2_noun p_dan = u2_h(dan);
    u2_noun q_dan = u2_t(dan);
    u2_noun toc = _mint_core
      (wir_r, u2_rx(wir_r, p_dan),
              u2_bt(wir_r, c3__gold, 
                           u2_rx(wir_r, p_dan), 
                           u2_bc(wir_r, u2_nul, u2_rx(wir_r, dab))));
    u2_noun dez = _mint_bake(wir_r, van, toc, dab);
    u2_noun zod = u2_bc(wir_r, 1, dez);
    u2_noun cot = _mint_core
      (wir_r, u2_rx(wir_r, p_dan),
              u2_bt(wir_r, mel, 
                           u2_rx(wir_r, p_dan), 
                           u2_bc(wir_r, u2_rx(wir_r, dez), 
                                        u2_rx(wir_r, dab))));
    u2_noun ret = u2_bc
      (wir_r, 
       _mint_nice(wir_r, van, gol, cot),
       j2_mby(Pt6, cons)(wir_r, zod, q_dan));

    u2_rz(wir_r, zod);
    u2_rz(wir_r, toc);
    u2_rz(wir_r, dan);

    return ret;
  }
示例#5
0
文件: parse.c 项目: mnemnion/urbit
/* here
*/
  u2_noun                                                         //  produce
  j2_mcx(Pt5, here, fun)(u2_wire wir_r,
                         u2_noun hez,                             //  retain
                         u2_noun sef,                             //  retain
                         u2_noun tub)                             //  retain
  {
    u2_noun vex = u2_bl_good(wir_r, u2_nk_mong(wir_r, sef, u2_rx(wir_r, tub)));
    u2_noun p_vex, q_vex;

    u2_bi_cell(wir_r, vex, &p_vex, &q_vex);

    if ( u2_no == u2_dust(q_vex) ) {
      return vex;
    }
    else {
      u2_noun uq_vex = u2_t(q_vex);
      u2_noun p_tub, q_tub;
      u2_noun puq_vex, quq_vex, pquq_vex;
      u2_noun gud, wag;
      u2_noun ret;

      u2_bi_cell(wir_r, tub, &p_tub, &q_tub);
      u2_bi_cell(wir_r, uq_vex, &puq_vex, &quq_vex);
      u2_bi_cell(wir_r, quq_vex, &pquq_vex, 0);
      gud = u2_bc(wir_r, 
                  u2_bt(wir_r, u2_nul, 
                               u2_rx(wir_r, p_tub), 
                               u2_rx(wir_r, pquq_vex)),
                  u2_rx(wir_r, puq_vex));

      wag = u2_bl_good(wir_r, u2_nk_mong(wir_r, hez, gud));
      ret = u2_bq(wir_r, u2_rx(wir_r, p_vex),
                         u2_nul,
                         wag,
                         u2_rx(wir_r, quq_vex));

      u2_rz(wir_r, vex);
      return ret;
    }
  }
示例#6
0
文件: ut_seek.c 项目: ngvrnd/urbit
  u2_noun                                                         //  transfer
  j2_mcx(Pt6, ut, seek)(u2_wire wir_r, 
                        u2_noun van,                              //  retain
                        u2_noun sut,                              //  retain
                        u2_noun way,                              //  retain
                        u2_noun hyp)                              //  retain
  {
    if ( u2_nul == hyp ) {
      return u2_bt
        (wir_r, _1, u2_yes, u2_rx(wir_r, sut));
    }
    else if ( u2_no == u2_dust(hyp) ) {
      return u2_bl_bail(wir_r, c3__fail);
    }
    else {
      u2_noun i_hyp = u2_h(hyp);
      u2_noun t_hyp = u2_t(hyp);
      u2_noun zar; 
      u2_noun p_zar, q_zar;
      u2_noun yip, syp, ret;

      if ( u2_yes == u2_dust(i_hyp) ) {
        yip = u2_rx(wir_r, i_hyp);
      } else {
        yip = u2_bt(wir_r, u2_no, 0, u2_rx(wir_r, i_hyp));
      }

      zar = j2_mcx(Pt6, ut, seek)(wir_r, van, sut, way, t_hyp);
      u2_as_cell(zar, &p_zar, &q_zar);

#if 0
      if ( u2_yes == u2_h(yip) ) {
        sic = u2_nul;
      } else {
        // sic = _seek_silk(wir_r, van, u2_h(u2_t(yip)), zar);
        sic = u2_nul;
      }
      if ( u2_nul != sic ) {
        u2_rz(wir_r, yip);
        u2_rz(wir_r, zar);

        return u2_t(sic);
      }
#endif

      if ( u2_yes == u2_h(q_zar) ) {
        syp = u2_rx(wir_r, u2_t(q_zar));
      } else {
        u2_noun pq_zar, qq_zar;
        u2_noun wip;

        u2_as_cell(u2_t(q_zar), &pq_zar, &qq_zar);
        wip = _seek_flat(wir_r, qq_zar);
        syp = j2_mcy(Pt6, ut, fire)(wir_r, van, sut, wip);

        u2_rz(wir_r, wip);
      }

      if ( u2_no == u2_h(yip) ) {
        u2_noun p_yip, q_yip, hud;

        if ( u2_no == u2_as_cell(u2_t(yip), &p_yip, &q_yip) ) {
          return u2_bl_bail(wir_r, c3__fail);
        }
        hud = j2_mcy(Pt6, ut, fink)(wir_r, van, syp, p_yip, way, q_yip);
        {
          u2_noun p_hud, q_hud;

          u2_as_cell(hud, &p_hud, &q_hud);

          ret = u2_bc(wir_r, j2_mbc(Pt3, peg)(wir_r, p_zar, p_hud), 
                             u2_rx(wir_r, q_hud));
          u2_rz(wir_r, hud);
        }
      } 
      else {
        u2_noun p_yip = u2_t(yip);

        if ( u2_no == u2_stud(p_yip) ) {
          return u2_bl_bail(wir_r, c3__fail);
        }
        else {
          ret = u2_bt
            (wir_r, j2_mbc(Pt3, peg)(wir_r, p_zar, p_yip),
                    u2_yes,
                    j2_mcy(Pt6, ut, peek)(wir_r, van, syp, way, p_yip));
        }
      }
      u2_rz(wir_r, yip);
      u2_rz(wir_r, syp);
      u2_rz(wir_r, zar);
      return ret;
    }
  }
示例#7
0
文件: ut_nest.c 项目: mnemnion/urbit
  static u2_flag
  _nest_sint(u2_wire wir_r,
             u2_noun van,
             u2_noun sut, 
             u2_noun ref,
             u2_noun gil)
  {
    u2_noun p_ref, q_ref, r_ref;

    if ( (u2_no == u2_dust(ref)) ) {
      switch ( ref ) {
        default: return u2_bl_bail(wir_r, c3__fail);

        case c3__noun: return u2_no;
        case c3__void: return u2_yes;
      }
    }
    else {
      switch ( u2_h(ref) ) {
        default: {
          return u2_bl_bail(wir_r, c3__fail);
        }
        case c3__atom: return u2_no;
        case c3__cell: return u2_no;
        case c3__core: {
          u2_type gam = j2_mcy(Pt6, ut, repo)(wir_r, van, ref);
          u2_flag hiv = _nest_dext(wir_r, van, sut, gam, gil);

          u2_rl_lose(wir_r, gam);
          return hiv;
        }
        case c3__cube: {
          if ( u2_no == u2_as_trel(ref, 0, &p_ref, &q_ref) ) {
            return u2_bl_bail(wir_r, c3__fail);
          } else {
            return _nest_dext(wir_r, van, sut, q_ref, gil);
          }
        }
        case c3__face: {
          if ( u2_no == u2_as_trel(ref, 0, &p_ref, &q_ref) ) {
            return u2_bl_bail(wir_r, c3__fail);
          } else {
            return _nest_dext(wir_r, van, sut, q_ref, gil);
          }
        }
        case c3__fine: {
          if ( u2_no == u2_as_qual(ref, 0, &p_ref, &q_ref, &r_ref) ) {
            return u2_bl_bail(wir_r, c3__fail);
          } else {
            return _nest_dext(wir_r, van, sut, r_ref, gil);
          }
        }
        case c3__fork: {
          if ( (u2_yes == u2_mean(ref, 6, &p_ref, 7, &q_ref, 0)) ) {
            return u2_and(_nest_dext(wir_r, van, sut, p_ref, gil),
                          _nest_dext(wir_r, van, sut, q_ref, gil));
          }
          else return u2_bl_bail(wir_r, c3__fail);
        } 
        case c3__hold: {
          p_ref = u2_t(ref);
          {
            u2_noun hud = u2_bc(wir_r, u2_rx(wir_r, sut), 
                                       u2_rx(wir_r, ref));

            if ( (u2_yes == j2_mcc(Pt4, in, has)(wir_r, gil, hud)) ) {
              u2_rl_lose(wir_r, hud);

              return u2_yes;
            } else {
              u2_noun zoc = j2_mcc(Pt4, in, put)(wir_r, gil, hud);
              u2_type gam = j2_mcy(Pt6, ut, repo)(wir_r, van, ref);

              {
                u2_flag hiv = _nest_dext(wir_r, van, sut, gam, zoc);

                u2_rl_lose(wir_r, hud);
                u2_rl_lose(wir_r, gam);
                u2_rl_lose(wir_r, zoc);

                return hiv;
              }
            }
          }
        } 
      }
    }
  }
示例#8
0
文件: ut_nest.c 项目: mnemnion/urbit
  static u2_flag
  _nest_cong(u2_wire wir_r,
             u2_noun van,
             u2_noun sut,
             u2_noun ref,
             u2_noun gil)
  {
    u2_noun p_sut, q_sut, p_ref, q_ref;
    u2_noun pq_sut, qq_sut, rq_sut;
    u2_noun pq_ref, qq_ref, rq_ref;
    u2_noun prq_sut, qrq_sut, prq_ref, qrq_ref;
    u2_flag ret;

    u2_bi_trel(wir_r, sut, 0, &p_sut, &q_sut);
    u2_bi_trel(wir_r, ref, 0, &p_ref, &q_ref);

    u2_bi_trel(wir_r, q_sut, &pq_sut, &qq_sut, &rq_sut);
    u2_bi_trel(wir_r, q_ref, &pq_ref, &qq_ref, &rq_ref);

    u2_bi_cell(wir_r, rq_sut, &prq_sut, &qrq_sut);
    u2_bi_cell(wir_r, rq_ref, &prq_ref, &qrq_ref);

    if ( u2_yes == u2_sing(q_sut, q_ref) ) {
      return _nest_dext(wir_r, van, p_sut, p_ref, gil);
    }
    else if ( (u2_no == _nest_dext(wir_r, van, qq_sut, p_sut, gil)) ||
              (u2_no == _nest_dext(wir_r, van, p_sut, qq_sut, gil)) ||
              (u2_no == _nest_dext(wir_r, van, qq_ref, p_ref, gil)) )
    {
      return u2_no;
    }
    else {
      if ( (pq_sut != pq_ref) && (c3__gold != pq_ref) ) {
        return u2_no;
      }
      else {
        u2_noun tus = u2_bt(wir_r, c3__core, 
                                   u2_rx(wir_r, qq_sut), 
                                   u2_rx(wir_r, q_sut));
        u2_noun fer = u2_bt(wir_r, c3__core, 
                                   u2_rx(wir_r, qq_ref), 
                                   u2_rx(wir_r, q_ref));

        ret = _nest_cram(wir_r, van, tus, fer, qrq_sut, qrq_ref, gil);
        u2_rz(wir_r, tus);
        u2_rz(wir_r, fer);

        if ( u2_no == ret ) {
          return u2_no;
        }
        else {
          switch ( pq_sut ) {
            default: return u2_bl_bail(wir_r, c3__fail);

            case c3__gold: {
              return u2_and(_nest_dext(wir_r, van, qq_sut, qq_ref, gil),
                            _nest_dext(wir_r, van, qq_ref, qq_sut, gil));
            }
            case c3__iron: {
              u2_noun s_sam = j2_mcy(Pt6, ut, peek)
                                      (wir_r, van, qq_sut, c3__rite, _3);
              u2_noun r_sam = j2_mcy(Pt6, ut, peek)
                                      (wir_r, van, qq_ref, c3__rite, _3);

              return _nest_dext(wir_r, van, r_sam, s_sam, gil);
            }
            case c3__lead: {
              return u2_yes;
            }
            case c3__zinc: {
              u2_noun s_pal = j2_mcy(Pt6, ut, peek)
                                      (wir_r, van, qq_sut, c3__read, _3);
              u2_noun r_pal = j2_mcy(Pt6, ut, peek)
                                      (wir_r, van, qq_ref, c3__read, _3);

              return _nest_dext(wir_r, van, s_pal, r_pal, gil);
            }
          }
        }
      }
    }
  }
示例#9
0
文件: dec.c 项目: mnemnion/urbit
/* functions
*/
  u2_weak                                                         //  transfer
  j2_mbc(Pt1, inc)(u2_wire wir_r,
                   u2_atom a)                                     //  retain
  {
    return u2_rl_vint(wir_r, u2_rx(wir_r, a));
  }
示例#10
0
文件: ut_nest.c 项目: mnemnion/urbit
  static u2_flag
  _nest_dext_in(u2_wire wir_r,
                u2_noun van,
                u2_noun sut,
                u2_noun ref,
                u2_noun gil)
  {
    u2_noun p_sut, q_sut, r_sut, p_ref, q_ref, r_ref;

    if ( (u2_no == u2_dust(sut)) ) switch ( sut ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__noun: {
        return u2_yes;
      }
      case c3__void: {
        return _nest_sint(wir_r, van, sut, ref, gil);
      }
    }
    else switch ( u2_h(sut) ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__atom: {
        if ( (u2_yes == u2_dust(ref)) && (c3__atom == u2_h(ref)) ) {
          return u2_yes;
        }
        else return _nest_sint(wir_r, van, sut, ref, gil);
      }
      case c3__cell: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          if ( u2_yes == u2_as_pq(ref, c3__cell, &p_ref, &q_ref) ) {
            return u2_and(_nest_dext(wir_r, van, p_sut, p_ref, gil),
                          _nest_dext(wir_r, van, q_sut, q_ref, gil));
          }
          else return _nest_sint(wir_r, van, sut, ref, gil);
        }
      }
      case c3__core: {
        if ( u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          if ( (u2_yes == u2_as_pq(ref, c3__core, &p_ref, &q_ref)) ) {
            return _nest_cong(wir_r, van, sut, ref, gil);
          }
          else return _nest_sint(wir_r, van, sut, ref, gil);
        }
      }
      case c3__cube: {
        if ( u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          if ( u2_yes == u2_as_pq(ref, c3__cube, &p_ref, &q_ref) ) {
            return u2_sing(p_sut, p_ref);
          }
          else return _nest_sint(wir_r, van, sut, ref, gil);
        }
      }
      case c3__face: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else { 
          return _nest_dext(wir_r, van, q_sut, ref, gil);
        }
      }
      case c3__fine: {
        if ( (u2_no == u2_as_qual(sut, 0, &p_sut, &q_sut, &r_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else { 
          if ( (u2_yes == u2_as_pqr(ref, c3__fine, &p_ref, &q_ref, &r_ref)) ) {
            return u2_and
              (u2_sing(p_sut, p_ref),
               u2_and(u2_sing(q_sut, q_ref),
                      _nest_dext(wir_r, van, r_sut, r_ref, gil)));
          }
          else return _nest_sint(wir_r, van, sut, ref, gil);
        }
      }
      case c3__fork: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        }
        else {
          if ( u2_no == u2_dust(ref) ) switch ( ref ) {
            default: return _nest_sint(wir_r, van, sut, ref, gil);

            case c3__noun:
              break;
          }
          else switch ( u2_h(ref) ) {
            default: return _nest_sint(wir_r, van, sut, ref, gil);
            
            case c3__atom:
            case c3__cell: 
            case c3__cube:
            case c3__core:
            case c3__fine:
              break;
          }

          return u2_or(_nest_dext(wir_r, van, p_sut, ref, gil),
                       _nest_dext(wir_r, van, q_sut, ref, gil));
        }
      } 
      case c3__hold: p_sut = u2_t(sut);
      {
        u2_noun hud = u2_bc(wir_r, u2_rx(wir_r, sut), 
                                   u2_rx(wir_r, ref));

        if ( (u2_yes == j2_mcc(Pt4, in, has)(wir_r, gil, hud)) ) {
          u2_rl_lose(wir_r, hud);

          return u2_yes;
        } else {
          u2_noun zoc = j2_mcc(Pt4, in, put)(wir_r, gil, hud);
          u2_type fop = j2_mcy(Pt6, ut, rest)(wir_r, van, sut, p_sut);
          u2_flag hiv = _nest_dext(wir_r, van, fop, ref, zoc);

          u2_rl_lose(wir_r, hud);
          u2_rl_lose(wir_r, fop);
          u2_rl_lose(wir_r, zoc);

          return hiv;
        }
      }
    }
  }
示例#11
0
文件: ut_mint.c 项目: mnemnion/urbit
  static u2_noun                                                  //  produce
  _mint_in(u2_wire wir_r, 
           u2_noun van,                                           //  retain
           u2_noun sut,                                           //  retain
           u2_noun gol,                                           //  retain
           u2_noun gen)                                           //  retain
  {
    u2_noun p_gen, q_gen, r_gen;
    u2_noun ret;

    if ( (c3__void == sut) && 
         !((u2_yes == u2_dust(gen)) && (c3__zpcb == u2_h(gen))) )
    {
      if ( (u2_no == _mint_vet(wir_r, van))
           || ((u2_yes == u2_dust(gen)) && 
               ((c3__zpfs == u2_h(gen)) || (c3__zpzp == u2_h(gen)))) )
      {
        return u2_bt(wir_r, c3__void, _0, _0);
      }
      else {
        return u2_bl_error(wir_r, "mint-vain");
      }
    }

    if ( u2_no == u2_dust(gen) ) {
      u2_noun ter = u2_frag(u2_cw_con_2, van);
      u2_noun rex = j2_mcy(Pt6, ap, open)(wir_r, ter, gen);

      ret = _mint_in(wir_r, van, sut, gol, rex);
      u2_rl_lose(wir_r, rex);

      return ret;
    } 
    else if ( u2_yes == u2_dust(u2_h(gen)) ) {
      _mint_used(wir_r);
      {
        u2_noun hed = _mint_in(wir_r, van, sut, c3__noun, u2_h(gen));
        u2_noun tal = _mint_in(wir_r, van, sut, c3__noun, u2_t(gen));
        u2_noun typ = j2_mby(Pt6, cell)(wir_r, u2_h(hed), u2_h(tal));

        ret = u2_bc
          (wir_r,
           _mint_nice(wir_r, van, gol, typ),
           j2_mby(Pt6, cons)(wir_r, u2_t(hed), u2_t(tal)));

        u2_rl_lose(wir_r, hed);
        u2_rl_lose(wir_r, tal);

        return ret;
      }
    } else switch ( u2_h(gen) ) {
      default: {
        u2_noun ter = u2_frag(u2_cw_con_2, van);
        u2_noun rex = j2_mcy(Pt6, ap, open)(wir_r, ter, gen);

        if ( u2_yes == u2_sing(rex, gen) ) {
#if 1
          u2_noun zix = j2_mcy(Pt6, ut, shep)
                (wir_r, van, "gene", 'q', u2_rx(wir_r, gen));

          u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, zix));
          return u2_bl_error(wir_r, "mint-open");
#else
          u2_err(wir_r, "h", u2_h(gen));
          return u2_bl_bail(wir_r, c3__fail);
#endif
        }
        ret = _mint_in(wir_r, van, sut, gol, rex);
        u2_rl_lose(wir_r, rex);

        return ret;
      }
      
      case c3__wtcn: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun vol = _mint_corn(wir_r, van, sut, q_gen);
        u2_noun axe = _mint_coke(wir_r, vol);
        u2_noun wam = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);

        ret = u2_bc
          (wir_r,
           _mint_nice(wir_r, van, gol, _mint_flag(wir_r)),
           j2_mcy(Pt6, ut, fish)(wir_r, van, wam, axe));

        u2_rl_lose(wir_r, axe);
        u2_rl_lose(wir_r, wam);
        return ret;
      }
      case c3__wtcl: u2_bi_trel(wir_r, u2_t(gen), &p_gen, &q_gen, &r_gen);
      _mint_used(wir_r);
      {
        u2_noun bol = _mint_flag(wir_r);
        u2_noun nor = _mint_in(wir_r, van, sut, bol, p_gen);
        u2_noun fex = j2_mcy(Pt6, ut, gain)(wir_r, van, sut, p_gen);
        u2_noun wux = j2_mcy(Pt6, ut, lose)(wir_r, van, sut, p_gen);
        u2_noun duy = (c3__void == fex)
                        ? ( (c3__void == wux)
                             ?  u2_bc(wir_r, _0, _0)
                             :  u2_bc(wir_r, _1, _1) )
                        : ( (c3__void == wux)
                            ?  u2_bc(wir_r, _1, _0)
                            :  u2_rx(wir_r, u2_t(nor)) );
        u2_noun hiq = _mint_in(wir_r, van, fex, gol, q_gen);
        u2_noun ran = _mint_in(wir_r, van, wux, gol, r_gen);

        ret = u2_bc
          (wir_r, j2_mby(Pt6, fork)(wir_r, u2_h(hiq), u2_h(ran)),
                  _mint_cond(wir_r, duy, 
                                    u2_rx(wir_r, u2_t(hiq)),
                                    u2_rx(wir_r, u2_t(ran))));

        u2_rl_lose(wir_r, ran);
        u2_rl_lose(wir_r, hiq);
        u2_rl_lose(wir_r, nor);
        u2_rl_lose(wir_r, wux);
        u2_rl_lose(wir_r, fex);
        u2_rl_lose(wir_r, bol);

        return ret;
      }
      case c3__clhp: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun hed = _mint_in(wir_r, van, sut, c3__noun, p_gen);
        u2_noun tal = _mint_in(wir_r, van, sut, c3__noun, q_gen);
        u2_noun typ = j2_mby(Pt6, cell)(wir_r, u2_h(hed), u2_h(tal));

        ret = u2_bc
          (wir_r,
           _mint_nice(wir_r, van, gol, typ),
           j2_mby(Pt6, cons)(wir_r, u2_t(hed), u2_t(tal)));

        u2_rl_lose(wir_r, hed);
        u2_rl_lose(wir_r, tal);

        return ret;
      }
      case c3__dtts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun typ = _mint_nice(wir_r, van, gol, _mint_flag(wir_r));

        return u2_bc
          (wir_r, 
           typ,
           u2_bt(wir_r, _5, _mint_corn(wir_r, van, sut, p_gen),
                            _mint_corn(wir_r, van, sut, q_gen)));
      }
      case c3__dtwt: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun typ = _mint_nice(wir_r, van, gol, _mint_flag(wir_r));

        return u2_bc
          (wir_r, 
           typ,
           u2_bc(wir_r, _3, _mint_corn(wir_r, van, sut, p_gen)));
      }
      case c3__dtkt: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun tom = c3__noun;
        u2_noun sam = _mint_in(wir_r, van, sut, tom, p_gen);

        ret = u2_bc
          (wir_r, 
           _mint_nice(wir_r, van, gol, tom),
           u2_bc(wir_r, _11, u2_rx(wir_r, u2_t(sam))));
        
        u2_rz(wir_r, sam);
        return ret;
      }
      case c3__dtls: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun tom = u2_bc(wir_r, c3__atom, u2_blip);
        u2_noun sam = _mint_in(wir_r, van, sut, tom, p_gen);

        ret = u2_bc
          (wir_r, 
           _mint_nice(wir_r, van, gol, tom),
           u2_bc(wir_r, _4, u2_rx(wir_r, u2_t(sam))));
        
        u2_rz(wir_r, sam);
        return ret;
      }
      case c3__dtsg: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun boc = (u2_no == u2_stud(q_gen)) 
                        ? c3__noun
                        : u2_bc(wir_r, c3__atom, u2_rx(wir_r, p_gen));
        u2_noun typ = j2_mby(Pt6, cube)(wir_r, q_gen, boc);
        u2_noun ret = 
            u2_bc(wir_r,
                  _mint_nice(wir_r, van, gol, typ),
                  u2_bc(wir_r, _1, u2_rx(wir_r, q_gen)));

        u2_rz(wir_r, boc);
        return ret;
      }
      case c3__dttr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        return u2_bc
          (wir_r, 
           _mint_nice(wir_r, van, gol, c3__noun),
           u2_bt(wir_r, _2, _mint_corn(wir_r, van, sut, p_gen),
                            _mint_corn(wir_r, van, sut, q_gen)));
      }
      case c3__dtpt: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun typ = j2_mcy(Pt6, ut, play)(wir_r, van, sut, gen);
        u2_noun ret = 
            u2_bc(wir_r,
                  _mint_nice(wir_r, van, gol, typ),
                  u2_bc(wir_r, _1, u2_rx(wir_r, q_gen)));

        return ret;
      }
      case c3__ktdt: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun wit = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun nep = j2_mcy(Pt6, ut, snap)(wir_r, van, wit, q_gen);
        u2_noun ret = _mint_in(wir_r, van, sut, gol, nep);

        u2_rz(wir_r, nep);
        u2_rz(wir_r, wit);
        return ret;
      }
      case c3__ktbr: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun ryd = _mint_in(wir_r, van, sut, gol, p_gen);
        u2_noun tyf = j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_h(ryd), c3__iron);
        u2_noun pro = u2_bc(wir_r, tyf, u2_rx(wir_r, u2_t(ryd)));

        u2_rz(wir_r, ryd);
        return pro;
      }
      case c3__ktpm: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun ryd = _mint_in(wir_r, van, sut, gol, p_gen);
        u2_noun tyf = j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_h(ryd), c3__zinc);
        u2_noun pro = u2_bc(wir_r, tyf, u2_rx(wir_r, u2_t(ryd)));

        u2_rz(wir_r, ryd);
        return pro;
      }
      case c3__ktwt: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun ryd = _mint_in(wir_r, van, sut, gol, p_gen);
        u2_noun tyf = j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_h(ryd), c3__lead);
        u2_noun pro = u2_bc(wir_r, tyf, u2_rx(wir_r, u2_t(ryd)));

        u2_rz(wir_r, ryd);
        return pro;
      }
      case c3__ktts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun vat = _mint_in(wir_r, van, sut, gol, q_gen);
     
        ret = u2_bc
          (wir_r,
           u2_bt(wir_r, c3__face,
                        u2_rx(wir_r, p_gen), 
                        u2_rx(wir_r, u2_h(vat))),
           u2_rx(wir_r, u2_t(vat)));

        u2_rl_lose(wir_r, vat);
        return ret;
      }
      case c3__ktsg: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun nef = _mint_in(wir_r, van, sut, gol, p_gen);
        u2_noun p_nef = u2_h(nef);
        u2_noun q_nef = u2_t(nef);
        u2_noun fom;

        {
          u2_noun cag = j2_mcy(Pt6, ut, burn)(wir_r, van, sut);
          u2_noun wim = u2_cn_moch(cag, u2k(q_nef));

          if ( 0 == u2h(wim) ) {
            fom = u2nc(1, u2k(u2t(wim)));
          } else {
            fom = u2k(q_nef);
          }
          u2z(wim);
        }
        ret = u2_bc(wir_r, u2_rx(wir_r, p_nef), fom);
 
        u2_rz(wir_r, nef);
        return ret;
      }
      case c3__ktls: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun hif = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun zel = _mint_in(wir_r, van, sut, hif, q_gen);
        u2_noun ret = u2_bc(wir_r, hif, u2_rx(wir_r, u2_t(zel)));

        u2_rz(wir_r, zel);
        return ret;
      }
      case c3__tsgr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun fid = _mint_in(wir_r, van, sut, c3__noun, p_gen);
        u2_noun p_fid = u2_h(fid);
        u2_noun q_fid = u2_t(fid);
        u2_noun dov = _mint_in(wir_r, van, p_fid, gol, q_gen);
        u2_noun p_dov = u2_h(dov);
        u2_noun q_dov = u2_t(dov);

        ret = u2_bc
          (wir_r, u2_rx(wir_r, p_dov), 
                  j2_mbc(Pt6, comb)(wir_r, q_fid, q_dov));

        u2_rl_lose(wir_r, fid); 
        u2_rl_lose(wir_r, dov);
        return ret;
      }
      case c3__cnts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun sec = j2_mcy(Pt6, ut, seek)(wir_r, van, sut, c3__read, p_gen);
        u2_noun lar = _mint_foil(wir_r, sec);
        u2_noun p_lar = u2_h(lar);
        u2_noun q_lar = u2_t(lar);
        u2_noun pq_lar = u2_h(q_lar);
        u2_noun qq_lar = u2_t(q_lar);
        u2_noun mew = j2_mcy(Pt6, ut, swab)(wir_r, van, sut, qq_lar, q_gen);
        u2_noun yom = _mint_edit
          (wir_r, van, sut, mew, p_lar, u2_rx(wir_r, qq_lar), u2_nul);
        u2_noun p_yom = u2_h(yom);
        u2_noun q_yom = u2_t(yom);
        u2_noun ret = u2_bc
          (wir_r, _mint_nice(wir_r, van, gol, u2_rx(wir_r, p_yom)),
                  (_0 == pq_lar) ? u2_rx(wir_r, q_yom)
                                 : u2_bt(wir_r, _9,
                                                u2_rx(wir_r, pq_lar),
                                                u2_rx(wir_r, q_yom)));
                  
        u2_rz(wir_r, yom);
        u2_rz(wir_r, mew);
        u2_rz(wir_r, lar);

        return ret;
      }
      case c3__pmcl: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun ruf = u2_bt
          (wir_r, c3__clhp, 
                  u2_bc(wir_r, u2_nul, _1),
                  u2_rx(wir_r, p_gen));
        u2_noun ret = _mint_grow(wir_r, van, sut, gol, c3__zinc, ruf, q_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__brcn: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun ruf = u2_bc(wir_r, u2_nul, _1);

        ret = _mint_grow(wir_r, van, sut, gol, c3__gold, ruf, p_gen);
        u2_rz(wir_r, ruf);

        return ret;
      }
      case c3__pmcn: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun ruf = u2_bc(wir_r, u2_nul, _1);

        ret = _mint_grow(wir_r, van, sut, gol, c3__lead, ruf, p_gen);
        u2_rz(wir_r, ruf);

        return ret;
      }
      case c3__pmls: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun ruf = u2_bt
          (wir_r, c3__clhp, 
                  u2_bc(wir_r, u2_nul, _1),
                  u2_rx(wir_r, p_gen));
        u2_noun ret = _mint_grow(wir_r, van, sut, gol, c3__iron, ruf, q_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__sggr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun hum = _mint_in(wir_r, van, sut, gol, q_gen);
        u2_noun bez;
      
          if ( u2_yes == u2_stud(p_gen) ) {
            bez = u2_rx(wir_r, p_gen);
          } else {
            bez = u2_bc(wir_r, u2_rx(wir_r, u2_h(p_gen)),
                               _mint_corn(wir_r, van, sut, u2_t(p_gen)));
          }
          ret = u2_bc(wir_r, 
                      u2_rx(wir_r, u2_h(hum)),
                      u2_bt(wir_r, _10, bez, u2_rx(wir_r, u2_t(hum))));
        
        u2_rl_lose(wir_r, hum);
        return ret;
      }
      case c3__zpts: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        u2_noun von = u2_bn_molt(wir_r, van, j2_ut_van_vet, u2_no, 0);
        u2_noun sev = _mint_corn(wir_r, von, sut, p_gen);

        u2_rz(wir_r, von);
        return u2_bc(wir_r, c3__noun, u2_bc(wir_r, _1, sev));
      }
      case c3__zpcm: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        return u2_bc
          (wir_r, 
           _mint_nice(wir_r, van, 
                             gol, 
                             j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen)),
           u2_bc(wir_r, 1, u2_rx(wir_r, q_gen)));
      }
      case c3__zpcb: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      {
        u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, _mint_loc(wir_r, van, p_gen)));
        {
          u2_noun hum = _mint_in(wir_r, van, sut, gol, q_gen);
          u2_noun bez = u2_bt(wir_r, c3__spot, _1, u2_rx(wir_r, p_gen));

          ret = u2_bc(wir_r, 
                      u2_rx(wir_r, u2_h(hum)),
                      u2_bt(wir_r, _10, bez, u2_rx(wir_r, u2_t(hum))));

          u2_rz(wir_r, hum);
        }
        u2_bl_drop(wir_r);
        return ret;
      }
      case c3__zpcn:
      _mint_used(wir_r);
      {
        u2_noun pet   = u2_bn_hook(wir_r, van, "seed");
        u2_noun p_pet = u2_h(pet);
        u2_noun q_pet = u2_t(pet);
        u2_noun ret;

        ret = u2_bc(wir_r, _mint_nice(wir_r, van, gol, u2_rx(wir_r, p_pet)),
                           u2_bc(wir_r, _1, u2_rx(wir_r, q_pet)));

        u2_rz(wir_r, pet);
        return ret;
      }
      case c3__zpsm: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mint_used(wir_r);
      {
        u2_noun vos   = _mint_in(wir_r, van, sut, c3__noun, q_gen);
        u2_noun zur   = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun p_vos = u2_h(vos);
        u2_noun q_vos = u2_t(vos);
        u2_noun waz   = u2_bc(wir_r, _1, u2_rx(wir_r, p_vos));
        u2_noun cig   = j2_mby(Pt6, cell)(wir_r, zur, p_vos);
        u2_noun ret;

        ret = u2_bc(wir_r,
                    _mint_nice(wir_r, van, gol, cig),
                    j2_mby(Pt6, cons)(wir_r, waz, q_vos));

        u2_rz(wir_r, waz);
        u2_rz(wir_r, zur);
        u2_rz(wir_r, vos);

        return ret;
      }
      case c3__zpfs: p_gen = u2_t(gen);
      _mint_used(wir_r);
      {
        if ( u2_yes == _mint_vet(wir_r, van) ) {
          u2_noun zur = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
          u2_noun dun = j2_mcy(Pt6, ut, dunq)(wir_r, van, "lost", zur);

          u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, dun));
          return u2_bl_error(wir_r, "mint-lost");
        }
        else {
          return u2_bt(wir_r, c3__void, _0, _0);
        }
      }
      case c3__zpzp:
      _mint_used(wir_r);
      {
        return u2_bt(wir_r, c3__void, _0, _0);
      }
    }
  }
示例#12
0
文件: ut_mull.c 项目: mnemnion/urbit
  static u2_noun 
  _mull_grow(u2_wire wir_r,
             u2_noun van,
             u2_noun sut,
             u2_noun gol,
             u2_noun dox,
             u2_atom mel,
             u2_noun ruf,
             u2_noun dab)
  {
    u2_noun dan = _mull_in(wir_r, van, sut, c3__noun, dox, ruf);
    u2_noun p_dan = u2_h(dan);
    u2_noun q_dan = u2_t(dan);
    u2_noun p_toc = _mull_core
      (wir_r, u2_rx(wir_r, p_dan),
              u2_bt(wir_r, c3__gold, 
                           u2_rx(wir_r, p_dan), 
                           u2_bc(wir_r, u2_nul, u2_rx(wir_r, dab))));
    u2_noun q_toc = _mull_core
      (wir_r, u2_rx(wir_r, q_dan),
              u2_bt(wir_r, c3__gold, 
                           u2_rx(wir_r, q_dan), 
                           u2_bc(wir_r, u2_nul, u2_rx(wir_r, dab))));
    u2_noun p_ret = _mull_core
        (wir_r, u2_rx(wir_r, p_dan),
                u2_bt(wir_r, u2_rx(wir_r, mel),
                             u2_rx(wir_r, p_dan), 
                             u2_bc(wir_r, u2_bc(wir_r, u2_nul, u2_nul),
                                          u2_rx(wir_r, dab))));
    u2_noun q_ret = _mull_core
        (wir_r, u2_rx(wir_r, q_dan),
                u2_bt(wir_r, u2_rx(wir_r, mel),
                             u2_rx(wir_r, q_dan), 
                             u2_bc(wir_r, u2_bc(wir_r, u2_nul, u2_nul),
                                          u2_rx(wir_r, dab))));
    u2_noun ret = u2_bc(wir_r, _mull_nice(wir_r, van, gol, p_ret), q_ret);

    _mull_bake(wir_r, van, p_toc, q_toc, dab);

    u2_rz(wir_r, q_toc);
    u2_rz(wir_r, p_toc);
    u2_rz(wir_r, dan);

    return ret;
  }
/* functions
*/
  u2_weak                                                         //  transfer
  j2_mcc(Pt4, by, put)(u2_wire wir_r,
                       u2_noun a,                                 //  retain
                       u2_noun b,                                 //  retain
                       u2_noun c)                                 //  retain
  {
    if ( u2_nul == a ) {
      return u2_rt(wir_r,
                   u2_rc(wir_r, u2_rx(wir_r, b),
                                u2_rx(wir_r, c)),
                   u2_nul,
                   u2_nul);
    }
    else {
      u2_noun l_a, n_a, r_a, pn_a, qn_a;
      u2_noun d, l_d, n_d, r_d;

      if ( (u2_no == u2_as_trel(a, &n_a, &l_a, &r_a)) ||
           (u2_no == u2_as_cell(n_a, &pn_a, &qn_a)) )
      {
        return u2_bl_bail(wir_r, c3__exit);
      }
      else if ( u2_yes == u2_sing(pn_a, b) ) {
        if ( u2_yes == u2_sing(qn_a, c) ) {
          return u2_rx(wir_r, a);
        } else {
          return u2_rt
            (wir_r, u2_rc(wir_r, u2_rx(wir_r, b), u2_rx(wir_r, c)),
                    u2_rx(wir_r, l_a),
                    u2_rx(wir_r, r_a));
        }
      }
      else {
        if ( u2_yes == j2_mbc(Pt3, gor)(wir_r, b, pn_a) ) {
          d = j2_mcc(Pt4, by, put)(wir_r, l_a, b, c);

          if ( u2_yes == j2_mbc(Pt3, vor)(wir_r, pn_a, u2_h(u2_h(d))) ) {
            return u2_rt(wir_r, u2_rx(wir_r, n_a),
                                d,
                                u2_rx(wir_r, r_a));
          }
          else {
            u2_as_trel(d, &n_d, &l_d, &r_d);
            {
              u2_noun e = u2_rt
                (wir_r, u2_rx(wir_r, n_d),
                        u2_rx(wir_r, l_d),
                        u2_rt(wir_r,
                              u2_rx(wir_r, n_a),
                              u2_rx(wir_r, r_d),
                              u2_rx(wir_r, r_a)));

              u2_rl_lose(wir_r, d);
              return e;
            }
          }
        }
        else {
          d = j2_mcc(Pt4, by, put)(wir_r, r_a, b, c);

          if ( u2_yes == j2_mbc(Pt3, vor)(wir_r, pn_a, u2_h(u2_h(d))) ) {
            return u2_rt(wir_r, u2_rx(wir_r, n_a),
                                u2_rx(wir_r, l_a),
                                d);
          }
          else {
            u2_as_trel(d, &n_d, &l_d, &r_d);
            {
              u2_noun e = u2_rt
                (wir_r, u2_rx(wir_r, n_d),
                        u2_rt(wir_r,
                              u2_rx(wir_r, n_a),
                              u2_rx(wir_r, l_a),
                              u2_rx(wir_r, l_d)),
                        u2_rx(wir_r, r_d));

              u2_rl_lose(wir_r, d);
              return e;
            }
          }
        }
      }
    }
  }
示例#14
0
文件: ut_cull.c 项目: Gruelty/urbit
  static u2_noun 
  _cull_in(u2_wire wir_r, 
           u2_noun van,                                           //  retain
           u2_noun sut,                                           //  retain
           u2_bean pol,                                           //  retain
           u2_atom axe,                                           //  retain
           u2_noun ref,                                           //  retain
           u2_noun now,                                           //  retain
           u2_noun lat,                                           //  retain
           u2_noun vil)                                           //  retain
  {
    u2_noun ret, p_sut, q_sut, r_sut;

    if ( u2_no == u2_dust(sut) ) switch ( sut ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__noun: {
        u2_noun pyr = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
        u2_noun yot = j2_mcx(Pt6, ut, cull)(wir_r, van, pyr, pol, axe, ref);
        
        if ( u2_yes == u2_sing(pyr, yot) ) {
          ret = u2_rx(wir_r, sut); 
        } else {
          ret = u2_rx(wir_r, yot);
        }
        u2_rl_lose(wir_r, pyr);
        u2_rl_lose(wir_r, yot);
        break;
      }
      case c3__void: {
        ret = c3__void;
      }
    }
    else switch ( u2_h(sut) ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__atom: {
        ret = c3__void; 
        break;
      }
      case c3__cell: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        u2_noun hub;

        if ( _2 == now ) {
          hub = j2_mcx(Pt6, ut, cull)(wir_r, van, p_sut, pol, lat, ref);
          ret = j2_mby(Pt6, cell)(wir_r, hub, q_sut);
        } else {
          hub = j2_mcx(Pt6, ut, cull)(wir_r, van, q_sut, pol, lat, ref);
          ret = j2_mby(Pt6, cell)(wir_r, p_sut, hub);
        }
        u2_rl_lose(wir_r, hub);
        break;
      }
      case c3__core: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        if ( _3 != now ) {
          ret = u2_rx(wir_r, sut);
        } else {
          u2_noun hub = j2_mcx(Pt6, ut, cull)
                                   (wir_r, van, p_sut, pol, lat, ref);

          ret = j2_mby(Pt6, core)(wir_r, hub, q_sut);

          u2_rl_lose(wir_r, hub);
        }
        break;
      }
      case c3__face: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        u2_noun hic = j2_mcx(Pt6, ut, cull)
                                    (wir_r, van, q_sut, pol, axe, ref);

        if ( u2_yes == u2_sing(hic, q_sut) ) {
          ret = u2_rx(wir_r, sut); 
        } else {
          ret = j2_mby(Pt6, face)(wir_r, p_sut, hic);
        }
        u2_rl_lose(wir_r, hic);

        break;
      }
      case c3__fine: u2_bi_trel(wir_r, u2_t(sut), &p_sut, &q_sut, &r_sut);
      {
        u2_noun hic = j2_mcx(Pt6, ut, cull)(wir_r, van, r_sut, pol, axe, ref);

        if ( u2_yes == u2_sing(hic, r_sut) ) {
          ret = u2_rx(wir_r, sut); 
        } else {
          ret = j2_mby(Pt6, fine)(wir_r, p_sut, q_sut, hic);
        }
        u2_rl_lose(wir_r, hic);

        break;
      }
      case c3__fork: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        if ( u2_yes == j2_mcc(Pt4, in, has)(wir_r, vil, sut) ) {
          return c3__void;
        } else {
          u2_noun zoc = j2_mcc(Pt4, in, put)(wir_r, vil, sut);
          u2_noun sin = _cull_in
            (wir_r, van, p_sut, pol, axe, ref, now, lat, zoc);
          u2_noun dex = _cull_in
            (wir_r, van, q_sut, pol, axe, ref, now, lat, zoc);
     
          ret = j2_mby(Pt6, fork)(wir_r, sin, dex);
          u2_rl_lose(wir_r, sin);
          u2_rl_lose(wir_r, dex);
          u2_rl_lose(wir_r, zoc);

          return ret;
        }
      }
      case c3__cube: 
      case c3__hold: 
      {
        u2_noun pyr = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
        u2_noun yot = _cull_in(wir_r, van, pyr, pol, axe, ref, now, lat, vil);

        if ( u2_yes == u2_sing(pyr, yot) ) {
          if ( c3__void == pyr ) {
            ret = c3__void;
          }
          else ret = u2_rx(wir_r, sut); 
        } else {
          ret = u2_rx(wir_r, yot);
        }
        u2_rl_lose(wir_r, pyr);
        u2_rl_lose(wir_r, yot);
        break;
      }
    }
    u2_rl_lose(wir_r, lat);
    return ret;
  }
示例#15
0
文件: dash.c 项目: 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);
  }
}
示例#16
0
文件: dash.c 项目: 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;
  }
}
示例#17
0
文件: ut_cull.c 项目: mnemnion/urbit
  u2_noun                                                         //  transfer
  j2_mcx(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_noun ret, p_sut, q_sut, r_sut;

    if ( _1 == axe ) {
      if ( u2_yes == pol ) {
        return j2_mcy(Pt6, ut, fuse)(wir_r, van, sut, ref);
      } else {
        return j2_mcy(Pt6, ut, crop)(wir_r, van, sut, ref);
      }
    } else {
      u2_atom now = j2_mbc(Pt3, cap)(wir_r, axe);
      u2_atom lat = j2_mbc(Pt3, mas)(wir_r, axe);

      if ( u2_no == u2_dust(sut) ) switch ( sut ) {
        default: return u2_bl_bail(wir_r, c3__fail);

        case c3__noun: {
          u2_noun pyr = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
          u2_noun yot = j2_mcx(Pt6, ut, cull)(wir_r, van, pyr, pol, axe, ref);
          
          if ( u2_yes == u2_sing(pyr, yot) ) {
            ret = u2_rx(wir_r, sut); 
          } else {
            ret = u2_rx(wir_r, yot);
          }
          u2_rl_lose(wir_r, pyr);
          u2_rl_lose(wir_r, yot);
          break;
        }
        case c3__void: {
          ret = c3__void;
        }
      }
      else switch ( u2_h(sut) ) {
        default: return u2_bl_bail(wir_r, c3__fail);

        case c3__atom: {
          ret = c3__void; 
          break;
        }
        case c3__cell: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
        {
          u2_noun hub;

          if ( _2 == now ) {
            hub = j2_mcx(Pt6, ut, cull)(wir_r, van, p_sut, pol, lat, ref);
            ret = j2_mby(Pt6, cell)(wir_r, hub, q_sut);
          } else {
            hub = j2_mcx(Pt6, ut, cull)(wir_r, van, q_sut, pol, lat, ref);
            ret = j2_mby(Pt6, cell)(wir_r, p_sut, hub);
          }
          u2_rl_lose(wir_r, hub);
          break;
        }
        case c3__core: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
        {
          if ( _2 != now ) {
            ret = u2_rx(wir_r, sut);
          } else {
            u2_noun hub = j2_mcx(Pt6, ut, cull)
                                     (wir_r, van, p_sut, pol, lat, ref);

            ret = j2_mby(Pt6, core)(wir_r, hub, q_sut);

            u2_rl_lose(wir_r, hub);
          }
          break;
        }
        case c3__face: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
        {
          u2_noun hic = j2_mcx(Pt6, ut, cull)
                                      (wir_r, van, q_sut, pol, axe, ref);

          if ( u2_yes == u2_sing(hic, q_sut) ) {
            ret = u2_rx(wir_r, sut); 
          } else {
            ret = j2_mby(Pt6, face)(wir_r, p_sut, hic);
          }
          u2_rl_lose(wir_r, hic);

          break;
        }
        case c3__fine: u2_bi_trel(wir_r, u2_t(sut), &p_sut, &q_sut, &r_sut);
        {
          u2_noun hic = j2_mcx(Pt6, ut, cull)(wir_r, van, r_sut, pol, axe, ref);

          if ( u2_yes == u2_sing(hic, r_sut) ) {
            ret = u2_rx(wir_r, sut); 
          } else {
            ret = j2_mby(Pt6, fine)(wir_r, p_sut, q_sut, hic);
          }
          u2_rl_lose(wir_r, hic);

          break;
        }
        case c3__fork: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
        {
          u2_noun sin = j2_mcx(Pt6, ut, cull)(wir_r, van, p_sut, pol, axe, ref);
          u2_noun dex = j2_mcx(Pt6, ut, cull)(wir_r, van, q_sut, pol, axe, ref);

          ret = j2_mby(Pt6, fork)(wir_r, sin, dex);
          u2_rl_lose(wir_r, sin);
          u2_rl_lose(wir_r, dex);

          return ret;
        }
        case c3__cube: 
        case c3__hold: 
        {
          u2_noun pyr = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
          u2_noun yot = j2_mcx(Pt6, ut, cull)(wir_r, van, pyr, pol, axe, ref);

          if ( u2_yes == u2_sing(pyr, yot) ) {
            ret = u2_rx(wir_r, sut); 
          } else {
            ret = u2_rx(wir_r, yot);
          }
          u2_rl_lose(wir_r, pyr);
          u2_rl_lose(wir_r, yot);
          break;
        }
      }
      u2_rl_lose(wir_r, lat);
      return ret;
    }
  }
示例#18
0
文件: ut_fuse.c 项目: mnemnion/urbit
  static u2_noun
  _fuse_in(u2_wire wir_r,
           u2_noun van,
           u2_noun sut,
           u2_noun ref,
           u2_noun bix)
  {
    u2_noun p_sut, q_sut, r_sut;

    if ( u2_yes == u2_sing(sut, ref) || (c3__noun == ref) ) {
      return u2_rx(wir_r, sut);
    }
    if ( u2_no == u2_dust(sut) ) switch ( sut ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__noun: 
      {
        return u2_rx(wir_r, ref);
      }
      case c3__void:
      {
        return c3__void;
      }
    }
    else switch ( u2_h(sut) ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__atom:
      {
        if ( u2_yes == u2_dust(ref) ) {
          if ( c3__atom == u2_h(ref) ) {
            if ( u2_yes == _fuse_fitz(wir_r, u2_t(ref), u2_t(sut)) ) {
              return u2_rx(wir_r, sut);
            } else return u2_rx(wir_r, ref);
          }
          else if ( c3__cell == u2_h(ref) ) {
            return c3__void;
          }
        }
        return _fuse_in(wir_r, van, ref, sut, bix);
      }
      case c3__cell: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        u2_noun p_ref, q_ref;

        if ( u2_yes == u2_as_pq(ref, c3__cell, &p_ref, &q_ref) ) {
          u2_noun hed = _fuse_in(wir_r, van, p_sut, p_ref, bix);
          u2_noun tal = _fuse_in(wir_r, van, q_sut, q_ref, bix);
          u2_noun ret = j2_mby(Pt6, cell)(wir_r, hed, tal);

          u2_rl_lose(wir_r, hed);
          u2_rl_lose(wir_r, tal);
          return ret;
        }
        else return _fuse_in(wir_r, van, ref, sut, bix);
      }
      case c3__core: 
      {
        return _fuse_repo(wir_r, van, sut, ref, bix);
      }
      case c3__cube: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        u2_noun foz = _fuse_in(wir_r, van, q_sut, ref, bix);
        u2_noun ret;
        
        if ( u2_no == j2_mcy(Pt6, ut, firm)(wir_r, van, foz, p_sut) ) {
          ret = c3__void;
        } else {
          ret = j2_mby(Pt6, cube)(wir_r, p_sut, foz);
        }
        u2_rz(wir_r, foz);
        return ret;
      }
      case c3__face: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        u2_noun vot = _fuse_in(wir_r, van, q_sut, ref, bix);
        u2_noun ret = j2_mby(Pt6, face)(wir_r, p_sut, vot);

        u2_rl_lose(wir_r, vot);
        return ret;
      }
      case c3__fine: u2_bi_trel(wir_r, u2_t(sut), &p_sut, &q_sut, &r_sut);
      {
        u2_noun vot = _fuse_in(wir_r, van, r_sut, ref, bix);
        u2_noun ret = j2_mby(Pt6, fine)(wir_r, p_sut, q_sut, vot);

        u2_rz(wir_r, vot);
        return ret;
      }
      case c3__fork: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        u2_noun dis = _fuse_in(wir_r, van, p_sut, ref, bix);
        u2_noun dat = _fuse_in(wir_r, van, q_sut, ref, bix);
        u2_noun ret = j2_mby(Pt6, fork)(wir_r, dis, dat);

        u2_rl_lose(wir_r, dis);
        u2_rl_lose(wir_r, dat);
        return ret;
      }
      case c3__hold: p_sut = u2_t(sut);
      {
        u2_noun hud = u2_bc(wir_r, u2_rx(wir_r, sut), u2_rx(wir_r, ref));

        if ( u2_yes == j2_mcc(Pt4, in, has)(wir_r, bix, hud) ) {
          u2_noun dun = j2_mcy(Pt6, ut, dunq)(wir_r, van, "type", sut);
          u2_noun niz = j2_mcy(Pt6, ut, dunq)(wir_r, van, "over", ref);

          u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, dun));
          u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, niz));

          return u2_bl_error(wir_r, "fuse-loop");
        } else {
          u2_noun bux = j2_mcc(Pt4, in, put)(wir_r, bix, hud);
          u2_noun ret = _fuse_repo(wir_r, van, sut, ref, bux);

          u2_rz(wir_r, hud);
          u2_rz(wir_r, bux);
          return ret;
        }
      }
    }
  }
示例#19
0
文件: ut_mull.c 项目: mnemnion/urbit
  static u2_noun                                                  //  produce
  _mull_in(u2_wire wir_r, 
           u2_noun van,                                           //  retain
           u2_noun sut,                                           //  retain
           u2_noun gol,                                           //  retain
           u2_noun dox,                                           //  retain
           u2_noun gen)                                           //  retain
  {
    u2_noun p_gen, q_gen, r_gen;
    u2_noun ret;

    if ( u2_no == u2_dust(gen) ) {
      u2_noun ter = u2_frag(u2_cw_con_2, van);
      u2_noun rex = j2_mcy(Pt6, ap, open)(wir_r, ter, gen);

      ret = _mull_in(wir_r, van, sut, gol, dox, rex);
      u2_rl_lose(wir_r, rex);

      return ret;
    } 
    else if ( u2_yes == u2_dust(u2_h(gen)) ) {
      _mull_used(wir_r);
      {
        u2_noun hed = _mull_in(wir_r, van, sut, c3__noun, dox, u2_h(gen));
        u2_noun tal = _mull_in(wir_r, van, sut, c3__noun, dox, u2_t(gen));
        u2_noun dis = j2_mby(Pt6, cell)(wir_r, u2_h(hed), u2_h(tal));
        u2_noun dat = j2_mby(Pt6, cell)(wir_r, u2_t(hed), u2_t(tal));
        u2_noun ret = u2_bc(wir_r, _mull_nice(wir_r, van, gol, dis), dat);

        u2_rz(wir_r, tal);
        u2_rz(wir_r, hed);

        return ret;
      }
    }
    else switch ( u2_h(gen) ) {
      default: {
        u2_noun ter = u2_frag(u2_cw_con_2, van);
        u2_noun rex = j2_mcy(Pt6, ap, open)(wir_r, ter, gen);

        if ( u2_yes == u2_sing(rex, gen) ) {
#if 1
          u2_noun zix = j2_mcy(Pt6, ut, shep)
                (wir_r, van, "gene", 'q', u2_rx(wir_r, gen));

          u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, zix));
          return u2_bl_error(wir_r, "mull-open");
#else
          u2_err(wir_r, "h", u2_h(gen));
          return u2_bl_bail(wir_r, c3__fail);
#endif
        }
        ret = _mull_in(wir_r, van, sut, gol, dox, rex);
        u2_rl_lose(wir_r, rex);

        return ret;
      }
      
      case c3__wtcn: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun p_waz = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun q_waz = j2_mcy(Pt6, ut, play)(wir_r, van, dox, p_gen);
        u2_noun p_syx = _mull_doke(wir_r, van, sut, q_gen);
        u2_noun q_syx = _mull_doke(wir_r, van, dox, q_gen);
        u2_noun p_pov = j2_mcy(Pt6, ut, fish)(wir_r, van, p_waz, p_syx);
        u2_noun q_pov = j2_mcy(Pt6, ut, fish)(wir_r, van, q_waz, q_syx);

        if ( (u2_no == u2_sing(p_syx, q_syx)) ||
             (u2_no == u2_sing(p_pov, q_pov)) ) 
        {
          return u2_bl_error(wir_r, "mull-bonk-b");
        }
        u2_rz(wir_r, p_waz); u2_rz(wir_r, q_waz);
        u2_rz(wir_r, p_syx); u2_rz(wir_r, q_syx);
        u2_rz(wir_r, p_pov); u2_rz(wir_r, q_pov);

        return _mull_both(wir_r, van, gol, _mull_flag(wir_r));
      }
      case c3__wtcl: u2_bi_trel(wir_r, u2_t(gen), &p_gen, &q_gen, &r_gen);
      _mull_used(wir_r);
      {
        u2_noun bol = _mull_flag(wir_r);
        u2_noun nor = _mull_in(wir_r, van, sut, bol, dox, p_gen);
        u2_noun p_fex = j2_mcy(Pt6, ut, gain)(wir_r, van, sut, p_gen);
        u2_noun q_fex = j2_mcy(Pt6, ut, gain)(wir_r, van, dox, p_gen);
        u2_noun p_wux = j2_mcy(Pt6, ut, lose)(wir_r, van, sut, p_gen);
        u2_noun q_wux = j2_mcy(Pt6, ut, lose)(wir_r, van, dox, p_gen);
        u2_noun hiq, ran;
        u2_noun dis, dat;
        u2_noun ret;
   
        if ( c3__void == p_fex ) {
          hiq = u2_bc(wir_r, 
                      c3__void, 
                      (c3__void == q_fex)
                        ? c3__void
                        : j2_mcy(Pt6, ut, play)(wir_r, van, q_fex, q_gen));
        } else if ( c3__void == q_fex ) {
          hiq = u2_bl_error(wir_r, "mull-bonk-c");
        }
        else hiq = _mull_in(wir_r, van, p_fex, gol, q_fex, q_gen);

        if ( c3__void == p_wux ) {
          ran = u2_bc(wir_r, 
                      c3__void, 
                      (c3__void == q_wux)
                        ? c3__void
                        : j2_mcy(Pt6, ut, play)(wir_r, van, q_wux, r_gen));
        } else if ( c3__void == q_wux ) {
          ran = u2_bl_error(wir_r, "mull-bonk-d");
        }
        else ran = _mull_in(wir_r, van, p_wux, gol, q_wux, r_gen);

        dis = j2_mby(Pt6, fork)(wir_r, u2_h(hiq), u2_h(ran));
        dat = j2_mby(Pt6, fork)(wir_r, u2_t(hiq), u2_t(ran));

        ret = u2_bc(wir_r, _mull_nice(wir_r, van, gol, dis), dat);

        u2_rz(wir_r, ran);
        u2_rz(wir_r, hiq);
        u2_rz(wir_r, q_wux);
        u2_rz(wir_r, p_wux);
        u2_rz(wir_r, q_fex);
        u2_rz(wir_r, p_fex);
        u2_rz(wir_r, nor);
        u2_rz(wir_r, bol);

        return ret;
      }
      case c3__clhp: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun hed = _mull_in(wir_r, van, sut, c3__noun, dox, p_gen);
        u2_noun tal = _mull_in(wir_r, van, sut, c3__noun, dox, q_gen);
        u2_noun dis = j2_mby(Pt6, cell)(wir_r, u2_h(hed), u2_h(tal));
        u2_noun dat = j2_mby(Pt6, cell)(wir_r, u2_t(hed), u2_t(tal));
        u2_noun ret = u2_bc(wir_r, _mull_nice(wir_r, van, gol, dis), dat);

        u2_rz(wir_r, tal);
        u2_rz(wir_r, hed);

        return ret;
      }
      case c3__dtts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun hed = _mull_in(wir_r, van, sut, c3__noun, dox, p_gen);
        u2_noun tal = _mull_in(wir_r, van, sut, c3__noun, dox, q_gen);

        u2_rz(wir_r, hed);
        u2_rz(wir_r, tal);

        return _mull_both(wir_r, van, gol, _mull_flag(wir_r));
      }
      case c3__dtwt: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun vay = _mull_in(wir_r, van, sut, c3__noun, dox, p_gen);
        
        u2_rz(wir_r, vay);
        return _mull_both(wir_r, van, gol, _mull_flag(wir_r));
      }
      case c3__dtkt: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun wuq = c3__noun;
        u2_noun vay = _mull_in(wir_r, van, sut, wuq, dox, p_gen);
 
        u2_rz(wir_r, vay);
        return _mull_both(wir_r, van, gol, wuq);
      }
      case c3__dtls: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun wuq = u2_bc(wir_r, c3__atom, u2_blip);
        u2_noun vay = _mull_in(wir_r, van, sut, wuq, dox, p_gen);
 
        u2_rz(wir_r, vay);
        return _mull_both(wir_r, van, gol, wuq);
      }
      case c3__dtsg: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun tof = u2_bt
          (wir_r, c3__cube,
                  u2_rx(wir_r, q_gen),
                  (u2_yes == u2_dust(q_gen))
                    ? c3__noun
                    : u2_bc(wir_r, c3__atom, u2_rx(wir_r, p_gen)));

        return _mull_both(wir_r, van, gol, tof);
      }
      case c3__dttr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun hed = _mull_in(wir_r, van, sut, c3__noun, dox, p_gen);
        u2_noun tal = _mull_in(wir_r, van, sut, c3__noun, dox, q_gen);

        u2_rz(wir_r, hed);
        u2_rz(wir_r, tal);

        return _mull_both(wir_r, van, gol, c3__noun);
      }
      case c3__dtpt: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun typ = j2_mcy(Pt6, ut, play)(wir_r, van, sut, gen);
        return _mull_both(wir_r, van, gol, typ);
      }
      case c3__ktgl: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun hoz = j2_mcy(Pt6, ap, late)(wir_r, gen);
        u2_noun ryd = _mull_in(wir_r, van, sut, c3__noun, dox, hoz);
        u2_noun boc = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun ret = 
          u2_bc(wir_r, 
                _mull_nice
                  (wir_r, van, gol, j2_mby(Pt6, fine)
                                      (wir_r, c3__very, boc, u2_h(ryd))),
                u2_rx(wir_r, u2_t(ryd)));

        u2_rz(wir_r, boc);
        u2_rz(wir_r, ryd);
        u2_rz(wir_r, hoz);

        return ret;
      }
      case c3__ktdt: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun p_wiv = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun q_wiv = j2_mcy(Pt6, ut, play)(wir_r, van, dox, p_gen);
        u2_noun p_hef = j2_mcy(Pt6, ut, snap)(wir_r, van, p_wiv, q_gen);
        u2_noun q_hef = j2_mcy(Pt6, ut, snap)(wir_r, van, q_wiv, q_gen);
        u2_noun ret;

        if ( u2_yes == u2_sing(p_hef, q_hef) ) {
          ret = _mull_in(wir_r, van, sut, gol, dox, p_hef);
        } else {
          u2_noun zyn = _mull_in(wir_r, van, sut, gol, dox, p_hef);

          ret = u2_bc(wir_r, u2_rx(wir_r, u2_h(zyn)),
                             j2_mcy(Pt6, ut, play)(wir_r, van, dox, q_hef));
          u2_rz(wir_r, zyn);
        }
        u2_rz(wir_r, q_hef);
        u2_rz(wir_r, p_hef);
        u2_rz(wir_r, q_wiv);
        u2_rz(wir_r, p_wiv);

        return ret;
      }
      case c3__ktbr: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun vat = _mull_in(wir_r, van, sut, gol, dox, p_gen);
        u2_noun pro = u2_bc
          (wir_r, j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_h(vat), c3__iron),
                  j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_t(vat), c3__iron));

        u2_rz(wir_r, vat);
        return pro;
      }
      case c3__ktpm: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun vat = _mull_in(wir_r, van, sut, gol, dox, p_gen);
        u2_noun pro = u2_bc
          (wir_r, j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_h(vat), c3__zinc),
                  j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_t(vat), c3__zinc));

        u2_rz(wir_r, vat);
        return pro;
      }
      case c3__ktwt: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun vat = _mull_in(wir_r, van, sut, gol, dox, p_gen);
        u2_noun pro = u2_bc
          (wir_r, j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_h(vat), c3__lead),
                  j2_mcy(Pt6, ut, wrap)(wir_r, van, u2_t(vat), c3__lead));

        u2_rz(wir_r, vat);
        return pro;
      }
      case c3__ktts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun vat = _mull_in(wir_r, van, sut, gol, dox, q_gen);
        u2_noun ret = 
          u2_bc(wir_r, 
                j2_mby(Pt6, face)(wir_r, p_gen, u2_h(vat)),
                j2_mby(Pt6, face)(wir_r, p_gen, u2_t(vat)));

        u2_rz(wir_r, vat);
        return ret;
      }
      case c3__ktgr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun hoz = j2_mcy(Pt6, ap, late)(wir_r, gen);
        u2_noun ryd = _mull_in(wir_r, van, sut, c3__noun, dox, hoz);
        u2_noun boc = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun ret = 
          u2_bc(wir_r, 
                _mull_nice
                  (wir_r, van, gol, j2_mby(Pt6, fine)
                                      (wir_r, c3__pure, boc, u2_h(ryd))),
                u2_rx(wir_r, u2_t(ryd)));

        u2_rz(wir_r, boc);
        u2_rz(wir_r, ryd);
        u2_rz(wir_r, hoz);

        return ret;
      }
      case c3__ktsg: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        return _mull_in(wir_r, van, sut, gol, dox, p_gen);
      }
      case c3__ktls: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun p_hif = _mull_nice
          (wir_r, van, gol, j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen));
        u2_noun q_hif = j2_mcy(Pt6, ut, play)(wir_r, van, dox, p_gen);

        u2_noun zel = _mull_in(wir_r, van, sut, p_hif, dox, q_gen);
        u2_noun ret = u2_bc(wir_r, p_hif, q_hif);

        u2_rz(wir_r, zel);
        return ret;
      }
      case c3__tsgr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun lem = _mull_in(wir_r, van, sut, c3__noun, dox, p_gen);
        u2_noun p_lem = u2_h(lem);
        u2_noun q_lem = u2_t(lem);
        u2_noun ret = _mull_in(wir_r, van, p_lem, gol, q_lem, q_gen);

        u2_rz(wir_r, lem);
        return ret;
      }
      case c3__cnts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun sec = j2_mcy(Pt6, ut, seek)(wir_r, van, sut, c3__read, p_gen);
        u2_noun suc = j2_mcy(Pt6, ut, seek)(wir_r, van, dox, c3__read, p_gen);
        u2_noun lar = _mull_foil(wir_r, sec);
        u2_noun p_lar = u2_h(lar);
        u2_noun q_lar = u2_t(lar);
        u2_noun pq_lar = u2_h(q_lar);
        u2_noun qq_lar = u2_t(q_lar);
        u2_noun vug = _mull_foil(wir_r, suc);
        u2_noun p_vug = u2_h(vug);
        u2_noun q_vug = u2_t(vug);
        u2_noun pq_vug = u2_h(q_vug);
        u2_noun qq_vug = u2_t(q_vug);
        u2_noun zoz = u2_and(u2_sing(p_lar, p_vug), u2_sing(pq_lar, pq_vug))
                        ? u2_bl_error(wir_r, "mull-bonk-f")
                        : 0;
        u2_noun mew = j2_mcy(Pt6, ut, swab)(wir_r, van, sut, qq_lar, q_gen);
        u2_noun muw = j2_mcy(Pt6, ut, swab)(wir_r, van, dox, qq_vug, q_gen);
        u2_noun qoq = u2_sing(mew, muw)
                        ? u2_bl_error(wir_r, "mull-bonk-g")
                        : 0;
        u2_noun yom = _mull_edit
          (wir_r, van, sut, dox, mew, u2_rx(wir_r, qq_lar), 
                                      u2_rx(wir_r, qq_vug));
        u2_noun von = u2_bn_molt(wir_r, van, j2_ut_van_vet, u2_no, 0);
        u2_noun p_ret = j2_mcy(Pt6, ut, fire)(wir_r, van, sut, u2_h(yom));
        u2_noun q_ret = j2_mcy(Pt6, ut, fire)(wir_r, von, sut, u2_t(yom));

        qoq = qoq; zoz = zoz;

        u2_rz(wir_r, von);
        u2_rz(wir_r, yom);
        u2_rz(wir_r, muw);
        u2_rz(wir_r, mew);
        u2_rz(wir_r, vug);
        u2_rz(wir_r, lar);

        return u2_bc(wir_r, _mull_nice(wir_r, van, gol, p_ret), q_ret);
      }
      case c3__pmcl: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun ruf = u2_bt
          (wir_r, c3__clhp, 
                  u2_bc(wir_r, u2_nul, _1),
                  u2_rx(wir_r, p_gen));
        u2_noun ret = _mull_grow
          (wir_r, van, sut, gol, dox, c3__zinc, ruf, q_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__brcn: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun ruf = u2_bc(wir_r, u2_nul, _1);

        ret = _mull_grow(wir_r, van, sut, gol, dox, c3__gold, ruf, p_gen);
        u2_rz(wir_r, ruf);

        return ret;
      }
      case c3__pmcn: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        u2_noun ruf = u2_bc(wir_r, u2_nul, _1);

        ret = _mull_grow(wir_r, van, sut, gol, dox, c3__lead, ruf, p_gen);
        u2_rz(wir_r, ruf);

        return ret;
      }
      case c3__pmls: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun ruf = u2_bt
          (wir_r, c3__clhp, 
                  u2_bc(wir_r, u2_nul, _1),
                  u2_rx(wir_r, p_gen));
        u2_noun ret = _mull_grow
          (wir_r, van, sut, gol, dox, c3__iron, ruf, q_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__sggr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        return _mull_in(wir_r, van, sut, gol, dox, q_gen);
      }
      case c3__zpcm: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun p_ret = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun q_ret = j2_mcy(Pt6, ut, play)(wir_r, van, sut, q_gen);

        return u2_bc
          (wir_r, _mull_nice(wir_r, van, gol, p_ret),
                  q_ret);
      }
      case c3__zpcb: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      {
        u2_noun ret;

        u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, _mull_loc(wir_r, van, p_gen)));
        {
          ret = _mull_in(wir_r, van, sut, gol, dox, q_gen);
        }
        u2_bl_drop(wir_r);
        return ret;
      }
      case c3__zpts: p_gen = u2_t(gen);
      _mull_used(wir_r);
      {
        return _mull_both(wir_r, van, gol, c3__noun);
      }
      case c3__zpcn:
      _mull_used(wir_r);
      {
        u2_noun pet = u2_bn_hook(wir_r, van, "seed");
        u2_noun peq = u2_rx(wir_r, u2_h(pet));

        u2_rz(wir_r, pet);
        return _mull_both(wir_r, van, gol, peq);
      }
      case c3__zpsm: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _mull_used(wir_r);
      {
        u2_noun p_zur = j2_mcy(Pt6, ut, play)(wir_r, van, sut, p_gen);
        u2_noun q_zur = j2_mcy(Pt6, ut, play) (wir_r, van, dox, p_gen);
        u2_noun vos = _mull_in(wir_r, van, sut, c3__noun, dox, q_gen);
        u2_noun p_ret = j2_mby(Pt6, cell)(wir_r, p_zur, u2_h(vos));
        u2_noun q_ret = j2_mby(Pt6, cell)(wir_r, q_zur, u2_t(vos));

        u2_rz(wir_r, vos);
        u2_rz(wir_r, q_zur);
        u2_rz(wir_r, p_zur);

        return u2_bc
          (wir_r, _mull_nice(wir_r, van, gol, p_ret), q_ret);
      }
      case c3__zpfs:
      case c3__zpzp:
      _mull_used(wir_r);
      {
        return u2_bc(wir_r, c3__void, c3__void);
      }
    }
  }
/* functions
*/
  u2_weak                                                         //  transfer
  j2_mcc(Pt4, by, uni)(u2_wire wir_r,
                       u2_noun a,                                 //  retain
                       u2_noun b)                                 //  retain
  {
    if ( u2_nul == a ) {
      return u2_rx(wir_r, b);
    }
    else if ( u2_nul == b ) {
      return u2_rx(wir_r, a);
    }
    else {
      u2_noun l_a, n_a, r_a, lr_a, p_n_a, q_n_a;
      u2_noun l_b, n_b, r_b, lr_b, p_n_b, q_n_b;

      if ( (u2_no == u2_as_cell(a, &n_a, &lr_a)) ) {
        return u2_bl_bail(wir_r, c3__exit);
      }
      else if ( (u2_no == u2_as_cell(b, &n_b, &lr_b)) ) {
        return u2_bl_bail(wir_r, c3__exit);
      }
      else if ( (u2_no == u2_as_cell(n_a, &p_n_a, &q_n_a)) ) {
        return u2_bl_bail(wir_r, c3__exit);
      }
      else if ( (u2_no == u2_as_cell(n_b, &p_n_b, &q_n_b)) ) {
        return u2_bl_bail(wir_r, c3__exit);
      }
      else if ( u2_no == u2_as_cell(lr_a, &l_a, &r_a) ) {
        return u2_bl_bail(wir_r, c3__exit);
      }
      else if ( u2_no == u2_as_cell(lr_b, &l_b, &r_b) ) {
        return u2_bl_bail(wir_r, c3__exit);
      }
      else if ( u2_yes == j2_mbc(Pt3, vor)(wir_r, p_n_a, p_n_b) ) {
        if ( u2_yes == u2_sing(p_n_a, p_n_b) ) {
          return u2_rt(wir_r, u2_rx(wir_r, n_b),
                              j2_mcc(Pt4, by, uni)(
                                wir_r, u2_rx(wir_r, l_a), u2_rx(wir_r, l_b)),
                              j2_mcc(Pt4, by, uni)(
                                wir_r, u2_rx(wir_r, r_a), u2_rx(wir_r, r_b)));
        }
        else if ( u2_yes == j2_mbc(Pt3, hor)(wir_r, p_n_b, p_n_a) ) {
          return j2_mcc(Pt4, by, uni)(
            wir_r,
            u2_rt(wir_r,
                  u2_rx(wir_r, n_a),
                  j2_mcc(Pt4, by, uni)(wir_r,
                                      u2_rx(wir_r, l_a),
                                      u2_rt(wir_r,
                                            u2_rx(wir_r, n_b),
                                            u2_rx(wir_r, l_b),
                                            u2_rx(wir_r, u2_nul))),
                  u2_rx(wir_r, r_a)),
            u2_rx(wir_r, r_b));
        }
        else {
          return j2_mcc(Pt4, by, uni)(
            wir_r,
            u2_rt(wir_r,
                  u2_rx(wir_r, n_a),
                  u2_rx(wir_r, l_a),
                  j2_mcc(Pt4, by, uni)(wir_r,
                                      u2_rx(wir_r, r_a),
                                      u2_rt(wir_r,
                                            u2_rx(wir_r, n_b),
                                            u2_rx(wir_r, u2_nul),
                                            u2_rx(wir_r, r_b)))),
            u2_rx(wir_r, l_b));
        }
      }
      else if ( u2_yes == u2_sing(p_n_b, p_n_a) ) {
        return u2_rt(
          wir_r,
          u2_rx(wir_r, n_b),
          j2_mcc(Pt4, by, uni)(wir_r, u2_rx(wir_r, r_b), u2_rx(wir_r, r_a)),
          j2_mcc(Pt4, by, uni)(wir_r, u2_rx(wir_r, l_b), u2_rx(wir_r, l_a)));
      }
      else if ( u2_yes == j2_mbc(Pt3, hor)(wir_r, p_n_a, p_n_b) ) {
        return j2_mcc(Pt4, by, uni)(
          wir_r,
          u2_rx(wir_r, r_a),
          u2_rt(wir_r,
                u2_rx(wir_r, n_b),
                j2_mcc(Pt4, by, uni)(wir_r,
                                    u2_rt(wir_r,
                                          u2_rx(wir_r, n_a),
                                          u2_rx(wir_r, l_a),
                                          u2_rx(wir_r, u2_nul)),
                                    u2_rx(wir_r, l_b)),
                u2_rx(wir_r, r_b)));
      }
      else {
        return j2_mcc(Pt4, by, uni)(
          wir_r,
          u2_rx(wir_r, l_a),
          u2_rt(wir_r,
                u2_rx(wir_r, n_b),
                u2_rx(wir_r, l_b),
                j2_mcc(Pt4, by, uni)(wir_r,
                                    u2_rx(wir_r, r_b),
                                    u2_rt(wir_r,
                                          u2_rx(wir_r, n_a),
                                          u2_rx(wir_r, u2_nul),
                                          u2_rx(wir_r, r_a)))));
      }
    }
  }
示例#21
0
文件: ut_burn.c 项目: Gruelty/urbit
/* logic
*/
  static u2_noun
  _burn_in(u2_wire wir_r, 
           u2_noun van,
           u2_noun sut,
           u2_noun gil)
  {
    u2_noun p_sut, q_sut, pq_sut, qq_sut, rq_sut, prq_sut, qrq_sut;

    if ( u2_no == u2_dust(sut) ) switch ( sut ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__noun: return _0;
      case c3__void: {
        return u2_bl_error(wir_r, "burn-void");
      }
    }
    else switch ( u2_h(sut) ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__atom: return _0;

      case c3__cell: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        return u2_bc
          (wir_r, _burn_in(wir_r, van, p_sut, gil),
                  _burn_in(wir_r, van, q_sut, gil));
      }
      case c3__core: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
                     u2_bi_trel(wir_r, q_sut, &pq_sut, &qq_sut, &rq_sut);
                     u2_bi_cell(wir_r, rq_sut, &prq_sut, &qrq_sut);
      {
        return u2_bc
          (wir_r, u2_rx(wir_r, prq_sut),
                  _burn_in(wir_r, van, p_sut, gil));
      }
      case c3__cube: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        return u2_rx(wir_r, p_sut);
      }
      case c3__face: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        return _burn_in(wir_r, van, q_sut, gil);
      }
      case c3__fork: u2_bi_cell(wir_r, u2_t(sut), &p_sut, &q_sut);
      {
        return _burn_in(wir_r, van, p_sut, gil);
      }
      case c3__hold: p_sut = u2_t(sut);
      {
        if ( (u2_yes == j2_mcc(Pt4, in, has)(wir_r, gil, sut)) ) {
          u2_noun sux = j2_mcy(Pt6, ut, dunq)(wir_r, van, "type", sut);

          u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, sux));
          return u2_bl_error(wir_r, "burn-loop");
        } 
        else {
          u2_noun zoc = j2_mcc(Pt4, in, put)(wir_r, gil, sut);
          u2_type fop = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
          u2_noun pro = _burn_in(wir_r, van, fop, zoc);

          u2_rl_lose(wir_r, fop);
          u2_rl_lose(wir_r, zoc);

          return pro;
        }
      }
    }
  }
示例#22
0
文件: look.c 项目: Gruelty/urbit
/* internals
*/
  static u2_noun
  _look_in(u2_wire wir_r,
           u2_noun cog,
           u2_noun dab,
           u2_atom axe)
  {
    if ( u2_nul == dab ) {
      return u2_nul;
    }
    else {
      u2_noun n_dab, l_dab, r_dab; 
     
      u2_as_trel(dab, &n_dab, &l_dab, &r_dab);
      if ( u2_no == u2_dust(n_dab) ) {
        return u2_bl_bail(wir_r, c3__fail);
      } 
      else {
        u2_noun pn_dab = u2_h(n_dab);
        u2_noun qn_dab = u2_t(n_dab);
 
        if ( (u2_nul == l_dab) && (u2_nul == r_dab) ) {
          if ( (u2_yes == u2_dust(qn_dab)) &&
               (u2_yes == u2_sing(cog, pn_dab)) ) {
            return u2_bt(wir_r, u2_nul, 
                                u2_rx(wir_r, axe), 
                                u2_rx(wir_r, qn_dab));
          }
          else {
            return u2_nul;
          }
        }
        else if ( (u2_nul == l_dab) ) {
          if ( (u2_yes == u2_dust(qn_dab)) &&
               (u2_yes == u2_sing(cog, pn_dab)) ) {
            return u2_bt(wir_r, u2_nul, 
                                j2_mbc(Pt3, peg)(wir_r, axe, _2),
                                u2_rx(wir_r, qn_dab));
          }
          else {
            if ( u2_yes == j2_mbc(Pt3, gor)(wir_r, cog, pn_dab) ) {
              return u2_nul;
            }
            else {
              u2_noun pro;

              axe = j2_mbc(Pt3, peg)(wir_r, axe, _3);
              pro = _look_in(wir_r, cog, r_dab, axe);
              u2_rl_lose(wir_r, axe);
              return pro;
            }
          }
        }
        else if ( (u2_nul == r_dab) ) {
          if ( (u2_yes == u2_dust(qn_dab)) &&
               (u2_yes == u2_sing(cog, pn_dab)) ) {
            return u2_bt(wir_r, u2_nul, 
                                j2_mbc(Pt3, peg)(wir_r, axe, _2),
                                u2_rx(wir_r, qn_dab));
          }
          else {
            if ( u2_yes == j2_mbc(Pt3, gor)(wir_r, cog, pn_dab) ) {
              u2_noun pro;

              axe = j2_mbc(Pt3, peg)(wir_r, axe, _3);
              pro = _look_in(wir_r, cog, l_dab, axe);
              u2_rl_lose(wir_r, axe);
              return pro;
            }
            else {
              return u2_nul;
            }
          }
        }
        else {
          if ( (u2_yes == u2_dust(qn_dab)) &&
               (u2_yes == u2_sing(cog, pn_dab)) ) {
            return u2_bt(wir_r, u2_nul, 
                                j2_mbc(Pt3, peg)(wir_r, axe, _2),
                                u2_rx(wir_r, qn_dab));
          }
          else {
            if ( u2_yes == j2_mbc(Pt3, gor)(wir_r, cog, pn_dab) ) {
              u2_noun pro;

              axe = j2_mbc(Pt3, peg)(wir_r, axe, _6);
              pro = _look_in(wir_r, cog, l_dab, axe);
              u2_rl_lose(wir_r, axe);
              return pro;
            }
            else {
              u2_noun pro;

              axe = j2_mbc(Pt3, peg)(wir_r, axe, _7);
              pro = _look_in(wir_r, cog, r_dab, axe);
              u2_rl_lose(wir_r, axe);
              return pro;
            }
          }
        }
      }
    }
  }
示例#23
0
文件: ut_peek.c 项目: MacTop/urbit
  static u2_noun                                                  //  produce
  _peek_in(u2_wire wir_r,
           u2_noun van,                                           //  retain
           u2_noun sut,                                           //  retain
           u2_noun way,                                           //  retain
           u2_atom axe,                                           //  retain
           u2_noun gil)                                           //  retain
  {
    u2_noun p_sut, q_sut;
    u2_noun pro;

    if ( (u2_no == u2_dust(sut)) ) switch ( sut ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__noun: {
        return c3__noun;
      }
      case c3__void: {
        return c3__void;
      }
    }
    else switch ( u2_h(sut) ) {
      default: return u2_bl_bail(wir_r, c3__fail);

      case c3__atom: {
        return c3__void;
      }
      case c3__cell: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          u2_atom tip = j2_mbc(Pt3, cap)(wir_r, axe);
          u2_atom tap = j2_mbc(Pt3, mas)(wir_r, axe);

          if ( _2 == tip ) {
            pro = j2_mcx(Pt6, ut, peek)(wir_r, van, p_sut, way, tap);
          }
          else {
            pro = j2_mcx(Pt6, ut, peek)(wir_r, van, q_sut, way, tap);
          }
          u2_rl_lose(wir_r, tap); 
          u2_rl_lose(wir_r, tip);

          return pro;
        }
      }
      case c3__core: {
        u2_noun pq_sut, qq_sut, rq_sut;
        u2_noun prq_sut, qrq_sut;

        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ||
             (u2_no == u2_as_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
             (u2_no == u2_as_cell(rq_sut, &prq_sut, &qrq_sut)) )
        {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          u2_atom tip = j2_mbc(Pt3, cap)(wir_r, axe);
          u2_atom tap = j2_mbc(Pt3, mas)(wir_r, axe);

          if ( _3 == tip ) {
            if ( u2_no == j2_mcy(Pt6, ut, park)(wir_r, van, sut, way, tap) ) 
            {
              // u2_noun dun = j2_mcy(Pt6, ut, dunq)(wir_r, van, "type", sut);
              u2_noun waz = j2_mcy(Pt6, ut, shep)
                (wir_r, van, "axis", 'd', u2_rx(wir_r, axe));

              // u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, dun));
              u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, waz));

              return u2_bl_error(wir_r, "peek-park");
            }
            else pro = j2_mcx(Pt6, ut, peek)(wir_r, van, p_sut, way, tap);
          }
          else {
            pro = c3__noun;
          }
          u2_rl_lose(wir_r, tap); 
          u2_rl_lose(wir_r, tip);

          return pro;
        }
      }
      case c3__cube: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          return _peek_in(wir_r, van, q_sut, way, axe, gil);
        }
      }
      case c3__face: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          return _peek_in(wir_r, van, q_sut, way, axe, gil);
        }
      }
      case c3__fork: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          u2_noun hed = _peek_in(wir_r, van, p_sut, way, axe, gil);
          u2_noun tal = _peek_in(wir_r, van, q_sut, way, axe, gil);

          pro = j2_mby(Pt6, fork)(wir_r, hed, tal);

          u2_rl_lose(wir_r, hed);
          u2_rl_lose(wir_r, tal);

          return pro;
        }
      } 
      case c3__hold: {
        p_sut = u2_t(sut);
        if ( (u2_yes == j2_mcc(Pt4, in, has)(wir_r, gil, sut)) ) {
          return c3__void;
        } 
        else {
          u2_noun zoc = j2_mcc(Pt4, in, put)(wir_r, gil, sut);
          u2_type fop = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
          u2_noun pro = _peek_in(wir_r, van, fop, way, axe, zoc);

          u2_rl_lose(wir_r, fop);
          u2_rl_lose(wir_r, zoc);

          return pro;
        }
      }
    }
  }
示例#24
0
文件: ut_tusk.c 项目: mnemnion/urbit
/* internals
*/
  static u2_noun                                                  //  transfer
  _tusk_in(u2_wire wir_r, 
           u2_noun van,                                           //  retain
           u2_noun sut,                                           //  retain
           u2_noun peh,                                           //  retain
           u2_noun boz,                                           //  retain
           u2_noun rix,                                           //  retain
           u2_atom axe)                                           //  retain
  {
    u2_noun ret;

    if ( u2_nul == peh ) {
      return j2_mcy(Pt6, ut, play)(wir_r, van, boz, rix);
    }
    else {
      u2_noun i_peh = u2_h(peh);
      u2_noun t_peh = u2_t(peh);

      if ( u2_yes == u2_stud(i_peh) ) {
        u2_noun cog = i_peh;
        u2_noun wer = j2_mcy(Pt6, ut, find)(wir_r, van, sut, c3__rite, i_peh);
        u2_noun p_wer, r_wer;

        u2_as_trel(wer, &p_wer, 0, &r_wer);
        {
          u2_noun nax = j2_mbc(Pt3, peg)(wir_r, axe, p_wer); 
          u2_noun giv = _tusk_in(wir_r, van, r_wer, t_peh, boz, rix, nax);
          u2_noun qog = u2_bc(wir_r, u2_nul, cog);
          u2_noun ret = j2_mcy(Pt6, ut, heal)
            (wir_r, van, sut, qog, p_wer, giv);

          u2_rl_lose(wir_r, nax);
          u2_rl_lose(wir_r, qog);
          u2_rl_lose(wir_r, giv);
          u2_rl_lose(wir_r, wer);

          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 rox;

        if ( u2_nul == t_peh ) {
          rox = j2_mcy(Pt6, ut, snap)(wir_r, van, vas, rix);
        } else rox = u2_rx(wir_r, rix);
        
        {
          u2_noun nax = j2_mbc(Pt3, peg)(wir_r, axe, bax); 
          u2_noun giv = _tusk_in(wir_r, van, vas, t_peh, boz, rox, nax);

          ret = j2_mcy(Pt6, ut, heal)(wir_r, van, sut, u2_nul, bax, giv);

          u2_rl_lose(wir_r, rox);
          u2_rl_lose(wir_r, nax);
          u2_rl_lose(wir_r, giv);

          return ret;
        }
      }
    }
  }
示例#25
0
文件: ut_play.c 项目: Gruelty/urbit
  static u2_noun
  _play_in(u2_wire wir_r,
           u2_noun van,
           u2_noun sut,
           u2_noun gen)
  {
    u2_noun p_gen, q_gen, r_gen;

    if ( u2_no == u2_dust(gen) ) {
      open: {
        u2_noun ter = u2_frag(u2_cv_con_3, van);
        u2_noun rex = j2_mcy(Pt6, ap, open)(wir_r, ter, gen);
        u2_noun ret;

        if ( u2_yes == u2_sing(rex, gen) ) {
          u2_noun zix = j2_mcy(Pt6, ut, shep)
                (wir_r, van, "gene", 'q', u2_rx(wir_r, gen));

          u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, zix));
          return u2_bl_error(wir_r, "play-open");
        }
        ret = _play_in(wir_r, van, sut, rex);
        u2_rl_lose(wir_r, rex);

        return ret;
      }
    } 
    else if ( u2_yes == u2_dust(u2_h(gen)) ) {
      _play_used(wir_r);
      {
        u2_noun dis = _play_in(wir_r, van, sut, u2_h(gen));
        u2_noun dat = _play_in(wir_r, van, sut, u2_t(gen));
        u2_noun ret = j2_mby(Pt6, cell)(wir_r, dis, dat);

        u2_rz(wir_r, dis);
        u2_rz(wir_r, dat);
        return ret;
      }
    }
    else switch ( u2_h(gen) ) {
      default: goto open;
    
      case c3__wtcn: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        return _play_bean(wir_r);
      }
      case c3__wtcl: u2_bi_trel(wir_r, u2_t(gen), &p_gen, &q_gen, &r_gen);
      _play_used(wir_r);
      {
        u2_noun fex = j2_mcy(Pt6, ut, gain)(wir_r, van, sut, p_gen);
        u2_noun wux = j2_mcy(Pt6, ut, lose)(wir_r, van, sut, p_gen);
        u2_noun dez = (fex == c3__void) ? c3__void 
                                        : _play_in(wir_r, van, fex, q_gen);
        u2_noun doz = (wux == c3__void) ? c3__void 
                                        : _play_in(wir_r, van, wux, r_gen);
        u2_noun ret = j2_mby(Pt6, fork)(wir_r, dez, doz);
       
        u2_rz(wir_r, dez); u2_rz(wir_r, doz);
        u2_rz(wir_r, fex); u2_rz(wir_r, wux);
        return ret;
      }
      case c3__clhp: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun dis = _play_in(wir_r, van, sut, p_gen);
        u2_noun dat = _play_in(wir_r, van, sut, q_gen);
        u2_noun ret = j2_mby(Pt6, cell)(wir_r, dis, dat);

        u2_rz(wir_r, dis);
        u2_rz(wir_r, dat);
        return ret;
      }
      case c3__dtkt: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        return c3__noun;
      }
      case c3__dtwt: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        return _play_bean(wir_r);
      }
      case c3__dtts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        return _play_bean(wir_r);
      }
      case c3__dtls: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        return u2_bc(wir_r, c3__atom, u2_blip);
      }
      case c3__dtsg: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun boc = (u2_no == u2_stud(q_gen)) 
                        ? c3__noun
                        : u2_bc(wir_r, c3__atom, u2_rx(wir_r, p_gen));
        u2_noun ret = j2_mby(Pt6, cube)(wir_r, q_gen, boc);

        u2_rz(wir_r, boc);
        return ret;
      }
      case c3__dttr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        return c3__noun;
      }
      case c3__dtpt: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        if ( 'f' == p_gen ) {
          if ( (q_gen > 1) ) {
            return u2_cm_bail(c3__exit);
          } else {
            return _play_bean(wir_r);
          }
        }
        else return u2_bc(wir_r, c3__atom, u2_rx(wir_r, p_gen));
      }
      case c3__ktbr: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        u2_noun boc = _play_in(wir_r, van, sut, p_gen);
        u2_noun pro = j2_mcy(Pt6, ut, wrap)(wir_r, van, boc, c3__iron);

        u2_rz(wir_r, boc);
        return pro;
      }
      case c3__ktpm: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        u2_noun boc = _play_in(wir_r, van, sut, p_gen);
        u2_noun pro = j2_mcy(Pt6, ut, wrap)(wir_r, van, boc, c3__zinc);

        u2_rz(wir_r, boc);
        return pro;
      }
      case c3__ktwt: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        u2_noun boc = _play_in(wir_r, van, sut, p_gen);
        u2_noun pro = j2_mcy(Pt6, ut, wrap)(wir_r, van, boc, c3__lead);

        u2_rz(wir_r, boc);
        return pro;
      }
      case c3__ktts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun boc = _play_in(wir_r, van, sut, q_gen);
        u2_noun ret = j2_mby(Pt6, face)(wir_r, p_gen, boc);

        u2_rz(wir_r, boc);
        return ret;
      }
      case c3__ktdt: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun boc = _play_in(wir_r, van, sut, p_gen);
        u2_noun hef = j2_mcy(Pt6, ut, snap)(wir_r, van, boc, q_gen);
        u2_noun ret = _play_in(wir_r, van, sut, hef);

        u2_rz(wir_r, boc);
        u2_rz(wir_r, hef);
        return ret;
      }
      case c3__ktsg: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        return _play_in(wir_r, van, sut, p_gen);
      }
      case c3__ktls: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        return _play_in(wir_r, van, sut, p_gen);
      }
      case c3__tsgr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun boc = _play_in(wir_r, van, sut, p_gen);
        u2_noun ret = _play_in(wir_r, van, boc, q_gen);

        u2_rz(wir_r, boc);
        return ret;
      }
      case c3__cnts: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun sec = j2_mcy(Pt6, ut, seek)(wir_r, van, sut, c3__read, p_gen);
        u2_noun lar = _play_foil(wir_r, sec);
        u2_noun q_lar = u2_t(lar);
        u2_noun qq_lar = u2_t(q_lar);
        u2_noun mew = j2_mcy(Pt6, ut, swab)(wir_r, van, sut, q_gen);
        u2_noun rag = _play_edit(wir_r, van, sut, mew, u2_rx(wir_r, qq_lar));
        u2_noun ret = j2_mcy(Pt6, ut, fire)(wir_r, van, sut, rag);

        u2_rz(wir_r, rag);
        u2_rz(wir_r, mew);
        u2_rz(wir_r, lar);

        return ret;
      }
      case c3__pmcl: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun ruf = u2_bt
          (wir_r, c3__clhp, 
                  u2_bc(wir_r, u2_nul, _1),
                  u2_rx(wir_r, p_gen));
        u2_noun ret = _play_grow(wir_r, van, sut, c3__zinc, ruf, q_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__brcn: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        u2_noun ruf = u2_bc(wir_r, u2_nul, _1);
        u2_noun ret = _play_grow(wir_r, van, sut, c3__gold, ruf, p_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__pmcn: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        u2_noun ruf = u2_bc(wir_r, u2_nul, _1);
        u2_noun ret = _play_grow(wir_r, van, sut, c3__lead, ruf, p_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__pmls: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun ruf = u2_bt
          (wir_r, c3__clhp, 
                  u2_bc(wir_r, u2_nul, _1),
                  u2_rx(wir_r, p_gen));
        u2_noun ret = _play_grow(wir_r, van, sut, c3__iron, ruf, q_gen);

        u2_rz(wir_r, ruf);
        return ret;
      }
      case c3__sggr: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        return _play_in(wir_r, van, sut, q_gen);
      }
      case c3__zpts: p_gen = u2_t(gen);
      _play_used(wir_r);
      {
        return c3__noun;
      }
      case c3__zpcm: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        return _play_in(wir_r, van, sut, p_gen);
      }
      case c3__zpcb: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      {
        u2_noun ret;

        u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, _play_loc(wir_r, van, p_gen)));
        {
          ret = _play_in(wir_r, van, sut, q_gen);
        }
        u2_bl_drop(wir_r);
        return ret;
      }
      case c3__zpcn:
      _play_used(wir_r);
      {
        u2_noun pet = u2_bn_hook(wir_r, van, "seed");
        u2_noun ret = u2_rx(wir_r, u2_h(pet));

        u2_rz(wir_r, pet);
        return ret;
      }
      case c3__zpsm: u2_bi_cell(wir_r, u2_t(gen), &p_gen, &q_gen);
      _play_used(wir_r);
      {
        u2_noun zur = _play_in(wir_r, van, sut, p_gen);
        u2_noun vos = _play_in(wir_r, van, sut, q_gen);
        u2_noun ret = j2_mby(Pt6, cell)(wir_r, zur, vos);

        u2_rz(wir_r, zur);
        u2_rz(wir_r, vos);

        return ret;
      }
      case c3__zpfs:
      case c3__zpzp:
      _play_used(wir_r);
      {
        return c3__void;
      }
    }
  }
示例#26
0
文件: ut_find.c 项目: mnemnion/urbit
/* logic
*/
  static u2_noun
  _find_in(u2_wire wir_r,
           u2_noun van,
           u2_noun sut,
           u2_noun way,
           u2_noun cog,
           u2_noun gil)
  {
    u2_noun p_sut, q_sut;

    if ( u2_yes == u2_stud(sut) ) {
      return u2_nul;
    }
    else switch ( u2_h(sut) ) {
      default: return u2_nul;

      case c3__cell: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          u2_noun taf = _find_in(wir_r, van, q_sut, way, cog, gil);

          if ( u2_nul == taf ) {
            u2_noun bov = _find_in(wir_r, van, p_sut, way, cog, gil);

            if ( u2_nul == bov ) {
              return u2_nul;
            } else {
              u2_noun p_bov, q_bov;
              u2_noun pro;

              u2_mean(bov, 6, &p_bov, 7, &q_bov, 0);
              pro = u2_bt
                (wir_r, u2_nul,
                        j2_mbc(Pt3, peg)(wir_r, 2, p_bov),
                        u2_rx(wir_r, q_bov));

              u2_rl_lose(wir_r, bov);
              return pro;
            }
          } else {
            u2_noun p_taf, q_taf;
            u2_noun pro;

            u2_mean(taf, 6, &p_taf, 7, &q_taf, 0);
            pro = u2_bt
              (wir_r, u2_nul,
                      j2_mbc(Pt3, peg)(wir_r, 3, p_taf),
                      u2_rx(wir_r, q_taf));

            u2_rl_lose(wir_r, taf);
            return pro;
          }
        }
      }
      case c3__core: {
        u2_noun pq_sut, qq_sut, rq_sut;
        u2_noun prq_sut, qrq_sut;

        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ||
             (u2_no == u2_as_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
             (u2_no == u2_as_cell(rq_sut, &prq_sut, &qrq_sut)) )
        {
          return u2_bl_bail(wir_r, c3__fail);
        } else {
          u2_noun zem = j2_mby(Pt6, look)(wir_r, cog, qrq_sut);

          if ( u2_nul == zem ) {
            u2_noun taf = _find_in(wir_r, van, p_sut, way, cog, gil);

            if ( u2_nul == taf ) {
              return u2_nul;
            } else {
              u2_noun p_taf, q_taf;
              u2_noun pro;

              u2_mean(taf, 6, &p_taf, 7, &q_taf, 0);

              if ( u2_no == j2_mcy(Pt6, ut, park)(wir_r, van, sut, way, p_taf) )
              {
                u2_noun weh = j2_mcy(Pt6, ut, shep)
                  (wir_r, van, "way", 'a', u2_rx(wir_r, way));
                u2_noun waz = j2_mcy(Pt6, ut, shep)
                  (wir_r, van, "axis", 'd', u2_rx(wir_r, p_taf));

                u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, weh));
                u2_bl_push(wir_r, u2_bc(wir_r, c3__mean, waz));
                return u2_bl_error(wir_r, "find-park");
              }
              else {
                pro = u2_bt
                  (wir_r, u2_nul,
                          j2_mbc(Pt3, peg)(wir_r, 2, p_taf),
                          u2_rx(wir_r, q_taf));

                u2_rl_lose(wir_r, taf);
                return pro;
              }
            }
          }
          else {
            u2_noun p_zem, q_zem;
            u2_noun pro;

            u2_mean(zem, 6, &p_zem, 7, &q_zem, 0);

            pro = u2_bq
              (wir_r, u2_nul,
                      _1,
                      u2_no,
                      u2_bc
                        (wir_r, j2_mbc(Pt3, peg)(wir_r, 3, p_zem),
                                u2_bc(wir_r, 
                                      u2_bc(wir_r, u2_rx(wir_r, sut),
                                                   u2_rx(wir_r, q_zem)),
                                      u2_nul)));
            u2_rz(wir_r, zem);
            return pro;
          }
        }
      }
      case c3__face: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        } else { 
          if ( u2_no == u2_sing(cog, p_sut) ) {
            return u2_nul;
          } else {
            return u2_bq(wir_r, u2_nul, _1, u2_yes, u2_rx(wir_r, q_sut));
          }
        }
      }
      case c3__cube:
      case c3__fine: {
        u2_type fop = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
        u2_noun ret = _find_in(wir_r, van, fop, way, cog, gil);
        
        u2_rz(wir_r, fop);
        return ret;
      }
      case c3__fork: {
        if ( (u2_no == u2_as_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u2_bl_bail(wir_r, c3__fail);
        }
        else {
          if ( (u2_yes == j2_mcc(Pt4, in, has)(wir_r, gil, q_sut)) ) {
            return _find_in(wir_r, van, p_sut, way, cog, gil);
          } 
          else if ( (u2_yes == j2_mcc(Pt4, in, has)(wir_r, gil, p_sut)) ) {
            return _find_in(wir_r, van, q_sut, way, cog, gil);
          } else {
            u2_noun hax = _find_in(wir_r, van, p_sut, way, cog, gil);
            u2_noun yor = _find_in(wir_r, van, q_sut, way, cog, gil);
            u2_noun p_hax, q_hax;
            u2_noun p_yor, q_yor;

            if ( u2_nul != hax ) {
              u2_mean(hax, 6, &p_hax, 7, &q_hax, 0);
            }
            if ( u2_nul != yor ) {
              u2_mean(yor, 6, &p_yor, 7, &q_yor, 0);
            }

            if ( u2_nul == hax ) {
              if ( u2_nul == yor ) {
                return u2_nul;
              } else {
                u2_noun pek = j2_mcy(Pt6, ut, peek)
                  (wir_r, van, p_sut, way, p_yor);
                u2_noun nuz = j2_mcy(Pt6, ut, nest)
                  (wir_r, van, c3__void, u2_no, pek);

                u2_rz(wir_r, pek);

                if ( u2_yes == nuz ) {
                  return yor;
                } else return u2_bl_error(wir_r, "find-fork");
              }
            }
            else {
              if ( u2_nul == yor ) {
                u2_noun pek = j2_mcy(Pt6, ut, peek)
                  (wir_r, van, q_sut, way, p_hax);
                u2_noun nuz = j2_mcy(Pt6, ut, nest)
                  (wir_r, van, c3__void, u2_no, pek);

                u2_rz(wir_r, pek);

                if ( u2_yes == nuz ) {
                  return hax;
                } else return u2_bl_error(wir_r, "find-fork");
              }
              else {
                if ( u2_yes == u2_sing(hax, yor) ) {
                  u2_rz(wir_r, yor);

                  return hax;
                } else {
                  u2_noun ret;

                  u2_mean(hax, 6, &p_hax, 7, &q_hax, 0);
                  u2_mean(yor, 6, &p_yor, 7, &q_yor, 0);

                  if ( u2_no == u2_sing(p_hax, p_yor) ) {
                    return u2_bl_error(wir_r, "find-fork");
                  }

                  if ( u2_yes == u2_h(q_hax) ) {
                    if ( u2_yes != u2_h(q_yor) ) {
                      return u2_bl_error(wir_r, "find-fork");
                    } else {
                      u2_noun pq_hax = u2_t(q_hax);
                      u2_noun pq_yor = u2_t(q_yor);

                      ret = u2_bq
                        (wir_r, 
                         u2_nul,
                         u2_rx(wir_r, p_hax),
                         u2_yes,
                         j2_mby(Pt6, fork)(wir_r, pq_hax, pq_yor));
                    }
                  }
                  else {
                    if ( u2_yes == u2_h(q_yor) ) {
                      return u2_bl_error(wir_r, "find-fork");
                    }
                    else {
                      u2_noun pq_hax, qq_hax, pq_yor, qq_yor;

                      u2_bi_cell(wir_r, u2_t(q_hax), &pq_hax, &qq_hax);
                      u2_bi_cell(wir_r, u2_t(q_yor), &pq_yor, &qq_yor);

                      if ( u2_no == u2_sing(pq_hax, pq_yor) ) {
                        return u2_bl_error(wir_r, "find-fork");
                      } else {
                        ret = u2_bq
                          (wir_r, u2_nul,
                                  u2_rx(wir_r, p_hax),
                                  u2_no,
                                  u2_bc
                                    (wir_r, u2_rx(wir_r, pq_hax),
                                            j2_mbc(Pt2, weld)
                                              (wir_r, qq_hax, qq_yor)));
                      }
                    }
                  }
                  u2_rz(wir_r, yor);
                  u2_rz(wir_r, hax);

                  return ret;
                }
              }
            }
          }
        }
      } 
      case c3__hold: p_sut = u2_t(sut);
      {
        if ( (u2_yes == j2_mcc(Pt4, in, has)(wir_r, gil, sut)) ) {
          return u2_nul;
        } 
        else {
          u2_noun zoc = j2_mcc(Pt4, in, put)(wir_r, gil, sut);
          u2_type fop = j2_mcy(Pt6, ut, repo)(wir_r, van, sut);
          u2_noun pro = _find_in(wir_r, van, fop, way, cog, zoc);

          u2_rl_lose(wir_r, fop);
          u2_rl_lose(wir_r, zoc);

          return pro;
        }
      }
    }
  }
示例#27
0
文件: shed.c 项目: Gruelty/urbit
/* u2_sh_mine(): substitute active, annotated battery.
*/
u2_weak                                                           //  transfer
u2_sh_mine(u2_ray  wir_r,
           u2_clue clu,                                           //  retain
           u2_noun cor)                                           //  transfer
{
  u2_ray bas_r;
  u2_noun pay, bat;
  u2_noun sil, bud, nut;
  u2_chip xip;

  if ( 0 == (bas_r = u2_wire_bas_r(wir_r)) ) {
    return cor;
  }
  else if ( (u2_none == u2_as_cell(cor, &pay, &bat)) || 
            (u2_no == u2_dust(bat)) )
  {
    return cor;
  }
  else if ( u2_none != (xip = u2_ch_find(u2_bask_hag_r(bas_r), bat)) ) {
    u2_noun cyr;

    if ( u2_none == (cyr = u2_rc(wir_r, u2_rx(wir_r, pay), u2_h(u2_t(xip)))) ) {
      return cor;
    }
    else {
      u2_rl_lose(wir_r, cor);

      return cyr;
    }
  }
  else if ( (u2_no == u2_as_trel(clu, &bud, &sil, &nut)) ||
            (u2_no == _sh_good_bud(bud)) ||
            (u2_no == _sh_good_sil(sil)) ||
            (u2_no == _sh_good_nut(nut)) )
  {
    return cor;
  }
  else {
    u2_noun dac, bot, pet, xop, cyr;
    
    dac = bot = pet = xop = cyr = u2_none;
    while ( 1 ) {
      /* disc: dac
      */
      {
        if ( u2_none == (dac = u2_rl_take(bas_r, u2_t(clu))) ) {
          break;
        }
      }

      /* battery: bot
      */
      {
        if ( u2_no == u2_rl_junior(bas_r, bat) ) {
          /* We need the jet battery to be in the shed, so that we 
          ** have a fast algorithm for distinguishing jet batteries
          ** by ray address.
          */
          bot = u2_rc(bas_r, u2_h(bat), u2_t(bat));
#if 0
        printf("battery: in basket: %d.%x\n",
                u2_ray_a(u2_dog_a(bot)),
                u2_ray_b(u2_dog_a(bot)));
#endif
        } 
        else {
          bot = u2_rl_take(bas_r, bat);
#if 0
          printf("battery: in shed! %d.%x\n",
                  u2_ray_a(u2_dog_a(bot)),
                  u2_ray_b(u2_dog_a(bot)));

#endif
        }
        if ( u2_none == bot ) {
          break;
        }
      }

      /* trunk: pet
      */
      {
        if ( _0 == bud ) {
          pet = u2_nul;
        } 
        else {
          u2_atom p_bud = u2_t(bud);
          u2_noun car   = u2_frag(p_bud, cor);
 
          if ( (u2_none == car) || (u2_no == u2_dust(car)) ) {
            break;
          } else {
            u2_noun but = u2_t(car);
            u2_noun xup, axe;

            if ( u2_none == (xup = u2_ch_find(u2_bask_hag_r(bas_r), but)) ) {
              printf("no base!\n");
              u2_err(wir_r, "clu", clu);
              break;
            }
            else u2_rl_gain(bas_r, xup);

            if ( u2_none == (axe = u2_rl_take(bas_r, p_bud)) ) {
              u2_rl_lose(bas_r, xup);
            }

            if ( u2_none == (pet = u2_rc(bas_r, p_bud, xup)) ) {
              u2_rl_lose(bas_r, axe);
              u2_rl_lose(bas_r, xup);
              break;
            }
          }
        }
      }

      /* xop: new chip.
      */
      {
        if ( u2_none == (xop = u2_rt(bas_r, dac, bot, pet)) ) {
          break;
        }
        if ( u2_none == (u2_ch_save(bas_r, u2_bask_hag_r(bas_r), bot, xop)) ) {
          break;
        }
        u2_rl_lose(bas_r, xop);
      }

      /* cyr: new core.
      */
      {
        u2_noun cyr;

        if ( u2_none == (cyr = u2_rc(wir_r, u2_rx(wir_r, pay), bot)) ) {
          break;
        }
        else {
          u2_rl_lose(wir_r, cor);

          return cyr;
        }
      }
    }
    u2_ho_warn_here();
#if 0
    //  XXX: an unknown bug is triggered here;
    //  but basket needs a minor rewrite.
    //
    if ( dac != u2_none ) u2_rl_lose(bas_r, dac);
    if ( bot != u2_none ) u2_rl_lose(bas_r, bot);
    if ( pet != u2_none ) u2_rl_lose(bas_r, pet);
    if ( xop != u2_none ) u2_rl_lose(bas_r, xop);
#endif
    return cor;
  }
}