Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix jet mismatches and crashes #703

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pkg/noun/jets/a/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "noun.h"

u3_noun
u3_atom
u3qa_add(u3_atom a,
u3_atom b)
{
Expand All @@ -31,16 +31,14 @@ u3qa_add(u3_atom a,
}
}

u3_noun
u3_weak
u3wa_add(u3_noun cor)
{
u3_noun a, b;

if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0)) ||
(c3n == u3ud(a)) ||
(c3n == u3ud(b) && a != 0) )
{
return u3m_bail(c3__exit);
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
if ( !_(u3ud(a)) || !_(u3ud(b)) ) {
return u3_none;
}
else {
return u3qa_add(a, b);
Expand Down
18 changes: 7 additions & 11 deletions pkg/noun/jets/a/gte.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "noun.h"

u3_noun
u3_atom
u3qa_gte(u3_atom a, u3_atom b)
{
if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) {
Expand All @@ -26,7 +26,7 @@ u3qa_gte(u3_atom a, u3_atom b)
}
else {
mpz_t a_mp, b_mp;
u3_noun cmp;
u3_atom cmp;

u3r_mp(a_mp, a);
u3r_mp(b_mp, b);
Expand All @@ -41,18 +41,14 @@ u3qa_gte(u3_atom a, u3_atom b)
}
}

u3_noun
u3_weak
u3wa_gte(u3_noun cor)
{
u3_noun a, b;

if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0))
|| (c3n == u3ud(b) && 0 != a)
|| (c3n == u3ud(a) && 0 != b) )
{
return u3m_bail(c3__exit);
}
else {
return u3qa_gte(a, b);
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
if ( !_(u3ud(a)) || !_(u3ud(b)) ) {
return u3_none;
}
return u3qa_gte(a, b);
}
24 changes: 10 additions & 14 deletions pkg/noun/jets/a/gth.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "noun.h"

u3_noun
u3_atom
u3qa_gth(u3_atom a, u3_atom b)
{
if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) {
Expand All @@ -27,7 +27,7 @@ u3qa_gth(u3_atom a, u3_atom b)
}
else {
mpz_t a_mp, b_mp;
u3_noun cmp;
u3_atom cmp;

u3r_mp(a_mp, a);
u3r_mp(b_mp, b);
Expand All @@ -42,26 +42,22 @@ u3qa_gth(u3_atom a, u3_atom b)
}
}

u3_noun
u3_weak
u3wa_gth(u3_noun cor)
{
u3_noun a, b;

if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0))
|| (c3n == u3ud(b) && 0 != a)
|| (c3n == u3ud(a) && 0 != b) )
{
return u3m_bail(c3__exit);
}
else {
return u3qa_gth(a, b);
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
if ( !_(u3ud(a)) || !_(u3ud(b)) ) {
return u3_none;
}
return u3qa_gth(a, b);
}

u3_noun
u3ka_gth(u3_noun a, u3_noun b)
u3_atom
u3ka_gth(u3_atom a, u3_atom b)
{
u3_noun c = u3qa_gth(a, b);
u3_atom c = u3qa_gth(a, b);
u3z(a); u3z(b);
return c;
}
24 changes: 10 additions & 14 deletions pkg/noun/jets/a/lte.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "noun.h"

u3_noun
u3_atom
u3qa_lte(u3_atom a, u3_atom b)
{
if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) {
Expand All @@ -27,7 +27,7 @@ u3qa_lte(u3_atom a, u3_atom b)
}
else {
mpz_t a_mp, b_mp;
u3_noun cmp;
u3_atom cmp;

u3r_mp(a_mp, a);
u3r_mp(b_mp, b);
Expand All @@ -42,26 +42,22 @@ u3qa_lte(u3_atom a, u3_atom b)
}
}

u3_noun
u3_weak
u3wa_lte(u3_noun cor)
{
u3_noun a, b;

if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0))
|| (c3n == u3ud(b) && 0 != a)
|| (c3n == u3ud(a) && 0 != b) )
{
return u3m_bail(c3__exit);
}
else {
return u3qa_lte(a, b);
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
if ( !_(u3ud(a)) || !_(u3ud(b)) ) {
return u3_none;
}
return u3qa_lte(a, b);
}

u3_noun
u3ka_lte(u3_noun a, u3_noun b)
u3_atom
u3ka_lte(u3_atom a, u3_atom b)
{
u3_noun c = u3qa_lte(a, b);
u3_atom c = u3qa_lte(a, b);
u3z(a); u3z(b);
return c;
}
18 changes: 7 additions & 11 deletions pkg/noun/jets/a/lth.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "noun.h"

u3_noun
u3_atom
u3qa_lth(u3_atom a, u3_atom b)
{
if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) {
Expand All @@ -26,7 +26,7 @@ u3qa_lth(u3_atom a, u3_atom b)
}
else {
mpz_t a_mp, b_mp;
u3_noun cmp;
u3_atom cmp;

u3r_mp(a_mp, a);
u3r_mp(b_mp, b);
Expand All @@ -41,18 +41,14 @@ u3qa_lth(u3_atom a, u3_atom b)
}
}

