From 88a8b9460d7f25279a84975dbeae75a93a1af441 Mon Sep 17 00:00:00 2001 From: pcmonk Date: Wed, 11 Jun 2014 11:18:43 -0700 Subject: [PATCH] Added map merge (mer:by) --- Makefile | 1 + gen164/4/by.c | 2 + gen164/4/by_mer.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++ gen164/4/in.c | 1 + gen164/4/in_mer.c | 2 +- 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 gen164/4/by_mer.c diff --git a/Makefile b/Makefile index e215537c0..667ff9baf 100644 --- a/Makefile +++ b/Makefile @@ -160,6 +160,7 @@ J164_4_OFILES=\ gen164/4/by_gas.o \ gen164/4/by_get.o \ gen164/4/by_has.o \ + gen164/4/by_mer.o \ gen164/4/by_put.o \ gen164/4/by_uni.o diff --git a/gen164/4/by.c b/gen164/4/by.c index 5ac8ab96a..09226a2d0 100644 --- a/gen164/4/by.c +++ b/gen164/4/by.c @@ -10,6 +10,7 @@ extern u2_ho_jet j2_mcj(Pt4, by, gas)[]; extern u2_ho_jet j2_mcj(Pt4, by, get)[]; extern u2_ho_jet j2_mcj(Pt4, by, has)[]; + extern u2_ho_jet j2_mcj(Pt4, by, mer)[]; extern u2_ho_jet j2_mcj(Pt4, by, put)[]; extern u2_ho_jet j2_mcj(Pt4, by, uni)[]; @@ -20,6 +21,7 @@ { j2_sc(Pt4, by, gas), j2_mcj(Pt4, by, gas), 0, 0, u2_none }, { j2_sc(Pt4, by, get), j2_mcj(Pt4, by, get), 0, 0, u2_none }, { j2_sc(Pt4, by, has), j2_mcj(Pt4, by, has), 0, 0, u2_none }, + { j2_sc(Pt4, by, mer), j2_mcj(Pt4, by, mer), 0, 0, u2_none }, { j2_sc(Pt4, by, put), j2_mcj(Pt4, by, put), 0, 0, u2_none }, { j2_sc(Pt4, by, uni), j2_mcj(Pt4, by, uni), 0, 0, u2_none }, {} diff --git a/gen164/4/by_mer.c b/gen164/4/by_mer.c new file mode 100644 index 000000000..f07904336 --- /dev/null +++ b/gen164/4/by_mer.c @@ -0,0 +1,106 @@ +/* j/4/by_mer.c +** +** This file is in the public domain. +*/ +#include "all.h" +#include "../pit.h" + +/* functions +*/ + u2_weak // transfer + j2_mcc(Pt4, by, mer)(u2_wire wir_r, + u2_noun a, // retain + u2_noun b) // retain + { + if ( u2_nul == a ) { + return u2_rx(wir_r, b); + } + else if ( u2_nul == b ) { + return u2_rx(wir_r, a); + } + else { + u2_noun l_a, n_a, r_a, lr_a, p_n_a, q_n_a; + u2_noun l_b, n_b, r_b, lr_b, p_n_b, q_n_b; + u2_noun c; + + if ( (u2_no == u2_as_cell(a, &n_a, &lr_a)) ) { + return u2_bl_bail(wir_r, c3__exit); + } + else if ( (u2_no == u2_as_cell(b, &n_b, &lr_b)) ) { + return u2_bl_bail(wir_r, c3__exit); + } + else if ( (u2_no == u2_as_cell(n_a, &p_n_a, &q_n_a)) ) { + return u2_bl_bail(wir_r, c3__exit); + } + else if ( (u2_no == u2_as_cell(n_b, &p_n_b, &q_n_b)) ) { + return u2_bl_bail(wir_r, c3__exit); + } + else { + if ( u2_yes == j2_mbc(Pt3, vor)(wir_r, p_n_b, p_n_a) ) { + c = a; a = b; b = c; + c = n_a; n_a = n_b; n_b = c; + c = lr_a; lr_a = lr_b; lr_b = c; + c = p_n_a; p_n_a = p_n_b; p_n_b = c; + c = q_n_a; q_n_a = q_n_b; q_n_b = c; + } + if ( u2_no == u2_as_cell(lr_a, &l_a, &r_a) ) { + return u2_bl_bail(wir_r, c3__exit); + } + else if ( u2_no == u2_as_cell(lr_b, &l_b, &r_b) ) { + return u2_bl_bail(wir_r, c3__exit); + } + else if ( u2_yes == u2_sing(p_n_a, p_n_b) ) { + return u2_rt(wir_r, u2_rx(wir_r, n_b), + j2_mcc(Pt4, by, mer)(wir_r, l_a, l_b), + j2_mcc(Pt4, by, mer)(wir_r, r_a, r_b)); + } + else if ( u2_yes == j2_mbc(Pt3, hor)(wir_r, p_n_b, p_n_a) ) { + return j2_mcc(Pt4, by, mer)(wir_r, + u2_rt(wir_r, + n_a, + j2_mcc(Pt4, by, mer)(wir_r, + l_a, + u2_rt(wir_r, + n_b, + l_b, + u2_nul)), + r_a), + r_b); + } + else { + return j2_mcc(Pt4, by, mer)(wir_r, + u2_rt(wir_r, + n_a, + l_a, + j2_mcc(Pt4, by, mer)(wir_r, + r_a, + u2_rt(wir_r, + n_b, + u2_nul, + r_b))), + l_b); + } + } + } + } + u2_weak // transfer + j2_mc(Pt4, by, mer)(u2_wire wir_r, + u2_noun cor) // retain + { + u2_noun a, b; + + if ( u2_no == u2_mean(cor, u2_cv_sam, &b, u2_cv_con_sam, &a, 0) ) { + return u2_bl_bail(wir_r, c3__exit); + } else { + return j2_mcc(Pt4, by, mer)(wir_r, a, b); + } + } + +/* structures +*/ + u2_ho_jet + j2_mcj(Pt4, by, mer)[] = { + { ".2", c3__lite, j2_mc(Pt4, by, mer), Tier4, u2_none, u2_none }, + { } + }; + diff --git a/gen164/4/in.c b/gen164/4/in.c index 00c067f67..9562f1a76 100644 --- a/gen164/4/in.c +++ b/gen164/4/in.c @@ -19,6 +19,7 @@ j2_mbd(Pt4, in)[] = { { j2_sc(Pt4, in, gas), j2_mcj(Pt4, in, gas), 0, 0, u2_none }, { j2_sc(Pt4, in, has), j2_mcj(Pt4, in, has), 0, 0, u2_none }, + { j2_sc(Pt4, in, mer), j2_mcj(Pt4, in, mer), 0, 0, u2_none }, { j2_sc(Pt4, in, put), j2_mcj(Pt4, in, put), 0, 0, u2_none }, { j2_sc(Pt4, in, tap), j2_mcj(Pt4, in, tap), 0, 0, u2_none }, {} diff --git a/gen164/4/in_mer.c b/gen164/4/in_mer.c index 0229d259e..d40043d38 100644 --- a/gen164/4/in_mer.c +++ b/gen164/4/in_mer.c @@ -19,7 +19,7 @@ return u2_rx(wir_r, a); } else { - u2_noun l_a, n_a, r_a, lr_a; // XX copy tree boilerplate to other pt4 + u2_noun l_a, n_a, r_a, lr_a; u2_noun l_b, n_b, r_b, lr_b; u2_noun c;