示例#1
0
文件: ut_play.c 项目: Gunga/urbit
  static u3_noun
  _play_x(u3_noun van,
          u3_noun sut,
          u3_noun gen)
  {
#if 1
    return _play_in(van, sut, gen);
#else
    u3_noun zix = u3qfu_shep
          (van, "gene", 'q', u3k(gen));
    u3_noun ret;

    u3t_push(u3nc(c3__mean, zix));

    ret = _play_in(van, sut, gen);

    u3t_drop();
    return ret;
#endif
  }
示例#2
0
文件: nock.c 项目: OCForks/urbit
/* _n_hint(): process hint.
*/
static u3_noun
_n_hint(u3_noun zep, 
        u3_noun hod,
        u3_noun bus,
        u3_noun nex)
{
  switch ( zep ) {
    default: {
      // u3m_p("weird zep", zep);
      u3a_lose(zep);
      u3a_lose(hod);

      return _n_nock_on(bus, nex);
    }

    case c3__hunk:
    case c3__lose:
    case c3__mean:
    case c3__spot: {
      u3_noun tac = u3nc(zep, hod);
      u3_noun pro;

      u3t_push(tac);
#if 0
      {
        static int low_i;

        if ( !low_i ) {
          low_i = 1;
          if ( 0 == (u3R->pro.nox_d % 65536ULL) ) {
            if ( c3__spot == zep ) {
              uL(fprintf(uH, "spot %d/%d : %d/%d\r\n",
                             u3h(u3h(u3t(hod))),
                             u3t(u3h(u3t(hod))),
                             u3h(u3t(u3t(hod))),
                             u3t(u3t(u3t(hod)))));
            }
          }
          low_i = 0;
        }
      }
#endif
      pro = _n_nock_on(bus, nex);
      u3t_drop();

      return pro;
    }

    case c3__live: {
      if ( c3y == u3ud(hod) ) {
        u3t_off(noc_o);
        u3t_heck(hod);
        u3t_on(noc_o);
      } else {
        u3z(hod);
      }
      return _n_nock_on(bus, nex);
    }

    case c3__slog: {
      if ( !(u3C.wag_w & u3o_quiet) ) {
        u3t_off(noc_o);
        u3t_slog(hod);
        u3t_on(noc_o);
      }
      return _n_nock_on(bus, nex);
    }

    case c3__germ: {
      u3_noun pro = _n_nock_on(bus, nex);

      if ( c3y == u3r_sing(pro, hod) ) {
        u3z(pro); return hod;
      } else {
        u3z(hod); return pro;
      }
    }

    case c3__fast: {
      u3_noun pro = _n_nock_on(bus, nex);

      u3t_off(noc_o);
      u3j_mine(hod, u3k(pro));
      u3t_on(noc_o);

      return pro;
    }

    case c3__memo: {
      u3z(hod);
#if 0
      return _n_nock_on(bus, nex);
#else
      {
        u3_noun pro = u3z_find_2(c3__nock, bus, nex);

        if ( pro != u3_none ) {
          u3z(bus); u3z(nex);
          return pro;
        }
        pro = _n_nock_on(u3k(bus), u3k(nex));

        if ( &(u3H->rod_u) != u3R ) {
          u3z_save_2(c3__nock, bus, nex, pro);
        }

        u3z(bus); u3z(nex);

        return pro;
      }
#endif
    }

    case c3__sole: {
      u3z(hod);
      {
        u3_noun pro = _n_nock_on(bus, nex);

        // return u3z_uniq(pro);
        return pro;
      }
    }
  }
}
示例#3
0
文件: nock.c 项目: OCForks/urbit
/* _n_nock_on(): produce .*(bus fol).  Do not virtualize.
*/
static u3_noun
_n_nock_on(u3_noun bus, u3_noun fol)
{
  u3_noun hib, gal;

  while ( 1 ) {
    hib = u3h(fol);
    gal = u3t(fol);

    u3R->pro.nox_d += 1;

    if ( c3y == u3r_du(hib) ) {
      u3_noun poz, riv;

      poz = _n_nock_on(u3k(bus), u3k(hib));
      riv = _n_nock_on(bus, u3k(gal));

      u3a_lose(fol);
      return u3i_cell(poz, riv);
    }
    else switch ( hib ) {
      default: return u3m_bail(c3__exit);

      case 0: {
        if ( c3n == u3r_ud(gal) ) {
          return u3m_bail(c3__exit);
        }
        else {
          u3_noun pro = u3k(u3at(gal, bus));

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

      case 1: {
        u3_noun pro = u3k(gal);

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

      case 2: {
        u3_noun nex = _n_nock_on(u3k(bus), u3k(u3t(gal)));
        u3_noun seb = _n_nock_on(bus, u3k(u3h(gal)));

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

      case 3: {
        u3_noun gof, pro;

        gof = _n_nock_on(bus, u3k(gal));
        pro = u3r_du(gof);

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

      case 4: {
        u3_noun gof, pro;

        gof = _n_nock_on(bus, u3k(gal));
        pro = u3i_vint(gof);

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

      case 5: {
        u3_noun wim = _n_nock_on(bus, u3k(gal));
        u3_noun pro = u3r_sing(u3h(wim), u3t(wim));

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

      case 6: {
        u3_noun b_gal, c_gal, d_gal;

        u3x_trel(gal, &b_gal, &c_gal, &d_gal);
        {
          u3_noun tys = _n_nock_on(u3k(bus), u3k(b_gal));
          u3_noun nex;

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

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

      case 7: {
        u3_noun b_gal, c_gal;

        u3x_cell(gal, &b_gal, &c_gal);
        {
          u3_noun bod = _n_nock_on(bus, u3k(b_gal));
          u3_noun nex = u3k(c_gal);

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

      case 8: {
        u3_noun b_gal, c_gal;

        u3x_cell(gal, &b_gal, &c_gal);
        {
          u3_noun heb = _n_nock_on(u3k(bus), u3k(b_gal));
          u3_noun bod = u3nc(heb, bus);
          u3_noun nex = u3k(c_gal);

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

      case 9: {
        u3_noun b_gal, c_gal;

        u3x_cell(gal, &b_gal, &c_gal);
        {
          u3_noun seb = _n_nock_on(bus, u3k(c_gal));
          u3_noun pro;
         
          u3t_off(noc_o);
          pro = u3j_kick(seb, b_gal);
          u3t_on(noc_o);

          if ( u3_none != pro ) {
            u3a_lose(fol);
            return pro;
          }
          else {
            if ( c3n == u3r_ud(b_gal) ) {
              return u3m_bail(c3__exit);
            }
            else {
              u3_noun nex = u3k(u3at(b_gal, seb));

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

      case 10: {
        u3_noun p_gal, q_gal;

        u3x_cell(gal, &p_gal, &q_gal);
        {
          u3_noun zep, hod, nex;

          if ( c3y == u3r_du(p_gal) ) {
            u3_noun b_gal = u3h(p_gal);
            u3_noun c_gal = u3t(p_gal);
            u3_noun d_gal = q_gal;

            zep = u3k(b_gal);
            hod = _n_nock_on(u3k(bus), u3k(c_gal));
            nex = u3k(d_gal);
          }
          else {
            u3_noun b_gal = p_gal;
            u3_noun c_gal = q_gal;

            zep = u3k(b_gal);
            hod = u3_nul;
            nex = u3k(c_gal);
          }

          u3a_lose(fol);
          return _n_hint(zep, hod, bus, nex);
        }
      }

      case 11: {
        u3_noun ref = _n_nock_on(u3k(bus), u3k(u3h(gal)));
        u3_noun gof = _n_nock_on(bus, u3k(u3t(gal)));
        u3_noun val;

        u3t_off(noc_o);
        val = u3m_soft_esc(ref, u3k(gof));
        u3t_on(noc_o);

        if ( !_(u3du(val)) ) {
          u3m_bail(u3nt(1, gof, 0));
        } 
        if ( !_(u3du(u3t(val))) ) {
          //
          //  replace with proper error stack push
          //
          u3t_push(u3nc(c3__hunk, _n_mush(gof)));
          return u3m_bail(c3__exit);
        }
        else {
          u3_noun pro;

          u3z(gof);
          u3z(fol);
          pro = u3k(u3t(u3t(val)));
          u3z(val);

          return pro;
        }
      }  
      c3_assert(!"not reached");
    }
  }
}
示例#4
0
文件: ut_play.c 项目: Gunga/urbit
  static u3_noun
  _play_in(u3_noun van,
           u3_noun sut,
           u3_noun gen)
  {
    u3_noun p_gen, q_gen, r_gen;

    if ( c3n == u3du(gen) ) {
      open: {
        u3_noun ter = u3r_at(u3x_con_3, van);
        u3_noun rex = u3qfp_open(ter, gen);
        u3_noun ret;

        if ( c3y == u3r_sing(rex, gen) ) {
          u3_noun zix = u3qfu_shep(van, "gene", 'q', u3k(gen));

          u3t_push(u3nc(c3__mean, zix));
          return u3m_error("play-open");
        }
        ret = _play_x(van, sut, rex);
        u3z(rex);

        return ret;
      }
    }
    else if ( c3y == u3du(u3h(gen)) ) {
      _play_used();
      {
        u3_noun dis = _play_x(van, sut, u3h(gen));
        u3_noun dat = _play_x(van, sut, u3t(gen));
        u3_noun ret = u3qf_cell(dis, dat);

        u3z(dis);
        u3z(dat);
        return ret;
      }
    }
    else switch ( u3h(gen) ) {
      default: goto open;

      case c3__bcpt: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun sep = u3qfu_seep(van, sut, c3__read, p_gen);
        u3_noun axe = u3h(sep);
        u3_noun rex = u3qfl_whip(van, q_gen, axe);
        u3_noun ret = _play_x(van, sut, rex);

        u3z(sep);
        u3z(rex);

        return ret;
      }
      case c3__wtts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_bean();
      }
      case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _play_used();
      {
        u3_noun fex = u3qfu_gain(van, sut, p_gen);
        u3_noun wux = u3qfu_lose(van, sut, p_gen);
        u3_noun dez = (fex == c3__void) ? c3__void
                                        : _play_x(van, fex, q_gen);
        u3_noun doz = (wux == c3__void) ? c3__void
                                        : _play_x(van, wux, r_gen);
        u3_noun ret = u3qf_fork(dez, doz);

        u3z(dez); u3z(doz);
        u3z(fex); u3z(wux);
        return ret;
      }
      case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun dis = _play_x(van, sut, p_gen);
        u3_noun dat = _play_x(van, sut, q_gen);
        u3_noun ret = u3qf_cell(dis, dat);

        u3z(dis);
        u3z(dat);
        return ret;
      }
      case c3__dtkt: p_gen = u3t(gen);
      _play_used();
      {
        return c3__noun;
      }
      case c3__dtwt: p_gen = u3t(gen);
      _play_used();
      {
        return _play_bean();
      }
      case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_bean();
      }
      case c3__dtls: p_gen = u3t(gen);
      _play_used();
      {
        return u3nc(c3__atom, u3_blip);
      }
      case c3__dtzz: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = (c3n == u3ud(q_gen))
                        ? c3__noun
                        : u3nc(c3__atom, u3k(p_gen));
        u3_noun ret = u3qf_cube(q_gen, boc);

        u3z(boc);
        return ret;
      }
      case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return c3__noun;
      }
      case c3__dtzy: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        if ( 'f' == p_gen ) {
          if ( (q_gen > 1) ) {
            return u3m_bail(c3__exit);
          } else {
            return _play_bean();
          }
        }
        else return u3nc(c3__atom, u3k(p_gen));
      }
      case c3__ktbr: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__iron);

        u3z(boc);
        return pro;
      }
      case c3__ktpm: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__zinc);

        u3z(boc);
        return pro;
      }
      case c3__ktwt: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__lead);

        u3z(boc);
        return pro;
      }
      case c3__ktts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, q_gen);
        u3_noun ret = u3qfu_conk(van, boc, p_gen);

        u3z(boc);
        return ret;
      }
      case c3__ktzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, q_gen);
        u3_noun ret = u3qfu_conk(van, boc, p_gen);

        u3z(boc);
        return ret;
      }
      case c3__ktsg: p_gen = u3t(gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }
      case c3__kthx: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }
      case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }
      case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun ret = _play_x(van, boc, q_gen);

        u3z(boc);
        return ret;
      }
      case c3__tstr: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _play_used();
      {
        u3_noun sep = u3qfu_seep(van, sut, c3__both, q_gen);
        u3_noun bid = u3nt(u3k(p_gen), u3k(q_gen), sep);
        u3_noun boc = u3qf_bull(bid, sut);
        u3_noun ret = _play_x(van, boc, r_gen);

        u3z(bid);
        u3z(boc);

        return ret;
      }
      case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun sec = u3qfu_seek(van, sut, c3__read, p_gen);
        u3_noun lar = _play_foil(sec);
        u3_noun q_lar = u3t(lar);
        u3_noun qq_lar = u3t(q_lar);
        u3_noun mew = u3qfu_snub(van, sut, q_gen);
        u3_noun rag = _play_edit(van, sut, mew, u3k(qq_lar));
        u3_noun ret = u3qfu_fire(van, sut, rag);

        u3z(rag);
        u3z(mew);
        u3z(lar);

        return ret;
      }
      case c3__pmcl: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun ruf = u3nt(c3__clhp,
                           u3nc(u3_nul, 1),
                           u3k(p_gen));
        u3_noun ret = _play_grow(van, sut, c3__zinc, ruf, q_gen);

        u3z(ruf);
        return ret;
      }
      case c3__brcn: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun ruf = u3nc(u3_nul, 1);
        u3_noun ret = _play_grow(van, sut, c3__gold, ruf, p_gen);

        u3z(ruf);
        return ret;
      }
      case c3__pmcn: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun ruf = u3nc(u3_nul, 1);
        u3_noun ret = _play_grow(van, sut, c3__lead, ruf, p_gen);

        u3z(ruf);
        return ret;
      }
      case c3__pmls: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun ruf = u3nt(c3__clhp,
                           u3nc(u3_nul, 1),
                           u3k(p_gen));
        u3_noun ret = _play_grow(van, sut, c3__iron, ruf, q_gen);

        u3z(ruf);
        return ret;
      }
      case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun typ = u3qfu_play(van, sut, p_gen);
        u3_noun dug = u3qfu_duck(van, typ);
        u3_noun ret;

        u3t_push(u3nc(c3__mean, dug));
        {
          ret = _play_x(van, sut, q_gen);
        }
        u3t_drop();

        u3z(typ);
        return ret;
      }
      case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, q_gen);
      }
      case c3__zpts: p_gen = u3t(gen);
      _play_used();
      {
        return c3__noun;
      }
      case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }
      case c3__zpcb: u3x_cell(u3t(gen), &p_gen, &q_gen);
      {
        u3_noun ret;

        u3t_push(u3nc(c3__mean, _play_loc(van, p_gen)));
        {
          ret = _play_x(van, sut, q_gen);
        }
        u3t_drop();
        return ret;
      }
      case c3__zpcn:
      _play_used();
      {
        u3_noun pet = u3j_hook(u3k(van), "seed");
        u3_noun ret = u3k(u3h(pet));

        u3z(pet);
        return ret;
      }
      case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun zur = _play_x(van, sut, p_gen);
        u3_noun vos = _play_x(van, sut, q_gen);
        u3_noun ret = u3qf_cell(zur, vos);

        u3z(zur);
        u3z(vos);

        return ret;
      }
      case c3__zpfs:
      case c3__zpzp:
      _play_used();
      {
        return c3__void;
      }
    }
  }
