示例#1
0
文件: ut_fire.c 项目: OCForks/urbit
  static u3_noun
  _fire_mull(u3_noun van,
             u3_noun sut,
             u3_noun dox,
             u3_noun gen)
  {
    u3_noun rib = u3r_at(u3qfu_van_rib, van);
    u3_noun key = u3nt(u3k(sut),
                       u3k(dox),
                       u3k(gen));
    u3_noun ret;

    if ( c3n == _fire_vet(van) ) {
      ret = c3y;
    }
    if ( c3y == u3qdi_has(rib, key) ) {
      ret = c3y;
    }
    else {
      u3_noun rob = u3qdi_put(rib, key);
      u3_noun von = u3i_molt(u3k(van),
                             u3qfu_van_rib,
                             u3k(rob),
                             0);
      u3_noun mul = u3qfu_mull(von, sut, c3__noun, dox, gen);

      ret = c3y;
  
      u3z(mul);
      u3z(von);
      u3z(rob);
    }
    u3z(key);
    return ret;
  }
示例#2
0
文件: in_gas.c 项目: Gunga/urbit
/* functions
*/
  u3_noun
  u3qdi_gas(u3_noun a,
            u3_noun b)
  {
    if ( u3_nul == b ) {
      return u3k(a);
    }
    else {
      if ( c3n == u3du(b) ) {
        return u3m_bail(c3__exit);
      } else {
        u3_noun i_b = u3h(b);
        u3_noun t_b = u3t(b);
        u3_noun c;

        if ( u3_none == (c = u3qdi_put(a, i_b)) ) {
          return u3m_bail(c3__exit);
        } else {
          u3_noun d = u3qdi_gas(c, t_b);

          u3z(c);
          return d;
        }
      }
    }
  }
示例#3
0
  static u3_noun
  _heal_to(
           u3_noun van,
           u3_noun sut,
           u3_noun gil,
           u3_noun qog,
           u3_noun ref,
           u3_atom now,
           u3_atom lat)
  {
    u3_noun p_sut, q_sut;

    if ( c3n == u3du(sut) ) {
      goto repo;
    }
    else switch ( u3h(sut) ) {
      default: goto repo;

      case c3__atom: return c3__void;

      case c3__bull: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun sub = _heal_to(van, q_sut, gil, qog, ref, now, lat);
        u3_noun ret;

        ret = u3qfu_busk
          (van, sub, u3h(p_sut), u3h(u3t(p_sut)));

        u3z(sub);
        return ret;
      }
      case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun ter, ret;

        if ( 2 == now ) {
          ter = _heal_as(van, p_sut, qog, lat, ref);
          ret = u3qf_cell(ter, q_sut);
        } else {
          ter = _heal_as(van, q_sut, qog, lat, ref);
          ret = u3qf_cell(p_sut, ter);
        }
        u3z(ter);
        return ret;
      }

      case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        if ( 3 != now ) {
          return u3m_error("heal-core");
        } else {
          u3_noun ter = _heal_as(van, p_sut, qog, lat, ref);
          u3_noun ret = u3qf_core(ter, q_sut);

          u3z(ter);
          return ret;
        }
      }
      case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun dun = _heal_to(van, q_sut, gil, qog, ref, now, lat);
        u3_noun ret = u3qf_face(p_sut, dun);

        u3z(dun);
        return ret;
      }
      case c3__fork: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun dis = _heal_to(van, p_sut, gil, qog, ref, now, lat);
        u3_noun dat = _heal_to(van, q_sut, gil, qog, ref, now, lat);
        u3_noun ret = u3qf_fork(dis, dat);

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

      case c3__hold: {
        if ( (c3y == u3qdi_has(gil, sut)) ) {
          return c3__void;
        }
        else {
          u3_noun zoc = u3qdi_put(gil, sut);
          u3_noun rep = u3qfu_repo(van, sut);
          u3_noun ret = _heal_to(van, rep, zoc, qog, ref, now, lat);

          u3z(rep);
          u3z(zoc);

          return ret;
        }
      }
    }

    repo: {
      u3_noun rep = u3qfu_repo(van, sut);
      u3_noun ret = _heal_to(van, rep, gil, qog, ref, now, lat);

      u3z(rep);
      return ret;
    }
  }
