jets: Start jetting +ob.

Since the most used parser in +slaw is the @p one, that's up next.
But first, we need to jet parts of +ob, which gets called through
+fed:ag.
This commit is contained in:
Elliot Glaysher 2020-04-27 16:25:30 -07:00
parent 55e9bd7056
commit 716cd2013f
5 changed files with 82 additions and 0 deletions

View File

@ -3810,6 +3810,7 @@
-- --
:: ::
++ ob ++ ob
~% %ob + ~
|% |%
:: +fein: conceal structure, v3. :: +fein: conceal structure, v3.
:: ::
@ -3817,6 +3818,7 @@
:: trivial to tell which planet a star has spawned under. :: trivial to tell which planet a star has spawned under.
:: ::
++ fein ++ fein
~/ %fein
|= pyn/@ ^- @ |= pyn/@ ^- @
?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff)) ?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff))
(add 0x1.0000 (feis (sub pyn 0x1.0000))) (add 0x1.0000 (feis (sub pyn 0x1.0000)))
@ -3832,6 +3834,7 @@
:: Restores obfuscated values that have been enciphered with +fein. :: Restores obfuscated values that have been enciphered with +fein.
:: ::
++ fynd ++ fynd
~/ %fynd
|= cry/@ ^- @ |= cry/@ ^- @
?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff)) ?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff))
(add 0x1.0000 (tail (sub cry 0x1.0000))) (add 0x1.0000 (tail (sub cry 0x1.0000)))
@ -3848,6 +3851,7 @@
:: See: Black & Rogaway (2002), Ciphers for arbitrary finite domains. :: See: Black & Rogaway (2002), Ciphers for arbitrary finite domains.
:: ::
++ feis ++ feis
~/ %feis
|= m=@ |= m=@
^- @ ^- @
(fee 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m) (fee 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m)
@ -3855,6 +3859,7 @@
:: +tail: reverse +feis. :: +tail: reverse +feis.
:: ::
++ tail ++ tail
~/ %tail
|= m=@ |= m=@
^- @ ^- @
(feen 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m) (feen 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m)
@ -3871,6 +3876,7 @@
:: m: an input value in the domain [0, k - 1] :: m: an input value in the domain [0, k - 1]
:: ::
++ fee ++ fee
~/ %fee
|= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@] |= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@]
^- @ ^- @
=/ c (fe r a b prf m) =/ c (fe r a b prf m)
@ -3884,6 +3890,7 @@
:: +fee. :: +fee.
:: ::
++ feen ++ feen
~/ %feen
|= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@] |= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@]
^- @ ^- @
=/ c (fen r a b prf m) =/ c (fen r a b prf m)
@ -3899,6 +3906,7 @@
:: to support some legacy behaviour. See urbit/arvo#1105. :: to support some legacy behaviour. See urbit/arvo#1105.
:: ::
++ fe ++ fe
~/ %fe
|= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@] |= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@]
=/ j 1 =/ j 1
=/ ell (mod m a) =/ ell (mod m a)
@ -3937,6 +3945,7 @@
:: to support some legacy behaviour. See urbit/arvo#1105. :: to support some legacy behaviour. See urbit/arvo#1105.
:: ::
++ fen ++ fen
~/ %fen
|= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@] |= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@]
=/ j r =/ j r
:: ::
@ -3985,6 +3994,7 @@
:: +eff: a murmur3-based pseudorandom function. 'F' in B&R (2002). :: +eff: a murmur3-based pseudorandom function. 'F' in B&R (2002).
:: ::
++ eff ++ eff
~/ %eff
|= [j=@ r=@] |= [j=@ r=@]
^- @ ^- @
(muk (snag j raku) 2 r) (muk (snag j raku) 2 r)

View File

@ -76,6 +76,8 @@
u3_noun u3wcp_tos(u3_noun); u3_noun u3wcp_tos(u3_noun);
u3_noun u3wcp_tod(u3_noun); u3_noun u3wcp_tod(u3_noun);
u3_noun u3wc_ob_eff(u3_noun);
/** Tier 4. /** Tier 4.
**/ **/
u3_noun u3wdb_bif(u3_noun); u3_noun u3wdb_bif(u3_noun);

48
pkg/urbit/jets/c/ob.c Normal file
View File