示例#5
0
文件: n.c 项目: alecbrick/urbit
/* _n_hint(): process hint.
*/
static u3_noun
_n_hint(u3_noun zep, 
        u3_noun hod,
        u3_noun bus,
        u3_noun nex)
{
  switch ( zep ) {
    default: {
      // u3m_p("weird zep", zep);
      u3a_lose(zep);
      u3a_lose(hod);

      return _n_nock_on(bus, nex);
    }

    case c3__hunk:
    case c3__lose:
    case c3__mean:
    case c3__spot: {
      u3_noun tac = u3nc(zep, hod);
      u3_noun pro;

      u3t_push(tac);
#if 0
      if ( c3__spot == zep ) {
        printf("spot %d/%d : %d/%d\r\n",
               u3h(u3h(u3t(hod))),
               u3t(u3h(u3t(hod))),
               u3h(u3t(u3t(hod))),
               u3t(u3t(u3t(hod))));
      }
#endif
      pro = _n_nock_on(bus, nex);
      u3t_drop();

      return pro;
    }

    case c3__slog: {
      u3t_off(noc_o);
      u3t_slog(hod);
      u3t_on(noc_o);
      return _n_nock_on(bus, nex);
    }

    case c3__germ: {
      u3_noun pro = _n_nock_on(bus, nex);

      if ( c3y == u3r_sing(pro, hod) ) {
        u3z(pro); return hod;
      } else {
        u3z(hod); return pro;
      }
    }

    case c3__fast: {
      u3_noun pro = _n_nock_on(bus, nex);

      u3t_off(noc_o);
      u3j_mine(hod, u3k(pro));
      u3t_on(noc_o);

      return pro;
    }

    case c3__memo: {
      u3z(hod);
#if 0
      return _n_nock_on(bus, nex);
#else
      {
        u3_noun pro = u3z_find_2(c3__nock, bus, nex);

        if ( pro != u3_none ) {
          u3z(bus); u3z(nex);
          return pro;
        }
        pro = _n_nock_on(u3k(bus), u3k(nex));

        u3z_save_2(c3__nock, bus, nex, pro);
        u3z(bus); u3z(nex);

        return pro;
      }
#endif
    }

    case c3__sole: {
      u3z(hod);
      {
        u3_noun pro = _n_nock_on(bus, nex);

        // return u3z_uniq(pro);
        return pro;
      }
    }
  }
}
示例#6
0
文件: ut_peek.c 项目: Gunga/urbit
  static u3_noun
  _peek_in(u3_noun van,
           u3_noun sut,
           u3_noun way,
           u3_atom axe,
           u3_noun gil)
  {
    u3_noun p_sut, q_sut;
    u3_noun pro;

    if ( (c3n == u3du(sut)) ) switch ( sut ) {
      default: return u3m_bail(c3__fail);

      case c3__noun: {
        return c3__noun;
      }
      case c3__void: {
        return c3__void;
      }
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom: {
        return c3__void;
      }
      case c3__bull: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _peek_in(van, q_sut, way, axe, gil);
        }
      }
      case c3__cell: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          u3_atom tip = u3qc_cap(axe);
          u3_atom tap = u3qc_mas(axe);

          if ( 2 == tip ) {
            pro = _cqfu_peek(van, p_sut, way, tap);
          }
          else {
            pro = _cqfu_peek(van, q_sut, way, tap);
          }
          u3z(tap);
          u3z(tip);

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

        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ||
             (c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) ||
             (c3n == u3r_cell(rq_sut, &prq_sut, &qrq_sut)) )
        {
          return u3m_bail(c3__fail);
        } else {
          u3_atom tip = u3qc_cap(axe);
          u3_atom tap = u3qc_mas(axe);

          if ( 3 == tip ) {
            if ( c3n == u3qfu_park(van, sut, way, tap) )
            {
              // u3_noun dun = u3qfu_dunq(van, "type", sut);
              u3_noun waz = u3qfu_shep
                (van, "axis", 'd', u3k(axe));

              // u3t_push(u3nc(c3__mean, dun));
              u3t_push(u3nc(c3__mean, waz));

              return u3m_error("peek-park");
            }
            else pro = _cqfu_peek(van, p_sut, way, tap);
          }
          else {
            pro = c3__noun;
          }
          u3z(tap);
          u3z(tip);

          return pro;
        }
      }
      case c3__cube: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _peek_in(van, q_sut, way, axe, gil);
        }
      }
      case c3__face: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _peek_in(van, q_sut, way, axe, gil);
        }
      }
      case c3__fork: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          u3_noun hed = _peek_in(van, p_sut, way, axe, gil);
          u3_noun tal = _peek_in(van, q_sut, way, axe, gil);

          pro = u3qf_fork(hed, tal);

          u3z(hed);
          u3z(tal);

          return pro;
        }
      }
      case c3__hold: {
        p_sut = u3t(sut);
        if ( (c3y == u3qdi_has(gil, sut)) ) {
          return c3__void;
        }
        else {
          u3_noun zoc = u3qdi_put(gil, sut);
          u3_noun fop = u3qfu_repo(van, sut);
          u3_noun pro = _peek_in(van, fop, way, axe, zoc);

          u3z(fop);
          u3z(zoc);

          return pro;
        }
      }
    }
  }