示例#4
0
文件: ut_nest.c 项目: alecbrick/urbit
  static u3_noun
  _nest_cong(u3_noun van,
             u3_noun sut,
             u3_noun tel,
             u3_noun ref,
             u3_noun gil)
  {
    u3_noun p_sut, q_sut, p_ref, q_ref;
    u3_noun pq_sut, qq_sut, rq_sut;
    u3_noun pq_ref, qq_ref, rq_ref;
    u3_noun prq_sut, qrq_sut, prq_ref, qrq_ref;
    u3_noun ret;

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

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

    u3x_cell(rq_sut, &prq_sut, &qrq_sut);
    u3x_cell(rq_ref, &prq_ref, &qrq_ref);

    if ( c3y == u3r_sing(q_sut, q_ref) ) {
      return _nest_dext(van, p_sut, tel, p_ref, gil);
    }
    else if ( (c3n == _nest_dext(van, qq_sut, tel, p_sut, gil)) ||
              (c3n == _nest_dext(van, p_sut, tel, qq_sut, gil)) ||
              (c3n == _nest_dext(van, qq_ref, tel, p_ref, gil)) )
    {
      return c3n;
    }
    else {
      if ( (pq_sut != pq_ref) && (c3__gold != pq_ref) ) {
        return c3n;
      }
      else {
        u3_noun hud = u3nc(u3k(sut), u3k(ref));

        if ( (c3y == u3qdi_has(gil, hud)) ) {
          u3z(hud);

          return c3y;
        }
        else {
          u3_noun zoc = u3qdi_put(gil, hud);
          u3_noun tus = u3nt(c3__core,
                                     u3k(qq_sut),
                                     u3k(q_sut));
          u3_noun fer = u3nt(c3__core,
                                     u3k(qq_ref),
                                     u3k(q_ref));

          ret = _nest_cram(van, tus, tel, fer, qrq_sut, qrq_ref, zoc);
          u3z(fer);
          u3z(tus);
          u3z(zoc);
          u3z(hud);

          if ( c3n == ret ) {
            return c3n;
          }
          else {
            switch ( pq_sut ) {
              default: return u3m_bail(c3__fail);

              case c3__gold: {
                return
                  c3a(_nest_dext(van, qq_sut, tel, qq_ref, gil),
                         _nest_dext(van, qq_ref, tel, qq_sut, gil));
              }
              case c3__iron: {
                u3_noun s_sam = u3qfu_peek
                                        (van, qq_sut, c3__rite, 2);
                u3_noun r_sam = u3qfu_peek
                                        (van, qq_ref, c3__rite, 2);
                u3_noun ret = _nest_dext(van, r_sam, tel, s_sam, gil);

                u3z(r_sam);
                u3z(s_sam);
                return ret;
              }
              case c3__lead: {
                return c3y;
              }
              case c3__zinc: {
                u3_noun s_pal = u3qfu_peek
                                        (van, qq_sut, c3__read, 2);
                u3_noun r_pal = u3qfu_peek
                                        (van, qq_ref, c3__read, 2);
                u3_noun ret = _nest_dext(van, s_pal, tel, r_pal, gil);

                u3z(r_pal);
                u3z(s_pal);

                return ret;
              }
            }
          }
        }
      }
    }
  }
