Merge remote-tracking branch 'origin/release-candidate' into lighter-than-eyre

This commit is contained in:
Elliot Glaysher 2018-12-14 11:33:22 -08:00
commit 897a538c49
135 changed files with 3098 additions and 9555 deletions

1
.d/.gitignore vendored
View File

@ -1 +0,0 @@
**.d

View File

View File

View File

View File

View File

View File

View File

0
.d/noun/.gitignore vendored
View File

View File

View File

0
.d/tests/.gitignore vendored
View File

0
.d/vere/.gitignore vendored
View File

1
.gitignore vendored
View File

@ -29,3 +29,4 @@ node_modules/
/inst
cscope.*
build/
TAGS

9
.gitmodules vendored
View File

@ -1,9 +1,6 @@
[submodule "subprojects/softfloat3"]
path = subprojects/softfloat3
url = https://github.com/urbit/berkeley-softfloat-3.git
[submodule "subprojects/commonmark-legacy"]
path = subprojects/commonmark-legacy
url = https://github.com/urbit/commonmark-legacy.git
[submodule "subprojects/ed25519"]
path = subprojects/ed25519
url = https://github.com/urbit/ed25519.git
@ -19,6 +16,12 @@
[submodule "subprojects/h2o"]
path = subprojects/libh2o
url = https://github.com/urbit/h2o.git
[submodule "subprojects/argon2"]
path = subprojects/argon2
url = https://github.com/urbit/argon2.git
[submodule "subprojects/secp256k1"]
path = subprojects/secp256k1
url = https://github.com/urbit/secp256k1.git
[submodule "subprojects/libsni"]
path = subprojects/libsni
url = https://github.com/urbit/sniproxy

View File

@ -2,20 +2,6 @@ language: node_js
node_js:
- 4
script:
- meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true
- cd ./build
- ninja
- sudo ninja install
- cd ../.travis
- ulimit -c unlimited -S
- npm install
# || true so we continue
- npm run -s test || RESULT=$?
- if [[ ${RESULT} -eq 0 ]]; then exit 0; else for i in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch; done; fi;
- echo "build failed with status code $RESULT"
- exit $RESULT
# Uncomment me if this gets annoying
#
# notifications:
@ -29,10 +15,17 @@ before_install:
install:
# pwd: ~/urbit
- pip3 install --user -I meson==0.44.1
- git clone https://github.com/urbit/arvo
- cd ./arvo
- git checkout $(cat ../.travis/pin-arvo-commit.txt)
- cd ..
script:
- meson . ./build --buildtype=debugoptimized -Dgc=true -Dprof=true
- cd ./build
- ninja
- ninja test
- sudo ninja install
- cd ../.travis
- npm install
- ulimit -c unlimited -S
- npm run -s test; bash print-core-backtrace.sh $?
addons:
apt:

View File

@ -1 +1 @@
6deeb7dee9f3d47e4458fac3a0518dcde429ef73
00c79de3df4ecae9f499053990471d420f0e79a0

View File

@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
set -x
RESULT=$1
if [[ ${RESULT} -eq 0 ]]; then
exit 0
else
for i in $(find ./ -maxdepth 1 -name 'core*' -print)
do
gdb urbit core* -ex "thread apply all bt" -ex "set pagination 0" -batch
done
fi
echo "build failed with status code $RESULT"
exit $RESULT

View File

@ -1,11 +1,15 @@
'use strict';
var fs = require('fs')
var runner = require('urbit-runner')
var Urbit = runner.Urbit;
var ERROR = runner.ERROR;
var actions = runner.actions
var args = ['-A', '../arvo', '-csgPSF', 'zod', 'zod'];
var hash = fs.readFileSync('./pin-arvo-commit.txt', 'utf-8').slice(0, 10)
var pill = 'https://bootstrap.urbit.org/git-' + hash + '.pill'
var args = ['-u', pill, '-cgPSF', 'zod', 'zod'];
var urbit = new Urbit(args);
// vere hangs (always?) with run in travis-ci with -P

View File

@ -53,12 +53,12 @@ are included as git submodules. To build urbit from source, perform the followin
4. The executable should appear in `./build` directory.
### Using meson & ninja
To configure project, enter the build directory and enter
`meson configure`. Without any arguments this command will display available
options. For example, to compile debug build of urbit, use
To configure the project, enter the build directory and enter
`meson configure -Dbuildtype=release`. To compile a debug build of urbit, use
`meson configure -Dbuildtype=debug`.
To set the prefix for installation use
`meson configure -Dprefix=/usr`, and so on.
To set a prefix for installation use
`meson configure -Dprefix=/usr`.
## Configuration & compilation for legacy meson

37
default.nix Normal file
View File

@ -0,0 +1,37 @@
let
pkgs =
builtins.fetchGit {
name = "nixpkgs-2018-11-13";
url = https://github.com/nixos/nixpkgs/;
rev = "695a3d4254545968fc3015142c5299c0da5ca0a9";
};
in
with (import pkgs {});
let
osxdeps = lib.optionals stdenv.isDarwin (
with darwin.apple_sdk.frameworks;
[ Cocoa CoreServices ]);
deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib
re2c openssl ];
isGitDir = (path: type: type != "directory" || baseNameOf path != ".git");
in
stdenv.mkDerivation {
name = "urbit";
src = builtins.filterSource isGitDir ./.;
buildInputs = osxdeps ++ deps;
mesonFlags = "-Dnix=true";
NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework CoreServices";
}

View File

@ -17,8 +17,17 @@
**/
/* Assert. Good to capture.
*/
// # define c3_assert(x) assert(x)
# define c3_assert(x) ( (x) ? 0 : c3_cooked(), assert(x) )
# define c3_assert(x) \
do { \
if (!(x)) { \
fprintf(stderr, \
"\rAssertion '%s' failed " \
"in %s:%d\n", \
#x, __FILE__, __LINE__); \
c3_cooked(); \
assert(x); \
} \
} while(0)
/* Stub.
*/
@ -97,3 +106,12 @@
void* rut = c3_malloc(s); \
memset(rut, 0, s); \
rut;})
/* c3_realloc(): asserting realloc
*/
#define c3_realloc(a, b) ({ \
void* rut = realloc(a, b); \
if ( 0 == rut ) { \
c3_assert(!"memory lost"); \
} \
rut;})

View File

@ -325,6 +325,7 @@
# define c3__dorn c3_s4('d','o','r','n')
# define c3__dost c3_s4('d','o','s','t')
# define c3__dot c3_s3('d','o','t')
# define c3__doze c3_s4('d','o','z','e')
# define c3__drag c3_s4('d','r','a','g')
# define c3__draz c3_s4('d','r','a','z')
# define c3__drib c3_s4('d','r','i','b')
@ -564,6 +565,7 @@
# define c3__ic c3_s2('i','c')
# define c3__ice c3_s3('i','c','e')
# define c3__iced c3_s4('i','c','e','d')
# define c3__id c3_s2('i','d')
# define c3__if c3_s2('i','f')
# define c3__ifix c3_s4('i','f','i','x')
# define c3__in c3_s2('i','n')
@ -1186,6 +1188,7 @@
# define c3__void c3_s4('v','o','i','d')
# define c3__vorp c3_s4('v','o','r','p')
# define c3__way c3_s3('w','a','y')
# define c3__wack c3_s4('w','a','c','k')
# define c3__wail c3_s4('w','a','i','l')
# define c3__wake c3_s4('w','a','k','e')
# define c3__wamp c3_s4('w','a','m','p')
@ -1200,6 +1203,7 @@
# define c3__werp c3_s4('w','e','r','p')
# define c3__west c3_s4('w','e','s','t')
# define c3__what c3_s4('w','h','a','t')
# define c3__whom c3_s4('w','h','o','m')
# define c3__wing c3_s4('w','i','n','g')
# define c3__wild c3_s4('w','i','l','d')
# define c3__win c3_s3('w','i','n')

View File