示例#7
0
文件: ut_fish.c 项目: OCForks/urbit
  static u3_noun
  _fish_in(u3_noun van,
           u3_noun sut,
           u3_atom axe,
           u3_noun vit)
  {
    u3_noun p_sut, q_sut;

    if ( c3y == u3ud(sut) ) switch ( sut ) {
      default: return u3m_bail(c3__fail);

      case c3__noun: {
        return u3nc(1, 0);
      }
      case c3__void: {
        return u3nc(1, 1);
      }
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          if ( c3n == u3du(q_sut) ) {
            u3_noun ton = u3nt(3, 0, u3k(axe));
            u3_noun pro = u3qf_flip(ton);

            u3z(ton);
            return pro;
          } else {
            return u3nt(5,
                        u3nc(1, u3k(u3t(q_sut))),
                        u3nc(0, u3k(axe)));
          }
        }
      }
      case c3__cell: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          u3_noun hut = u3nt(3, 0, u3k(axe));
          u3_noun lef = u3qc_peg(axe, 2);
          u3_noun rit = u3qc_peg(axe, 3);
          u3_noun hed = _fish_in(van, p_sut, lef, vit);
          u3_noun tal = _fish_in(van, q_sut, rit, vit);
          u3_noun hob = u3qf_flan(hed, tal);
          u3_noun vug = u3qf_flan(hut, hob);

          u3z(hob);
          u3z(tal);
          u3z(hed);
          u3z(rit);
          u3z(lef);
          u3z(hut);

          return vug;
        }
      }
      case c3__core: {
        return u3nc(0, 0);
      }
      case c3__face: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _fish_in(van, q_sut, axe, vit);
        }
      }
      case c3__fork: p_sut = u3t(sut);
      {
        u3_noun yed = u3qdi_tap(p_sut, u3_nul);
        u3_noun ret = _fish_fork(van, yed, axe, vit);

        u3z(yed);
        return ret;
      }
      case c3__hold: {
        p_sut = u3t(sut);
        {
          if ( (c3y == u3qdi_has(vit, sut)) ) {
            //  u3_noun dun = u3qfu_dunq(van, "type", sut);
            u3_noun niz = u3qfu_shep
              (van, "axis", 'd', u3k(axe));

            //  u3t_push(u3nc(c3__mean, dun));
            u3t_push(u3nc(c3__mean, niz));

            return u3m_error("fish-loop");
          } else {
            u3_noun zoc = u3qdi_put(vit, sut);
            u3_noun fop = u3qfu_repo(van, sut);
            u3_noun pro = _fish_in(van, fop, axe, zoc);

            u3z(fop);
            u3z(zoc);

            return pro;
          }
        }
      }
    }
  }
