コード例 #1
0
u2_noun
u2_cm_bail(c3_l how_l)
{
  u2_ray kit_r = u2_wire_kit_r(u2_Wire);

  if ( u2_yes == u2_Flag_Abort ) {
    if ( c3__fail == how_l ) { c3_assert(0); }
    c3_assert(0);
  }
  u2_tx_sys_bit(u2_Wire, u2_yes);

  // fprintf(stderr, "bail\n");
  // if ( _num == 0 ) { c3_assert(0); } else _num--;

  {
    u2_noun jaq;
    jmp_buf buf_f;

    // Reset the old stack trace, pulling off the local top.
    //
    jaq = u2_cm_wail();

    // Reset the old action trace.
    {
      u2z(u2_wrac_at(u2_Wire, duz.don));
      u2_wrac_at(u2_Wire, duz.don) = u2_kite_don(kit_r);
    }

    // Copy out the jump buffer; free the old kite.
    {
      memcpy((void *)buf_f,
             u2_at_cord(u2_kite_buf_r(kit_r), c3_wiseof(jmp_buf)),
             sizeof(jmp_buf));

      u2_wire_kit_r(u2_Wire) = u2_kite_par_r(kit_r);
      u2_rl_rfree(u2_Wire, kit_r);
    }

    // Longjmp with the how-trace pair.  XX: no workee with 64-bit nouns.
    //
    {
      _longjmp(buf_f, u2nc(how_l, jaq));
    }
  }
  return 0;
}
コード例 #2
0
ファイル: nock.c プロジェクト: ngvrnd/urbit
/* nock_molg(): function call (mung) with kode.  Arguments transferred.
*/
static u2_noun
_nock_molg(u2_noun  gat,
           u2_noun  sam,
           u2_kode* pon)
{
  if ( (u2_no == u2du(gat)) || (u2_no == u2du(u2t(gat))) ) {
    *pon = 2; return u2_cm_wail();
  }
  else {
    u2_noun cor, fol;

    cor = u2nc(u2k(u2h(gat)), u2nc(sam, u2k(u2t(u2t(gat)))));
    fol = u2k(u2h(gat));
    u2z(gat);

    //  XX  try to chip with u2_ds_find?  but a rare case...
    return _nock_mool(cor, fol, pon);
  }
}
コード例 #3
0
/* u2_cm_bowl(): bail out with preset report.
*/
u2_noun
u2_cm_bowl(u2_noun how)
{
  u2_ray kit_r = u2_wire_kit_r(u2_Wire);

  u2_tx_sys_bit(u2_Wire, u2_yes);

  {
    u2_noun jaq;
    jmp_buf buf_f;

    // Reset the old stack trace, pulling off the local top.
    //
    jaq = u2_cm_wail();

    // Reset the old action trace.
    {
      u2z(u2_wrac_at(u2_Wire, duz.don));
      u2_wrac_at(u2_Wire, duz.don) = u2_kite_don(kit_r);
    }

    // Copy out the jump buffer; free the old kite.
    {
      memcpy((void *)buf_f,
             u2_at_cord(u2_kite_buf_r(kit_r), c3_wiseof(jmp_buf)),
             sizeof(jmp_buf));

      u2_wire_kit_r(u2_Wire) = u2_kite_par_r(kit_r);
      u2_rl_rfree(u2_Wire, kit_r);
    }

    // Longjmp with the how-trace pair.  XX: no workee with 64-bit nouns.
    //
    {
      u2z(jaq);
      _longjmp(buf_f, how);
    }
  }
  return 0;
}
コード例 #4
0
ファイル: nock.c プロジェクト: sillsm/urbit
/* nock_mool(): fast internal mink interface.  Arguments transferred.
*/
u2_noun
_nock_mool(u2_noun  bus,
           u2_noun  fol,
           u2_kode* pon)
{
    u2_noun hib, gal;

    c3_assert(u2_yes == *pon);

    while ( 1 ) {
        u2_tx_did_hop(u2_Wire, 1);

        if ( u2_no == u2du(fol) ) {
            *pon = 2;
            u2z(bus);
            u2z(fol);
            return u2_cm_wail();
        }
        else {
            hib = u2fh(fol);
            gal = u2ft(fol);
        }

        if ( u2_yes == u2du(hib) ) {
            u2_noun poz, riv;
            u2_kode h_pon = 0, t_pon = 0;

            poz = _nock_mool(u2k(bus), u2k(hib), &h_pon);
            if ( 2 == h_pon ) {
                *pon = 2;
                u2z(bus);
                u2z(fol);
                return poz;
            }

            riv = _nock_mool(bus, u2k(gal), &t_pon);
            u2z(fol);
            if ( 2 == t_pon ) {
                *pon = 2;
                u2z(poz);
                return riv;
            }

            if ( (1 == h_pon) || (1 == t_pon) ) {
                u2_noun lal;

                *pon = 1;

                if ( 0 == h_pon ) {
                    u2z(poz);
                    lal = riv;
                } else if ( 0 == t_pon ) {
                    u2z(riv);
                    lal = poz;
                } else {
                    lal = u2_ckb_weld(poz, riv);
                }
                return lal;
            }
            return u2_cn_cell(poz, riv);
        }
        else switch ( hib ) {
            default:
                *pon = 2;
                u2z(bus);
                u2z(fol);
                return u2_cm_wail();

            case 0: {
                if ( u2_no == u2_cr_ud(gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_weak pro = u2_cr_at(gal, bus);

                    if ( u2_none == pro ) {
                        *pon = 2;
                        u2z(bus);
                        u2z(fol);
                        return u2_cm_wail();
                    }
                    else {
                        pro = u2k(pro);
                        u2z(bus);
                        u2z(fol);

                        return pro;
                    }
                }
            }
            case 1: {
                u2_noun pro = u2k(gal);

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

            case 2: {
                if ( (u2_no == u2du(gal)) || (u2_no == u2du(u2fh(gal))) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun neb;

                    neb = _nock_mool(bus, u2k(gal), pon);
                    u2z(fol);
                    if ( 0 != *pon ) {
                        return neb;
                    }

                    bus = u2k(u2fh(neb));
                    fol = u2k(u2ft(neb));
                    u2z(neb);
                    continue;
                }
            }
            c3_assert(!"not reached");

            case 3: {
                u2_noun gof, pro;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                pro = u2du(gof);
                u2z(gof);

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

            case 4: {
                u2_noun gof, pro;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                if ( u2_none == (pro = u2_rl_vint(u2_Wire, gof)) ) {
                    *pon = 2;
                    u2z(gof);
                    return u2_cm_wail();
                }
                u2z(gof);

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

            case 5: {
                u2_noun gof, pro;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                if ( u2_no == u2du(gof) ) {
                    *pon = 2;
                    u2z(gof);
                    return u2_cm_wail();
                }
                pro = u2_cr_sing(u2h(gof), u2t(gof));
                u2z(gof);

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

            case 6: {
                u2_noun b_gal, cd_gal, c_gal, d_gal;

                if ( u2_no == u2_cr_cell(gal, &b_gal, &cd_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun tys, nex;

                    tys = _nock_mool(u2k(bus), u2k(b_gal), pon);
                    if ( 0 != *pon ) {
                        u2z(bus);
                        u2z(fol);
                        return tys;
                    }

                    if ( u2_no == u2_cr_cell(cd_gal, &c_gal, &d_gal) ) {
                        *pon = 2;
                        u2z(bus);
                        u2z(fol);
                        return u2_cm_wail();
                    }

                    if ( 0 == tys ) {
                        nex = u2k(c_gal);
                    } else if ( 1 == tys ) {
                        nex = u2k(d_gal);
                    } else {
                        *pon = 2;
                        u2z(bus);
                        u2z(fol);
                        return u2_cm_wail();
                    }

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

            case 7: {
                u2_noun b_gal, c_gal;

                if ( u2_no == u2_cr_cell(gal, &b_gal, &c_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun bod, nex;

                    bod = _nock_mool(bus, u2k(b_gal), pon);
                    if ( 0 != *pon ) {
                        u2z(fol);
                        return bod;
                    }

                    nex = u2k(c_gal);
                    u2z(fol);

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

            case 8: {
                u2_noun b_gal, c_gal;

                // c3_assert(!"got 8 (mink)!");
                if ( u2_no == u2_cr_cell(gal, &b_gal, &c_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun wib, bod, nex;

                    wib = _nock_mool(u2k(bus), u2k(b_gal), pon);
                    if ( 0 != *pon ) {
                        u2z(bus);
                        u2z(fol);
                        return wib;
                    }

                    bod = u2nc(wib, bus);
                    nex = u2k(c_gal);
                    u2z(fol);

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

            case 9: {
                u2_noun b_gal, c_gal;

                if ( (u2_no == u2_cr_cell(gal, &b_gal, &c_gal)) ||
                        (u2_no == u2ud(b_gal)) )
                {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun seb;
                    u2_weak xip;

                    seb = _nock_mool(bus, u2k(c_gal), pon);
                    u2z(fol);
                    if ( 0 != *pon ) {
                        return seb;
                    }

                    u2_tx_sys_bit(u2_Wire, u2_yes);
                    xip = u2_ds_find(u2_Wire, seb);
                    u2_tx_sys_bit(u2_Wire, u2_no);

                    if ( u2_none != xip ) {
                        u2_noun pro;

                        u2_tx_sys_bit(u2_Wire, u2_yes);
                        pro = u2_ho_kicq(u2_Wire, xip, seb, b_gal, pon);
                        u2_tx_sys_bit(u2_Wire, u2_no);
                        u2z(seb);

                        if ( u2_none == pro ) {
                            *pon = 2;
                            return u2_cm_wail();
                        }
                        else return pro;
                    }
                    else {
                        u2_noun nex = u2_cr_at(b_gal, seb);

                        if ( u2_none == nex ) {
                            *pon = 2;
                            u2z(seb);
                            return u2_cm_wail();
                        }
                        bus = seb;
                        fol = u2k(nex);
                        continue;
                    }
                }
            }
            c3_assert(!"not reached");

            case 10: {
                u2_noun p_gal, q_gal;

                if ( u2_no == u2_cr_cell(gal, &p_gal, &q_gal) ) {
                    *pon = 2;
                    u2z(bus);
                    u2z(fol);
                    return u2_cm_wail();
                }
                else {
                    u2_noun zep, hod, nex;

                    if ( u2_yes == u2du(p_gal) ) {
                        u2_noun b_gal = u2fh(p_gal);
                        u2_noun c_gal = u2ft(p_gal);
                        u2_noun d_gal = q_gal;

                        hod = _nock_mool(u2k(bus), u2_ct(c_gal), pon);
                        if ( 0 != *pon ) {
                            u2z(fol);
                            return hod;
                        }

                        zep = u2k(b_gal);
                        nex = u2k(d_gal);
                        u2z(fol);
                    }
                    else {
                        u2_noun b_gal = p_gal;
                        u2_noun c_gal = q_gal;

                        zep = u2k(b_gal);
                        hod = u2_nul;
                        nex = u2k(c_gal);

                        u2z(fol);
                    }

                    return _nock_hint(zep, hod, bus, nex, pon);
                }
            }

            case 11: {
                u2_noun gof;

                gof = _nock_mool(bus, u2k(gal), pon);
                u2z(fol);
                if ( 0 != *pon ) {
                    return gof;
                }

                return _nock_pray_mool(gof, pon);
            }
            c3_assert(!"not reached");
            }
    }
}