@ -263,81 +263,3 @@
u3_noun u3gfu_tack(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3gfu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3gfu_wrap(u3_noun, u3_noun, u3_noun);
u3_noun u3qz_bull(u3_noun, u3_noun);
u3_noun u3qz_cell(u3_noun, u3_noun);
u3_noun u3qz_comb(u3_noun, u3_noun);
u3_noun u3qz_cons(u3_noun, u3_noun);
u3_noun u3qz_core(u3_noun, u3_noun);
u3_noun u3qz_cube(u3_noun, u3_noun);
u3_noun u3qz_face(u3_noun, u3_noun);
u3_noun u3qz_fine(u3_noun, u3_noun, u3_noun);
u3_noun u3qz_fitz(u3_noun, u3_noun);
u3_noun u3qz_flan(u3_noun, u3_noun);
u3_noun u3qz_flay(u3_noun);
u3_noun u3qz_flip(u3_noun);
u3_noun u3qz_flor(u3_noun, u3_noun);
u3_noun u3qz_forq(u3_noun, u3_noun);
u3_noun u3qz_fork(u3_noun);
u3_noun u3qz_grof(u3_noun);
u3_noun u3qz_help(u3_noun, u3_noun);
u3_noun u3qz_hike(u3_noun, u3_noun);
u3_noun u3qz_look(u3_noun, u3_noun);
u3_noun u3qz_loot(u3_noun, u3_noun);
u3_noun u3qz_slot(u3_atom, u3_noun);
u3_noun u3qz_type(u3_noun);
u3_noun u3qzl_bunt(u3_noun, u3_noun);
u3_noun u3qzl_whip(u3_noun, u3_noun, u3_noun);
u3_noun u3qzp_hack(u3_noun, u3_noun);
u3_noun u3qzp_late(u3_noun);
u3_noun u3qzp_open(u3_noun, u3_noun);
u3_noun u3qzp_rake(u3_noun);
# define u3qzu_van_fan 28
# define u3qzu_van_rib 58
# define u3qzu_van_vrf 59
# define u3qzu_van_vet 118
# define u3qzu_van_fab 119
u3_noun u3qzu_burn(u3_noun, u3_noun);
u3_noun u3qzu_busk(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_buss(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_bust(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_conk(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_crop(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_cull(u3_noun, u3_noun, u3_noun, u3_atom, u3_noun);
u3_noun u3qzu_duck(u3_noun, u3_noun);
u3_noun u3qzu_dung(u3_noun, u3_noun cap, u3_noun);
u3_noun u3qzu_dunq(u3_noun, const c3_c*, u3_noun);
void u3qzu_dump(u3_noun, const c3_c*, u3_noun);
u3_noun u3qzu_fond(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_finc(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_fire(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_firm(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_fish(u3_noun, u3_noun, u3_atom);
u3_noun u3qzu_fuse(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_gain(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_heal(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_lose(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_mint(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_mull(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_nest(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_nost(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_orth(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_peek(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_peel(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_play(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_repo(u3_noun, u3_noun);
u3_noun u3qzu_rest(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_shep(u3_noun, const c3_c*, u3_noun, u3_noun);
u3_noun u3qzu_shew(u3_noun, u3_noun);
u3_noun u3qzu_sift(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_snub(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_tack(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_wrap(u3_noun, u3_noun, u3_noun);

View File

@ -18,6 +18,11 @@
/* u3kc: tier 3 functions
*/
/* u3kc_mix(): binary xor.
*/
u3_noun
u3kc_mix(u3_atom a, u3_atom b);
/* u3kc_lsh(): left shift.
*/
u3_noun
@ -28,6 +33,26 @@
u3_noun
u3kc_rsh(u3_noun a, u3_noun b, u3_noun c);
/* u3kc_rep(): assemble single.
*/
u3_noun
u3kc_rep(u3_atom a, u3_noun b);
/* u3kc_rip(): disassemble.
*/
u3_noun
u3kc_rip(u3_atom a, u3_atom b);
/* u3kc_rev(): reverse block order, accounting for leading zeroes.
*/
u3_noun
u3kc_rev(u3_atom boz, u3_atom len, u3_atom dat);
/* u3kc_swp(): reverse block order.
*/
u3_noun
u3kc_swp(u3_atom a, u3_atom b);
/* u3kd: tier 4 functions
*/
/* u3kdb_get(): map get for key `b` in map `a` with u3_none.

View File

@ -64,8 +64,10 @@
u3_noun u3qc_pow(u3_atom, u3_atom);
u3_noun u3qc_rap(u3_atom, u3_noun);
u3_noun u3qc_rep(u3_atom, u3_noun);
u3_noun u3qc_rev(u3_atom, u3_atom, u3_atom);
u3_noun u3qc_rip(u3_atom, u3_atom);
u3_noun u3qc_rsh(u3_atom, u3_atom, u3_atom);
u3_noun u3qc_swp(u3_atom, u3_atom);
u3_noun u3qc_sqt(u3_atom);
u3_noun u3qc_vor(u3_atom, u3_atom);
@ -132,6 +134,25 @@
u3_noun u3qe_shay(u3_atom, u3_atom);
u3_noun u3qe_shas(u3_atom, u3_atom);
u3_noun u3qe_shal(u3_atom, u3_atom);
u3_noun u3qe_sha1(u3_atom, u3_atom);
u3_noun u3qe_hmac(u3_noun, u3_atom, u3_atom,
u3_atom, u3_atom, u3_atom, u3_atom);
u3_noun u3qe_argon2(u3_atom, u3_atom, u3_atom,
u3_atom, u3_atom, u3_atom,
u3_atom, u3_atom, u3_atom, u3_atom,
u3_atom, u3_atom, u3_atom, u3_atom);
u3_noun u3qe_blake(u3_atom wid, u3_atom dat,
u3_atom wik, u3_atom dak, u3_atom out);
u3_noun u3qe_ripe(u3_atom wid, u3_atom dat);
u3_noun u3qe_make(u3_atom has, u3_atom prv);
u3_noun u3qe_reco(u3_atom has, u3_atom sig_v, u3_atom sig_r, u3_atom sig_s);
u3_noun u3qe_sign(u3_atom has, u3_atom prv);
u3_noun u3qeo_raw(u3_atom, u3_atom);
@ -268,85 +289,4 @@
u3_noun u3qfu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qfu_wrap(u3_noun, u3_noun, u3_noun);
u3_noun u3qz_bull(u3_noun, u3_noun);
u3_noun u3qz_cell(u3_noun, u3_noun);
u3_noun u3qz_comb(u3_noun, u3_noun);
u3_noun u3qz_cons(u3_noun, u3_noun);
u3_noun u3qz_core(u3_noun, u3_noun);
u3_noun u3qz_cube(u3_noun, u3_noun);
u3_noun u3qz_face(u3_noun, u3_noun);
u3_noun u3qz_fine(u3_noun, u3_noun, u3_noun);
u3_noun u3qz_fitz(u3_noun, u3_noun);
u3_noun u3qz_flan(u3_noun, u3_noun);
u3_noun u3qz_flay(u3_noun);
u3_noun u3qz_flip(u3_noun);
u3_noun u3qz_flor(u3_noun, u3_noun);
u3_noun u3qz_forq(u3_noun, u3_noun);
u3_noun u3qz_fork(u3_noun);
u3_noun u3qz_grof(u3_noun);
u3_noun u3qz_hint(u3_noun, u3_noun);
u3_noun u3qz_hike(u3_noun, u3_noun);
u3_noun u3qz_look(u3_noun, u3_noun);
u3_noun u3qz_loot(u3_noun, u3_noun);
u3_noun u3qz_slot(u3_atom, u3_noun);
u3_noun u3qz_type(u3_noun);
u3_noun u3qzl_bunt(u3_noun, u3_noun);
u3_noun u3qzl_whip(u3_noun, u3_noun, u3_noun);
u3_noun u3qzr_fish(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzp_hack(u3_noun, u3_noun);
u3_noun u3qzp_late(u3_noun);
u3_noun u3qzp_open(u3_noun, u3_noun, u3_noun);
u3_noun u3qzp_rake(u3_noun);
void u3qf_test(const c3_c*, u3_noun);
# define u3qzu_van_fan 28
# define u3qzu_van_rib 58
# define u3qzu_van_vrf 59
# define u3qzu_van_vet 118
# define u3qzu_van_fab 119
u3_noun u3qzu_burn(u3_noun, u3_noun);
u3_noun u3qzu_busk(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_buss(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_bust(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_conk(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_crop(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_cull(u3_noun, u3_noun, u3_noun, u3_atom, u3_noun);
u3_noun u3qzu_duck(u3_noun, u3_noun);
u3_noun u3qzu_dung(u3_noun, u3_noun cap, u3_noun);
u3_noun u3qzu_dunq(u3_noun, const c3_c*, u3_noun);
void u3qzu_dump(u3_noun, const c3_c*, u3_noun);
u3_noun u3qzu_fond(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_find(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_finc(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_fire(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_firm(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_fish(u3_noun, u3_noun, u3_atom);
u3_noun u3qzu_fuse(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_gain(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_heal(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_lose(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_mint(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_mull(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_nest(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_nost(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_orth(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_peek(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_peel(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_play(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_repo(u3_noun, u3_noun);
u3_noun u3qzu_rest(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_shep(u3_noun, const c3_c*, u3_noun, u3_noun);
u3_noun u3qzu_shew(u3_noun, u3_noun);
u3_noun u3qzu_sift(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_snub(u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_tack(u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_toss(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
u3_noun u3qzu_wrap(u3_noun, u3_noun, u3_noun);

View File

@ -64,8 +64,10 @@
u3_noun u3wc_pow(u3_noun);
u3_noun u3wc_rap(u3_noun);
u3_noun u3wc_rep(u3_noun);
u3_noun u3wc_rev(u3_noun);
u3_noun u3wc_rip(u3_noun);
u3_noun u3wc_rsh(u3_noun);
u3_noun u3wc_swp(u3_noun);
u3_noun u3wc_sqt(u3_noun);
u3_noun u3wc_vor(u3_noun);
@ -77,16 +79,19 @@
/** Tier 4.
**/
u3_noun u3wdb_bif(u3_noun);
u3_noun u3wdb_del(u3_noun);
u3_noun u3wdb_dif(u3_noun);
u3_noun u3wdb_gas(u3_noun);
u3_noun u3wdb_get(u3_noun);
u3_noun u3wdb_has(u3_noun);
u3_noun u3wdb_int(u3_noun);
u3_noun u3wdb_jab(u3_noun);
u3_noun u3wdb_put(u3_noun);
# define u3wdb_tap u3wdi_tap
u3_noun u3wdb_uni(u3_noun);
u3_noun u3wdi_bif(u3_noun);
u3_noun u3wdi_del(u3_noun);
u3_noun u3wdi_dif(u3_noun);
u3_noun u3wdi_gas(u3_noun);
u3_noun u3wdi_has(u3_noun);
@ -143,6 +148,7 @@
u3_noun u3we_shay(u3_noun);
u3_noun u3we_shas(u3_noun);
u3_noun u3we_shal(u3_noun);
u3_noun u3we_sha1(u3_noun);
u3_noun u3weo_raw(u3_noun);
@ -151,6 +157,19 @@
u3_noun u3wee_veri(u3_noun);
u3_noun u3wee_shar(u3_noun);
u3_noun u3we_hmac(u3_noun);
u3_noun u3we_argon2(u3_noun);
u3_noun u3we_blake(u3_noun);
u3_noun u3we_ripe(u3_noun);
u3_noun u3we_make(u3_noun);
u3_noun u3we_sign(u3_noun);
u3_noun u3we_reco(u3_noun);
u3_noun u3we_bend_fun(u3_noun);
u3_noun u3we_cold_fun(u3_noun);
u3_noun u3we_cook_fun(u3_noun);
@ -272,62 +291,3 @@
u3_noun u3wfu_snub(u3_noun);
u3_noun u3wfu_toss(u3_noun);
u3_noun u3wfu_wrap(u3_noun);
u3_noun u3wz_bull(u3_noun);
u3_noun u3wz_cell(u3_noun);
u3_noun u3wz_comb(u3_noun);
u3_noun u3wz_cons(u3_noun);
u3_noun u3wz_core(u3_noun);
u3_noun u3wz_cube(u3_noun);
u3_noun u3wz_face(u3_noun);
u3_noun u3wz_fine(u3_noun);
u3_noun u3wz_fitz(u3_noun);
u3_noun u3wz_flan(u3_noun);
u3_noun u3wz_flay(u3_noun);
u3_noun u3wz_flip(u3_noun);
u3_noun u3wz_flor(u3_noun);
u3_noun u3wz_forq(u3_noun);
u3_noun u3wz_fork(u3_noun);
u3_noun u3wz_help(u3_noun);
u3_noun u3wz_hike(u3_noun);
u3_noun u3wz_look(u3_noun);
u3_noun u3wz_loot(u3_noun);
u3_noun u3wzl_bunt(u3_noun);
u3_noun u3wzl_whip(u3_noun);
u3_noun u3wzp_hack(u3_noun);
u3_noun u3wzp_late(u3_noun);
u3_noun u3wzp_open(u3_noun);
u3_noun u3wzp_rake(u3_noun);
u3_noun u3wzu_burn(u3_noun);
u3_noun u3wzu_busk(u3_noun);
u3_noun u3wzu_bust(u3_noun);
u3_noun u3wzu_conk(u3_noun);
u3_noun u3wzu_crop(u3_noun);
u3_noun u3wzu_cull(u3_noun);
u3_noun u3wzu_duck(u3_noun);
u3_noun u3wzu_find(u3_noun);
u3_noun u3wzu_fond(u3_noun);
u3_noun u3wzu_fink(u3_noun);
u3_noun u3wzu_fire(u3_noun);
u3_noun u3wzu_firm(u3_noun);
u3_noun u3wzu_fish(u3_noun);
u3_noun u3wzu_fuse(u3_noun);
u3_noun u3wzu_heal(u3_noun);
u3_noun u3wzu_mint(u3_noun);
u3_noun u3wzu_mull(u3_noun);
u3_noun u3wzu_nest(u3_noun);
u3_noun u3wzu_peek(u3_noun);
u3_noun u3wzu_peel(u3_noun);
u3_noun u3wzu_play(u3_noun);
u3_noun u3wzu_repo(u3_noun);
u3_noun u3wzu_rest(u3_noun);
u3_noun u3wzu_snub(u3_noun);
u3_noun u3wzu_toss(u3_noun);
u3_noun u3wzu_wrap(u3_noun);
/** Tier 7.
**/
u3_noun u3wg_down(u3_noun);

View File

@ -327,7 +327,3 @@
u3_noun u3wzu_snub(u3_noun);
u3_noun u3wzu_toss(u3_noun);
u3_noun u3wzu_wrap(u3_noun);
/** Tier 7.
**/
u3_noun u3yg_down(u3_noun);

View File

@ -146,6 +146,7 @@
c3_d nox_d; // nock steps
c3_d cel_d; // cell allocations
u3_noun don; // (list batt)
u3_noun trace; // (list trace)
u3_noun day; // doss, only in u3H (moveme)
} pro;

View File

@ -25,7 +25,8 @@
u3o_verbose = 0x10, // be remarkably wordy
u3o_dryrun = 0x20, // don't touch checkpoint
u3o_quiet = 0x40, // disable ~&
u3o_hashless = 0x80 // disable hashboard
u3o_hashless = 0x80, // disable hashboard
u3o_trace = 0x100 // enables trace dumping
};
/** Globals.

View File

@ -83,6 +83,32 @@
void
u3t_flee(void);
/* u3t_trace_open(): opens the path for writing tracing information.
*/
void
u3t_trace_open(c3_c*);
/* u3t_trace_close(): closes the trace file. optional.
*/
void
u3t_trace_close();
/* u3t_nock_trace_push(): pushes a frame onto the trace stack;
* return yes if active push.
*/
c3_o
u3t_nock_trace_push(u3_noun lab);
/* u3t_nock_trace_pop(): pop off trace stack.
*/
void
u3t_nock_trace_pop();
/* u3t_event_trace(): record a lifecycle event.
*/
void
u3t_event_trace(const c3_c* name, c3_c type);
/* u3t_damp(): print and clear profile data.
*/
void

View File

@ -33,7 +33,6 @@
u3_noun roe; // temporary unsaved events
u3_noun key; // log key, or 0
u3_noun ken; // kernel formula
u3_noun roc; // kernel core
struct { // ova waiting to process
@ -65,15 +64,10 @@
u3_noun
u3v_do(const c3_c* txt_c, u3_noun arg);
/* u3v_make(): make a new pier by loading a pill.
/* u3v_boot(): evaluate boot sequence, making a kernel
*/
void
u3v_make(c3_c* pas_c);
/* u3v_jack(): execute kernel formula to bind jets.
*/
void
u3v_jack(void);
u3v_boot(u3_noun eve);
/* u3v_start(): start time.
*/
@ -90,11 +84,6 @@
u3_noun
u3v_pike(u3_noun ovo, u3_noun cor);
/* u3v_nick(): transform enveloped packets, [vir cor].
*/
u3_noun
u3v_nick(u3_noun vir, u3_noun cor);
/* u3v_do(): use a kernel function.
*/
u3_noun
@ -120,21 +109,11 @@
u3_noun
u3v_peek(u3_noun hap);
/* u3v_keep(): measure timer.
*/
u3_noun
u3v_keep(u3_noun hap);
/* u3v_poke(): insert and apply an input ovum (protected).
*/
u3_noun
u3v_poke(u3_noun ovo);
/* u3v_http_request(): hear http request on channel (unprotected).
*/
void
u3v_http_request(c3_o sec, u3_noun pox, u3_noun req);
/* u3v_tank(): dump single tank.
*/
void
@ -165,11 +144,6 @@
void
u3v_hose(void);
/* u3v_louse(): last-minute deviltry upon a bail.
*/
void
u3v_louse(c3_m how_m);
/* u3v_mark(): mark arvo kernel.
*/
c3_w

View File

@ -38,12 +38,15 @@
/* u3x_cap(): root axis, 2 or 3.
*/
# define u3x_cap(a_w) (0x2 | (a_w >> (u3x_dep(a_w) - 1)))
# define u3x_cap(a_w) ({ \
c3_assert( 1 < a_w ); \
(0x2 | (a_w >> (u3x_dep(a_w) - 1))); })
/* u3x_mas(): remainder after cap.
*/
# define u3x_mas(a_w) \
( (a_w & ~(1 << u3x_dep(a_w))) | (1 << (u3x_dep(a_w) - 1)) )
# define u3x_mas(a_w) ({ \
c3_assert( 1 < a_w ); \
( (a_w & ~(1 << u3x_dep(a_w))) | (1 << (u3x_dep(a_w) - 1)) ); })
/* u3x_peg(): connect two axes.
*/

View File

@ -254,7 +254,6 @@
uv_udp_t wax_u;
uv_handle_t had_u;
};
uv_timer_t tim_u; // network timer
c3_o liv; // listener on
c3_o alm; // alarm on
c3_w law_w; // last wakeup, unix time
@ -435,7 +434,6 @@
*/
typedef struct _u3_behn {
uv_timer_t tim_u; // behn timer
c3_w run_w; // run of consecutive alarms
c3_o alm; // alarm
} u3_behn;
@ -581,38 +579,38 @@
*/
typedef struct _u3_opts {
c3_c* arv_c; // -A, initial sync from
c3_c* gen_c; // -G, czar generator
c3_c* nam_c; // -n, unix hostname
c3_o abo; // -a, abort aggressively
c3_c* pil_c; // -B, bootstrap from
c3_c* raf_c; // -r, raft flotilla
c3_c* url_c; // -u, pill url
c3_c* who_c; // -w, begin with ticket
c3_c* key_c; // -K, private key file
c3_o abo; // -a
c3_o bat; // -b, batch create
c3_o dem; // -d, daemon
c3_o dry; // -D, dry compute
c3_c* eth_c; // -e, ethereum node url
c3_o etn; // -t, use snapshot exclusively to boot
c3_c* ets_c; // -E, eth snapshot
c3_c* fak_c; // -F, fake ship
c3_o fog; // -X, skip last event
c3_o gab; // -g, run with garbage collector
c3_o has; // -S, Skip battery hashes
c3_o git; // -s, pill url from arvo git hash
c3_o mem; // -M, memory madness
c3_o net; // -N, remote networking in -F mode
c3_o nuu; // -c, new pier
c3_o dry; // -D, dry compute, no checkpoint
c3_o dem; // -d, daemon
c3_c* ets_c; // -E, eth snapshot
c3_c* eth_c; // -e, ethereum node url
c3_c* fak_c; // -F, fake ship
c3_w fuz_w; // -f, fuzz testing
c3_c* gen_c; // -G, czar generator
c3_o gab; // -g, test garbage collection
c3_c* dns_c; // -H, ames bootstrap domain
c3_c* json_file_c; // -j, json trace
c3_w kno_w; // -K, kernel version
c3_c* key_c; // -k, private key file
c3_o net; // -L, local-only networking
c3_s rop_s; // -l, raft port
c3_c* nam_c; // -n, unix hostname
c3_o pro; // -P, profile
c3_s por_s; // -p, ames port
c3_o qui; // -q, quiet
c3_o rep; // -R, report build info
c3_o tex; // -x, exit after loading
c3_o veb; // -v, verbose (inverse of -q)
c3_c* raf_c; // -r, raft flotilla
c3_o has; // -S, Skip battery hashes
c3_o git; // -s, pill url from arvo git hash
c3_o etn; // -t, use snapshot exclusively to boot
c3_c* url_c; // -u, pill url
c3_o vno; // -V, replay without reboots
c3_s por_s; // -p, ames port
c3_s rop_s; // -l, raft port
c3_w fuz_w; // -f, fuzz testing
c3_w kno_w; // -k, kernel version
c3_o veb; // -v, verbose (inverse of -q)
c3_c* who_c; // -w, begin with ticket
c3_o tex; // -x, exit after loading
} u3_opts;
/* u3_host: entire host.
@ -635,6 +633,7 @@
c3_o liv; // if u3_no, shut down
c3_i xit_i; // exit code for shutdown
void* tls_u; // server SSL_CTX*
FILE* trace_file_u; // trace file to write to
} u3_host; // host == computer == process
# define u3L u3_Host.lup_u // global event loop
@ -906,11 +905,6 @@
void
u3_term_io_exit(void);
/* u3_term_io_poll(): update terminal IO state.
*/
void
u3_term_io_poll(void);
/* u3_term_io_hija(): hijack console for cooked print.
*/
FILE*
@ -962,11 +956,6 @@
void
u3_ames_io_exit(void);
/* u3_ames_io_poll(): update ames IO state.
*/
void
u3_ames_io_poll(void);
/** Autosave.
**/
/* u3_save_ef_chld(): report SIGCHLD.
@ -984,11 +973,6 @@
void
u3_save_io_exit(void);
/* u3_save_io_poll(): update autosave state.
*/
void
u3_save_io_poll(void);
/** Storage, new school.
**/
/* u3_unix_ef_hold():
@ -1041,29 +1025,27 @@
void
u3_unix_io_exit(void);
/* u3_unix_io_poll(): update storage state.
*/
void
u3_unix_io_poll(void);
/** behn, just a timer.
**/
/* u2_behn_io_init(): initialize behn timer.
/* u3_behn_io_init(): initialize behn timer.
*/
void
u2_behn_io_init(void);
u3_behn_io_init(void);
/* u2_behn_io_exit(): terminate timer.
*/
void
u2_behn_io_exit(void);
u3_behn_io_exit(void);
/* u2_behn_io_poll(): update behn IO state.
/* u3_behn_ef_bake(): notify %behn that we're live
*/
void
u2_behn_io_poll(void);
u3_behn_ef_bake(void);
/* u3_behn_ef_doze(): set or cancel timer
*/
void
u3_behn_ef_doze(u3_noun wen);
/** HTTP server.
**/
@ -1119,11 +1101,6 @@
void
u3_http_io_exit(void);
/* u3_http_io_poll(): update http IO state.
*/
void
u3_http_io_poll(void);
/** Raft log syncing.
**/
/* u3_raft_readopt(): parse command line options.
@ -1136,7 +1113,12 @@
void
u3_raft_init(void);
/* u3_raft_work(): poke, kick, and push pending events.
/* u3_raft_play(): synchronously poke, kick, and push pending events.
*/
void
u3_raft_play(void);
/* u3_raft_work(): asynchronously poke, kick, and push pending events.
*/
void
u3_raft_work(void);
@ -1212,24 +1194,6 @@
void
u3_sist_rand(c3_w* rad_w);
/** New timer system.
**/
/* u3_behn_io_init(): initialize time timer.
*/
void
u3_behn_io_init(void);
/* u3_behn_io_exit(): terminate timer.
*/
void
u3_behn_io_exit(void);
/* u3_behn_io_poll(): update behn IO state.
*/
void
u3_behn_io_poll(void);
/** HTTP client.
**/
/* u3_cttp_ef_thus(): send %thus effect to cttp.
@ -1248,7 +1212,13 @@
void
u3_cttp_io_exit(void);
/* u3_cttp_io_poll(): update cttp IO state.
/* u3_dawn_come(): mine a comet under star (unit)
*/
void
u3_cttp_io_poll(void);
u3_noun
u3_dawn_come(u3_noun star);
/* u3_dawn_vent(): validatated boot event
*/
u3_noun
u3_dawn_vent(u3_noun seed);

View File

@ -6,13 +6,73 @@
/* functions
*/
// like skid, except its callback is $-([* *] ?) and it takes the second
// argument so that it calls its callback with [i.list, second]
//
// all args are RETAINED
static u3_noun
_split_in(u3j_site* sit_u,
u3_noun a,
u3_noun second)
{
if ( 0 == a ) {
return u3nc(u3_nul, u3_nul);
}
else if ( c3n == u3du(a) ) {
return u3m_bail(c3__exit);
} else {
u3_noun acc = _split_in(sit_u, u3t(a), second);
u3_noun hoz = u3j_gate_slam(sit_u, u3nc(u3k(u3h(a)), u3k(second)));
u3_noun nex;
if ( c3y == hoz ) {
nex = u3nc(u3nc(u3k(u3h(a)), u3k(u3h(acc))), u3k(u3t(acc)));
}
else {
nex = u3nc(u3k(u3h(acc)), u3nc(u3k(u3h(a)), u3k(u3t(acc))));
}
u3z(hoz);
u3z(acc);
return nex;
}
}
static u3_noun
_sort_in(u3j_site* sit_u, u3_noun list)
{
if ( 0 == list ) {
return u3_nul;
}
else if ( c3n == u3du(list) ) {
return u3m_bail(c3__exit);
} else {
u3_noun hed, tal;
u3x_cell(list, &hed, &tal);
u3_noun split = _split_in(sit_u, tal, hed);
u3_noun lhs = _sort_in(sit_u, u3h(split));
u3_noun rhs = u3nc(u3k(hed), _sort_in(sit_u, u3t(split)));
u3_noun ret = u3qb_weld(lhs, rhs);
u3z(lhs);
u3z(rhs);
u3z(split);
return ret;
}
}
u3_noun
u3qb_sort(u3_noun a,
u3_noun b)
{
// must think about
//
return u3m_bail(c3__fail);
u3_noun pro;
u3j_site sit_u;
u3j_gate_prep(&sit_u, u3k(b));
pro = _sort_in(&sit_u, a);
u3j_gate_lose(&sit_u);
return pro;
}
u3_noun
u3wb_sort(u3_noun cor)

View File

@ -48,4 +48,11 @@
return u3qc_mix(a, b);
}
}
u3_noun
u3kc_mix(u3_atom a,
u3_atom b)
{
u3_noun res = u3qc_mix(a, b);
u3z(a); u3z(b);
return res;
}

View File

@ -84,4 +84,11 @@
return pro;
}
}
u3_noun
u3kc_rep(u3_atom a,
u3_noun b)
{
u3_noun res = u3qc_rep(a, b);
u3z(a); u3z(b);
return res;
}

50
jets/c/rev.c Normal file
View File

@ -0,0 +1,50 @@
/* j/3/rev.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qc_rev(u3_atom boz,
u3_atom len,
u3_atom dat)
{
if ( !_(u3a_is_cat(boz)) || (boz >= 32) ||
!_(u3a_is_cat(len)) ) {
return u3m_bail(c3__fail);
}
dat = u3qc_end(boz, len, dat);
c3_w met = u3r_met(boz, dat);
return u3kc_lsh(boz, (len - met), u3kc_swp(boz, dat));
}
u3_noun
u3wc_rev(u3_noun cor)
{
u3_noun boz, len, dat;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &boz,
u3x_sam_6, &len,
u3x_sam_7, &dat, 0)) ||
(c3n == u3ud(boz)) ||
(c3n == u3ud(len)) ||
(c3n == u3ud(dat)) )
{
return u3m_bail(c3__exit);
} else {
return u3qc_rev(boz, len, dat);
}
}
u3_noun
u3kc_rev(u3_atom boz,
u3_atom len,
u3_atom dat)
{
u3_noun res = u3qc_rev(boz, len, dat);
u3z(boz); u3z(len); u3z(dat);
return res;
}

View File

@ -81,3 +81,12 @@
return u3qc_rip(a, b);
}
}
u3_noun
u3kc_rip(u3_atom a,
u3_atom b)
{
u3_noun res = u3qc_rip(a, b);
u3z(a); u3z(b);
return res;
}

39
jets/c/swp.c Normal file
View File

@ -0,0 +1,39 @@
/* j/3/swp.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qc_swp(u3_atom a,
u3_atom b)
{
//XX write a proper c-style swp, maybe
return u3kc_rep(u3k(a), u3kb_flop(u3qc_rip(a, b)));
}
u3_noun
u3wc_swp(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)) )
{
return u3m_bail(c3__exit);
} else {
return u3qc_swp(a, b);
}
}
u3_noun
u3kc_swp(u3_atom a,
u3_atom b)
{
u3_noun res = u3qc_swp(a, b);
u3z(a); u3z(b);
return res;
}

111
jets/d/by_del.c Normal file
View File

@ -0,0 +1,111 @@
/* j/4/by_del.c
**
*/
#include "all.h"
/* functions
*/
static u3_noun
_rebalance(u3_noun a)
{
u3_noun l_a, n_a, r_a;
if ( c3n == u3r_trel(a, &n_a, &l_a, &r_a) ) {
return u3m_bail(c3__exit);
}
else {
if ( u3_nul == l_a) {
return u3k(r_a);
}
else if ( u3_nul == r_a) {
return u3k(l_a);
}
else {
u3_noun n_l_a, l_l_a, r_l_a;
u3_noun n_r_a, l_r_a, r_r_a;
if ( (c3n == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a) ) ||
(c3n == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a) ) ||
(c3n == u3du(n_l_a)) ||
(c3n == u3du(n_r_a)) ) {
return u3m_bail(c3__exit);
}
else {
if ( c3y == u3qc_vor(u3h(n_l_a), u3h(n_r_a)) ) {
u3_noun new_right = u3nt(u3k(n_a),
u3k(r_l_a),
u3k(r_a));
u3_noun ret = u3nt(u3k(n_l_a),
u3k(l_l_a),
_rebalance(new_right));
u3z(new_right);
return ret;
}
else {
u3_noun new_left = u3nt(u3k(n_a),
u3k(l_a),
u3k(l_r_a));
u3_noun ret = u3nt(u3k(n_r_a),
_rebalance(new_left),
u3k(r_r_a));
u3z(new_left);
return ret;
}
}
}
}
}
u3_noun
u3qdb_del(u3_noun a,
u3_noun b)
{
if ( u3_nul == a ) {
return u3_nul;
}
else {
u3_noun l_a, n_a, r_a, pn_a, qn_a;
if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) ||
(c3n == u3r_cell(n_a, &pn_a, &qn_a)) )
{
return u3m_bail(c3__exit);
}
else if ( c3n == u3r_sing(pn_a, b) ) {
if ( c3y == u3qc_gor(b, pn_a) ) {
return u3nt(u3k(n_a),
u3qdb_del(l_a, b),
u3k(r_a));
}
else {
return u3nt(u3k(n_a),
u3k(l_a),
u3qdb_del(r_a, b));
}
}
else {
return _rebalance(a);
}
}
}
u3_noun
u3wdb_del(u3_noun cor)
{
u3_noun a, b;
if ( c3n == u3r_mean(cor, u3x_sam, &b,
u3x_con_sam, &a, 0) ) {
return u3m_bail(c3__exit);
}
else {
u3_noun n = u3qdb_del(a, b);
return n;
}
}

56
jets/d/by_jab.c Normal file
View File

@ -0,0 +1,56 @@
/* j/4/by_jab.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qdb_jab(u3_noun a,
u3_noun key,
u3_noun fun)
{
if ( u3_nul == a ) {
return u3m_bail(c3__exit);
}
else {
u3_noun l_a, n_a, r_a;
u3_noun pn_a, qn_a;
if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) ||
(c3n == u3r_cell(n_a, &pn_a, &qn_a) ) )
{
return u3m_bail(c3__exit);
}
else {
if ( (c3y == u3r_sing(key, pn_a)) ) {
u3_noun value = u3n_slam_on(u3k(fun), u3k(qn_a));
return u3nc(u3nc(u3k(pn_a), value), u3k(u3t(a)));
}
else {
if ( c3y == u3qc_gor(key, pn_a) ) {
return u3nt(u3k(n_a), u3qdb_jab(l_a, key, fun), u3k(r_a));
}
else {
return u3nt(u3k(n_a), u3k(l_a), u3qdb_jab(r_a, key, fun));
}
}
}
}
}
u3_noun
u3wdb_jab(u3_noun cor)
{
u3_noun a, key, fun;
if ( c3n == u3r_mean(cor, u3x_sam_2, &key,
u3x_sam_3, &fun,
u3x_con_sam, &a, 0) ) {
return u3m_bail(c3__exit);
} else {
u3_noun n = u3qdb_jab(a, key, fun);
return n;
}
}

105
jets/d/in_del.c Normal file
View File

@ -0,0 +1,105 @@
/* j/4/in_del.c
**
*/
#include "all.h"
/* functions
*/
static u3_noun
_rebalance(u3_noun a)
{
u3_noun l_a, n_a, r_a;
if ( c3n == u3r_trel(a, &n_a, &l_a, &r_a) ) {
return u3m_bail(c3__exit);
}
else {
if ( u3_nul == l_a) {
return u3k(r_a);
}
else if ( u3_nul == r_a) {
return u3k(l_a);
}
else {
u3_noun n_l_a, l_l_a, r_l_a;
u3_noun n_r_a, l_r_a, r_r_a;
if ( (c3n == u3r_trel(l_a, &n_l_a, &l_l_a, &r_l_a) ) ||
(c3n == u3r_trel(r_a, &n_r_a, &l_r_a, &r_r_a) ) ) {
return u3m_bail(c3__exit);
}
else {
if ( c3y == u3qc_vor(n_l_a, n_r_a) ) {
u3_noun new_right = u3nt(u3k(n_a),
u3k(r_l_a),
u3k(r_a));
u3_noun ret = u3nt(u3k(n_l_a),
u3k(l_l_a),
_rebalance(new_right));
u3z(new_right);
return ret;
}
else {
u3_noun new_left = u3nt(u3k(n_a),
u3k(l_a),
u3k(l_r_a));
u3_noun ret = u3nt(u3k(n_r_a),
_rebalance(new_left),
u3k(r_r_a));
u3z(new_left);
return ret;
}
}
}
}
}
u3_noun
u3qdi_del(u3_noun a,
u3_noun b)
{
if ( u3_nul == a ) {
return u3_nul;
}
else {
u3_noun l_a, n_a, r_a;
if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) ) {
return u3m_bail(c3__exit);
}
else if ( c3n == u3r_sing(n_a, b) ) {
if ( c3y == u3qc_hor(b, n_a) ) {
return u3nt(u3k(n_a),
u3qdi_del(l_a, b),
u3k(r_a));
}
else {
return u3nt(u3k(n_a),
u3k(l_a),
u3qdi_del(r_a, b));
}
}
else {
return _rebalance(a);
}
}
}
u3_noun
u3wdi_del(u3_noun cor)
{
u3_noun a, b;
if ( c3n == u3r_mean(cor, u3x_sam, &b,
u3x_con_sam, &a, 0) ) {
return u3m_bail(c3__exit);
}
else {
u3_noun n = u3qdi_del(a, b);
return n;
}
}

146
jets/e/argon2.c Normal file
View File

@ -0,0 +1,146 @@
/* j/5/argon2.c
**
*/
#include "all.h"
#include <argon2.h>
/* helpers
*/
int argon2_alloc(uint8_t** output, size_t bytes)
{
*output = u3a_malloc(bytes);
return (NULL != output);
}
void argon2_free(uint8_t* memory, size_t bytes)
{
u3a_free(memory);
}
/* functions
*/
u3_noun
u3qe_argon2( // configuration params,
u3_atom out, u3_atom type, u3_atom version,
u3_atom threads, u3_atom mem_cost, u3_atom time_cost,
u3_atom wik, u3_atom key, u3_atom wix, u3_atom extra,
// input params
u3_atom wid, u3_atom dat, u3_atom wis, u3_atom sat )
{
c3_assert( _(u3a_is_cat(out)) && _(u3a_is_cat(type)) &&
_(u3a_is_cat(version)) && _(u3a_is_cat(threads)) &&
_(u3a_is_cat(mem_cost)) && _(u3a_is_cat(time_cost)) &&
_(u3a_is_cat(wik)) && _(u3a_is_cat(wix)) &&
_(u3a_is_cat(wid)) && _(u3a_is_cat(wis)) );
// flip endianness for argon2
key = u3qc_rev(3, wik, key);
extra = u3qc_rev(3, wix, extra);
dat = u3qc_rev(3, wid, dat);
sat = u3qc_rev(3, wis, sat);
// atoms to byte arrays
c3_y bytes_key[wik];
u3r_bytes(0, wik, bytes_key, key);
c3_y bytes_extra[wix];
u3r_bytes(0, wix, bytes_extra, extra);
c3_y bytes_dat[wid];
u3r_bytes(0, wid, bytes_dat, dat);
c3_y bytes_sat[wis];
u3r_bytes(0, wis, bytes_sat, sat);
c3_y outhash[out];
argon2_context context = {
outhash, // output array, at least [digest length] in size
out, // digest length
bytes_dat, // password array
wid, // password length
bytes_sat, // salt array
wis, // salt length
bytes_key, wik, // optional secret data
bytes_extra, wix, // optional associated data
time_cost, mem_cost, threads, threads, // performance cost configuration
version, // algorithm version
argon2_alloc, // custom memory allocation function
argon2_free, // custom memory deallocation function
ARGON2_DEFAULT_FLAGS // by default only internal memory is cleared
};
int argon_res;
switch ( type ) {
default:
fprintf(stderr, "\nunjetted argon2 variant %i\n", type);
u3m_bail(c3__exit);
break;
//
case c3__d:
argon_res = argon2d_ctx(&context);
break;
//
case c3__i:
argon_res = argon2i_ctx(&context);
break;
//
case c3__id:
argon_res = argon2id_ctx(&context);
break;
//
case c3__u:
argon_res = argon2u_ctx(&context);
break;
}
if ( ARGON2_OK != argon_res ) {
fprintf(stderr, "\nargon2 error: %s\n", argon2_error_message(argon_res));
u3m_bail(c3__exit);
}
u3z(key); u3z(extra); u3z(dat); u3z(sat);
return u3kc_rev(3, out, u3i_bytes(out, outhash));
}
u3_noun
u3we_argon2(u3_noun cor)
{
u3_noun // configuration params
out, type, version,
threads, mem_cost, time_cost,
wik, key, wix, extra,
// input params
wid, dat, wis, sat,
// for use during unpacking
wmsg, wsat, arg, brg, wkey, wext;
// the hoon code for argon2 takes configuration parameters,
// and then produces a gate. we jet that inner gate.
// this does mean that the config params have gotten buried
// pretty deep in the subject, hence the +510.
if ( c3n == u3r_mean(cor, u3x_sam_2, &wmsg,
u3x_sam_3, &wsat,
510, &arg, 0) ||
u3r_cell(wmsg, &wid, &dat) || u3ud(wid) || u3ud(dat) ||
u3r_cell(wsat, &wis, &sat) || u3ud(wis) || u3ud(sat) ||
//
u3r_qual(arg, &out, &type, &version, &brg) ||
u3ud(out) || u3ud(type) || u3ud(version) ||
//
u3r_qual(brg, &threads, &mem_cost, &time_cost, &arg) ||
u3ud(threads) || u3ud(mem_cost) || u3ud(time_cost) ||
//
u3r_cell(arg, &wkey, &wext) ||
u3r_cell(wkey, &wik, &key) || u3ud(wik) || u3ud(key) ||
u3r_cell(wext, &wix, &extra) || u3ud(wix) || u3ud(extra)
)
{
return u3m_bail(c3__exit);
}
else {
return u3qe_argon2(out, type, version,
threads, mem_cost, time_cost,
wik, key, wix, extra,
wid, dat, wis, sat);
}
}

72
jets/e/blake.c Normal file
View File

@ -0,0 +1,72 @@
/* j/5/blake.c
**
*/
#include "all.h"
#include <argon2.h>
#include "../src/blake2/blake2.h"
/* functions
*/
u3_noun
u3qe_blake(u3_atom wid, u3_atom dat,
u3_atom wik, u3_atom dak,
u3_atom out)
{
c3_assert(_(u3a_is_cat(wid)) && _(u3a_is_cat(wik)) && _(u3a_is_cat(out)));
// flip endianness for the internal blake2b function
dat = u3qc_rev(3, wid, dat);
dak = u3qc_rev(3, wik, dak);
c3_y* dat_y = (c3_y*)u3a_malloc(wid);
u3r_bytes(0, wid, (void*)dat_y, dat);
c3_y* dak_y = (c3_y*)u3a_malloc(wik);
u3r_bytes(0, wik, (void*)dak_y, dak);
int ret;
c3_y out_y[64];
ret = blake2b(out_y, // OUT: output
out, // IN: max output size
dat_y, // IN: msg body
wid, // IN: msg len
dak_y, // IN: key body
wik); // IN: key len
/* free() BEFORE checking error code;
we don't want to leak memory if we return early
*/
u3a_free(dat_y);
u3a_free(dak_y);
if ( 0 != ret )
{
fprintf(stderr, "\rblake jet: cryto lib error\n");
return u3m_bail(c3__exit);
}
return u3kc_rev(3, out, u3i_bytes(out, out_y));
}
u3_noun
u3we_blake(u3_noun cor)
{
u3_noun msg, key, out, // arguments
wid, dat, // destructured msg
wik, dak; // destructured key
if ( c3n == u3r_mean(cor, u3x_sam_2, &msg,
u3x_sam_6, &key,
u3x_sam_7, &out, 0) ||
u3r_cell(msg, &wid, &dat) || u3ud(wid) || u3ud(dat) ||
u3r_cell(key, &wik, &dak) || u3ud(wik) || u3ud(dak) ||
u3ud(out) )
{
fprintf(stderr, "\rblake jet: arguments error\n");
return u3m_bail(c3__exit);
} else {
return u3qe_blake(wid, dat, wik, dak, out);
}
}

View File

@ -27,14 +27,14 @@
memset(pub_y, 0, 64);
memset(sec_y, 0, 64);
mes_y = malloc(mesm_w);
mes_y = u3a_malloc(mesm_w);
u3r_bytes(0, mesm_w, mes_y, a);
u3r_bytes(0, mess_w, sed_y, b);
ed25519_create_keypair(pub_y, sec_y, sed_y);
ed25519_sign(sig_y, mes_y, mesm_w, pub_y, sec_y);
free(mes_y);
u3a_free(mes_y);
return u3i_bytes(64, sig_y);
}

88
jets/e/hmac.c Normal file
View File

@ -0,0 +1,88 @@
/* j/5/hmac.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qe_hmac(u3_noun haj,
u3_atom boq,
u3_atom out,
u3_atom wik,
u3_atom key,
u3_atom wid,
u3_atom dat)
{
c3_assert(_(u3a_is_cat(boq)) && _(u3a_is_cat(wik)) && _(u3a_is_cat(wid)));
// ensure key and message fit signaled lengths
key = u3qc_end(3, wik, key);
dat = u3qc_end(3, wid, dat);
// keys longer than block size are shortened by hashing
if (wik > boq) {
key = u3n_slam_on(u3k(haj), u3nc(wik, key));
wik = out;
}
// keys shorter than block size are right-padded
if (wik < boq) {
key = u3kc_lsh(3, (boq - wik), key);
}
// pad key, inner and outer
c3_y trail = (boq % 4);
c3_y padwords = (boq / 4) + (trail == 0 ? 0 : 1);
c3_w innpad[padwords], outpad[padwords];
memset(innpad, 0x36, padwords * 4);
memset(outpad, 0x5c, padwords * 4);
if ( trail > 0 ) {
innpad[padwords-1] = 0x36363636 >> (8 * (4 - trail));
outpad[padwords-1] = 0x5c5c5c5c >> (8 * (4 - trail));
}
u3_atom innkey = u3kc_mix(u3k(key), u3i_words(padwords, innpad));
u3_atom outkey = u3kc_mix( key , u3i_words(padwords, outpad));
// append inner padding to message, then hash
u3_atom innmsg = u3ka_add(u3kc_lsh(3, wid, innkey), u3k(dat));
u3_atom innhaj = u3n_slam_on(u3k(haj), u3nc((wid + boq), innmsg));
// prepend outer padding to result, hash again
u3_atom outmsg = u3ka_add(u3kc_lsh(3, out, outkey), innhaj);
u3_atom outhaj = u3n_slam_on(u3k(haj), u3nc((out + boq), outmsg));
return outhaj;
}
u3_noun
u3we_hmac(u3_noun cor)
{
u3_noun haj, boq, out, wik, key, wid, dat;
// sample is [[haj boq out] [wik key] [wid dat]]
if ( (c3n == u3r_mean(cor, u3x_sam_4, &haj,
50, &boq, // +<->-
51, &out, // +<->+
u3x_sam_12, &wik,
u3x_sam_13, &key,
u3x_sam_14, &wid,
u3x_sam_15, &dat, 0)) ||
(c3n == u3ud(boq)) ||
(c3n == u3a_is_cat(boq)) ||
(c3n == u3ud(out)) ||
(c3n == u3a_is_cat(out)) ||
(c3n == u3ud(wik)) ||
(c3n == u3a_is_cat(wik)) ||
(c3n == u3ud(key)) ||
(c3n == u3ud(wid)) ||
(c3n == u3a_is_cat(wid)) ||
(c3n == u3ud(dat)) )
{
return u3m_bail(c3__exit);
}
else {
return u3qe_hmac(haj, boq, out, wik, key, wid, dat);
}
}

View File

@ -35,8 +35,12 @@
}
{
c3_y* byts_y = alloca(meg_w);
u3r_bytes(pos_w, meg_w, byts_y, lub);
c3_y* byts_y = 0;
if ( 0 != meg_w ) {
byts_y = alloca(meg_w);
u3r_bytes(pos_w, meg_w, byts_y, lub);
}
if ( _(end_y) ) {
return u3kb_flop(u3nc(u3i_bytes(meg_w, byts_y), tez));

80
jets/e/ripe.c Normal file
View File

@ -0,0 +1,80 @@
/* j/5/ripe.c
**
*/
#include "all.h"
#include <openssl/evp.h>
/* functions
*/
u3_noun
u3qe_ripe(u3_atom wid, u3_atom dat)
{
c3_assert(_(u3a_is_cat(wid)));
dat = u3qc_rev(3, wid, dat);
c3_y* dat_y = (c3_y*)u3a_malloc(wid); // msg body
u3r_bytes(0, wid, (void*)dat_y, dat);
const EVP_MD* rip_u = EVP_ripemd160(); // ripem algorithm
static EVP_MD_CTX* con_u = NULL; // context
/* build library context object
we do this once (and only once)
*/
if (NULL == con_u) {
con_u = EVP_MD_CTX_create();
}
/* perform signature
*/
c3_y sib_y[20]; // signature body
c3_w sil_w; // signature length
c3_w ret_w; // return code
ret_w = EVP_DigestInit_ex(con_u, rip_u, NULL);
if ( 1 != ret_w ) {
u3a_free(dat_y);
fprintf(stderr, "\rripe jet: crypto library fail 1\n");
return u3m_bail(c3__exit);
}
ret_w = EVP_DigestUpdate(con_u, (void*)dat_y, wid);
u3a_free(dat_y);
if (1 != ret_w) {
fprintf(stderr, "\rripe jet: crypto library fail 2\n");
return u3m_bail(c3__exit);
}
ret_w = EVP_DigestFinal_ex(con_u, sib_y, &sil_w);
if ( 1 != ret_w ) {
fprintf(stderr, "\rripe jet: crypto library fail 3\n");
return u3m_bail(c3__exit);
}
/* endian conversion;
turn into noun for return
*/
return u3kc_rev(3, sil_w, u3i_bytes(sil_w, sib_y));
}
u3_noun
u3we_ripe(u3_noun cor)
{
u3_noun wid, dat;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &wid,
u3x_sam_3, &dat, 0) ||
u3ud(wid) || u3ud(dat))
)
{
fprintf(stderr, "\rripe jet: argument error\n");
return u3m_bail(c3__exit);
}
else {
return u3qe_ripe(wid, dat);
}
}

315
jets/e/secp.c Normal file
View File

@ -0,0 +1,315 @@
/* j/5/secp.c
**
*/
#include "all.h"
#include "../include/secp256k1.h"
#include "../include/secp256k1_recovery.h"
/* util funcs
*/
/* no guarantees if 'in' and 'out' overlap / are the same */
static void byte_reverse(c3_y *i_y, /* in */
c3_y *o_y, /* out */
c3_w n_w) /* size */
{
c3_w j_w;
for (j_w = 0; j_w < n_w; j_w++){
o_y[n_w - 1 - j_w] = i_y[j_w];
}
return;
}
/* Identical to u3r_bytes, but reverses bytes in place.
could be cleaner if we modified u3r_bytes(), but not gonna do that.
This func exists bc Urbit code base is explicitly little-endian,
and secp256k1 library is explicitly big-endian.
Several times below we do the pattern of (1) invoke u3r_bytes, (2) invert. Do it in a func.
*/
static void u3r_bytes_reverse(c3_w a_w,
c3_w b_w,
c3_y* c_y, /* out */
u3_atom d) /* in */
{
u3r_bytes(a_w, b_w, c_y, d);
c3_w i_w;
for (i_w = 0; i_w < ((b_w - a_w) / 2) ; i_w++) {
c3_y lo = c_y[i_w];
c3_y hi = c_y[b_w - i_w - 1];
c_y[i_w] = hi;
c_y[b_w - i_w - 1] = lo;
}
return;
}
/* sign hash with priv key
*/
u3_noun
u3we_sign(u3_noun cor)
{
u3_noun has, prv;
if ( (c3n == u3r_mean(cor,
u3x_sam_2, &has,
u3x_sam_3, &prv,
0)) ||
(c3n == u3ud(has)) ||
(c3n == u3ud(prv))) {
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
} else {
return (u3qe_sign(has, prv));
}
}
u3_noun
u3qe_sign(u3_atom has,
u3_atom prv)
{
/* build library context object once (and only once) */
static secp256k1_context * ctx_u = NULL;
if (NULL == ctx_u) {
ctx_u = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
}
/* parse arguments, convert endianness */
c3_y has_y[32]; /* hash */
c3_y prv_y[32]; /* private key */
u3r_bytes_reverse(0, 32, has_y, has);
u3r_bytes_reverse(0, 32, prv_y, prv);
/* sign
N.B. if we want the 'v' field we can't use default secp256k1_ecdsa_sign(),
but must use secp256k1_ecdsa_sign_recoverable() */
c3_ws ret;
secp256k1_ecdsa_recoverable_signature sig_u;
ret = secp256k1_ecdsa_sign_recoverable(ctx_u, /* IN: context object */
& sig_u, /* OUT: signature */
(const c3_y *) has_y, /* IN: 32 byte hash to be signed */
(const c3_y *) prv_y, /* IN: 32 byte secret key */
(secp256k1_nonce_function) NULL, /* IN: nonce-function ptr ; NULL = default */
(const void *) NULL); /* IN: data for nonce function; not used */
if (1 != ret) {
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
}
/* convert opaque 65 byte signature into v + [r + s]
convert endianness while we're at it */
c3_y rec_y[64];
c3_ws v = 0;
ret = secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx_u,
rec_y, /* OUT: 64 byte sig (r,s) */
& v, /* OUT: v */
& sig_u); /* IN: 65 byte sig */
if (1 != ret) {
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
}
c3_y s_y[32];
c3_y r_y[32];
byte_reverse(rec_y, r_y, 32);
byte_reverse(rec_y + 32, s_y, 32);
/* package s,r,v signature for return */
u3_noun s = u3i_words(8, (const c3_w*) s_y);
u3_noun r = u3i_words(8, (const c3_w*) r_y);
return (u3nt(v, r, s));
}
/* recover pubkey from signature (which is how we verify signatures)
*/
u3_noun
u3we_reco(u3_noun cor)
{
u3_noun has, /* hash */
siv, sir, sis; /* signature: v, r, s */
if ( (c3n == u3r_mean(cor,
u3x_sam_2, &has,
u3x_sam_6, &siv,
u3x_sam_14, &sir,
u3x_sam_15, &sis,
0)) ||
(c3n == u3ud(has)) ||
(c3n == u3ud(siv)) ||
(c3n == u3ud(sir)) ||
(c3n == u3ud(sis)) )
{
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
} else {
return u3qe_reco(has, siv, sir, sis);
}
}
u3_noun
u3qe_reco(u3_atom has,
u3_atom siv, /* signature: v */
u3_atom sir, /* signature: r */
u3_atom sis) /* signature: s */
{
/* build library context object once (and only once) */
static secp256k1_context * ctx_u = NULL;
if (NULL == ctx_u) {
ctx_u = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY);
}
/* parse arguments, convert endianness */
c3_y has_y[32];
c3_y sir_y[32];
c3_y sis_y[32];
c3_y siv_y[1];
u3r_bytes_reverse(0, 32, has_y, has);
u3r_bytes_reverse(0, 32, sir_y, sir);
u3r_bytes_reverse(0, 32, sis_y, sis);
u3r_bytes_reverse(0, 1, siv_y, siv);
/* build the signature object */
c3_y ras_y[64]; /* priv key: r and s components */
c3_ws i_ws;
for (i_ws = 0; i_ws < 32; i_ws++) {
ras_y[i_ws] = sir_y[i_ws] ;
}
for (i_ws = 0; i_ws < 32; i_ws++) {
ras_y[i_ws + 32] = sis_y[i_ws] ;
}
c3_ws siv_ws = siv_y[0];
secp256k1_ecdsa_recoverable_signature sig_u;
memset( (void *) & sig_u, 0, sizeof(secp256k1_ecdsa_recoverable_signature) );
c3_ws ret = secp256k1_ecdsa_recoverable_signature_parse_compact(ctx_u, /* IN: context */
& sig_u, /* OUT: sig */
ras_y, /* IN: r/s */
siv_ws); /* IN: v */
if (1 != ret) {
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
}
/* turn sign into puk_u */
secp256k1_pubkey puk_u;
memset((void *) & puk_u, 0, sizeof(secp256k1_pubkey) );
ret = secp256k1_ecdsa_recover(ctx_u, /* IN: context */
& puk_u, /* OUT: pub key */
& sig_u, /* IN: signature */
(const c3_y *) & has); /* IN: message has */
if (1 != ret) {
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
}
/* convert puk_u into serialized form that we can get x,y out of */
c3_y puk_y[65];
size_t outputlen = 65;
memset((void *) puk_y, 0, 65);
ret = secp256k1_ec_pubkey_serialize( ctx_u, /* IN: */
puk_y, /* OUT: */
& outputlen, /* OUT: */
& puk_u, /* IN: */
SECP256K1_EC_UNCOMPRESSED); /* IN: flags */
if (1 != ret) {
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
}
/* in file
subprojects/secp256k1/src/eckey_impl.h
func
secp256k1_eckey_puk_u_parse()
we can see
byte 0: signal bits (???)
bytes 1-32: x
bytes 33-64: y
convert endianness while we're at it */
c3_y x_y[32];
for (i_ws = 0; i_ws < 32; i_ws++) {
x_y[i_ws] = puk_y[32 - i_ws];
}
u3_noun x = u3i_bytes(32, x_y);
c3_y y_y[32];
for (i_ws = 0; i_ws < 32; i_ws++) {
y_y[i_ws] = puk_y[64 - i_ws];
}
u3_noun y = u3i_bytes(32, y_y);
/* returns x,y */
return(u3nc(x, y));
}
u3_noun
u3we_make(u3_noun cor)
{
u3_noun has, prv;
if ( (c3n == u3r_mean(cor,
u3x_sam_2, &has,
u3x_sam_3, &prv,
0)) ||
(c3n == u3ud(has)) ||
(c3n == u3ud(prv)) )
{
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
} else {
return u3qe_make(has, prv);
}
}
u3_noun
u3qe_make(u3_atom has,
u3_atom prv)
{
c3_y hel_y[32]; /* hash, little endian */
c3_y heb_y[32]; /* hash, big endian */
u3r_bytes(0, 32, hel_y, has);
byte_reverse(hel_y, heb_y, 32);
c3_y pel_y[32]; /* priv key, little endian */
c3_y peb_y[32]; /* priv key, big endian */
u3r_bytes(0, 32, pel_y, prv);
byte_reverse(pel_y, peb_y, 32);
c3_ws ret_ws;
c3_y neb_y[32]; /* nonce */
ret_ws = secp256k1_nonce_function_rfc6979(neb_y, /* OUT: return arg for nonce */
(const c3_y *) heb_y, /* IN: message / hash */
(const c3_y *) peb_y, /* IN: key32 */
NULL, /* IN: algorithm (NULL == ECDSA) */
(void *) NULL, /* IN: arbitrary data pointer (unused) */
0); /* IN: attempt number (0 == normal) */
if (1 != ret_ws) {
fprintf(stderr, "\rsecp jet: crypto package error\n");
return u3m_bail(c3__exit);
}
c3_y nel_y[32];
byte_reverse(neb_y, nel_y, 32);
u3_noun non = u3i_words(8, (const c3_w*) nel_y);
return(non);
}

59
jets/e/sha1.c Normal file
View File

@ -0,0 +1,59 @@
/* j/5/sha1.c
**
*/
#include "all.h"
#if defined(U3_OS_osx)
#include <CommonCrypto/CommonDigest.h>
#else
#include <openssl/sha.h>
#endif
/* functions
*/
u3_noun
u3qe_sha1(u3_atom wid, u3_atom dat)
{
c3_assert(_(u3a_is_cat(wid)));
dat = u3qc_rev(3, wid, dat);
c3_y* fat_y = u3a_malloc(wid + 1);
u3r_bytes(0, wid, fat_y, dat);
{
c3_y dig_y[32];
#if defined(U3_OS_osx)
CC_SHA1_CTX ctx_h;
CC_SHA1_Init(&ctx_h);
CC_SHA1_Update(&ctx_h, fat_y, wid);
CC_SHA1_Final(dig_y, &ctx_h);
#else
SHA_CTX ctx_h;
SHA1_Init(&ctx_h);
SHA1_Update(&ctx_h, fat_y, wid);
SHA1_Final(dig_y, &ctx_h);
#endif
u3a_free(fat_y);
u3z(dat);
return u3kc_rev(3, 20, u3i_bytes(20, dig_y));
}
}
u3_noun
u3we_sha1(u3_noun cor)
{
u3_noun wid, dat;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &wid, u3x_sam_3, &dat, 0)) ||
(c3n == u3ud(wid)) ||
(c3n == u3a_is_cat(wid)) ||
(c3n == u3ud(dat)) )
{
return u3m_bail(c3__exit);
}
else {
return u3qe_sha1(wid, dat);
}
}

View File

@ -18,7 +18,7 @@
u3_atom b)
{
c3_assert(_(u3a_is_cat(a)));
c3_y* fat_y = c3_malloc(a + 1);
c3_y* fat_y = u3a_malloc(a + 1);
u3r_bytes(0, a, fat_y, b);
{
@ -36,7 +36,7 @@
SHA256_Update(&ctx_h, fat_y, a);
SHA256_Final(dig_y, &ctx_h);
#endif
free(fat_y);
u3a_free(fat_y);
return u3i_bytes(32, dig_y);
}
}
@ -53,7 +53,7 @@ u3_noun
u3qe_shax(u3_atom a)
{
c3_w met_w = u3r_met(3, a);
c3_y* fat_y = c3_malloc(met_w + 1);
c3_y* fat_y = u3a_malloc(met_w + 1);
u3r_bytes(0, met_w, fat_y, a);
{
@ -71,7 +71,7 @@ u3_noun
SHA256_Update(&ctx_h, fat_y, met_w);
SHA256_Final(dig_y, &ctx_h);
#endif
free(fat_y);
u3a_free(fat_y);
return u3i_bytes(32, dig_y);
}
}
@ -83,7 +83,7 @@ u3_noun
u3_atom b)
{
c3_assert(_(u3a_is_cat(a)));
c3_y* fat_y = c3_malloc(a + 1);
c3_y* fat_y = u3a_malloc(a + 1);
u3r_bytes(0, a, fat_y, b);
{
@ -101,7 +101,7 @@ u3_noun
SHA512_Update(&ctx_h, fat_y, a);
SHA512_Final(dig_y, &ctx_h);
#endif
free(fat_y);
u3a_free(fat_y);
return u3i_bytes(64, dig_y);
}
}