示例#5
0
文件: ut_nest.c 项目: alecbrick/urbit
  static u3_noun
  _nest_sint(
             u3_noun van,
             u3_noun sut,
             u3_noun tel,
             u3_noun ref,
             u3_noun gil)
  {
    u3_noun p_ref, q_ref;

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

        case c3__noun: return c3n;
        case c3__void: return c3y;
      }
    }
    else {
      switch ( u3h(ref) ) {
        default: {
          return u3m_bail(c3__fail);
        }
        case c3__atom: return c3n;
        case c3__bull: {
          if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) {
            return u3m_bail(c3__fail);
          } else {
            return _nest_dext(van, sut, tel, q_ref, gil);
          }
        }
        case c3__cell: return c3n;
        case c3__core: {
          u3_noun gam = u3qfu_repo(van, ref);
          u3_noun hiv = _nest_dext(van, sut, tel, gam, gil);

          u3z(gam);
          return hiv;
        }
        case c3__cube: {
          if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) {
            return u3m_bail(c3__fail);
          } else {
            return _nest_dext(van, sut, tel, q_ref, gil);
          }
        }
        case c3__face: {
          if ( c3n == u3r_trel(ref, 0, &p_ref, &q_ref) ) {
            return u3m_bail(c3__fail);
          } else {
            return _nest_dext(van, sut, tel, q_ref, gil);
          }
        }
        case c3__fork: {
          if ( (c3y == u3r_mean(ref, 6, &p_ref, 7, &q_ref, 0)) ) {
            return c3a(_nest_dext(van, sut, c3n, p_ref, gil),
                          _nest_dext(van, sut, c3n, q_ref, gil));
          }
          else return u3m_bail(c3__fail);
        }
        case c3__hold: {
          p_ref = u3t(ref);
          {
            u3_noun hud = u3nc(u3k(sut),
                                       u3k(ref));

            if ( (c3y == u3qdi_has(gil, hud)) ) {
              u3z(hud);

              return c3y;
            } else {
              u3_noun zoc = u3qdi_put(gil, hud);
              u3_noun gam = u3qfu_repo(van, ref);

              {
                u3_noun hiv = _nest_dext(van, sut, tel, gam, zoc);

                u3z(hud);
                u3z(gam);
                u3z(zoc);

                return hiv;
              }
            }
          }
        }
      }
    }
  }
示例#6
0
文件: ut_nest.c 项目: alecbrick/urbit
  static u3_noun
  _nest_dext_in(
                u3_noun van,
                u3_noun sut,
                u3_noun tel,
                u3_noun ref,
                u3_noun gil)
  {
    u3_noun p_sut, q_sut, p_ref, q_ref;

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

      case c3__noun: {
        return c3y;
      }
      case c3__void: {
        return _nest_sint(van, sut, tel, ref, gil);
      }
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom: {
        if ( (c3y == u3du(ref)) && (c3__atom == u3h(ref)) ) {
          if ( c3n == u3qf_fitz(u3t(sut), u3t(ref)) ) {
            // u3_err("fitz: need", u3t(sut));
            // u3_err("fitz: have", u3t(ref));
            return c3n;
          }
          return c3y;
        }
        else return _nest_sint(van, sut, tel, ref, gil);
      }
      case c3__bull: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _nest_dext(van, q_sut, tel, ref, gil);
        }
      }
      case c3__cell: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          if ( c3y == u3r_pq(ref, c3__cell, &p_ref, &q_ref) ) {
            return c3a(_nest_dext(van, p_sut, tel, p_ref, gil),
                          _nest_dext(van, q_sut, tel, q_ref, gil));
          }
          else return _nest_sint(van, sut, tel, ref, gil);
        }
      }
      case c3__core: {
        if ( c3n == u3r_trel(sut, 0, &p_sut, &q_sut) ) {
          return u3m_bail(c3__fail);
        } else {
          if ( (c3y == u3r_pq(ref, c3__core, &p_ref, &q_ref)) ) {
            return _nest_cong(van, sut, tel, ref, gil);
          }
          else return _nest_sint(van, sut, tel, ref, gil);
        }
      }
      case c3__cube: {
        if ( c3n == u3r_trel(sut, 0, &p_sut, &q_sut) ) {
          return u3m_bail(c3__fail);
        } else {
          if ( c3y == u3r_pq(ref, c3__cube, &p_ref, &q_ref) ) {
            return u3r_sing(p_sut, p_ref);
          }
          else return _nest_sint(van, sut, tel, ref, gil);
        }
      }
      case c3__face: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        } else {
          return _nest_dext(van, q_sut, tel, ref, gil);
        }
      }
      case c3__fork: {
        if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) {
          return u3m_bail(c3__fail);
        }
        else {
          if ( c3n == u3du(ref) ) switch ( ref ) {
            default: return _nest_sint(van, sut, tel, ref, gil);

            case c3__noun:
              break;
          }
          else switch ( u3h(ref) ) {
            default: return _nest_sint(van, sut, tel, ref, gil);

            case c3__atom:
            case c3__cell:
            case c3__cube:
            case c3__core:
              break;
          }

          return c3o(_nest_dext(van, p_sut, c3n, ref, gil),
                       _nest_dext(van, q_sut, c3n, ref, gil));
        }
      }
      case c3__hold: p_sut = u3t(sut);
      {
        u3_noun hud = u3nc(u3k(sut), u3k(ref));

        if ( (c3y == u3qdi_has(gil, hud)) ) {
          u3z(hud);

          return c3y;
        } else {
          u3_noun zoc = u3qdi_put(gil, hud);
          u3_noun fop = u3qfu_rest(van, sut, p_sut);
          u3_noun hiv = _nest_dext(van, fop, tel, ref, zoc);

          u3z(hud);
          u3z(fop);
          u3z(zoc);

          return hiv;
        }
      }
    }
  }