@ -0,0 +1,48 @@
/* j/3/ob.c
**
*/
#include "all.h"
u3_noun
u3qc_ob_eff(u3_atom j, u3_atom r)
{
c3_d found = 0;
switch (j) {
case 0:
found = 0xb76d5eed;
break;
case 1:
found = 0xee281300;
break;
case 2:
found = 0x85bcae01;
break;
case 3:
found = 0x4b387af7;
break;
default:
// the internal snag would have failed.
return u3m_bail(c3__exit);
}
return u3qc_muk(u3i_chubs(1, &found), 2, r);
}
u3_noun
u3wc_ob_eff(u3_noun cor)
{
u3_noun j, r;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &j,
u3x_sam_3, &r, 0)) ||
(c3n == u3ud(j)) ||
(c3n == u3ud(r)) )
{
fprintf(stderr, "u3wc_ob_eff failed to unpack\r\n");
return u3m_bail(c3__exit);
}
else {
return u3qc_ob_eff(j, r);
}
}

View File

@ -49,6 +49,18 @@
return u3nc(0, total); return u3nc(0, total);
} }
// parsing @p:
//
// +slaw calls +fed:ag directly. +fed:ag:
//
// - parses the text first into a number.
// - runs fynd:ob, which is the scrambler restore structure. And +fynd is
// unjetted.
//
// The actual +po stuff, like +ins:po, is jetted but it's jetted such that it
// pulls the tables out of the sample, so we can't just reuse it from other
// jets.
u3_noun u3_noun
_parse_tas(u3_noun txt) { _parse_tas(u3_noun txt) {
// For any symbol which matches, txt will return itself as a // For any symbol which matches, txt will return itself as a

View File

@ -923,6 +923,14 @@ static c3_c* _141_tri__cofl_ha[] = {
0 0
}; };
static u3j_harm _141_tri__ob_eff_a[] = {{".2", u3wc_ob_eff}, {}};
static u3j_core _141_tri__ob_d[] =
{ { "eff", 7, _141_tri__ob_eff_a, 0, 0 },
{}
};
static u3j_harm _141_tri__rd_add_a[] = {{".2", u3wer_add}, {}}; static u3j_harm _141_tri__rd_add_a[] = {{".2", u3wer_add}, {}};
static c3_c* _141_tri__rd_add_ha[] = { static c3_c* _141_tri__rd_add_ha[] = {
"90dfaaadb2878d6d89a808ce4199e5bb239fa981e1c2edf24dc54aa3fcab55a5", "90dfaaadb2878d6d89a808ce4199e5bb239fa981e1c2edf24dc54aa3fcab55a5",
@ -1270,6 +1278,7 @@ static c3_c* _141_tri_shal_ha[] = {
static u3j_core _141_tri_d[] = static u3j_core _141_tri_d[] =
{ { "qua", 3, 0, _141_qua_d, _141_qua_ha, _141_qua_ho }, { { "qua", 3, 0, _141_qua_d, _141_qua_ha, _141_qua_ho },
{ "ob", 3, 0, _141_tri__ob_d, 0 },
{ "cofl", 7, 0, _141_tri__cofl_d, _141_tri__cofl_ha }, { "cofl", 7, 0, _141_tri__cofl_d, _141_tri__cofl_ha },
{ "rd", 7, 0, _141_tri__rd_d, _141_tri__rd_ha }, { "rd", 7, 0, _141_tri__rd_d, _141_tri__rd_ha },
{ "rs", 7, 0, _141_tri__rs_d, _141_tri__rs_ha }, { "rs", 7, 0, _141_tri__rs_d, _141_tri__rs_ha },
@ -1282,6 +1291,7 @@ static u3j_core _141_tri_d[] =
{ "shay", 7, _141_tri_shay_a, 0, _141_tri_shay_ha }, { "shay", 7, _141_tri_shay_a, 0, _141_tri_shay_ha },
{ "shas", 7, _141_tri_shas_a, 0, _141_tri_shas_ha }, { "shas", 7, _141_tri_shas_a, 0, _141_tri_shas_ha },
{ "shal", 7, _141_tri_shal_a, 0, _141_tri_shal_ha }, { "shal", 7, _141_tri_shal_a, 0, _141_tri_shal_ha },
{} {}
}; };
static c3_c* _141_tri_ha[] = { static c3_c* _141_tri_ha[] = {