View File

@ -13,18 +13,65 @@
u3_noun lon,
u3_noun gil);
/* `u3qfu_felt_arm` is a helper function for
* u3qfu_felt. It handles the case in which the
* opal is for an arm, by creating a list of
* parent core types. These will be converted to
* a single `fork` type.
*/
static u3_noun
u3qfu_felt(u3_noun van,
u3_noun sut,
u3_noun lap)
u3qfu_felt_arm(u3_noun lis)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_cook("u3qfu_felt-felt", von, "felt");
if ( u3_nul == lis ) {
return u3_nul;
}
else {
u3_noun i_lis, t_lis, fot, typ;
u3x_cell(lis, &i_lis, &t_lis);
u3x_cell(i_lis, &typ, &fot);
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(lap),
0));
if ( (c3n == u3du(typ)) ||
(c3__core != u3h(typ)) ) {
return u3m_error("felt-core");
}
else {
u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ;
u3x_cell(u3t(typ), &p_typ, &q_typ);
u3x_trel(q_typ, &pq_typ, &qq_typ, &rq_typ);
u3_noun dox = u3nt(c3__core, u3k(qq_typ), u3k(q_typ));
return u3nc(dox, u3qfu_felt_arm(t_lis));
}
}
}
/* `u3qfu_felt` takes an opal, lap, and converts
* it to a type. The opal comes from the last
* limb of the wing processed by `+fond`. The
* type is used in +fond as the subject type of
* the next limb in the wing.
*/
static u3_noun
u3qfu_felt(u3_noun lap)
{
u3_noun lim, mil;
u3x_cell(lap, &lim, &mil);
if ( c3y == lim ) {
return u3k(mil);
}
else if ( c3n == lim ) {
u3_noun p_lap, q_lap, lis, hos;
u3x_cell(mil, &p_lap, &q_lap);
lis = u3qdi_tap(q_lap);
hos = u3qfu_felt_arm(lis);
u3z(lis);
return u3kf_fork(hos);
}
else {
u3m_bail(c3__exit);
}
}
static u3_noun
@ -190,15 +237,8 @@
u3_noun pu_zem = u3h(u_zem);
u3_noun qu_zem = u3t(u_zem);
u3_noun zut;
u3_noun mut;
u3_noun pro;
mut = u3nt(c3__core,
u3k(p_sut),
u3nt(u3nt(u3k(ppq_sut), u3k(qpq_sut), c3__gold),
u3k(qq_sut),
u3k(rq_sut)));
#if 1
if ( qpq_sut == c3__wet ) {
zut = u3nc(c3__wet, u3k(qu_zem));
@ -214,7 +254,7 @@
u3nc(u3nc(u3_nul, u3k(axe)), u3k(lon)),
u3nt(c3n,
u3qc_peg(2, pu_zem),
u3nt(u3nc(mut, zut), u3_nul, u3_nul)));
u3nt(u3nc(u3k(sut), zut), u3_nul, u3_nul)));
u3z(zem);
return pro;
@ -665,7 +705,7 @@
u3_noun qp_mor = u3t(p_mor); // opal
{
u3_noun ref = u3qfu_felt(van, sut, qp_mor);
u3_noun ref = u3qfu_felt(qp_mor);
u3_noun lon = u3k(pp_mor);
u3_noun heg = (c3y == u3du(i_hyp))
? u3k(i_hyp)

View File

@ -62,6 +62,7 @@
u3_noun gat)
{
u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ;
u3_noun ppq_typ, qpq_typ, rpq_typ;
u3_noun h_gat, t_gat;
if ( (c3n == u3du(typ)) || (c3__core != u3h(typ)) ) {
@ -69,12 +70,16 @@
} else if
( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) ||
(c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) ||
(c3n == u3r_trel(pq_typ, &ppq_typ, &qpq_typ, &rpq_typ)) ||
(c3n == u3r_cell(gat, &h_gat, &t_gat)) )
{
return u3m_bail(c3__fail);
} else {
u3_noun dox = u3nt
(c3__core, u3k(qq_typ), u3k(q_typ));
u3_noun dox = u3nt(c3__core,
u3k(qq_typ),
u3nt(u3nt(u3k(ppq_typ), u3k(qpq_typ), c3__gold),
u3k(qq_typ),
u3k(rq_typ)));
if ( (c3__ash == u3h(gat)) || (c3__dry == u3h(gat)) ) {
if ( (c3y == vet) &&

View File

@ -150,9 +150,6 @@
else if ( c3__wet == qpq_sut ) {
return u3r_sing(qrq_sut, qrq_ref);
}
else if ( c3y == u3r_sing(qrq_sut, qrq_ref) ) {
return c3y;
}
else {
u3_noun hud = u3nc(u3k(sut), u3k(ref));

View File

@ -88,11 +88,26 @@
u3_noun pec = u3qfu_peel(van, sut, way, rpq_sut);
u3_noun sam = u3h(pec);
u3_noun con = u3t(pec);
u3_atom tow;
if ( c3y == c3a(sam, con) ) {
if ( 1 == lat ) {
tow = 1;
} else {
tow = u3qc_cap(lat);
}
if ( (c3y == c3a(sam, con)) ||
((c3y == sam) && (tow == 2)) ||
((c3y == con) && (tow == 3)) )
{
pro = _cqfu_peek(van, p_sut, way, lat);
}
else {
if ( way != c3__read ) {
return u3m_error("payload-block");
}
u3_noun typ;
{
@ -120,6 +135,7 @@
}
u3z(pec);
u3z(tow);
}
else {
pro = c3__noun;

View File

@ -1,220 +0,0 @@
/* j/g/down.c
**
*/
#include "all.h"
#include <cmark.h>
#include <node.h>
#include <buffer.h>
static u3_noun node_to_noun(cmark_node * nod);
static u3_noun list_elems_to_noun(cmark_node * nod)
{
u3_noun elems = u3_nul;
cmark_node * child;
for ( child = nod->last_child; child; child = child->prev ) {
elems = u3nc(node_to_noun(child),elems);
}
return elems;
}
static u3_noun document_to_noun(cmark_node * nod)
{
return list_elems_to_noun(nod);
}
static u3_noun block_quote_to_noun(cmark_node * nod)
{
return u3nc(u3nc(c3__bloq,u3_nul),list_elems_to_noun(nod));
}
static u3_noun list_to_noun(cmark_node * nod)
{
return
u3nc(
u3nt(
c3__list,
__(nod->as.list.tight),
(nod->as.list.list_type == CMARK_BULLET_LIST)
? nod->as.list.bullet_char /* XX convert? */
: u3nc(nod->as.list.start,
(nod->as.list.delimiter == CMARK_PERIOD_DELIM)
? '.'
: ')')),
list_elems_to_noun(nod));
}
static u3_noun list_item_to_noun(cmark_node * nod)
{
return u3nc(u3nc(c3__item,u3_nul),list_elems_to_noun(nod));
}
static u3_noun code_block_to_noun(cmark_node * nod)
{
u3_atom str = u3i_string((c3_c *) nod->string_content.ptr); /* XX u3i_bytes */
u3_noun res =
u3nt(
c3__code,
nod->as.code.fenced
? u3nq(
u3_nul,
nod->as.code.fence_char,
nod->as.code.fence_length,
u3i_tape((c3_c *) nod->as.code.info.ptr)
)
: u3_nul,
u3qe_lore(str));
u3z(str);
return res;
}
static u3_noun html_to_noun(cmark_node * nod)
{
u3_atom str = u3i_string((c3_c *) nod->string_content.ptr); /* XX u3i_bytes */
u3_noun res = u3nc(c3__html, u3qe_lore(str));
u3z(str);
return res;
}
static u3_noun paragraph_to_noun(cmark_node * nod)
{
return u3nc(c3__para, list_elems_to_noun(nod));
}
static u3_noun header_to_noun(cmark_node * nod)
{
/* see also nod->as.header.setext */
return u3nt(c3__head, nod->as.header.level, list_elems_to_noun(nod));
}
static u3_noun hrule_to_noun(cmark_node * nod)
{
return u3nc(c3__hrul, u3_nul);
}
static u3_noun reference_def_to_noun(cmark_node * nod)
{
return u3nc(c3__defn, u3_nul);
}
static u3_noun text_to_noun(cmark_node * nod)
{
return u3nc(u3_blip, u3i_tape((c3_c *) cmark_chunk_to_cstr(&nod->as.literal)));
}
static u3_noun softbreak_to_noun(cmark_node * nod) // XXX
{
return u3nt(0, 10, 0);
}
static u3_noun linebreak_to_noun(cmark_node * nod)
{
return u3nc(c3__line, u3_nul);
}
static u3_noun inline_code_to_noun(cmark_node * nod)
{
return u3nc(c3__code, u3i_tape((c3_c *) cmark_chunk_to_cstr(&nod->as.literal)));
}
static u3_noun inline_html_to_noun(cmark_node * nod) // XXX
{
return u3nc(c3__htmt, u3i_string((c3_c *) cmark_chunk_to_cstr(&nod->as.literal)));
}
static u3_noun emph_to_noun(cmark_node * nod)
{
return u3nc(u3nc(c3__emph, c3n), list_elems_to_noun(nod));
}
static u3_noun strong_to_noun(cmark_node * nod)
{
return u3nc(u3nc(c3__emph, c3y), list_elems_to_noun(nod));
}
static u3_noun link_to_noun(cmark_node * nod)
{
return u3nc(u3nt(c3__link,
nod->as.link.url
? u3i_tape((c3_c *) nod->as.link.url)
: u3_nul,
nod->as.link.title
? u3nc(u3_nul, u3i_tape((c3_c *) nod->as.link.title))
: u3_nul),
list_elems_to_noun(nod));
}
static u3_noun image_to_noun(cmark_node * nod)
{
return u3nc(u3nt(c3__blot,
u3i_tape((c3_c *) nod->as.link.url),
nod->as.link.title
? u3nc(u3_nul, u3i_tape((c3_c *) nod->as.link.title))
: u3_nul),
list_elems_to_noun(nod));
}
static u3_noun node_to_noun(cmark_node * nod)
{
if (!nod) {
fprintf(stderr, "markdown null node");
return u3m_bail(c3__fail);
}
switch ( nod->type ) {
/* Block */
case CMARK_NODE_DOCUMENT: return document_to_noun(nod);
case CMARK_NODE_BLOCK_QUOTE: return block_quote_to_noun(nod);
case CMARK_NODE_LIST: return list_to_noun(nod);
case CMARK_NODE_LIST_ITEM: return list_item_to_noun(nod);
case CMARK_NODE_CODE_BLOCK: return code_block_to_noun(nod);
case CMARK_NODE_HTML: return html_to_noun(nod);
case CMARK_NODE_PARAGRAPH: return paragraph_to_noun(nod);
case CMARK_NODE_HEADER: return header_to_noun(nod);
case CMARK_NODE_HRULE: return hrule_to_noun(nod);
case CMARK_NODE_REFERENCE_DEF: return reference_def_to_noun(nod);
/* Inline */
case CMARK_NODE_TEXT: return text_to_noun(nod);
case CMARK_NODE_SOFTBREAK: return softbreak_to_noun(nod);
case CMARK_NODE_LINEBREAK: return linebreak_to_noun(nod);
case CMARK_NODE_INLINE_CODE: return inline_code_to_noun(nod);
case CMARK_NODE_INLINE_HTML: return inline_html_to_noun(nod);
case CMARK_NODE_EMPH: return emph_to_noun(nod);
case CMARK_NODE_STRONG: return strong_to_noun(nod);
case CMARK_NODE_LINK: return link_to_noun(nod);
case CMARK_NODE_IMAGE: return image_to_noun(nod);
default: fprintf(stderr, "bad markdown parsing");
return u3m_bail(c3__fail);
}
}
/* functions
*/
u3_noun
u3qg_down(u3_atom a)
{
c3_c *tex = u3r_string(a);
/* XX better strlen */
cmark_node * doc = cmark_parse_document(tex, strlen(tex));
u3_noun res = document_to_noun(doc);
cmark_node_free(doc);
// free out, tex?
return res;
}
u3_noun
u3wg_down(u3_noun cor)
{
u3_noun a;
if ( (u3_none == (a = u3r_at(u3x_sam, cor))) ||
(c3n == u3ud(a)) )
{
return u3m_bail(c3__exit);
} else {
return u3qg_down(a);
}
}

View File

@ -81,15 +81,6 @@ static u3j_core _141_hex_aes_d[] =
};
static c3_c* _141_hex_aes_ha[] = {0};
static u3j_harm _141_hex_down_mark_a[] = {{".2", u3wg_down, c3y}, {}};
static c3_c* _141_hex_down_mark_ha[] = {0};
static u3j_core _141_hex_down_d[] =
{ { "mark", 7, _141_hex_down_mark_a, 0, _141_hex_down_mark_ha },
{}
};
static c3_c* _141_hex_down_ha[] = {0};
static u3j_harm _141_hex_lore_a[] = {{".2", u3we_lore}, {}};
static c3_c* _141_hex_lore_ha[] = {0};
static u3j_harm _141_hex_loss_a[] = {{".2", u3we_loss}, {}};
@ -121,15 +112,78 @@ static u3j_core _141_hex_coed_d[] =
};
static c3_c* _141_hex_coed_ha[] = {0};
static u3j_core _141_hex_d[] =
{ { "down", 8063, 0, _141_hex_down_d, _141_hex_down_ha },
static u3j_harm _141_hex_hmac_hmac_a[] = {{".2", u3we_hmac}, {}};
static c3_c* _141_hex_hmac_hmac_ha[] = {0};
static u3j_core _141_hex_hmac_d[] =
{ { "hmac", 7, _141_hex_hmac_hmac_a, 0, _141_hex_hmac_hmac_ha },
{}
};
static c3_c* _141_hex_hmac_ha[] = {0};
{ "lore", 63, _141_hex_lore_a, 0, _141_hex_lore_ha },
static u3j_harm _141_hex_argon2_a[] = {{".2", u3we_argon2}, {}};
static c3_c* _141_hex_argon2_ha[] = {0};
static u3j_core _141_hex_argon_d[] =
{ { "argon2", 7, _141_hex_argon2_a, 0, _141_hex_argon2_ha },
{}
};
static c3_c* _141_hex_argon_ha[] = {0};
static u3j_harm _141_hex_secp_make_a[] = {{".2", u3we_make, c3y}, {}};
static c3_c* _141_hex_secp_make_ha[] = {0};
static u3j_harm _141_hex_secp_sign_a[] = {{".2", u3we_sign, c3y}, {}};
static c3_c* _141_hex_secp_sign_ha[] = {0};
static u3j_harm _141_hex_secp_reco_a[] = {{".2", u3we_reco, c3y}, {}};
static c3_c* _141_hex_secp_reco_ha[] = {0};
static u3j_core _141_hex_secp_secp_helper_d[] =
{ { "make-k", 7, _141_hex_secp_make_a, 0, _141_hex_secp_make_ha },
{ "ecdsa-raw-sign", 7, _141_hex_secp_sign_a, 0, _141_hex_secp_sign_ha },
{ "ecdsa-raw-recover", 7, _141_hex_secp_reco_a, 0, _141_hex_secp_reco_ha },
{}
};
static c3_c* _141_hex_secp_secp_helper_ha[] = {0};
static u3j_core _141_hex_secp_secp_d[] =
{ { "helper", 7, 0, _141_hex_secp_secp_helper_d, _141_hex_secp_secp_helper_ha },
{}
};
static c3_c* _141_hex_secp_secp_ha[] = {0};
static u3j_core _141_hex_secp_d[] =
{ { "secp", 7, 0, _141_hex_secp_secp_d, _141_hex_secp_secp_ha },
{}
};
static c3_c* _141_hex_secp_ha[] = {0};
static u3j_harm _141_hex_blake2b_a[] = {{".2", u3we_blake, c3y}, {}};
static c3_c* _141_hex_blake2b_ha[] = {0};
static u3j_core _141_hex_blake_d[] =
{ { "blake2b", 7, _141_hex_blake2b_a, 0, _141_hex_blake2b_ha },
{}
};
static c3_c* _141_hex_blake_ha[] = {0};
static u3j_harm _141_hex_ripemd_160_a[] = {{".2", u3we_ripe, c3y}, {}};
static c3_c* _141_hex_ripemd_160_ha[] = {0};
static u3j_core _141_hex_ripe_d[] =
{ { "ripemd160", 7, _141_hex_ripemd_160_a, 0, _141_hex_ripemd_160_ha },
{}
};
static c3_c* _141_hex_ripe_ha[] = {0};
static u3j_core _141_hex_d[] =
{ { "lore", 63, _141_hex_lore_a, 0, _141_hex_lore_ha },
{ "loss", 63, _141_hex_loss_a, 0, _141_hex_loss_ha },
{ "lune", 127, _141_hex_lune_a, 0, _141_hex_lune_ha },
{ "coed", 63, 0, _141_hex_coed_d, _141_hex_coed_ha },
{ "aes", 31, 0, _141_hex_aes_d, _141_hex_aes_ha },
{ "hmac", 31, 0, _141_hex_hmac_d, _141_hex_hmac_ha },
{ "argon", 15, 0, _141_hex_argon_d, _141_hex_argon_ha },
{ "blake", 15, 0, _141_hex_blake_d, _141_hex_blake_ha },
{ "ripemd", 15, 0, _141_hex_ripe_d, _141_hex_ripe_ha },
{ "secp", 15, 0, _141_hex_secp_d, _141_hex_secp_ha },
{}
};
static c3_c* _141_hex_ha[] = {0};
@ -168,11 +222,8 @@ static c3_c* _141_pen_loot_ha[] = {0};
static u3j_harm _141_pen__ut_crop_a[] = {{".2", u3wfu_crop}, {}};
static c3_c* _141_pen__ut_crop_ha[] = {0};
// XX figure out why this is disabled
// static u3j_harm _141_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}};
// static c3_c* _141_pen__ut_fire_ha[] = {0};
static u3j_harm _141_pen__ut_fire_a[] = {{".2", u3wfu_fire}, {}};
static c3_c* _141_pen__ut_fire_ha[] = {0};
static u3j_harm _141_pen__ut_fond_a[] = {{".2", u3wfu_fond}, {}};
static c3_c* _141_pen__ut_fond_ha[] = {0};
static u3j_harm _141_pen__ut_fish_a[] = {{".2", u3wfu_fish}, {}};
@ -200,7 +251,7 @@ static u3j_core _141_pen__ut_d[] =
{
{ "crop", 7, _141_pen__ut_crop_a, 0, _141_pen__ut_crop_ha },
{ "fond", 7, _141_pen__ut_fond_a, 0, _141_pen__ut_fond_ha },
// { "fire", 7, _141_pen__ut_fire_a, 0, _141_pen__ut_fire_ha },
{ "fire", 7, _141_pen__ut_fire_a, 0, _141_pen__ut_fire_ha },
{ "fish", 7, _141_pen__ut_fish_a, 0, _141_pen__ut_fish_ha },
{ "fuse", 7, _141_pen__ut_fuse_a, 0, _141_pen__ut_fuse_ha },
{ "mint", 7, _141_pen__ut_mint_a, 0, _141_pen__ut_mint_ha },
@ -668,6 +719,14 @@ static u3j_core _141_tri__og_d[] =
};
static c3_c* _141_tri__og_ha[] = {0};
static u3j_harm _141_tri__sha_sha1_a[] = {{".2", u3we_sha1}, {}};
static c3_c* _141_tri__sha_sha1_ha[] = {0};
static u3j_core _141_tri__sha_d[] =
{ { "sha1", 7, _141_tri__sha_sha1_a, 0, _141_tri__sha_sha1_ha },
{}
};
static c3_c* _141_tri__sha_ha[] = {0};
static u3j_harm _141_tri_shax_a[] = {{".2", u3we_shax}, {}};
static c3_c* _141_tri_shax_ha[] = {0};
static u3j_harm _141_tri_shay_a[] = {{".2", u3we_shay}, {}};
@ -686,6 +745,7 @@ static u3j_core _141_tri_d[] =
{ "rh", 7, 0, _141_tri__rh_d, _141_tri__rh_ha },
{ "og", 7, 0, _141_tri__og_d, _141_tri__og_ha },
{ "sha", 7, 0, _141_tri__sha_d, _141_tri__sha_ha },
{ "shax", 7, _141_tri_shax_a, 0, _141_tri_shax_ha },
{ "shay", 7, _141_tri_shay_a, 0, _141_tri_shay_ha },
{ "shas", 7, _141_tri_shas_a, 0, _141_tri_shas_ha },
@ -726,11 +786,8 @@ static u3j_harm _141_two_slag_a[] = {{".2", u3wb_slag, c3y}, {}};
static c3_c* _141_two_slag_ha[] = {0};
static u3j_harm _141_two_snag_a[] = {{".2", u3wb_snag, c3y}, {}};
static c3_c* _141_two_snag_ha[] = {0};
// https://github.com/urbit/urbit/issues/387
// static u3j_harm _141_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}};
// static c3_c* _141_two_sort_ha[] = {0};
static u3j_harm _141_two_sort_a[] = {{".2", u3wb_sort, c3y}, {}};
static c3_c* _141_two_sort_ha[] = {0};
static u3j_harm _141_two_turn_a[] = {{".2", u3wb_turn, c3y}, {}};
static c3_c* _141_two_turn_ha[] = {0};
static u3j_harm _141_two_weld_a[] = {{".2", u3wb_weld, c3y}, {}};
@ -780,10 +837,14 @@ static u3j_harm _141_two_rap_a[] = {{".2", u3wc_rap, c3y}, {}};
static c3_c* _141_two_rap_ha[] = {0};
static u3j_harm _141_two_rep_a[] = {{".2", u3wc_rep, c3y}, {}};
static c3_c* _141_two_rep_ha[] = {0};
static u3j_harm _141_two_rev_a[] = {{".2", u3wc_rev, c3y}, {}};
static c3_c* _141_two_rev_ha[] = {0};
static u3j_harm _141_two_rip_a[] = {{".2", u3wc_rip, c3y}, {}};
static c3_c* _141_two_rip_ha[] = {0};
static u3j_harm _141_two_rsh_a[] = {{".2", u3wc_rsh, c3y}, {}};
static c3_c* _141_two_rsh_ha[] = {0};
static u3j_harm _141_two_swp_a[] = {{".2", u3wc_swp, c3y}, {}};
static c3_c* _141_two_swp_ha[] = {0};
static u3j_harm _141_two_sqt_a[] = {{".2", u3wc_sqt, c3y}, {}};
static c3_c* _141_two_sqt_ha[] = {0};
static u3j_harm _141_two_vor_a[] = {{".2", u3wc_vor, c3y}, {}};
@ -793,6 +854,8 @@ static c3_c* _141_two_xeb_ha[] = {0};
static u3j_harm _141_two__in_bif_a[] = {{".2", u3wdi_bif}, {}};
static c3_c* _141_two__in_bif_ha[] = {0};
static u3j_harm _141_two__in_del_a[] = {{".2", u3wdi_del}, {}};
static c3_c* _141_two__in_del_ha[] = {0};
static u3j_harm _141_two__in_dif_a[] = {{".2", u3wdi_dif}, {}};
static c3_c* _141_two__in_dif_ha[] = {0};
static u3j_harm _141_two__in_gas_a[] = {{".2", u3wdi_gas}, {}};
@ -816,6 +879,7 @@ static c3_c* _141_two_xeb_ha[] = {0};
static c3_c* _141_two__in_uni_ha[] = {0};
static u3j_core _141_two__in_d[] =
{ { "bif", 7, _141_two__in_bif_a, 0, _141_two__in_bif_ha },
{ "del", 7, _141_two__in_del_a, 0, _141_two__in_del_ha },
{ "dif", 7, _141_two__in_dif_a, 0, _141_two__in_dif_ha },
{ "gas", 7, _141_two__in_gas_a, 0, _141_two__in_gas_ha },
{ "has", 7, _141_two__in_has_a, 0, _141_two__in_has_ha },
@ -831,6 +895,8 @@ static c3_c* _141_two__in_ha[] = {0};
static u3j_harm _141_two__by_bif_a[] = {{".2", u3wdb_bif, c3y}, {}};
static c3_c* _141_two__by_bif_ha[] = {0};
static u3j_harm _141_two__by_del_a[] = {{".2", u3wdb_del, c3y}, {}};
static c3_c* _141_two__by_del_ha[] = {0};
static u3j_harm _141_two__by_dif_a[] = {{".2", u3wdb_dif, c3y}, {}};
static c3_c* _141_two__by_dif_ha[] = {0};
static u3j_harm _141_two__by_gas_a[] = {{".2", u3wdb_gas, c3y}, {}};
@ -844,6 +910,8 @@ static c3_c* _141_two__in_ha[] = {0};
// static u3j_harm _141_two__by_int_a[] = {{".2", u3wdb_int, c3y}, {}};
// static c3_c* _141_two__by_int_ha[] = {0};
static u3j_harm _141_two__by_jab_a[] = {{".2", u3wdb_jab, c3y}, {}};
static c3_c* _141_two__by_jab_ha[] = {0};
static u3j_harm _141_two__by_put_a[] = {{".2", u3wdb_put, c3y}, {}};
static c3_c* _141_two__by_put_ha[] = {0};
static u3j_harm _141_two__by_tap_a[] = {{".2", u3wdb_tap, c3y}, {}};
@ -855,11 +923,13 @@ static c3_c* _141_two__in_ha[] = {0};
static u3j_core _141_two__by_d[] =
{ { "bif", 7, _141_two__by_bif_a, 0, _141_two__by_bif_ha },
{ "del", 7, _141_two__by_del_a, 0, _141_two__by_del_ha },
{ "dif", 7, _141_two__by_dif_a, 0, _141_two__by_dif_ha },
{ "gas", 7, _141_two__by_gas_a, 0, _141_two__by_gas_ha },
{ "get", 7, _141_two__by_get_a, 0, _141_two__by_get_ha },
{ "has", 7, _141_two__by_has_a, 0, _141_two__by_has_ha },
// { "int", 7, _141_two__by_int_a, 0, _141_two__by_int_ha },
{ "jab", 7, _141_two__by_jab_a, 0, _141_two__by_jab_ha },
{ "put", 7, _141_two__by_put_a, 0, _141_two__by_put_ha },
{ "tap", 7, _141_two__by_tap_a, 0, _141_two__by_tap_ha },
// { "uni", 7, _141_two__by_uni_a, 0, _141_two__by_uni_ha },
@ -894,7 +964,7 @@ static u3j_core _141_two_d[] =
{ "scag", 7, _141_two_scag_a, 0, _141_two_scag_ha },
{ "slag", 7, _141_two_slag_a, 0, _141_two_slag_ha },
{ "snag", 7, _141_two_snag_a, 0, _141_two_snag_ha },
// { "sort", 7, _141_two_sort_a, 0, _141_two_sort_ha },
{ "sort", 7, _141_two_sort_a, 0, _141_two_sort_ha },
{ "turn", 7, _141_two_turn_a, 0, _141_two_turn_ha },
{ "weld", 7, _141_two_weld_a, 0, _141_two_weld_ha },
@ -921,8 +991,10 @@ static u3j_core _141_two_d[] =
{ "muk", 59, _141_two_muk_a, 0, _141_two_muk_ha },
{ "rap", 7, _141_two_rap_a, 0, _141_two_rap_ha },
{ "rep", 7, _141_two_rep_a, 0, _141_two_rep_ha },
{ "rev", 7, _141_two_rev_a, 0, _141_two_rev_ha },
{ "rip", 7, _141_two_rip_a, 0, _141_two_rip_ha },
{ "rsh", 7, _141_two_rsh_a, 0, _141_two_rsh_ha },
{ "swp", 7, _141_two_swp_a, 0, _141_two_swp_ha },
{ "rub", 7, _141_two_rub_a, 0, _141_two_rub_ha },
{ "peg", 7, _141_two_peg_a, 0, _141_two_peg_ha },
{ "pow", 7, _141_two_pow_a, 0, _141_two_pow_ha },

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@
/* j/6/cell.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_cell(u3_noun hed,
u3_noun tal)
{
if ( (c3__void == hed) || (c3__void == tal) ) {
return c3__void;
} else {
return u3nt(c3__cell, u3k(hed), u3k(tal));
}
}
u3_noun
u3wz_cell(u3_noun cor)
{
u3_noun hed, tal;
if ( c3n == u3r_mean(cor, u3x_sam_2, &hed, u3x_sam_3, &tal, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_cell(hed, tal);
}
}

View File

@ -1,70 +0,0 @@
/* j/6/comb.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_comb(u3_noun mal,
u3_noun buz)
{
if ( (u3_none == mal) || (u3_none == buz) ) {
return u3_none;
}
else {
u3_noun p_mal, q_mal, p_buz, q_buz, pp_buz, pq_buz;
if ( (c3y == u3r_p(mal, 0, &p_mal)) && (0 != p_mal) ) {
if ( (c3y == u3r_p(buz, 0, &p_buz)) && (0 != p_buz) ) {
return u3nc(0,
u3qc_peg(p_mal, p_buz));
}
else if ( c3y == u3r_pq(buz, 2, &p_buz, &q_buz) &&
c3y == u3r_p(p_buz, 0, &pp_buz) &&
c3y == u3r_p(q_buz, 0, &pq_buz) )
{
return u3nt(2,
u3nc(0,
u3qc_peg(p_mal, pp_buz)),
u3nc(0,
u3qc_peg(p_mal, pq_buz)));
}
else return u3nt(7,
u3k(mal),
u3k(buz));
}
#if 1
else if ( (c3y == u3r_bush(mal, &p_mal, &q_mal)) &&
(c3y == u3du(p_mal)) &&
(c3y == u3du(q_mal)) &&
(0 == u3h(q_mal)) &&
(1 == u3t(q_mal)) )
{
return u3nt(8,
u3k(p_mal),
u3k(buz));
}
#endif
else if ( (c3y == u3r_p(buz, 0, &p_buz)) &&
(c3y == u3r_sing(1, p_buz)) )
{
return u3k(mal);
}
else return u3nt(7,
u3k(mal),
u3k(buz));
}
}
u3_noun
u3wz_comb(u3_noun cor)
{
u3_noun mal, buz;
if ( c3n == u3r_mean(cor, u3x_sam_2, &mal, u3x_sam_3, &buz, 0) ) {
return u3_none;
} else {
return u3qz_comb(mal, buz);
}
}

View File

@ -1,52 +0,0 @@
/* j/6/cons.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_cons(u3_noun vur,
u3_noun sed)
{
u3_noun p_vur, p_sed;
if ( c3y == u3r_p(vur, 1, &p_vur) &&
c3y == u3r_p(sed, 1, &p_sed) ) {
return u3nt(1,
u3k(p_vur),
u3k(p_sed));
}
else if ( c3y == u3r_p(vur, 0, &p_vur) &&
c3y == u3r_p(sed, 0, &p_sed) &&
!(c3y == u3r_sing(1, p_vur)) &&
!(c3y == u3r_sing(p_vur, p_sed)) &&
(0 == u3r_nord(p_vur, p_sed)) )
{
u3_atom fub = u3qa_div(p_vur, 2);
u3_atom nof = u3qa_div(p_sed, 2);
if ( c3y == u3r_sing(fub, nof) ) {
u3z(nof);
return u3nc(0, fub);
}
else {
u3z(fub);
u3z(nof);
}
}
return u3nc(u3k(vur), u3k(sed));
}
u3_noun
u3wz_cons(u3_noun cor)
{
u3_noun vur, sed;
if ( c3n == u3r_mean(cor, u3x_sam_2, &vur, u3x_sam_3, &sed, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_cons(vur, sed);
}
}

View File

@ -1,42 +0,0 @@
/* j/6/core.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_core(u3_noun pac,
u3_noun con)
{
if ( (c3__void == pac) ) {
return c3__void;
} else {
{
u3_noun p_con, q_con, r_con, hr_con, tr_con;
u3r_trel(con, &p_con, &q_con, &r_con);
u3r_cell(r_con, &hr_con, &tr_con);
if ( (c3y == u3du(hr_con)) &&
(u3_nul == u3h(hr_con)) &&
(u3_nul == u3t(hr_con)) )
{
fprintf(stderr, "old core\r\n");
abort();
}
}
return u3nt(c3__core, u3k(pac), u3k(con));
}
}
u3_noun
u3wz_core(u3_noun cor)
{
u3_noun pac, con;
if ( c3n == u3r_mean(cor, u3x_sam_2, &pac, u3x_sam_3, &con, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_core(pac, con);
}
}

View File

@ -1,31 +0,0 @@
/* j/6/face.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_face(u3_noun sag,
u3_noun tip)
{
if ( c3__void == tip ) {
return c3__void;
}
else return u3nt(c3__face,
u3k(sag),
u3k(tip));
}
u3_noun
u3wz_face(u3_noun cor)
{
u3_noun sag, tip;
if ( c3n == u3r_mean(cor, u3x_sam_2, &sag, u3x_sam_3, &tip, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_face(sag, tip);
}
}

View File

@ -1,35 +0,0 @@
/* j/6/fine.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_fine(u3_noun fuv,
u3_noun lup,
u3_noun mar)
{
if ( (c3__void == lup) || (c3__void == mar) ) {
return c3__void;
} else {
return u3nq(c3__fine,
u3k(fuv),
u3k(lup),
u3k(mar));
}
}
u3_noun
u3wz_fine(u3_noun cor)
{
u3_noun fuv, lup, mar;
if ( c3n == u3r_mean(cor, u3x_sam_2, &fuv,
u3x_sam_6, &lup,
u3x_sam_7, &mar, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_fine(fuv, lup, mar);
}
}

View File

@ -1,67 +0,0 @@
/* j/6/fitz.c
**
*/
#include "all.h"
/* functions
*/
static u3_noun
_fitz_fiz(u3_noun yaz,
u3_noun wix)
{
c3_w yaz_w = u3r_met(3, yaz);
c3_w wix_w = u3r_met(3, wix);
c3_y yaz_y, wix_y;
yaz_y = (0 == yaz_w) ? 0 : u3r_byte((yaz_w - 1), yaz);
if ( (yaz_y < 'A') || (yaz_y > 'Z') ) yaz_y = 0;
wix_y = (0 == wix_w) ? 0 : u3r_byte((wix_w - 1), wix);
if ( (wix_y < 'A') || (wix_y > 'Z') ) wix_y = 0;
if ( yaz_y && wix_y ) {
if ( !wix_y || (wix_y > yaz_y) ) {
return c3n;
}
}
return c3y;
}
u3_noun
u3qz_fitz(u3_noun yaz,
u3_noun wix)
{
c3_w i_w, met_w = c3_min(u3r_met(3, yaz), u3r_met(3, wix));
if ( c3n == _fitz_fiz(yaz, wix) ) {
return c3n;
}
for ( i_w = 0; i_w < met_w; i_w++ ) {
c3_y yaz_y = u3r_byte(i_w, yaz);
c3_y wix_y = u3r_byte(i_w, wix);
if ( (yaz_y >= 'A') && (yaz_y <= 'Z') ) yaz_y = 0;
if ( (wix_y >= 'A') && (wix_y <= 'Z') ) wix_y = 0;
if ( yaz_y && wix_y && (yaz_y != wix_y) ) {
return c3n;
}
}
return c3y;
}
u3_noun
u3wz_fitz(u3_noun cor)
{
u3_noun yaz, wix;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &yaz, u3x_sam_3, &wix, 0)) ||
(c3n == u3ud(yaz)) ||
(c3n == u3ud(wix)) )
{
return u3m_bail(c3__fail);
} else {
return u3qz_fitz(yaz, wix);
}
}

View File

@ -1,44 +0,0 @@
/* j/6/flan.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_flan(u3_noun bos,
u3_noun nif)
{
if ( c3y == u3r_sing(1, u3h(bos)) ) {
if ( (u3_nul == u3t(bos)) ) {
return u3k(nif);
}
else return u3k(bos);
}
else {
if ( c3y == u3r_sing(1, u3h(nif)) ) {
if ( (u3_nul == u3t(nif)) ) {
return u3k(bos);
}
else return u3k(nif);
}
else {
return u3nq(6,
u3k(bos),
u3k(nif),
u3nc(1, c3n));
}
}
}
u3_noun
u3wz_flan(u3_noun cor)
{
u3_noun bos, nif;
if ( c3n == u3r_mean(cor, u3x_sam_2, &bos, u3x_sam_3, &nif, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_flan(bos, nif);
}
}

View File

@ -1,39 +0,0 @@
/* j/6/flip.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_flip(u3_noun hel)
{
if ( c3y == u3r_sing(1, u3h(hel)) ) {
if ( (c3y == u3t(hel)) ) {
return u3nc(1, c3n);
}
else {
c3_assert((c3n == u3t(hel)));
return u3nc(1, c3y);
}
}
else {
return u3nq(6,
u3k(hel),
u3nc(1, c3n),
u3nc(1, c3y));
}
}
u3_noun
u3wz_flip(u3_noun cor)
{
u3_noun hel;
if ( u3_none == (hel = u3r_at(u3x_sam, cor)) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_flip(hel);
}
}

View File

@ -1,44 +0,0 @@
/* j/6/flor.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_flor(u3_noun bos,
u3_noun nif)
{
if ( c3y == u3r_sing(1, u3h(bos)) ) {
if ( (u3_nul == u3t(bos)) ) {
return u3k(bos);
}
else return u3k(nif);
}
else {
if ( c3y == u3r_sing(1, u3h(nif)) ) {
if ( (u3_nul == u3t(nif)) ) {
return u3k(nif);
}
else return u3k(bos);
}
else {
return u3nq(6,
u3k(bos),
u3nc(1, c3y),
u3k(nif));
}
}
}
u3_noun
u3wz_flor(u3_noun cor)
{
u3_noun bos, nif;
if ( c3n == u3r_mean(cor, u3x_sam_2, &bos, u3x_sam_3, &nif, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_flor(bos, nif);
}
}

View File

@ -1,78 +0,0 @@
/* j/6/fork.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_forq(u3_noun hoz,
u3_noun bur)
{
if ( c3y == u3r_sing(hoz, bur) ) {
return u3k(hoz);
}
else if ( c3__void == bur ) {
return u3k(hoz);
}
else if ( c3__void == hoz ) {
return u3k(bur);
}
else return u3kz_fork(u3nt(u3k(hoz), u3k(bur), u3_nul));
}
u3_noun
u3qz_fork(u3_noun yed)
{
u3_noun lez = u3_nul;
while ( u3_nul != yed ) {
u3_noun i_yed = u3h(yed);
if ( c3__void != i_yed ) {
if ( (c3y == u3du(i_yed)) && (c3__fork == u3h(i_yed)) ) {
lez = u3kdi_uni(lez, u3k(u3t(i_yed)));
}
else {
lez = u3kdi_put(lez, u3k(i_yed));
}
}
yed = u3t(yed);
}
if ( u3_nul == lez ) {
return c3__void;
}
else if ( (u3_nul == u3h(u3t(lez))) && (u3_nul == u3t(u3t(lez))) ) {
u3_noun ret = u3k(u3h(lez));
u3z(lez);
return ret;
}
else {
return u3nc(c3__fork, lez);
}
}
u3_noun
u3wz_fork(u3_noun cor)
{
u3_noun yed;
if ( c3n == u3r_mean(cor, u3x_sam, &yed, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_fork(yed);
}
}
u3_noun
u3kz_fork(u3_noun yed)
{
u3_noun ret = u3qz_fork(yed);
u3z(yed);
return ret;
}

View File

@ -1,136 +0,0 @@
/* j/6/hike.c
**
*/
#include "all.h"
/* internal tools
*/
/* _lily_hike_belt_root(): convert (pac) to a list of root tools.
*/
static u3_noun
_lily_hike_belt_root(u3_noun pac)
{
if ( (u3_nul == pac) ) {
return u3_nul;
}
else {
u3_atom axis = u3h(u3h(pac));
u3_noun tool = u3t(u3h(pac));
u3_noun list_tool = _lily_hike_belt_root(u3t(pac));
if ( c3y == u3r_sing(1, axis) ) {
return u3nc(u3k(tool),
list_tool);
}
else return list_tool;
}
}
/* _lily_hike_belt_l(): factor (pac) left.
*/
static u3_noun
_lily_hike_belt_l(u3_noun pac)
{
if ( (u3_nul == pac) ) {
return u3_nul;
}
else {
u3_atom axis = u3h(u3h(pac));
u3_noun tool = u3t(u3h(pac));
u3_noun belt_l = _lily_hike_belt_l(u3t(pac));
{
if ( (1 != axis) &&
(c3y == u3r_sing(2, u3qc_cap(axis))) )
{
u3_atom axis_tap = u3qc_mas(axis);
return u3nc(u3nc(u3k(axis_tap),
u3k(tool)),
belt_l);
}
else return belt_l;
}
}
}
/* _lily_hike_belt_r(): factor (pac) right.
*/
static u3_noun
_lily_hike_belt_r(u3_noun pac)
{
if ( (u3_nul == pac) ) {
return u3_nul;
}
else {
u3_atom axis = u3h(u3h(pac));
u3_noun tool = u3t(u3h(pac));
u3_noun belt_r = _lily_hike_belt_r(u3t(pac));
{
if ( (1 != axis) &&
(c3y == u3r_sing(3, u3qc_cap(axis))) )
{
u3_atom axis_tap = u3qc_mas(axis);
return u3nc(u3nc(u3k(axis_tap),
u3k(tool)),
belt_r);
}
else return belt_r;
}
}
}
/* functions
*/
u3_noun
u3qz_hike(u3_noun axe,
u3_noun pac)
{
if ( (u3_nul == pac) ) {
return u3nc(0, u3k(axe));
}
else {
u3_noun zet = _lily_hike_belt_root(pac);
if ( u3_nul != zet ) {
u3_noun fol = u3k(u3h(zet));
u3z(zet);
return fol;
}
else {
u3_noun tum = _lily_hike_belt_l(pac);
u3_noun gam = _lily_hike_belt_r(pac);
u3_noun hax = u3qc_peg(axe, 2);
u3_noun moz = u3qc_peg(axe, 3);
u3_noun zip = u3qz_hike(hax, tum);
u3_noun dof = u3qz_hike(moz, gam);
u3_noun fol = u3qz_cons(zip, dof);
u3z(tum);
u3z(gam);
u3z(hax);
u3z(moz);
u3z(zip);
u3z(dof);
return fol;
}
}
}
u3_noun
u3wz_hike(u3_noun cor)
{
u3_noun axe, pac;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &axe, u3x_sam_3, &pac, 0)) ||
(c3n == u3ud(axe)) )
{
return u3m_bail(c3__fail);
} else {
return u3qz_hike(axe, pac);
}
}

View File

@ -1,32 +0,0 @@
/* j/6/help.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_hint(u3_noun sag,
u3_noun tip)
{
if ( c3__void == tip ) {
return c3__void;
}
if ( c3__noun == tip ) {
return c3__noun;
}
else return u3nt(c3__hint, u3k(sag), u3k(tip));
}
u3_noun
u3wz_hint(u3_noun cor)
{
u3_noun sag, tip;
if ( c3n == u3r_mean(cor, u3x_sam_2, &sag, u3x_sam_3, &tip, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_hint(sag, tip);
}
}

View File

@ -1,134 +0,0 @@
/* j/6/look.c
**
*/
#include "all.h"
/* internals
*/
static u3_noun
_look_in(u3_noun cog,
u3_noun dab,
u3_atom axe)
{
if ( u3_nul == dab ) {
return u3_nul;
}
else {
u3_noun n_dab, l_dab, r_dab;
u3r_trel(dab, &n_dab, &l_dab, &r_dab);
if ( c3n == u3du(n_dab) ) {
// return u3m_bail(c3__fail);
fprintf(stderr, "bad look\r\n");
return u3m_bail(c3__exit) ;
}
else {
u3_noun pn_dab = u3h(n_dab);
u3_noun qn_dab = u3t(n_dab);
if ( (u3_nul == l_dab) && (u3_nul == r_dab) ) {
if ( (c3y == u3du(qn_dab)) &&
(c3y == u3r_sing(cog, pn_dab)) ) {
return u3nt(u3_nul,
u3k(axe),
u3k(qn_dab));
}
else {
return u3_nul;
}
}
else if ( (u3_nul == l_dab) ) {
if ( (c3y == u3du(qn_dab)) &&
(c3y == u3r_sing(cog, pn_dab)) ) {
return u3nt(u3_nul,
u3qc_peg(axe, 2),
u3k(qn_dab));
}
else {
if ( c3y == u3qc_gor(cog, pn_dab) ) {
return u3_nul;
}
else {
u3_noun pro;
axe = u3qc_peg(axe, 3);
pro = _look_in(cog, r_dab, axe);
u3z(axe);
return pro;
}
}
}
else if ( (u3_nul == r_dab) ) {
if ( (c3y == u3du(qn_dab)) &&
(c3y == u3r_sing(cog, pn_dab)) ) {
return u3nt(u3_nul,
u3qc_peg(axe, 2),
u3k(qn_dab));
}
else {
if ( c3y == u3qc_gor(cog, pn_dab) ) {
u3_noun pro;
axe = u3qc_peg(axe, 3);
pro = _look_in(cog, l_dab, axe);
u3z(axe);
return pro;
}
else {
return u3_nul;
}
}
}
else {
if ( (c3y == u3du(qn_dab)) &&
(c3y == u3r_sing(cog, pn_dab)) ) {
return u3nt(u3_nul,
u3qc_peg(axe, 2),
u3k(qn_dab));
}
else {
if ( c3y == u3qc_gor(cog, pn_dab) ) {
u3_noun pro;
axe = u3qc_peg(axe, 6);
pro = _look_in(cog, l_dab, axe);
u3z(axe);
return pro;
}
else {
u3_noun pro;
axe = u3qc_peg(axe, 7);
pro = _look_in(cog, r_dab, axe);
u3z(axe);
return pro;
}
}
}
}
}
}
/* functions
*/
u3_noun
u3qz_look(u3_noun cog,
u3_noun dab)
{
return _look_in(cog, dab, 1);
}
u3_noun
u3wz_look(u3_noun cor)
{
u3_noun cog, dab;
if ( c3n == u3r_mean(cor, u3x_sam_2, &cog, u3x_sam_3, &dab, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_look(cog, dab);
}
}

View File

@ -1,133 +0,0 @@
/* j/6/loot.c
**
*/
#include "all.h"
/* internals
*/
static u3_noun
_loot_in(u3_noun cog,
u3_noun dom,
u3_atom axe)
{
if ( u3_nul == dom ) {
return u3_nul;
}
else {
u3_noun n_dom, l_dom, r_dom;
u3r_trel(dom, &n_dom, &l_dom, &r_dom);
if ( c3n == u3du(n_dom) ) {
return u3m_bail(c3__fail);
}
else {
u3_noun qn_dom = u3t(n_dom);
u3_noun yep = u3qz_look(cog, qn_dom);
if ( (u3_nul == l_dom) && (u3_nul == r_dom) ) {
if ( u3_nul == yep ) {
return u3_nul;
} else {
u3_noun u_yep = u3t(yep);
u3_noun pro;
pro = u3nt(u3_nul, u3qc_peg(axe, u3h(u_yep)), u3k(u3t(u_yep)));
u3z(yep);
return pro;
}
}
else if ( (u3_nul == l_dom) ) {
if ( u3_nul == yep ) {
u3_noun nax = u3qc_peg(axe, 3);
u3_noun pro;
pro = _loot_in(cog, r_dom, nax);
u3z(nax);
return pro;
}
else {
u3_noun u_yep = u3t(yep);
u3_noun nax = u3qc_peg(axe, 2);
u3_noun pro;
pro = u3nt(u3_nul, u3qc_peg(nax, u3h(u_yep)), u3k(u3t(u_yep)));
u3z(nax);
u3z(yep);
return pro;
}
}
else if ( (u3_nul == r_dom) ) {
if ( u3_nul == yep ) {
u3_noun nax = u3qc_peg(axe, 3);
u3_noun pro;
pro = _loot_in(cog, l_dom, nax);
u3z(nax);
return pro;
}
else {
u3_noun u_yep = u3t(yep);
u3_noun nax = u3qc_peg(axe, 2);
u3_noun pro;
pro = u3nt(u3_nul, u3qc_peg(nax, u3h(u_yep)), u3k(u3t(u_yep)));
u3z(nax);
u3z(yep);
return pro;
}
}
else {
if ( u3_nul == yep ) {
u3_noun nax = u3qc_peg(axe, 6);
u3_noun pey;
pey = _loot_in(cog, l_dom, nax);
u3z(nax);
if ( u3_nul != pey ) {
return pey;
}
else {
u3_noun nax = u3qc_peg(axe, 7);
u3_noun pro;
pro = _loot_in(cog, r_dom, nax);
u3z(nax);
return pro;
}
}
else {
u3_noun u_yep = u3t(yep);
u3_noun nax = u3qc_peg(axe, 2);
u3_noun pro;
pro = u3nt(u3_nul, u3qc_peg(nax, u3h(u_yep)), u3k(u3t(u_yep)));
u3z(nax);
u3z(yep);
return pro;
}
}
}
}
}
/* functions
*/
u3_noun
u3qz_loot(u3_noun cog,
u3_noun dom)
{
return _loot_in(cog, dom, 1);
}
u3_noun
u3wz_loot(u3_noun cor)
{
u3_noun cog, dom;
if ( c3n == u3r_mean(cor, u3x_sam_2, &cog, u3x_sam_3, &dom, 0) ) {
return u3m_bail(c3__fail);
} else {
return u3qz_loot(cog, dom);
}
}

View File

@ -1,55 +0,0 @@
/* j/6/slot.c
**
*/
#include "all.h"
/* functions
*/
u3_noun
u3qz_slot(u3_atom axe,
u3_noun vax)
{
u3_noun fag = u3r_at(axe, u3t(vax));
fprintf(stderr, "slot axe %d\r\n", axe);
if ( u3_none == fag ) {
return u3m_bail(c3__exit);
}
else {
u3_noun typ = u3qzu_peek(
}
c3_w i_w, met_w = c3_min(u3r_met(3, axe), u3r_met(3, vax));
if ( c3n == _slot_fiz(axe, vax) ) {
return c3n;
}
for ( i_w = 0; i_w < met_w; i_w++ ) {
c3_y axe_y = u3r_byte(i_w, axe);
c3_y vax_y = u3r_byte(i_w, vax);
if ( (axe_y >= 'A') && (axe_y <= 'Z') ) axe_y = 0;
if ( (vax_y >= 'A') && (vax_y <= 'Z') ) vax_y = 0;
if ( axe_y && vax_y && (axe_y != vax_y) ) {
return c3n;
}
}
return c3y;
}
u3_noun
u3we_slot(u3_noun cor)
{
u3_noun axe, vax;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &axe, u3x_sam_3, &vax, 0)) ||
(c3n == u3ud(axe)) ||
(c3n == u3du(vax)) )
{
return u3m_bail(c3__fail);
} else {
return u3qz_slot(axe, vax);
}
}