u3_noun
u3_weak
u3wa_lth(u3_noun cor)
{
u3_noun a, b;

if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0))
|| (c3n == u3ud(b) && 0 != a)
|| (c3n == u3ud(a) && 0 != b) )
{
return u3m_bail(c3__exit);
}
else {
return u3qa_lth(a, b);
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
if ( !_(u3ud(a)) || !_(u3ud(b)) ) {
return u3_none;
}
return u3qa_lth(a, b);
}
28 changes: 13 additions & 15 deletions pkg/noun/jets/a/max.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@

#include "noun.h"

u3_noun
u3_atom
u3qa_max(u3_atom a, u3_atom b)
{
if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) {
return u3k(c3_max(a, b));
return c3_max(a, b);
}
else {
if ( a == 0 ) return u3k(b);
if ( b == 0 ) return u3k(a);
c3_w a_w = u3r_met(0, a);
c3_w b_w = u3r_met(0, b);

Expand All @@ -21,7 +23,7 @@ u3qa_max(u3_atom a, u3_atom b)
}
else {
mpz_t a_mp, b_mp;
u3_noun max;
u3_atom max;

u3r_mp(a_mp, a);
u3r_mp(b_mp, b);
Expand All @@ -36,26 +38,22 @@ u3qa_max(u3_atom a, u3_atom b)
}
}

u3_noun
u3_weak
u3wa_max(u3_noun cor)
{
u3_noun a, b;

if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0))
|| (c3n == u3ud(b) && 0 != a)
|| (c3n == u3ud(a) && 0 != b) )
{
return u3m_bail(c3__exit);
}
else {
return u3qa_max(a, b);
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
if ( !_(u3ud(a)) || !_(u3ud(b)) ) {
return u3_none;
}
return u3qa_max(a, b);
}

u3_noun
u3ka_max(u3_noun a, u3_noun b)
u3_atom
u3ka_max(u3_atom a, u3_atom b)
{
u3_noun c = u3qa_max(a, b);
u3_atom c = u3qa_max(a, b);
u3z(a); u3z(b);
return c;
}
29 changes: 14 additions & 15 deletions pkg/noun/jets/a/min.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

#include "noun.h"

u3_noun
u3_atom
u3qa_min(u3_atom a, u3_atom b)
{
if ( _(u3a_is_cat(a)) && _(u3a_is_cat(b)) ) {
return u3k(c3_min(a, b));
return c3_min(a, b);
}
else {
if ( (a == 0) || (b == 0) ) {
return 0;
}
c3_w a_w = u3r_met(0, a);
c3_w b_w = u3r_met(0, b);

Expand All @@ -21,7 +24,7 @@ u3qa_min(u3_atom a, u3_atom b)
}
else {
mpz_t a_mp, b_mp;
u3_noun min;
u3_atom min;

u3r_mp(a_mp, a);
u3r_mp(b_mp, b);
Expand All @@ -36,26 +39,22 @@ u3qa_min(u3_atom a, u3_atom b)
}
}

u3_noun
u3_weak
u3wa_min(u3_noun cor)
{
u3_noun a, b;

if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0))
|| (c3n == u3ud(b) && 0 != a)
|| (c3n == u3ud(a) && 0 != b) )
{
return u3m_bail(c3__exit);
}
else {
return u3qa_min(a, b);
u3x_mean(cor, u3x_sam_2, &a, u3x_sam_3, &b, 0);
if ( !_(u3ud(a)) || !_(u3ud(b)) ) {
return u3_none;
}
return u3qa_min(a, b);
}

u3_noun
u3ka_min(u3_noun a, u3_noun b)
u3_atom
u3ka_min(u3_atom a, u3_atom b)
{
u3_noun c = u3qa_min(a, b);
u3_atom c = u3qa_min(a, b);
u3z(a); u3z(b);
return c;
}
5 changes: 4 additions & 1 deletion pkg/noun/jets/b/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
if ( c3y == hoz ) {
nex = u3nc(u3nc(u3k(u3h(a)), u3k(u3h(acc))), u3k(u3t(acc)));
}
else {
else if ( c3n == hoz ) {
nex = u3nc(u3k(u3h(acc)), u3nc(u3k(u3h(a)), u3k(u3t(acc))));
}
else {
return u3m_bail(c3__exit);
}
u3z(hoz);
u3z(acc);

Expand Down
10 changes: 7 additions & 3 deletions pkg/noun/jets/c/swp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ u3_noun
u3qc_swp(u3_atom a,
u3_atom b)
{
c3_w len_w = u3r_met(a, b);
if ( !_(u3a_is_cat(a)) || (a >= 32) ) {
return u3m_bail(c3__fail);
}
c3_g a_g = a;
c3_w len_w = u3r_met(a_g, b);
u3i_slab sab_u;
u3i_slab_init(&sab_u, a, len_w);
u3i_slab_init(&sab_u, a_g, len_w);

for (c3_w i = 0; i < len_w; i++) {
u3r_chop(a, i, 1, len_w - i - 1, sab_u.buf_w, b);
u3r_chop(a_g, i, 1, len_w - i - 1, sab_u.buf_w, b);
}

return u3i_slab_mint(&sab_u);
Expand Down
2 changes: 1 addition & 1 deletion pkg/noun/jets/e/cue.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ u3qe_cue(u3_atom a)
u3_noun
u3we_cue(u3_noun cor)
{
return u3qe_cue(u3x_at(u3x_sam, cor));
return u3qe_cue(u3x_atom(u3x_at(u3x_sam, cor)));
}

u3_noun
Expand Down
Loading