示例#8
0
文件: ut_fire.c 项目: OCForks/urbit
  static u3_noun
  _fire_each(u3_noun van,
             u3_noun vet,
             u3_noun typ,
             u3_noun gat)
  {
    u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ;
    u3_noun h_gat, t_gat;

    if ( (c3n == u3du(typ)) || (c3__core != u3h(typ)) ) {
      return u3m_error("fire-core");
    } else if
         ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) ||
           (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) ||
           (c3n == u3r_cell(gat, &h_gat, &t_gat)) )
    {
      return u3m_bail(c3__fail);
    } else {
      u3_noun dox = u3nt
        (c3__core, u3k(qq_typ), u3k(q_typ));

      if ( c3__ash == u3h(gat) ) {
        if ( (c3y == vet) &&
             (c3n == u3qfu_nest(van, qq_typ, c3y, p_typ)) )
        {
#if 0
          u3_noun dun = u3qfu_dunq(van, "need", qq_typ);
          u3_noun niz = u3qfu_dunq(van, "have", p_typ);

          u3t_push(u3nc(c3__mean, niz));
          u3t_push(u3nc(c3__mean, dun));
#endif
          return u3m_error("fire-dry");
        }
        else {
          return u3nc(dox, u3k(t_gat));
        }
      }
      else {
        c3_assert(c3__elm == u3h(gat));
#if 0
        u3_noun dun = u3qfu_dunq(van, "wild", typ);
        u3_noun niz = u3qfu_dunq(van, "tame", dox);

        u3t_push(u3nc(c3__mean, dun));
        u3t_push(u3nc(c3__mean, niz));
#endif
        if ( (c3y == vet) &&
             (c3n == _fire_mull(van, typ, dox, t_gat)) )
        {
          return u3m_error("fire-wet");
        }
        else {
          u3z(dox);
#if 0
          u3t_drop();
          u3t_drop();
#endif
          return u3nc(u3k(typ), u3k(t_gat));
        }
      }
    }
  }
示例#9
0
文件: ut_play.c 项目: OCForks/urbit
  static u3_noun
  _play_in(u3_noun van,
           u3_noun sut,
           u3_noun gen)
  {
    u3_noun p_gen, q_gen, r_gen;

    if ( c3n == u3du(gen) ) {
      open: {
        u3_noun ter = u3r_at(u3x_con_3, van);
        u3_noun rex = u3qfp_open(ter, gen);
        u3_noun ret;

        if ( c3y == u3r_sing(rex, gen) ) {
          u3_noun zix = u3qfu_shep(van, "gene", 'q', u3k(gen));

          u3t_push(u3nc(c3__mean, zix));
          return u3m_error("play-open");
        }
        ret = _play_x(van, sut, rex);
        u3z(rex);

        return ret;
      }
    }
    else if ( c3y == u3du(u3h(gen)) ) {
      _play_used();
      {
        u3_noun dis = _play_x(van, sut, u3h(gen));
        u3_noun dat = _play_x(van, sut, u3t(gen));
        u3_noun ret = u3qf_cell(dis, dat);

        u3z(dis);
        u3z(dat);
        return ret;
      }
    }
    else switch ( u3h(gen) ) {
      default: goto open;

      case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_bean();
      }

      case c3__if: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _play_used();
      {
        u3_noun fex = u3qfu_gain(van, sut, p_gen);
        u3_noun wux = u3qfu_lose(van, sut, p_gen);
        u3_noun dez = (fex == c3__void) ? c3__void
                                        : _play_x(van, fex, q_gen);
        u3_noun doz = (wux == c3__void) ? c3__void
                                        : _play_x(van, wux, r_gen);
        u3_noun ret = u3qf_forq(dez, doz);

        u3z(dez); u3z(doz);
        u3z(fex); u3z(wux);
        return ret;
      }

      case c3__cons: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun dis = _play_x(van, sut, p_gen);
        u3_noun dat = _play_x(van, sut, q_gen);
        u3_noun ret = u3qf_cell(dis, dat);

        u3z(dis);
        u3z(dat);
        return ret;
      }

      case c3__wish: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun nog = u3nc(c3__bunt, u3k(p_gen));
        u3_noun ret = _play_x(van, sut, nog);

        u3z(nog);
        return ret;
      }

      case c3__deep: p_gen = u3t(gen);
      _play_used();
      {
        return _play_bean();
      }

      case c3__same: u3x_cell(u3t(gen), &p_gen, &q_gen); 
      _play_used();
      {
        return _play_bean();
      }
      
      case c3__bump: p_gen = u3t(gen);
      _play_used();
      {
        return u3nt(c3__atom, u3_blip, u3_nul);
      }

      case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_rock(p_gen, q_gen);
      }

      case c3__nock: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return c3__noun;
      }

      case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_sand(p_gen, q_gen);
      }

      case c3__hand: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return u3k(p_gen);
      }

      case c3__iron: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__iron);

        u3z(boc);
        return pro;
      }

      case c3__zinc: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__zinc);

        u3z(boc);
        return pro;
      }

      case c3__lead: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__lead);

        u3z(boc);
        return pro;
      }

      case c3__name: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, q_gen);
        u3_noun ret = u3qfu_conk(van, boc, p_gen);

        u3z(boc);
        return ret;
      }

      case c3__burn: p_gen = u3t(gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }

      case c3__like: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }

      case c3__per: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun ret = _play_x(van, boc, q_gen);

        u3z(boc);
        return ret;
      }

      case c3__aka: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _play_used();
      {
        u3_noun boc = u3qfu_buss(van, sut, p_gen, q_gen);
        u3_noun ret = _play_x(van, boc, r_gen);

        u3z(boc);
        return ret;
      }

      case c3__make: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_cnts(van, sut, p_gen, q_gen);
      }

      case c3__core: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun ruf = u3nc(u3_nul, 1);
        u3_noun ret = _play_grow(van, sut, c3__gold, ruf, p_gen);

        u3z(ruf);
        return ret;
      }

      case c3__peep: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun typ = u3qfu_play(van, sut, p_gen);
        u3_noun dug = u3qfu_duck(van, typ);
        u3_noun ret;

        u3t_push(u3nc(c3__mean, dug));
        {
          ret = _play_x(van, sut, q_gen);
        }
        u3t_drop();

        u3z(typ);
        return ret;
      }

      case c3__hint: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, q_gen);
      }

      case c3__code: p_gen = u3t(gen);
      _play_used();
      {
        return c3__noun;
      }

      case c3__twig: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }

      case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen);
      {
        u3_noun ret;

        u3t_push(u3nc(c3__mean, _play_loc(van, p_gen)));
        {
          ret = _play_x(van, sut, q_gen);
        }
        u3t_drop();
        return ret;
      }

      case c3__spit: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun zur = _play_x(van, sut, p_gen);
        u3_noun vos = _play_x(van, sut, q_gen);
        u3_noun ret = u3qf_cell(zur, vos);

        u3z(zur);
        u3z(vos);

        return ret;
      }

      case c3__lost:
      case c3__fail:
      _play_used();
      {
        return c3__void;
      }
    }
  }