View File

@ -1,42 +0,0 @@
/* j/6/type.c
**
*/
/* new template for type switching
*/
{
u3_noun p_sut, q_sut, r_sut;
if ( c3n == u3du(sut) ) switch ( sut ) {
default: return u3m_bail(c3__fail);
case c3__noun:
{
}
case c3__void:
{
}
}
else switch ( u3h(sut) ) {
default: return u3m_bail(c3__fail);
case c3__atom: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
}
case c3__cell: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
}
case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
}
case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
}
case c3__fork: p_sut = u3t(sut);
{
}
case c3__hold: p_sut = u3t(sut);
{
}
}
}

View File

@ -1,100 +0,0 @@
/* j/6/ut.c
**
*/
#include "all.h"
extern void
u3_pier_tank(c3_l tab_l, u3_noun tac);
// duck: create a duck core for mean.
//
u3_noun
u3qzu_duck(u3_noun van,
u3_noun typ)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0);
u3_noun ret = u3j_hook(u3k(von), "dune");
u3z(von);
return ret;
}
// dung: create a dunk core for mean (noun caption)
//
u3_noun
u3qzu_dung(u3_noun van,
u3_noun paz,
u3_noun typ)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0);
u3_noun duq = u3j_hook(u3k(von), "dunk");
u3_noun ret = u3i_molt(u3k(duq), u3x_sam, u3k(paz), 0);
u3z(duq);
u3z(von);
return ret;
}
// dunq: create a dunk core for mean
//
u3_noun
u3qzu_dunq(u3_noun van,
const c3_c* paz_c,
u3_noun typ)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(typ), 0);
u3_noun duq = u3j_hook(u3k(von), "dunk");
u3_noun paz = u3i_string(paz_c);
u3_noun ret = u3i_molt(u3k(duq), u3x_sam, u3k(paz), 0);
u3z(paz);
u3z(duq);
u3z(von);
return ret;
}
// dump: dump a type.
//
void
u3qzu_dump(u3_noun van,
const c3_c* paz_c,
u3_noun typ)
{
c3_c* pfix_c = u3r_string((c3y == u3du(typ)) ? u3h(typ) : typ);
c3_c ugh_c[1024];
sprintf(ugh_c, "%s: %s: 0x%8x:",
paz_c, pfix_c, u3r_mug(typ));
#if 0
u3_pier_tank(0, u3n_kick_on(u3qzu_dunq(van, ugh_c, typ)));
#endif
}
// shew: create a show core for mean
//
u3_noun
u3qzu_shew(u3_noun van,
u3_noun mol)
{
u3_noun sho = u3j_hook(u3k(van), "show");
u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0);
u3z(sho);
u3z(mol);
return ret;
}
// shep: show with caption and style
//
u3_noun
u3qzu_shep(u3_noun van,
const c3_c* paz_c,
u3_noun sty,
u3_noun mol)
{
return u3qzu_shew(van,
u3nc(u3nc('c', u3i_string(paz_c)),
u3nc(u3k(sty), mol)));
}