示例#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_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;
        }
      }
    }
  }
示例#9
0
文件: ut_fuse.c 项目: bd/urbit
  static u3_noun
  _fuse_in(u3_noun van,
           u3_noun sut,
           u3_noun ref,
           u3_noun bix)
  {
    u3_noun p_sut, q_sut;

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

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

      case c3__atom: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        if ( c3y == u3du(ref) ) {
          if ( c3__atom == u3h(ref) ) {
            u3_noun p_ref, q_ref;

            u3x_cell(u3t(ref), &p_ref, &q_ref);
            {
              u3_noun foc = (c3y == u3qf_fitz(p_ref, p_sut))
                              ? u3k(p_sut)
                              : u3k(p_ref);

              if ( c3y == u3du(q_sut) ) {
                if ( c3y == u3du(q_ref) ) {
                  if ( c3y == u3r_sing(q_ref, q_sut) ) {
                    return u3nt(c3__atom, foc, u3k(q_sut));
                  }
                  else { 
                    u3z(foc);
                    return c3__void;
                  }
                }
                else {
                  return u3nt(c3__atom, foc, u3k(q_sut));
                }
              } else {
                return u3nt(c3__atom, foc, u3k(q_ref));
              }
            }
          }
          else if ( c3__cell == u3h(ref) ) {
            return c3__void;
          }
        }
        return _fuse_in(van, ref, sut, bix);
      }
      case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun p_ref, q_ref;

        if ( c3y == u3r_pq(ref, c3__cell, &p_ref, &q_ref) ) {
          u3_noun hed = _fuse_in(van, p_sut, p_ref, bix);
          u3_noun tal = _fuse_in(van, q_sut, q_ref, bix);
          u3_noun ret = u3qf_cell(hed, tal);

          u3z(hed);
          u3z(tal);
          return ret;
        }
        else return _fuse_in(van, ref, sut, bix);
      }
      case c3__core:
      {
        return _fuse_repo(van, sut, ref, bix);
      }
      case c3__help: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun vot = _fuse_in(van, q_sut, ref, bix);
        u3_noun ret = u3qf_help(p_sut, vot);

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

        u3z(vot);
        return ret;
      }
      case c3__fork: p_sut = u3t(sut);
      {
        u3_noun yed = u3qdi_tap(p_sut);
        u3_noun ret = u3kf_fork(_fuse_in_fork(van, yed, ref, bix));

        u3z(yed);
        return ret;
      }
      case c3__hold:
      {
        u3_noun hud = u3nc(u3k(sut), u3k(ref));

        if ( c3y == u3qdi_has(bix, hud) ) {
          //  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));

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

          u3z(hud);
          u3z(bux);
          return ret;
        }
      }
    }
  }