示例#10
0
文件: ut_play.c 项目: bd/urbit
  static u3_noun
  _play_in(u3_noun van,
           u3_noun sut,
           u3_noun gen)
  {
    u3_noun p_gen, q_gen, r_gen;

    if ( c3n == u3du(gen) ) {
      open: {
        u3_noun fab = u3r_at(u3qfu_van_fab, van);
        u3_noun ter = u3r_at(u3x_con_3, van);
        u3_noun rex = (c3n == fab) ? u3qfp_nepo(ter, gen)
                                   : u3qfp_open(ter, gen);
        u3_noun ret;

        if ( c3y == u3r_sing(rex, gen) ) {
          u3_noun zix = u3qfu_shep(van, "gene", 'q', u3k(gen));

          u3t_push(u3nc(c3__mean, zix));
          return u3m_error("play-open-z");
        }
        ret = _play_x(van, sut, rex);
        u3z(rex);

        return ret;
      }
    }
    else if ( c3y == u3du(u3h(gen)) ) {
      _play_used();
      {
        u3_noun dis = _play_x(van, sut, u3h(gen));
        u3_noun dat = _play_x(van, sut, u3t(gen));
        u3_noun ret = u3qf_cell(dis, dat);

        u3z(dis);
        u3z(dat);
        return ret;
      }
    }
    else switch ( u3h(gen) ) {
      default: goto open;

      case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_bean();
      }

      case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _play_used();
      {
        u3_noun fex = u3qfu_gain(van, sut, p_gen);
        u3_noun wux = u3qfu_lose(van, sut, p_gen);
        u3_noun dez = (fex == c3__void) ? c3__void
                                        : _play_x(van, fex, q_gen);
        u3_noun doz = (wux == c3__void) ? c3__void
                                        : _play_x(van, wux, r_gen);
        u3_noun ret = u3qf_forq(dez, doz);

        u3z(dez); u3z(doz);
        u3z(fex); u3z(wux);
        return ret;
      }

      case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun dis = _play_x(van, sut, p_gen);
        u3_noun dat = _play_x(van, sut, q_gen);
        u3_noun ret = u3qf_cell(dis, dat);

        u3z(dis);
        u3z(dat);
        return ret;
      }

      case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun nog = u3nc(c3__bunt, u3k(p_gen));
        u3_noun ret = _play_x(van, sut, nog);

        u3z(nog);
        return ret;
      }

      case c3__dtwt: p_gen = u3t(gen);
      _play_used();
      {
        return _play_bean();
      }

      case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen); 
      _play_used();
      {
        return _play_bean();
      }
      
      case c3__dtls: p_gen = u3t(gen);
      _play_used();
      {
        return u3nt(c3__atom, u3_blip, u3_nul);
      }

      case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_rock(p_gen, q_gen);
      }

      case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return c3__noun;
      }

      case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_sand(p_gen, q_gen);
      }

      case c3__hand: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return u3k(p_gen);
      }

      case c3__ktbr: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__iron);

        u3z(boc);
        return pro;
      }

      case c3__ktpm: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__zinc);

        u3z(boc);
        return pro;
      }

      case c3__ktwt: p_gen = u3t(gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun pro = u3qfu_wrap(van, boc, c3__lead);

        u3z(boc);
        return pro;
      }

      case c3__help: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, q_gen);
        u3_noun ret = u3qf_help(p_gen, boc);

        u3z(boc);
        return ret;
      }

      case c3__docs: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, q_gen);
        u3_noun hep = u3nc(c3__docs, u3k(p_gen));
        u3_noun ret = u3qf_help(hep, boc);

        u3z(hep);
        u3z(boc);
        return ret;
      }

      case c3__ktts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, q_gen);
        u3_noun ret = u3qfu_conk(van, boc, p_gen);

        u3z(boc);
        return ret;
      }

      case c3__tune: p_gen = u3t(gen);
      _play_used();
      {
        return u3qf_face(p_gen, sut);
      }

      case c3__ktsg: p_gen = u3t(gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }

      case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }

      case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = _play_x(van, sut, p_gen);
        u3_noun ret = _play_x(van, boc, q_gen);

        u3z(boc);
        return ret;
      }

      case c3__tstr: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _play_used();
      {
        u3_noun boc = u3qfu_buss(van, sut, p_gen, q_gen);
        u3_noun ret = _play_x(van, boc, r_gen);

        u3z(boc);
        return ret;
      }

      case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun boc = u3qfu_busk(van, sut, p_gen);
        u3_noun ret = _play_x(van, boc, q_gen);

        u3z(boc);
        return ret;
      }

      case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_cnts(van, sut, p_gen, q_gen);
      }

      case c3__brcn: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun ruf = u3nc(u3_nul, 1);
        u3_noun ret = _play_grow(van, sut, c3__gold, ruf, p_gen, q_gen);

        u3z(ruf);
        return ret;
      }

      case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun typ = u3qfu_play(van, sut, p_gen);
        u3_noun dug = u3qfu_duck(van, typ);
        u3_noun ret;

        u3t_push(u3nc(c3__mean, dug));
        {
          ret = _play_x(van, sut, q_gen);
        }
        u3t_drop();

        u3z(typ);
        return ret;
      }

      case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, q_gen);
      }

      case c3__zpts: p_gen = u3t(gen);
      _play_used();
      {
        return c3__noun;
      }

      case c3__ktcn: p_gen = u3t(gen);
      {
        u3_noun von = u3i_molt(u3k(van), u3qfu_van_fab, c3n, 0);
        u3_noun ret = _play_x(von, sut, p_gen);

        u3z(von);
        return ret;
      }

      case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        return _play_x(van, sut, p_gen);
      }

      case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen);
      {
        u3_noun ret;

#if 0
        {
          u3_noun cog = _play_loc_term(van, p_gen);

          u3t_heck(cog);
          u3z(cog);
        }
#endif
        u3t_push(u3nc(c3__mean, _play_loc(van, p_gen)));
        {
          ret = _play_x(van, sut, q_gen);
        }
        u3t_drop();
        return ret;
      }

      case c3__zpmc:
      case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _play_used();
      {
        u3_noun zur = _play_x(van, sut, p_gen);
        u3_noun vos = _play_x(van, sut, q_gen);
        u3_noun ret = u3qf_cell(zur, vos);

        u3z(zur);
        u3z(vos);

        return ret;
      }

      case c3__lost:
      case c3__fail:
      case c3__zpzp:
      _play_used();
      {
        return c3__void;
      }
    }
  }