View File

@ -1,93 +0,0 @@
/* j/6/ut_buss.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_cqzu_buss(u3_noun van,
u3_noun sut,
u3_noun cog,
u3_noun gen)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "buss");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(cog),
u3x_sam_3,
u3k(gen),
0));
}
static u3_noun
_cqzu_busk(u3_noun van,
u3_noun sut,
u3_noun gen)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "busk");
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(gen),
0));
}
/* boilerplate
*/
u3_noun
u3wzu_buss(u3_noun cor)
{
u3_noun sut, cog, gen, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &cog,
u3x_sam_3, &gen,
u3x_con, &van,
0)) ||
(c3n == u3ud(cog)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_buss(van, sut, cog, gen);
}
}
u3_noun
u3qzu_buss(u3_noun van,
u3_noun sut,
u3_noun cog,
u3_noun gen)
{
return _cqzu_buss(van, sut, cog, gen);
}
u3_noun
u3wzu_busk(u3_noun cor)
{
u3_noun sut, gen, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &gen,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_busk(van, sut, gen);
}
}
u3_noun
u3qzu_busk(u3_noun van,
u3_noun sut,
u3_noun gen)
{
return _cqzu_busk(van, sut, gen);
}

View File

@ -1,88 +0,0 @@
/* j/6/ut_conk.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_cqzu_conk(u3_noun van,
u3_noun sut,
u3_noun got)
{
if ( c3y == u3ud(got) ) {
u3_noun ret = u3qz_face(u3k(got), sut);
return ret;
}
else switch ( u3h(got) ) {
default: return u3m_bail(c3__fail);
case 0: {
return u3k(sut);
}
case 1: {
u3_noun cok = _cqzu_conk(van, sut, u3t(u3t(got)));
u3_noun nux = u3k(u3h(u3t(got)));
u3_noun ret = u3qz_face(nux, cok);
u3z(nux);
u3z(cok);
return ret;
}
case 2: {
u3_noun vet = u3r_at(u3qzu_van_vet, van);
u3_noun hed, tal, deh, lat, ret;
if ( c3y == vet ) {
u3_noun cel = u3nt(c3__cell, c3__noun, c3__noun);
if ( c3n == u3qzu_nest(van, cel, c3y, sut) ) {
return u3m_bail(c3__fail);
}
u3z(cel);
}
hed = u3qzu_peek(van, sut, c3__both, 2);
tal = u3qzu_peek(van, sut, c3__both, 3);
deh = _cqzu_conk(van, hed, u3h(u3t(got)));
lat = _cqzu_conk(van, tal, u3t(u3t(got)));
ret = u3qz_cell(deh, lat);
u3z(lat);
u3z(deh);
u3z(tal);
u3z(hed);
return ret;
}
}
}
/* boilerplate
*/
u3_noun
u3wzu_conk(u3_noun cor)
{
u3_noun sut, got, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &got,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_conk(van, sut, got);
}
}
u3_noun
u3qzu_conk(u3_noun van,
u3_noun sut,
u3_noun got)
{
return _cqzu_conk(van, sut, got);
}

View File

@ -1,271 +0,0 @@
/* j/6/crop.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_crop_dext(u3_noun, u3_noun, u3_noun, u3_noun);
static u3_noun
_crop_sint(u3_noun, u3_noun, u3_noun, u3_noun);
static u3_noun
_crop_repo(u3_noun van,
u3_noun sut,
u3_noun ref,
u3_noun bix)
{
u3_noun rep = u3qzu_repo(van, sut);
u3_noun ret = _crop_dext(van, rep, ref, bix);
if ( c3y == u3r_sing(ret, rep) ) {
if ( c3__void == rep ) {
return c3__void;
} else {
u3z(rep);
u3z(ret);
return u3k(sut);
}
} else {
u3z(rep);
return ret;
}
}
static u3_noun
_crop_dext_fork(u3_noun van, u3_noun p_sut, u3_noun ref, u3_noun bix)
{
if ( u3_nul == p_sut ) {
return u3_nul;
}
else {
return u3nc(_crop_dext(van, u3h(p_sut), ref, bix),
_crop_dext_fork(van, u3t(p_sut), ref, bix));
}
}
static u3_noun
_crop_sint_fork(u3_noun van, u3_noun sut, u3_noun p_ref, u3_noun bix)
{
if ( u3_nul == p_ref ) {
return u3k(sut);
}
else {
u3_noun tuz = _crop_dext(van, sut, u3h(p_ref), bix);
u3_noun zat = _crop_sint_fork(van, tuz, u3t(p_ref), bix);
u3z(tuz);
return zat;
}
}
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: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
if ( c3__atom == u3h(ref) ) {
u3x_cell(u3t(ref), &p_ref, &q_ref);
if ( c3y == u3du(q_sut) ) {
if ( c3y == u3du(q_ref) ) {
if ( c3y == u3r_sing(q_sut, q_ref) ) {
return c3__void;
} else {
return u3k(sut);
}
} else {
return c3__void;
}
}
else {
if ( c3y == u3du(q_ref) ) {
return u3k(sut);
}
else return c3__void;
}
}
else if ( c3__cell == u3h(ref) ) {
return u3k(sut);
}
else return _crop_sint(van, sut, ref, bix);
}
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 == u3qzu_nest(van, p_ref, c3n, p_sut) )
{
u3_noun foz = _crop_dext(van, q_sut, q_ref, bix);
u3_noun ret = u3qz_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__hint: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
u3_noun foz = _crop_dext(van, q_sut, ref, bix);
u3_noun ret = u3qz_hint(p_sut, foz);
u3z(foz);
return ret;
}
case c3__face: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
u3_noun foz = _crop_dext(van, q_sut, ref, bix);
u3_noun ret = u3qz_face(p_sut, foz);
u3z(foz);
return ret;
}
case c3__fork: p_sut = u3t(sut);
{
u3_noun yed = u3qdi_tap(p_sut);
u3_noun ret = u3kf_fork(_crop_dext_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) ) {
# if 0
u3_noun dun = u3qzu_dunq(van, "type", sut);
u3_noun niz = u3qzu_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;
}
}
}
}
static u3_noun
_crop_sint(u3_noun van,
u3_noun sut,
u3_noun ref,
u3_noun bix)
{
u3_noun p_ref, q_ref;
switch ( u3h(ref) ) {
default: return u3m_bail(c3__fail);
case c3__core:
case c3__hint:
case c3__face: u3x_cell(u3t(ref), &p_ref, &q_ref);
{
return _crop_dext(van, sut, q_ref, bix);
}
case c3__fork: p_ref = u3t(ref);
{
u3_noun yed = u3qdi_tap(p_ref);
u3_noun ret = _crop_sint_fork(van, sut, yed, bix);
u3z(yed);
return ret;
}
case c3__hold:
{
u3_noun rep = u3qzu_repo(van, ref);
u3_noun ret = _crop_dext(van, sut, rep, bix);
u3z(rep);
return ret;
}
}
}
static u3_noun
_cqzu_crop(u3_noun van,
u3_noun sut,
u3_noun ref)
{
return _crop_dext(van, sut, ref, u3_nul);
}
/* boilerplate
*/
u3_noun
u3wzu_crop(u3_noun cor)
{
u3_noun sut, ref, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_crop(van, sut, ref);
}
}
u3_noun
u3qzu_crop(u3_noun van,
u3_noun sut,
u3_noun ref)
{
c3_m fun_m = 144 + c3__crop + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_2(fun_m, sut, ref);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_crop(van, sut, ref);
return u3z_save_2(fun_m, sut, ref, pro);
}
}

View File

@ -1,915 +0,0 @@
/* j/6/find.c
**
*/
#include "all.h"
static u3_noun
_find_buck(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil);
static u3_noun
_opal_sane(u3_noun ope)
{
if ( (0 == u3h(ope)) && (0 == u3t(ope)) ) {
fprintf(stderr, "insane opal\r\n");
c3_assert(0);
}
else return ope;
}
static u3_noun
_pony_sane(u3_noun poy)
{
if ( 0 == poy ) {
return poy;
}
else if ( c3n == u3h(poy) ) {
if ( c3n == u3h(u3t(poy)) ) {
// abnormal
u3_noun type = u3h(u3t(u3t(u3t(poy))));
if ( 0 == type ) {
u3m_p("insane type", 0);
c3_assert(0);
}
}
return poy;
}
else {
u3_noun tt_poy = u3t(u3t(poy)); // opal
_opal_sane(tt_poy);
return poy;
}
}
static u3_noun
u3qzu_felt(u3_noun van,
u3_noun sut,
u3_noun lap)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "felt");
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(lap),
0));
}
static u3_noun
u3qzu_fund(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun gen)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "fund");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(way),
u3x_sam_3,
u3k(gen),
0));
}
static u3_noun
u3qzu_fine(u3_noun van,
u3_noun sut,
u3_noun tor)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "fine");
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(tor),
0));
}
static u3_noun
_find_buck_here(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
if ( 0 == p_heg ) {
return u3nt
(c3y,
u3nt(u3_nul,
u3nc(u3_nul, u3k(axe)),
u3k(lon)),
u3nc(c3y, u3k(sut)));
}
else {
return u3nt
(c3n, c3y, u3qa_dec(p_heg));
}
}
static u3_noun
_find_buck_lose(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
return u3nt(c3n, c3y, u3k(p_heg));
}
static u3_noun
_find_buck_stop(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
if ( u3_nul == q_heg ) {
return _find_buck_here(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
else {
return _find_buck_lose(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
}
static u3_noun
_find_buck_cell(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
u3_noun p_sut, q_sut;
u3x_cell(u3t(sut), &p_sut, &q_sut);
{
if ( u3_nul == q_heg ) {
return _find_buck_here(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
else {
u3_noun exa = u3qc_peg(axe, 2);
u3_noun hed = _find_buck(van, p_sut, way, p_heg, q_heg, exa, lon, gil);
u3z(exa);
if ( (u3_nul == hed) || (c3y == u3h(hed)) || (c3n == u3h(u3t(hed))) ) {
return hed;
}
else {
u3_noun exa = u3qc_peg(axe, 3);
u3_noun tal = _find_buck
(van, q_sut, way, u3t(u3t(hed)), q_heg, exa, lon, gil);
u3z(exa);
u3z(hed);
return tal;
}
}
}
}
static u3_noun
_find_buck_core(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
u3_noun p_sut, q_sut, pq_sut, qq_sut, rq_sut, prq_sut, qrq_sut;
u3_noun ppq_sut, qpq_sut, rpq_sut;
u3x_cell(u3t(sut), &p_sut, &q_sut);
u3x_trel(q_sut, &pq_sut, &qq_sut, &rq_sut);
u3x_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut);
u3x_cell(rq_sut, &prq_sut, &qrq_sut);
{
if ( u3_nul == q_heg ) {
return _find_buck_here(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
else {
u3_noun zem = u3qz_loot(u3t(q_heg), qrq_sut);
if ( (u3_nul != zem) && (0 != p_heg) ) {
u3_noun ped;
ped = u3qa_dec(p_heg);
u3z(p_heg); p_heg = ped;
u3z(zem);
zem = u3_nul;
}
if ( u3_nul != zem ) {
u3_noun u_zem = u3t(zem);
u3_noun pu_zem = u3h(u_zem);
u3_noun qu_zem = u3t(u_zem);
u3_noun qqu_zem = u3t(qu_zem);
u3_noun mut;
u3_noun pro;
mut = u3nt(c3__core,
u3k(p_sut),
u3nt(u3nt(u3k(ppq_sut), u3k(qpq_sut), c3__gold),
u3k(qq_sut),
u3k(rq_sut)));
pro = u3nt
(c3y,
u3nc(u3nc(u3_nul, u3k(axe)), u3k(lon)),
u3nt(c3n,
u3qc_peg(2, pu_zem),
u3nt(u3nc(mut, u3k(qqu_zem)), u3_nul, u3_nul)));
u3z(zem);
return pro;
}
else {
u3_noun pec = u3qzu_peel(van, sut, way, rpq_sut);
u3_noun pro;
if ( c3n == u3h(pec) ) {
pro = _find_buck_lose(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
else if ( c3y == u3t(pec) ) {
u3_noun exa = u3qc_peg(axe, 3);
pro = _find_buck(van, p_sut, way, p_heg, q_heg, exa, lon, gil);
u3z(exa);
}
else {
u3_noun sam = u3qzu_peek(van, p_sut, way, 2);
u3_noun exa = u3qc_peg(axe, 6);
pro = _find_buck(van, sam, way, p_heg, q_heg, exa, lon, gil);
u3z(exa);
u3z(sam);
}
u3z(pec);
return pro;
}
}
}
}
static u3_noun
_find_twin(u3_noun van,
u3_noun hax,
u3_noun yor)
{
if ( c3y == u3r_sing(hax, yor) ) {
return u3k(hax);
}
else if ( u3_nul == hax ) {
return u3k(yor);
}
else if ( u3_nul == yor ) {
return u3k(hax);
}
else if ( c3n == u3h(hax) ) {
if ( (c3n != u3h(yor)) ) {
return u3m_error("find-fork-a");
}
else {
u3_noun p_hax = u3t(hax); // (each @ud {span nock})
u3_noun p_yor = u3t(yor); // (each @ud {span nock})
if ( (c3n != u3h(p_hax)) || (c3n != u3h(p_yor)) ) {
return u3m_error("find-fork-b");
}
else {
u3_noun pp_hax = u3t(p_hax); // {span nock}
u3_noun pp_yor = u3t(p_yor); // {span nock}
u3_noun ppp_hax = u3h(pp_hax); // span
u3_noun ppp_yor = u3h(pp_yor); // span
u3_noun qpp_hax = u3t(pp_hax); // nock
u3_noun qpp_yor = u3t(pp_yor); // nock
if ( c3n == u3r_sing(qpp_hax, qpp_yor) ) {
return u3m_error("find-fork-c");
}
return u3nt(c3n,
c3n,
u3nc(
u3kf_fork(u3nt(u3k(ppp_hax), u3k(ppp_yor), u3_nul)),
u3k(qpp_hax)));
}
}
}
else {
if ( c3n == u3h(yor) ) {
return u3m_error("find-fork-d");
}
else {
u3_noun p_hax = u3t(hax); // {vein opal}
u3_noun p_yor = u3t(yor); // {vein opal}
u3_noun pp_hax = u3h(p_hax); // vein
u3_noun pp_yor = u3h(p_yor); // vein
u3_noun qp_hax = u3t(p_hax); // opal
u3_noun qp_yor = u3t(p_yor); // opal
if ( c3n == u3r_sing(pp_hax, pp_yor) ) {
return u3m_error("find-fork-e");
}
else {
if ( c3y == u3h(qp_hax) ) {
if ( c3y != u3h(qp_yor) ) {
return u3m_error("find-fork-f");
} else {
u3_noun pqp_hax = u3t(qp_hax); // type
u3_noun pqp_yor = u3t(qp_yor); // type
return
u3nt(c3y,
u3k(pp_hax),
u3nc(c3y, u3kf_fork
(u3nt(u3k(pqp_hax), u3k(pqp_yor), u3_nul))));
}
}
else if ( c3n != u3h(qp_yor) ) {
return u3m_error("find-fork-g");
} else {
u3_noun pqp_hax = u3h(u3t(qp_hax)); // axis
u3_noun pqp_yor = u3h(u3t(qp_yor)); // axis
u3_noun qqp_hax = u3t(u3t(qp_hax)); // (set {type foot})
u3_noun qqp_yor = u3t(u3t(qp_yor)); // (set {type foot})
if ( c3n == u3r_sing(pqp_hax, pqp_yor) ) {
return u3m_error("find-fork-h");
} else {
return
u3nt(c3y,
u3k(pp_hax),
u3nt(c3n, u3k(pqp_hax), u3qdi_uni(qqp_hax, qqp_yor)));
}
}
}
}
}
// error: { return u3m_error("find-fork"); }
}
static u3_noun
_find_buck_fork_twin(u3_noun van, u3_noun wiz)
{
if ( u3_nul == wiz ) {
return u3_nul;
}
else if ( u3_nul == u3t(wiz) ) {
return u3k(u3h(wiz));
}
else {
u3_noun hax = u3k(u3h(wiz));
u3_noun yor = _find_buck_fork_twin(van, u3t(wiz));
u3_noun fid = _find_twin(van, hax, yor);
u3z(hax);
u3z(yor);
return fid;
}
}
static u3_noun
_find_buck_fork_turn(u3_noun van,
u3_noun yed,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
if ( u3_nul == yed ) {
return u3_nul;
}
else {
u3_noun fid = _find_buck(van, u3h(yed), way, p_heg, q_heg, axe, lon, gil);
return u3nc
(fid,
_find_buck_fork_turn
(van, u3t(yed), way, p_heg, q_heg, axe, lon, gil));
}
}
static u3_noun
_find_buck_fork(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
u3_noun p_sut = u3t(sut);
u3_noun yed = u3qdi_tap(p_sut);
u3_noun wiz;
u3_noun ret;
wiz = _find_buck_fork_turn(van, yed, way, p_heg, q_heg, axe, lon, gil);
u3z(yed);
ret = _find_buck_fork_twin(van, wiz);
u3z(wiz);
return ret;
}
static u3_noun
_find_buck_face_next(u3_noun van,
u3_noun sut,
u3_noun q_sut,
u3_noun qp_sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
if ( u3_nul == qp_sut ) {
u3_noun nol = u3nc(u3_nul, u3k(lon));
u3_noun ret = _find_buck(van, q_sut, way, p_heg, q_heg, axe, nol, gil);
u3z(nol);
return ret;
}
else {
u3_noun iqp_sut = u3h(qp_sut); // twig
u3_noun tiv = u3qzu_mint // (pair type nock)
(van, q_sut, c3__noun, iqp_sut);
u3_noun tqp_sut = u3t(qp_sut); // (list twig)
u3_noun p_tiv = u3h(tiv); // type
u3_noun q_tiv = u3t(tiv); // nock
u3_noun fid = _find_buck // pony
(van, p_tiv, way, p_heg, q_heg, 1, u3_nul, u3_nul);
if ( u3_nul == fid ) {
u3z(tiv);
return u3_nul;
}
else if ( (c3n == u3h(fid)) && (c3y == u3h(u3t(fid))) ) {
u3_noun ret;
ret = _find_buck_face_next
(van, sut, q_sut, tqp_sut, way, u3t(u3t(fid)), q_heg, axe, lon, gil);
u3z(fid);
u3z(tiv);
return ret;
}
else {
u3_noun tor; // port
u3_noun vat; // (pair type nock)
u3_noun ret;
u3_noun dog = u3nc(0, u3k(axe)); // nock
u3_noun cob = u3qz_comb(dog, q_tiv);
if ( c3y == u3h(fid) ) {
tor = u3nc(c3y, u3k(u3t(fid)));
} else {
tor = u3nc(c3n, u3k(u3t(u3t(fid))));
}
u3z(fid);
vat = u3qzu_fine(van, sut, tor);
u3z(tor);
ret = u3nt
(c3n,
c3n,
u3nc(u3k(u3h(vat)), u3qz_comb(cob, u3t(vat))));
u3z(vat);
u3z(dog);
u3z(cob);
u3z(tiv);
return ret;
}
}
}
static u3_noun
_find_buck_face(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
u3_noun p_sut, q_sut;
u3x_cell(u3t(sut), &p_sut, &q_sut);
if ( u3_nul == q_heg ) {
return _find_buck_here(van, q_sut, way, p_heg, q_heg, axe, lon, gil);
}
else {
u3_noun uq_heg = u3t(q_heg); // term
if ( c3y == u3ud(p_sut) ) {
if ( c3y == u3r_sing(p_sut, uq_heg) ) {
return _find_buck_here(van, q_sut, way, p_heg, q_heg, axe, lon, gil);
}
else {
return _find_buck_lose(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
}
else {
u3_noun pp_sut = u3h(p_sut); // (map term {wain (unit twig)})
u3_noun qp_sut = u3t(p_sut); // (list (pair type nock))
u3_noun tyr = u3qdb_get(pp_sut, uq_heg); // (unit {wain (unit twig)})
if ( u3_nul == tyr ) {
return _find_buck_face_next
(van, sut, q_sut, qp_sut, way, p_heg, q_heg, axe, lon, gil);
}
else {
u3_noun u_tyr = u3t(tyr); // (pair wain (unit twig))
u3_noun qu_tyr = u3t(u_tyr);
if ( u3_nul == qu_tyr ) {
u3_noun nol = u3nc(u3_nul, u3k(lon));
u3_noun dep = u3qa_inc(p_heg);
u3_noun ret = _find_buck
(van, q_sut, way, dep, q_heg, axe, nol, gil);
u3z(dep);
u3z(nol);
u3z(tyr);
return ret;
}
else {
u3_noun uqu_tyr = u3t(qu_tyr);
u3_noun tor = u3qzu_fund(van, sut, way, uqu_tyr);
if ( c3y == u3h(tor) ) {
u3_noun p_tor = u3t(tor); // (pair vein opal)
u3_noun pp_tor = u3h(p_tor); // vein
u3_noun qp_tor = u3t(p_tor); // opal
u3_noun nol = // vein
u3nt(u3_nul, u3nc(u3_nul, u3k(axe)), u3k(lon));
u3_noun ret;
ret = u3nt(c3y, u3qb_weld(pp_tor, nol), u3k(qp_tor));
u3z(nol);
u3z(tor);
u3z(tyr);
return ret;
}
else {
u3_noun p_tor = u3t(tor); // (pair type nock)
u3_noun pp_tor = u3h(p_tor); // type
u3_noun qp_tor = u3t(p_tor); // nock
u3_noun dog = u3nc(0, u3k(axe)); // nock
u3_noun ret;
ret = u3nt(c3n,
c3n,
u3nc(u3k(pp_tor), u3qz_comb(dog, qp_tor)));
u3z(dog);
u3z(tor);
u3z(tyr);
return ret;
}
}
}
}
}
}
static u3_noun
_find_bucx(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
if ( c3n == u3du(sut) ) switch ( sut ) {
default: return u3m_bail(c3__fail);
case c3__noun: {
// fprintf(stderr, "noun\r\n");
return _find_buck_stop(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
case c3__void: {
// fprintf(stderr, "void\r\n");
// return _find_buck_stop(van, sut, way, p_heg, q_heg, axe, lon, gil);
return u3_nul;
}
}
else switch ( u3h(sut) ) {
default: return u3m_bail(c3__fail);
case c3__atom:
{
// fprintf(stderr, "atom\r\n");
return _find_buck_stop(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
case c3__cell:
{
// fprintf(stderr, "cell\r\n");
return _find_buck_cell(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
case c3__core:
{
// fprintf(stderr, "core\r\n");
return _find_buck_core(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
case c3__hint:
{
u3_noun fop = u3qzu_repo(van, sut);
u3_noun pro = _find_bucx(van, fop, way, p_heg, q_heg, axe, lon, gil);
u3z(fop);
return pro;
}
case c3__face:
{
// fprintf(stderr, "face\r\n");
return _find_buck_face(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
case c3__fork:
{
// fprintf(stderr, "fork\r\n");
return _find_buck_fork(van, sut, way, p_heg, q_heg, axe, lon, gil);
}
case c3__hold:
{
// fprintf(stderr, "hold\r\n");
if ( (c3y == u3qdi_has(gil, sut)) ) {
return u3_nul;
}
else {
u3_noun zoc = u3qdi_put(gil, sut);
u3_noun fop = u3qzu_repo(van, sut);
u3_noun pro = _find_buck(van, fop, way, p_heg, q_heg, axe, lon, zoc);
u3z(fop);
u3z(zoc);
return pro;
}
}
}
}
static u3_noun
_find_buck(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun p_heg,
u3_noun q_heg,
u3_noun axe,
u3_noun lon,
u3_noun gil)
{
u3_noun ret = _find_bucx(van, sut, way, p_heg, q_heg, axe, lon, gil);
return _pony_sane(ret);
}
static u3_noun
_find_limb(u3_noun van,
u3_noun sut, // type
u3_noun way, // ?(%read %rite %free %both)
u3_noun i_hyp, // limb
u3_noun p_mor) // palo
{
u3_noun pp_mor = u3h(p_mor); // vein
u3_noun qp_mor = u3t(p_mor); // opal
qp_mor = _opal_sane(qp_mor);
{
u3_noun ref = u3qzu_felt(van, sut, qp_mor);
u3_noun lon = u3k(pp_mor);
u3_noun heg = (c3y == u3du(i_hyp))
? u3k(i_hyp)
: u3nq(c3n, 0, u3_nul, u3k(i_hyp));
u3_noun ret;
if ( c3y == u3h(heg) ) {
u3_noun p_heg = u3t(heg); // axis
ret = u3nt
(c3y,
u3nc(u3nc(u3_nul, u3k(p_heg)), u3k(lon)),
u3nc(c3y, u3qzu_peek(van, ref, way, p_heg)));
ret = _pony_sane(ret);
}
else {
u3_noun p_heg = u3h(u3t(heg)); // @ud
u3_noun q_heg = u3t(u3t(heg)); // (unit term)
ret = _find_buck
(van, ref, way, p_heg, q_heg, 1, lon, u3_nul);
}
u3z(heg);
u3z(lon);
u3z(ref);
return _pony_sane(ret);
}
}
static u3_noun
_find_pony(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
if ( u3_nul == hyp ) {
return _pony_sane(u3nt(c3y, u3_nul, u3nc(c3y, u3k(sut))));
}
else {
u3_noun i_hyp = u3h(hyp);
u3_noun t_hyp = u3t(hyp);
u3_noun mor = _find_pony(van, sut, way, t_hyp);
mor = _pony_sane(mor);
if ( c3n == u3h(mor) ) {
u3_noun p_mor = u3t(mor);
if ( c3y == u3h(p_mor) ) {
return mor;
}
else {
u3_noun pp_mor = u3t(p_mor); // {span nock}
u3_noun ppp_mor = u3h(pp_mor); // span
u3_noun qpp_mor = u3t(pp_mor); // nock
u3_noun gen = u3nt(c3__wing, u3k(i_hyp), u3_nul);
u3_noun fex = u3qfu_mint(van, ppp_mor, c3__noun, gen);
u3_noun ret = u3nt(c3n,
c3n,
u3nc(u3k(u3h(fex)),
u3qf_comb(qpp_mor, u3t(fex))));
u3z(fex);
u3z(gen);
u3z(mor);
return _pony_sane(ret);
}
}
else {
u3_noun p_mor = u3t(mor);
u3_noun ret = _find_limb(van, sut, way, i_hyp, p_mor);
u3z(mor);
return _pony_sane(ret);
}
}
}
static u3_noun
_cqzu_fond(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
u3_noun taf;
taf = _find_pony(van, sut, way, hyp);
return taf;
}
static u3_noun
_cqzu_find(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
u3_noun taf = _find_pony(van, sut, way, hyp);
if ( u3_nul == taf ) {
goto error;
}
else {
if ( c3y == u3h(taf) ) {
u3_noun fat = u3nc(c3y, u3k(u3t(taf)));
u3z(taf);
return fat;
}
else {
if ( c3n == u3h(u3t(taf)) ) {
u3_noun fat = u3nc(c3n, u3k(u3t(u3t(u3t(taf)))));
u3z(taf);
return fat;
}
else {
goto error;
}
}
}
error: {
u3m_p("wing", hyp);
return u3m_error("find");
}
}
/* boilerplate
*/
u3_noun
u3wzu_find(u3_noun cor)
{
u3_noun sut, way, hyp, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &way,
u3x_sam_3, &hyp,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_find(van, sut, way, hyp);
}
}
u3_noun
u3qzu_find(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
c3_m fun_m = 144 + c3__find + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_3(fun_m, sut, way, hyp);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_find(van, sut, way, hyp);
return u3z_save_3(fun_m, sut, way, hyp, pro);
}
}
/* boilerplate
*/
u3_noun
u3wzu_fond(u3_noun cor)
{
u3_noun sut, way, hyp, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &way,
u3x_sam_3, &hyp,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_fond(van, sut, way, hyp);
}
}
u3_noun
u3qzu_fond(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun hyp)
{
c3_m fun_m = 144 + c3__fond + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_3(fun_m, sut, way, hyp);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_fond(van, sut, way, hyp);
return u3z_save_3(fun_m, sut, way, hyp, pro);
}
}

View File

@ -1,195 +0,0 @@
/* j/6/fire.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_fire_vet(u3_noun van)
{
// u3_noun vet = u3j_hook(u3k(van), "vet");
u3_noun vet = u3r_at(u3qzu_van_vet, van);
switch ( vet ) {
case c3n:
case c3y: return vet;
default: return u3m_bail(c3__fail);
}
}
static u3_noun
_fire_mull(u3_noun van,
u3_noun sut,
u3_noun dox,
u3_noun gen)
{
u3_noun rib = u3r_at(u3qzu_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),
u3qzu_van_rib,
u3k(rob),
0);
u3_noun mul = u3qzu_mull(von, sut, c3__noun, dox, gen);
ret = c3y;
u3z(mul);
u3z(von);
u3z(rob);
}
u3z(key);
return ret;
}
static u3_noun
_fire_each(u3_noun van,
u3_noun vet,
u3_noun typ,
u3_noun gat)
{
u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ;
u3_noun h_gat, t_gat;
if ( (c3n == u3du(typ)) || (c3__core != u3h(typ)) ) {
return u3m_error("fire-core");
} else if
( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) ||
(c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) ||
(c3n == u3r_cell(gat, &h_gat, &t_gat)) )
{
return u3m_bail(c3__fail);
} else {
u3_noun dox = u3nt
(c3__core, u3k(qq_typ), u3k(q_typ));
if ( c3__ash == u3h(gat) ) {
if ( (c3y == vet) &&
(c3n == u3qzu_nest(van, qq_typ, c3y, p_typ)) )
{
#if 0
u3_noun dun = u3qzu_dunq(van, "need", qq_typ);
u3_noun niz = u3qzu_dunq(van, "have", p_typ);
u3t_push(u3nc(c3__mean, niz));
u3t_push(u3nc(c3__mean, dun));
#endif
return u3m_error("fire-dry");
}
else {
return u3nc(dox, u3k(t_gat));
}
}
else {
c3_assert(c3__elm == u3h(gat));
#if 0
u3_noun dun = u3qzu_dunq(van, "wild", typ);
u3_noun niz = u3qzu_dunq(van, "tame", dox);
u3t_push(u3nc(c3__mean, dun));
u3t_push(u3nc(c3__mean, niz));
#endif
if ( (c3y == vet) &&
(c3n == _fire_mull(van, typ, dox, t_gat)) )
{
return u3m_error("fire-wet");
}
else {
u3z(dox);
#if 0
u3t_drop();
u3t_drop();
#endif
return u3nc(u3k(typ), u3k(t_gat));
}
}
}
}
static u3_noun
_fire_in(u3_noun van,
u3_noun vet,
u3_noun hag)
{
if ( u3_nul == hag ) {
return u3_nul;
}
else {
u3_noun i_hag = u3h(hag);
u3_noun t_hag = u3t(hag);
if ( c3n == u3du(i_hag) ) {
return u3m_bail(c3__fail);
} else {
return u3nc
(_fire_each(van, vet, u3h(i_hag), u3t(i_hag)),
_fire_in(van, vet, t_hag));
}
}
}
static u3_noun
_cqzu_fire(u3_noun van,
u3_noun sut,
u3_noun hag)
{
u3_noun vet = u3r_at(u3qzu_van_vet, van);
c3_assert(!"not live");
{
if ( (c3y == u3du(hag)) && (u3_nul == u3t(hag)) ) {
u3_noun i_hag = u3h(hag);
u3_noun pi_hag = u3h(i_hag);
u3_noun qi_hag = u3t(i_hag);
if ( c3__elm == u3h(qi_hag) ) {
u3_noun qqi_hag = u3t(qi_hag);
if ( c3y == u3du(qqi_hag) &&
(u3_nul == u3h(qqi_hag)) &&
(1 == u3t(qqi_hag)) )
{
return u3k(pi_hag);
}
}
}
}
return u3nc(c3__hold, _fire_in(van, vet, hag));
}
/* boilerplate
*/
u3_noun
u3wzu_fire(u3_noun cor)
{
u3_noun sut, hag, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &hag, u3x_con, &van, 0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_fire(van, sut, hag);
}
}
u3_noun
u3qzu_fire(u3_noun van,
u3_noun sut,
u3_noun hag)
{
return _cqzu_fire(van, sut, hag);
}

View File

@ -1,180 +0,0 @@
/* j/6/fish.c
**
*/
#include "all.h"
/* functions
*/
static u3_noun
_fish_in(u3_noun, u3_noun, u3_atom, u3_noun);
static u3_noun
_fish_fork(u3_noun van,
u3_noun p_sut,
u3_atom axe,
u3_noun vit)
{
if ( u3_nul == p_sut ) {
return u3nc(1, 1);
}
else {
u3_noun hed = _fish_in(van, u3h(p_sut), axe, vit);
u3_noun tal = _fish_fork(van, u3t(p_sut), axe, vit);
u3_noun pro = u3qz_flor(hed, tal);
u3z(hed);
u3z(tal);
return pro;
}
}
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 = u3qz_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 = u3qz_flan(hed, tal);
u3_noun vug = u3qz_flan(hut, hob);
u3z(hob);
u3z(tal);
u3z(hed);
u3z(rit);
u3z(lef);
u3z(hut);
return vug;
}
}
case c3__core: {
return u3m_error("fish-core");
}
case c3__hint:
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_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 = u3qzu_dunq(van, "type", sut);
u3_noun niz = u3qzu_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 = u3qzu_repo(van, sut);
u3_noun pro = _fish_in(van, fop, axe, zoc);
u3z(fop);
u3z(zoc);
return pro;
}
}
}
}
}
static u3_noun
_cqzu_fish(u3_noun van,
u3_noun sut,
u3_atom axe)
{
return _fish_in(van, sut, axe, u3_nul);
}
/* boilerplate
*/
u3_noun
u3wzu_fish(u3_noun cor)
{
u3_noun sut, axe, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &axe, u3x_con, &van, 0)) ||
(c3n == u3ud(axe)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_fish(van, sut, axe);
}
}
u3_noun
u3qzu_fish(u3_noun van,
u3_noun sut,
u3_noun axe)
{
c3_m fun_m = 144 + c3__fish + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_2(fun_m, sut, axe);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_fish(van, sut, axe);
return u3z_save_2(fun_m, sut, axe, pro);
}
}

View File

@ -1,215 +0,0 @@
/* j/6/fuse.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_fuse_in(u3_noun, u3_noun, u3_noun, u3_noun);
static u3_noun
_fuse_repo(u3_noun van,
u3_noun sut,
u3_noun ref,
u3_noun bix)
{
u3_noun rep = u3qzu_repo(van, sut);
u3_noun ret = _fuse_in(van, rep, ref, bix);
if ( c3y == u3r_sing(ret, rep) ) {
if ( c3__void == rep ) {
return c3__void;
} else {
u3z(rep);
u3z(ret);
return u3k(sut);
}
} else {
u3z(rep);
return ret;
}
}
static u3_noun
_fuse_in_fork(u3_noun van, u3_noun p_sut, u3_noun ref, u3_noun bix)
{
if ( u3_nul == p_sut ) {
return u3_nul;
}
else {
return u3nc(_fuse_in(van, u3h(p_sut), ref, bix),
_fuse_in_fork(van, u3t(p_sut), ref, bix));
}
}
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 == u3qz_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 = u3qz_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__hint: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
u3_noun vot = _fuse_in(van, q_sut, ref, bix);
u3_noun ret = u3qz_hint(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 = u3qz_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 = u3qzu_dunq(van, "type", sut);
// u3_noun niz = u3qzu_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;
}
}
}
}
static u3_noun
_cqzu_fuse(u3_noun van,
u3_noun sut,
u3_noun ref)
{
return _fuse_in(van, sut, ref, u3_nul);
}
/* boilerplate
*/
u3_noun
u3wzu_fuse(u3_noun cor)
{
u3_noun sut, ref, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &ref, u3x_con, &van, 0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_fuse(van, sut, ref);
}
}
u3_noun
u3qzu_fuse(u3_noun van,
u3_noun sut,
u3_noun ref)
{
c3_m fun_m = 144 + c3__fuse + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_2(fun_m, sut, ref);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_fuse(van, sut, ref);
return u3z_save_2(fun_m, sut, ref, pro);
}
}

View File

@ -1,16 +0,0 @@
/* j/6/gain.c
**
*/
#include "all.h"
u3_noun
u3qzu_gain(u3_noun van,
u3_noun sut,
u3_noun gen)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "gain");
return u3n_kick_on(u3i_molt(gat, u3x_sam, u3k(gen), 0));
}

View File

@ -1,16 +0,0 @@
/* j/6/lose.c
**
*/
#include "all.h"
u3_noun
u3qzu_lose(u3_noun van,
u3_noun sut,
u3_noun gen)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "lose");
return u3n_kick_on(u3i_molt(gat, u3x_sam, u3k(gen), 0));
}