示例#10
0
  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__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 now = u3qc_cap(axe);
          u3_atom lat = u3qc_mas(axe);

          if ( 3 == now ) {
            u3_noun pec = u3qfu_perk(van, sut, way, pq_sut);
            u3_noun sam = u3h(pec);
            u3_noun con = u3t(pec);

            if ( c3y == c3a(sam, con) ) {
              pro = _cqfu_peek(van, p_sut, way, lat);
            }
            else {
              u3_noun typ;

              {
                u3_noun hed, tal;

                if ( c3n == sam ) {
                  hed = c3__noun;
                } else {
                  hed = _cqfu_peek(van, p_sut, way, 2);
                }

                if ( c3n == con ) {
                  tal = c3__noun;
                } else {
                  tal = _cqfu_peek(van, p_sut, way, 3);
                }

                typ = u3qf_cell(hed, tal);
                u3z(hed);
                u3z(tal);
              }

              pro = _cqfu_peek(van, typ, way, lat);
              u3z(typ);
            }

            u3z(pec);
          }
          else {
            pro = c3__noun;
          }
          u3z(lat);
          u3z(now);

          return pro;
        }
      }
      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: p_sut = u3t(sut);
      {
        u3_noun yed = u3qdi_tap(p_sut, u3_nul);
        u3_noun ret = u3kf_fork(_peek_fork(van, yed, way, axe, gil));

        u3z(yed);
        return ret;
      }
      case c3__hold: {
        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;
        }
      }
    }
  }
示例#11
0
文件: ut_cull.c 项目: Gunga/urbit
  static u3_noun
  _cull_in(u3_noun van,
           u3_noun sut,
           u3_noun pol,
           u3_atom axe,
           u3_noun ref,
           u3_noun now,
           u3_noun lat,
           u3_noun vil)
  {
    u3_noun ret, p_sut, q_sut;

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

      case c3__noun: {
        u3_noun pyr = u3qfu_repo(van, sut);
        u3_noun yot = _cqfu_cull(van, pyr, pol, axe, ref);

        if ( c3y == u3r_sing(pyr, yot) ) {
          ret = u3k(sut);
        } else {
          ret = u3k(yot);
        }
        u3z(pyr);
        u3z(yot);
        break;
      }
      case c3__void: {
        ret = c3__void;
      }
    }
    else switch ( u3h(sut) ) {
      default: return u3m_bail(c3__fail);

      case c3__atom: {
        ret = c3__void;
        break;
      }
      case c3__bull: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun hic = _cqfu_cull(van, q_sut, pol, axe, ref);

        if ( c3y == u3r_sing(hic, q_sut) ) {
          ret = u3k(sut);
        } else {
          ret = u3qf_bull(p_sut, hic);
        }
        u3z(hic);

        break;
      }
      case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun hub;

        if ( 2 == now ) {
          hub = _cqfu_cull(van, p_sut, pol, lat, ref);
          ret = u3qf_cell(hub, q_sut);
        } else {
          hub = _cqfu_cull(van, q_sut, pol, lat, ref);
          ret = u3qf_cell(p_sut, hub);
        }
        u3z(hub);
        break;
      }
      case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        if ( 3 != now ) {
          ret = u3k(sut);
        } else {
          u3_noun hub = _cqfu_cull(van, p_sut, pol, lat, ref);

          ret = u3qf_core(hub, q_sut);

          u3z(hub);
        }
        break;
      }
      case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        u3_noun hic = _cqfu_cull(van, q_sut, pol, axe, ref);

        if ( c3y == u3r_sing(hic, q_sut) ) {
          ret = u3k(sut);
        } else {
          ret = u3qf_face(p_sut, hic);
        }
        u3z(hic);

        break;
      }
      case c3__fork: u3x_cell(u3t(sut), &p_sut, &q_sut);
      {
        if ( c3y == u3qdi_has(vil, sut) ) {
          return c3__void;
        } else {
          u3_noun zoc = u3qdi_put(vil, sut);
          u3_noun sin = _cull_in(van, p_sut, pol, axe, ref, now, lat, zoc);
          u3_noun dex = _cull_in(van, q_sut, pol, axe, ref, now, lat, zoc);

          ret = u3qf_fork(sin, dex);
          u3z(sin);
          u3z(dex);
          u3z(zoc);

          return ret;
        }
      }
      case c3__cube:
      case c3__hold:
      {
        u3_noun pyr = u3qfu_repo(van, sut);
        u3_noun yot = _cull_in(van, pyr, pol, axe, ref, now, lat, vil);

        if ( c3y == u3r_sing(pyr, yot) ) {
          if ( c3__void == pyr ) {
            ret = c3__void;
          }
          else ret = u3k(sut);
        } else {
          ret = u3k(yot);
        }
        u3z(pyr);
        u3z(yot);
        break;
      }
    }
    u3z(lat);
    return ret;
  }
示例#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;
        }
      }
    }
  }