示例#11
0
  static u3_noun
  _mint_in(u3_noun van,
           u3_noun sut,
           u3_noun gol,
           u3_noun gen)
  {
    u3_noun p_gen, q_gen, r_gen;
    u3_noun ret;

    if ( (c3__void == sut) &&
         !((c3y == u3du(gen)) && (c3__zpcb == u3h(gen))) )
    {
      if ( (c3n == _mint_vet(van))
           || ((c3y == u3du(gen)) &&
               ((c3__zpfs == u3h(gen)) || (c3__zpzp == u3h(gen)))) )
      {
        return u3nt(c3__void, 0, 0);
      }
      else {
        return u3m_error("mint-vain");
      }
    }

    if ( c3n == u3du(gen) ) {
      u3_noun ter = u3r_at(u3x_con_3, van);
      u3_noun rex = u3qfp_open(ter, gen);

      ret = _mint_in(van, sut, gol, rex);
      u3z(rex);

      return ret;
    }
    else if ( c3y == u3du(u3h(gen)) ) {
      _mint_used();
      {
        u3_noun hed = _mint_in(van, sut, c3__noun, u3h(gen));
        u3_noun tal = _mint_in(van, sut, c3__noun, u3t(gen));
        u3_noun typ = u3qf_cell(u3h(hed), u3h(tal));

        ret = u3nc
          (
           _mint_nice(van, gol, typ),
           u3qf_cons(u3t(hed), u3t(tal)));

        u3z(hed);
        u3z(tal);

        return ret;
      }
    } else switch ( u3h(gen) ) {
      default: {
        u3_noun ter = u3r_at(u3x_con_3, van);
        u3_noun rex = u3qfp_open(ter, gen);

        if ( c3y == u3r_sing(rex, gen) ) {
#if 1
          u3_noun zix = u3qfu_shep(van, "gene", 'q', u3k(gen));

          u3t_push(u3nc(c3__mean, zix));
          return u3m_error("mint-open");
#else
          u3_err("h", u3h(gen));
          return u3m_bail(c3__fail);
#endif
        }
        ret = _mint_in(van, sut, gol, rex);
        u3z(rex);

        return ret;
      }

      case c3__bcpt: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun sep = u3qfu_seep(van, sut, c3__read, p_gen);
        u3_noun axe = u3h(sep);
        u3_noun rex = u3qfl_whip(van, q_gen, axe);
        u3_noun ret = _mint_in(van, sut, gol, rex);

        u3z(sep);
        u3z(rex);

        return ret;
      }

      case c3__wtts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun nob = u3qfl_bunt(van, p_gen);
        u3_noun dok = u3nc(c3__cnzz, u3k(q_gen));
        u3_noun vol = _mint_corn(van, sut, dok);
        u3_noun axe = _mint_coke(vol);
        u3_noun wam = u3qfu_play(van, sut, nob);

        ret = u3nc
          (
           _mint_nice(van, gol, _mint_bean()),
           u3qfu_fish(van, wam, axe));

        u3z(axe);
        u3z(wam);
        u3z(nob);
        u3z(dok);

        return ret;
      }

      case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _mint_used();
      {
        u3_noun bol = _mint_bean();
        u3_noun nor = _mint_in(van, sut, bol, p_gen);
        u3_noun fex = u3qfu_gain(van, sut, p_gen);
        u3_noun wux = u3qfu_lose(van, sut, p_gen);
        u3_noun duy = (c3__void == fex)
                        ? ( (c3__void == wux)
                             ?  u3nc(0, 0)
                             :  u3nc(1, 1) )
                        : ( (c3__void == wux)
                            ?  u3nc(1, 0)
                            :  u3k(u3t(nor)) );
        u3_noun hiq = _mint_in(van, fex, gol, q_gen);
        u3_noun ran = _mint_in(van, wux, gol, r_gen);

        ret = u3nc
          (u3qf_fork(u3h(hiq), u3h(ran)),
                  _mint_cond(duy,
                                    u3k(u3t(hiq)),
                                    u3k(u3t(ran))));

        u3z(ran);
        u3z(hiq);
        u3z(nor);
        u3z(wux);
        u3z(fex);
        u3z(bol);

        return ret;
      }
      case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun hed = _mint_in(van, sut, c3__noun, p_gen);
        u3_noun tal = _mint_in(van, sut, c3__noun, q_gen);
        u3_noun typ = u3qf_cell(u3h(hed), u3h(tal));

        ret = u3nc
          (
           _mint_nice(van, gol, typ),
           u3qf_cons(u3t(hed), u3t(tal)));

        u3z(hed);
        u3z(tal);

        return ret;
      }
      case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun typ = _mint_nice(van, gol, _mint_bean());
        u3_noun one = _mint_corn(van, sut, p_gen);
        u3_noun two = _mint_corn(van, sut, q_gen);

        return u3nc(typ, u3nt(5, one, two));
      }
      case c3__dtwt: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun typ = _mint_nice(van, gol, _mint_bean());

        return u3nc
          (
           typ,
           u3nc(3, _mint_corn(van, sut, p_gen)));
      }
      case c3__dtkt: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun tom = c3__noun;
        u3_noun sam = _mint_in(van, sut, tom, p_gen);

        ret = u3nc
          (
           _mint_nice(van, gol, tom),
           u3nc(11, u3k(u3t(sam))));

        u3z(sam);
        return ret;
      }
      case c3__dtls: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun tom = u3nc(c3__atom, u3_blip);
        u3_noun sam = _mint_in(van, sut, tom, p_gen);

        ret = u3nc
          (
           _mint_nice(van, gol, tom),
           u3nc(4, u3k(u3t(sam))));

        u3z(sam);
        return ret;
      }
      case c3__dtzz: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun boc = (c3n == u3ud(q_gen))
                        ? c3__noun
                        : u3nc(c3__atom, u3k(p_gen));
        u3_noun typ = u3qf_cube(q_gen, boc);
        u3_noun ret =
            u3nc(
                  _mint_nice(van, gol, typ),
                  u3nc(1, u3k(q_gen)));

        u3z(boc);
        return ret;
      }
      case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun one = _mint_corn(van, sut, p_gen);
        u3_noun two = _mint_corn(van, sut, q_gen);

        return u3nc
          (
           _mint_nice(van, gol, c3__noun),
           u3nt(2, one, two));
      }
      case c3__dtzy: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun typ = u3qfu_play(van, sut, gen);
        u3_noun ret =
            u3nc(
                  _mint_nice(van, gol, typ),
                  u3nc(1, u3k(q_gen)));

        return ret;
      }
      case c3__ktbr: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun ryd = _mint_in(van, sut, gol, p_gen);
        u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__iron);
        u3_noun pro = u3nc(tyf, u3k(u3t(ryd)));

        u3z(ryd);
        return pro;
      }
      case c3__ktpm: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun ryd = _mint_in(van, sut, gol, p_gen);
        u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__zinc);
        u3_noun pro = u3nc(tyf, u3k(u3t(ryd)));

        u3z(ryd);
        return pro;
      }
      case c3__ktwt: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun ryd = _mint_in(van, sut, gol, p_gen);
        u3_noun tyf = u3qfu_wrap(van, u3h(ryd), c3__lead);
        u3_noun pro = u3nc(tyf, u3k(u3t(ryd)));

        u3z(ryd);
        return pro;
      }
      case c3__ktts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun vat = _mint_in(van, sut, gol, q_gen);

        ret = u3nc
          (
           u3qfu_conk(van, u3h(vat), p_gen),
           u3k(u3t(vat)));

        u3z(vat);
        return ret;
      }
      case c3__ktzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun vat = _mint_in(van, sut, gol, q_gen);

        ret = u3nc
          (
           u3qfu_conk(van, u3h(vat), p_gen),
           u3k(u3t(vat)));

        u3z(vat);
        return ret;
      }
      case c3__ktsg: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun nef = _mint_in(van, sut, gol, p_gen);
        u3_noun p_nef = u3h(nef);
        u3_noun q_nef = u3t(nef);
        u3_noun fom;

        {
          u3_noun cag = u3qfu_burn(van, sut);
          u3_noun wim = u3n_nock_an(cag, u3k(q_nef));

          if ( 0 == u3h(wim) ) {
            fom = u3nc(1, u3k(u3t(wim)));
          } else {
            fom = u3k(q_nef);
          }
          u3z(wim);
        }
        ret = u3nc(u3k(p_nef), fom);

        u3z(nef);
        return ret;
      }
      case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun huz = u3qfu_play(van, sut, p_gen);
        u3_noun hif = _mint_nice(van, gol, huz);
        u3_noun zel = _mint_in(van, sut, hif, q_gen);
        u3_noun ret = u3nc(hif, u3k(u3t(zel)));

        u3z(zel);
        return ret;
      }
      case c3__kthx: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun huz = u3qfu_play(van, sut, p_gen);
        u3_noun hif = _mint_nice(van, gol, huz);
        u3_noun zel = _mint_in(van, sut, hif, q_gen);
        u3_noun ret = u3nc(hif, u3k(u3t(zel)));