View File

@ -1,830 +0,0 @@
/* j/6/mint.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_mint_in(u3_noun, u3_noun, u3_noun, u3_noun);
static u3_noun
_mint_bean()
{
return u3kf_fork(u3nt(u3nq(c3__atom, 'f', u3_nul, 0),
u3nq(c3__atom, 'f', u3_nul, 1),
u3_nul));
}
static u3_noun
_mint_vet(u3_noun van)
{
// u3_noun vet = u3j_hook(u3k(van), "vet");
u3_noun vet = u3r_at(u3qzu_van_vet, van);
switch ( vet ) {
case c3n:
case c3y: return vet;
default: return u3m_bail(c3__fail);
}
}
static u3_noun
_mint_feel(u3_noun van,
u3_noun sut,
u3_noun rot)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "feel");
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(rot),
0));
}
static u3_noun
_mint_mine(u3_noun van,
u3_noun sut,
u3_noun mel,
u3_noun dom)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "mine");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(mel),
u3x_sam_3,
u3k(dom),
0));
}
static u3_noun
_mint_burp(u3_noun van,
u3_noun sut)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
return u3j_hook(von, "burp");
}
static u3_noun
_mint_cond(u3_noun pex,
u3_noun yom,
u3_noun woq)
{
if ( 1 == u3h(pex) ) {
if ( 0 == u3t(pex) ) {
u3z(pex);
u3z(woq);
return yom;
}
else if ( 1 == u3t(pex) ) {
u3z(pex);
u3z(yom);
return woq;
}
}
return u3nq(6, pex, yom, woq);
}
static u3_noun
_mint_corn(u3_noun van,
u3_noun sut,
u3_noun gen)
{
u3_noun mil = _mint_in(van, sut, c3__noun, gen);
u3_noun fol = u3k(u3t(mil));
u3z(mil);
return fol;
}
static u3_noun
_mint_nice(u3_noun van,
u3_noun gol,
u3_noun typ)
{
if ( (c3y == _mint_vet(van)) &&
(c3n == u3qzu_nest(van, gol, c3y, typ)) )
{
// u3_noun dun = u3qzu_dunq(van, "need", gol);
// u3_noun niz = u3qzu_dunq(van, "have", typ);
// u3t_push(u3nc(c3__mean, dun));
// u3t_push(u3nc(c3__mean, niz));
return u3m_error("mint-nice");
}
else return typ;
}
static u3_noun
_mint_coke(u3_noun nug)
{
if ( 0 == u3h(nug) ) {
return u3k(u3t(nug));
}
else if ( 10 == u3h(nug) ) {
return _mint_coke(u3t(u3t(nug)));
}
else {
return u3m_error("mint-coke");
}
}
static u3_noun
_mint_grow(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_atom mel,
u3_noun ruf,
u3_noun dom)
{
u3_noun dan = _mint_in(van, sut, c3__noun, ruf);
u3_noun p_dan = u3h(dan);
u3_noun q_dan = u3t(dan);
u3_noun pul = _mint_mine(van, p_dan, mel, dom);
u3_noun ret = u3nc(_mint_nice(van, gol, u3k(u3h(pul))),
u3qz_cons(u3t(pul), q_dan));
u3z(pul);
u3z(dan);
return ret;
}
static u3_noun
_mint_loc(u3_noun van,
u3_noun loc)
{
u3_noun mol = u3nc('o', u3k(loc));
u3_noun sho = u3j_hook(u3k(van), "show");
u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0);
u3z(mol);
u3z(sho);
return ret;
}
#if 1
static u3_noun
_mint_cnts(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun hyp,
u3_noun rig)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "emin");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(gol),
u3x_sam_6,
u3k(hyp),
u3x_sam_7,
u3k(rig),
0));
}
#else
static u3_noun
_mint_edit(u3_noun van,
u3_noun sut,
u3_noun mew,
u3_noun p_lar,
u3_noun rag,
u3_noun hej)
{
while ( 1 ) {
if ( c3n == u3du(mew) ) {
u3_noun gim = u3qzu_fire(van, sut, rag);
u3_noun fol = u3qz_hike(p_lar, hej);
u3z(rag);
u3z(hej);
return u3nc(gim, fol);
} else {
u3_noun i_mew = u3h(mew);
u3_noun t_mew = u3t(mew);
u3_noun pi_mew = u3h(i_mew);
u3_noun qi_mew = u3t(i_mew);
u3_noun zil = u3qzu_mint(van, sut, c3__noun, qi_mew);
u3_noun p_zil = u3h(zil);
u3_noun q_zil = u3t(zil);
u3_noun wip = u3qzu_toss(van, sut, pi_mew, p_zil, rag);
u3z(rag);
rag = u3k(u3t(wip));
hej = u3nc(u3nc(u3k(u3h(wip)),
u3k(q_zil)),
hej);
u3z(zil);
u3z(wip);
mew = t_mew;
}
}
}
static u3_noun
_mint_cnts_old(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun hyp,
u3_noun rig)
{
u3_noun lar = u3qzu_seek(van, sut, c3__read, hyp);
u3_noun p_lar = u3h(lar);
u3_noun q_lar = u3t(lar);
u3_noun pq_lar = u3h(q_lar);
u3_noun qq_lar = u3t(q_lar);
u3_noun mew = rig;
u3_noun yom = _mint_edit(van, sut, mew, p_lar, u3k(qq_lar), u3_nul);
u3_noun p_yom = u3h(yom);
u3_noun q_yom = u3t(yom);
u3_noun ret = u3nc(_mint_nice(van, gol, u3k(p_yom)),
(0 == pq_lar) ? u3k(q_yom)
: u3nt(9, u3k(pq_lar), u3k(q_yom)));
u3z(yom);
u3z(lar);
return ret;
}
#endif
# define _mint_used()
static u3_noun
_mint_in(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun gen)
{
u3_noun p_gen, q_gen, r_gen;
u3_noun ret;
if ( (c3__void == sut) &&
!((c3y == u3du(gen)) && (c3__dbug == u3h(gen))) )
{
if ( (c3n == _mint_vet(van))
|| ((c3y == u3du(gen)) &&
((c3__zpfs == u3h(gen)) ||
(c3__zpsk == u3h(gen)) ||
(c3__lost == u3h(gen)) ||
(c3__fail == u3h(gen)) ||
(c3__zpzp == u3h(gen)))) )
{
return u3nt(c3__void, 0, 0);
}
else {
return u3m_error("mint-vain");
}
}
if ( c3n == u3du(gen) ) {
u3_noun ter = u3r_at(u3x_con_3, van);
u3_noun fab = u3r_at(u3qzu_van_fab, van);
u3_noun rex = u3qzp_open(ter, fab, gen);
ret = _mint_in(van, sut, gol, rex);
u3z(rex);
return ret;
}
else if ( c3y == u3du(u3h(gen)) ) {
_mint_used();
{
u3_noun hed = _mint_in(van, sut, c3__noun, u3h(gen));
u3_noun tal = _mint_in(van, sut, c3__noun, u3t(gen));
u3_noun typ = u3qz_cell(u3h(hed), u3h(tal));
ret = u3nc(_mint_nice(van, gol, typ),
u3qz_cons(u3t(hed),
u3t(tal)));
u3z(hed);
u3z(tal);
return ret;
}
} else switch ( u3h(gen) ) {
default: {
u3_noun ter = u3r_at(u3x_con_3, van);
u3_noun fab = u3r_at(u3qzu_van_fab, van);
u3_noun rex = u3qzp_open(ter, fab, gen);
if ( c3y == u3r_sing(rex, gen) ) {
#if 1
u3_noun zix = u3qzu_shep(van, "gene", 'q', u3k(gen));
u3t_push(u3nc(c3__mean, zix));
return u3m_error("mint-open");
#else
u3_err("h", u3h(gen));
return u3m_bail(c3__fail);
#endif
}
ret = _mint_in(van, sut, gol, rex);
u3z(rex);
return ret;
}
case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun wam = u3qzu_play(van, sut, p_gen);
u3_noun dok = u3nc(c3__wing, u3k(q_gen));
u3_noun vol = _mint_corn(van, sut, dok);
u3_noun axe = _mint_coke(vol);
ret = u3nc(_mint_nice(van, gol, _mint_bean()),
u3qzu_fish(van, wam, axe));
u3z(axe);
u3z(vol);
u3z(wam);
u3z(dok);
return ret;
}
case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
_mint_used();
{
u3_noun bol = _mint_bean();
u3_noun nor = _mint_in(van, sut, bol, p_gen);
u3_noun fex = u3qzu_gain(van, sut, p_gen);
u3_noun wux = u3qzu_lose(van, sut, p_gen);
u3_noun duy = (c3__void == fex)
? ( (c3__void == wux)
? u3nc(0, 0)
: u3nc(1, 1) )
: ( (c3__void == wux)
? u3nc(1, 0)
: u3k(u3t(nor)) );
u3_noun hiq = _mint_in(van, fex, gol, q_gen);
u3_noun ran = _mint_in(van, wux, gol, r_gen);
ret = u3nc(u3qz_forq(u3h(hiq),
u3h(ran)),
_mint_cond(duy,
u3k(u3t(hiq)),
u3k(u3t(ran))));
u3z(ran);
u3z(hiq);
u3z(nor);
u3z(wux);
u3z(fex);
u3z(bol);
return ret;
}
case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun hed = _mint_in(van, sut, c3__noun, p_gen);
u3_noun tal = _mint_in(van, sut, c3__noun, q_gen);
u3_noun typ = u3qz_cell(u3h(hed), u3h(tal));
ret = u3nc(_mint_nice(van, gol, typ),
u3qz_cons(u3t(hed),
u3t(tal)));
u3z(hed);
u3z(tal);
return ret;
}
case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun typ = _mint_nice(van, gol, _mint_bean());
u3_noun one = _mint_in(van, sut, c3__noun, p_gen);
u3_noun two = _mint_in(van, sut, c3__noun, q_gen);
u3_noun ret;
if ( (c3y == _mint_vet(van)) &&
(c3n == u3qzu_nest(van, u3h(one), c3n, u3h(two))) &&
(c3n == u3qzu_nest(van, u3h(two), c3y, u3h(one))) )
{
return u3m_error("nest");
}
ret = u3nc(typ, u3nt(5, u3k(u3t(one)), u3k(u3t(two))));
u3z(one);
u3z(two);
return ret;
}
case c3__dtwt: p_gen = u3t(gen);
_mint_used();
{
u3_noun typ = _mint_nice(van, gol, _mint_bean());
return u3nc(typ,
u3nc(3, _mint_corn(van, sut, p_gen)));
}
case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun nog = u3nc(c3__bcdt, u3k(p_gen));
u3_noun nef = _mint_in(van, sut, gol, nog);
u3_noun viz = _mint_in(van, sut, c3__noun, q_gen);
ret = u3nc(u3k(u3h(nef)),
u3nt(11, u3nc(1, u3nc(151, u3k(u3h(nef)))), u3k(u3t(viz))));
u3z(viz);
u3z(nef);
u3z(nog);
return ret;
}
case c3__dtls: p_gen = u3t(gen);
_mint_used();
{
u3_noun tom = u3nt(c3__atom, u3_blip, u3_nul);
u3_noun sam = _mint_in(van, sut, tom, p_gen);
ret = u3nc(_mint_nice(van, gol, tom),
u3nc(4, u3k(u3t(sam))));
u3z(sam);
return ret;
}
case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun typ = u3qzu_play(van, sut, gen);
u3_noun ret = u3nc(_mint_nice(van, gol, typ),
u3nc(1, u3k(q_gen)));
return ret;
}
case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun one = _mint_corn(van, sut, p_gen);
u3_noun two = _mint_corn(van, sut, q_gen);
return u3nc(_mint_nice(van, gol, c3__noun),
u3nt(2, one, two));
}
case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun typ = u3qzu_play(van, sut, gen);
u3_noun ret = u3nc(_mint_nice(van, gol, typ),
u3nc(1, u3k(q_gen)));
return ret;
}
case c3__hand:
_mint_used();
{
return u3k(u3t(gen));
}
case c3__ktbr: p_gen = u3t(gen);
_mint_used();
{
u3_noun ryd = _mint_in(van, sut, gol, p_gen);
u3_noun tyf = u3qzu_wrap(van, u3h(ryd), c3__iron);
u3_noun pro = u3nc(tyf, u3k(u3t(ryd)));
u3z(ryd);
return pro;
}
case c3__ktpd:
case c3__ktpm: p_gen = u3t(gen);
_mint_used();
{
u3_noun ryd = _mint_in(van, sut, gol, p_gen);
u3_noun tyf = u3qzu_wrap(van, u3h(ryd), c3__zinc);
u3_noun pro = u3nc(tyf, u3k(u3t(ryd)));
u3z(ryd);
return pro;
}
case c3__ktwt: p_gen = u3t(gen);
_mint_used();
{
u3_noun ryd = _mint_in(van, sut, gol, p_gen);
u3_noun tyf = u3qzu_wrap(van, u3h(ryd), c3__lead);
u3_noun pro = u3nc(tyf, u3k(u3t(ryd)));
u3z(ryd);
return pro;
}
case c3__note: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun hit = u3nc(u3k(sut), u3k(p_gen));
u3_noun hum = _mint_in(van, sut, gol, q_gen);
u3_noun ret = u3nc(u3qz_hint(hit, u3h(hum)),
u3k(u3t(hum)));
u3z(hum);
u3z(hit);
return ret;
}
case c3__tune: p_gen = u3t(gen);
_mint_used();
{
return u3nc(u3qz_face(p_gen, sut), u3nc(0, 1));
}
case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun huz = u3qzu_play(van, sut, p_gen);
u3_noun hif = _mint_nice(van, gol, huz);
u3_noun zel = _mint_in(van, sut, hif, q_gen);
u3_noun ret = u3nc(hif, u3k(u3t(zel)));
u3z(zel);
return ret;
}
case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun fid = _mint_in(van, sut, c3__noun, p_gen);
u3_noun p_fid = u3h(fid);
u3_noun q_fid = u3t(fid);
if ( 0 == p_fid ) {
u3m_p("bad subject: p_gen", p_gen);
c3_assert(0);
}
u3_noun dov = _mint_in(van, p_fid, gol, q_gen);
u3_noun p_dov = u3h(dov);
u3_noun q_dov = u3t(dov);
ret = u3nc(u3k(p_dov),
u3qz_comb(q_fid, q_dov));
u3z(fid);
u3z(dov);
return ret;
}
case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun boc = u3qzu_busk(van, sut, p_gen);
u3_noun ret = _mint_in(van, boc, gol, q_gen);
u3z(boc);
return ret;
}
case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
return _mint_cnts(van, sut, gol, p_gen, q_gen);
}
case c3__brcn: p_gen = u3t(gen);
_mint_used();
{
u3_noun ruf = u3nc(u3_nul, 1);
ret = _mint_grow(van, sut, gol, c3__gold, ruf, p_gen);
u3z(ruf);
return ret;
}
case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun typ = u3qzu_play(van, sut, p_gen);
u3_noun dug = u3qzu_duck(van, typ);
u3t_push(u3nc(c3__mean, dug));
{
ret = _mint_in(van, sut, gol, q_gen);
}
u3t_drop();
u3z(typ);
return ret;
}
case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun hum = _mint_in(van, sut, gol, q_gen);
u3_noun bez;
if ( c3y == u3ud(p_gen) ) {
bez = u3k(p_gen);
} else {
bez = u3nc(u3k(u3h(p_gen)),
_mint_corn(van, sut, u3t(p_gen)));
}
ret = u3nc(u3k(u3h(hum)),
u3nt(10, bez, u3k(u3t(hum))));
u3z(hum);
return ret;
}
case c3__zpts: p_gen = u3t(gen);
_mint_used();
{
u3_noun von = u3i_molt(u3k(van), u3qzu_van_vet, c3n, 0);
u3_noun sev = _mint_corn(von, sut, p_gen);
u3z(von);
return u3nc(c3__noun, u3nc(1, sev));
}
case c3__ktcn: p_gen = u3t(gen);
_mint_used();
{
u3_noun von = u3i_molt(u3k(van), u3qzu_van_fab, c3n, 0);
u3_noun ret = _mint_in(von, sut, gol, p_gen);
u3z(von);
return ret;
}
case c3__cold:
case c3__ktsg: p_gen = u3t(gen);
_mint_used();
{
c3_m fun_m = 144 + c3__blow;
u3_noun vrf = u3r_at(u3qzu_van_vrf, van);
u3_noun pro = u3z_find_4(fun_m, vrf, sut, gol, p_gen);
if ( u3_none != pro ) {
return pro;
}
else {
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "blow");
u3_noun pro;
pro = u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(gol),
u3x_sam_3,
u3k(p_gen),
0));
return u3z_save_4(fun_m, vrf, sut, gol, p_gen, pro);
}
}
case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
return u3nc(_mint_nice(van,
gol,
u3qzu_play(van, sut, p_gen)),
u3nc(1, u3k(q_gen)));
}
case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen);
{
u3t_push(u3nc(c3__mean, _mint_loc(van, p_gen)));
{
u3_noun hum = _mint_in(van, sut, gol, q_gen);
u3_noun bez = u3nt(c3__spot, 1, u3k(p_gen));
ret = u3nc(u3k(u3h(hum)), u3nt(10, bez, u3k(u3t(hum))));
u3z(hum);
}
u3t_drop();
return ret;
}
case c3__zpmc:
case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mint_used();
{
u3_noun vos = _mint_in(van, sut, c3__noun, q_gen);
u3_noun zur = u3qzu_play(van, sut, p_gen);
u3_noun p_vos = u3h(vos);
u3_noun q_vos = u3t(vos);
u3_noun waz = u3nc(1, _mint_burp(van, p_vos));
// u3_noun waz = u3nc(1, u3k(p_vos));
u3_noun sif = u3k(zur);
u3_noun cig = u3qz_cell(sif, p_vos);
u3_noun ret;
ret = u3nc(_mint_nice(van, gol, cig),
u3qz_cons(waz, q_vos));
u3z(waz);
u3z(zur);
u3z(sif);
u3z(vos);
return ret;
}
case c3__zpvt: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
_mint_used();
{
if ( c3y == _mint_feel(van, sut, p_gen) ) {
return _mint_in(van, sut, gol, q_gen);
} else {
return _mint_in(van, sut, gol, r_gen);
}
}
case c3__lost: p_gen = u3t(gen);
_mint_used();
{
if ( c3y == _mint_vet(van) ) {
u3_noun zur = u3qzu_play(van, sut, p_gen);
u3_noun dun = u3qzu_dunq(van, "lost", zur);
u3t_push(u3nc(c3__mean, dun));
return u3m_error("mint-lost");
}
else {
return u3nt(c3__void, 0, 0);
}
}
case c3__fail:
case c3__zpzp:
_mint_used();
{
return u3nt(c3__void, 0, 0);
}
}
}
static u3_noun
_cqzu_mint(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun gen)
{
return _mint_in(van, sut, gol, gen);
}
/* boilerplate
*/
u3_noun
u3wzu_mint(u3_noun cor)
{
u3_noun sut, gol, gen, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol,
u3x_sam_3, &gen,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_mint(van, sut, gol, gen);
}
}
u3_noun
u3qzu_mint(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun gen)
{
c3_m fun_m = 144 + c3__mint;
u3_noun vrf = u3r_at(u3qzu_van_vrf, van);
u3_noun pro = u3z_find_4(fun_m, vrf, sut, gol, gen);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_mint(van, sut, gol, gen);
return u3z_save_4(fun_m, vrf, sut, gol, gen, pro);
}
}

View File