#if 0
        {
          u3_noun goz = u3qfu_play(van, sut, q_gen);
          u3_noun bar;

          FOO = 1;
          fprintf(stderr, "\r\n");
          bar = u3qfu_nest(van, huz, c3n, goz);
          fprintf(stderr, "kthx: bar %d\r\n", bar);
          FOO = 0;
        }
#endif
        u3z(zel);
        return ret;
      }
      case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun fid = _mint_in(van, sut, c3__noun, p_gen);
        u3_noun p_fid = u3h(fid);
        u3_noun q_fid = u3t(fid);
        u3_noun dov = _mint_in(van, p_fid, gol, q_gen);
        u3_noun p_dov = u3h(dov);
        u3_noun q_dov = u3t(dov);

        ret = u3nc
          (u3k(p_dov),
                  u3qf_comb(q_fid, q_dov));

        u3z(fid);
        u3z(dov);
        return ret;
      }
      case c3__tstr: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
      _mint_used();
      {
        u3_noun sep = u3qfu_seep(van, sut, c3__both, q_gen);
        u3_noun bid = u3nt(u3k(p_gen), u3k(q_gen), sep);
        u3_noun boc = u3qf_bull(bid, sut);
        u3_noun ret = _mint_in(van, boc, gol, r_gen);

        u3z(bid);
        u3z(boc);

        return ret;
      }
      case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun sec = u3qfu_seek(van, sut, c3__read, p_gen);
        u3_noun lar = _mint_foil(sec);
        u3_noun p_lar = u3h(lar);
        u3_noun q_lar = u3t(lar);
        u3_noun pq_lar = u3h(q_lar);
        u3_noun qq_lar = u3t(q_lar);
        u3_noun mew = u3qfu_snub(van, sut, q_gen);
        u3_noun yom = _mint_edit
          (van, sut, mew, p_lar, u3k(qq_lar), u3_nul);
        u3_noun p_yom = u3h(yom);
        u3_noun q_yom = u3t(yom);
        u3_noun ret = u3nc
          (_mint_nice(van, gol, u3k(p_yom)),
                  (0 == pq_lar) ? u3k(q_yom)
                                : u3nt(9, u3k(pq_lar), u3k(q_yom)));

        u3z(yom);
        u3z(mew);
        u3z(lar);

        return ret;
      }
      case c3__pmcl: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun ruf = u3nt
          (c3__clhp,
                  u3nc(u3_nul, 1),
                  u3k(p_gen));
        u3_noun ret = _mint_grow(van, sut, gol, c3__zinc, ruf, q_gen);

        u3z(ruf);
        return ret;
      }
      case c3__brcn: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun ruf = u3nc(u3_nul, 1);

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

        return ret;
      }
      case c3__pmcn: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun ruf = u3nc(u3_nul, 1);

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

        return ret;
      }
      case c3__pmls: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun ruf = u3nt
          (c3__clhp,
                  u3nc(u3_nul, 1),
                  u3k(p_gen));
        u3_noun ret = _mint_grow(van, sut, gol, c3__iron, ruf, q_gen);

        u3z(ruf);
        return ret;
      }
      case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun typ = u3qfu_play(van, sut, p_gen);
        u3_noun dug = u3qfu_duck(van, typ);

        u3t_push(u3nc(c3__mean, dug));
        {
          ret = _mint_in(van, sut, gol, q_gen);
        }
        u3t_drop();

        u3z(typ);
        return ret;
      }
      case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun hum = _mint_in(van, sut, gol, q_gen);
        u3_noun bez;

          if ( c3y == u3ud(p_gen) ) {
            bez = u3k(p_gen);
          } else {
            bez = u3nc(u3k(u3h(p_gen)),
                               _mint_corn(van, sut, u3t(p_gen)));
          }
          ret = u3nc(
                      u3k(u3h(hum)),
                      u3nt(10, bez, u3k(u3t(hum))));

        u3z(hum);
        return ret;
      }
      case c3__zpts: p_gen = u3t(gen);
      _mint_used();
      {
        u3_noun von = u3i_molt(u3k(van), u3qfu_van_vet, c3n, 0);
        u3_noun sev = _mint_corn(von, sut, p_gen);

        u3z(von);
        return u3nc(c3__noun, u3nc(1, sev));
      }
      case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        return u3nc
          (
           _mint_nice(van,
                             gol,
                             u3qfu_play(van, sut, p_gen)),
           u3nc(1, u3k(q_gen)));
      }
      case c3__zpcb: u3x_cell(u3t(gen), &p_gen, &q_gen);
      {
        u3t_push(u3nc(c3__mean, _mint_loc(van, p_gen)));
        {
          u3_noun hum = _mint_in(van, sut, gol, q_gen);
          u3_noun bez = u3nt(c3__spot, 1, u3k(p_gen));

          ret = u3nc(u3k(u3h(hum)), u3nt(10, bez, u3k(u3t(hum))));
          u3z(hum);
        }
        u3t_drop();
        return ret;
      }
      case c3__zpcn:
      _mint_used();
      {
        u3_noun pet   = u3j_hook(u3k(van), "seed");
        u3_noun p_pet = u3h(pet);
        u3_noun q_pet = u3t(pet);
        u3_noun ret;

        ret = u3nc(_mint_nice(van, gol, u3k(p_pet)),
                           u3nc(1, u3k(q_pet)));

        u3z(pet);
        return ret;
      }
      case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen);
      _mint_used();
      {
        u3_noun vos   = _mint_in(van, sut, c3__noun, q_gen);
        u3_noun zur   = u3qfu_play(van, sut, p_gen);
        u3_noun p_vos = u3h(vos);
        u3_noun q_vos = u3t(vos);
        u3_noun waz   = u3nc(1, u3k(p_vos));
        u3_noun sif   = u3k(zur);
        u3_noun cig   = u3qf_cell(sif, p_vos);
        u3_noun ret;

        ret = u3nc(
                    _mint_nice(van, gol, cig),
                    u3qf_cons(waz, q_vos));

        u3z(waz);
        u3z(zur);
        u3z(sif);
        u3z(vos);

        return ret;
      }
      case c3__zpfs: p_gen = u3t(gen);
      _mint_used();
      {
        if ( c3y == _mint_vet(van) ) {
          u3_noun zur = u3qfu_play(van, sut, p_gen);
          u3_noun dun = u3qfu_dunq(van, "lost", zur);

          u3t_push(u3nc(c3__mean, dun));
          return u3m_error("mint-lost");
        }
        else {
          return u3nt(c3__void, 0, 0);
        }
      }
      case c3__zpzp:
      _mint_used();
      {
        return u3nt(c3__void, 0, 0);
      }
    }
  }