@ -1,757 +0,0 @@
/* j/6/mull.c
**
*/
#include "all.h"
/* functions
*/
static u3_noun
_mull_in(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
static u3_noun
_mull_bean()
{
return u3kf_fork(u3nt(u3nq(c3__atom, 'f', u3_nul, 0),
u3nq(c3__atom, 'f', u3_nul, 1),
u3_nul));
}
static u3_noun
_mull_loc(u3_noun van,
u3_noun loc)
{
u3_noun mol = u3nc('o', u3k(loc));
u3_noun sho = u3j_hook(u3k(van), "show");
u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0);
u3z(mol);
u3z(sho);
return ret;
}
static u3_noun
_mull_feel(u3_noun van,
u3_noun sut,
u3_noun rot)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "feel");
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(rot),
0));
}
static u3_noun
_mull_coke(u3_noun nug)
{
if ( 0 == u3h(nug) ) {
return u3k(u3t(nug));
}
else if ( 10 == u3h(nug) ) {
return _mull_coke(u3t(u3t(nug)));
}
else {
return u3m_error("mull-coke");
}
}
static u3_noun
_mull_mile(u3_noun van,
u3_noun sut,
u3_noun dox,
u3_noun mel,
u3_noun dom)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "mile");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(dox),
u3x_sam_6,
u3k(mel),
u3x_sam_7,
u3k(dom),
0));
}
static u3_noun
_mull_doke(u3_noun van,
u3_noun sut,
u3_noun gen)
{
u3_noun fug = u3qzu_mint(van, sut, c3__noun, gen);
u3_noun axe = _mull_coke(u3t(fug));
u3z(fug);
return axe;
}
static u3_noun
_mull_nice(u3_noun van,
u3_noun gol,
u3_noun typ)
{
if ( c3n == u3qzu_nest(van, gol, c3y, typ) ) {
// u3_noun dun = u3qzu_dunq(van, "need", gol);
// u3_noun niz = u3qzu_dunq(van, "have", typ);
// u3t_push(u3nc(c3__mean, dun));
// u3t_push(u3nc(c3__mean, niz));
return u3m_error("mull-nice");
}
else return typ;
}
static u3_noun
_mull_grow(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun dox,
u3_atom mel,
u3_noun ruf,
u3_noun dom)
{
u3_noun dan = _mull_in(van, sut, c3__noun, dox, ruf);
u3_noun p_dan = u3h(dan);
u3_noun q_dan = u3t(dan);
u3_noun yaz = _mull_mile(van, p_dan, q_dan, mel, dom);
u3_noun p_yaz = u3h(yaz);
u3_noun q_yaz = u3t(yaz);
u3_noun ret = u3nc(_mull_nice(van, gol, u3k(p_yaz)), u3k(q_yaz));
u3z(yaz);
u3z(dan);
return ret;
}
static u3_noun
_mull_both(u3_noun van,
u3_noun gol,
u3_noun typ)
{
return u3nc(_mull_nice(van, gol, u3k(typ)),
typ);
}
#if 1
static u3_noun
_mull_cnts(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun dox,
u3_noun hyp,
u3_noun rig)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "emul");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(gol),
u3x_sam_6,
u3k(dox),
u3x_sam_14,
u3k(hyp),
u3x_sam_15,
u3k(rig),
0));
}
#else
static u3_noun
_mull_edit(u3_noun van,
u3_noun sut,
u3_noun dox,
u3_noun mew,
u3_noun p_yom,
u3_noun q_yom)
{
while ( 1 ) {
if ( c3n == u3du(mew) ) {
return u3nc(p_yom, q_yom);
} else {
u3_noun i_mew = u3h(mew);
u3_noun t_mew = u3t(mew);
u3_noun pi_mew = u3h(i_mew);
u3_noun qi_mew = u3t(i_mew);
u3_noun zil = _mull_in(van, sut, c3__noun, dox, qi_mew);
u3_noun p_zil = u3h(zil);
u3_noun q_zil = u3t(zil);
u3_noun cuf = u3qzu_toss(van, sut, pi_mew, p_zil, p_yom);
u3_noun dof = u3qzu_toss(van, sut, pi_mew, q_zil, q_yom);
if ( u3r_sing(u3h(cuf), u3h(dof)) ) {
u3m_error("mull-bonk-a");
}
u3z(p_yom);
p_yom = u3k(u3t(cuf));
u3z(q_yom);
q_yom = u3k(u3t(dof));
u3z(dof);
u3z(cuf);
u3z(zil);
mew = t_mew;
}
}
}
static u3_noun
_mull_cnts_old(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun dox,
u3_noun hyp,
u3_noun rig)
{
u3_noun lar = u3qzu_seek(van, sut, c3__read, hyp);
u3_noun vug = u3qzu_seek(van, dox, c3__read, hyp);
u3_noun p_lar = u3h(lar);
u3_noun q_lar = u3t(lar);
u3_noun pq_lar = u3h(q_lar);
u3_noun qq_lar = u3t(q_lar);
u3_noun p_vug = u3h(vug);
u3_noun q_vug = u3t(vug);
u3_noun pq_vug = u3h(q_vug);
u3_noun qq_vug = u3t(q_vug);
if ( c3a(u3r_sing(p_lar, p_vug), u3r_sing(pq_lar, pq_vug)) ) {
u3m_error("mull-bonk-e");
}
{
u3_noun mew = rig;
u3_noun yom = _mull_edit
(van, sut, dox, mew, u3k(qq_lar),
u3k(qq_vug));
u3_noun von = u3i_molt(u3k(van), u3qzu_van_vet, c3n, 0);
u3_noun p_ret = u3qzu_fire(van, sut, u3h(yom));
u3_noun q_ret = u3qzu_fire(von, sut, u3t(yom));
u3z(von);
u3z(yom);
u3z(vug);
u3z(lar);
return u3nc(_mull_nice(van, gol, p_ret), q_ret);
}
}
#endif
# define _mull_used()
static u3_noun
_mull_in(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun dox,
u3_noun gen)
{
u3_noun p_gen, q_gen, r_gen;
u3_noun ret;
if ( c3n == u3du(gen) ) {
u3_noun ter = u3r_at(u3x_con_3, van);
u3_noun fab = u3r_at(u3qzu_van_fab, van);
u3_noun rex = u3qzp_open(ter, fab, gen);
ret = _mull_in(van, sut, gol, dox, rex);
u3z(rex);
return ret;
}
else if ( c3y == u3du(u3h(gen)) ) {
_mull_used();
{
u3_noun hed = _mull_in(van, sut, c3__noun, dox, u3h(gen));
u3_noun tal = _mull_in(van, sut, c3__noun, dox, u3t(gen));
u3_noun dis = u3qz_cell(u3h(hed), u3h(tal));
u3_noun dat = u3qz_cell(u3t(hed), u3t(tal));
u3_noun ret = u3nc(_mull_nice(van, gol, dis), dat);
u3z(tal);
u3z(hed);
return ret;
}
}
else switch ( u3h(gen) ) {
default: {
u3_noun ter = u3r_at(u3x_con_3, van);
u3_noun fab = u3r_at(u3qzu_van_fab, van);
u3_noun rex = u3qzp_open(ter, fab, gen);
if ( c3y == u3r_sing(rex, gen) ) {
#if 1
u3_noun zix = u3qzu_shep(van, "gene", 'q', u3k(gen));
u3t_push(u3nc(c3__mean, zix));
return u3m_error("mull-open");
#else
u3_err("h", u3h(gen));
return u3m_bail(c3__fail);
#endif
}
ret = _mull_in(van, sut, gol, dox, rex);
u3z(rex);
return ret;
}
case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun p_waz = u3qzu_play(van, sut, p_gen);
u3_noun q_waz = u3qzu_play(van, dox, p_gen);
u3_noun dok = u3nc(c3__wing, u3k(q_gen));
u3_noun p_syx = _mull_doke(van, sut, dok);
u3_noun q_syx = _mull_doke(van, dox, dok);
u3_noun p_pov = u3qzu_fish(van, p_waz, p_syx);
u3_noun q_pov = u3qzu_fish(van, q_waz, q_syx);
if ( (c3n == u3r_sing(p_syx, q_syx)) ||
(c3n == u3r_sing(p_pov, q_pov)) )
{
return u3m_error("mull-bonk-b");
}
u3z(p_waz); u3z(q_waz);
u3z(p_syx); u3z(q_syx);
u3z(p_pov); u3z(q_pov);
u3z(dok);
return _mull_both(van, gol, _mull_bean());
}
case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
_mull_used();
{
u3_noun bol = _mull_bean();
u3_noun nor = _mull_in(van, sut, bol, dox, p_gen);
u3_noun p_fex = u3qzu_gain(van, sut, p_gen);
u3_noun q_fex = u3qzu_gain(van, dox, p_gen);
u3_noun p_wux = u3qzu_lose(van, sut, p_gen);
u3_noun q_wux = u3qzu_lose(van, dox, p_gen);
u3_noun hiq, ran;
u3_noun dis, dat;
u3_noun ret;
if ( c3__void == p_fex ) {
hiq = u3nc(c3__void,
(c3__void == q_fex)
? c3__void
: u3qzu_play(van, q_fex, q_gen));
} else if ( c3__void == q_fex ) {
hiq = u3m_error("mull-bonk-c");
}
else hiq = _mull_in(van, p_fex, gol, q_fex, q_gen);
if ( c3__void == p_wux ) {
ran = u3nc(c3__void,
(c3__void == q_wux)
? c3__void
: u3qzu_play(van, q_wux, r_gen));
} else if ( c3__void == q_wux ) {
ran = u3m_error("mull-bonk-d");
}
else ran = _mull_in(van, p_wux, gol, q_wux, r_gen);
dis = u3qz_forq(u3h(hiq), u3h(ran));
dat = u3qz_forq(u3t(hiq), u3t(ran));
ret = u3nc(_mull_nice(van, gol, dis), dat);
u3z(ran);
u3z(hiq);
u3z(q_wux);
u3z(p_wux);
u3z(q_fex);
u3z(p_fex);
u3z(nor);
u3z(bol);
return ret;
}
case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun hed = _mull_in(van, sut, c3__noun, dox, p_gen);
u3_noun tal = _mull_in(van, sut, c3__noun, dox, q_gen);
u3_noun dis = u3qz_cell(u3h(hed), u3h(tal));
u3_noun dat = u3qz_cell(u3t(hed), u3t(tal));
u3_noun ret = u3nc(_mull_nice(van, gol, dis), dat);
u3z(tal);
u3z(hed);
return ret;
}
case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun hed = _mull_in(van, sut, c3__noun, dox, p_gen);
u3_noun tal = _mull_in(van, sut, c3__noun, dox, q_gen);
u3z(hed);
u3z(tal);
return _mull_both(van, gol, _mull_bean());
}
case c3__dtwt: p_gen = u3t(gen);
_mull_used();
{
u3_noun vay = _mull_in(van, sut, c3__noun, dox, p_gen);
u3z(vay);
return _mull_both(van, gol, _mull_bean());
}
case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun nog = u3nc(c3__bcdt, u3k(p_gen));
u3_noun vay = _mull_in(van, sut, c3__noun, dox, q_gen);
u3_noun ret;
u3z(vay);
ret = _mull_in(van, sut, gol, dox, nog);
u3z(nog);
return ret;
}
case c3__dtls: p_gen = u3t(gen);
_mull_used();
{
u3_noun wuq = u3nt(c3__atom, u3_blip, u3_nul);
u3_noun vay = _mull_in(van, sut, wuq, dox, p_gen);
u3z(vay);
return _mull_both(van, gol, wuq);
}
case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun typ = u3qzu_play(van, sut, gen);
return _mull_both(van, gol, typ);
}
case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun hed = _mull_in(van, sut, c3__noun, dox, p_gen);
u3_noun tal = _mull_in(van, sut, c3__noun, dox, q_gen);
u3z(hed);
u3z(tal);
return _mull_both(van, gol, c3__noun);
}
case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun typ = u3qzu_play(van, sut, gen);
return _mull_both(van, gol, typ);
}
case c3__hand: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
return u3nc(u3k(p_gen), u3k(p_gen));
}
case c3__ktbr: p_gen = u3t(gen);
_mull_used();
{
u3_noun vat = _mull_in(van, sut, gol, dox, p_gen);
u3_noun pro = u3nc(u3qzu_wrap(van,
u3h(vat),
c3__iron),
u3qzu_wrap(van,
u3t(vat),
c3__iron));
u3z(vat);
return pro;
}
case c3__ktpd:
case c3__ktpm: p_gen = u3t(gen);
_mull_used();
{
u3_noun vat = _mull_in(van, sut, gol, dox, p_gen);
u3_noun pro = u3nc(u3qzu_wrap(van,
u3h(vat),
c3__zinc),
u3qzu_wrap(van,
u3t(vat),
c3__zinc));
u3z(vat);
return pro;
}
case c3__ktwt: p_gen = u3t(gen);
_mull_used();
{
u3_noun vat = _mull_in(van, sut, gol, dox, p_gen);
u3_noun pro = u3nc(u3qzu_wrap(van,
u3h(vat),
c3__lead),
u3qzu_wrap(van,
u3t(vat),
c3__lead));
u3z(vat);
return pro;
}
case c3__note: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun vat = _mull_in(van, sut, gol, dox, q_gen);
u3_noun hit = u3nc(u3k(sut), u3k(p_gen));
u3_noun hix = u3nc(u3k(dox), u3k(p_gen));
u3_noun ret = u3nc(u3qz_hint(hit, u3h(vat)),
u3qz_hint(hix, u3t(vat)));
u3z(hix);
u3z(hit);
u3z(vat);
return ret;
}
case c3__tune: p_gen = u3t(gen);
_mull_used();
{
return u3nc(u3qz_face(p_gen, sut),
u3qz_face(p_gen, dox));
}
case c3__ktsg: p_gen = u3t(gen);
_mull_used();
{
return _mull_in(van, sut, gol, dox, p_gen);
}
case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun p_hif = _mull_nice(van, gol, u3qzu_play(van, sut, p_gen));
u3_noun q_hif = u3qzu_play(van, dox, p_gen);
u3_noun zel = _mull_in(van, sut, p_hif, dox, q_gen);
u3_noun ret = u3nc(p_hif, q_hif);
u3z(zel);
return ret;
}
case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun lem = _mull_in(van, sut, c3__noun, dox, p_gen);
u3_noun p_lem = u3h(lem);
u3_noun q_lem = u3t(lem);
u3_noun ret = _mull_in(van, p_lem, gol, q_lem, q_gen);
u3z(lem);
return ret;
}
case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun boc = u3qzu_busk(van, sut, p_gen);
u3_noun nuf = u3qzu_busk(van, dox, p_gen);
u3_noun ret = _mull_in(van, boc, gol, nuf, q_gen);
u3z(boc);
u3z(nuf);
return ret;
}
case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
return _mull_cnts(van, sut, gol, dox, p_gen, q_gen);
}
case c3__brcn: p_gen = u3t(gen);
_mull_used();
{
u3_noun ruf = u3nc(u3_nul, 1);
ret = _mull_grow(van, sut, gol, dox, c3__gold, ruf, p_gen);
u3z(ruf);
return ret;
}
case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun typ = u3qzu_play(van, sut, p_gen);
u3_noun dug = u3qzu_duck(van, typ);
u3_noun ret;
u3t_push(u3nc(c3__mean, dug));
{
ret = _mull_in(van, sut, gol, dox, q_gen);
}
u3t_drop();
u3z(typ);
return ret;
}
case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
return _mull_in(van, sut, gol, dox, q_gen);
}
case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun p_ret = u3qzu_play(van, sut, p_gen);
u3_noun q_ret = u3qzu_play(van, sut, q_gen);
return u3nc(_mull_nice(van, gol, p_ret),
q_ret);
}
case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen);
{
u3_noun ret;
u3t_push(u3nc(c3__mean, _mull_loc(van, p_gen)));
{
ret = _mull_in(van, sut, gol, dox, q_gen);
}
u3t_drop();
return ret;
}
case c3__zpts: p_gen = u3t(gen);
_mull_used();
{
return _mull_both(van, gol, c3__noun);
}
case c3__ktcn: p_gen = u3t(gen);
_mull_used();
{
u3_noun von = u3i_molt(u3k(van), u3qzu_van_fab, c3n, 0);
u3_noun ret = _mull_in(von, sut, gol, dox, p_gen);
u3z(von);
return ret;
}
case c3__zpmc:
case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_mull_used();
{
u3_noun p_zur = u3qzu_play(van, sut, p_gen);
u3_noun q_zur = u3qzu_play (van, dox, p_gen);
u3_noun vos = _mull_in(van, sut, c3__noun, dox, q_gen);
u3_noun p_ret = u3qz_cell(p_zur, u3h(vos));
u3_noun q_ret = u3qz_cell(q_zur, u3t(vos));
u3z(vos);
u3z(q_zur);
u3z(p_zur);
return u3nc
(_mull_nice(van, gol, p_ret), q_ret);
}
case c3__zpvt: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
_mull_used();
{
c3_o fes = _mull_feel(van, sut, p_gen);
c3_o fed = _mull_feel(van, dox, p_gen);
if ( fes != fed ) {
return u3m_error("mull-bonk-f");
}
else {
if ( c3y == fes ) {
return _mull_in(van, sut, gol, dox, q_gen);
} else {
return _mull_in(van, sut, gol, dox, r_gen);
}
}
}
case c3__lost:
case c3__fail:
case c3__zpzp:
_mull_used();
{
return u3nc(c3__void, c3__void);
}
}
}
static u3_noun
_cqzu_mull(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun dox,
u3_noun gen)
{
return _mull_in(van, sut, gol, dox, gen);
}
/* boilerplate
*/
u3_noun
u3wzu_mull(u3_noun cor)
{
u3_noun sut, gol, dox, gen, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &gol,
u3x_sam_6, &dox,
u3x_sam_7, &gen,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_mull(van, sut, gol, dox, gen);
}
}
u3_noun
u3qzu_mull(u3_noun van,
u3_noun sut,
u3_noun gol,
u3_noun dox,
u3_noun gen)
{
c3_m fun_m = 144 + c3__mull + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_4(fun_m, sut, gol, dox, gen);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_mull(van, sut, gol, dox, gen);
return u3z_save_4(fun_m, sut, gol, dox, gen, pro);
}
}

View File

@ -1,566 +0,0 @@
/* j/6/ut_nest.c
**
*/
#include "all.h"
/* logic
*/
/* forward
*/
static u3_noun
_nest_sint(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
static u3_noun
_nest_dext(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
static u3_noun
_nest_deep(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref,
u3_noun dab,
u3_noun hem,
u3_noun gil)
{
if ( u3_nul == dab ) {
return u3r_sing(u3_nul, hem);
} else if ( u3_nul == hem ) {
return c3n;
} else {
u3_noun n_dab, l_dab, r_dab;
u3_noun n_hem, l_hem, r_hem;
u3_noun pn_hem, pqn_hem, qqn_hem, pn_dab, pqn_dab, qqn_dab;
u3x_trel(dab, &n_dab, &l_dab, &r_dab);
u3x_trel(hem, &n_hem, &l_hem, &r_hem);
if ( (c3n == _nest_deep(van, sut, tel, ref, l_dab, l_hem, gil)) ||
(c3n == _nest_deep(van, sut, tel, ref, r_dab, r_hem, gil)) )
{
return c3n;
}
u3x_trel(n_dab, &pn_dab, &pqn_dab, &qqn_dab);
u3x_trel(n_hem, &pn_hem, &pqn_hem, &qqn_hem);
if ( c3n == u3r_sing(pn_dab, pn_hem) ) {
return c3n;
} else {
if ( (c3n == u3du(qqn_dab)) || (c3n == u3du(qqn_hem)) ) {
return u3m_bail(c3__fail);
}
else switch ( u3h(qqn_dab) ) {
default: return u3m_bail(c3__exit);
case c3__ash: {
if ( c3__ash != u3h(qqn_hem) ) {
return c3n;
} else {
u3_noun qqqn_dab = u3t(qqn_dab);
u3_noun qqqn_hem = u3t(qqn_hem);
u3_noun vis = u3qzu_play(van, sut, qqqn_dab);
u3_noun lon = u3qzu_play(van, ref, qqqn_hem);
u3_noun ret = _nest_dext(van, vis, tel, lon, u3_nul, u3_nul, gil);
u3z(vis);
u3z(lon);
return ret;
}
}
case c3__elm: {
return u3r_sing(qqn_dab, qqn_hem);
}
}
}
}
}
static u3_noun
_nest_dope(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref,
u3_noun dom,
u3_noun vim,
u3_noun gil)
{
if ( u3_nul == dom ) {
return u3r_sing(u3_nul, vim);
} else if ( u3_nul == vim ) {
return c3n;
} else {
u3_noun n_dom, l_dom, r_dom;
u3_noun n_vim, l_vim, r_vim;
u3_noun pn_vim, qn_vim, pn_dom, qn_dom;
u3x_trel(dom, &n_dom, &l_dom, &r_dom);
u3x_trel(vim, &n_vim, &l_vim, &r_vim);
if ( (c3n == _nest_dope(van, sut, tel, ref, l_dom, l_vim, gil)) ||
(c3n == _nest_dope(van, sut, tel, ref, r_dom, r_vim, gil)) )
{
return c3n;
}
u3x_cell(n_dom, &pn_dom, &qn_dom);
u3x_cell(n_vim, &pn_vim, &qn_vim);
if ( c3n == u3r_sing(pn_dom, pn_vim) ) {
return c3n;
} else {
return _nest_deep(van, sut, tel, ref, qn_dom, qn_vim, gil);
}
}
}
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 ppq_sut, qpq_sut, rpq_sut;
u3_noun ppq_ref, qpq_ref, rpq_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_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut);
u3x_trel(pq_ref, &ppq_ref, &qpq_ref, &rpq_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, u3_nul, u3_nul, gil);
}
else if ( (c3n == _nest_dext
(van, qq_sut, tel, p_sut, u3_nul, u3_nul, gil)) ||
(c3n == _nest_dext
(van, p_sut, tel, qq_sut, u3_nul, u3_nul, gil)) ||
(c3n == _nest_dext
(van, qq_ref, tel, p_ref, u3_nul, u3_nul, gil)) )
{
return c3n;
}
else {
if ( (rpq_sut != rpq_ref) &&
(c3__lead != rpq_sut) &&
(c3__gold != rpq_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),
u3nc(u3nt(u3k(ppq_sut), u3k(qpq_sut), c3__gold),
u3k(u3t(q_sut))));
u3_noun fer = u3nt(c3__core,
u3k(qq_ref),
u3nc(u3nt(u3k(ppq_ref), u3k(qpq_ref), c3__gold),
u3k(u3t(q_ref))));
ret = _nest_dope(van, tus, tel, fer, qrq_sut, qrq_ref, zoc);
u3z(fer);
u3z(tus);
u3z(zoc);
u3z(hud);
if ( c3n == ret ) {
return c3n;
}
else {
switch ( rpq_sut ) {
default: return u3m_bail(c3__fail);
case c3__gold: {
return
c3a(_nest_dext(van, qq_sut, tel, qq_ref, u3_nul, u3_nul, gil),
_nest_dext(van, qq_ref, tel, qq_sut, u3_nul, u3_nul, gil));
}
case c3__iron: {
u3_noun s_sam = u3qzu_peek(van, qq_sut, c3__rite, 2);
u3_noun r_sam = u3qzu_peek(van, qq_ref, c3__rite, 2);
u3_noun ret = _nest_dext
(van, r_sam, tel, s_sam, u3_nul, u3_nul, gil);
u3z(r_sam);
u3z(s_sam);
return ret;
}
case c3__lead: {
return c3y;
}
case c3__zinc: {
u3_noun s_pal = u3qzu_peek(van, qq_sut, c3__read, 2);
u3_noun r_pal = u3qzu_peek(van, qq_ref, c3__read, 2);
u3_noun ret = _nest_dext
(van, s_pal, tel, r_pal, u3_nul, u3_nul, gil);
u3z(r_pal);
u3z(s_pal);
return ret;
}
}
}
}
}
}
}
static u3_noun
_nest_dext_in(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref,
u3_noun seg,
u3_noun reg,
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, seg, reg, gil);
}
}
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 ( c3y == u3r_pq(ref, c3__atom, &p_ref, &q_ref) ) {
if ( (c3n == u3qz_fitz(p_sut, p_ref)) ||
( (c3y == u3du(q_sut)) &&
( (c3n == u3du(q_ref)) ||
(c3n == u3r_sing(q_sut, q_ref)))) )
{
return c3n;
}
return c3y;
}
return _nest_sint(van, sut, tel, ref, seg, reg, 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, u3_nul, u3_nul, gil),
_nest_dext(van, q_sut, tel, q_ref, u3_nul, u3_nul, gil));
}
else return _nest_sint(van, sut, tel, ref, seg, reg, 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, seg, reg, gil);
}
}
case c3__hint:
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, seg, reg, gil);
}
}
case c3__fork: p_sut = u3t(sut);
{
if ( c3n == u3du(ref) ) switch ( ref ) {
default: return _nest_sint(van, sut, tel, ref, seg, reg, gil);
case c3__noun:
break;
}
else switch ( u3h(ref) ) {
default: return _nest_sint(van, sut, tel, ref, seg, reg, gil);
case c3__atom:
case c3__cell:
case c3__core:
break;
}
{
u3_noun dey = u3qdi_tap(p_sut);
u3_noun yed = dey;
while ( u3_nul != yed ) {
if ( c3y == _nest_dext(van, u3h(yed), c3n, ref, seg, reg, gil) ) {
u3z(dey);
return c3y;
} else {
yed = u3t(yed);
}
}
u3z(dey);
return c3n;
}
}
case c3__hold:
{
if ( c3y == u3qdi_has(seg, sut) ) {
return c3n;
}
else {
u3_noun hud = u3nc(u3k(sut), u3k(ref));
if ( (c3y == u3qdi_has(gil, hud)) ) {
u3z(hud);
return c3y;
}
else {
u3_noun gus = u3qdi_put(seg, sut);
u3_noun zoc = u3qdi_put(gil, hud);
u3_noun fop = u3qzu_repo(van, sut);
u3_noun hiv = _nest_dext(van, fop, tel, ref, gus, reg, zoc);
u3z(hud);
u3z(fop);
u3z(zoc);
u3z(gus);
return hiv;
}
}
}
}
}
static u3_noun
_nest_dext_to(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref,
u3_noun seg,
u3_noun reg,
u3_noun gil)
{
u3_noun tyn = _nest_dext_in(van, sut, tel, ref, seg, reg, gil);
if ( (c3y == tyn) || (c3n == tel) ) {
return tyn;
} else {
#if 0
u3_noun dun = u3qzu_dunq(van, "need", sut);
u3_noun niz = u3qzu_dunq(van, "have", ref);
u3t_push(u3nc(c3__mean, dun));
u3t_push(u3nc(c3__mean, niz));
#endif
return u3m_error("nest-fail");
}
}
static u3_noun
_nest_dext(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref,
u3_noun seg,
u3_noun reg,
u3_noun gil)
{
if ( (c3y == u3r_sing(sut, ref)) ) {
return c3y;
}
{
c3_m fun_m = 144 + c3__nest + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_2(fun_m, sut, ref);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _nest_dext_to(van, sut, tel, ref, seg, reg, gil);
if ( ((c3y == pro) && (u3_nul == reg)) ||
((c3n == pro) && (u3_nul == seg)) )
{
return u3z_save_2(fun_m, sut, ref, pro);
}
else return pro;
}
}
}
static u3_noun
_nest_sint(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref,
u3_noun seg,
u3_noun reg,
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__cell: return c3n;
case c3__core: {
u3_noun gam = u3qzu_repo(van, ref);
u3_noun hiv = _nest_dext(van, sut, tel, gam, seg, reg, gil);
u3z(gam);
return hiv;
}
case c3__hint:
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, seg, reg, gil);
}
}
case c3__fork: p_ref = u3t(ref);
{
u3_noun dey = u3qdi_tap(p_ref);
u3_noun yed = dey;
while ( u3_nul != yed ) {
if ( c3n == _nest_dext(van, sut, c3n, u3h(yed), seg, reg, gil) ) {
u3z(dey);
return c3n;
} else {
yed = u3t(yed);
}
}
u3z(dey);
return c3y;
}
case c3__hold: {
if ( c3y == u3qdi_has(reg, ref) ) {
return c3y;
}
{
u3_noun hud = u3nc(u3k(sut), u3k(ref));
if ( (c3y == u3qdi_has(gil, hud)) ) {
u3z(hud);
return c3y;
} else {
u3_noun gur = u3qdi_put(reg, ref);
u3_noun zoc = u3qdi_put(gil, hud);
u3_noun gam = u3qzu_repo(van, ref);
{
u3_noun hiv = _nest_dext(van, sut, tel, gam, seg, gur, zoc);
u3z(hud);
u3z(gam);
u3z(zoc);
u3z(gur);
return hiv;
}
}
}
}
}
}
}
static u3_noun
_cqzu_nest(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref)
{
return _nest_dext(van, sut, tel, ref, u3_nul, u3_nul, u3_nul);
}
/* boilerplate
*/
u3_noun
u3wzu_nest(u3_noun cor)
{
u3_noun sut, tel, ref, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &tel,
u3x_sam_3, &ref,
u3x_con, &van,
0)) ||
(c3n == u3ud(tel)) || (tel > 1) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_nest(van, sut, tel, ref);
}
}
u3_noun
u3qzu_nest(u3_noun van,
u3_noun sut,
u3_noun tel,
u3_noun ref)
{
#if 1
c3_m fun_m = 144 + c3__nest;
u3_noun vrf = u3r_at(u3qzu_van_vrf, van);
u3_noun pro = u3z_find_4(fun_m, vrf, sut, tel, ref);
if ( u3_none != pro ) {
// u3t_heck(c3__good);
return pro;
}
else {
pro = _cqzu_nest(van, sut, tel, ref);
// u3t_heck(c3__nest);
return u3z_save_4(fun_m, vrf, sut, tel, ref, pro);
}
#else
return _cqzu_nest(van, sut, tel, ref);
#endif
}

View File

@ -1,216 +0,0 @@
/* j/6/peek.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_cqzu_peek(u3_noun, u3_noun, u3_noun, u3_atom);
static u3_noun
_peek_in(u3_noun, u3_noun, u3_noun, u3_atom, u3_noun);
static u3_noun
_peek_fork(u3_noun van, u3_noun p_sut, u3_noun way, u3_noun axe, u3_noun gil)
{
if ( u3_nul == p_sut ) {
return u3_nul;
}
else {
return u3nc(_peek_in(van, u3h(p_sut), way, axe, gil),
_peek_fork(van, u3t(p_sut), way, axe, gil));
}
}
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 = _cqzu_peek(van, p_sut, way, tap);
}
else {
pro = _cqzu_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 ppq_sut, qpq_sut, rpq_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_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_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 = u3qzu_peel(van, sut, way, rpq_sut);
u3_noun sam = u3h(pec);
u3_noun con = u3t(pec);
if ( c3y == c3a(sam, con) ) {
pro = _cqzu_peek(van, p_sut, way, lat);
}
else {
u3_noun typ;
{
u3_noun hed, tal;
if ( c3n == sam ) {
hed = c3__noun;
} else {
hed = _cqzu_peek(van, p_sut, way, 2);
}
if ( c3n == con ) {
tal = c3__noun;
} else {
tal = _cqzu_peek(van, p_sut, way, 3);
}
typ = u3qz_cell(hed, tal);
u3z(hed);
u3z(tal);
}
pro = _cqzu_peek(van, typ, way, lat);
u3z(typ);
}
u3z(pec);
}
else {
pro = c3__noun;
}
u3z(lat);
u3z(now);
return pro;
}
}
case c3__hint:
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_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 = u3qzu_repo(van, sut);
u3_noun pro = _peek_in(van, fop, way, axe, zoc);
u3z(fop);
u3z(zoc);
return pro;
}
}
}
}
static u3_noun
_cqzu_peek(u3_noun van,
u3_noun sut,
u3_noun way,
u3_atom axe)
{
if ( 1 == axe ) {
return u3k(sut);
}
else return _peek_in(van, sut, way, axe, u3_nul);
}
/* boilerplate
*/
u3_noun
u3wzu_peek(u3_noun cor)
{
u3_noun sut, way, axe, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &way,
u3x_sam_3, &axe,
u3x_con, &van,
0)) ||
(c3n == u3ud(axe)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_peek(van, sut, way, axe);
}
}
u3_noun
u3qzu_peek(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun axe)
{
c3_m fun_m = 144 + c3__peek + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_3(fun_m, sut, way, axe);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_peek(van, sut, way, axe);
return u3z_save_3(fun_m, sut, way, axe, pro);
}
}

View File

@ -1,55 +0,0 @@
/* j/6/ut_peel.c
**
*/
#include "all.h"
/* logic
*/
u3_noun
_cqzu_peel(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun met)
{
if ( c3__gold == met ) {
return u3nc(c3y, c3y);
}
else switch ( way ) {
default: return u3m_bail(c3__fail);
case c3__both: return u3nc(c3n, c3n);
case c3__free: return u3nc(c3y, c3y);
case c3__read: return u3nc(((met == c3__zinc) ? c3y : c3n), c3n);
case c3__rite: return u3nc(((met == c3__iron) ? c3y : c3n), c3n);
}
}
/* boilerplate
*/
u3_noun
u3wzu_peel(u3_noun cor)
{
u3_noun sut, way, met, van;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &way,
u3x_sam_3, &met,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_peel(van, sut, way, met);
}
}
u3_noun
u3qzu_peel(u3_noun van,
u3_noun sut,
u3_noun way,
u3_noun met)
{
return _cqzu_peel(van, sut, way, met);
}

View File

@ -1,592 +0,0 @@
/* j/6/play.c
**
*/
#include "all.h"
/* logic
*/
# define _play_used()
static u3_noun
_play_in(u3_noun, u3_noun, u3_noun);
static u3_noun
_play_bean()
{
return u3kf_fork(u3nt(u3nq(c3__atom, 'f', u3_nul, 0),
u3nq(c3__atom, 'f', u3_nul, 1),
u3_nul));
}
static u3_noun
_play_rock(u3_noun odo, u3_noun bob)
{
if ( c3y == u3ud(bob) ) {
return u3nq(c3__atom, u3k(odo), u3_nul, u3k(bob));
}
else return u3nt(c3__cell, _play_rock(odo, u3h(bob)),
_play_rock(odo, u3t(bob)));
}
static u3_noun
_play_sand(u3_noun odo, u3_noun bob)
{
if ( c3y == u3ud(bob) ) {
if ( 'n' == odo ) {
if ( (bob != 0) ) {
return u3m_bail(c3__exit);
} else {
return u3nq(c3__atom, odo, u3_nul, bob);
}
}
if ( 'f' == odo ) {
if ( (bob > 1) ) {
return u3m_bail(c3__exit);
} else {
return _play_bean();
}
}
return u3nt(c3__atom, u3k(odo), u3_nul);
}
else return u3nt(c3__cell, _play_rock(odo, u3h(bob)),
_play_rock(odo, u3t(bob)));
}
static u3_noun
_play_core(u3_noun pac,
u3_noun con)
{
if ( (c3__void == pac) ) {
u3z(con);
return c3__void;
} else {
return u3nt(c3__core, pac, con);
}
}
static u3_noun
_play_loc(u3_noun van,
u3_noun loc)
{
u3_noun mol = u3nc('o', u3k(loc));
u3_noun sho = u3j_hook(u3k(van), "show");
u3_noun ret = u3i_molt(u3k(sho), u3x_sam, u3k(mol), 0);
u3z(mol);
u3z(sho);
return ret;
}
static u3_noun
_play_feel(u3_noun van,
u3_noun sut,
u3_noun rot)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "feel");
return u3n_kick_on(u3i_molt(gat,
u3x_sam,
u3k(rot),
0));
}
#if 0
static u3_noun
_play_loc_term(u3_noun van,
u3_noun loc)
{
u3_noun fop = u3kb_flop(u3k(u3h(loc)));
u3_noun nam = ((0 == fop) ? c3__none : u3k(u3h(fop)));
u3_noun lys = u3nt(u3k(u3h(u3t(loc))), u3k(u3t(u3t(loc))), u3_nul);
u3_noun rup = u3nc(nam, lys);
c3_c* pre_c = u3m_pretty(rup);
u3_noun pro = u3i_string(pre_c);
u3z(fop);
u3z(rup);
free(pre_c);
return pro;
}
#endif
#if 1
static u3_noun
_play_cnts(u3_noun van,
u3_noun sut,
u3_noun hyp,
u3_noun rig)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "epla");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(hyp),
u3x_sam_3,
u3k(rig),
0));
}
#else
static u3_noun
_play_edit(u3_noun van,
u3_noun sut,
u3_noun mew,
u3_noun rag)
{
while ( 1 ) {
if ( c3n == u3du(mew) ) {
return rag;
} else {
u3_noun i_mew = u3h(mew);
u3_noun t_mew = u3t(mew);
u3_noun pi_mew = u3h(i_mew);
u3_noun qi_mew = u3t(i_mew);
u3_noun laf = _play_in(van, sut, qi_mew);
u3_noun ruz = u3qzu_toss(van, sut, pi_mew, laf, rag);
u3z(laf);
u3z(rag);
rag = u3k(u3t(ruz));
u3z(ruz);
mew = t_mew;
}
}
}
static u3_noun
_play_cnts_old(u3_noun van,
u3_noun sut,
u3_noun hyp,
u3_noun rig)
{
u3_noun lar = u3qzu_seek(van, sut, c3__read, hyp);
u3_noun q_lar = u3t(lar);
u3_noun qq_lar = u3t(q_lar);
u3_noun mew = rig;
u3_noun rag = _play_edit(van, sut, mew, u3k(qq_lar));
u3_noun ret = u3qzu_fire(van, sut, rag);
u3z(rag);
u3z(lar);
return ret;
}
#endif
static u3_noun
_play_grow(u3_noun van,
u3_noun sut,
u3_atom mel,
u3_noun ruf,
u3_noun dom)
{
u3_noun dan = _play_in(van, sut, ruf);
return _play_core(dan,
u3nt(u3nt(u3_nul, c3__dry, u3k(mel)),
u3k(dan),
u3nc(u3nc(u3nc(c3__full, u3_nul), u3_nul),
u3k(dom))));
}
static u3_noun
_play_in(u3_noun van,
u3_noun sut,
u3_noun gen);
static u3_noun
_play_x(u3_noun van,
u3_noun sut,
u3_noun gen)
{
#if 1
return _play_in(van, sut, gen);
#else
u3_noun zix = u3qzu_shep
(van, "gene", 'q', u3k(gen));
u3_noun ret;
u3t_push(u3nc(c3__mean, zix));
ret = _play_in(van, sut, gen);
u3t_drop();
return ret;
#endif
}
static u3_noun
_play_in(u3_noun van,
u3_noun sut,
u3_noun gen)
{
u3_noun p_gen, q_gen, r_gen;
if ( c3n == u3du(gen) ) {
open: {
u3_noun ter = u3r_at(u3x_con_3, van);
u3_noun fab = u3r_at(u3qzu_van_fab, van);
u3_noun rex = u3qzp_open(ter, fab, gen);
u3_noun ret;
if ( c3y == u3r_sing(rex, gen) ) {
u3_noun zix = u3qzu_shep(van, "gene", 'q', u3k(gen));
u3t_push(u3nc(c3__mean, zix));
return u3m_error("play-open-z");
}
ret = _play_x(van, sut, rex);
u3z(rex);
return ret;
}
}
else if ( c3y == u3du(u3h(gen)) ) {
_play_used();
{
u3_noun dis = _play_x(van, sut, u3h(gen));
u3_noun dat = _play_x(van, sut, u3t(gen));
u3_noun ret = u3qz_cell(dis, dat);
u3z(dis);
u3z(dat);
return ret;
}
}
else switch ( u3h(gen) ) {
default: goto open;
case c3__fits: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_bean();
}
case c3__wtcl: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
_play_used();
{
u3_noun fex = u3qzu_gain(van, sut, p_gen);
u3_noun wux = u3qzu_lose(van, sut, p_gen);
u3_noun dez = (fex == c3__void) ? c3__void
: _play_x(van, fex, q_gen);
u3_noun doz = (wux == c3__void) ? c3__void
: _play_x(van, wux, r_gen);
u3_noun ret = u3qz_forq(dez, doz);
u3z(dez); u3z(doz);
u3z(fex); u3z(wux);
return ret;
}
case c3__clhp: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
u3_noun dis = _play_x(van, sut, p_gen);
u3_noun dat = _play_x(van, sut, q_gen);
u3_noun ret = u3qz_cell(dis, dat);
u3z(dis);
u3z(dat);
return ret;
}
case c3__dtkt: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
u3_noun nog = u3nc(c3__bcdt, u3k(p_gen));
u3_noun ret = _play_x(van, sut, nog);
u3z(nog);
return ret;
}
case c3__dtwt: p_gen = u3t(gen);
_play_used();
{
return _play_bean();
}
case c3__dtts: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_bean();
}
case c3__dtls: p_gen = u3t(gen);
_play_used();
{
return u3nt(c3__atom, u3_blip, u3_nul);
}
case c3__rock: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_rock(p_gen, q_gen);
}
case c3__dttr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return c3__noun;
}
case c3__sand: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_sand(p_gen, q_gen);
}
case c3__hand: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return u3k(p_gen);
}
case c3__ktbr: p_gen = u3t(gen);
_play_used();
{
u3_noun boc = _play_x(van, sut, p_gen);
u3_noun pro = u3qzu_wrap(van, boc, c3__iron);
u3z(boc);
return pro;
}
case c3__ktpm: p_gen = u3t(gen);
_play_used();
{
u3_noun boc = _play_x(van, sut, p_gen);
u3_noun pro = u3qzu_wrap(van, boc, c3__zinc);
u3z(boc);
return pro;
}
case c3__ktwt: p_gen = u3t(gen);
_play_used();
{
u3_noun boc = _play_x(van, sut, p_gen);
u3_noun pro = u3qzu_wrap(van, boc, c3__lead);
u3z(boc);
return pro;
}
case c3__note: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
u3_noun boc = _play_x(van, sut, q_gen);
u3_noun hit = u3nc(u3k(sut), u3k(p_gen));
u3_noun ret = u3qz_hint(hit, boc);
u3z(hit);
u3z(boc);
return ret;
}
case c3__tune: p_gen = u3t(gen);
_play_used();
{
return u3qz_face(p_gen, sut);
}
case c3__ktsg: p_gen = u3t(gen);
_play_used();
{
return _play_x(van, sut, p_gen);
}
case c3__ktls: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_x(van, sut, p_gen);
}
case c3__tsgr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
u3_noun boc = _play_x(van, sut, p_gen);
u3_noun ret = _play_x(van, boc, q_gen);
u3z(boc);
return ret;
}
case c3__tscm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
u3_noun boc = u3qzu_busk(van, sut, p_gen);
u3_noun ret = _play_x(van, boc, q_gen);
u3z(boc);
return ret;
}
case c3__cnts: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_cnts(van, sut, p_gen, q_gen);
}
case c3__brcn: p_gen = u3t(gen);
_play_used();
{
u3_noun ruf = u3nc(u3_nul, 1);
u3_noun ret = _play_grow(van, sut, c3__gold, ruf, p_gen);
u3z(ruf);
return ret;
}
case c3__sgzp: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
u3_noun typ = u3qzu_play(van, sut, p_gen);
u3_noun dug = u3qzu_duck(van, typ);
u3_noun ret;
u3t_push(u3nc(c3__mean, dug));
{
ret = _play_x(van, sut, q_gen);
}
u3t_drop();
u3z(typ);
return ret;
}
case c3__sggr: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_x(van, sut, q_gen);
}
case c3__zpts: p_gen = u3t(gen);
_play_used();
{
return c3__noun;
}
case c3__ktcn: p_gen = u3t(gen);
{
u3_noun von = u3i_molt(u3k(van), u3qzu_van_fab, c3n, 0);
u3_noun ret = _play_x(von, sut, p_gen);
u3z(von);
return ret;
}
case c3__zpcm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
return _play_x(van, sut, p_gen);
}
case c3__dbug: u3x_cell(u3t(gen), &p_gen, &q_gen);
{
u3_noun ret;
#if 0
{
u3_noun cog = _play_loc_term(van, p_gen);
u3t_heck(cog);
u3z(cog);
}
#endif
u3t_push(u3nc(c3__mean, _play_loc(van, p_gen)));
{
ret = _play_x(van, sut, q_gen);
}
u3t_drop();
return ret;
}
case c3__zpmc:
case c3__zpsm: u3x_cell(u3t(gen), &p_gen, &q_gen);
_play_used();
{
u3_noun zur = _play_x(van, sut, p_gen);
u3_noun vos = _play_x(van, sut, q_gen);
u3_noun ret = u3qz_cell(zur, vos);
u3z(zur);
u3z(vos);
return ret;
}
case c3__zpvt: u3x_trel(u3t(gen), &p_gen, &q_gen, &r_gen);
_play_used();
{
if ( c3y == _play_feel(van, sut, p_gen) ) {
return _play_x(van, sut, q_gen);
} else {
return _play_x(van, sut, r_gen);
}
}
case c3__lost:
case c3__fail:
case c3__zpzp:
_play_used();
{
return c3__void;
}
}
}
static u3_noun
_cqzu_play(u3_noun van,
u3_noun sut,
u3_noun gen)
{
u3_noun von = u3i_molt(u3k(van), u3qzu_van_vet, c3n, 0);
u3_noun ret = _play_x(von, sut, gen);
u3z(von);
return ret;
}
/* boilerplate
*/
u3_noun
u3wzu_play(u3_noun cor)
{
u3_noun sut, gen, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &gen, u3x_con, &van, 0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_play(van, sut, gen);
}
}
u3_noun
u3qzu_play(u3_noun van,
u3_noun sut,
u3_noun gen)
{
#if 1
c3_m fun_m = 144 + c3__play;
u3_noun vrf = u3r_at(u3qzu_van_vrf, van);
u3_noun pro = u3z_find_3(fun_m, vrf, sut, gen);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_play(van, sut, gen);
return u3z_save_3(fun_m, vrf, sut, gen, pro);
}
#else
return _cqzu_play(van, sut, gen);
#endif
}

View File

@ -1,70 +0,0 @@
/* j/6/ut_repo.c
**
*/
#include "all.h"
/* logic
*/
u3_noun
u3qzu_repo(u3_noun van,
u3_noun sut)
{
u3_noun p_sut, q_sut;
if ( c3n == u3du(sut) ) switch ( sut ) {
default: return u3k(sut);
case c3__noun: {
return u3kf_fork(u3nt(u3nt(c3__atom, u3_blip, u3_nul),
u3nt(c3__cell, c3__noun, c3__noun),
u3_nul));
}
}
else switch ( u3h(sut) ) {
default: {
u3m_p("head", u3h(sut));
return u3m_error("repo-flat");
}
case c3__core: {
if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut) ) {
return u3m_bail(c3__fail);
} else {
return u3nt(c3__cell, c3__noun, u3k(p_sut));
}
}
case c3__hint:
case c3__face: {
if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) {
return u3m_bail(c3__fail);
} else {
return u3k(q_sut);
}
}
case c3__hold: {
if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) {
return u3m_bail(c3__fail);
} else {
u3_noun old = u3nc(u3nc(u3k(p_sut), u3k(q_sut)), u3_nul);
u3_noun ret;
ret = u3qzu_rest(van, sut, old);
u3z(old);
return ret;
}
}
}
}
u3_noun
u3wzu_repo(u3_noun cor)
{
u3_noun sut;
if ( u3_none == (sut = u3r_at(u3x_sam, cor)) ) {
return u3m_bail(c3__fail);
} else {
return u3qzu_repo(cor, sut);
}
}

View File

@ -1,114 +0,0 @@
/* j/6/ut_rest.c
**
*/
#include "all.h"
/* logic
*/
static u3_noun
_rest_in_list(u3_noun van,
u3_noun leg)
{
if ( u3_nul == leg ) {
return u3_nul;
} else {
u3_noun i_leg = u3h(leg);
u3_noun t_leg = u3t(leg);
return u3nc(u3qzu_play(van, u3h(i_leg), u3t(i_leg)),
_rest_in_list(van, t_leg));
}
}
static u3_noun
_rest_in_stil(u3_noun van,
u3_noun gar)
{
u3_noun gun = u3qdi_gas(u3_nul, gar);
u3_noun yed = u3qdi_tap(gun);
u3z(gun);
return yed;
}
static u3_noun
_rest_in(u3_noun van,
u3_noun leg)
{
u3_noun gar = _rest_in_list(van, leg);
u3_noun yed = _rest_in_stil(van, gar);
u3_noun fub = u3qz_fork(yed);
u3z(gar);
u3z(yed);
return fub;
}
static u3_noun
_rest_hit_fan(u3_noun fan,
u3_noun leg)
{
if ( u3_nul == leg ) {
return c3n;
} else {
return c3o(u3qdi_has(fan, u3h(leg)),
_rest_hit_fan(fan, u3t(leg)));
}
}
static u3_noun
_cqzu_rest(u3_noun van,
u3_noun sut,
u3_noun leg)
{
u3_noun fan = u3r_at(u3qzu_van_fan, van);
if ( c3y == _rest_hit_fan(fan, leg) ) {
return u3m_error("rest-loop");
}
else {
u3_noun naf = u3qdi_gas(fan, leg);
u3_noun nav = u3i_molt(u3k(van), u3qzu_van_fan, u3k(naf), 0);
u3_noun mez = _rest_in(nav, leg);
u3z(naf);
u3z(nav);
return mez;
}
}
/* boilerplate
*/
u3_noun
u3wzu_rest(u3_noun cor)
{
u3_noun sut, leg, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &leg, u3x_con, &van, 0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_rest(van, sut, leg);
}
}
u3_noun
u3qzu_rest(u3_noun van,
u3_noun sut,
u3_noun leg)
{
c3_m fun_m = 144 + c3__rest + ((!!u3r_at(u3qzu_van_vet, van)) << 8);
u3_noun pro = u3z_find_2(fun_m, sut, leg);
if ( u3_none != pro ) {
return pro;
}
else {
pro = _cqzu_rest(van, sut, leg);
return u3z_save_2(fun_m, sut, leg, pro);
}
}

View File

@ -1,21 +0,0 @@
/* j/6/tack.c
**
*/
#include "all.h"
u3_noun
u3qzu_tack(u3_noun van,
u3_noun sut,
u3_noun hyp,
u3_noun mur)
{
u3_noun von = u3i_molt(u3k(van), u3x_sam, u3k(sut), 0);
u3_noun gat = u3j_hook(von, "tack");
return u3n_kick_on(u3i_molt(gat,
u3x_sam_2,
u3k(hyp),
u3x_sam_3,
u3k(mur),
0));
}

View File

@ -1,97 +0,0 @@
/* j/6/toss.c
**
*/
#include "all.h"
/* internals
*/
static u3_noun
_toss_in(u3_noun van,
u3_noun sut,
u3_noun peh,
u3_noun mur,
u3_noun men)
{
if ( c3n == u3du(men) ) {
return u3nc(u3_nul, u3_nul);
}
else {
u3_noun i_men = u3h(men);
u3_noun pi_men = u3h(i_men);
u3_noun qi_men = u3t(i_men);
u3_noun t_men = u3t(men);
u3_noun geq = u3qzu_tack(van, pi_men, peh, mur);
u3_noun p_geq = u3h(geq);
u3_noun q_geq = u3t(geq);
u3_noun mox = _toss_in(van, sut, peh, mur, t_men);
u3_noun p_mox = u3h(mox);
u3_noun q_mox = u3t(mox);
u3_noun ret;
ret = u3nc(
( (u3_nul == p_mox)
? u3nc(u3_nul, u3k(p_geq))
: (c3n == u3r_sing(p_geq, u3t(p_mox)))
? u3m_bail(c3__exit)
: u3k(p_mox) ),
u3nc(u3nc(u3k(q_geq), u3k(qi_men)), u3k(q_mox)));
u3z(mox);
u3z(geq);
return ret;
}
}
/* functions
*/
u3_noun
_cqzu_toss(u3_noun van,
u3_noun sut,
u3_noun peh,
u3_noun mur,
u3_noun men)
{
u3_noun wib = _toss_in(van, sut, peh, mur, men);
u3_noun p_wib = u3h(wib);
u3_noun q_wib = u3t(wib);
if ( u3_nul == p_wib ) {
return u3m_bail(c3__exit);
} else {
u3_noun ret = u3nc(u3k(u3t(p_wib)), u3k(q_wib));
u3z(wib);
return ret;
}
}
/* boilerplate
*/
u3_noun
u3wzu_toss(u3_noun cor)
{
u3_noun van, sut, peh, mur, men;
if ( (c3n == u3r_mean(cor, u3x_sam_2, &peh,
u3x_sam_6, &mur,
u3x_sam_7, &men,
u3x_con, &van,
0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_toss(van, sut, peh, mur, men);
}
}
u3_noun
u3qzu_toss(u3_noun van,
u3_noun sut,
u3_noun peh,
u3_noun mur,
u3_noun men)
{
return _cqzu_toss(van, sut, peh, mur, men);
}

View File

@ -1,96 +0,0 @@
/* j/6/wrap.c
**
*/
#include "all.h"
static u3_noun _cqzu_wrap(u3_noun, u3_noun, u3_noun);
static u3_noun
_wrap_fork(u3_noun van, u3_noun p_sut, u3_noun yoz)
{
if ( u3_nul == p_sut ) {
return u3_nul;
}
else {
return u3nc(_cqzu_wrap(van, u3h(p_sut), yoz),
_wrap_fork(van, u3t(p_sut), yoz));
}
}
static u3_noun
_cqzu_wrap(u3_noun van,
u3_noun sut,
u3_noun yoz)
{
u3_noun p_sut, q_sut;
if ( c3n == u3du(sut) ) {
return u3m_error("wrap-type");
}
else switch ( u3h(sut) ) {
default: return u3m_error("wrap-type");
case c3__core: u3x_cell(u3t(sut), &p_sut, &q_sut);
{
u3_noun pq_sut, qq_sut, rq_sut;
u3_noun ppq_sut, qpq_sut, rpq_sut;
if ( c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut) ) {
return u3m_bail(c3__fail);
}
if ( c3n == u3r_trel(pq_sut, &ppq_sut, &qpq_sut, &rpq_sut) ) {
return u3m_bail(c3__fail);
}
else if ( c3__gold != rpq_sut ) {
return u3m_error("wrap-gold");
}
else {
return u3nt(c3__core,
u3k(p_sut),
u3nt(u3nt(u3k(ppq_sut), u3k(qpq_sut), u3k(yoz)),
u3k(qq_sut),
u3k(rq_sut)));
}
}
case c3__fork: p_sut = u3t(sut);
{
u3_noun yed = u3qdi_tap(p_sut);
u3_noun ret = u3kf_fork(_wrap_fork(van, yed, yoz));
u3z(yed);
return ret;
}
case c3__hold:
{
u3_noun fop = u3qzu_repo(van, sut);
u3_noun pro = _cqzu_wrap(van, fop, yoz);
u3z(fop);
return pro;
}
}
}
/* boilerplate
*/
u3_noun
u3wzu_wrap(u3_noun cor)
{
u3_noun sut, yoz, van;
if ( (c3n == u3r_mean(cor, u3x_sam, &yoz, u3x_con, &van, 0)) ||
(u3_none == (sut = u3r_at(u3x_sam, van))) )
{
return u3m_bail(c3__fail);
} else {
return _cqzu_wrap(van, sut, yoz);
}
}
u3_noun
u3qzu_wrap(u3_noun van,
u3_noun sut,
u3_noun yoz)
{
return _cqzu_wrap(van, sut, yoz);
}

View File

@ -71,8 +71,10 @@ jets_c_src = [
'jets/c/pow.c',
'jets/c/rap.c',
'jets/c/rep.c',
'jets/c/rev.c',
'jets/c/rip.c',
'jets/c/rsh.c',
'jets/c/swp.c',
'jets/c/sqt.c',
'jets/c/vor.c',
]
@ -88,10 +90,13 @@ jets_d_src = [
'jets/d/in_wyt.c',
'jets/d/in_bif.c',
'jets/d/in_dif.c',
'jets/d/in_del.c',
'jets/d/by_del.c',
'jets/d/by_gas.c',
'jets/d/by_get.c',
'jets/d/by_has.c',
'jets/d/by_int.c',
'jets/d/by_jab.c',
'jets/d/by_put.c',
'jets/d/by_uni.c',
'jets/d/by_bif.c',
@ -102,8 +107,11 @@ jets_e_src = [
'jets/e/aes_ecb.c',
'jets/e/aes_cbc.c',
'jets/e/aesc.c',
'jets/e/argon2.c',
'jets/e/blake.c',
'jets/e/cue.c',
'jets/e/fl.c',
'jets/e/hmac.c',
'jets/e/jam.c',
'jets/e/mat.c',
'jets/e/mink.c',
@ -115,11 +123,14 @@ jets_e_src = [
'jets/e/rh.c',
'jets/e/rub.c',
'jets/e/scr.c',
'jets/e/secp.c',
'jets/e/shax.c',
'jets/e/sha1.c',
'jets/e/lore.c',
'jets/e/loss.c',
'jets/e/lune.c',
'jets/e/trip.c'
'jets/e/trip.c',
'jets/e/ripe.c'
]
jets_e_ed_src = [
@ -170,55 +181,20 @@ jets_f_ut_src = [
'jets/f/ut_wrap.c'
]
jets_z_src = [
'jets/z/ap.c',
'jets/z/cell.c',
'jets/z/comb.c',
'jets/z/cons.c',
'jets/z/core.c',
'jets/z/face.c',
'jets/z/fitz.c',
'jets/z/flan.c',
'jets/z/flip.c',
'jets/z/flor.c',
'jets/z/fork.c',
'jets/z/hint.c',
'jets/z/hike.c',
'jets/z/look.c',
'jets/z/loot.c'
]
jets_z_ut_src = [
'jets/z/ut.c',
'jets/z/ut_buss.c',
'jets/z/ut_crop.c',
'jets/z/ut_find.c',
'jets/z/ut_fire.c',
'jets/z/ut_fish.c',
'jets/z/ut_fuse.c',
'jets/z/ut_gain.c',
'jets/z/ut_lose.c',
'jets/z/ut_mint.c',
'jets/z/ut_mull.c',
'jets/z/ut_nest.c',
'jets/z/ut_peek.c',
'jets/z/ut_peel.c',
'jets/z/ut_play.c',
'jets/z/ut_repo.c',
'jets/z/ut_rest.c',
'jets/z/ut_tack.c',
'jets/z/ut_toss.c',
'jets/z/ut_wrap.c'
]
jets_g_src = [
'jets/g/down.c'
]
jets_src = [
'jets/tree.c'
]
noun_src = ['noun/allocate.c',
jets_all_src = [
jets_a_src, jets_b_src,
jets_c_src, jets_d_src,
jets_e_src, jets_e_ed_src,
jets_f_src, jets_f_ut_src,
jets_src
]
noun_src = [
'noun/allocate.c',
'noun/events.c',
'noun/hashtable.c',
'noun/imprison.c',
@ -229,14 +205,16 @@ noun_src = ['noun/allocate.c',
'noun/trace.c',
'noun/vortex.c',
'noun/xtract.c',
'noun/zave.c']
'noun/zave.c'
]
vere_src = ['vere/ames.c',
vere_sans_main = [
'vere/ames.c',
'vere/behn.c',
'vere/cttp.c',
'vere/dawn.c',
'vere/http.c',
'vere/loop.c',
'vere/main.c',
'vere/raft.c',
'vere/reck.c',
'vere/save.c',
@ -244,16 +222,12 @@ vere_src = ['vere/ames.c',
'vere/term.c',
'vere/time.c',
'vere/unix.c',
'vere/walk.c']
'vere/walk.c'
]
src_list = [
vere_src, noun_src,
jets_a_src, jets_b_src,
jets_c_src, jets_d_src,
jets_e_src, jets_e_ed_src,
jets_f_src, jets_f_ut_src,
jets_z_src, jets_z_ut_src,
jets_g_src, jets_src]
vere_src = vere_sans_main + [ 'vere/main.c' ]
src_list = [vere_src, noun_src, jets_all_src]
sources = []
foreach s : src_list
@ -323,7 +297,7 @@ configure_file(input : 'include/config.h.in',
# We expect these libs to supplied with the distribution
curl_dep = dependency('libcurl', version: '>=7.35.0')
if osdet == 'darwin'
if osdet == 'darwin' and not get_option('nix')
libcrypto = meson.get_compiler('c').find_library('crypto', dirs: [ '/usr/local/opt/openssl/lib/' ])
libssl = meson.get_compiler('c').find_library('ssl', dirs: [ '/usr/local/opt/openssl/lib/' ])
openssl_dep = declare_dependency(dependencies: [libcrypto, libssl], include_directories: include_directories('/usr/local/opt/openssl/include'))
@ -340,7 +314,6 @@ else
endif
# For these libs we provide fallback bundle
cmark_dep = dependency('libcmark', version: '0.12.0', fallback: ['commonmark-legacy', 'cmark_dep'])
urbitscrypt_dep = dependency('libscrypt', version: '>=0.1.21', fallback: ['libscrypt', 'libscrypt_dep'])
ed25519_dep = dependency('ed25519', version: '>=0.1.0', fallback: ['ed25519', 'ed25519_dep'])
@ -348,24 +321,54 @@ murmur3_dep = dependency('murmur3', version: '>=0.1.0', fallback: ['murmur3', 'm
softfloat3_dep = dependency('softfloat3', version: '>=3.0.0', fallback: ['softfloat3', 'softfloat3_dep'])
libuv_dep = dependency('libuv', version: '>=1.8.0', fallback:['libuv', 'libuv_dep'])
libh2o_dep = dependency('libh2o', version: '>=0.13.3', fallback: ['libh2o', 'libh2o_dep'])
argon2_dep = dependency('argon2', version: '>=1', fallback: ['argon2', 'argon2_dep'])
secp256k1_dep = dependency('libsecp256k1', version: '>=0.1.0', fallback: ['secp256k1', 'secp256k1_dep'])
libsni_dep = dependency('libsni', version: '>=0.5.0', fallback: ['libsni', 'libsni_dep'])
deps = [openssl_dep,
curl_dep,
libuv_dep,
libh2o_dep,
secp256k1_dep,
gmp_dep,
sigsegv_dep,
urbitscrypt_dep,
ed25519_dep,
murmur3_dep,
argon2_dep,
softfloat3_dep,
libsni_dep]
executable('urbit',
sources : sources,
include_directories : incdir,
c_args : os_c_flags,
link_args: os_link_flags,
dependencies: [openssl_dep,
curl_dep,
libuv_dep,
libh2o_dep,
cmark_dep,
gmp_dep,
sigsegv_dep,
urbitscrypt_dep,
ed25519_dep,
murmur3_dep,
softfloat3_dep,
libsni_dep] + os_deps,
dependencies: deps + os_deps,
install: true)
# XX shrink this list
test_sources = noun_src + jets_all_src + vere_sans_main
test_hashtable = executable('test-hashtable',
sources : test_sources + ['tests/hashtable_tests.c'],
include_directories : incdir,
c_args : os_c_flags,
link_args: os_link_flags,
dependencies: deps + os_deps,
install: false)
test('test-hashtable', test_hashtable)
test_mem_sources = noun_src + jets_all_src + vere_sans_main + ['tests/test.c']
test_mem = executable('test-mem',
sources : test_sources + ['tests/test.c'],
include_directories : incdir,
c_args : os_c_flags,
link_args: os_link_flags,
dependencies: deps + os_deps,
install: false)
test('test-mem', test_mem, should_fail: true)

View File

@ -2,3 +2,5 @@ option('gc', type : 'boolean', value : false,
description : 'Add debugging information to heap. Run with -g. Breaks image.')
option('prof', type : 'boolean', value : false,
description : 'Activate profiling. Run with -P.')
option('nix', type: 'boolean', value: false,
description: 'Build using nix.')

View File

@ -772,7 +772,7 @@ u3a_celloc(void)
return u3a_walloc(c3_wiseof(u3a_cell));
}
else {
if ( c3n == u3a_cellblock(256 << 10) ) {
if ( c3n == u3a_cellblock(4096) ) {
return u3a_walloc(c3_wiseof(u3a_cell));
}
cel_p = u3R->all.cel_p;

Some files were not shown because too many files have changed in this diff Show More