示例#12
0
  static u3_noun
  _crop_dext(
             u3_noun van,
             u3_noun sut,
             u3_noun ref,
             u3_noun bix)
  {
    u3_noun p_sut, q_sut, p_ref, q_ref;

    if ( c3n == u3du(ref) ) {
      switch ( ref ) {
        case c3__void: return u3k(sut);
        case c3__noun: return c3__void;
        default: return u3m_bail(c3__fail);
      }
    }
    if ( c3y == u3r_sing(sut, ref) ) {
      return c3__void;
    }
    if ( c3n == u3du(sut) ) switch ( sut ) {
      default: return u3m_bail(c3__fail);

      case c3__noun: return _crop_repo(van, sut, ref, bix);
      case c3__void: return c3__void;
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom:
      {
        if ( c3__atom == u3h(ref) ) {
          return c3__void;
        }
        else if ( c3__cell == u3h(ref) ) {
          return u3k(sut);
        }
        else return _crop_sint(van, sut, ref, bix);
      }
      case c3__bull: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun foz = _crop_dext(van, q_sut, ref, bix);
        u3_noun ret = u3qf_bull(p_sut, foz);

        u3z(foz);
        return ret;
      }
      case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        if ( c3__atom == u3h(ref) ) {
          return u3k(sut);
        }
        else if ( c3__cell == u3h(ref) ) {
          u3x_cell(u3t(ref), &p_ref, &q_ref);

          if ( c3y == u3qfu_nest
                              (van, p_ref, c3n, p_sut) )
          {
            u3_noun foz = _crop_dext(van, q_sut, q_ref, bix);
            u3_noun ret = u3qf_cell(p_sut, foz);

            u3z(foz);
            return ret;
          }
          else return u3k(sut);
        }
        else return _crop_sint(van, sut, ref, bix);
      }
      case c3__core:
      {
        if ( (c3__atom == u3h(ref)) || (c3__cell == u3h(ref)) ) {
          return u3k(sut);
        }
        else return _crop_sint(van, sut, ref, bix);
      }
      case c3__cube: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        if ( (c3__cube == u3h(ref)) &&
             (c3y == u3r_sing(p_sut, u3h(u3t(ref)))) )
        {
          return c3__void;
        }
        else if ( (c3__atom == u3h(ref)) || (c3__cell == u3h(ref)) ) {
          u3_noun foz = _crop_dext(van, q_sut, ref, bix);
          u3_noun ret;

          if ( c3y == u3qfu_firm(van, foz, p_sut) ) {
            ret = u3qf_cube(p_sut, foz);
          }
          else ret = c3__void;

          u3z(foz);
          return ret;
        }
        else return _crop_sint(van, sut, ref, bix);
      }
      case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun foz = _crop_dext(van, q_sut, ref, bix);
        u3_noun ret = u3qf_face(p_sut, foz);

        u3z(foz);
        return ret;
      }
      case c3__fork: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun dis = _crop_dext(van, p_sut, ref, bix);
        u3_noun dat = _crop_dext(van, q_sut, ref, bix);
        u3_noun ret = u3qf_fork(dis, dat);

        u3z(dis);
        u3z(dat);
        return ret;
      }
      case c3__hold: p_sut = u3t(sut);
      {
        u3_noun hud = u3nc(u3k(sut), u3k(ref));

        if ( c3y == u3qdi_has(bix, hud) ) {
#         if 0
            u3_noun dun = u3qfu_dunq(van, "type", sut);
            u3_noun niz = u3qfu_dunq(van, "over", ref);

            u3t_push(u3nc(c3__mean, dun));
            u3t_push(u3nc(c3__mean, niz));
#         endif

          return u3m_error("crop-loop");
        } else {
          u3_noun bux = u3qdi_put(bix, hud);
          u3_noun ret = _crop_repo(van, sut, ref, bux);

          u3z(hud);
          u3z(bux);
          return ret;
        }
      }
    }
  }