mirror of
https://github.com/urbit/shrub.git
synced 2024-12-28 22:54:15 +03:00
Merge remote-tracking branch 'origin/test' into dish
Conflicts: i/v/vere.h
This commit is contained in:
commit
b1ca1c5322
322
Makefile
322
Makefile
@ -55,8 +55,8 @@ else
|
||||
LIBS=-lssl -lcrypto -lgmp -lncurses -lsigsegv $(OSLIBS)
|
||||
endif
|
||||
|
||||
INCLUDE=include
|
||||
MDEFINES=-DU2_OS_$(OS) -DU2_OS_ENDIAN_$(ENDIAN) -D U2_LIB=\"$(LIB)\"
|
||||
INCLUDE=i
|
||||
MDEFINES=-DU3_OS_$(OS) -DU3_OS_ENDIAN_$(ENDIAN) -D U3_LIB=\"$(LIB)\"
|
||||
|
||||
# NOTFORCHECKIN - restore -O3
|
||||
CFLAGS= $(COSFLAGS) -O3 -msse3 -ffast-math \
|
||||
@ -78,175 +78,175 @@ CWFLAGS=-Wall
|
||||
.c.o:
|
||||
$(CC) -c $(CWFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
G_OFILES=\
|
||||
g/a.o \
|
||||
g/e.o \
|
||||
g/h.o \
|
||||
g/i.o \
|
||||
g/j.o \
|
||||
g/m.o \
|
||||
g/n.o \
|
||||
g/r.o \
|
||||
g/t.o \
|
||||
g/x.o \
|
||||
g/v.o \
|
||||
g/z.o
|
||||
N_OFILES=\
|
||||
n/a.o \
|
||||
n/e.o \
|
||||
n/h.o \
|
||||
n/i.o \
|
||||
n/j.o \
|
||||
n/m.o \
|
||||
n/n.o \
|
||||
n/r.o \
|
||||
n/t.o \
|
||||
n/x.o \
|
||||
n/v.o \
|
||||
n/z.o
|
||||
|
||||
J_1_OFILES=\
|
||||
j/1/add.o \
|
||||
j/1/dec.o \
|
||||
j/1/div.o \
|
||||
j/1/gte.o \
|
||||
j/1/gth.o \
|
||||
j/1/lte.o \
|
||||
j/1/lth.o \
|
||||
j/1/mod.o \
|
||||
j/1/mul.o \
|
||||
j/1/sub.o
|
||||
J_A_OFILES=\
|
||||
j/a/add.o \
|
||||
j/a/dec.o \
|
||||
j/a/div.o \
|
||||
j/a/gte.o \
|
||||
j/a/gth.o \
|
||||
j/a/lte.o \
|
||||
j/a/lth.o \
|
||||
j/a/mod.o \
|
||||
j/a/mul.o \
|
||||
j/a/sub.o
|
||||
|
||||
J_2_OFILES=\
|
||||
j/2/bind.o \
|
||||
j/2/clap.o \
|
||||
j/2/drop.o \
|
||||
j/2/flop.o \
|
||||
j/2/lent.o \
|
||||
j/2/levy.o \
|
||||
j/2/lien.o \
|
||||
j/2/need.o \
|
||||
j/2/reel.o \
|
||||
j/2/roll.o \
|
||||
j/2/skim.o \
|
||||
j/2/skip.o \
|
||||
j/2/scag.o \
|
||||
j/2/slag.o \
|
||||
j/2/snag.o \
|
||||
j/2/sort.o \
|
||||
j/2/turn.o \
|
||||
j/2/weld.o
|
||||
J_B_OFILES=\
|
||||
j/b/bind.o \
|
||||
j/b/clap.o \
|
||||
j/b/drop.o \
|
||||
j/b/flop.o \
|
||||
j/b/lent.o \
|
||||
j/b/levy.o \
|
||||
j/b/lien.o \
|
||||
j/b/need.o \
|
||||
j/b/reel.o \
|
||||
j/b/roll.o \
|
||||
j/b/skim.o \
|
||||
j/b/skip.o \
|
||||
j/b/scag.o \
|
||||
j/b/slag.o \
|
||||
j/b/snag.o \
|
||||
j/b/sort.o \
|
||||
j/b/turn.o \
|
||||
j/b/weld.o
|
||||
|
||||
J_3_OFILES=\
|
||||
j/3/bex.o \
|
||||
j/3/can.o \
|
||||
j/3/cap.o \
|
||||
j/3/cat.o \
|
||||
j/3/con.o \
|
||||
j/3/cut.o \
|
||||
j/3/dor.o \
|
||||
j/3/dis.o \
|
||||
j/3/end.o \
|
||||
j/3/gor.o \
|
||||
j/3/hor.o \
|
||||
j/3/lsh.o \
|
||||
j/3/mas.o \
|
||||
j/3/met.o \
|
||||
j/3/mix.o \
|
||||
j/3/mug.o \
|
||||
j/3/peg.o \
|
||||
j/3/po.o \
|
||||
j/3/rap.o \
|
||||
j/3/rip.o \
|
||||
j/3/rsh.o \
|
||||
j/3/vor.o
|
||||
J_C_OFILES=\
|
||||
j/c/bex.o \
|
||||
j/c/can.o \
|
||||
j/c/cap.o \
|
||||
j/c/cat.o \
|
||||
j/c/con.o \
|
||||
j/c/cut.o \
|
||||
j/c/dor.o \
|
||||
j/c/dis.o \
|
||||
j/c/end.o \
|
||||
j/c/gor.o \
|
||||
j/c/hor.o \
|
||||
j/c/lsh.o \
|
||||
j/c/mas.o \
|
||||
j/c/met.o \
|
||||
j/c/mix.o \
|
||||
j/c/mug.o \
|
||||
j/c/peg.o \
|
||||
j/c/po.o \
|
||||
j/c/rap.o \
|
||||
j/c/rip.o \
|
||||
j/c/rsh.o \
|
||||
j/c/vor.o
|
||||
|
||||
J_4_OFILES=\
|
||||
j/4/in_has.o \
|
||||
j/4/in_int.o \
|
||||
j/4/in_gas.o \
|
||||
j/4/in_mer.o \
|
||||
j/4/in_put.o \
|
||||
j/4/in_tap.o \
|
||||
j/4/in_uni.o \
|
||||
j/4/by_gas.o \
|
||||
j/4/by_get.o \
|
||||
j/4/by_has.o \
|
||||
j/4/by_int.o \
|
||||
j/4/by_put.o \
|
||||
j/4/by_uni.o
|
||||
J_D_OFILES=\
|
||||
j/d/in_has.o \
|
||||
j/d/in_int.o \
|
||||
j/d/in_gas.o \
|
||||
j/d/in_mer.o \
|
||||
j/d/in_put.o \
|
||||
j/d/in_tap.o \
|
||||
j/d/in_uni.o \
|
||||
j/d/by_gas.o \
|
||||
j/d/by_get.o \
|
||||
j/d/by_has.o \
|
||||
j/d/by_int.o \
|
||||
j/d/by_put.o \
|
||||
j/d/by_uni.o
|
||||
|
||||
J_5_OFILES=\
|
||||
j/5/aesc.o \
|
||||
j/5/cue.o \
|
||||
j/5/jam.o \
|
||||
j/5/mat.o \
|
||||
j/5/mink.o \
|
||||
j/5/mule.o \
|
||||
j/5/parse.o \
|
||||
j/5/rd.o \
|
||||
j/5/repg.o \
|
||||
j/5/rexp.o \
|
||||
j/5/rub.o \
|
||||
j/5/shax.o \
|
||||
j/5/lore.o \
|
||||
j/5/loss.o \
|
||||
j/5/trip.o
|
||||
J_E_OFILES=\
|
||||
j/e/aesc.o \
|
||||
j/e/cue.o \
|
||||
j/e/jam.o \
|
||||
j/e/mat.o \
|
||||
j/e/mink.o \
|
||||
j/e/mule.o \
|
||||
j/e/parse.o \
|
||||
j/e/rd.o \
|
||||
j/e/repg.o \
|
||||
j/e/rexp.o \
|
||||
j/e/rub.o \
|
||||
j/e/shax.o \
|
||||
j/e/lore.o \
|
||||
j/e/loss.o \
|
||||
j/e/trip.o
|
||||
|
||||
J_5_OFILES_ED=\
|
||||
j/5/ed_puck.o \
|
||||
j/5/ed_sign.o \
|
||||
j/5/ed_veri.o
|
||||
J_E_OFILES_ED=\
|
||||
j/e/ed_puck.o \
|
||||
j/e/ed_sign.o \
|
||||
j/e/ed_veri.o
|
||||
|
||||
J_6_OFILES=\
|
||||
j/6/al.o \
|
||||
j/6/ap.o \
|
||||
j/6/bull.o \
|
||||
j/6/cell.o \
|
||||
j/6/comb.o \
|
||||
j/6/cons.o \
|
||||
j/6/core.o \
|
||||
j/6/cube.o \
|
||||
j/6/face.o \
|
||||
j/6/fitz.o \
|
||||
j/6/flan.o \
|
||||
j/6/flay.o \
|
||||
j/6/flip.o \
|
||||
j/6/flor.o \
|
||||
j/6/fork.o \
|
||||
j/6/hike.o \
|
||||
j/6/look.o \
|
||||
J_F_OFILES=\
|
||||
j/f/al.o \
|
||||
j/f/ap.o \
|
||||
j/f/bull.o \
|
||||
j/f/cell.o \
|
||||
j/f/comb.o \
|
||||
j/f/cons.o \
|
||||
j/f/core.o \
|
||||
j/f/cube.o \
|
||||
j/f/face.o \
|
||||
j/f/fitz.o \
|
||||
j/f/flan.o \
|
||||
j/f/flay.o \
|
||||
j/f/flip.o \
|
||||
j/f/flor.o \
|
||||
j/f/fork.o \
|
||||
j/f/hike.o \
|
||||
j/f/look.o \
|
||||
|
||||
J_6_OFILES_UT=\
|
||||
j/6/ut.o \
|
||||
j/6/ut_burn.o \
|
||||
j/6/ut_busk.o \
|
||||
j/6/ut_bust.o \
|
||||
j/6/ut_conk.o \
|
||||
j/6/ut_crop.o \
|
||||
j/6/ut_cull.o \
|
||||
j/6/ut_find.o \
|
||||
j/6/ut_fink.o \
|
||||
j/6/ut_fire.o \
|
||||
j/6/ut_firm.o \
|
||||
j/6/ut_fish.o \
|
||||
j/6/ut_fuse.o \
|
||||
j/6/ut_gain.o \
|
||||
j/6/ut_heal.o \
|
||||
j/6/ut_lose.o \
|
||||
j/6/ut_mint.o \
|
||||
j/6/ut_mull.o \
|
||||
j/6/ut_nest.o \
|
||||
j/6/ut_park.o \
|
||||
j/6/ut_peek.o \
|
||||
j/6/ut_play.o \
|
||||
j/6/ut_repo.o \
|
||||
j/6/ut_rest.o \
|
||||
j/6/ut_seek.o \
|
||||
j/6/ut_swab.o \
|
||||
j/6/ut_tack.o \
|
||||
j/6/ut_tock.o \
|
||||
j/6/ut_wrap.o
|
||||
J_F_OFILES_UT=\
|
||||
j/f/ut.o \
|
||||
j/f/ut_burn.o \
|
||||
j/f/ut_busk.o \
|
||||
j/f/ut_bust.o \
|
||||
j/f/ut_conk.o \
|
||||
j/f/ut_crop.o \
|
||||
j/f/ut_cull.o \
|
||||
j/f/ut_find.o \
|
||||
j/f/ut_fink.o \
|
||||
j/f/ut_fire.o \
|
||||
j/f/ut_firm.o \
|
||||
j/f/ut_fish.o \
|
||||
j/f/ut_fuse.o \
|
||||
j/f/ut_gain.o \
|
||||
j/f/ut_heal.o \
|
||||
j/f/ut_lose.o \
|
||||
j/f/ut_mint.o \
|
||||
j/f/ut_mull.o \
|
||||
j/f/ut_nest.o \
|
||||
j/f/ut_park.o \
|
||||
j/f/ut_peek.o \
|
||||
j/f/ut_play.o \
|
||||
j/f/ut_repo.o \
|
||||
j/f/ut_rest.o \
|
||||
j/f/ut_seek.o \
|
||||
j/f/ut_swab.o \
|
||||
j/f/ut_tack.o \
|
||||
j/f/ut_tock.o \
|
||||
j/f/ut_wrap.o
|
||||
|
||||
J_OFILES=\
|
||||
$(J_1_OFILES) \
|
||||
$(J_2_OFILES) \
|
||||
$(J_3_OFILES) \
|
||||
$(J_4_OFILES) \
|
||||
$(J_5_OFILES) \
|
||||
$(J_5_OFILES_ED) \
|
||||
$(J_6_OFILES) \
|
||||
$(J_6_OFILES_UT) \
|
||||
j/dash.o
|
||||
$(J_A_OFILES) \
|
||||
$(J_B_OFILES) \
|
||||
$(J_C_OFILES) \
|
||||
$(J_D_OFILES) \
|
||||
$(J_E_OFILES) \
|
||||
$(J_E_OFILES_ED) \
|
||||
$(J_F_OFILES) \
|
||||
$(J_F_OFILES_UT) \
|
||||
j/tree.o
|
||||
|
||||
BASE_OFILES=$(G_OFILES) $(J_OFILES)
|
||||
BASE_OFILES=$(N_OFILES) $(J_OFILES)
|
||||
|
||||
CRE2_OFILES=\
|
||||
outside/cre2/src/src/cre2.o
|
||||
@ -336,7 +336,7 @@ $(LIBANACHRONISM):
|
||||
$(CRE2_OFILES): outside/cre2/src/src/cre2.cpp outside/cre2/src/src/cre2.h $(LIBRE2)
|
||||
$(CXX) $(CXXFLAGS) -c $< $(LIBRE2) -o $@
|
||||
|
||||
$(V_OFILES): include/v/vere.h
|
||||
$(V_OFILES): i/v/vere.h
|
||||
|
||||
$(BIN)/vere: $(LIBCRE) $(VERE_OFILES) $(LIBUV) $(LIBRE2) $(LIBED25519) $(LIBANACHRONISM)
|
||||
mkdir -p $(BIN)
|
||||
|
245
Spec/u3.md
Normal file
245
Spec/u3.md
Normal file
@ -0,0 +1,245 @@
|
||||
# u3: noun processing in C.
|
||||
|
||||
`u3` is the C library that makes Urbit work. If it wasn't called
|
||||
`u3`, it might be called `libnoun` - it's a library for making
|
||||
and storing nouns.
|
||||
|
||||
What's a noun? A noun is either a cell or an atom. A cell is an
|
||||
ordered pair of any two nouns. An atom is an unsigned integer of
|
||||
any size.
|
||||
|
||||
To the C programmer, this is not a terribly complicated data
|
||||
structure, so why do you need a library for it?
|
||||
|
||||
One: nouns have a well-defined computation kernel, Nock, whose
|
||||
spec fits on a page and gzips to 340 bytes. But the only
|
||||
arithmetic operation in Nock is increment. So it's nontrivial
|
||||
to compute both efficiently and correctly.
|
||||
|
||||
Two: `u3` is designed to support "permanent computing," ie, a
|
||||
single-level store which is transparently checkpointed. This
|
||||
implies a specialized memory-management model, etc, etc.
|
||||
|
||||
(Does `u3` depend on the higher levels of Urbit, Arvo and Hoon?
|
||||
Yes and no. It expects you to load something shaped like an Arvo
|
||||
kernel, and use it as an event-processing function. But you
|
||||
don't need to use this feature if you don't want, and your kernel
|
||||
can be anything you want.)
|
||||
|
||||
## c3: C in Urbit
|
||||
|
||||
Under `u3` is the simple `c3` layer, which is just how we write C
|
||||
in Urbit.
|
||||
|
||||
When writing C in u3, please of course follow the conventions of
|
||||
the code around you as regards indentation, etc. It's especially
|
||||
important that every function have a header comment, even if it
|
||||
says nothing interesting.
|
||||
|
||||
But some of our idiosyncrasies go beyond convention. Yes, we've
|
||||
done awful things to C. Here's what we did and why we did.
|
||||
|
||||
### c3: integer types
|
||||
|
||||
First, it's generally acknowledged that underspecified integer
|
||||
types are C's worst disaster. C99 fixed this, but the `stdint`
|
||||
types are wordy and annoying. We've replaced them with:
|
||||
|
||||
/* Good integers.
|
||||
*/
|
||||
typedef uint64_t c3_d; // double-word
|
||||
typedef int64_t c3_ds; // signed double-word
|
||||
typedef uint32_t c3_w; // word
|
||||
typedef int32_t c3_ws; // signed word
|
||||
typedef uint16_t c3_s; // short
|
||||
typedef int16_t c3_ss; // signed short
|
||||
typedef uint8_t c3_y; // byte
|
||||
typedef int8_t c3_ys; // signed byte
|
||||
typedef uint8_t c3_b; // bit
|
||||
|
||||
typedef uint8_t c3_t; // boolean
|
||||
typedef uint8_t c3_o; // loobean
|
||||
typedef uint8_t c3_g; // 32-bit log - 0-31 bits
|
||||
typedef uint32_t c3_l; // little; 31-bit unsigned integer
|
||||
typedef uint32_t c3_m; // mote; also c3_l; LSB first a-z 4-char string.
|
||||
|
||||
/* Bad integers.
|
||||
*/
|
||||
typedef char c3_c; // does not match int8_t or uint8_t
|
||||
typedef int c3_i; // int - really bad
|
||||
typedef uintptr_t c3_p; // pointer-length uint - really really bad
|
||||
typedef intptr_t c3_ps; // pointer-length int - really really bad
|
||||
|
||||
Some of these need explanation. A loobean is a Nock boolean -
|
||||
Nock, for mysterious reasons, uses 0 as true (always say "yes")
|
||||
and 1 as false (always say "no").
|
||||
|
||||
Nock and/or Hoon cannot tell the difference between a short atom
|
||||
and a long one, but at the `u3` level every atom under `2^31` is
|
||||
direct. The `c3_l` type is useful to annotate this. A `c3_m` is
|
||||
a mote - a string of up to 4 characters in a `c3_l`, least
|
||||
significant byte first. A `c3_g` should be a 5-bit atom. Of
|
||||
course, C cannot enforce these constraints, only document them.
|
||||
|
||||
Use the "bad" - ie, poorly specified - integer types only when
|
||||
interfacing with external code that expects them.
|
||||
|
||||
An enormous number of motes are defined in `i/c/motes.h`. There
|
||||
is no reason to delete motes that aren't being used, or even to
|
||||
modularize the definitions. Keep them alphabetical, though.
|
||||
|
||||
### c3: variables and variable naming
|
||||
|
||||
The C3 style uses Hoon style TLV variable names, with a quasi
|
||||
Hungarian syntax. This is weird, but works really well, as
|
||||
long as what you're doing isn't hideous.
|
||||
|
||||
A TLV variable name is a random pronounceable three-letter
|
||||
string, sometimes with some vague relationship to its meaning,
|
||||
but usually not. Usually CVC (consonant-vowel-consonant) is a
|
||||
good choice.
|
||||
|
||||
You should use TLVs much the way math people use Greek letters.
|
||||
The same concept should in general get the same name across
|
||||
different contexts. When you're working in a given area, you'll
|
||||
tend to remember the binding from TLV to concept by sheer power
|
||||
of associative memory. When you come back to it, it's not that
|
||||
hard to relearn. And of course, when in doubt, comment it.
|
||||
|
||||
Variables take pseudo-Hungarian suffixes, matching in general the
|
||||
suffix of the integer type:
|
||||
|
||||
c3_w wor_w; // 32-bit word
|
||||
|
||||
Unlike in true Hungarian, there is no change for pointer
|
||||
variables. Structure variables take a `_u` suffix;
|
||||
|
||||
### c3: loobeans
|
||||
|
||||
The code (from `defs.h`) tells the story:
|
||||
|
||||
# define c3y 0
|
||||
# define c3n 1
|
||||
|
||||
# define _(x) (c3y == (x))
|
||||
# define __(x) ((x) ? c3y : c3n)
|
||||
# define c3a(x, y) __(_(x) && _(y))
|
||||
# define c3o(x, y) __(_(x) || _(y))
|
||||
|
||||
In short, use `_()` to turn a loobean into a boolean, `__` to go
|
||||
the other way. Use `!` as usual, `c3y` for yes and `c3n` for no,
|
||||
`c3a` for and and `c3o` for or.
|
||||
|
||||
## u3: introduction to the noun world
|
||||
|
||||
The division between `c3` and `u3` is that you could theoretically
|
||||
imagine using `c3` as just a generic C environment. Anything to do
|
||||
with nouns is in `u3`.
|
||||
|
||||
### u3: a map of the system
|
||||
|
||||
There are two kinds of symbols in `u3`: regular and irregular.
|
||||
Regular symbols follow this pattern:
|
||||
|
||||
prefix purpose .h .c
|
||||
-------------------------------------------------------
|
||||
u3a_ allocation i/n/a.h n/a.c
|
||||
u3e_ persistence i/n/e.h n/e.c
|
||||
u3h_ hashtables i/n/h.h n/h.c
|
||||
u3i_ noun construction i/n/i.h n/i.c
|
||||
u3j_ jet control i/n/j.h n/j.c
|
||||
u3m_ system management i/n/m.h n/m.c
|
||||
u3n_ nock computation i/n/n.h n/n.c
|
||||
u3r_ noun access (error returns) i/n/r.h n/r.c
|
||||
u3t_ profiling i/n/t.h n/t.c
|
||||
u3v_ arvo i/n/v.h n/v.c
|
||||
u3x_ noun access (error crashes) i/n/x.h n/x.c
|
||||
u3z_ memoization i/n/z.h n/z.c
|
||||
u3k[a-g] jets (transfer, C args) i/j/k.h j/[a-g]/*.c
|
||||
u3q[a-g] jets (retain, C args) i/j/q.h j/[a-g]/*.c
|
||||
u3w[a-g] jets (retain, nock core) i/j/w.h j/[a-g]/*.c
|
||||
|
||||
|
||||
u3 deals with reference-counted, immutable, acyclic nouns. 90%
|
||||
of what you need to know to program in u3 is just how to get your
|
||||
refcounts right.
|
||||
|
||||
|
||||
/** Prefix definitions:
|
||||
***
|
||||
*** u3a_: fundamental allocators.
|
||||
*** u3c_: constants.
|
||||
*** u3e_: checkpointing.
|
||||
*** u3h_: HAMT hash tables.
|
||||
*** u3i_: noun constructors
|
||||
*** u3j_: jets.
|
||||
*** u3k*: direct jet calls (modern C convention)
|
||||
*** u3m_: system management etc.
|
||||
*** u3n_: nock interpreter.
|
||||
*** u3o_: fundamental macros.
|
||||
*** u3q*: direct jet calls (archaic C convention)
|
||||
*** u3r_: read functions which never bail out.
|
||||
*** u3s_: structures and definitions.
|
||||
*** u3t_: tracing.
|
||||
*** u3w_: direct jet calls (core noun convention)
|
||||
*** u3x_: read functions which do bail out.
|
||||
*** u3v_: arvo specific structures.
|
||||
*** u3z_: memoization.
|
||||
***
|
||||
*** u3_cr_, u3_cx_, u3_cz_ functions use retain conventions; the caller
|
||||
*** retains ownership of passed-in nouns, the callee preserves
|
||||
*** ownership of returned nouns.
|
||||
***
|
||||
*** Unless documented otherwise, all other functions use transfer
|
||||
*** conventions; the caller logically releases passed-in nouns,
|
||||
*** the callee logically releases returned nouns.
|
||||
***
|
||||
*** In general, exceptions to the transfer convention all occur
|
||||
*** when we're using a noun as a key.
|
||||
**/
|
||||
|
||||
|
||||
|
||||
|
||||
The best way to introduce `u3` is with a simple map of the Urbit
|
||||
build directory:
|
||||
|
||||
g/ u3 implementation
|
||||
g/a.c allocation
|
||||
g/e.c persistence
|
||||
g/h.c hashtables
|
||||
g/i.c noun construction
|
||||
g/j.c jet control
|
||||
g/m.c master state
|
||||
g/n.c nock execution
|
||||
g/r.c noun access, error returns
|
||||
g/t.c tracing/profiling
|
||||
g/v.c arvo kernel
|
||||
g/x.c noun access, error crashes
|
||||
g/z.c memoization/caching
|
||||
i/ all includes
|
||||
i/v vere systems headers
|
||||
i/g u3 headers (matching g/ names)
|
||||
i/c c3 headers
|
||||
i/c/defs.h miscellaneous c3 macros
|
||||
i/c/motes.h symbolic constants
|
||||
i/c/portable.h portability definitions
|
||||
i/c/types.h c3 types
|
||||
i/j jet headers
|
||||
i/j/k.h jet interfaces (transfer, args)
|
||||
i/j/q.h jet interfaces (retain, args)
|
||||
i/j/w.h jet interfaces (retain, core)
|
||||
j/ jet code
|
||||
j/dash.c jet structures
|
||||
j/1 tier 1 jets: basic math
|
||||
j/2 tier 2 jets: lists
|
||||
j/3 tier 3 jets: bit twiddling
|
||||
j/4 tier 4 jets: containers
|
||||
j/5 tier 5 jets: misc
|
||||
j/6 tier 6 jets: hoon
|
||||
v/ vere systems code
|
||||
outside/ all external bundled code
|
||||
|
||||
|
||||
|
||||
|
531
g/v.c
531
g/v.c
@ -1,531 +0,0 @@
|
||||
/* g/v.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "all.h"
|
||||
|
||||
int WISH;
|
||||
/* _cv_nock_wish(): call wish through hardcoded interface.
|
||||
*/
|
||||
static u3_noun
|
||||
_cv_nock_wish(u3_noun txt)
|
||||
{
|
||||
u3_noun fun, pro;
|
||||
|
||||
WISH = 1;
|
||||
fun = u3_cn_nock_on(u3k(u3A->roc), u3k(u3_cx_at(20, u3A->roc)));
|
||||
pro = u3_cn_slam_on(fun, txt);
|
||||
WISH = 0;
|
||||
|
||||
return pro;
|
||||
}
|
||||
|
||||
/* u3_cv_make(): make a new pier and instantiate pill.
|
||||
*/
|
||||
void
|
||||
u3_cv_make(c3_c* pas_c)
|
||||
{
|
||||
u3_noun sys = u3_cke_cue(u3_cm_file(pas_c));
|
||||
|
||||
printf("cv_make: loaded pill %s, as %x\n", pas_c, u3_cr_mug(sys));
|
||||
|
||||
u3A->ken = u3k(u3h(sys));
|
||||
u3A->roc = u3k(u3t(sys));
|
||||
|
||||
printf("cv_make: kernel %x, core %x\n",
|
||||
u3_cr_mug(u3A->ken), u3_cr_mug(u3A->roc));
|
||||
u3z(sys);
|
||||
}
|
||||
|
||||
int JACK;
|
||||
|
||||
/* u3_cv_jack(): execute kernel formula to bind jets.
|
||||
*/
|
||||
void
|
||||
u3_cv_jack(void)
|
||||
{
|
||||
u3_noun cor;
|
||||
|
||||
JACK = 1;
|
||||
printf("cv_jack: activating kernel %x\n", u3_cr_mug(u3A->ken));
|
||||
cor = u3_cn_nock_on(0, u3k(u3A->ken));
|
||||
printf("cv_jack: activated\n");
|
||||
JACK = 0;
|
||||
|
||||
u3z(cor);
|
||||
}
|
||||
|
||||
/* u3_cv_hose(): clear initial ovum queue.
|
||||
*/
|
||||
void
|
||||
u3_cv_hose(void)
|
||||
{
|
||||
u3p(u3_cs_cart) egg_p = u3A->ova.egg_p;
|
||||
|
||||
while ( egg_p ) {
|
||||
u3_cs_cart* egg_u = u3to(u3_cs_cart, egg_p);
|
||||
u3p(u3_cs_cart) nex_p = egg_u->nex_p;
|
||||
|
||||
u3_ca_lose(egg_u->vir);
|
||||
u3_ca_free(egg_u);
|
||||
|
||||
egg_p = nex_p;
|
||||
}
|
||||
u3A->ova.egg_p = u3A->ova.geg_p = 0;
|
||||
u3z(u3A->roe);
|
||||
u3A->roe = u3_nul;
|
||||
}
|
||||
|
||||
/* u3_cv_start(): start time.
|
||||
*/
|
||||
void
|
||||
u3_cv_start(u3_noun now)
|
||||
{
|
||||
u3_cv_time(now);
|
||||
u3_cv_numb();
|
||||
|
||||
{
|
||||
c3_c* wen_c = u3_cr_string(u3A->wen);
|
||||
|
||||
printf("cv_start: time: %s\n", wen_c);
|
||||
free(wen_c);
|
||||
}
|
||||
}
|
||||
|
||||
/* u3_cv_wish(): text expression with cache.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_wish(const c3_c* str_c)
|
||||
{
|
||||
u3_noun exp;
|
||||
|
||||
if ( u3R == &u3H->rod_u ) {
|
||||
u3_noun txt = u3_ci_string(str_c);
|
||||
|
||||
exp = u3_ckdb_get(u3k(u3A->yot), u3k(txt));
|
||||
|
||||
if ( u3_none == exp ) {
|
||||
exp = _cv_nock_wish(u3k(txt));
|
||||
u3A->yot = u3_ckdb_put(u3A->yot, u3k(txt), u3k(exp));
|
||||
}
|
||||
u3z(txt);
|
||||
return exp;
|
||||
}
|
||||
else {
|
||||
// It's probably not a good idea to use u3_cv_wish()
|
||||
// outside the top level...
|
||||
//
|
||||
return _cv_nock_wish(u3_ci_string(str_c));
|
||||
}
|
||||
}
|
||||
|
||||
/* _cv_mung(): formula wrapper with gate and sample.
|
||||
*/
|
||||
static u3_noun
|
||||
_cv_mung_in(u3_noun gam)
|
||||
{
|
||||
u3_noun pro = u3_cn_slam_on(u3k(u3h(gam)), u3k(u3t(gam)));
|
||||
|
||||
u3z(gam); return pro;
|
||||
}
|
||||
static u3_noun
|
||||
_cv_mung(c3_w sec_w, u3_noun gat, u3_noun sam)
|
||||
{
|
||||
u3_noun gam = u3nc(gat, sam);
|
||||
|
||||
return u3_cm_soft(0, _cv_mung_in, gam);
|
||||
}
|
||||
|
||||
/* u3_cv_pike(): poke with floating core.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_pike(u3_noun ovo, u3_noun cor)
|
||||
{
|
||||
u3_noun fun = u3_cn_nock_on(cor, u3k(u3_cx_at(42, cor)));
|
||||
u3_noun sam = u3nc(u3k(u3A->now), ovo);
|
||||
|
||||
return _cv_mung(0, fun, sam);
|
||||
}
|
||||
|
||||
/* u3_cv_nick(): transform enveloped packets, [vir cor].
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_nick(u3_noun vir, u3_noun cor)
|
||||
{
|
||||
if ( u3_nul == vir ) {
|
||||
return u3nt(u3_blip, vir, cor);
|
||||
}
|
||||
else {
|
||||
u3_noun i_vir = u3h(vir);
|
||||
u3_noun pi_vir, qi_vir;
|
||||
u3_noun vix;
|
||||
|
||||
if ( (u3_yes == u3_cr_cell((i_vir=u3h(vir)), &pi_vir, &qi_vir)) &&
|
||||
(u3_yes == u3du(qi_vir)) &&
|
||||
(c3__hear == u3h(qi_vir)) )
|
||||
{
|
||||
u3_noun gon;
|
||||
|
||||
gon = u3_cv_pike(u3k(i_vir), cor);
|
||||
if ( u3_blip != u3h(gon) ) {
|
||||
u3z(vir);
|
||||
return gon;
|
||||
}
|
||||
else {
|
||||
u3_noun viz;
|
||||
|
||||
vix = u3k(u3h(u3t(gon)));
|
||||
cor = u3k(u3t(u3t(gon)));
|
||||
u3z(gon);
|
||||
|
||||
viz = u3_ckb_weld(vix, u3k(u3t(vir)));
|
||||
u3z(vir);
|
||||
|
||||
return u3_cv_nick(viz, cor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
u3_noun nez = u3_cv_nick(u3k(u3t(vir)), cor);
|
||||
|
||||
if ( u3_blip != u3h(nez) ) {
|
||||
u3z(vir);
|
||||
return nez;
|
||||
} else {
|
||||
u3_noun viz;
|
||||
|
||||
viz = u3nc(u3k(i_vir), u3k(u3h(u3t(nez))));
|
||||
cor = u3k(u3t(u3t(nez)));
|
||||
|
||||
u3z(vir);
|
||||
u3z(nez);
|
||||
|
||||
return u3nt(u3_blip, viz, cor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* _cv_nock_poke(): call poke through hardcoded interface.
|
||||
*/
|
||||
static u3_noun
|
||||
_cv_nock_poke(u3_noun ovo)
|
||||
{
|
||||
u3_noun fun = u3_cn_nock_on(u3k(u3A->roc), u3k(u3_cx_at(42, u3A->roc)));
|
||||
u3_noun sam, pro;
|
||||
|
||||
sam = u3nc(u3k(u3A->now), ovo);
|
||||
#if 0
|
||||
{
|
||||
c3_c* ovi_c = u3_cr_string(u3h(u3t(ovo)));
|
||||
u3_noun tox = u3_do("spat", u3k(u3h(ovo)));
|
||||
c3_c* tox_c = u3_cr_string(tox);
|
||||
|
||||
printf("poke: %%%s (%x) on %s\r\n", ovi_c, u3_cr_mug(ovo), tox_c);
|
||||
free(tox_c); free(ovi_c); u3z(tox);
|
||||
}
|
||||
#endif
|
||||
|
||||
// u3_leak_on(1);
|
||||
pro = u3_cn_slam_on(fun, sam);
|
||||
// u3_leak_off;
|
||||
|
||||
#if 0
|
||||
{
|
||||
c3_c* ovi_c = u3_cr_string(u3h(u3t(ovo)));
|
||||
|
||||
printf("poked: %s\r\n", ovi_c);
|
||||
|
||||
free(ovi_c);
|
||||
}
|
||||
#endif
|
||||
|
||||
return pro;
|
||||
}
|
||||
|
||||
/* _cv_nock_peek(): call peek through hardcoded interface.
|
||||
*/
|
||||
static u3_noun
|
||||
_cv_nock_peek(u3_noun hap)
|
||||
{
|
||||
u3_noun fun = u3_cn_nock_on(u3k(u3A->roc), u3k(u3_cx_at(87, u3A->roc)));
|
||||
u3_noun sam = u3nc(u3k(u3A->now), hap);
|
||||
|
||||
return u3_cn_slam_on(fun, sam);
|
||||
}
|
||||
|
||||
/* _cv_nock_keep(): call wait through hardcoded interface.
|
||||
*/
|
||||
static u3_noun
|
||||
_cv_nock_keep(u3_noun hap)
|
||||
{
|
||||
u3_noun fun = u3_cn_nock_on(u3k(u3A->roc), u3k(u3_cx_at(4, u3A->roc)));
|
||||
u3_noun sam = u3nc(u3k(u3A->now), hap);
|
||||
|
||||
return u3_cn_slam_on(fun, sam);
|
||||
}
|
||||
|
||||
/* u3_cv_do(): use a kernel gate.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_do(const c3_c* txt_c, u3_noun sam)
|
||||
{
|
||||
u3_noun gat = u3_cv_wish(txt_c);
|
||||
u3_noun pro;
|
||||
|
||||
#if 0
|
||||
if ( &u3H->rod_u == u3R ) {
|
||||
pro = u3_cm_soft_slam(gat, sam);
|
||||
}
|
||||
else {
|
||||
pro = u3_cn_slam_on(gat, sam);
|
||||
}
|
||||
#else
|
||||
pro = u3_cn_slam_on(gat, sam);
|
||||
#endif
|
||||
|
||||
return pro;
|
||||
}
|
||||
|
||||
/* _cv_scot(): print atom.
|
||||
*/
|
||||
static u3_noun
|
||||
_cv_scot(u3_noun dim)
|
||||
{
|
||||
return u3_do("scot", dim);
|
||||
}
|
||||
|
||||
/* u3_cv_time(): set the reck time.
|
||||
*/
|
||||
void
|
||||
u3_cv_time(u3_noun now)
|
||||
{
|
||||
u3z(u3A->now);
|
||||
u3A->now = now;
|
||||
|
||||
u3z(u3A->wen);
|
||||
u3A->wen = _cv_scot(u3nc(c3__da, u3k(u3A->now)));
|
||||
}
|
||||
|
||||
/* u3_cv_numb(): set the instance number.
|
||||
*/
|
||||
void
|
||||
u3_cv_numb()
|
||||
{
|
||||
u3A->sev_l = u3_cr_mug(u3A->now);
|
||||
u3z(u3A->sen);
|
||||
u3A->sen = _cv_scot(u3nc(c3__uv, u3A->sev_l));
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* _cv_time_bump(): advance the reck time by a small increment.
|
||||
*/
|
||||
static void
|
||||
_cv_time_bump(u3_reck* rec_u)
|
||||
{
|
||||
c3_d bum_d = (1ULL << 48ULL);
|
||||
|
||||
u3A->now = u3_cka_add(u3A->now, u3_ci_chubs(1, &bum_d));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u3_cv_peek(): query the reck namespace (protected).
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_peek(u3_noun hap)
|
||||
{
|
||||
return u3_cm_soft_sure(_cv_nock_peek, hap);
|
||||
}
|
||||
|
||||
/* u3_cv_keep(): measure timer.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_keep(u3_noun hap)
|
||||
{
|
||||
return u3_cm_soft_sure(_cv_nock_keep, hap);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* _cv_mole(): parse simple atomic mole.
|
||||
*/
|
||||
static u3_bean
|
||||
_cv_mole(u3_noun fot,
|
||||
u3_noun san,
|
||||
c3_d* ato_d)
|
||||
{
|
||||
u3_noun uco = u3_do("slay", san);
|
||||
u3_noun p_uco, q_uco, r_uco, s_uco;
|
||||
|
||||
if ( (u3_no == u3_cr_qual(uco, &p_uco, &q_uco, &r_uco, &s_uco)) ||
|
||||
(0 != p_uco) ||
|
||||
(0 != q_uco) ||
|
||||
(u3_no == u3_sing(fot, r_uco)) )
|
||||
{
|
||||
uL(fprintf(uH, "strange mole %s\n", u3_cr_string(san)));
|
||||
|
||||
u3z(fot); u3z(uco); return u3_no;
|
||||
}
|
||||
else {
|
||||
*ato_d = u3_cr_chub(0, s_uco);
|
||||
|
||||
u3z(fot); u3z(uco); return u3_yes;
|
||||
}
|
||||
}
|
||||
|
||||
/* _cv_lily(): parse little atom.
|
||||
*/
|
||||
static u3_bean
|
||||
_cv_lily(u3_noun fot, u3_noun txt, c3_l* tid_l)
|
||||
{
|
||||
c3_d ato_d;
|
||||
|
||||
if ( u3_no == _cv_mole(fot, txt, &ato_d) ) {
|
||||
return u3_no;
|
||||
} else {
|
||||
if ( ato_d >= 0x80000000ULL ) {
|
||||
return u3_no;
|
||||
} else {
|
||||
*tid_l = (c3_l) ato_d;
|
||||
|
||||
return u3_yes;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* u3_cv_poke(): insert and apply an input ovum (protected).
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_poke(u3_noun ovo)
|
||||
{
|
||||
return _cv_nock_poke(ovo);
|
||||
}
|
||||
|
||||
/* u3_cv_http_request(): hear http request on channel (unprotected).
|
||||
*/
|
||||
void
|
||||
u3_cv_http_request(u3_bean sec, u3_noun pox, u3_noun req)
|
||||
{
|
||||
// uL(fprintf(uH, "http: request\n"));
|
||||
u3_cv_plan(pox, u3nq(c3__this, sec, 0, req));
|
||||
}
|
||||
|
||||
/* u3_cv_tank(): dump single tank.
|
||||
*/
|
||||
void
|
||||
u3_cv_tank(u3_noun blu, c3_l tab_l, u3_noun tac)
|
||||
{
|
||||
u3_cv_punt(blu, tab_l, u3nc(tac, u3_nul));
|
||||
}
|
||||
|
||||
/* u3_cv_punt(): dump tank list.
|
||||
*/
|
||||
void
|
||||
u3_cv_punt(u3_noun blu, c3_l tab_l, u3_noun tac)
|
||||
{
|
||||
#if 0
|
||||
u3_noun blu = u3_term_get_blew(0);
|
||||
#endif
|
||||
c3_l col_l = u3h(blu);
|
||||
u3_noun cat = tac;
|
||||
|
||||
// We are calling nock here, but hopefully need no protection.
|
||||
//
|
||||
while ( u3_yes == u3_cr_du(cat) ) {
|
||||
u3_noun wol = u3_dc("wash", u3nc(tab_l, col_l), u3k(u3h(cat)));
|
||||
|
||||
u3_cm_wall(wol);
|
||||
cat = u3t(cat);
|
||||
}
|
||||
u3z(tac);
|
||||
u3z(blu);
|
||||
}
|
||||
|
||||
/* u3_cv_sway(): print trace.
|
||||
*/
|
||||
void
|
||||
u3_cv_sway(u3_noun blu, c3_l tab_l, u3_noun tax)
|
||||
{
|
||||
u3_noun mok = u3_dc("mook", 2, tax);
|
||||
|
||||
u3_cv_punt(blu, tab_l, u3k(u3t(mok)));
|
||||
u3z(mok);
|
||||
}
|
||||
|
||||
/* u3_cv_plan(): queue ovum (external).
|
||||
*/
|
||||
void
|
||||
u3_cv_plan(u3_noun pax, u3_noun fav)
|
||||
{
|
||||
u3_noun egg = u3nc(pax, fav);
|
||||
u3A->roe = u3nc(u3nc(u3_nul, egg), u3A->roe);
|
||||
}
|
||||
|
||||
/* u3_cv_plow(): queue multiple ova (external).
|
||||
*/
|
||||
void
|
||||
u3_cv_plow(u3_noun ova)
|
||||
{
|
||||
u3_noun ovi = ova;
|
||||
|
||||
while ( u3_nul != ovi ) {
|
||||
u3_noun ovo=u3h(ovi);
|
||||
|
||||
u3_cv_plan(u3k(u3h(ovo)), u3k(u3t(ovo)));
|
||||
ovi = u3t(ovi);
|
||||
}
|
||||
u3z(ova);
|
||||
}
|
||||
|
||||
/* u3_cv_louse(): last-minute deviltry upon a bail.
|
||||
*/
|
||||
void
|
||||
u3_cv_louse(c3_m how_m)
|
||||
{
|
||||
#if 0
|
||||
if ( c3__exit == how_m ) {
|
||||
printf("louse: nocks: %d\n", NOX);
|
||||
printf("louse: washing kernel %x %d\n", u3A->ken, u3_co_is_dog(u3A->ken));
|
||||
u3_cm_wash(u3A->ken);
|
||||
|
||||
printf("kernel %x; washed mug %x\n", u3A->ken, u3_cr_mug(u3A->ken));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* _cv_mark_ova(): mark ova queue.
|
||||
*/
|
||||
static void
|
||||
_cv_mark_ova(u3p(u3_cs_cart) egg_p)
|
||||
{
|
||||
while ( egg_p ) {
|
||||
u3_cs_cart* egg_u = u3to(u3_cs_cart, egg_p);
|
||||
|
||||
u3_ca_mark_ptr(egg_u);
|
||||
u3_ca_mark_noun(egg_u->vir);
|
||||
|
||||
egg_p = egg_u->nex_p;
|
||||
}
|
||||
}
|
||||
|
||||
/* u3_cv_mark(): mark arvo kernel.
|
||||
*/
|
||||
void
|
||||
u3_cv_mark(void)
|
||||
{
|
||||
u3_cs_arvo* arv_u = &(u3H->arv_u);
|
||||
|
||||
u3_ca_mark_noun(arv_u->yot);
|
||||
u3_ca_mark_noun(arv_u->now);
|
||||
u3_ca_mark_noun(arv_u->wen);
|
||||
u3_ca_mark_noun(arv_u->sen);
|
||||
u3_ca_mark_noun(arv_u->own);
|
||||
|
||||
u3_ca_mark_noun(arv_u->roe);
|
||||
u3_ca_mark_noun(arv_u->key);
|
||||
|
||||
u3_ca_mark_noun(arv_u->ken);
|
||||
u3_ca_mark_noun(arv_u->roc);
|
||||
|
||||
_cv_mark_ova(arv_u->ova.egg_p);
|
||||
}
|
31
i/all.h
Normal file
31
i/all.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* include/all.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** c3: C environment.
|
||||
**/
|
||||
# include "c/portable.h" // C and OS portability
|
||||
# include "c/types.h" // c3 types
|
||||
# include "c/defs.h" // c3 macros
|
||||
# include "c/motes.h" // c3 constants
|
||||
|
||||
/** u3: noun environment.
|
||||
**/
|
||||
# include "n/u.h" // general u3
|
||||
|
||||
# include "n/a.h" // u3a: allocation
|
||||
# include "n/e.h" // u3e: persistence
|
||||
# include "n/h.h" // u3h: hashtables
|
||||
# include "n/i.h" // u3i: noun construction
|
||||
# include "n/j.h" // u3j: jet control
|
||||
# include "n/m.h" // u3m: master state
|
||||
# include "n/n.h" // u3n: nock execution
|
||||
# include "n/r.h" // u3r: noun access (error returns)
|
||||
# include "n/t.h" // u3t: profiling / tracing
|
||||
# include "n/x.h" // u3x: noun access (error crashes)
|
||||
# include "n/v.h" // u3v: arvo kernel
|
||||
# include "n/z.h" // u3z: memoization
|
||||
|
||||
# include "j/k.h" // u3k: jets (transfer, args)
|
||||
# include "j/q.h" // u3q: jets (retain, args)
|
||||
# include "j/w.h" // u3w: jets (retain, core)
|
@ -2,6 +2,17 @@
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Loobeans - inverse booleans to match nock.
|
||||
**/
|
||||
# define c3y 0
|
||||
# define c3n 1
|
||||
|
||||
# define _(x) (c3y == (x))
|
||||
# define __(x) ((x) ? c3y : c3n)
|
||||
# define c3a(x, y) __(_(x) && _(y))
|
||||
# define c3o(x, y) __(_(x) || _(y))
|
||||
|
||||
|
||||
/** Random useful C macros.
|
||||
**/
|
||||
/* Assert. Good to capture.
|
||||
@ -19,41 +30,7 @@
|
||||
|
||||
/* Bit counting.
|
||||
*/
|
||||
#if 1
|
||||
# define c3_bits_word(w) ((w) ? (32 - __builtin_clz(w)) : 0)
|
||||
#else
|
||||
#ifdef C3_GLOBAL
|
||||
c3_y Bts_y[] = {
|
||||
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
|
||||
};
|
||||
#else
|
||||
extern c3_y Bts_y[];
|
||||
#endif
|
||||
# define c3_bits_byte(y) Bts_y[y]
|
||||
# define c3_bits_word(w) \
|
||||
( ((w) >> 24) \
|
||||
? (24 + Bts_y[(w) >> 24]) \
|
||||
: ((w) >> 16) \
|
||||
? (16 + Bts_y[(w) >> 16]) \
|
||||
: ((w) >> 8) \
|
||||
? (8 + Bts_y[(w) >> 8]) \
|
||||
: Bts_y[(w)] )
|
||||
#endif
|
||||
# define c3_bits_word(w) ((w) ? (32 - __builtin_clz(w)) : 0)
|
||||
|
||||
/* Min and max.
|
||||
*/
|
||||
@ -104,6 +81,7 @@
|
||||
} \
|
||||
cnt_w = (cnt_w + 1) % (n); \
|
||||
} while (0)
|
||||
|
||||
/* c3_malloc(): asserting malloc
|
||||
*/
|
||||
#define c3_malloc(s) ({ \
|
@ -16,7 +16,7 @@
|
||||
*** porting layer here. Include them directly in the
|
||||
*** C file.
|
||||
**/
|
||||
# if defined(U2_OS_linux)
|
||||
# if defined(U3_OS_linux)
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <stdarg.h>
|
||||
@ -31,7 +31,7 @@
|
||||
# include <sys/resource.h>
|
||||
# include <sys/mman.h>
|
||||
|
||||
# elif defined(U2_OS_osx)
|
||||
# elif defined(U3_OS_osx)
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <stdarg.h>
|
||||
@ -47,7 +47,7 @@
|
||||
# include <sys/resource.h>
|
||||
# include <sys/mman.h>
|
||||
|
||||
# elif defined(U2_OS_bsd)
|
||||
# elif defined(U3_OS_bsd)
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <stdarg.h>
|
||||
@ -69,23 +69,23 @@
|
||||
|
||||
/** Address space layout.
|
||||
**/
|
||||
# if defined(U2_OS_linux)
|
||||
# define U2_OS_LoomBase 0x404db000
|
||||
# define U2_OS_LoomBits 29 // ie, 2^29 words == 2GB
|
||||
# elif defined(U2_OS_osx)
|
||||
# if defined(U3_OS_linux)
|
||||
# define U3_OS_LoomBase 0x404db000
|
||||
# define U3_OS_LoomBits 29 // ie, 2^29 words == 2GB
|
||||
# elif defined(U3_OS_osx)
|
||||
# ifdef __LP64__
|
||||
# define U2_OS_LoomBase 0x200000000
|
||||
# define U3_OS_LoomBase 0x200000000
|
||||
# else
|
||||
# define U2_OS_LoomBase 0x4000000
|
||||
# define U3_OS_LoomBase 0x4000000
|
||||
# endif
|
||||
# define U2_OS_LoomBits 29 // ie, 2^29 words == 2GB
|
||||
# elif defined(U2_OS_bsd)
|
||||
# define U3_OS_LoomBits 29 // ie, 2^29 words == 2GB
|
||||
# elif defined(U3_OS_bsd)
|
||||
# ifdef __LP64__
|
||||
# define U2_OS_LoomBase 0x200000000
|
||||
# define U3_OS_LoomBase 0x200000000
|
||||
# else
|
||||
# define U2_OS_LoomBase 0x4000000
|
||||
# define U3_OS_LoomBase 0x4000000
|
||||
# endif
|
||||
# define U2_OS_LoomBits 29 // ie, 2^29 words == 2GB
|
||||
# define U3_OS_LoomBits 29 // ie, 2^29 words == 2GB
|
||||
# else
|
||||
# error "port: LoomBase"
|
||||
# endif
|
||||
@ -110,7 +110,7 @@
|
||||
/** Private C "extensions."
|
||||
***
|
||||
*** Except for these and main(), any function, macro, or structure
|
||||
*** names must be prefixed either by u3_/U2_ (for public names),
|
||||
*** names must be prefixed either by u3_/U3_ (for public names),
|
||||
*** or _ (for static and other file-local names).
|
||||
**/
|
||||
/* Endianness.
|
||||
@ -118,22 +118,22 @@
|
||||
# define c3_endian_little 0
|
||||
# define c3_endian_big 1
|
||||
|
||||
# ifdef U2_OS_ENDIAN_little
|
||||
# ifdef U3_OS_ENDIAN_little
|
||||
# define c3_endian c3_endian_little
|
||||
# elif defined(U2_OS_ENDIAN_big)
|
||||
# elif defined(U3_OS_ENDIAN_big)
|
||||
# define c3_endian c3_endian_big
|
||||
# else
|
||||
# error "port: U2_OS_ENDIAN"
|
||||
# error "port: U3_OS_ENDIAN"
|
||||
# endif
|
||||
|
||||
/* Byte swapping.
|
||||
*/
|
||||
# if defined(U2_OS_linux) || defined(U2_OS_bsd)
|
||||
# if defined(U3_OS_linux) || defined(U3_OS_bsd)
|
||||
# define c3_bswap_16(x) bswap_16(x)
|
||||
# define c3_bswap_32(x) bswap_32(x)
|
||||
# define c3_bswap_64(x) bswap_64(x)
|
||||
|
||||
# elif defined(U2_OS_osx)
|
||||
# elif defined(U3_OS_osx)
|
||||
# define c3_bswap_16(x) NXSwapShort(x)
|
||||
# define c3_bswap_32(x) NXSwapInt(x)
|
||||
# define c3_bswap_64(x) NXSwapLongLong(x)
|
||||
@ -143,9 +143,9 @@
|
||||
|
||||
/* Sync
|
||||
*/
|
||||
# if defined(U2_OS_linux) || defined(U2_OS_bsd)
|
||||
# if defined(U3_OS_linux) || defined(U3_OS_bsd)
|
||||
# define c3_sync(fd) (fdatasync(fd))
|
||||
# elif defined(U2_OS_osx)
|
||||
# elif defined(U3_OS_osx)
|
||||
# define c3_sync(fd) (fcntl(fd, F_FULLFSYNC, 0))
|
||||
# else
|
||||
# error "port: sync"
|
||||
@ -153,10 +153,10 @@
|
||||
|
||||
/* Purge
|
||||
*/
|
||||
# if defined(U2_OS_linux)
|
||||
# if defined(U3_OS_linux)
|
||||
# include <stdio_ext.h>
|
||||
# define c3_fpurge __fpurge
|
||||
# elif defined(U2_OS_bsd) || defined(U2_OS_osx)
|
||||
# elif defined(U3_OS_bsd) || defined(U3_OS_osx)
|
||||
# define c3_fpurge fpurge
|
||||
# else
|
||||
# error "port: fpurge"
|
||||
@ -164,12 +164,12 @@
|
||||
|
||||
/* Stat struct
|
||||
*/
|
||||
# if defined(U2_OS_linux)
|
||||
# if defined(U3_OS_linux)
|
||||
# define c3_stat_mtime(dp) (u3_time_t_in_ts((dp)->st_mtime))
|
||||
# elif defined(U2_OS_osx)
|
||||
# elif defined(U3_OS_osx)
|
||||
# define c3_stat_mtime(dp) (u3_time_in_ts(&((dp)->st_mtimespec)))
|
||||
# define lseek64 lseek
|
||||
# elif defined(U2_OS_bsd)
|
||||
# elif defined(U3_OS_bsd)
|
||||
# define c3_stat_mtime(dp) (u3_time_in_ts(&((dp)->st_mtim)))
|
||||
# define lseek64 lseek
|
||||
# else
|
@ -22,13 +22,6 @@
|
||||
typedef uint32_t c3_l; // little; 31-bit unsigned integer
|
||||
typedef uint32_t c3_m; // mote; also c3_l; LSB first a-z 4-char string.
|
||||
|
||||
/* C true and false; boolean logic
|
||||
*/
|
||||
# define c3_true 1
|
||||
# define c3_false 0
|
||||
# define c3_and(x, y) ((x) && (y))
|
||||
# define c3_or(x, y) ((x) || (y))
|
||||
|
||||
/* Deprecated integers.
|
||||
*/
|
||||
typedef char c3_c; // does not match int8_t or uint8_t
|
96
i/j/k.h
Normal file
96
i/j/k.h
Normal file
@ -0,0 +1,96 @@
|
||||
/* include/f/kjet.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tier 1.
|
||||
**/
|
||||
u3_noun u3ka_add(u3_noun a, u3_noun b);
|
||||
u3_noun u3ka_sub(u3_noun a, u3_noun b);
|
||||
u3_noun u3ka_mul(u3_noun a, u3_noun b);
|
||||
u3_noun u3ka_gth(u3_noun a, u3_noun b);
|
||||
u3_noun u3ka_lte(u3_noun a, u3_noun b);
|
||||
|
||||
/** Tier 2.
|
||||
**/
|
||||
u3_noun u3kb_lent(u3_noun a);
|
||||
u3_noun u3kb_weld(u3_noun a, u3_noun b);
|
||||
u3_noun u3kb_flop(u3_noun a);
|
||||
|
||||
/* u3kc: tier 3 functions
|
||||
*/
|
||||
/* u3kc_lsh(): left shift.
|
||||
*/
|
||||
u3_noun
|
||||
u3kc_lsh(u3_noun a, u3_noun b, u3_noun c);
|
||||
|
||||
/* u3kc_rsh(): right shift.
|
||||
*/
|
||||
u3_noun
|
||||
u3kc_rsh(u3_noun a, u3_noun b, u3_noun c);
|
||||
|
||||
/* u3kd: tier 4 functions
|
||||
*/
|
||||
/* u3kdb_get(): map get for key `b` in map `a` with u3_none.
|
||||
*/
|
||||
u3_weak
|
||||
u3kdb_get(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3kdb_got(): map get for key `b` in map `a` with bail.
|
||||
*/
|
||||
u3_noun
|
||||
u3kdb_got(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3kdb_put(): map put for key `b`, value `c` in map `a`.
|
||||
*/
|
||||
u3_weak
|
||||
u3kdb_put(u3_noun a, u3_noun b, u3_noun c);
|
||||
|
||||
/* u3kdb_has(): test for get.
|
||||
*/
|
||||
u3_noun
|
||||
u3kdb_has(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3kdb_gas(): list to map.
|
||||
*/
|
||||
u3_noun
|
||||
u3kdb_gas(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3kdi_gas(): list to map.
|
||||
*/
|
||||
u3_noun
|
||||
u3kdi_gas(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3kdi_has(): test for presence.
|
||||
*/
|
||||
u3_noun
|
||||
u3kdi_has(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3kdi_tap(): map/set convert to list. (solves by_tap also.)
|
||||
*/
|
||||
u3_noun
|
||||
u3kdi_tap(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3kdi_put(): put in set.
|
||||
*/
|
||||
u3_weak
|
||||
u3kdi_put(u3_noun a, u3_noun b);
|
||||
|
||||
# define u3kdb_tap(a, b) u3kdi_tap(a, b)
|
||||
|
||||
/* u3ke: tier 5 functions
|
||||
*/
|
||||
/* u3ke_cue(): expand saved pill.
|
||||
*/
|
||||
u3_noun
|
||||
u3ke_cue(u3_atom a);
|
||||
|
||||
/* u3ke_jam(): pack noun as atom.
|
||||
*/
|
||||
u3_atom
|
||||
u3ke_jam(u3_noun a);
|
||||
|
||||
/* u3ke_trip: atom to tape.
|
||||
*/
|
||||
u3_noun
|
||||
u3ke_trip(u3_noun a);
|
||||
|
184
i/j/q.h
Normal file
184
i/j/q.h
Normal file
@ -0,0 +1,184 @@
|
||||
/* include/f/qjet.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tier 1.
|
||||
**/
|
||||
u3_noun u3qa_add(u3_atom, u3_atom);
|
||||
u3_noun u3qa_dec(u3_atom);
|
||||
u3_noun u3qa_div(u3_atom, u3_atom);
|
||||
u3_noun u3qa_gte(u3_atom, u3_atom);
|
||||
u3_noun u3qa_gth(u3_atom, u3_atom);
|
||||
u3_noun u3qa_inc(u3_atom);
|
||||
u3_noun u3qa_lte(u3_atom, u3_atom);
|
||||
u3_noun u3qa_lth(u3_atom, u3_atom);
|
||||
u3_noun u3qa_mod(u3_atom, u3_atom);
|
||||
u3_noun u3qa_mul(u3_atom, u3_atom);
|
||||
u3_noun u3qa_sub(u3_atom, u3_atom);
|
||||
|
||||
/** Tier 2.
|
||||
**/
|
||||
u3_noun u3qb_bind(u3_noun, u3_noun);
|
||||
u3_noun u3qb_clap(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qb_drop(u3_noun);
|
||||
u3_noun u3qb_flop(u3_noun);
|
||||
u3_noun u3qb_lent(u3_noun);
|
||||
u3_noun u3qb_levy(u3_noun, u3_noun);
|
||||
u3_noun u3qb_lien(u3_noun, u3_noun);
|
||||
u3_noun u3qb_need(u3_noun);
|
||||
u3_noun u3qb_reel(u3_noun, u3_noun);
|
||||
u3_noun u3qb_roll(u3_noun, u3_noun);
|
||||
u3_noun u3qb_skim(u3_noun, u3_noun);
|
||||
u3_noun u3qb_skip(u3_noun, u3_noun);
|
||||
u3_noun u3qb_scag(u3_atom, u3_noun);
|
||||
u3_noun u3qb_slag(u3_atom, u3_noun);
|
||||
u3_noun u3qb_snag(u3_atom, u3_noun);
|
||||
u3_noun u3qb_sort(u3_noun, u3_noun);
|
||||
u3_noun u3qb_turn(u3_noun, u3_noun);
|
||||
u3_noun u3qb_weld(u3_noun, u3_noun);
|
||||
|
||||
/** Tier 3.
|
||||
**/
|
||||
u3_noun u3qc_bex(u3_atom);
|
||||
u3_noun u3qc_can(u3_atom, u3_noun);
|
||||
u3_noun u3qc_cap(u3_atom);
|
||||
u3_noun u3qc_cat(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3qc_con(u3_atom, u3_atom);
|
||||
u3_noun u3qc_cut(u3_atom, u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3qc_dis(u3_atom, u3_atom);
|
||||
u3_noun u3qc_dor(u3_atom, u3_atom);
|
||||
u3_noun u3qc_end(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3qc_gor(u3_atom, u3_atom);
|
||||
u3_noun u3qc_hor(u3_atom, u3_atom);
|
||||
u3_noun u3qc_lsh(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3qc_mas(u3_atom);
|
||||
u3_noun u3qc_met(u3_atom, u3_atom);
|
||||
u3_noun u3qc_mix(u3_atom, u3_atom);
|
||||
u3_noun u3qc_peg(u3_atom, u3_atom);
|
||||
u3_noun u3qc_rap(u3_atom, u3_noun);
|
||||
u3_noun u3qc_rip(u3_atom, u3_atom);
|
||||
u3_noun u3qc_rsh(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3qc_vor(u3_atom, u3_atom);
|
||||
|
||||
/** Tier 4.
|
||||
**/
|
||||
u3_noun u3qdb_gas(u3_noun, u3_noun);
|
||||
u3_noun u3qdb_get(u3_noun, u3_noun);
|
||||
u3_noun u3qdb_has(u3_noun, u3_noun);
|
||||
u3_noun u3qdb_int(u3_noun, u3_noun);
|
||||
u3_noun u3qdb_put(u3_noun, u3_noun, u3_noun);
|
||||
# define u3qdb_tap u3qdi_tap
|
||||
u3_noun u3qdb_uni(u3_noun, u3_noun);
|
||||
|
||||
u3_noun u3qdi_gas(u3_noun, u3_noun);
|
||||
u3_noun u3qdi_has(u3_noun, u3_noun);
|
||||
u3_noun u3qdi_int(u3_noun, u3_noun);
|
||||
u3_noun u3qdi_mer(u3_noun, u3_noun);
|
||||
u3_noun u3qdi_put(u3_noun, u3_noun);
|
||||
u3_noun u3qdi_tap(u3_noun, u3_noun);
|
||||
u3_noun u3qdi_uni(u3_noun, u3_noun);
|
||||
|
||||
/** Tier 5.
|
||||
**/
|
||||
u3_noun u3qe_cue(u3_atom);
|
||||
u3_noun u3qe_jam(u3_atom);
|
||||
u3_noun u3qe_mat(u3_atom);
|
||||
u3_noun u3qe_rub(u3_atom, u3_atom);
|
||||
u3_noun u3qe_lore(u3_atom);
|
||||
u3_noun u3qe_loss(u3_noun, u3_noun);
|
||||
u3_noun u3qe_repg(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qe_rexp(u3_noun, u3_noun);
|
||||
u3_noun u3qe_trip(u3_atom);
|
||||
|
||||
u3_noun u3qea_de(u3_atom, u3_atom);
|
||||
u3_noun u3qea_en(u3_atom, u3_atom);
|
||||
|
||||
u3_noun u3qe_shax(u3_atom);
|
||||
u3_noun u3qe_shas(u3_atom, u3_atom);
|
||||
u3_noun u3qe_shal(u3_atom, u3_atom);
|
||||
|
||||
u3_noun u3qeo_raw(u3_atom, u3_atom);
|
||||
|
||||
u3_noun u3qer_sun(u3_atom);
|
||||
u3_noun u3qer_mul(u3_atom, u3_atom);
|
||||
u3_noun u3qer_div(u3_atom, u3_atom);
|
||||
u3_noun u3qer_add(u3_atom, u3_atom);
|
||||
u3_noun u3qer_sub(u3_atom, u3_atom);
|
||||
u3_noun u3qer_lte(u3_atom, u3_atom);
|
||||
u3_noun u3qer_lth(u3_atom, u3_atom);
|
||||
u3_noun u3qer_gte(u3_atom, u3_atom);
|
||||
u3_noun u3qer_gth(u3_atom, u3_atom);
|
||||
|
||||
|
||||
/** Tier 6.
|
||||
**/
|
||||
u3_noun u3qf_bull(u3_noun, u3_noun);
|
||||
u3_noun u3qf_cell(u3_noun, u3_noun);
|
||||
u3_noun u3qf_comb(u3_noun, u3_noun);
|
||||
u3_noun u3qf_cons(u3_noun, u3_noun);
|
||||
u3_noun u3qf_core(u3_noun, u3_noun);
|
||||
u3_noun u3qf_cube(u3_noun, u3_noun);
|
||||
u3_noun u3qf_face(u3_noun, u3_noun);
|
||||
u3_noun u3qf_fine(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qf_fitz(u3_noun, u3_noun);
|
||||
u3_noun u3qf_flan(u3_noun, u3_noun);
|
||||
u3_noun u3qf_flay(u3_noun);
|
||||
u3_noun u3qf_flip(u3_noun);
|
||||
u3_noun u3qf_flor(u3_noun, u3_noun);
|
||||
u3_noun u3qf_fork(u3_noun, u3_noun);
|
||||
u3_noun u3qf_hike(u3_noun, u3_noun);
|
||||
u3_noun u3qf_look(u3_noun, u3_noun);
|
||||
u3_noun u3qf_slot(u3_atom, u3_noun);
|
||||
u3_noun u3qf_type(u3_noun);
|
||||
|
||||
u3_noun u3qfl_bunt(u3_noun, u3_noun);
|
||||
u3_noun u3qfl_whip(u3_noun, u3_noun, u3_noun);
|
||||
|
||||
u3_noun u3qfp_hack(u3_noun, u3_noun);
|
||||
u3_noun u3qfp_late(u3_noun);
|
||||
u3_noun u3qfp_open(u3_noun, u3_noun);
|
||||
u3_noun u3qfp_rake(u3_noun);
|
||||
|
||||
# define u3qfu_van_fan 28
|
||||
# define u3qfu_van_rib 58
|
||||
# define u3qfu_van_vrf 59
|
||||
# define u3qfu_van_vet 118
|
||||
# define u3qfu_van_fab 119
|
||||
|
||||
u3_noun u3qfu_burn(u3_noun, u3_noun);
|
||||
u3_noun u3qfu_busk(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_bust(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_conk(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_crop(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_cull(u3_noun, u3_noun, u3_noun, u3_atom, u3_noun);
|
||||
u3_noun u3qfu_duck(u3_noun, u3_noun);
|
||||
u3_noun u3qfu_dung(u3_noun, u3_noun cap, u3_noun);
|
||||
u3_noun u3qfu_dunq(u3_noun, const c3_c*, u3_noun);
|
||||
u3_noun u3qfu_find(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_fino(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_fire(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_firm(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_fish(u3_noun, u3_noun, u3_atom);
|
||||
u3_noun u3qfu_fuse(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_gain(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_heal(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_lose(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_mint(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_mull(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_nest(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_orth(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_park(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_peek(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_play(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_repo(u3_noun, u3_noun);
|
||||
u3_noun u3qfu_rest(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_seek(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_seep(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_shep(u3_noun, const c3_c*, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_shew(u3_noun, u3_noun);
|
||||
u3_noun u3qfu_sift(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_snub(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_tack(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_tock(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3qfu_wrap(u3_noun, u3_noun, u3_noun);
|
197
i/j/w.h
Normal file
197
i/j/w.h
Normal file
@ -0,0 +1,197 @@
|
||||
/* include/f/qjet.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tier 1.
|
||||
**/
|
||||
u3_noun u3wa_add(u3_noun);
|
||||
u3_noun u3wa_dec(u3_noun);
|
||||
u3_noun u3wa_div(u3_noun);
|
||||
u3_noun u3wa_gte(u3_noun);
|
||||
u3_noun u3wa_gth(u3_noun);
|
||||
u3_noun u3wa_lte(u3_noun);
|
||||
u3_noun u3wa_lth(u3_noun);
|
||||
u3_noun u3wa_mod(u3_noun);
|
||||
u3_noun u3wa_mul(u3_noun);
|
||||
u3_noun u3wa_sub(u3_noun);
|
||||
|
||||
/** Tier 2.
|
||||
**/
|
||||
u3_noun u3wb_bind(u3_noun);
|
||||
u3_noun u3wb_clap(u3_noun);
|
||||
u3_noun u3wb_drop(u3_noun);
|
||||
u3_noun u3wb_flop(u3_noun);
|
||||
u3_noun u3wb_lent(u3_noun);
|
||||
u3_noun u3wb_levy(u3_noun);
|
||||
u3_noun u3wb_lien(u3_noun);
|
||||
u3_noun u3wb_need(u3_noun);
|
||||
u3_noun u3wb_reel(u3_noun);
|
||||
u3_noun u3wb_roll(u3_noun);
|
||||
u3_noun u3wb_skim(u3_noun);
|
||||
u3_noun u3wb_skip(u3_noun);
|
||||
u3_noun u3wb_scag(u3_noun);
|
||||
u3_noun u3wb_slag(u3_noun);
|
||||
u3_noun u3wb_snag(u3_noun);
|
||||
u3_noun u3wb_sort(u3_noun);
|
||||
u3_noun u3wb_turn(u3_noun);
|
||||
u3_noun u3wb_weld(u3_noun);
|
||||
|
||||
/** Tier 3.
|
||||
**/
|
||||
u3_noun u3wc_bex(u3_noun);
|
||||
u3_noun u3wc_can(u3_noun);
|
||||
u3_noun u3wc_cap(u3_noun);
|
||||
u3_noun u3wc_cat(u3_noun);
|
||||
u3_noun u3wc_con(u3_noun);
|
||||
u3_noun u3wc_cut(u3_noun);
|
||||
u3_noun u3wc_dis(u3_noun);
|
||||
u3_noun u3wc_dor(u3_noun);
|
||||
u3_noun u3wc_end(u3_noun);
|
||||
u3_noun u3wc_gor(u3_noun);
|
||||
u3_noun u3wc_hor(u3_noun);
|
||||
u3_noun u3wc_lsh(u3_noun);
|
||||
u3_noun u3wc_mas(u3_noun);
|
||||
u3_noun u3wc_met(u3_noun);
|
||||
u3_noun u3wc_mix(u3_noun);
|
||||
u3_noun u3wc_mug(u3_noun);
|
||||
u3_noun u3wc_peg(u3_noun);
|
||||
u3_noun u3wc_rap(u3_noun);
|
||||
u3_noun u3wc_rip(u3_noun);
|
||||
u3_noun u3wc_rsh(u3_noun);
|
||||
u3_noun u3wc_vor(u3_noun);
|
||||
|
||||
u3_noun u3wcp_ins(u3_noun);
|
||||
u3_noun u3wcp_ind(u3_noun);
|
||||
u3_noun u3wcp_tos(u3_noun);
|
||||
u3_noun u3wcp_tod(u3_noun);
|
||||
|
||||
/** Tier 4.
|
||||
**/
|
||||
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_put(u3_noun);
|
||||
# define u3wdb_tap u3wdi_tap
|
||||
u3_noun u3wdb_uni(u3_noun);
|
||||
|
||||
u3_noun u3wdi_gas(u3_noun);
|
||||
u3_noun u3wdi_has(u3_noun);
|
||||
u3_noun u3wdi_int(u3_noun);
|
||||
u3_noun u3wdi_mer(u3_noun);
|
||||
u3_noun u3wdi_put(u3_noun);
|
||||
u3_noun u3wdi_tap(u3_noun);
|
||||
u3_noun u3wdi_uni(u3_noun);
|
||||
|
||||
/** Tier 5.
|
||||
**/
|
||||
u3_noun u3we_cue(u3_noun);
|
||||
u3_noun u3we_jam(u3_noun);
|
||||
u3_noun u3we_mat(u3_noun);
|
||||
u3_noun u3we_rub(u3_noun);
|
||||
u3_noun u3we_lore(u3_noun);
|
||||
u3_noun u3we_loss(u3_noun);
|
||||
u3_noun u3we_mink(u3_noun);
|
||||
u3_noun u3we_mule(u3_noun);
|
||||
u3_noun u3we_repg(u3_noun);
|
||||
u3_noun u3we_rexp(u3_noun);
|
||||
u3_noun u3we_trip(u3_noun);
|
||||
|
||||
u3_noun u3we_pfix(u3_noun);
|
||||
u3_noun u3we_plug(u3_noun);
|
||||
u3_noun u3we_pose(u3_noun);
|
||||
u3_noun u3we_sfix(u3_noun);
|
||||
|
||||
u3_noun u3wea_de(u3_noun);
|
||||
u3_noun u3wea_en(u3_noun);
|
||||
|
||||
u3_noun u3we_shax(u3_noun);
|
||||
u3_noun u3we_shas(u3_noun);
|
||||
u3_noun u3we_shal(u3_noun);
|
||||
|
||||
u3_noun u3weo_raw(u3_noun);
|
||||
|
||||
u3_noun u3wee_puck(u3_noun);
|
||||
u3_noun u3wee_sign(u3_noun);
|
||||
u3_noun u3wee_veri(u3_noun);
|
||||
|
||||
u3_noun u3we_bend_fun(u3_noun);
|
||||
u3_noun u3we_cold_fun(u3_noun);
|
||||
u3_noun u3we_cook_fun(u3_noun);
|
||||
u3_noun u3we_comp_fun(u3_noun);
|
||||
u3_noun u3we_easy_fun(u3_noun);
|
||||
u3_noun u3we_glue_fun(u3_noun);
|
||||
u3_noun u3we_here_fun(u3_noun);
|
||||
u3_noun u3we_just_fun(u3_noun);
|
||||
u3_noun u3we_mask_fun(u3_noun);
|
||||
u3_noun u3we_shim_fun(u3_noun);
|
||||
u3_noun u3we_stag_fun(u3_noun);
|
||||
u3_noun u3we_stew_fun(u3_noun);
|
||||
u3_noun u3we_stir_fun(u3_noun);
|
||||
|
||||
u3_noun u3wer_sun(u3_noun);
|
||||
u3_noun u3wer_mul(u3_noun);
|
||||
u3_noun u3wer_div(u3_noun);
|
||||
u3_noun u3wer_add(u3_noun);
|
||||
u3_noun u3wer_sub(u3_noun);
|
||||
u3_noun u3wer_lte(u3_noun);
|
||||
u3_noun u3wer_lth(u3_noun);
|
||||
u3_noun u3wer_gte(u3_noun);
|
||||
u3_noun u3wer_gth(u3_noun);
|
||||
|
||||
|
||||
/** Tier 6.
|
||||
**/
|
||||
u3_noun u3wf_bull(u3_noun);
|
||||
u3_noun u3wf_cell(u3_noun);
|
||||
u3_noun u3wf_comb(u3_noun);
|
||||
u3_noun u3wf_cons(u3_noun);
|
||||
u3_noun u3wf_core(u3_noun);
|
||||
u3_noun u3wf_cube(u3_noun);
|
||||
u3_noun u3wf_face(u3_noun);
|
||||
u3_noun u3wf_fine(u3_noun);
|
||||
u3_noun u3wf_fitz(u3_noun);
|
||||
u3_noun u3wf_flan(u3_noun);
|
||||
u3_noun u3wf_flay(u3_noun);
|
||||
u3_noun u3wf_flip(u3_noun);
|
||||
u3_noun u3wf_flor(u3_noun);
|
||||
u3_noun u3wf_fork(u3_noun);
|
||||
u3_noun u3wf_hike(u3_noun);
|
||||
u3_noun u3wf_look(u3_noun);
|
||||
|
||||
u3_noun u3wfl_bunt(u3_noun);
|
||||
u3_noun u3wfl_whip(u3_noun);
|
||||
|
||||
u3_noun u3wfp_hack(u3_noun);
|
||||
u3_noun u3wfp_late(u3_noun);
|
||||
u3_noun u3wfp_open(u3_noun);
|
||||
u3_noun u3wfp_rake(u3_noun);
|
||||
|
||||
u3_noun u3wfu_burn(u3_noun);
|
||||
u3_noun u3wfu_busk(u3_noun);
|
||||
u3_noun u3wfu_bust(u3_noun);
|
||||
u3_noun u3wfu_conk(u3_noun);
|
||||
u3_noun u3wfu_crop(u3_noun);
|
||||
u3_noun u3wfu_cull(u3_noun);
|
||||
u3_noun u3wfu_duck(u3_noun);
|
||||
u3_noun u3wfu_find(u3_noun);
|
||||
u3_noun u3wfu_fino(u3_noun);
|
||||
u3_noun u3wfu_fink(u3_noun);
|
||||
u3_noun u3wfu_fire(u3_noun);
|
||||
u3_noun u3wfu_firm(u3_noun);
|
||||
u3_noun u3wfu_fish(u3_noun);
|
||||
u3_noun u3wfu_fuse(u3_noun);
|
||||
u3_noun u3wfu_heal(u3_noun);
|
||||
u3_noun u3wfu_mint(u3_noun);
|
||||
u3_noun u3wfu_mull(u3_noun);
|
||||
u3_noun u3wfu_nest(u3_noun);
|
||||
u3_noun u3wfu_park(u3_noun);
|
||||
u3_noun u3wfu_peek(u3_noun);
|
||||
u3_noun u3wfu_play(u3_noun);
|
||||
u3_noun u3wfu_repo(u3_noun);
|
||||
u3_noun u3wfu_rest(u3_noun);
|
||||
u3_noun u3wfu_seek(u3_noun);
|
||||
u3_noun u3wfu_seep(u3_noun);
|
||||
u3_noun u3wfu_snub(u3_noun);
|
||||
u3_noun u3wfu_tock(u3_noun);
|
||||
u3_noun u3wfu_wrap(u3_noun);
|
492
i/n/a.h
Normal file
492
i/n/a.h
Normal file
@ -0,0 +1,492 @@
|
||||
/* include/g/a.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tunables.
|
||||
**/
|
||||
# undef U3_MEMORY_DEBUG
|
||||
# ifdef U3_MEMORY_DEBUG
|
||||
# define u3a_leak_on(x) (u3_Code = x)
|
||||
# define u3a_leak_off (u3_Code = 0)
|
||||
# endif
|
||||
|
||||
# define u3a_bits U3_OS_LoomBits // 28, max 29
|
||||
# define u3a_page 12 // 16Kbyte pages
|
||||
# define u3a_pages (1 << (u3a_bits - u3a_page)) // 2^16 pages
|
||||
# define u3a_words (1 << u3a_bits)
|
||||
# define u3a_bytes (c3_w)((1 << (2 + u3a_bits)))
|
||||
|
||||
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3_atom, u3_cell: logical atom and cell structures.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w mug_w;
|
||||
} u3a_noun;
|
||||
|
||||
typedef struct {
|
||||
c3_w mug_w;
|
||||
c3_w len_w;
|
||||
c3_w buf_w[0];
|
||||
} u3a_atom;
|
||||
|
||||
typedef struct {
|
||||
c3_w mug_w;
|
||||
u3_noun hed;
|
||||
u3_noun tel;
|
||||
} u3a_cell;
|
||||
|
||||
/* Inside a noun.
|
||||
*/
|
||||
# define u3a_is_cat(som) (((som) >> 31) ? c3n : c3y)
|
||||
# define u3a_is_dog(som) (((som) >> 31) ? c3y : c3n)
|
||||
|
||||
# define u3a_is_pug(som) ((2 == ((som) >> 30)) ? c3y : c3n)
|
||||
# define u3a_is_pom(som) ((3 == ((som) >> 30)) ? c3y : c3n)
|
||||
# define u3a_to_off(som) ((som) & 0x3fffffff)
|
||||
# define u3a_to_ptr(som) (u3a_into(u3a_to_off(som)))
|
||||
# define u3a_to_wtr(som) ((c3_w *)u3a_to_ptr(som))
|
||||
# define u3a_to_pug(off) (off | 0x80000000)
|
||||
# define u3a_to_pom(off) (off | 0xc0000000)
|
||||
|
||||
# define u3a_is_atom(som) c3o(u3a_is_cat(som), \
|
||||
u3a_is_pug(som))
|
||||
# define u3a_is_cell(som) u3a_is_pom(som)
|
||||
# define u3a_de_twin(dog, dog_w) ((dog & 0xc0000000) | u3a_outa(dog_w))
|
||||
|
||||
# define u3a_h(som) \
|
||||
( _(u3a_is_cell(som)) \
|
||||
? ( ((u3a_cell *)u3a_to_ptr(som))->hed )\
|
||||
: u3m_bail(c3__exit) )
|
||||
|
||||
# define u3a_t(som) \
|
||||
( _(u3a_is_cell(som)) \
|
||||
? ( ((u3a_cell *)u3a_to_ptr(som))->tel )\
|
||||
: u3m_bail(c3__exit) )
|
||||
|
||||
/* u3a_box: classic allocation box.
|
||||
**
|
||||
** The box size is also stored at the end of the box in classic
|
||||
** bad ass malloc style. Hence a box is:
|
||||
**
|
||||
** ---
|
||||
** siz_w
|
||||
** use_w
|
||||
** if(debug) cod_w
|
||||
** user data
|
||||
** siz_w
|
||||
** ---
|
||||
**
|
||||
** Do not attempt to adjust this structure!
|
||||
*/
|
||||
typedef struct _u3a_box {
|
||||
c3_w siz_w; // size of this box
|
||||
c3_w use_w; // reference count; free if 0
|
||||
# ifdef U3_MEMORY_DEBUG
|
||||
c3_w eus_w; // recomputed refcount
|
||||
c3_w cod_w; // tracing code
|
||||
# endif
|
||||
} u3a_box;
|
||||
|
||||
# define u3a_boxed(len_w) (len_w + c3_wiseof(u3a_box) + 1)
|
||||
# define u3a_boxto(box_v) ( (void *) \
|
||||
( ((c3_w *)(void*)(box_v)) + \
|
||||
c3_wiseof(u3a_box) ) )
|
||||
# define u3a_botox(tox_v) ( (struct _u3a_box *) \
|
||||
(void *) \
|
||||
( ((c3_w *)(void*)(tox_v)) - \
|
||||
c3_wiseof(u3a_box) ) )
|
||||
|
||||
/* u3a_fbox: free node in heap. Sets minimum node size.
|
||||
**
|
||||
*/
|
||||
typedef struct _u3a_fbox {
|
||||
u3a_box box_u;
|
||||
u3p(struct _u3a_fbox) pre_p;
|
||||
u3p(struct _u3a_fbox) nex_p;
|
||||
} u3a_fbox;
|
||||
|
||||
# define u3_cc_minimum 6
|
||||
# define u3_cc_fbox_no 28
|
||||
|
||||
|
||||
/* u3a_road: contiguous allocation and execution context.
|
||||
**
|
||||
** A road is a normal heap-stack system, except that the heap
|
||||
** and stack can point in either direction. Therefore, inside
|
||||
** a road, we can nest another road in the opposite direction.
|
||||
**
|
||||
** When the opposite road completes, its heap is left on top of
|
||||
** the opposite heap's stack. It's no more than the normal
|
||||
** behavior of a stack machine for all subcomputations to push
|
||||
** their results, internally durable, on the stack.
|
||||
**
|
||||
** The performance tradeoff of "leaping" - reversing directions
|
||||
** in the road - is that if the outer computation wants to
|
||||
** preserve the results of the inner one, not just use them for
|
||||
** temporary purposes, it has to copy them.
|
||||
**
|
||||
** This is a trivial cost in some cases, a prohibitive cost in
|
||||
** others. The upside, of course, is that all garbage accrued
|
||||
** in the inner computation is discarded at zero cost.
|
||||
**
|
||||
** The goal of the road system is the ability to *layer* memory
|
||||
** models. If you are allocating on a road, you have no idea
|
||||
** how deep within a nested road system you are - in other words,
|
||||
** you have no idea exactly how durable your result may be.
|
||||
** But free space is never fragmented within a road.
|
||||
**
|
||||
** Roads do not reduce the generality or performance of a memory
|
||||
** system, since even the most complex GC system can be nested
|
||||
** within a road at no particular loss of performance - a road
|
||||
** is just a block of memory. The cost of road allocation is,
|
||||
** at least in theory, the branch prediction hits when we try to
|
||||
** decide which side of the road we're allocating on. The road
|
||||
** system imposes no pointer read or write barriers, of course.
|
||||
**
|
||||
** The road can point in either direction. If cap > hat, it
|
||||
** looks like this ("north"):
|
||||
**
|
||||
** 0 rut hat ffff
|
||||
** | | | |
|
||||
** |~~~~~~~~~~~~-------##########################+++++++$~~~~~|
|
||||
** | | | |
|
||||
** 0 cap mat ffff
|
||||
**
|
||||
** Otherwise, it looks like this ("south"):
|
||||
**
|
||||
** 0 mat cap ffff
|
||||
** | | | |
|
||||
** |~~~~~~~~~~~~$++++++##########################--------~~~~~|
|
||||
** | | | |
|
||||
** 0 hat rut ffff
|
||||
**
|
||||
** Legend: - is durable storage (heap); + is temporary storage
|
||||
** (stack); ~ is deep storage (immutable); $ is the allocation block;
|
||||
** # is free memory.
|
||||
**
|
||||
** Pointer restrictions: pointers stored in + can point anywhere,
|
||||
** except to more central pointers in +. (Ie, all pointers from
|
||||
** stack to stack must point downward on the stack.) Pointers in
|
||||
** - can only point to - or ~; pointers in ~ only point to ~.
|
||||
**
|
||||
** To "leap" is to create a new inner road in the ### free space.
|
||||
** but in the reverse direction, so that when the inner road
|
||||
** "falls" (terminates), its durable storage is left on the
|
||||
** temporary storage of the outer road.
|
||||
**
|
||||
** In all cases, the pointer in a u3_noun is a word offset into
|
||||
** u3H, the top-level road.
|
||||
*/
|
||||
typedef struct _u3a_road {
|
||||
struct _u3a_road* par_u; // parent road
|
||||
|
||||
struct _u3a_road* kid_u; // child road list
|
||||
struct _u3a_road* nex_u; // sibling road
|
||||
struct _u3a_road* now_u; // current road pointer
|
||||
|
||||
u3p(c3_w) cap_p; // top of transient region
|
||||
u3p(c3_w) hat_p; // top of durable region
|
||||
u3p(c3_w) mat_p; // bottom of transient region
|
||||
u3p(c3_w) rut_p; // bottom of durable region
|
||||
u3p(c3_w) ear_p; // original cap if kid is live
|
||||
|
||||
c3_w fut_w[32]; // futureproof buffer
|
||||
|
||||
struct { // escape buffer
|
||||
union {
|
||||
jmp_buf buf;
|
||||
c3_w buf_w[256]; // futureproofing
|
||||
};
|
||||
} esc;
|
||||
|
||||
struct { // miscellaneous config
|
||||
c3_w fag_w; // flag bits
|
||||
} how; //
|
||||
|
||||
struct { // allocation pools
|
||||
u3p(u3a_fbox) fre_p[u3_cc_fbox_no]; // heap by node size log
|
||||
c3_w fre_w; // number of free words
|
||||
} all;
|
||||
|
||||
struct { // jet dashboard
|
||||
u3p(u3h_root) har_p; // jet index (old style)
|
||||
u3_noun das; // dashboard (new style)
|
||||
} jed;
|
||||
|
||||
struct { // namespace
|
||||
u3_noun flu; // (list $+(* (unit))), inward
|
||||
} ski;
|
||||
|
||||
struct { // trace stack
|
||||
u3_noun tax; // (list ,*)
|
||||
u3_noun mer; // emergency buffer to release
|
||||
} bug;
|
||||
|
||||
struct { // profile stack
|
||||
c3_d nox_d; // nock steps
|
||||
u3_noun don; // ++path
|
||||
u3_noun day; // profile data, ++doss
|
||||
} pro;
|
||||
|
||||
struct { // memoization
|
||||
u3p(u3h_root) har_p; // (map (pair term noun) noun)
|
||||
} cax;
|
||||
} u3a_road;
|
||||
typedef u3a_road u3_road;
|
||||
|
||||
|
||||
/** Flags.
|
||||
**/
|
||||
enum u3a_flag {
|
||||
u3a_flag_debug = 0x1, // debug memory
|
||||
u3a_flag_gc = 0x2, // garbage collect once
|
||||
u3a_flag_sand = 0x4, // sand mode, bump allocation
|
||||
u3a_flag_die = 0x8 // process was asked to exit
|
||||
};
|
||||
|
||||
|
||||
/** Macros.
|
||||
**/
|
||||
# define u3a_into(x) ((void *)(u3_Loom + (x)))
|
||||
# define u3a_outa(p) (((c3_w*)(void*)(p)) - u3_Loom)
|
||||
|
||||
# define u3to(type, x) ((type *) u3a_into(x))
|
||||
# define u3of(type, x) (u3a_outa((type *)x))
|
||||
|
||||
# define u3a_is_north(r) __(r->cap_p > r->hat_p)
|
||||
# define u3a_is_south(r) !u3a_is_north(r)
|
||||
|
||||
# define u3a_open(r) ( (c3y == u3a_is_north(r)) \
|
||||
? (c3_w)(r->cap_p - r->hat_p) \
|
||||
: (c3_w)(r->hat_p - r->cap_p) )
|
||||
|
||||
# define u3a_north_is_senior(r, dog) \
|
||||
__((u3a_to_off(dog) < r->rut_p) || \
|
||||
(u3a_to_off(dog) >= r->mat_p))
|
||||
|
||||
# define u3a_north_is_junior(r, dog) \
|
||||
__((u3a_to_off(dog) >= r->cap_p) && \
|
||||
(u3a_to_off(dog) < r->mat_p))
|
||||
|
||||
# define u3a_north_is_normal(r, dog) \
|
||||
c3a(!(u3a_north_is_senior(r, dog)), \
|
||||
!(u3a_north_is_junior(r, dog)))
|
||||
|
||||
# define u3a_south_is_senior(r, dog) \
|
||||
__((u3a_to_off(dog) < r->mat_p) || \
|
||||
(u3a_to_off(dog) >= r->rut_p))
|
||||
|
||||
# define u3a_south_is_junior(r, dog) \
|
||||
__((u3a_to_off(dog) < r->cap_p) && \
|
||||
(u3a_to_off(dog) >= r->mat_p))
|
||||
|
||||
# define u3a_south_is_normal(r, dog) \
|
||||
c3a(!(u3a_south_is_senior(r, dog)), \
|
||||
!(u3a_south_is_junior(r, dog)))
|
||||
|
||||
# define u3a_is_junior(r, som) \
|
||||
( _(u3a_is_cat(som)) \
|
||||
? c3n \
|
||||
: _(u3a_is_north(r)) \
|
||||
? u3a_north_is_junior(r, som) \
|
||||
: u3a_south_is_junior(r, som) )
|
||||
|
||||
# define u3a_is_senior(r, som) \
|
||||
( _(u3a_is_cat(som)) \
|
||||
? c3y \
|
||||
: _(u3a_is_north(r)) \
|
||||
? u3a_north_is_senior(r, som) \
|
||||
: u3a_south_is_senior(r, som) )
|
||||
|
||||
/* Word axis macros. For 31-bit axes only.
|
||||
*/
|
||||
/* u3_ax_dep(): number of axis bits.
|
||||
*/
|
||||
# define u3_ax_dep(a_w) (c3_bits_word(a_w) - 1)
|
||||
|
||||
/* u3_ax_cap(): root axis, 2 or 3.
|
||||
*/
|
||||
# define u3_ax_cap(a_w) (0x2 | (a_w >> (u3_ax_dep(a_w) - 1)))
|
||||
|
||||
/* u3_ax_mas(): remainder after cap.
|
||||
*/
|
||||
# define u3_ax_mas(a_w) \
|
||||
( (a_w & ~(1 << u3_ax_dep(a_w))) | (1 << (u3_ax_dep(a_w) - 1)) )
|
||||
|
||||
/* u3_ax_peg(): connect two axes.
|
||||
*/
|
||||
# define u3_ax_peg(a_w, b_w) \
|
||||
( (a_w << u3_ax_dep(b_w)) | (b_w &~ (1 << u3_ax_dep(b_w))) )
|
||||
|
||||
/* Conventional axes for gate call.
|
||||
*/
|
||||
# define u3v_pay 3 // payload
|
||||
# define u3v_sam 6 // sample
|
||||
# define u3v_sam_1 6
|
||||
# define u3v_sam_2 12
|
||||
# define u3v_sam_3 13
|
||||
# define u3v_sam_4 24
|
||||
# define u3v_sam_5 25
|
||||
# define u3v_sam_6 26
|
||||
# define u3v_sam_12 52
|
||||
# define u3v_sam_13 53
|
||||
# define u3v_sam_7 27
|
||||
# define u3v_con 7 // context
|
||||
# define u3v_con_2 14 // context
|
||||
# define u3v_con_3 15 // context
|
||||
# define u3v_con_sam 30 // sample in gate context
|
||||
# define u3v_noc 2 // deprecated
|
||||
# define u3v_bat 2 // battery
|
||||
|
||||
|
||||
/** Globals.
|
||||
**/
|
||||
/* u3_Road / u3R: current road (thread-local).
|
||||
*/
|
||||
c3_global u3_road* u3_Road;
|
||||
# define u3R u3_Road
|
||||
|
||||
/* u3_Code: memory code.
|
||||
*/
|
||||
#ifdef U3_MEMORY_DEBUG
|
||||
c3_global c3_w u3_Code;
|
||||
#endif
|
||||
|
||||
# define u3_Loom ((c3_w *)(void *)U3_OS_LoomBase)
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Allocation.
|
||||
**/
|
||||
/* Basic allocation.
|
||||
*/
|
||||
/* u3a_walloc(): allocate storage measured in words.
|
||||
*/
|
||||
void*
|
||||
u3a_walloc(c3_w len_w);
|
||||
|
||||
/* u3a_malloc(): allocate storage measured in bytes.
|
||||
*/
|
||||
void*
|
||||
u3a_malloc(c3_w len_w);
|
||||
|
||||
/* u3a_free(): free storage.
|
||||
*/
|
||||
void
|
||||
u3a_free(void* lag_v);
|
||||
|
||||
/* u3a_wealloc(): word realloc.
|
||||
*/
|
||||
void*
|
||||
u3a_wealloc(void* lag_v, c3_w len_w);
|
||||
|
||||
/* u3a_realloc(): byte realloc.
|
||||
*/
|
||||
void*
|
||||
u3a_realloc(void* lag_v, c3_w len_w);
|
||||
|
||||
|
||||
/* Reference and arena control.
|
||||
*/
|
||||
/* u3a_gain(): gain a reference count in normal space.
|
||||
*/
|
||||
u3_weak
|
||||
u3a_gain(u3_weak som);
|
||||
|
||||
/* u3a_take(): gain, copying juniors.
|
||||
*/
|
||||
u3_noun
|
||||
u3a_take(u3_noun som);
|
||||
|
||||
/* u3a_left(): true of junior if preserved.
|
||||
*/
|
||||
c3_o
|
||||
u3a_left(u3_noun som);
|
||||
|
||||
/* u3a_lose(): lose a reference.
|
||||
*/
|
||||
void
|
||||
u3a_lose(u3_weak som);
|
||||
|
||||
/* u3a_wash(): wash all lazy mugs in subtree. RETAIN.
|
||||
*/
|
||||
void
|
||||
u3a_wash(u3_noun som);
|
||||
|
||||
/* u3a_use(): reference count.
|
||||
*/
|
||||
c3_w
|
||||
u3a_use(u3_noun som);
|
||||
|
||||
/* u3a_mark_ptr(): mark a pointer for gc. Produce size.
|
||||
*/
|
||||
c3_w
|
||||
u3a_mark_ptr(void* ptr_v);
|
||||
|
||||
/* u3a_mark_noun(): mark a noun for gc. Produce size.
|
||||
*/
|
||||
c3_w
|
||||
u3a_mark_noun(u3_noun som);
|
||||
|
||||
/* u3a_sweep(): sweep a fully marked road.
|
||||
*/
|
||||
void
|
||||
u3a_sweep(c3_c* cap_c);
|
||||
|
||||
/* u3a_sane(): check allocator sanity.
|
||||
*/
|
||||
void
|
||||
u3a_sane(void);
|
||||
|
||||
/* u3a_detect(): axis (som) is referenced from (fum).
|
||||
**
|
||||
** (som) and (fum) are both RETAINED.
|
||||
*/
|
||||
c3_d
|
||||
u3a_detect(u3_noun fum, u3_noun som);
|
||||
|
||||
/* u3a_lush(): leak push.
|
||||
*/
|
||||
c3_w
|
||||
u3a_lush(c3_w lab_w);
|
||||
|
||||
/* u3a_lop(): leak pop.
|
||||
*/
|
||||
void
|
||||
u3a_lop(c3_w lab_w);
|
||||
|
||||
/* u3a_print_memory: print memory amount.
|
||||
*/
|
||||
void
|
||||
u3a_print_memory(c3_c* cap_c, c3_w wor_w);
|
||||
|
||||
/* Atoms from proto-atoms.
|
||||
*/
|
||||
/* u3a_slab(): create a length-bounded proto-atom.
|
||||
*/
|
||||
c3_w*
|
||||
u3a_slab(c3_w len_w);
|
||||
|
||||
/* u3a_slaq(): u3a_slaq() with a defined blocksize.
|
||||
*/
|
||||
c3_w*
|
||||
u3a_slaq(c3_g met_g, c3_w len_w);
|
||||
|
||||
/* u3a_malt(): measure and finish a proto-atom.
|
||||
*/
|
||||
u3_noun
|
||||
u3a_malt(c3_w* sal_w);
|
||||
|
||||
/* u3a_moot(): finish a pre-measured proto-atom; dangerous.
|
||||
*/
|
||||
u3_noun
|
||||
u3a_moot(c3_w* sal_w);
|
||||
|
||||
/* u3a_mint(): finish a measured proto-atom.
|
||||
*/
|
||||
u3_noun
|
||||
u3a_mint(c3_w* sal_w, c3_w len_w);
|
||||
|
||||
|
90
i/n/e.h
Normal file
90
i/n/e.h
Normal file
@ -0,0 +1,90 @@
|
||||
/* include/g/e.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3e_line: control line.
|
||||
*/
|
||||
typedef struct _u3e_line {
|
||||
c3_w pag_w;
|
||||
c3_w mug_w;
|
||||
} u3e_line;
|
||||
|
||||
/* u3e_control: memory change, control file.
|
||||
*/
|
||||
typedef struct _u3e_control {
|
||||
c3_d evt_d; // event number
|
||||
c3_w nor_w; // new page count north
|
||||
c3_w sou_w; // new page count south
|
||||
c3_w pgs_w; // number of changed pages
|
||||
u3e_line mem_u[0]; // per page
|
||||
} u3e_control;
|
||||
|
||||
/* u3_cs_patch: memory change, top level.
|
||||
*/
|
||||
typedef struct _u3_cs_patch {
|
||||
c3_i ctl_i;
|
||||
c3_i mem_i;
|
||||
u3e_control* con_u;
|
||||
} u3_cs_patch;
|
||||
|
||||
/* u3e_image: memory segment, open file.
|
||||
*/
|
||||
typedef struct _u3e_image {
|
||||
c3_c* nam_c; // segment name
|
||||
c3_i fid_i; // open file, or 0
|
||||
c3_w pgs_w; // length in pages
|
||||
} u3e_image;
|
||||
|
||||
/* u3e_pool: entire memory system.
|
||||
*/
|
||||
typedef struct _u3e_pool {
|
||||
c3_c* cpu_c; // path to
|
||||
c3_d evt_d; // last patch written at event
|
||||
c3_w dit_w[u3a_pages >> 5]; // touched since last save
|
||||
u3e_image nor_u; // north segment
|
||||
u3e_image sou_u; // south segment
|
||||
} u3e_pool;
|
||||
|
||||
|
||||
/** Globals.
|
||||
**/
|
||||
/* u3_Pool / u3P: global memory control.
|
||||
*/
|
||||
c3_global u3e_pool u3_Pool;
|
||||
# define u3P u3_Pool
|
||||
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u3e_fault(): handle a memory event with libsigsegv protocol.
|
||||
*/
|
||||
c3_i
|
||||
u3e_fault(void* adr_v, c3_i ser_i);
|
||||
|
||||
/* u3e_save():
|
||||
*/
|
||||
void
|
||||
u3e_save(void);
|
||||
|
||||
/* u3e_boot(): start the memory system.
|
||||
*/
|
||||
void
|
||||
u3e_boot(c3_o nuu_o, c3_o bug_o, c3_c* cpu_c);
|
||||
|
||||
/* u3e_init(): start the environment, with/without checkpointing.
|
||||
*/
|
||||
void
|
||||
u3e_init(c3_o chk_o);
|
||||
|
||||
/* u3e_grab(): garbage-collect the world, plus extra roots.
|
||||
*/
|
||||
void
|
||||
u3e_grab(c3_c* cap_c, u3_noun som, ...); // terminate with u3_none
|
||||
|
||||
/* u3e_dirty(): count dirty pages.
|
||||
*/
|
||||
c3_w
|
||||
u3e_dirty(void);
|
||||
|
120
i/n/h.h
Normal file
120
i/n/h.h
Normal file
@ -0,0 +1,120 @@
|
||||
/* include/g/h.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/** Straightforward implementation of the classic Bagwell
|
||||
*** HAMT (hash array mapped trie), using a mug hash.
|
||||
***
|
||||
*** Because a mug is 31 bits, the root table is 64 wide.
|
||||
*** Thereupon 5 bits each are warm for each layer. The
|
||||
*** final leaf is simply a linear search.
|
||||
***
|
||||
*** We store an extra "freshly warm" bit for a simple
|
||||
*** clock-algorithm reclamation policy, not yet implemented.
|
||||
*** Search "clock algorithm" to figure it out.
|
||||
**/
|
||||
/* u3h_slot: map slot.
|
||||
**
|
||||
** Either a key-value cell or a loom offset, decoded as a pointer
|
||||
** to a u3h_node. Matches the u3_noun format - coordinate with
|
||||
** meme.h. The top two bits are:
|
||||
**
|
||||
** 00 - empty (in the root table only)
|
||||
** 01 - table
|
||||
** 02 - entry, stale
|
||||
** 03 - entry, fresh
|
||||
*/
|
||||
typedef c3_w u3h_slot;
|
||||
|
||||
/* u3h_node: map node.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w map_w;
|
||||
u3h_slot sot_w[0];
|
||||
} u3h_node;
|
||||
|
||||
/* u3h_root: hash root table, with future-proof clock.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w clk_w;
|
||||
u3h_slot sot_w[64];
|
||||
} u3h_root;
|
||||
|
||||
/* u3h_buck: bottom bucket.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w len_w;
|
||||
u3_noun kev[0];
|
||||
} u3h_buck;
|
||||
|
||||
/** HAMT macros.
|
||||
***
|
||||
*** Coordinate with u3_noun definition!
|
||||
**/
|
||||
/* u3h_slot_is_null(): yes iff slot is empty
|
||||
** u3h_slot_is_noun(): yes iff slot contains a key/value cell
|
||||
** u3h_slot_is_node(): yes iff slot contains a subtable/bucket
|
||||
** u3h_slot_is_warm(): yes iff fresh bit is set
|
||||
** u3h_slot_to_node(): slot to node pointer
|
||||
** u3h_node_to_slot(): node pointer to slot
|
||||
** u3h_slot_to_noun(): slot to cell
|
||||
** u3h_noun_to_slot(): cell to slot
|
||||
*/
|
||||
# define u3h_slot_is_null(sot) ((0 == ((sot) >> 30)) ? c3y : c3n)
|
||||
# define u3h_slot_is_node(sot) ((1 == ((sot) >> 30)) ? c3y : c3n)
|
||||
# define u3h_slot_is_noun(sot) ((1 == ((sot) >> 31)) ? c3y : c3n)
|
||||
# define u3h_slot_is_warm(sot) (((sot) & 0x40000000) ? c3y : c3n)
|
||||
# define u3h_slot_to_node(sot) (u3a_into((sot) & 0x3fffffff))
|
||||
# define u3h_node_to_slot(ptr) (u3a_outa(ptr) | 0x40000000)
|
||||
# define u3h_slot_to_noun(sot) (0x40000000 | (sot))
|
||||
# define u3h_noun_to_slot(som) (som)
|
||||
# define u3h_noun_be_warm(sot) ((sot) | 0x40000000)
|
||||
# define u3h_noun_be_cold(sot) ((sot) & ~0x40000000)
|
||||
|
||||
|
||||
/** Functions.
|
||||
***
|
||||
*** Needs: delete and merge functions; clock reclamation function.
|
||||
**/
|
||||
/* u3h_new(): create hashtable.
|
||||
*/
|
||||
u3p(u3h_root)
|
||||
u3h_new(void);
|
||||
|
||||
/* u3h_put(): insert in hashtable.
|
||||
**
|
||||
** `key` is RETAINED; `val` is transferred.
|
||||
*/
|
||||
void
|
||||
u3h_put(u3p(u3h_root) har_p, u3_noun key, u3_noun val);
|
||||
|
||||
/* u3h_get(): read from hashtable.
|
||||
**
|
||||
** `key` is RETAINED.
|
||||
*/
|
||||
u3_weak
|
||||
u3h_get(u3p(u3h_root) har_p, u3_noun key);
|
||||
|
||||
/* u3h_gut(): read from hashtable, unifying key nouns.
|
||||
**
|
||||
** `key` is RETAINED.
|
||||
*/
|
||||
u3_weak
|
||||
u3h_gut(u3p(u3h_root) har_p, u3_noun key);
|
||||
|
||||
/* u3h_free(): free hashtable.
|
||||
*/
|
||||
void
|
||||
u3h_free(u3p(u3h_root) har_p);
|
||||
|
||||
/* u3h_mark(): mark hashtable for gc.
|
||||
*/
|
||||
void
|
||||
u3h_mark(u3p(u3h_root) har_p);
|
||||
|
||||
/* u3h_walk(): traverse hashtable with key, value fn; RETAINS.
|
||||
*/
|
||||
void
|
||||
u3h_walk(u3p(u3h_root) har_p, void (*fun_f)(u3_noun));
|
@ -4,83 +4,83 @@
|
||||
*/
|
||||
/* General constructors.
|
||||
*/
|
||||
/* u3_ci_words():
|
||||
/* u3i_words():
|
||||
**
|
||||
** Copy [a] words from [b] into an atom.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_words(c3_w a_w,
|
||||
u3i_words(c3_w a_w,
|
||||
const c3_w* b_w);
|
||||
|
||||
/* u3_ci_bytes():
|
||||
/* u3i_bytes():
|
||||
**
|
||||
** Copy `a` bytes from `b` to an LSB first atom.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_bytes(c3_w a_w,
|
||||
u3i_bytes(c3_w a_w,
|
||||
const c3_y* b_y);
|
||||
|
||||
/* u3_ci_mp():
|
||||
/* u3i_mp():
|
||||
**
|
||||
** Copy the GMP integer `a` into an atom, and clear it.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_mp(mpz_t a_mp);
|
||||
u3i_mp(mpz_t a_mp);
|
||||
|
||||
/* u3_ci_vint():
|
||||
/* u3i_vint():
|
||||
**
|
||||
** Create `a + 1`.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_vint(u3_noun a);
|
||||
u3i_vint(u3_noun a);
|
||||
|
||||
/* u3_ci_cell():
|
||||
/* u3i_cell():
|
||||
**
|
||||
** Produce the cell `[a b]`.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_cell(u3_noun a, u3_noun b);
|
||||
u3i_cell(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ci_trel():
|
||||
/* u3i_trel():
|
||||
**
|
||||
** Produce the triple `[a b c]`.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_trel(u3_noun a, u3_noun b, u3_noun c);
|
||||
u3i_trel(u3_noun a, u3_noun b, u3_noun c);
|
||||
|
||||
/* u3_ci_qual():
|
||||
/* u3i_qual():
|
||||
**
|
||||
** Produce the cell `[a b c d]`.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_qual(u3_noun a, u3_noun b, u3_noun c, u3_noun d);
|
||||
u3i_qual(u3_noun a, u3_noun b, u3_noun c, u3_noun d);
|
||||
|
||||
/* u3_ci_string():
|
||||
/* u3i_string():
|
||||
**
|
||||
** Produce an LSB-first atom from the C string `a`.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_string(const c3_c* a_c);
|
||||
u3i_string(const c3_c* a_c);
|
||||
|
||||
/* u3_ci_molt():
|
||||
/* u3i_molt():
|
||||
**
|
||||
** Mutate `som` with a 0-terminated list of axis, noun pairs.
|
||||
** Axes must be cats (31 bit).
|
||||
*/
|
||||
u3_noun
|
||||
u3_ci_molt(u3_noun som, ...);
|
||||
u3i_molt(u3_noun som, ...);
|
||||
|
||||
/* u3_ci_chubs():
|
||||
/* u3i_chubs():
|
||||
**
|
||||
** Construct `a` double-words from `b`, LSD first, as an atom.
|
||||
*/
|
||||
u3_atom
|
||||
u3_ci_chubs(c3_w a_w,
|
||||
u3i_chubs(c3_w a_w,
|
||||
const c3_d* b_d);
|
||||
|
||||
/* u3_ci_tape(): from a C string, to a list of bytes.
|
||||
/* u3i_tape(): from a C string, to a list of bytes.
|
||||
*/
|
||||
u3_atom
|
||||
u3_ci_tape(const c3_c* txt_c);
|
||||
u3i_tape(const c3_c* txt_c);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/* include/f/jets.h
|
||||
/* include/g/j.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Noun structures.
|
||||
/** Noun semantics.
|
||||
**/
|
||||
#if 0
|
||||
++ bane ,@tas :: battery name
|
||||
@ -57,39 +57,114 @@
|
||||
==
|
||||
--
|
||||
#endif
|
||||
|
||||
/** Data structures.
|
||||
***
|
||||
*** All of these are transient structures allocated with malloc.
|
||||
**/
|
||||
/* u3_cs_harm: jet arm.
|
||||
/* u3e_harm: jet arm.
|
||||
*/
|
||||
typedef struct _u3_cs_harm {
|
||||
typedef struct _u3e_harm {
|
||||
c3_c* fcs_c; // `.axe` or name
|
||||
u3_noun (*fun_f)(u3_noun); // compute or 0 / semitransfer
|
||||
// u3_bean (*val_f)(u3_noun); // validate or 0 / retain
|
||||
// c3_o (*val_f)(u3_noun); // validate or 0 / retain
|
||||
c3_o ice; // perfect (don't test)
|
||||
c3_o tot; // total (never punts)
|
||||
c3_o liv; // live (enabled)
|
||||
c3_l axe_l; // computed/discovered axis
|
||||
struct _u3_cs_core* cop_u; // containing core
|
||||
} u3_cs_harm;
|
||||
struct _u3e_core* cop_u; // containing core
|
||||
} u3e_harm;
|
||||
|
||||
/* u3_cs_core: driver definition.
|
||||
/* u3e_core: driver definition.
|
||||
*/
|
||||
typedef struct _u3_cs_core {
|
||||
typedef struct _u3e_core {
|
||||
c3_c* cos_c; // control string
|
||||
struct _u3_cs_harm* arm_u; // blank-terminated static list
|
||||
struct _u3_cs_core* dev_u; // blank-terminated static list
|
||||
struct _u3_cs_core* par_u; // dynamic parent pointer
|
||||
struct _u3e_harm* arm_u; // blank-terminated static list
|
||||
struct _u3e_core* dev_u; // blank-terminated static list
|
||||
struct _u3e_core* par_u; // dynamic parent pointer
|
||||
c3_l axe_l; // axis to parent
|
||||
c3_l jax_l; // index in global dashboard
|
||||
} u3_cs_core;
|
||||
} u3e_core;
|
||||
|
||||
/* u3_cs_dash, u3_Dash, u3D: jet dashboard singleton
|
||||
/* u3e_dash, u3_Dash, u3D: jet dashboard singleton
|
||||
*/
|
||||
typedef struct _u3_cs_dash {
|
||||
u3_cs_core* dev_u; // null-terminated static list
|
||||
typedef struct _u3e_dash {
|
||||
u3e_core* dev_u; // null-terminated static list
|
||||
c3_l len_l; // dynamic array length
|
||||
c3_l all_l; // allocated length
|
||||
u3_cs_core* ray_u; // dynamic array by axis
|
||||
} u3_cs_dash;
|
||||
u3e_core* ray_u; // dynamic array by axis
|
||||
} u3e_dash;
|
||||
|
||||
/** Globals.
|
||||
**/
|
||||
/* u3_Dash: jet dashboard.
|
||||
*/
|
||||
extern u3e_dash u3_Dash;
|
||||
# define u3D u3_Dash
|
||||
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u3j_boot(): initialize jet system.
|
||||
*/
|
||||
void
|
||||
u3j_boot(void);
|
||||
|
||||
/* u3j_clear(): clear jet table to re-register.
|
||||
*/
|
||||
void
|
||||
u3j_clear(void);
|
||||
|
||||
/* u3j_hook():
|
||||
**
|
||||
** Execute hook from core.
|
||||
*/
|
||||
u3_noun
|
||||
u3j_hook(u3_noun cor,
|
||||
const c3_c* tam_c);
|
||||
|
||||
/* u3j_soft():
|
||||
**
|
||||
** Execute hook from core, without jet.
|
||||
*/
|
||||
u3_noun
|
||||
u3j_soft(u3_noun cor,
|
||||
const c3_c* tam_c);
|
||||
|
||||
/* u3j_find(): battery to driver number, or 0.
|
||||
**
|
||||
** `bat` is RETAINED by the caller.
|
||||
*/
|
||||
c3_l
|
||||
u3j_find(u3_noun bat);
|
||||
|
||||
/* u3j_kick(): try to kick by jet. If no kick, produce u3_none.
|
||||
**
|
||||
** `axe` is RETAINED by the caller; `cor` is RETAINED iff there
|
||||
** is no kick, TRANSFERRED if one.
|
||||
*/
|
||||
u3_weak
|
||||
u3j_kick(u3_noun cor,
|
||||
u3_noun axe);
|
||||
|
||||
/* u3j_kink(): kick either by jet or by nock.
|
||||
*/
|
||||
u3_noun
|
||||
u3j_kink(u3_noun cor,
|
||||
u3_noun axe);
|
||||
|
||||
/* u3j_mine(): register core for jets.
|
||||
*/
|
||||
void
|
||||
u3j_mine(u3_noun clu,
|
||||
u3_noun cor);
|
||||
|
||||
/* u3j_ream(): refresh after restoring from checkpoint.
|
||||
*/
|
||||
void
|
||||
u3j_ream(void);
|
||||
|
||||
/* u3j_reap(): promote jet state. RETAINS.
|
||||
*/
|
||||
void
|
||||
u3j_reap(u3_noun das, u3p(u3h_root) har_p);
|
173
i/n/m.h
Normal file
173
i/n/m.h
Normal file
@ -0,0 +1,173 @@
|
||||
/* include/g/m.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** System management.
|
||||
**/
|
||||
/* u3m_boot(): set up top-level road.
|
||||
*/
|
||||
void
|
||||
u3m_boot(c3_o nuu_o, c3_o bug_o);
|
||||
|
||||
/* u3m_trap(): setjmp within road.
|
||||
*/
|
||||
#if 0
|
||||
c3_o
|
||||
u3m_trap(void);
|
||||
#else
|
||||
# define u3m_trap() (u3_noun)(setjmp(u3R->esc.buf))
|
||||
#endif
|
||||
|
||||
/* u3m_signal(): treat a nock-level exception as a signal interrupt.
|
||||
*/
|
||||
void
|
||||
u3m_signal(u3_noun sig_l);
|
||||
|
||||
/* u3m_bail(): bail out. Does not return.
|
||||
**
|
||||
** Bail motes:
|
||||
**
|
||||
** %exit :: semantic failure
|
||||
** %evil :: bad crypto
|
||||
** %intr :: interrupt
|
||||
** %fail :: execution failure
|
||||
** %foul :: assert failure
|
||||
** %need :: network block
|
||||
** %meme :: out of memory
|
||||
*/
|
||||
c3_i
|
||||
u3m_bail(c3_m how_m);
|
||||
|
||||
/* u3m_dump(): dump the current road to stderr.
|
||||
*/
|
||||
void
|
||||
u3m_dump(void);
|
||||
|
||||
/* u3m_file(): load file, as atom, or bail.
|
||||
*/
|
||||
u3_noun
|
||||
u3m_file(c3_c* pas_c);
|
||||
|
||||
/* u3m_clear(): clear all allocated data in road.
|
||||
*/
|
||||
void
|
||||
u3m_clear(void);
|
||||
|
||||
/* u3m_mark(): mark all nouns in the road.
|
||||
*/
|
||||
void
|
||||
u3m_mark(void);
|
||||
|
||||
/* u3m_error(): bail out with %exit, ct_pushing error.
|
||||
*/
|
||||
c3_i
|
||||
u3m_error(c3_c* str_c);
|
||||
|
||||
/* u3m_check(): checkpoint memory to file. Asserts u3R == u3H.
|
||||
*/
|
||||
void
|
||||
u3m_check(void);
|
||||
|
||||
/* u3m_fall(): return to parent road.
|
||||
*/
|
||||
void
|
||||
u3m_fall(void);
|
||||
|
||||
/* u3m_hate(): new, integrated leap mechanism (enter).
|
||||
*/
|
||||
void
|
||||
u3m_hate(c3_w pad_w);
|
||||
|
||||
/* u3m_love(): return product from leap.
|
||||
*/
|
||||
u3_noun
|
||||
u3m_love(u3_noun pro);
|
||||
|
||||
/* u3m_leap(): in u3R, create a new road within the existing one.
|
||||
*/
|
||||
void
|
||||
u3m_leap(c3_w pad_w);
|
||||
|
||||
/* u3m_golf(): record cap length for u3_flog().
|
||||
*/
|
||||
c3_w
|
||||
u3m_golf(void);
|
||||
|
||||
/* u3m_flog(): pop the cap.
|
||||
**
|
||||
** A common sequence for inner allocation is:
|
||||
**
|
||||
** c3_w gof_w = u3m_golf();
|
||||
** u3m_leap();
|
||||
** // allocate some inner stuff...
|
||||
** u3m_fall();
|
||||
** // inner stuff is still valid, but on cap
|
||||
** u3m_flog(gof_w);
|
||||
**
|
||||
** u3m_flog(0) simply clears the cap.
|
||||
*/
|
||||
void
|
||||
u3m_flog(c3_w gof_w);
|
||||
|
||||
/* u3m_soft(): system soft wrapper. unifies unix and nock errors.
|
||||
**
|
||||
** Produces [%$ result] or [%error (list tank)].
|
||||
*/
|
||||
u3_noun
|
||||
u3m_soft(c3_w sec_w, u3_funk fun_f, u3_noun arg);
|
||||
|
||||
/* u3m_soft_top(): top-level safety wrapper.
|
||||
*/
|
||||
u3_noun
|
||||
u3m_soft_top(c3_w sec_w, // timer seconds
|
||||
c3_w pad_w, // base memory pad
|
||||
u3_funk fun_f,
|
||||
u3_noun arg);
|
||||
|
||||
/* u3m_soft_slam: top-level call.
|
||||
*/
|
||||
u3_noun
|
||||
u3m_soft_slam(u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3m_soft_sure(): top-level call assumed correct.
|
||||
*/
|
||||
u3_noun
|
||||
u3m_soft_sure(u3_funk fun_f, u3_noun arg);
|
||||
|
||||
/* u3m_soft_run(): descend into virtualization context.
|
||||
*/
|
||||
u3_noun
|
||||
u3m_soft_run(u3_noun fly,
|
||||
u3_funq fun_f,
|
||||
u3_noun aga,
|
||||
u3_noun agb);
|
||||
|
||||
/* u3m_soft_esc(): namespace lookup to (unit ,*).
|
||||
*/
|
||||
u3_noun
|
||||
u3m_soft_esc(u3_noun sam);
|
||||
|
||||
/* u3m_water(): produce high and low watermarks. Asserts u3R == u3H.
|
||||
*/
|
||||
void
|
||||
u3m_water(c3_w *low_w, c3_w *hig_w);
|
||||
|
||||
/* u3m_pretty(): dumb prettyprint to string. RETAIN.
|
||||
*/
|
||||
c3_c*
|
||||
u3m_pretty(u3_noun som);
|
||||
|
||||
/* u3m_p(): dumb print with caption. RETAIN.
|
||||
*/
|
||||
void
|
||||
u3m_p(const c3_c* cap_c, u3_noun som);
|
||||
|
||||
/* u3m_tape(): dump a tape to stdout.
|
||||
*/
|
||||
void
|
||||
u3m_tape(u3_noun tep);
|
||||
|
||||
/* u3m_wall(): dump a wall to stdout.
|
||||
*/
|
||||
void
|
||||
u3m_wall(u3_noun wol);
|
45
i/n/n.h
Normal file
45
i/n/n.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* include/g/n.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Functions.
|
||||
**/
|
||||
/* u3n_nock_on(): produce .*(bus fol).
|
||||
*/
|
||||
u3_noun
|
||||
u3n_nock_on(u3_noun bus, u3_noun fol);
|
||||
|
||||
/* u3n_slam_on(): produce (gat sam).
|
||||
*/
|
||||
u3_noun
|
||||
u3n_slam_on(u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3n_kick_on(): fire `gat` without changing the sample.
|
||||
*/
|
||||
u3_noun
|
||||
u3n_kick_on(u3_noun gat);
|
||||
|
||||
/* u3n_nock_un(): produce .*(bus fol), as ++toon.
|
||||
*/
|
||||
u3_noun
|
||||
u3n_nock_un(u3_noun bus, u3_noun fol);
|
||||
|
||||
/* u3n_slam_un(): produce (gat sam), as ++toon.
|
||||
*/
|
||||
u3_noun
|
||||
u3n_slam_un(u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3n_nock_in(): produce .*(bus fol), as ++toon, in namespace.
|
||||
*/
|
||||
u3_noun
|
||||
u3n_nock_in(u3_noun fly, u3_noun bus, u3_noun fol);
|
||||
|
||||
/* u3n_slam_in(): produce (gat sam), as ++toon, in namespace.
|
||||
*/
|
||||
u3_noun
|
||||
u3n_slam_in(u3_noun fly, u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3n_nock_an(): as slam_in(), but with empty fly.
|
||||
*/
|
||||
u3_noun
|
||||
u3n_nock_an(u3_noun bus, u3_noun fol);
|
@ -2,318 +2,318 @@
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** u3_cr_*: read without ever crashing.
|
||||
/** u3r_*: read without ever crashing.
|
||||
**/
|
||||
#if 1
|
||||
# define u3_cr_du(a) u3_co_is_cell(a)
|
||||
# define u3_cr_ud(a) u3_co_is_atom(a)
|
||||
# define u3r_du(a) u3a_is_cell(a)
|
||||
# define u3r_ud(a) u3a_is_atom(a)
|
||||
#else
|
||||
/* u3_cr_du(): u3_yes iff `a` is cell.
|
||||
/* u3r_du(): c3y iff `a` is cell.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_du(u3_noun a);
|
||||
c3_o
|
||||
u3r_du(u3_noun a);
|
||||
|
||||
/* u3_cr_ud(): u3_no iff `a` is cell.
|
||||
/* u3r_ud(): c3n iff `a` is cell.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_ud(u3_noun a);
|
||||
c3_o
|
||||
u3r_ud(u3_noun a);
|
||||
#endif
|
||||
|
||||
/* u3_cr_at(): fragment `a` of `b`, or u3_none.
|
||||
/* u3r_at(): fragment `a` of `b`, or u3_none.
|
||||
*/
|
||||
u3_weak
|
||||
u3_cr_at(u3_atom a,
|
||||
u3r_at(u3_atom a,
|
||||
u3_weak b);
|
||||
|
||||
/* u3_cr_mean():
|
||||
/* u3r_mean():
|
||||
**
|
||||
** Attempt to deconstruct `a` by axis, noun pairs; 0 terminates.
|
||||
** Axes must be sorted in tree order.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_mean(u3_noun a,
|
||||
c3_o
|
||||
u3r_mean(u3_noun a,
|
||||
...);
|
||||
|
||||
/* u3_cr_mug():
|
||||
/* u3r_mug():
|
||||
**
|
||||
** Compute and/or recall the mug (31-bit hash) of (a).
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_mug(u3_noun a);
|
||||
u3r_mug(u3_noun a);
|
||||
|
||||
/* u3_cr_mug_string():
|
||||
/* u3r_mug_string():
|
||||
**
|
||||
** Compute the mug of `a`, LSB first.
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_mug_string(const c3_c *a_c);
|
||||
u3r_mug_string(const c3_c *a_c);
|
||||
|
||||
/* u3_cr_mug_words():
|
||||
/* u3r_mug_words():
|
||||
**
|
||||
** Compute the mug of `buf`, `len`, LSW first.
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_mug_words(const c3_w *buf_w,
|
||||
u3r_mug_words(const c3_w *buf_w,
|
||||
c3_w len_w);
|
||||
|
||||
/* u3_cr_mug_cell():
|
||||
/* u3r_mug_cell():
|
||||
**
|
||||
** Compute the mug of `[a b]`.
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_mug_cell(u3_noun a,
|
||||
u3r_mug_cell(u3_noun a,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_mug_trel():
|
||||
/* u3r_mug_trel():
|
||||
**
|
||||
** Compute the mug of `[a b c]`.
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_mug_trel(u3_noun a,
|
||||
u3r_mug_trel(u3_noun a,
|
||||
u3_noun b,
|
||||
u3_noun c);
|
||||
|
||||
/* u3_cr_mug_qual():
|
||||
/* u3r_mug_qual():
|
||||
**
|
||||
** Compute the mug of `[a b c d]`.
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_mug_qual(u3_noun a,
|
||||
u3r_mug_qual(u3_noun a,
|
||||
u3_noun b,
|
||||
u3_noun c,
|
||||
u3_noun d);
|
||||
|
||||
/* u3_cr_mug_both():
|
||||
/* u3r_mug_both():
|
||||
**
|
||||
** Join two mugs.
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_mug_both(c3_w a_w,
|
||||
u3r_mug_both(c3_w a_w,
|
||||
c3_w b_w);
|
||||
|
||||
/* u3_cr_fing():
|
||||
/* u3r_fing():
|
||||
**
|
||||
** Yes iff (a) and (b) are the same copy of the same noun.
|
||||
** (Ie, by pointer equality - u3_cr_sing with false negatives.)
|
||||
** (Ie, by pointer equality - u3r_sing with false negatives.)
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_fing(u3_noun a,
|
||||
c3_o
|
||||
u3r_fing(u3_noun a,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_fing_cell():
|
||||
/* u3r_fing_cell():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_fing_cell(u3_noun p,
|
||||
c3_o
|
||||
u3r_fing_cell(u3_noun p,
|
||||
u3_noun q,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_fing_mixt():
|
||||
/* u3r_fing_mixt():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_fing_mixt(const c3_c* p_c,
|
||||
c3_o
|
||||
u3r_fing_mixt(const c3_c* p_c,
|
||||
u3_noun q,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_fing_trel():
|
||||
/* u3r_fing_trel():
|
||||
**
|
||||
** Yes iff `[p q r]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_fing_trel(u3_noun p,
|
||||
c3_o
|
||||
u3r_fing_trel(u3_noun p,
|
||||
u3_noun q,
|
||||
u3_noun r,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_fing_qual():
|
||||
/* u3r_fing_qual():
|
||||
**
|
||||
** Yes iff `[p q r s]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_fing_qual(u3_noun p,
|
||||
c3_o
|
||||
u3r_fing_qual(u3_noun p,
|
||||
u3_noun q,
|
||||
u3_noun r,
|
||||
u3_noun s,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_sing():
|
||||
/* u3r_sing():
|
||||
**
|
||||
** Yes iff (a) and (b) are the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_sing(u3_noun a,
|
||||
c3_o
|
||||
u3r_sing(u3_noun a,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_sung(): yes iff (a) and (b) are the same noun, unifying equals.
|
||||
/* u3r_sung(): yes iff (a) and (b) are the same noun, unifying equals.
|
||||
**
|
||||
** Make sure you have no live, uncounted pointers to any noun
|
||||
** within (a) or (b)!
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_sung(u3_noun a,
|
||||
c3_o
|
||||
u3r_sung(u3_noun a,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_sing_c):
|
||||
/* u3r_sing_c):
|
||||
**
|
||||
** Yes iff (b) is the same noun as the C string [a].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_sing_c(const c3_c* a_c,
|
||||
c3_o
|
||||
u3r_sing_c(const c3_c* a_c,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_sing_cell():
|
||||
/* u3r_sing_cell():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_sing_cell(u3_noun p,
|
||||
c3_o
|
||||
u3r_sing_cell(u3_noun p,
|
||||
u3_noun q,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_sing_mixt():
|
||||
/* u3r_sing_mixt():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_sing_mixt(const c3_c* p_c,
|
||||
c3_o
|
||||
u3r_sing_mixt(const c3_c* p_c,
|
||||
u3_noun q,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_sing_trel():
|
||||
/* u3r_sing_trel():
|
||||
**
|
||||
** Yes iff `[p q r]` and `b` are the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_sing_trel(u3_noun p,
|
||||
c3_o
|
||||
u3r_sing_trel(u3_noun p,
|
||||
u3_noun q,
|
||||
u3_noun r,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_sing_qual():
|
||||
/* u3r_sing_qual():
|
||||
**
|
||||
** Yes iff `[p q r s]` and `b` are the same noun.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_sing_qual(u3_noun p,
|
||||
c3_o
|
||||
u3r_sing_qual(u3_noun p,
|
||||
u3_noun q,
|
||||
u3_noun r,
|
||||
u3_noun s,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_nord():
|
||||
/* u3r_nord():
|
||||
**
|
||||
** Return 0, 1 or 2 if `a` is below, equal to, or above `b`.
|
||||
*/
|
||||
u3_atom
|
||||
u3_cr_nord(u3_noun a,
|
||||
u3r_nord(u3_noun a,
|
||||
u3_noun b);
|
||||
|
||||
/* u3_cr_mold():
|
||||
/* u3r_mold():
|
||||
**
|
||||
** Divide `a` as a mold `[b.[p q] c]`.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_mold(u3_noun a,
|
||||
c3_o
|
||||
u3r_mold(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c);
|
||||
|
||||
/* u3_cr_cell():
|
||||
/* u3r_cell():
|
||||
**
|
||||
** Divide `a` as a cell `[b c]`.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_cell(u3_noun a,
|
||||
c3_o
|
||||
u3r_cell(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c);
|
||||
|
||||
/* u3_cr_trel():
|
||||
/* u3r_trel():
|
||||
**
|
||||
** Divide `a` as a trel `[b c]`.
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_trel(u3_noun a,
|
||||
c3_o
|
||||
u3r_trel(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c,
|
||||
u3_noun* d);
|
||||
|
||||
/* u3_cr_qual():
|
||||
/* u3r_qual():
|
||||
**
|
||||
** Divide (a) as a qual [b c d e f].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_qual(u3_noun a,
|
||||
c3_o
|
||||
u3r_qual(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c,
|
||||
u3_noun* d,
|
||||
u3_noun* e);
|
||||
|
||||
/* u3_cr_quil():
|
||||
/* u3r_quil():
|
||||
**
|
||||
** Divide (a) as a quil [b c d e f].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_quil(u3_noun a,
|
||||
c3_o
|
||||
u3r_quil(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c,
|
||||
u3_noun* d,
|
||||
u3_noun* e,
|
||||
u3_noun* f);
|
||||
|
||||
/* u3_cr_p():
|
||||
/* u3r_p():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_p(u3_noun a,
|
||||
c3_o
|
||||
u3r_p(u3_noun a,
|
||||
u3_noun b,
|
||||
u3_noun* c);
|
||||
|
||||
/* u3_cr_bush():
|
||||
/* u3r_bush():
|
||||
**
|
||||
** Factor [a] as a bush [b.[p q] c].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_bush(u3_noun a,
|
||||
c3_o
|
||||
u3r_bush(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c);
|
||||
|
||||
/* u3_cr_pq():
|
||||
/* u3r_pq():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c d].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_pq(u3_noun a,
|
||||
c3_o
|
||||
u3r_pq(u3_noun a,
|
||||
u3_noun b,
|
||||
u3_noun* c,
|
||||
u3_noun* d);
|
||||
|
||||
/* u3_cr_pqr():
|
||||
/* u3r_pqr():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c *d *e].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_pqr(u3_noun a,
|
||||
c3_o
|
||||
u3r_pqr(u3_noun a,
|
||||
u3_noun b,
|
||||
u3_noun* c,
|
||||
u3_noun* d,
|
||||
u3_noun* e);
|
||||
|
||||
/* u3_cr_pqrs():
|
||||
/* u3r_pqrs():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c *d *e *f].
|
||||
*/
|
||||
u3_bean
|
||||
u3_cr_pqrs(u3_noun a,
|
||||
c3_o
|
||||
u3r_pqrs(u3_noun a,
|
||||
u3_noun b,
|
||||
u3_noun* c,
|
||||
u3_noun* d,
|
||||
u3_noun* e,
|
||||
u3_noun* f);
|
||||
|
||||
/* u3_cr_met():
|
||||
/* u3r_met():
|
||||
**
|
||||
** Return the size of (b) in bits, rounded up to
|
||||
** (1 << a_y).
|
||||
@ -321,89 +321,89 @@
|
||||
** For example, (a_y == 3) returns the size in bytes.
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_met(c3_y a_y,
|
||||
u3r_met(c3_y a_y,
|
||||
u3_atom b);
|
||||
|
||||
/* u3_cr_bit():
|
||||
/* u3r_bit():
|
||||
**
|
||||
** Return bit (a_w) of (b).
|
||||
*/
|
||||
c3_b
|
||||
u3_cr_bit(c3_w a_w,
|
||||
u3r_bit(c3_w a_w,
|
||||
u3_atom b);
|
||||
|
||||
/* u3_cr_byte():
|
||||
/* u3r_byte():
|
||||
**
|
||||
** Return byte (a_w) of (b).
|
||||
*/
|
||||
c3_y
|
||||
u3_cr_byte(c3_w a_w,
|
||||
u3r_byte(c3_w a_w,
|
||||
u3_atom b);
|
||||
|
||||
/* u3_cr_bytes():
|
||||
/* u3r_bytes():
|
||||
**
|
||||
** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c).
|
||||
*/
|
||||
void
|
||||
u3_cr_bytes(c3_w a_w,
|
||||
u3r_bytes(c3_w a_w,
|
||||
c3_w b_w,
|
||||
c3_y* c_y,
|
||||
u3_atom d);
|
||||
|
||||
/* u3_cr_chop():
|
||||
/* u3r_chop():
|
||||
**
|
||||
** Into the bloq space of `met`, from position `fum` for a
|
||||
** span of `wid`, to position `tou`, XOR from atom `src`
|
||||
** into ray `dst`.
|
||||
*/
|
||||
void
|
||||
u3_cr_chop(c3_g met_g,
|
||||
u3r_chop(c3_g met_g,
|
||||
c3_w fum_w,
|
||||
c3_w wid_w,
|
||||
c3_w tou_w,
|
||||
c3_w* dst_w,
|
||||
u3_atom src);
|
||||
|
||||
/* u3_cr_mp():
|
||||
/* u3r_mp():
|
||||
**
|
||||
** Copy (b) into (a_mp).
|
||||
*/
|
||||
void
|
||||
u3_cr_mp(mpz_t a_mp,
|
||||
u3r_mp(mpz_t a_mp,
|
||||
u3_atom b);
|
||||
|
||||
/* u3_cr_word():
|
||||
/* u3r_word():
|
||||
**
|
||||
** Return word (a_w) of (b).
|
||||
*/
|
||||
c3_w
|
||||
u3_cr_word(c3_w a_w,
|
||||
u3r_word(c3_w a_w,
|
||||
u3_atom b);
|
||||
|
||||
/* u3_cr_chub():
|
||||
/* u3r_chub():
|
||||
**
|
||||
** Return double-word (a_w) of (b).
|
||||
*/
|
||||
c3_d
|
||||
u3_cr_chub(c3_w a_w,
|
||||
u3r_chub(c3_w a_w,
|
||||
u3_atom b);
|
||||
|
||||
/* u3_cr_words():
|
||||
/* u3r_words():
|
||||
**
|
||||
** Copy words (a_w) through (a_w + b_w - 1) from (d) to (c).
|
||||
*/
|
||||
void
|
||||
u3_cr_words(c3_w a_w,
|
||||
u3r_words(c3_w a_w,
|
||||
c3_w b_w,
|
||||
c3_w* c_w,
|
||||
u3_atom d);
|
||||
|
||||
/* u3_cr_string(): `a`, a text atom, as malloced C string.
|
||||
/* u3r_string(): `a`, a text atom, as malloced C string.
|
||||
*/
|
||||
c3_c*
|
||||
u3_cr_string(u3_atom a);
|
||||
u3r_string(u3_atom a);
|
||||
|
||||
/* u3_cr_tape(): `a`, a list of bytes, as malloced C string.
|
||||
/* u3r_tape(): `a`, a list of bytes, as malloced C string.
|
||||
*/
|
||||
c3_y*
|
||||
u3_cr_tape(u3_noun a);
|
||||
u3r_tape(u3_noun a);
|
60
i/n/t.h
Normal file
60
i/n/t.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* include/g/t.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tracing.
|
||||
**/
|
||||
/* u3t_push(): push on trace stack.
|
||||
*/
|
||||
void
|
||||
u3t_push(u3_noun mon);
|
||||
|
||||
/* u3t_mean(): push `[%mean roc]` on trace stack.
|
||||
*/
|
||||
void
|
||||
u3t_mean(u3_noun roc);
|
||||
|
||||
/* u3t_drop(): drop from meaning stack.
|
||||
*/
|
||||
void
|
||||
u3t_drop(void);
|
||||
|
||||
/* u3t_slog(): print directly.
|
||||
*/
|
||||
void
|
||||
u3t_slog(u3_noun hod);
|
||||
|
||||
/* u3t_heck(): profile point.
|
||||
*/
|
||||
void
|
||||
u3t_heck(u3_atom cog);
|
||||
|
||||
/* u3t_samp(): sample.
|
||||
*/
|
||||
void
|
||||
u3t_samp(void);
|
||||
|
||||
/* u3t_come(): push on profile stack.
|
||||
*/
|
||||
void
|
||||
u3t_come(u3_atom cog);
|
||||
|
||||
/* u3t_flee(): pop off profile stack.
|
||||
*/
|
||||
void
|
||||
u3t_flee(void);
|
||||
|
||||
/* u3t_damp(): print and clear profile data.
|
||||
*/
|
||||
void
|
||||
u3t_damp(void);
|
||||
|
||||
/* u3t_boff(): turn profile sampling off.
|
||||
*/
|
||||
void
|
||||
u3t_boff(void);
|
||||
|
||||
/* u3t_boot(): turn sampling on.
|
||||
*/
|
||||
void
|
||||
u3t_boot(void);
|
102
i/n/u.h
Normal file
102
i/n/u.h
Normal file
@ -0,0 +1,102 @@
|
||||
/* include/all.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Typedefs.
|
||||
**/
|
||||
/* u3_post: pointer offset into u3_Loom; _p suffix; declare as u3p().
|
||||
*/
|
||||
typedef c3_w u3_post;
|
||||
# define u3p(type) u3_post
|
||||
|
||||
/* u3_noun: tagged noun pointer.
|
||||
**
|
||||
** If bit 31 is 0, a u3_noun is a direct 31-bit atom ("cat").
|
||||
** If bit 31 is 1 and bit 30 0, an indirect atom ("pug").
|
||||
** If bit 31 is 1 and bit 30 1, an indirect cell ("pom").
|
||||
**
|
||||
** Bits 0-29 are a word offset against u3_Loom (u3_post).
|
||||
*/
|
||||
typedef c3_w u3_noun;
|
||||
|
||||
/* u3_weak: u3_noun which may be u3_none (not a noun).
|
||||
*/
|
||||
typedef u3_noun u3_weak;
|
||||
|
||||
/* u3_atom: u3_noun which must be an atom.
|
||||
*/
|
||||
typedef u3_noun u3_atom;
|
||||
|
||||
/* u3_term: u3_noun which must be a term (@tas).
|
||||
*/
|
||||
typedef u3_noun u3_term;
|
||||
|
||||
/* u3_cell, u3_trel, u3_qual, u3_quin: cell, triple, quadruple, quintuple.
|
||||
*/
|
||||
typedef u3_noun u3_cell;
|
||||
typedef u3_noun u3_trel;
|
||||
typedef u3_noun u3_qual;
|
||||
typedef u3_noun u3_quin;
|
||||
|
||||
/* u3_funk, u3_funq: unary and binary noun functions.
|
||||
*/
|
||||
typedef u3_noun (*u3_funk)(u3_noun);
|
||||
typedef u3_noun (*u3_funq)(u3_noun, u3_noun);
|
||||
|
||||
|
||||
/** Constants.
|
||||
**/
|
||||
/* u3_none - u3_noun which is not a noun.
|
||||
*/
|
||||
# define u3_none (u3_noun)0xffffffff
|
||||
|
||||
/* u3_nul: 0, hoon ~.
|
||||
*/
|
||||
# define u3_nul 0
|
||||
|
||||
/* u3_blip: 0, hoon %$.
|
||||
*/
|
||||
# define u3_blip 0
|
||||
|
||||
|
||||
/** Macros.
|
||||
**/
|
||||
/* u3_assure(): loobean assert, bailing with %fail.
|
||||
*/
|
||||
# define u3_assure(x) if ( !_(x) ) { u3m_bail(c3__fail); }
|
||||
|
||||
/* u3_assert(): loobean assert, bailing with %exit.
|
||||
*/
|
||||
# define u3_assent(x) if ( !_(x) ) { u3m_bail(c3__exit); }
|
||||
|
||||
|
||||
/** Aliases.
|
||||
**/
|
||||
/* u3h(), u3t(), u3at(): noun fragments.
|
||||
*/
|
||||
# define u3h(som) u3x_h(som)
|
||||
# define u3t(som) u3x_t(som)
|
||||
# define u3at(axe, som) u3x_at(axe, som)
|
||||
|
||||
/* u3nc(), u3nt(), u3nq(): tuple composition.
|
||||
*/
|
||||
# define u3nc(a, b) u3i_cell(a, b)
|
||||
# define u3nt(a, b, c) u3i_trel(a, b, c)
|
||||
# define u3nq(a, b, c, d) u3i_qual(a, b, c, d)
|
||||
|
||||
/* u3du(), u3ud(): noun/cell test.
|
||||
*/
|
||||
# define u3du(som) (u3r_du(som))
|
||||
# define u3ud(som) (u3r_ud(som))
|
||||
|
||||
/* u3k(), u3z(): reference counts.
|
||||
*/
|
||||
# define u3k(som) u3a_gain(som)
|
||||
# define u3z(som) u3a_lose(som)
|
||||
|
||||
/* u3do(), u3dc(), u3dt(), u3dq(): arvo calls.
|
||||
*/
|
||||
# define u3do(txt_c, arg) u3v_do(txt_c, arg)
|
||||
# define u3dc(txt_c, a, b) u3v_do(txt_c, u3nc(a, b))
|
||||
# define u3dt(txt_c, a, b, c) u3v_do(txt_c, u3nt(a, b, c))
|
||||
# define u3dq(txt_c, a, b, c, d) u3v_do(txt_c, u3nt(a, b, c, d))
|
173
i/n/v.h
Normal file
173
i/n/v.h
Normal file
@ -0,0 +1,173 @@
|
||||
/* include/g/v.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3_cart: ovum carton.
|
||||
*/
|
||||
struct _u3v_arvo;
|
||||
|
||||
typedef struct _u3v_cart {
|
||||
u3_noun vir; // effects of ovum
|
||||
c3_o did; // cart considered for commit?
|
||||
c3_o cit; // cart committed?
|
||||
c3_d ent_d; // entry in raft queue?
|
||||
u3p(struct _u3v_cart) nex_p;
|
||||
} u3v_cart;
|
||||
|
||||
/* u3v_arvo: modern arvo structure.
|
||||
*/
|
||||
typedef struct _u3v_arvo {
|
||||
c3_d ent_d; // event number
|
||||
u3_noun yot; // cached gates
|
||||
u3_noun now; // current time, as noun
|
||||
u3_noun wen; // current time, as text
|
||||
u3_noun sev_l; // instance number
|
||||
u3_noun sen; // instance string
|
||||
u3_noun own; // owner list
|
||||
|
||||
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
|
||||
u3p(u3v_cart) egg_p; // exit of ovum queue
|
||||
u3p(u3v_cart) geg_p; // entry of ovum queue
|
||||
} ova;
|
||||
} u3v_arvo;
|
||||
|
||||
/* u3v_home: all internal (within image) state.
|
||||
*/
|
||||
typedef struct _u3v_home {
|
||||
u3a_road rod_u; // storage state
|
||||
u3v_arvo arv_u; // arvo state
|
||||
} u3v_home;
|
||||
|
||||
|
||||
/** Globals.
|
||||
**/
|
||||
/* u3_Home / u3H: root of thread.
|
||||
*/
|
||||
c3_global u3v_home* u3_Home;
|
||||
# define u3H u3_Home
|
||||
# define u3A (&(u3_Home->arv_u))
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u3v_do(): use a kernel function.
|
||||
*/
|
||||
u3_noun
|
||||
u3v_do(const c3_c* txt_c, u3_noun arg);
|
||||
|
||||
/* u3v_make(): make a new pier by loading a pill.
|
||||
*/
|
||||
void
|
||||
u3v_make(c3_c* pas_c);
|
||||
|
||||
/* u3v_jack(): execute kernel formula to bind jets.
|
||||
*/
|
||||
void
|
||||
u3v_jack(void);
|
||||
|
||||
/* u3v_start(): start time.
|
||||
*/
|
||||
void
|
||||
u3v_start(u3_noun now);
|
||||
|
||||
/* u3v_arm(): load a kernel arm.
|
||||
*/
|
||||
u3_noun
|
||||
u3v_arm(const c3_c* txt_c);
|
||||
|
||||
/* u3v_pike(): poke with floating core.
|
||||
*/
|
||||
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
|
||||
u3v_do(const c3_c* txt_c, u3_noun arg);
|
||||
|
||||
/* u3v_wish(): text expression with cache.
|
||||
*/
|
||||
u3_noun
|
||||
u3v_wish(const c3_c* str_c);
|
||||
|
||||
/* u3v_numb(): set the instance number.
|
||||
*/
|
||||
void
|
||||
u3v_numb(void);
|
||||
|
||||
/* u3v_time(): set the reck time.
|
||||
*/
|
||||
void
|
||||
u3v_time(u3_noun now);
|
||||
|
||||
/* u3v_peek(): query the reck namespace.
|
||||
*/
|
||||
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
|
||||
u3v_tank(u3_noun blu, c3_l tab_l, u3_noun tac);
|
||||
|
||||
/* u3v_punt(): dump tank list.
|
||||
*/
|
||||
void
|
||||
u3v_punt(u3_noun blu, c3_l tab_l, u3_noun tac);
|
||||
|
||||
/* u3v_sway(): print trace.
|
||||
*/
|
||||
void
|
||||
u3v_sway(u3_noun blu, c3_l tab_l, u3_noun tax);
|
||||
|
||||
/* u3v_plan(): queue ovum (external).
|
||||
*/
|
||||
void
|
||||
u3v_plan(u3_noun pax, u3_noun fav);
|
||||
|
||||
/* u3v_plow(): queue multiple ova (external).
|
||||
*/
|
||||
void
|
||||
u3v_plow(u3_noun ova);
|
||||
|
||||
/* u3v_hose(): clear initial ovum queue.
|
||||
*/
|
||||
void
|
||||
u3v_hose(void);
|
||||
|
||||
/* u3v_louse(): last-minute deviltry upon a bail.
|
||||
*/
|
||||
void
|
||||
u3v_louse(c3_m how_m);
|
||||
|
||||
/* u3v_mark(): mark arvo kernel.
|
||||
*/
|
||||
void
|
||||
u3v_mark(void);
|
@ -2,68 +2,68 @@
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** u3_cx_*: read, but bail with c3__exit on a crash.
|
||||
/** u3x_*: read, but bail with c3__exit on a crash.
|
||||
**/
|
||||
#if 1
|
||||
# define u3_cx_h(som) u3_co_h(som)
|
||||
# define u3_cx_t(som) u3_co_t(som)
|
||||
# define u3x_h(som) u3a_h(som)
|
||||
# define u3x_t(som) u3a_t(som)
|
||||
#else
|
||||
/* u3_cx_h (u3h): head.
|
||||
/* u3x_h (u3h): head.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cx_h(u3_noun som);
|
||||
u3x_h(u3_noun som);
|
||||
|
||||
/* u3_cx_t (u3t): tail.
|
||||
/* u3x_t (u3t): tail.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cx_t(u3_noun som);
|
||||
u3x_t(u3_noun som);
|
||||
#endif
|
||||
/* u3_cx_good(): test for u3_none.
|
||||
/* u3x_good(): test for u3_none.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cx_good(u3_weak som);
|
||||
u3x_good(u3_weak som);
|
||||
|
||||
/* u3_cx_at (u3at): fragment.
|
||||
/* u3x_at (u3at): fragment.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cx_at(u3_noun axe, u3_noun som);
|
||||
u3x_at(u3_noun axe, u3_noun som);
|
||||
|
||||
/* u3_cx_cell():
|
||||
/* u3x_cell():
|
||||
**
|
||||
** Divide `a` as a cell `[b c]`.
|
||||
*/
|
||||
void
|
||||
u3_cx_cell(u3_noun a,
|
||||
u3x_cell(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c);
|
||||
|
||||
/* u3_cx_trel():
|
||||
/* u3x_trel():
|
||||
**
|
||||
** Divide `a` as a trel `[b c d]`, or bail.
|
||||
*/
|
||||
void
|
||||
u3_cx_trel(u3_noun a,
|
||||
u3x_trel(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c,
|
||||
u3_noun* d);
|
||||
|
||||
/* u3_cx_qual():
|
||||
/* u3x_qual():
|
||||
**
|
||||
** Divide `a` as a quadruple `[b c d e]`.
|
||||
*/
|
||||
void
|
||||
u3_cx_qual(u3_noun a,
|
||||
u3x_qual(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c,
|
||||
u3_noun* d,
|
||||
u3_noun* e);
|
||||
|
||||
/* u3_cx_quil():
|
||||
/* u3x_quil():
|
||||
**
|
||||
** Divide `a` as a quintuple `[b c d e f]`.
|
||||
*/
|
||||
void
|
||||
u3_cx_quil(u3_noun a,
|
||||
u3x_quil(u3_noun a,
|
||||
u3_noun* b,
|
||||
u3_noun* c,
|
||||
u3_noun* d,
|
34
i/n/z.h
Normal file
34
i/n/z.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* include/g/z.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Memoization.
|
||||
***
|
||||
*** The memo cache is keyed by an arbitrary symbolic function
|
||||
*** and a noun argument to that (logical) function. Functions
|
||||
*** are predefined by C-level callers, but 0 means nock.
|
||||
***
|
||||
*** The memo cache is within its road and dies when it falls.
|
||||
***
|
||||
*** Memo functions RETAIN keys and transfer values.
|
||||
**/
|
||||
/* u3z_find*(): find in memo cache.
|
||||
*/
|
||||
u3_weak u3z_find(c3_m, u3_noun);
|
||||
u3_weak u3z_find_2(c3_m, u3_noun, u3_noun);
|
||||
u3_weak u3z_find_3(c3_m, u3_noun, u3_noun, u3_noun);
|
||||
u3_weak u3z_find_4(c3_m, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
|
||||
/* u3z_save*(): save in memo cache.
|
||||
*/
|
||||
u3_noun u3z_save(c3_m, u3_noun, u3_noun);
|
||||
u3_noun u3z_save_2(c3_m, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3z_save_3(c3_m, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3z_save_4
|
||||
(c3_m, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
|
||||
/* u3z_uniq(): uniquify with memo cache.
|
||||
*/
|
||||
u3_noun
|
||||
u3z_uniq(u3_noun som);
|
||||
|
@ -72,8 +72,8 @@
|
||||
void* par_u; // struct http_parser *
|
||||
c3_c* url_c; // url
|
||||
c3_w ipf_w; // ipv4
|
||||
u3_bean liv; // keepalive
|
||||
u3_bean end; // all responses added
|
||||
c3_o liv; // keepalive
|
||||
c3_o end; // all responses added
|
||||
u3_hhed* hed_u; // headers
|
||||
u3_hbod* bod_u; // body parts (exit)
|
||||
u3_hbod* dob_u; // body parts (entry)
|
||||
@ -113,7 +113,7 @@
|
||||
c3_w sev_l; // server number
|
||||
c3_w coq_l; // next connection number
|
||||
c3_w por_w; // running port
|
||||
u3_bean sec; // logically secure
|
||||
c3_o sec; // logically secure
|
||||
struct _u3_hcon* hon_u; // connection list
|
||||
struct _u3_http* nex_u; // next in list
|
||||
} u3_http;
|
||||
@ -136,7 +136,7 @@
|
||||
c3_c* hot_c; // host
|
||||
c3_s por_s; // port
|
||||
c3_c* url_c; // url
|
||||
u3_bean sec; // yes == https
|
||||
c3_o sec; // yes == https
|
||||
u3_hmet met_e; // method
|
||||
u3_hhed* hed_u; // headers
|
||||
u3_hbod* bod_u; // body
|
||||
@ -164,7 +164,7 @@
|
||||
c3_c* hot_c; // hostname
|
||||
c3_s por_s; // port
|
||||
c3_w ipf_w; // IP
|
||||
u3_bean sec; // yes == https
|
||||
c3_o sec; // yes == https
|
||||
u3_hbod* rub_u; // exit of send queue
|
||||
u3_hbod* bur_u; // entry of send queue
|
||||
u3_creq* ceq_u; // exit of request queue
|
||||
@ -203,7 +203,7 @@
|
||||
typedef struct _u3_ames { // packet network state
|
||||
uv_udp_t wax_u; // socket state
|
||||
uv_timer_t tim_u; // network timer
|
||||
u3_bean alm; // alarm on
|
||||
c3_o alm; // alarm on
|
||||
c3_w law_w; // last wakeup, unix time
|
||||
c3_s por_s; // public IPv4 port
|
||||
c3_w imp_w[256]; // imperial IPs
|
||||
@ -241,8 +241,8 @@
|
||||
} mir;
|
||||
|
||||
struct { // escape code control
|
||||
u3_bean ape; // escape received
|
||||
u3_bean bra; // bracket or O received
|
||||
c3_o ape; // escape received
|
||||
c3_o bra; // bracket or O received
|
||||
} esc;
|
||||
|
||||
struct {
|
||||
@ -298,8 +298,8 @@
|
||||
*/
|
||||
typedef struct _u3_unod {
|
||||
uv_fs_event_t was_u; // stat watcher
|
||||
u3_bean dir; // always
|
||||
u3_bean dry; // ie, unmodified
|
||||
c3_o dir; // always
|
||||
c3_o dry; // ie, unmodified
|
||||
c3_c* pax_c; // absolute path
|
||||
struct _u3_udir* par_u; // in directory
|
||||
} u3_unod;
|
||||
@ -308,8 +308,8 @@
|
||||
*/
|
||||
typedef struct _u3_ufil {
|
||||
uv_fs_event_t was_u; // stat watcher
|
||||
u3_bean non; // always u3_no
|
||||
u3_bean dry; // ie, unmodified
|
||||
c3_o non; // always u3_no
|
||||
c3_o dry; // ie, unmodified
|
||||
c3_c* pax_c; // absolute path
|
||||
struct _u3_udir* par_u; // in directory
|
||||
c3_c* dot_c; // extension point or 0
|
||||
@ -321,8 +321,8 @@
|
||||
*/
|
||||
typedef struct _u3_udir {
|
||||
uv_fs_event_t was_u; // stat watcher
|
||||
u3_bean yes; // always u3_yes
|
||||
u3_bean dry; // ie, unmodified
|
||||
c3_o yes; // always u3_yes
|
||||
c3_o dry; // ie, unmodified
|
||||
c3_c* pax_c; // absolute path
|
||||
struct _u3_udir* par_u; // parent directory
|
||||
struct _u3_udir* dis_u; // subdirectories
|
||||
@ -355,7 +355,7 @@
|
||||
#ifdef SYNCLOG
|
||||
c3_w lot_w; // sync-slot
|
||||
struct _u3_sylo {
|
||||
u3_bean unx; // from unix
|
||||
c3_o unx; // from unix
|
||||
c3_m wer_m; // mote saying where
|
||||
c3_m wot_m; // mote saying what
|
||||
c3_c* pax_c; // path
|
||||
@ -368,7 +368,7 @@
|
||||
typedef struct _u3_temp {
|
||||
uv_timer_t tim_u; // temp timer
|
||||
c3_w run_w; // run of consecutive alarms
|
||||
u3_bean alm; // alarm
|
||||
c3_o alm; // alarm
|
||||
} u3_temp;
|
||||
|
||||
/* u2_utfo: unix terminfo strings.
|
||||
@ -489,13 +489,13 @@
|
||||
uv_tcp_t wax_u; // TCP handle
|
||||
struct _u3_rnam* nam_u; // peer we're connected to
|
||||
u3_rbuf* red_u; // read buffer
|
||||
u3_bean red; // u3_yes on new data
|
||||
c3_o red; // u3_yes on new data
|
||||
u3_rbuf* wri_u; // write buffer
|
||||
u3_raft* raf_u; // back-reference to server
|
||||
u3_rreq* out_u; // exit of request queue
|
||||
u3_rreq* tou_u; // entry of request queue
|
||||
struct _u3_rcon* nex_u; // pointer to next con
|
||||
u3_bean liv; // are we live?
|
||||
c3_o liv; // are we live?
|
||||
} u3_rcon;
|
||||
|
||||
/* u3_rnam: raft peer name.
|
||||
@ -506,7 +506,7 @@
|
||||
c3_c* por_c; // port
|
||||
u3_rcon* ron_u; // connection
|
||||
struct _u3_rnam* nex_u; // pointer to next peer
|
||||
u3_bean vog; // did they vote for us?
|
||||
c3_o vog; // did they vote for us?
|
||||
} u3_rnam;
|
||||
|
||||
/* u3_opts: command line configuration.
|
||||
@ -519,18 +519,18 @@
|
||||
c3_w fuz_w; // -f, fuzz testing
|
||||
c3_s por_s; // -p, ames port
|
||||
c3_s rop_s; // -l, raft port
|
||||
u3_bean abo; // -a
|
||||
u3_bean bat; // -b, batch create
|
||||
u3_bean gab; // -g
|
||||
u3_bean dem; // -d, dem
|
||||
u3_bean fog; // -Xwtf, skip last event
|
||||
u3_bean fak; // -F, fake carrier
|
||||
u3_bean loh; // -L, local-only networking
|
||||
u3_bean pro; // , profile
|
||||
u3_bean veb; // -v, verbose (inverse of -q)
|
||||
u3_bean nuu; // -c, new pier
|
||||
u3_bean vno; // -V
|
||||
u3_bean mem; // -M, memory madness
|
||||
c3_o abo; // -a
|
||||
c3_o bat; // -b, batch create
|
||||
c3_o gab; // -g
|
||||
c3_o dem; // -d, dem
|
||||
c3_o fog; // -Xwtf, skip last event
|
||||
c3_o fak; // -F, fake carrier
|
||||
c3_o loh; // -L, local-only networking
|
||||
c3_o pro; // , profile
|
||||
c3_o veb; // -v, verbose (inverse of -q)
|
||||
c3_o nuu; // -c, new pier
|
||||
c3_o vno; // -V
|
||||
c3_o mem; // -M, memory madness
|
||||
} u3_opts;
|
||||
|
||||
/* u3_host: entire host.
|
||||
@ -550,7 +550,7 @@
|
||||
u3_opts ops_u; // commandline options
|
||||
u3_unix unx_u; // sync and clay
|
||||
u3_temp teh_u; // temp timer
|
||||
u3_bean liv; // if u2_no, shut down
|
||||
c3_o liv; // if u3_no, shut down
|
||||
c3_i xit_i; // exit code for shutdown
|
||||
void* ssl_u; // struct SSL_CTX*
|
||||
} u3_host; // host == computer == process
|
||||
@ -566,10 +566,10 @@
|
||||
c3_global c3_c* u3_Local;
|
||||
c3_global c3_c* u3_System;
|
||||
|
||||
c3_global u3_bean u3_Flag_Abort;
|
||||
c3_global u3_bean u3_Flag_Garbage;
|
||||
c3_global u3_bean u3_Flag_Profile;
|
||||
c3_global u3_bean u3_Flag_Verbose;
|
||||
c3_global c3_o u3_Flag_Abort;
|
||||
c3_global c3_o u3_Flag_Garbage;
|
||||
c3_global c3_o u3_Flag_Profile;
|
||||
c3_global c3_o u3_Flag_Verbose;
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
@ -628,7 +628,7 @@
|
||||
*/
|
||||
u3_atom
|
||||
u3_time_in_ts(struct timespec* tim_ts);
|
||||
#if defined(U2_OS_linux)
|
||||
#if defined(U3_OS_linux)
|
||||
/* u3_time_t_in_ts(): urbit time from time_t.
|
||||
*/
|
||||
u3_atom
|
||||
@ -675,7 +675,7 @@
|
||||
/* u3_path(): C unix path in computer for file or directory.
|
||||
*/
|
||||
c3_c*
|
||||
u3_path(u3_bean fyl, u3_noun pax);
|
||||
u3_path(c3_o fyl, u3_noun pax);
|
||||
|
||||
/** Filesystem (old api).
|
||||
**/
|
||||
@ -698,7 +698,7 @@
|
||||
|
||||
/* u3_ve_save(): save internal file as atom.
|
||||
*/
|
||||
u3_bean
|
||||
c3_o
|
||||
u3_ve_save(c3_c* ext_c, u3_noun tah, u3_noun dat);
|
||||
|
||||
/* u3_ve_zeus(): prayer to internal file path. Return unit.
|
||||
@ -775,7 +775,7 @@
|
||||
/* u3_lo_shut(): end callback processing.
|
||||
*/
|
||||
void
|
||||
u3_lo_shut(u3_bean);
|
||||
u3_lo_shut(c3_o);
|
||||
|
||||
|
||||
/** Terminal, new style.
|
||||
@ -1096,6 +1096,23 @@
|
||||
void
|
||||
u3_sist_get(const c3_c* key_c, c3_y* val_y);
|
||||
|
||||
/** New timer system.
|
||||
**/
|
||||
/* u3_temp_io_init(): initialize time timer.
|
||||
*/
|
||||
void
|
||||
u3_temp_io_init(void);
|
||||
|
||||
/* u3_temp_io_exit(): terminate timer.
|
||||
*/
|
||||
void
|
||||
u3_temp_io_exit(void);
|
||||
|
||||
/* u3_temp_io_poll(): update temp IO state.
|
||||
*/
|
||||
void
|
||||
u3_temp_io_poll(void);
|
||||
|
||||
|
||||
/** HTTP client.
|
||||
**/
|
@ -1,78 +0,0 @@
|
||||
/* include/all.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Prefix definitions:
|
||||
***
|
||||
*** u3_ca_: fundamental allocators.
|
||||
*** u3_cc_: constants.
|
||||
*** u3_ce_: checkpointing.
|
||||
*** u3_ch_: HAMT hash tables.
|
||||
*** u3_ci_: noun constructors
|
||||
*** u3_cj_: jets.
|
||||
*** u3_ck*: direct jet calls (modern C convention)
|
||||
*** u3_cm_: system management etc.
|
||||
*** u3_cn_: nock interpreter.
|
||||
*** u3_co_: fundamental macros.
|
||||
*** u3_cq*: direct jet calls (archaic C convention)
|
||||
*** u3_cr_: read functions which never bail out.
|
||||
*** u3_cs_: structures and definitions.
|
||||
*** u3_ct_: tracing.
|
||||
*** u3_cw_: direct jet calls (core noun convention)
|
||||
*** u3_cx_: read functions which do bail out.
|
||||
*** u3_cv_: arvo specific structures.
|
||||
*** u3_cz_: memoization.
|
||||
***
|
||||
*** u3_cr_, u3_cx_, u3_cz_ functions use retain conventions; the caller
|
||||
*** retains ownership of passed-in nouns, the callee preserves
|
||||
*** ownership of returned nouns.
|
||||
***
|
||||
*** Unless documented otherwise, all other functions use transfer
|
||||
*** conventions; the caller logically releases passed-in nouns,
|
||||
*** the callee logically releases returned nouns.
|
||||
***
|
||||
*** In general, exceptions to the transfer convention all occur
|
||||
*** when we're using a noun as a key.
|
||||
**/
|
||||
|
||||
/** c: the c3 layer, C portability and definitions.
|
||||
**/
|
||||
# include "c/portable.h"
|
||||
# include "c/tune.h"
|
||||
# include "c/types.h"
|
||||
# include "c/defs.h"
|
||||
# include "c/motes.h"
|
||||
# include "c/comd.h"
|
||||
|
||||
/** n: the u3 layer, definitions and data structures.
|
||||
**/
|
||||
# include "n/tune.h"
|
||||
# include "n/noun.h"
|
||||
# include "n/save.h"
|
||||
# include "n/hash.h"
|
||||
# include "n/road.h"
|
||||
# include "n/jets.h"
|
||||
# include "n/meze.h"
|
||||
# include "n/arvo.h"
|
||||
# include "n/glob.h"
|
||||
|
||||
/** g: the u3 layer, functions.
|
||||
**/
|
||||
# include "g/a.h"
|
||||
# include "g/e.h"
|
||||
# include "g/h.h"
|
||||
# include "g/i.h"
|
||||
# include "g/j.h"
|
||||
# include "g/m.h"
|
||||
# include "g/n.h"
|
||||
# include "g/r.h"
|
||||
# include "g/t.h"
|
||||
# include "g/x.h"
|
||||
# include "g/v.h"
|
||||
# include "g/z.h"
|
||||
|
||||
/** j: the u3 layer, jets.
|
||||
**/
|
||||
# include "j/k.h"
|
||||
# include "j/w.h"
|
||||
# include "j/q.h"
|
@ -1,22 +0,0 @@
|
||||
/* include/comd.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Functions.
|
||||
**/
|
||||
/* c3_comd_init():
|
||||
**
|
||||
** Initialize the readline console. Return the history filename.
|
||||
*/
|
||||
c3_c* // produce
|
||||
c3_comd_init(void);
|
||||
|
||||
/* c3_comd_line():
|
||||
**
|
||||
** Read a line from the console, saving to history file `fel`.
|
||||
**
|
||||
** Returns 0 iff the console has exited.
|
||||
*/
|
||||
c3_c* // produce
|
||||
c3_comd_line(const c3_c *fel_c,
|
||||
const c3_c *prm_c); // retain
|
@ -1,24 +0,0 @@
|
||||
/* include/c/tune.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tuning ifdefs. Comment out to disable.
|
||||
**/
|
||||
/** Profiling.
|
||||
**/
|
||||
/* Profile at all.
|
||||
*/
|
||||
# define U2_PROFILE
|
||||
|
||||
/* Measure memory usage.
|
||||
*/
|
||||
# define U2_PROFILE_MEMORY
|
||||
|
||||
/* Measure execution time.
|
||||
*/
|
||||
# define U2_PROFILE_SPEED
|
||||
|
||||
/* Describe execution patterns.
|
||||
*/
|
||||
# define U2_PROFILE_SHAPE
|
||||
|
488
include/f/bail.h
488
include/f/bail.h
@ -1,488 +0,0 @@
|
||||
/* include/bail.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data types.
|
||||
**/
|
||||
/** Structures - in loom space.
|
||||
**/
|
||||
/* u2_loom_kite: jump buffer.
|
||||
*/
|
||||
typedef struct _u2_loom_kite {
|
||||
/* Parent kite.
|
||||
*/
|
||||
u2_ray par_r;
|
||||
|
||||
/* Interpreter trace at call point.
|
||||
*/
|
||||
u2_noun tax;
|
||||
|
||||
/* Profiling action stack.
|
||||
*/
|
||||
u2_noun don;
|
||||
|
||||
/* C escape buffer.
|
||||
*/
|
||||
jmp_buf buf_f;
|
||||
} u2_loom_kite;
|
||||
|
||||
# define u2_kite_tax(kit_r) *u2_at(kit_r, u2_loom_kite, tax)
|
||||
# define u2_kite_don(kit_r) *u2_at(kit_r, u2_loom_kite, don)
|
||||
# define u2_kite_par_r(kit_r) *u2_at(kit_r, u2_loom_kite, par_r)
|
||||
# define u2_kite_buf_r(kit_r) u2_aftr(kit_r, u2_loom_kite, buf_f)
|
||||
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Fail-specific.
|
||||
**/
|
||||
/* u2_bl_bail(): bail out.
|
||||
**
|
||||
** Bail codes:
|
||||
**
|
||||
** c3__exit for normal exit with correct trace
|
||||
** c3__fail for abnormal failure without assumptions
|
||||
**
|
||||
** When in doubt, fail.
|
||||
**
|
||||
** In both cases, a mark-and-sweep is necessary (and
|
||||
** not currently performed) to clean up leaks.
|
||||
*/
|
||||
u2_noun // blocked
|
||||
u2_bl_bail(u2_wire wir_r,
|
||||
c3_l how_l);
|
||||
|
||||
/* u2_bl_yes(): assure yes.
|
||||
*/
|
||||
# define u2_bl_yes(wir_r, feg) \
|
||||
( (u2_yes == (feg)) ? 0 : u2_bl_bail(wir_r, c3__fail) )
|
||||
|
||||
/* u2_bl_good(): test for u2_none.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bl_good(u2_wire wir_r, u2_weak som);
|
||||
|
||||
/* u2_bl_some(): test for zero ray.
|
||||
*/
|
||||
u2_ray
|
||||
u2_bl_some(u2_wire wir_r, u2_ray ray_r);
|
||||
|
||||
/* u2_bl_flat(): force to atom.
|
||||
*/
|
||||
u2_atom
|
||||
u2_bl_flat(u2_wire wir_r, u2_noun som);
|
||||
|
||||
|
||||
/** General. All functions bail out on error.
|
||||
**/
|
||||
/** Cell access.
|
||||
**/
|
||||
/* u2_bi_h():
|
||||
**
|
||||
** Return the head of (a).
|
||||
*/
|
||||
u2_noun
|
||||
u2_bi_h(u2_wire wir_r,
|
||||
u2_noun a);
|
||||
|
||||
# define u2_xh(wir_r, a) u2_bi_h(wir_r, a)
|
||||
# define u2_xt(wir_r, a) u2_bi_t(wir_r, a)
|
||||
|
||||
/* u2_bi_t():
|
||||
**
|
||||
** Return the tail of (a).
|
||||
*/
|
||||
u2_noun
|
||||
u2_bi_t(u2_wire wir_r,
|
||||
u2_noun a);
|
||||
|
||||
|
||||
/* u2_bi_frag():
|
||||
**
|
||||
** Return fragment (a) of (b).
|
||||
*/
|
||||
u2_noun
|
||||
u2_bi_frag(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_bi_cell():
|
||||
**
|
||||
** Factor `a` as a cell `[b c]`.
|
||||
*/
|
||||
void
|
||||
u2_bi_cell(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c);
|
||||
|
||||
/* u2_bi_qual():
|
||||
**
|
||||
** Factor `a` as a quadruple `[b c d e]`.
|
||||
*/
|
||||
void
|
||||
u2_bi_qual(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c,
|
||||
u2_noun* d,
|
||||
u2_noun* e);
|
||||
|
||||
/* u2_bi_quil():
|
||||
**
|
||||
** Factor `a` as a quintuple `[b c d e f]`, or bail.
|
||||
*/
|
||||
void
|
||||
u2_bi_quil(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c,
|
||||
u2_noun* d,
|
||||
u2_noun* e,
|
||||
u2_noun* f);
|
||||
|
||||
/* u2_bi_trel():
|
||||
**
|
||||
** Factor `a` as a trel `[b c d]`, or bail.
|
||||
*/
|
||||
void
|
||||
u2_bi_trel(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c,
|
||||
u2_noun* d);
|
||||
|
||||
/** Tracing.
|
||||
**/
|
||||
/* u2_bl_push(): push on trace stack.
|
||||
*/
|
||||
void
|
||||
u2_bl_push(u2_wire wir_r,
|
||||
u2_noun mon); // transfer
|
||||
|
||||
/* u2_bl_mean(): push `[%mean roc]` on trace stack.
|
||||
*/
|
||||
void
|
||||
u2_bl_mean(u2_wire wir_r,
|
||||
u2_noun roc); // transfer
|
||||
|
||||
/* u2_bl_error(): simple string error.
|
||||
*/
|
||||
u2_noun // blocked
|
||||
u2_bl_error(u2_wire wir_r,
|
||||
const c3_c* err_c); // retain
|
||||
|
||||
/* u2_bl_drop(): drop from meaning stack.
|
||||
*/
|
||||
void
|
||||
u2_bl_drop(u2_wire wir_r);
|
||||
|
||||
/** Atom access.
|
||||
**/
|
||||
/* u2_bi_met():
|
||||
**
|
||||
** Return the size of (b) in bits, rounded up to
|
||||
** (1 << a_y).
|
||||
**
|
||||
** For example, (a_y == 3) returns the size in bytes.
|
||||
*/
|
||||
c3_w
|
||||
u2_bi_met(u2_wire wir_r,
|
||||
c3_y a_y,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_bi_bit():
|
||||
**
|
||||
** Return bit (a_w) of (b).
|
||||
*/
|
||||
c3_b
|
||||
u2_bi_bit(u2_wire wir_r,
|
||||
c3_w a_w,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_bi_byte():
|
||||
**
|
||||
** Return byte (a_w) of (b).
|
||||
*/
|
||||
c3_y
|
||||
u2_bi_byte(u2_wire wir_r,
|
||||
c3_w a_w,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_bi_bytes():
|
||||
**
|
||||
** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c).
|
||||
*/
|
||||
void
|
||||
u2_bi_bytes(u2_wire wir_r,
|
||||
c3_w a_w,
|
||||
c3_w b_w,
|
||||
c3_y* c_y,
|
||||
u2_noun d);
|
||||
|
||||
/* u2_bi_mp():
|
||||
**
|
||||
** Copy (b) into (a_mp).
|
||||
*/
|
||||
void
|
||||
u2_bi_mp(u2_wire wir_r,
|
||||
mpz_t a_mp,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_bi_word():
|
||||
**
|
||||
** Return word (a_w) of (b).
|
||||
*/
|
||||
c3_w
|
||||
u2_bi_word(u2_wire wir_r,
|
||||
c3_w a_w,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_bi_words():
|
||||
**
|
||||
** Copy words (a_w) through (a_w + b_w - 1) from (d) to (c).
|
||||
*/
|
||||
void
|
||||
u2_bi_words(u2_wire wir_r,
|
||||
c3_w a_w,
|
||||
c3_w b_w,
|
||||
c3_w* c_w,
|
||||
u2_noun d);
|
||||
|
||||
/** Allocation.
|
||||
**/
|
||||
/* u2_bn_slab():
|
||||
**
|
||||
** Create an atomic slab of `len` words.
|
||||
*/
|
||||
u2_ray
|
||||
u2_bn_slab(u2_wire wir_r,
|
||||
c3_w len_w);
|
||||
|
||||
/* u2_bn_slaq():
|
||||
**
|
||||
** Create an atomic slab of `len` bloqs of size `met`.
|
||||
*/
|
||||
u2_ray
|
||||
u2_bn_slaq(u2_wire wir_r,
|
||||
c3_g met_g,
|
||||
c3_w len_w);
|
||||
|
||||
/** Noun construction.
|
||||
**/
|
||||
/* u2_bn_bytes():
|
||||
**
|
||||
** Copy [a] bytes from [b].
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_bytes(u2_wire wir_r,
|
||||
c3_w a_w,
|
||||
const c3_y* b_y);
|
||||
|
||||
/* u2_bn_string():
|
||||
**
|
||||
** u2_bn_bytes(wir_r, strlen(a_c), (c3_y *)a_c);
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_string(u2_wire wir_r,
|
||||
const c3_c* a_c);
|
||||
|
||||
/* u2_bn_tape():
|
||||
**
|
||||
** Create an atomic string from a list of bytes.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_tape(u2_wire wir_r,
|
||||
u2_list lit);
|
||||
|
||||
/* u2_bn_cell():
|
||||
**
|
||||
** Produce the cell [a b].
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_cell(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun b);
|
||||
# define u2_bc(wir_r, a, b) u2_bn_cell(wir_r, a, b)
|
||||
# define u2_bo(wir_r, a) u2_bn_cell(wir_r, a, _0)
|
||||
|
||||
/* u2_bn_decimal():
|
||||
**
|
||||
** On (wir_r), write (list), a list of digits, as a decimal.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_decimal(u2_wire wir_r,
|
||||
u2_list lit);
|
||||
|
||||
/* u2_bn_heximal():
|
||||
**
|
||||
** On (wir_r), write (lit), a list of digits, as a hexadecimal.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_heximal(u2_wire wir_r,
|
||||
u2_list lit);
|
||||
|
||||
/* u2_bn_ice():
|
||||
**
|
||||
** Produce `a`, not referencing the can. Copy or gain reference.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_ice(u2_wire wir_r,
|
||||
u2_weak a);
|
||||
# define u2_bx(wir_r, a) u2_bn_ice(wir_r, a)
|
||||
|
||||
/* u2_bn_list():
|
||||
**
|
||||
** Generate a null-terminated list, with u2_none as terminator.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_list(u2_wire wir_r, ...);
|
||||
|
||||
/* u2_bn_nock():
|
||||
**
|
||||
** Nock or bail.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_bn_nock(u2_wire wir_r,
|
||||
u2_noun bus, // retain
|
||||
u2_noun fol); // retain
|
||||
|
||||
/* u2_bn_mp():
|
||||
**
|
||||
** Copy the GMP integer [a] into an atom. Free it.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_mp(u2_wire wir_r,
|
||||
mpz_t a_mp);
|
||||
|
||||
/* u2_bn_qual():
|
||||
**
|
||||
** Produce the quadruple [a b c d].
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_qual(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun c,
|
||||
u2_noun d);
|
||||
# define u2_bq(wir_r, a, b, c, d) u2_bn_qual(wir_r, a, b, c, d)
|
||||
|
||||
/* u2_bn_quil():
|
||||
**
|
||||
** Produce the quintuple [a b c d].
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_quil(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun c,
|
||||
u2_noun d,
|
||||
u2_noun e);
|
||||
# define u2_bu(wir_r, a, b, c, d, e) u2_bn_quil(wir_r, a, b, c, d, e)
|
||||
|
||||
/* u2_bn_trel():
|
||||
**
|
||||
** Produce the triple [a b c].
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_trel(u2_wire wir_r,
|
||||
u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun c);
|
||||
# define u2_bt(wir_r, a, b, c) u2_bn_trel(wir_r, a, b, c)
|
||||
|
||||
/* u2_bn_words():
|
||||
**
|
||||
** Copy [a] words from [b] into an atom.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_words(u2_wire wir_r,
|
||||
c3_w a_w,
|
||||
const c3_w* b_w);
|
||||
|
||||
/* u2_bn_molt():
|
||||
**
|
||||
** Mutate `som` with a 0-terminated list of axis, noun pairs.
|
||||
** Axes must be cats (31 bit).
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_bn_molt(u2_wire wir_r,
|
||||
u2_noun som, // retain
|
||||
...); // retain
|
||||
|
||||
/* u2_bn_molf():
|
||||
**
|
||||
** As u2_bn_molt(), with argument pointer.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_molf(u2_wire wir_r,
|
||||
u2_noun som,
|
||||
va_list vap);
|
||||
|
||||
/* u2_bn_mang():
|
||||
**
|
||||
** Kick a core, substituting axes with nouns.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_mang(u2_wire wir_r,
|
||||
u2_noun cor,
|
||||
...); // nouns
|
||||
|
||||
/* u2_bn_mong():
|
||||
**
|
||||
** Call by gate and sample (new convention).
|
||||
** Caller retains `gat`, transfers `sam`.
|
||||
*/
|
||||
u2_noun // produce
|
||||
u2_bn_mong(u2_wire wir_r,
|
||||
u2_noun gat, // retain
|
||||
u2_noun sam); // submit
|
||||
|
||||
/* u2_bn_hook():
|
||||
**
|
||||
** Execute hook from core.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_bn_hook(u2_wire wir_r,
|
||||
u2_noun cor, // retain
|
||||
const c3_c* tam_c);
|
||||
|
||||
/* u2_bn_cook():
|
||||
**
|
||||
** Reverse hook as molt.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_bn_cook(u2_wire wir_r,
|
||||
u2_noun cor, // retain
|
||||
const c3_c* tam_c,
|
||||
u2_noun som); // transfer
|
||||
|
||||
/* u2_bn_gart():
|
||||
**
|
||||
** Call by core, hook, sample.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_gart(u2_wire wir_r,
|
||||
u2_noun cor,
|
||||
const c3_c* tam_c,
|
||||
u2_noun sam);
|
||||
|
||||
/* u2_bn_gort():
|
||||
**
|
||||
** Call by core, depth, hook, molt list.
|
||||
*/
|
||||
u2_noun
|
||||
u2_bn_gort(u2_wire wir_r,
|
||||
u2_noun cor,
|
||||
const c3_c* tam_c,
|
||||
...);
|
||||
|
||||
/* u2_bn_wait():
|
||||
**
|
||||
** Produce the functional equivalent of `|.(~(tam cor sam))`.
|
||||
*/
|
||||
u2_noun // produce
|
||||
u2_bn_wait(u2_wire wir_r,
|
||||
u2_noun cor, // retain
|
||||
u2_noun sam, // retain
|
||||
const c3_c* tam_c); // retain
|
192
include/f/benx.h
192
include/f/benx.h
@ -1,192 +0,0 @@
|
||||
/* include/benx.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u2_loom_benx: tracing, profiling, debugging
|
||||
*/
|
||||
typedef struct _u2_loom_benx {
|
||||
/* Source position debug stack:
|
||||
**
|
||||
** *(list ~[* [@ @] [@ @]])
|
||||
*/
|
||||
u2_weak zat; // on shed
|
||||
|
||||
/* Manual context debug stack:
|
||||
**
|
||||
** *(list %{nap})
|
||||
*/
|
||||
u2_weak zof; // on shed
|
||||
|
||||
/* Interpreter steps.
|
||||
*/
|
||||
c3_d sap_d;
|
||||
|
||||
/* Words copied.
|
||||
*/
|
||||
c3_d cop_d;
|
||||
|
||||
/* Matching comparisons.
|
||||
*/
|
||||
c3_d det_d;
|
||||
|
||||
/* Jet activations.
|
||||
*/
|
||||
c3_d jax_d;
|
||||
|
||||
/* User-defined activations.
|
||||
*/
|
||||
c3_d use_d;
|
||||
|
||||
/* Current depth of C stack.
|
||||
*/
|
||||
c3_w wac_w;
|
||||
|
||||
/* Maximum depth of C stack.
|
||||
*/
|
||||
c3_w wax_w;
|
||||
|
||||
/* Original words in wire.
|
||||
*/
|
||||
c3_w lif_w;
|
||||
|
||||
/* Original words in basket.
|
||||
*/
|
||||
c3_w bos_w;
|
||||
|
||||
/* Unix time in seconds.
|
||||
*/
|
||||
c3_w sec_w;
|
||||
|
||||
/* Unix time in microseconds.
|
||||
*/
|
||||
c3_w usc_w;
|
||||
} u2_loom_benx;
|
||||
|
||||
#define u2_benx_at(bex_r, wof) *u2_at(bex_r, u2_loom_benx, wof)
|
||||
#define u2_benx_be(bex_r, ite, wof) *u2_be(bex_r, u2_loom_benx, ite, wof)
|
||||
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_bx_boot(): reset the performance log.
|
||||
*/
|
||||
void
|
||||
u2_bx_boot(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_post(): export and reset the performance log.
|
||||
**
|
||||
** zat: source position stack (on shed)
|
||||
** zof: programer action stack (on shed)
|
||||
** sap: number of steps
|
||||
** cop: number of words copied
|
||||
** det: number of identical nouns compared
|
||||
** jax: number of jet activations
|
||||
** use: number of user counts
|
||||
** wax: maximum depth of C stack
|
||||
** viq: words in wire allocated
|
||||
** zor: words in basket allocated
|
||||
** ums: number of milliseconds consumed
|
||||
*/
|
||||
u2_bean
|
||||
u2_bx_post(u2_ray wir_r,
|
||||
u2_noun* zat,
|
||||
u2_noun* zof,
|
||||
c3_d* sap_d,
|
||||
c3_d* cop_d,
|
||||
c3_d* det_d,
|
||||
c3_d* jax_d,
|
||||
c3_d* use_d,
|
||||
c3_w* wax_w,
|
||||
c3_ws* viq_ws,
|
||||
c3_ws* zor_ws,
|
||||
c3_w* ums_w);
|
||||
|
||||
/* u2_bx_spot(): declare source position.
|
||||
*/
|
||||
void
|
||||
u2_bx_spot(u2_ray wir_r,
|
||||
u2_noun hod); // transfer
|
||||
|
||||
/* u2_bx_loaf(): print debug wall.
|
||||
*/
|
||||
void
|
||||
u2_bx_loaf(u2_ray wir_r,
|
||||
u2_noun wal); // retain
|
||||
|
||||
/* u2_bx_bean_ent(), u2_bx_bean_out(): enter and exit execution state.
|
||||
*/
|
||||
void
|
||||
u2_bx_bean_ent(u2_ray wir_r,
|
||||
u2_noun hod); // transfer
|
||||
void
|
||||
u2_bx_bean_out(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_step(): note interpreter step.
|
||||
*/
|
||||
void
|
||||
u2_bx_step(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_copy(): note `cop` copied words.
|
||||
*/
|
||||
void
|
||||
u2_bx_copy(u2_ray wir_r,
|
||||
c3_w cop_w);
|
||||
|
||||
/* u2_bx_dent(): note 'det' identicals.
|
||||
*/
|
||||
void
|
||||
u2_bx_dent(u2_ray wir_r,
|
||||
c3_w det_w);
|
||||
|
||||
/* u2_bx_shed(): note `wad` allocated/freed words in hangar.
|
||||
*/
|
||||
void
|
||||
u2_bx_shed(u2_ray wir_r,
|
||||
c3_ws wad_ws);
|
||||
|
||||
/* u2_bx_bask(): note `wad` allocated/freed words in basket.
|
||||
*/
|
||||
void
|
||||
u2_bx_bask(u2_ray wir_r,
|
||||
c3_ws wad_ws);
|
||||
|
||||
/* u2_bx_sink(): go deeper (call) in the C stack.
|
||||
*/
|
||||
void
|
||||
u2_bx_sink(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_rise(): go shallower (return) in the C stack.
|
||||
*/
|
||||
void
|
||||
u2_bx_rise(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_used(): report a user count.
|
||||
*/
|
||||
void
|
||||
u2_bx_used(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_flew(): report a jet activation.
|
||||
*/
|
||||
void
|
||||
u2_bx_flew(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_mark(): update memory watermarks.
|
||||
*/
|
||||
void
|
||||
u2_bx_mark(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_show(): print benchmark report and clear structure.
|
||||
*/
|
||||
void
|
||||
u2_bx_show(u2_ray wir_r);
|
||||
|
||||
/* u2_bx_warn(): report a warning at file and line.
|
||||
*/
|
||||
void
|
||||
u2_bx_warn(u2_ray wir_r,
|
||||
const c3_c* fil_c,
|
||||
c3_w lyn_w);
|
||||
# define u2_bx_warn_here(wir_r) u2_bx_warn(wir_r, __FILE__, __LINE__)
|
||||
|
271
include/f/cash.h
271
include/f/cash.h
@ -1,271 +0,0 @@
|
||||
/* include/cash.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Hash-table design:
|
||||
***
|
||||
*** The cash system is a 16-way hash tree designed to
|
||||
*** scale smoothly, remaining small for small usage
|
||||
*** and fast for big usage. It is also salted for use
|
||||
*** of multiple associations in the same table.
|
||||
***
|
||||
*** A logical key is the combination of an opaque
|
||||
*** function salt, any number < (1 << 31), and a
|
||||
*** sample list. Matches are in every case within
|
||||
*** the salt.
|
||||
***
|
||||
*** All the nouns in the sample list are equal, but
|
||||
*** duplicate. Comparing duplicates is expensive, so
|
||||
*** the hash-table stores every duplicate it finds.
|
||||
***
|
||||
*** The search key is the mug of the salt, XORed
|
||||
*** with the mug of the sample. [XX - This sacrifices
|
||||
*** efficiency to internal convenience and should
|
||||
*** be replaced with direct salt.]
|
||||
***
|
||||
*** A single slot stores a single entry. If a new entry
|
||||
*** is added, the slot expands to a 16-way table. If the
|
||||
*** table is lightly filled, slots are collision-mapped.
|
||||
*** If it is heavily filled, slots are radix-mapped.
|
||||
***
|
||||
*** Full key collisions, which are inevitable and not at
|
||||
*** all improbable, revert to linear search. 16 collisions
|
||||
*** on the same 31-bit key will produce storage failure.
|
||||
***
|
||||
*** Future revisions should add a reclamation mode based on
|
||||
*** the "clock algorithm" (a variant on LRU). The clock
|
||||
*** rotates around search-key space. Entries are reclaimed
|
||||
*** if they are clocked out and either key or value has a
|
||||
*** reference count of 1.
|
||||
**/
|
||||
|
||||
/** Tunable constants.
|
||||
**/
|
||||
/* A 16-way subtable with remaining keyspace switches up to laminar
|
||||
** mode when it exceeds `cash_hi` recursively counted entries, and
|
||||
** reverts to collision mode when it falls back below `cash_lo`.
|
||||
*/
|
||||
# define u2_tune_cash_lo 6
|
||||
# define u2_tune_cash_hi 10
|
||||
|
||||
/** Data types.
|
||||
**/
|
||||
/* Slot: a discriminated union.
|
||||
*/
|
||||
# define u2_slot_is_a(lot_r) (0 == (*u2_at_ray(lot_r) >> 31))
|
||||
# define u2_slot_is_b(lot_r) (3 == (*u2_at_ray(lot_r) >> 30))
|
||||
# define u2_slot_is_c(lot_r) (2 == (*u2_at_ray(lot_r) >> 30))
|
||||
|
||||
/* u2_cash_slot_a: cache slot, containing exactly one entry.
|
||||
*/
|
||||
typedef struct {
|
||||
/* sel_m: opaque, unique function identity (0 for nock)
|
||||
** sap: sample list
|
||||
** pro: product
|
||||
*/
|
||||
c3_m sel_m;
|
||||
u2_noun sap;
|
||||
u2_noun pro;
|
||||
} u2_cash_slot_a;
|
||||
|
||||
typedef u2_cash_slot_a u2_cash_slot;
|
||||
|
||||
# define u2_slot_a_sel(lot_r) *u2_at(lot_r, u2_cash_slot_a, sel_m)
|
||||
# define u2_slot_a_sap(lot_r) *u2_at(lot_r, u2_cash_slot_a, sap)
|
||||
# define u2_slot_a_pro(lot_r) *u2_at(lot_r, u2_cash_slot_a, pro)
|
||||
|
||||
# define u2_slot_gunk_coll (7 << 29)
|
||||
# define u2_slot_gunk_radx (6 << 29)
|
||||
|
||||
# define u2_slot_gunk_is_coll(gun_w) (!!((gun_w) & (1 << 29)))
|
||||
# define u2_slot_gunk_is_radx(gun_w) (!((gun_w) & (1 << 29)))
|
||||
|
||||
/* u2_cash_slot_b: cache slot, with 16-way table - if not empty.
|
||||
*/
|
||||
typedef struct {
|
||||
/* gun_w: gunk word - (1 << 31) at present
|
||||
** rag_w: recursive entry count
|
||||
** sid_r: ray to 16-way slot array, or 0 if rag_w is 0
|
||||
*/
|
||||
c3_w gun_w;
|
||||
c3_w rag_w;
|
||||
u2_ray sid_r;
|
||||
} u2_cash_slot_b;
|
||||
|
||||
# define u2_slot_b_gun(lot_r) *u2_at(lot_r, u2_cash_slot_b, gun_w)
|
||||
# define u2_slot_b_rag(lot_r) *u2_at(lot_r, u2_cash_slot_b, rag_w)
|
||||
# define u2_slot_b_sid(lot_r) *u2_at(lot_r, u2_cash_slot_b, sid_r)
|
||||
# define u2_slot_b_sid_i(lot_r, i_w) \
|
||||
(u2_slot_b_sid(lot_r) + ((i_w) * c3_wiseof(u2_cash_slot_a)))
|
||||
|
||||
/* u2_cash_slot_c: cache slot, empty
|
||||
*/
|
||||
typedef struct {
|
||||
/* emt_w: (1 << 31)
|
||||
*/
|
||||
c3_w emt_w;
|
||||
c3_w xxx_w; // unused
|
||||
c3_w xxy_w; // unused
|
||||
} u2_cash_slot_c;
|
||||
|
||||
# define u2_slot_emty (1 << 31)
|
||||
# define u2_slot_c_emt(lot_r) *u2_at(lot_r, u2_cash_slot_c, emt_w)
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_cs_free():
|
||||
**
|
||||
** Release an old hashtable.
|
||||
*/
|
||||
void
|
||||
u2_cs_free(u2_ray ral_r,
|
||||
u2_ray lot_r); // submit
|
||||
|
||||
/* u2_cs_mark():
|
||||
**
|
||||
** Mark traverse of slot. Return allocated words.
|
||||
*/
|
||||
c3_w
|
||||
u2_cs_mark(u2_ray ral_r,
|
||||
u2_ray lot_r);
|
||||
|
||||
/* u2_cs_init():
|
||||
**
|
||||
** Initialize slot to empty.
|
||||
*/
|
||||
void
|
||||
u2_cs_init(u2_ray lot_r);
|
||||
|
||||
/* u2_cs_lose():
|
||||
**
|
||||
** Release all resources in and under slot (but not slot itself).
|
||||
*/
|
||||
void
|
||||
u2_cs_lose(u2_ray ral_r,
|
||||
u2_ray lot_r); // submit
|
||||
|
||||
/* u2_cs_make():
|
||||
**
|
||||
** Create a new hashtable.
|
||||
*/
|
||||
u2_ray // produce
|
||||
u2_cs_make(u2_ray ral_r);
|
||||
|
||||
/* u2_cs_find():
|
||||
**
|
||||
** Find `sam` for `sel`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak // discover
|
||||
u2_cs_find(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun sam); // retain
|
||||
|
||||
/* u2_cs_find_cell():
|
||||
**
|
||||
** Find `[a b]` for `sel`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak // retain
|
||||
u2_cs_find_cell(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun a, // retain
|
||||
u2_noun b); // retain
|
||||
|
||||
/* u2_cs_find_mixt():
|
||||
**
|
||||
** Find `[a b]` for `sel`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak // retain
|
||||
u2_cs_find_mixt(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
const c3_c* a_c, // retain
|
||||
u2_noun b); // retain
|
||||
|
||||
/* u2_cs_find_trel():
|
||||
**
|
||||
** Find `[a b c]` for `sel`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak // retain
|
||||
u2_cs_find_trel(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun a, // retain
|
||||
u2_noun b, // retain
|
||||
u2_noun c); // retain
|
||||
|
||||
/* u2_cs_find_qual():
|
||||
**
|
||||
** Find `[a b c d]` for `sel`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak // retain
|
||||
u2_cs_find_qual(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun a, // retain
|
||||
u2_noun b, // retain
|
||||
u2_noun c, // retain
|
||||
u2_noun d); // retain
|
||||
|
||||
/* u2_cs_save():
|
||||
**
|
||||
** Save `sam` as `pro` for `sel`. Replace existing `pro`, if any.
|
||||
*/
|
||||
u2_noun // produce
|
||||
u2_cs_save(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun sam, // retain
|
||||
u2_noun pro); // submit
|
||||
|
||||
/* u2_cs_save_cell():
|
||||
**
|
||||
** Save `[a b]` as `pro` for `sel`.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_cs_save_cell(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun a, // retain
|
||||
u2_noun b, // retain
|
||||
u2_noun pro); // transfer
|
||||
|
||||
/* u2_cs_save_mixt():
|
||||
**
|
||||
** Save `[a b]` as `pro` for `sel`.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_cs_save_mixt(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
const c3_c* a_c, // retain
|
||||
u2_noun b, // retain
|
||||
u2_noun pro); // transfer
|
||||
|
||||
/* u2_cs_save_trel():
|
||||
**
|
||||
** Save `[a b c]` as `pro` for `sel`.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_cs_save_trel(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun a, // retain
|
||||
u2_noun b, // retain
|
||||
u2_noun c, // retain
|
||||
u2_noun pro); // transfer
|
||||
|
||||
/* u2_cs_save_qual():
|
||||
**
|
||||
** Save `[a b c d]` as `pro` for `sel`.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_cs_save_qual(u2_ray ral_r,
|
||||
u2_ray lot_r,
|
||||
c3_m sel_m,
|
||||
u2_noun a, // retain
|
||||
u2_noun b, // retain
|
||||
u2_noun c, // retain
|
||||
u2_noun d, // retain
|
||||
u2_noun pro); // transfer
|
107
include/f/chad.h
107
include/f/chad.h
@ -1,107 +0,0 @@
|
||||
/* include/chad.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data types.
|
||||
**/
|
||||
/* u2_loom_pear: overloaded name-value pair.
|
||||
*/
|
||||
typedef struct {
|
||||
/* [nam val]: name-value pair
|
||||
** [u2_none ray]: subtable
|
||||
** [u2_none 0]: empty
|
||||
*/
|
||||
u2_weak nam;
|
||||
u2_weak val;
|
||||
} u2_loom_pear;
|
||||
|
||||
#define u2_pear_nam(per_r) *u2_at(per_r, u2_loom_pear, nam)
|
||||
#define u2_pear_val(per_r) *u2_at(per_r, u2_loom_pear, nam)
|
||||
|
||||
/* u2_loom_chad:
|
||||
**
|
||||
** 16-way mug-powered hashtable. If wun != u2_none,
|
||||
** table is not allocated.
|
||||
*/
|
||||
typedef struct {
|
||||
u2_loom_pear dol_p[16];
|
||||
} u2_loom_chad;
|
||||
|
||||
#define u2_chad_dol(cad_r, i_w) \
|
||||
( (cad_r) + ((i_w) * c3_wiseof(u2_loom_pear)) )
|
||||
|
||||
#define u2_chad_dol_nam(cad_r, i_w) u2_pear_nam(u2_chad_dol(cad_r, i_w))
|
||||
#define u2_chad_dol_val(cad_r, i_w) u2_pear_val(u2_chad_dol(cad_r, i_w))
|
||||
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_ch_init():
|
||||
**
|
||||
** Initialize empty chad.
|
||||
*/
|
||||
void
|
||||
u2_ch_init(u2_ray cad_r);
|
||||
|
||||
/* u2_ch_find():
|
||||
**
|
||||
** Find value for `nam` in `cad`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak
|
||||
u2_ch_find(u2_ray cad_r,
|
||||
u2_noun nam);
|
||||
|
||||
/* u2_ch_find_cell():
|
||||
**
|
||||
** Find value for `[hed tal]` in `cad`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak
|
||||
u2_ch_find_cell(u2_ray cad_r,
|
||||
u2_noun hed,
|
||||
u2_noun tal);
|
||||
|
||||
/* u2_ch_find_mixt():
|
||||
**
|
||||
** Find value for `[hed tal]` in `cad`, or return `u2_none`.
|
||||
*/
|
||||
u2_weak
|
||||
u2_ch_find_mixt(u2_ray cad_r,
|
||||
const c3_c* hed_c,
|
||||
u2_noun tal);
|
||||
|
||||
/* u2_ch_save():
|
||||
**
|
||||
** Save `val` under `nam` in `cad`, allocating in `ral`.
|
||||
** Return `u2_none` iff allocation fails. Asserts on duplicate.
|
||||
*/
|
||||
u2_weak // retain
|
||||
u2_ch_save(u2_ray ral_r,
|
||||
u2_ray cad_r,
|
||||
u2_noun nam, // retain
|
||||
u2_noun val); // retain
|
||||
|
||||
/* u2_ch_save_cell():
|
||||
**
|
||||
** Save `val` under `[hed tal]` in `cad`, allocating in `ral`.
|
||||
** Return `u2_none` iff allocation fails. Asserts on duplicate.
|
||||
*/
|
||||
u2_weak // retain
|
||||
u2_ch_save_cell(u2_ray ral_r,
|
||||
u2_ray cad_r,
|
||||
u2_noun hed, // retain
|
||||
u2_noun tal, // retain
|
||||
u2_noun val); // retain
|
||||
|
||||
/* u2_ch_save_mixt():
|
||||
**
|
||||
** Save `val` under `[hed tal]` in `cad`, allocating in `ral`.
|
||||
** Return `u2_none` iff allocation fails. Asserts on duplicate.
|
||||
**
|
||||
** Caller retains ownership of arguments; callee retains result.
|
||||
*/
|
||||
u2_weak // retain
|
||||
u2_ch_save_mixt(u2_ray ral_r,
|
||||
u2_ray cad_r,
|
||||
const c3_c* hed_c,
|
||||
u2_noun tal, // retain
|
||||
u2_noun val); // retain
|
@ -1,73 +0,0 @@
|
||||
/* include/dash.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data types.
|
||||
**/
|
||||
/* u2_chop: identification in objective battery declaration.
|
||||
**
|
||||
** |?
|
||||
** lef=*term
|
||||
** [std=*term kel=@]
|
||||
** [ven=*term pro=*term kel=@]
|
||||
** [ven=*term pro=*term ver=@ kel=@]
|
||||
** ==
|
||||
*/
|
||||
// typedef u2_noun u2_chop;
|
||||
|
||||
/* u2_clue: programmer's declaration hint
|
||||
**
|
||||
** [bud=*tool cop=*chop pic=*(list &[p=*term q=*tool])]
|
||||
*/
|
||||
// typedef u2_noun u2_clue;
|
||||
|
||||
/* u2_chip: complete battery record (XX: list should be map)
|
||||
**
|
||||
** :* dac=[cop=*chop pic=*(list <[p=*term q=*tool]>)]
|
||||
** bat=*
|
||||
** pet=<~ [axe=*axis led=*chip]>
|
||||
** --
|
||||
*/
|
||||
// typedef u2_noun u2_chip;
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_ds_find(): find chip by core, or none.
|
||||
*/
|
||||
u2_weak // senior
|
||||
u2_ds_find(u2_wire wir_r,
|
||||
u2_noun cor); // retain
|
||||
|
||||
/* u2_ds_mine():
|
||||
**
|
||||
** Register and/or replace core.
|
||||
*/
|
||||
u2_noun // produce
|
||||
u2_ds_mine(u2_wire wir_r,
|
||||
u2_noun clu, // retain
|
||||
u2_noun cor); // submit
|
||||
|
||||
/* u2_ds_look():
|
||||
**
|
||||
** Produce hook formula from core, or u2_none.
|
||||
*/
|
||||
u2_weak // produce
|
||||
u2_ds_look(u2_wire wir_r,
|
||||
u2_noun cor, // retain
|
||||
const c3_c* tam_c); // retain
|
||||
|
||||
/* u2_ds_wipe():
|
||||
**
|
||||
** Clear dashboard.
|
||||
*/
|
||||
void
|
||||
u2_ds_wipe(u2_wire wir_r);
|
||||
|
||||
/* u2_ds_fire():
|
||||
**
|
||||
** Fire formula from core.
|
||||
*/
|
||||
u2_weak // produce
|
||||
u2_ds_fire(u2_wire wir_r,
|
||||
u2_noun cor, // retain
|
||||
const c3_c* tam_c); // retain
|
430
include/f/funj.h
430
include/f/funj.h
@ -1,430 +0,0 @@
|
||||
/* include/funj.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/** Various nouns.
|
||||
**/
|
||||
typedef u2_noun u2_bank;
|
||||
typedef u2_noun u2_cord;
|
||||
typedef u2_noun u2_door;
|
||||
typedef u2_noun u2_gene;
|
||||
typedef u2_noun u2_home;
|
||||
typedef u2_noun u2_init;
|
||||
typedef u2_noun u2_menu;
|
||||
typedef u2_noun u2_plan;
|
||||
typedef u2_noun u2_plot;
|
||||
typedef u2_noun u2_prop;
|
||||
typedef u2_noun u2_rack;
|
||||
typedef u2_noun u2_rung;
|
||||
typedef u2_noun u2_rope;
|
||||
typedef u2_noun u2_spec;
|
||||
typedef u2_noun u2_tack;
|
||||
typedef u2_noun u2_type;
|
||||
typedef u2_noun u2_prep;
|
||||
typedef u2_noun u2_dump;
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Miscellaneous operators - all old.
|
||||
**/
|
||||
/* u2_fj_op_add():
|
||||
**
|
||||
** Produce the sum of (a) and (b).
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_add(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_fj_op_con():
|
||||
**
|
||||
** Produce (a | b).
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_con(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_fj_op_dec():
|
||||
**
|
||||
** Produce (atom - 1), or bull if (atom) is 0.
|
||||
*/
|
||||
u2_weak
|
||||
u2_fj_op_dec(u2_wire wir_r,
|
||||
u2_atom atom);
|
||||
|
||||
/* u2_fj_op_div():
|
||||
**
|
||||
** Produce (b / a), or bull if (a) is 0.
|
||||
*/
|
||||
u2_weak
|
||||
u2_fj_op_div(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_fj_op_glu():
|
||||
**
|
||||
** Concatenate atomic strings `a` and `b`.
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_glu(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_fj_op_inc():
|
||||
**
|
||||
** Produce (atom + 1).
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_inc(u2_wire wir_r,
|
||||
u2_atom atom);
|
||||
|
||||
/* u2_fj_op_log():
|
||||
**
|
||||
** Produce the lowest m_log such that (1 << m_log) > m.
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_log(u2_wire wir_r,
|
||||
u2_atom atom);
|
||||
|
||||
/* u2_fj_op_lsh():
|
||||
**
|
||||
** Produce (b << a).
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_lsh(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_fj_op_peg():
|
||||
**
|
||||
** Concatenate (twig_a) above (twig_b).
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_peg(u2_wire wir_r,
|
||||
u2_atom twig_a,
|
||||
u2_atom twig_b);
|
||||
|
||||
/* u2_fj_op_rsh():
|
||||
**
|
||||
** Produce (b >> a).
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_op_rsh(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_fj_op_sub():
|
||||
**
|
||||
** Produce (b - a), or bull if (a > b).
|
||||
*/
|
||||
u2_weak
|
||||
u2_fj_op_sub(u2_wire wir_r,
|
||||
u2_atom a,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_fj_op_tip():
|
||||
**
|
||||
** Produce the root of (twig) - 2 or 3; o4 bull if (twig) is 1.
|
||||
*/
|
||||
u2_weak
|
||||
u2_fj_op_tip(u2_atom twig);
|
||||
|
||||
/* u2_fj_op_tap():
|
||||
**
|
||||
** Produce (twig) with the root bit removed, or bull if (twig) is 1.
|
||||
*/
|
||||
u2_weak
|
||||
u2_fj_op_tap(u2_wire wir_r,
|
||||
u2_atom twig);
|
||||
|
||||
/** Lists.
|
||||
**/
|
||||
/* u2_fj_list_cat(): concatenate list.
|
||||
*/
|
||||
u2_list
|
||||
u2_fj_list_cat(u2_wire wir_r,
|
||||
u2_list lit,
|
||||
u2_list lus);
|
||||
|
||||
/* u2_fj_list_flip(): invert list.
|
||||
*/
|
||||
u2_list
|
||||
u2_fj_list_flip(u2_wire wir_r,
|
||||
u2_list lit);
|
||||
|
||||
/* u2_fj_list_len(): length of list.
|
||||
*/
|
||||
c3_w
|
||||
u2_fj_list_len(u2_wire wir_r,
|
||||
u2_list lit);
|
||||
|
||||
/** Pools (sets).
|
||||
**/
|
||||
/* u2_fj_pool_ok(): sanity test for pool.
|
||||
*/
|
||||
c3_t
|
||||
u2_fj_pool_ok(u2_pool pool);
|
||||
|
||||
/* u2_fj_pool_in():
|
||||
**
|
||||
** Return 1 iff (pig) is in (pool).
|
||||
*/
|
||||
c3_t
|
||||
u2_fj_pool_in(u2_noun pig,
|
||||
u2_pool pool);
|
||||
|
||||
/* u2_fj_pool_add():
|
||||
**
|
||||
** Produce a version of (pool_sub) which includes (pig).
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_pool_add(u2_wire wir_r,
|
||||
u2_noun pig,
|
||||
u2_pool pool_sub);
|
||||
|
||||
/* u2_fj_pool_list():
|
||||
**
|
||||
** Convert (pool) to a pseudo-randomly sorted list,
|
||||
** prepending to (list).
|
||||
*/
|
||||
u2_list
|
||||
u2_fj_pool_list(u2_wire wir_r,
|
||||
u2_list list,
|
||||
u2_pool pool);
|
||||
|
||||
/* u2_fj_pool_cat():
|
||||
**
|
||||
** Produce a version of (pool_b) which includes all entries
|
||||
** in (pool_a).
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_pool_cat(u2_wire wir_r,
|
||||
u2_pool pool_a,
|
||||
u2_pool pool_b);
|
||||
|
||||
/* u2_fj_pool_at():
|
||||
**
|
||||
** Return path to node of (pig) in (pool), under (axe); or 0.
|
||||
*/
|
||||
u2_atom
|
||||
u2_fj_pool_at(u2_wire wir_r,
|
||||
u2_noun pig_in,
|
||||
u2_atom axe,
|
||||
u2_pool pool);
|
||||
|
||||
/** Books (associative arrays).
|
||||
**/
|
||||
/* u2_fj_book_is():
|
||||
**
|
||||
** Return 1 iff (noun) is a book.
|
||||
*/
|
||||
c3_t
|
||||
u2_fj_book_is(u2_noun book);
|
||||
|
||||
/* u2_fj_book_in():
|
||||
**
|
||||
** Return 1 iff (tag_in) is in (book).
|
||||
*/
|
||||
c3_t
|
||||
u2_fj_book_in(u2_noun tag_in,
|
||||
u2_book book);
|
||||
|
||||
/* u2_fj_book_get():
|
||||
**
|
||||
** Produce the dog in (book) matching (tag_get), or u2_none.
|
||||
*/
|
||||
u2_weak
|
||||
u2_fj_book_get(u2_noun tag_get,
|
||||
u2_book book);
|
||||
|
||||
/* u2_fj_book_add():
|
||||
**
|
||||
** Produce a new book which adds (tag_add dog_add) to (book).
|
||||
** Replace old dog, if any.
|
||||
*/
|
||||
u2_book
|
||||
u2_fj_book_add(u2_wire wir_r,
|
||||
u2_noun tag_add,
|
||||
u2_noun dog_add,
|
||||
u2_book book);
|
||||
|
||||
/* u2_fj_book_add_list():
|
||||
**
|
||||
** Produce a new book which adds all (tag dog) cells in
|
||||
** (list) to (book). Replace old dog, if any.
|
||||
*/
|
||||
u2_book
|
||||
u2_fj_book_add_list(u2_wire wir_r,
|
||||
u2_list list,
|
||||
u2_book book);
|
||||
|
||||
/* u2_fj_book_list():
|
||||
**
|
||||
** Convert (book) to a pseudo-randomly sorted list of (tag dog)
|
||||
** cells, prepending to (list).
|
||||
*/
|
||||
u2_list
|
||||
u2_fj_book_list(u2_wire wir_r,
|
||||
u2_list list,
|
||||
u2_book book);
|
||||
|
||||
/** Parsing.
|
||||
**/
|
||||
/* u2_fj_watt():
|
||||
**
|
||||
** Convert `zar`, a text atom, to a gene.
|
||||
*/
|
||||
u2_gene
|
||||
u2_fj_watt(u2_wire wir_r,
|
||||
u2_noun zar);
|
||||
|
||||
/** Plow (Watt compilation).
|
||||
**/
|
||||
/* u2_fj_plow_make():
|
||||
**
|
||||
** Not verifying type correctness, compile to formula.
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_plow_make(u2_wire wir_r,
|
||||
u2_type sut,
|
||||
u2_gene gen);
|
||||
|
||||
/* u2_fj_plow_play():
|
||||
**
|
||||
** Not verifying type correctness, infer product type.
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_plow_play(u2_wire wir_r,
|
||||
u2_type sut,
|
||||
u2_gene gen);
|
||||
|
||||
/* u2_fj_plow_show():
|
||||
**
|
||||
** Verify type correctness.
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_plow_show(u2_wire wir_r,
|
||||
u2_type sut,
|
||||
u2_gene gen);
|
||||
|
||||
/* u2_fj_plow_pass():
|
||||
**
|
||||
** Verifying type correctness, compile to formula.
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_plow_pass(u2_wire wir_r,
|
||||
u2_type sut,
|
||||
u2_gene gen);
|
||||
|
||||
/* u2_fj_plow_shop():
|
||||
**
|
||||
** Verifying type correctness, infer product type.
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_plow_shop(u2_wire wir_r,
|
||||
u2_type sut,
|
||||
u2_gene gen);
|
||||
|
||||
/* u2_fj_plow_wish():
|
||||
**
|
||||
** Not verifying type correctness, compile and infer.
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_plow_wish(u2_wire wir_r,
|
||||
u2_type sut,
|
||||
u2_gene gen);
|
||||
|
||||
/* u2_fj_plow_mill():
|
||||
**
|
||||
** Verifying type correctness, compile and infer.
|
||||
*/
|
||||
u2_noun
|
||||
u2_fj_plow_mill(u2_wire wir_r,
|
||||
u2_type sut,
|
||||
u2_gene gen);
|
||||
|
||||
/** Prep and pump (prettyprinting).
|
||||
**/
|
||||
/* u2_fj_prep_textual():
|
||||
**
|
||||
** Prep with a text bias; fall back to decimal.
|
||||
*/
|
||||
u2_prep
|
||||
u2_fj_prep_textual(u2_wire wir_r,
|
||||
u2_atom atom);
|
||||
|
||||
/* u2_fj_prep_decimal():
|
||||
**
|
||||
** Prep a decimal value.
|
||||
*/
|
||||
u2_prep
|
||||
u2_fj_prep_decimal(u2_wire wir_r,
|
||||
u2_atom atom);
|
||||
|
||||
/* u2_fj_prep_heximal():
|
||||
**
|
||||
** Prep a hexadecimal value, with 0x.
|
||||
*/
|
||||
u2_prep
|
||||
u2_fj_prep_heximal(u2_wire wir_r,
|
||||
u2_atom atom);
|
||||
|
||||
/* u2_fj_prep_hexinal():
|
||||
**
|
||||
** Prep a heximal value, without 0x.
|
||||
*/
|
||||
u2_prep
|
||||
u2_fj_prep_hexinal(u2_wire wir_r,
|
||||
u2_atom atom);
|
||||
|
||||
/* u2_fj_prep_noun():
|
||||
**
|
||||
** Convert (noun) to a prep, which is
|
||||
**
|
||||
** (text)
|
||||
** | (.glue *prep)
|
||||
** | (.nail *prep)
|
||||
*/
|
||||
u2_prep
|
||||
u2_fj_prep_noun(u2_wire wir_r,
|
||||
u2_noun noun);
|
||||
|
||||
/* u2_fj_prep_close():
|
||||
**
|
||||
** Prep a list of preps, in (xb_a, xb_b).
|
||||
*/
|
||||
u2_prep
|
||||
u2_fj_prep_close(u2_wire wir_r,
|
||||
c3_y xb_a,
|
||||
c3_y xb_b,
|
||||
u2_list gah);
|
||||
|
||||
/* u2_fj_pump_dump():
|
||||
**
|
||||
** Convert (prep) to a dump, printing (cols) wide.
|
||||
*/
|
||||
u2_dump
|
||||
u2_fj_pump_dump(u2_wire wir_r,
|
||||
c3_w xw_cols,
|
||||
u2_prep prep);
|
||||
|
||||
/* u2_err():
|
||||
**
|
||||
** Print (nopt) with (caption), using (wir).
|
||||
*/
|
||||
void
|
||||
u2_err(u2_wire wir_r,
|
||||
const c3_c* cl_caption,
|
||||
u2_weak noun);
|
||||
|
||||
/* u2_burp():
|
||||
**
|
||||
** Print (prep) with (caption), using (wir).
|
||||
*/
|
||||
void
|
||||
u2_burp(u2_wire wir_r,
|
||||
const c3_c* cl_caption,
|
||||
u2_prep prep);
|
@ -1,44 +0,0 @@
|
||||
/* include/hevn.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u2_pryr: takes a path and produces a unit.
|
||||
*/
|
||||
typedef u2_noun (*u2_pryr)(u2_noun);
|
||||
|
||||
/* u2_loom_hevn: global namespace control structure.
|
||||
*/
|
||||
typedef struct _u2_loom_hevn {
|
||||
/* Don't set this unless you know what you're doing.
|
||||
*/
|
||||
u2_pryr god;
|
||||
|
||||
/* Mock gate stack. Pop the stack when executing.
|
||||
**
|
||||
** Each entry in this list is a crash-only gate. If the
|
||||
** list is empty, we are in kernel mode & god is active.
|
||||
*/
|
||||
u2_noun lad;
|
||||
} u2_loom_hevn;
|
||||
|
||||
#define u2_hevx_at(hev_r, wof) (*u2_at(hev_r, u2_loom_hevn, wof))
|
||||
#define u2_hevx_be(hev_r, ite, wof) (*u2_be(hev_r, u2_loom_hevn, ite, wof))
|
||||
|
||||
#define u2_hevn_at(wof) u2_hevx_at(u2_wire_hev_r(u2_Wire), wof)
|
||||
#define u2_hevn_be(ite, wof) u2_hevx_be(u2_wire_hev_r(u2_Wire), ite, wof)
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Lifecycle.
|
||||
**/
|
||||
/* u2_hv_init(): initialize state.
|
||||
*/
|
||||
u2_ray
|
||||
u2_hv_init(u2_ray wir_r);
|
||||
|
||||
/* u2_hv_mark(): mark heaven.
|
||||
*/
|
||||
c3_w
|
||||
u2_hv_mark();
|
333
include/f/host.h
333
include/f/host.h
@ -1,333 +0,0 @@
|
||||
/* include/host.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Macros.
|
||||
**/
|
||||
/* Symbol composition. Horrid.
|
||||
*/
|
||||
# define _j2_xd(x) j2_##x##_d
|
||||
# define _j2_xm(x) j2_##x##_m
|
||||
# define _j2_xmc(x) j2_##x##_mc
|
||||
# define _j2_xmy(x) j2_##x##_my
|
||||
# define _j2_xmx(x) j2_##x##_mx
|
||||
# define _j2_xmk(x) j2_##x##_mk
|
||||
# define _j2_xmi(x) j2_##x##_mi
|
||||
# define _j2_xmj(x) j2_##x##_jets
|
||||
# define _j2_xmd(x) j2_##x##_drivers
|
||||
# define _j2_xp(p, x) j2_##x##_p_##p
|
||||
# define _j2_xpc(p, x) j2_##x##_pc_##p
|
||||
# define _j2_xss(x) #x
|
||||
# define _j2_xs(x) _j2_xss(x)
|
||||
|
||||
# define _j2_qd(x) _j2_xd(x)
|
||||
# define _j2_qm(x) _j2_xm(x)
|
||||
# define _j2_qmc(x) _j2_xmc(x)
|
||||
# define _j2_qmy(x) _j2_xmy(x)
|
||||
# define _j2_qmx(x) _j2_xmx(x)
|
||||
# define _j2_qmi(x) _j2_xmi(x)
|
||||
# define _j2_qmk(x) _j2_xmk(x)
|
||||
# define _j2_qmd(x) _j2_xmd(x)
|
||||
# define _j2_qmj(x) _j2_xmj(x)
|
||||
# define _j2_qp(p, x) _j2_xp(p, x)
|
||||
# define _j2_qpc(p, x) _j2_xpc(p, x)
|
||||
|
||||
# define _j2_a(a) a
|
||||
# define _j2_ab(a, b) a##__##b
|
||||
# define _j2_abc(a, b, c) a##__##b##__##c
|
||||
# define _j2_abcd(a, b, c, d) a##__##b##__##c##__##d
|
||||
# define _j2_abcde(a, b, c, d, e) a##__##b##__##c##__##d##__##e
|
||||
|
||||
# define j2_sa(a) _j2_xs(_j2_a(a))
|
||||
# define j2_sb(a, b) _j2_xs(_j2_ab(a, b))
|
||||
# define j2_sc(a, b, c) _j2_xs(_j2_abc(a, b, c))
|
||||
# define j2_sd(a, b, c, d) _j2_xs(_j2_abcd(a, b, c, d))
|
||||
# define j2_se(a, b, c, d, e) _j2_xs(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_da(a) _j2_qd(_j2_a(a))
|
||||
# define j2_db(a, b) _j2_qd(_j2_ab(a, b))
|
||||
# define j2_dc(a, b, c) _j2_qd(_j2_abc(a, b, c))
|
||||
# define j2_dd(a, b, c, d) _j2_qd(_j2_abcd(a, b, c, d))
|
||||
# define j2_de(a, b, c, d, e) _j2_qd(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_ma(a) _j2_qm(_j2_a(a))
|
||||
# define j2_mb(a, b) _j2_qm(_j2_ab(a, b))
|
||||
# define j2_mc(a, b, c) _j2_qm(_j2_abc(a, b, c))
|
||||
# define j2_md(a, b, c, d) _j2_qm(_j2_abcd(a, b, c, d))
|
||||
# define j2_me(a, b, c, d, e) _j2_qm(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_mac(a) _j2_qmc(_j2_a(a))
|
||||
# define j2_mbc(a, b) _j2_qmc(_j2_ab(a, b))
|
||||
# define j2_mcc(a, b, c) _j2_qmc(_j2_abc(a, b, c))
|
||||
# define j2_mdc(a, b, c, d) _j2_qmc(_j2_abcd(a, b, c, d))
|
||||
# define j2_mec(a, b, c, d, e) _j2_qmc(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_may(a) _j2_qmy(_j2_a(a))
|
||||
# define j2_mby(a, b) _j2_qmy(_j2_ab(a, b))
|
||||
# define j2_mcy(a, b, c) _j2_qmy(_j2_abc(a, b, c))
|
||||
# define j2_mdy(a, b, c, d) _j2_qmy(_j2_abcd(a, b, c, d))
|
||||
# define j2_mey(a, b, c, d, e) _j2_qmy(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_max(a) _j2_qmx(_j2_a(a))
|
||||
# define j2_mbx(a, b) _j2_qmx(_j2_ab(a, b))
|
||||
# define j2_mcx(a, b, c) _j2_qmx(_j2_abc(a, b, c))
|
||||
# define j2_mdx(a, b, c, d) _j2_qmx(_j2_abcd(a, b, c, d))
|
||||
# define j2_mex(a, b, c, d, e) _j2_qmx(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_mai(a) _j2_qmi(_j2_a(a))
|
||||
# define j2_mbi(a, b) _j2_qmi(_j2_ab(a, b))
|
||||
# define j2_mci(a, b, c) _j2_qmi(_j2_abc(a, b, c))
|
||||
# define j2_mdi(a, b, c, d) _j2_qmi(_j2_abcd(a, b, c, d))
|
||||
# define j2_mei(a, b, c, d, e) _j2_qmi(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_mak(a) _j2_qmk(_j2_a(a))
|
||||
# define j2_mbk(a, b) _j2_qmk(_j2_ab(a, b))
|
||||
# define j2_mck(a, b, c) _j2_qmk(_j2_abc(a, b, c))
|
||||
# define j2_mdk(a, b, c, d) _j2_qmk(_j2_abcd(a, b, c, d))
|
||||
# define j2_mek(a, b, c, d, e) _j2_qmk(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_maj(a) _j2_qmj(_j2_a(a))
|
||||
# define j2_mbj(a, b) _j2_qmj(_j2_ab(a, b))
|
||||
# define j2_mcj(a, b, c) _j2_qmj(_j2_abc(a, b, c))
|
||||
# define j2_mdj(a, b, c, d) _j2_qmj(_j2_abcd(a, b, c, d))
|
||||
# define j2_mej(a, b, c, d, e) _j2_qmj(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_mad(a) _j2_qmd(_j2_a(a))
|
||||
# define j2_mbd(a, b) _j2_qmd(_j2_ab(a, b))
|
||||
# define j2_mcd(a, b, c) _j2_qmd(_j2_abc(a, b, c))
|
||||
# define j2_mdd(a, b, c, d) _j2_qmd(_j2_abcd(a, b, c, d))
|
||||
# define j2_med(a, b, c, d, e) _j2_qmd(_j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_pa(a, p) _j2_qp(p, _j2_a(a))
|
||||
# define j2_pb(a, b, p) _j2_qp(p, _j2_ab(a, b))
|
||||
# define j2_pc(a, b, c, p) _j2_qp(p, _j2_abc(a, b, c))
|
||||
# define j2_pd(a, b, c, d, p) _j2_qp(p, _j2_abcd(a, b, c, d))
|
||||
# define j2_pe(a, b, c, d, e, p) _j2_qp(p, _j2_abcde(a, b, c, d, e))
|
||||
|
||||
# define j2_pac(a, p) _j2_qpc(p, _j2_a(a))
|
||||
# define j2_pbc(a, b, p) _j2_qpc(p, _j2_ab(a, b))
|
||||
# define j2_pcc(a, b, c, p) _j2_qpc(p, _j2_abc(a, b, c))
|
||||
# define j2_pdc(a, b, c, d, p) _j2_qpc(p, _j2_abcd(a, b, c, d))
|
||||
# define j2_pec(a, b, c, d, e, p) _j2_qpc(p, _j2_abcde(a, b, c, d, e))
|
||||
|
||||
/** Types.
|
||||
**/
|
||||
/* u2_nash: cash-hash.
|
||||
*/
|
||||
struct u2_nash;
|
||||
/* u2_ho_fun: actual function.
|
||||
*/
|
||||
typedef u2_noun (*u2_ho_fun)(u2_noun cor);
|
||||
|
||||
/* Jet to hash selector.
|
||||
*/
|
||||
# define u2_jet_fun_m(jet_j) (0x7fffffff & (c3_w)(c3_p)(jet_j))
|
||||
|
||||
/* u2_ho_state: jet state beans
|
||||
*/
|
||||
typedef c3_w u2_ho_state;
|
||||
|
||||
# define u2_jet_live 0x1 // live: C jet active
|
||||
# define u2_jet_test 0x2 // test: C jet must be tested
|
||||
# define u2_jet_memo 0x4 // memo: memoize, even if jet is dead
|
||||
# define u2_jet_leak 0x8 // leak: check for memory leaks
|
||||
# define u2_jet_dead 0
|
||||
|
||||
/* u2_ho_jet: a C function, per formula.
|
||||
*/
|
||||
typedef struct {
|
||||
/* Function control string - finds formula in core. Declared.
|
||||
**
|
||||
** ".@" | "hook"
|
||||
*/
|
||||
const c3_c* fcs_c;
|
||||
|
||||
/* Invocation model. Declared:
|
||||
**
|
||||
** c3__lite // does not bail
|
||||
** c3__hevy // may bail
|
||||
*/
|
||||
c3_m vok_m;
|
||||
|
||||
/* C function, on core. Declared.
|
||||
*/
|
||||
u2_noun (*fun_f)(u2_noun cor);
|
||||
|
||||
/* State - see above. Declared, but may change dynamically.
|
||||
*/
|
||||
u2_ho_state sat_s;
|
||||
|
||||
/* chip: battery identifier. Computed (declare u2_none).
|
||||
*/
|
||||
u2_noun xip;
|
||||
|
||||
/* Tool: Nock formula. Computed (declare u2_none).
|
||||
*/
|
||||
u2_noun fol;
|
||||
|
||||
/* Custom memoization key from core. Declared - should reorder.
|
||||
*/
|
||||
u2_noun (*key_f)(u2_noun cor);
|
||||
|
||||
/* Memo selector. Declared, with key function.
|
||||
*/
|
||||
c3_m fun_m;
|
||||
|
||||
/* Axis in battery. Computed (declare 0).
|
||||
*/
|
||||
c3_l axe_l;
|
||||
} u2_ho_jet;
|
||||
|
||||
/* u2_ho_driver: battery driver.
|
||||
*/
|
||||
typedef struct _u2_ho_driver {
|
||||
/* Control string - computed from seals.
|
||||
*/
|
||||
const c3_c* cos_c;
|
||||
|
||||
/* Function/formula jet array. Null `fcs` terminates.
|
||||
*/
|
||||
u2_ho_jet *fan_j;
|
||||
|
||||
/* Subdriver array, if any.
|
||||
*/
|
||||
struct _u2_ho_driver* sub_d;
|
||||
|
||||
/* Mug: short hash of chip, or 0. Must match if set.
|
||||
*/
|
||||
c3_w mug_w;
|
||||
|
||||
/* chip: battery identifier, from shed.
|
||||
*/
|
||||
u2_noun xip;
|
||||
|
||||
/* Cache from axe to jet.
|
||||
*/
|
||||
struct u2_nash* jax_s;
|
||||
} u2_ho_driver;
|
||||
|
||||
/* u2_ho_hangar: driver system.
|
||||
*/
|
||||
typedef struct _u2_ho_hangar {
|
||||
/* Cache from chip to driver.
|
||||
*/
|
||||
struct u2_nash* bad_s;
|
||||
|
||||
/* Next hangar in stack.
|
||||
*/
|
||||
struct _u2_ho_hangar *nex_h;
|
||||
} u2_ho_hangar;
|
||||
|
||||
/** Globals.
|
||||
**/
|
||||
extern u2_ho_driver *HostDriverBase[];
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_ho_push():
|
||||
**
|
||||
** Push a driver hangar (corresponding to a jet shed).
|
||||
*/
|
||||
void
|
||||
u2_ho_push(void);
|
||||
|
||||
/* u2_ho_popp():
|
||||
**
|
||||
** Pop a driver hangar.
|
||||
*/
|
||||
void
|
||||
u2_ho_popp(void);
|
||||
|
||||
/* u2_ho_klar():
|
||||
**
|
||||
** Clear and release all hangars.
|
||||
*/
|
||||
void
|
||||
u2_ho_klar(void);
|
||||
|
||||
/* u2_ho_cstring(): return malloced control string for `xip`.
|
||||
*/
|
||||
c3_c* // transfer
|
||||
u2_ho_cstring(u2_noun xip); // retain
|
||||
|
||||
/* u2_ho_warn():
|
||||
**
|
||||
** Report a warning at file and line. This is assumed
|
||||
** to have no semantic effect and negligible cost.
|
||||
*/
|
||||
void
|
||||
u2_ho_warn(const c3_c* fil_c,
|
||||
c3_w lyn_w);
|
||||
|
||||
# define u2_ho_warn_here() u2_ho_warn(__FILE__, __LINE__)
|
||||
|
||||
/* u2_ho_test():
|
||||
**
|
||||
** Report result of jet test on `cor`. `pro` is fast; `vet` is slow.
|
||||
*/
|
||||
void
|
||||
u2_ho_test(u2_ho_jet* jet_j,
|
||||
u2_weak cor, // retain
|
||||
u2_weak sof, // retain
|
||||
u2_weak had); // retain
|
||||
|
||||
/* u2_ho_dive():
|
||||
**
|
||||
** Report compatibility failure in `xip`, with subject `bus`.
|
||||
*/
|
||||
void
|
||||
u2_ho_dive(u2_noun xip, // retain
|
||||
u2_noun bus); // retain
|
||||
|
||||
/* u2_ho_fine():
|
||||
**
|
||||
** Report test execution in `xip`, with subject `bus`.
|
||||
*/
|
||||
void
|
||||
u2_ho_fine(u2_noun xip, // retain
|
||||
u2_noun bus); // retain
|
||||
|
||||
/* u2_ho_use():
|
||||
**
|
||||
** Run a jet. Must be previously verified with u2_ho_nice().
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_ho_use(u2_ho_jet* jet_j, // retain
|
||||
u2_noun cor, // retain
|
||||
u2_noun fol); // retain
|
||||
|
||||
/* u2_ho_nice():
|
||||
**
|
||||
** Verify quickly that a chip's jet supports this core.
|
||||
**
|
||||
** Only the outer battery is assumed to match.
|
||||
*/
|
||||
u2_bean
|
||||
u2_ho_nice(u2_ho_jet* jet_j,
|
||||
u2_noun cor);
|
||||
|
||||
/* u2_ho_punt():
|
||||
**
|
||||
** Apply host nock driver on `xip`, `cor`, `fol`.
|
||||
*/
|
||||
u2_weak
|
||||
u2_ho_punt(u2_noun xip, // retain
|
||||
u2_noun cor, // retain
|
||||
u2_noun fol); // retain
|
||||
|
||||
/* u2_ho_kick():
|
||||
**
|
||||
** Apply host nock driver on `xip`, `cor`, `fol`.
|
||||
*/
|
||||
u2_weak // produce
|
||||
u2_ho_kick(u2_noun xip, // retain
|
||||
u2_noun cor, // retain
|
||||
u2_atom axe); // retain
|
||||
|
||||
/* u2_ho_kicq(): as u2_ho_kick(), but mocky.
|
||||
*/
|
||||
u2_noun // produce
|
||||
u2_ho_kicq(u2_noun xip, // retain
|
||||
u2_noun cor, // retain
|
||||
u2_atom axe, // retain
|
||||
u2_bean *pon); // retain
|
970
include/f/loom.h
970
include/f/loom.h
@ -1,970 +0,0 @@
|
||||
/* include/loom.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Global variables and definitions.
|
||||
**/
|
||||
# define Loom ((c3_w *)U2_OS_LoomBase)
|
||||
# define LoomBits U2_OS_LoomBits
|
||||
# define LoomSize (1 << LoomBits)
|
||||
# define HalfBits (U2_OS_LoomBits - 1)
|
||||
# define HalfSize (1 << HalfBits)
|
||||
# define HalfEnd (HalfSize - 1)
|
||||
# define LoomPageWords 12 // 16K pages
|
||||
# define LoomAllPages (1 << 16) // 65536 pages
|
||||
# define LoomHalfPages (1 << 15) // 32768 pages
|
||||
# define LoomVersion 0xdeafbee
|
||||
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u2_life: page state.
|
||||
*/
|
||||
typedef enum {
|
||||
u2_page_none = 0, // page is not mapped
|
||||
u2_page_slow = 1, // page not yet loaded (not used)
|
||||
u2_page_neat = 2, // page is unmodified
|
||||
u2_page_tref = 3 // page is dirty
|
||||
} u2_page_life;
|
||||
|
||||
typedef struct {
|
||||
u2_page_life lif_e: 2; // page state
|
||||
c3_w mug_e: 30; // 30-bit mug
|
||||
} u2_chit;
|
||||
|
||||
/* u2_chef: memory control, per whole, on disk.
|
||||
*/
|
||||
typedef struct _u2_chef { // control image
|
||||
c3_d ent_d; // event number
|
||||
c3_w ven_w; // version
|
||||
c3_w bot_w; // offset in loom
|
||||
c3_w pgs_w; // pages saved
|
||||
} u2_chef;
|
||||
|
||||
/* u2_cheg: mapped segment. always grows upward for now.
|
||||
*/
|
||||
typedef struct _u2_cheg {
|
||||
c3_c* nam_c; // name as a file
|
||||
struct _u2_cheg* nex_u; // linked in list
|
||||
c3_w bot_w; // beginning page
|
||||
c3_w len_w; // length in pages
|
||||
c3_w pgs_w; // pages in used prefix
|
||||
c3_i ctl_i; // control file
|
||||
c3_i dat_i; // data file
|
||||
} u2_cheg;
|
||||
|
||||
# ifdef U2_GLOBAL
|
||||
/* Memory control structures.
|
||||
*/
|
||||
volatile u2_chit LoomChem[LoomAllPages]; // memory
|
||||
|
||||
/* Direct segment pointers.
|
||||
*/
|
||||
u2_cheg LoomSegmentD = { "d" };
|
||||
u2_cheg LoomSegmentC = { "c", &LoomSegmentD };
|
||||
u2_cheg LoomSegmentB = { "b", &LoomSegmentC };
|
||||
u2_cheg LoomSegmentA = { "a", &LoomSegmentB };
|
||||
|
||||
/* Critical-section bit, for signal handlers.
|
||||
*/
|
||||
volatile uint32_t u2_Critical;
|
||||
|
||||
# else
|
||||
extern uint32_t LoomFrame;
|
||||
extern volatile sig_atomic_t LoomStop;
|
||||
extern volatile sig_atomic_t LoomIntr;
|
||||
extern volatile uint32_t u2_Critical;
|
||||
|
||||
extern volatile u2_chit LoomChem[LoomAllPages];
|
||||
extern u2_cheg LoomSegmentA, LoomSegmentB, LoomSegmentC, LoomSegmentD;
|
||||
# endif
|
||||
|
||||
# define LoomFrameMax 8192
|
||||
# define LoomSink \
|
||||
(LoomFrame == LoomFrameMax ? (LoomStop = 1) : LoomFrame++)
|
||||
# define LoomRise \
|
||||
(LoomFrame--)
|
||||
|
||||
// # define LoomFold
|
||||
|
||||
/** Data types.
|
||||
**/
|
||||
/** Bitfields. Assumes HalfBits == 28 (the maximum).
|
||||
***
|
||||
*** u2_nit - word offset in loom
|
||||
*** &&&&:28a
|
||||
*** a: offset from loom
|
||||
***
|
||||
*** u2_ray - word offset on beam
|
||||
*** &&&:1a:28b
|
||||
*** a: beam (& = low = west, | = high = east)
|
||||
*** b: offset on beam
|
||||
***
|
||||
*** u2_noun - noun
|
||||
*** ?(u2_cat, u2_dog)
|
||||
*** 1a:31b
|
||||
*** a: cat if 0, dog if 1
|
||||
***
|
||||
*** u2_weak - noun
|
||||
*** ?(noun, u2_none)
|
||||
***
|
||||
*** u2_dog - indirect atom or cell
|
||||
*** ?(u2_pom, u2_pug)
|
||||
*** |:29a:1b:1c
|
||||
*** a: ray to data
|
||||
*** b: boxed bit
|
||||
***
|
||||
*** u2_cat - direct atom
|
||||
*** &:31a
|
||||
*** a: unsigned integer
|
||||
***
|
||||
*** u2_pom - indirect cell
|
||||
*** |:29a:1b:&
|
||||
*** a: ray to struct u2_cell
|
||||
*** b: allocated bit (0 == fixed, 1 == allocated)
|
||||
***
|
||||
*** u2_pug - indirect atom
|
||||
*** |:29a:1b:|
|
||||
*** a: ray to struct u2_atom
|
||||
*** b: allocated bit (0 == fixed, 1 == allocated)
|
||||
**/
|
||||
typedef c3_w u2_nit;
|
||||
typedef c3_w u2_ray;
|
||||
typedef c3_w u2_fly;
|
||||
typedef c3_w u2_dog;
|
||||
typedef c3_w u2_cat;
|
||||
typedef c3_w u2_pug;
|
||||
|
||||
/** Structures.
|
||||
***
|
||||
**/
|
||||
/* u2_atom, u2_cell: logical atom and cell structures.
|
||||
**
|
||||
** Not referenced as such, since in ray space.
|
||||
*/
|
||||
typedef struct _u2_loom_atom {
|
||||
c3_w mug_w;
|
||||
c3_w len_w;
|
||||
c3_w buf_w[0];
|
||||
} u2_loom_atom;
|
||||
|
||||
typedef struct _u2_loom_cell {
|
||||
c3_w mug_w;
|
||||
u2_ray hed_r;
|
||||
u2_ray tel_r;
|
||||
} u2_loom_cell;
|
||||
|
||||
/** Basic macros.
|
||||
**/
|
||||
/** Bitfield unpacking. See above.
|
||||
**/
|
||||
# define u2_ray_a(ray) ( (ray) >> HalfBits )
|
||||
# define u2_ray_b(ray) ( (ray) & ((1 << HalfBits) - 1) )
|
||||
|
||||
# define u2_fly_a(fly) ( (fly) >> 31 )
|
||||
|
||||
# define u2_dog_a(dog) ( ((dog) &~ (1 << 31)) >> 2 )
|
||||
# define u2_dog_b(dog) ( 1 & ((dog) >> 1) )
|
||||
# define u2_dog_c(dog) ( 1 & (dog) )
|
||||
|
||||
# define u2_pom_a(pom) u2_dog_a(pom)
|
||||
# define u2_pom_b(pom) u2_dog_b(pom)
|
||||
# define u2_pug_a(pug) u2_dog_a(pug)
|
||||
# define u2_pug_b(pug) u2_dog_b(pug)
|
||||
|
||||
# define u2_fly_is_cat(fly) ( !u2_fly_a(fly) )
|
||||
# define u2_fly_is_dog(fly) ( u2_fly_a(fly) )
|
||||
|
||||
# define u2_dog_is_pom(dog) ( !u2_dog_c(dog) )
|
||||
# define u2_dog_is_pug(dog) ( u2_dog_c(dog) )
|
||||
|
||||
# define u2_dog_is_all(dog) ( u2_dog_b(dog) )
|
||||
|
||||
# define u2_fly_is_atom(a) \
|
||||
(u2_fly_is_cat(a) || u2_dog_is_pug(a))
|
||||
|
||||
|
||||
/** Bitfield packing. See above.
|
||||
**/
|
||||
# define u2_ray_of(a, b) ( ((a) << HalfBits) | (b) )
|
||||
|
||||
# define u2_dog_of(a, b, c) \
|
||||
( (1 << 31) | ((a) << 2) | ((b) << 1) | (c) )
|
||||
|
||||
# define u2_pom_of(a, b) u2_dog_of(a, b, 0)
|
||||
# define u2_pug_of(a, b) u2_dog_of(a, b, 1)
|
||||
|
||||
|
||||
/** Cage reference and geometry.
|
||||
***
|
||||
*** Formally, we are always folded.
|
||||
**/
|
||||
# define u2_ray_fnit(ray) \
|
||||
( u2_ray_a(ray) ? (HalfEnd - u2_ray_b(ray)) : (ray) )
|
||||
# ifdef LoomFold
|
||||
# define u2_ray_nit(ray) u2_ray_fnit(ray)
|
||||
# else
|
||||
# define u2_ray_nit(ray) (ray)
|
||||
# endif
|
||||
|
||||
# define u2_ray_open(tid, tat, das) \
|
||||
( (0 == u2_ray_a(tid)) \
|
||||
? ( (u2_ray_fnit(tid) + (das)) < u2_ray_fnit(tat) ) \
|
||||
: ( (u2_ray_fnit(tat) + (das)) < u2_ray_fnit(tid) ) )
|
||||
|
||||
# define u2_ray_gap(tid, tat) \
|
||||
( (HalfSize - (u2_ray_b(tid) + u2_ray_b(tat))) )
|
||||
|
||||
/* last word of opposite is first word of other. so, in a 4-word loom:
|
||||
**
|
||||
** 0 1 2 3
|
||||
** | | | |
|
||||
** ## ## ## ##
|
||||
** | | | |
|
||||
** 3 2 1 0
|
||||
*/
|
||||
|
||||
# define u2_ray_over(ray, siz_w) \
|
||||
u2_ray_of(!u2_ray_a(ray), (HalfSize - (u2_ray_b(ray) + (siz_w))))
|
||||
|
||||
# define u2_at_nit(nit) (Loom + nit)
|
||||
# define u2_at_ray(ray) u2_at_nit(u2_ray_nit(ray))
|
||||
# define u2_nit_at(ptr_v) (((c3_w *)(ptr_v)) - Loom)
|
||||
|
||||
# ifdef LoomFold
|
||||
# define u2_at_cord(ray, siz) \
|
||||
(u2_ray_a(ray) ? (u2_at_ray(ray) - ((siz) - 1)) : u2_at_ray(ray))
|
||||
# else
|
||||
# define u2_at_cord(ray, siz) u2_at_ray(ray)
|
||||
# endif
|
||||
|
||||
# define u2_aftr(ray, type, field) \
|
||||
((ray) + \
|
||||
( ((c3_w *)&((type *)0)->field) - \
|
||||
((c3_w *)0) ) \
|
||||
)
|
||||
# define u2_fore(ray, type, field) \
|
||||
((ray - 1) - \
|
||||
( ((c3_w *)&((type *)0)->field) - \
|
||||
((c3_w *)0) ) \
|
||||
)
|
||||
|
||||
# define u2_at(ray, type, field) \
|
||||
u2_at_ray(u2_aftr(ray, type, field))
|
||||
# define u2_by(ray, type, field) \
|
||||
u2_at_ray(u2_fore(ray, type, field))
|
||||
|
||||
# define u2_be(ray, type, item, field) \
|
||||
( (item *)(void *)u2_at_ray(u2_aftr(ray, type, field)) )
|
||||
|
||||
# define u2_ray_beam(ray) u2_ray_a(ray)
|
||||
# define u2_ray_point(ray) u2_ray_b(ray)
|
||||
|
||||
# define u2_dog_ray(dog) u2_dog_a(dog)
|
||||
|
||||
# define u2_dog_beam(dog) u2_ray_beam(u2_dog_ray(dog))
|
||||
|
||||
|
||||
/*** Noun structure access.
|
||||
***/
|
||||
# define u2_at_dog_mug(a) u2_at_ray(u2_dog_a(a))
|
||||
|
||||
# define u2_at_pom_hed(a) u2_at_ray((1 + u2_pom_a(a)))
|
||||
# define u2_at_pom_tel(a) u2_at_ray((2 + u2_pom_a(a)))
|
||||
|
||||
# define u2_at_pug_len(a) u2_at_ray((1 + u2_pug_a(a)))
|
||||
# define u2_at_pug_buf(a, b) \
|
||||
u2_at_ray((2 + (b) + u2_pug_a(a)))
|
||||
|
||||
# define u2_atom_word(a, b) \
|
||||
( u2_fly_is_cat(a) ? (b ? 0 : (a)) : *u2_at_pug_buf(a, b) )
|
||||
|
||||
/*** Word axis macros.
|
||||
****
|
||||
**** Use these on axes known to be in 31-bit range.
|
||||
***/
|
||||
/* u2_ax_dep(): number of axis bits.
|
||||
*/
|
||||
# define u2_ax_dep(a_w) (c3_bits_word(a_w) - 1)
|
||||
|
||||
/* u2_ax_cap(): root axis, 2 or 3.
|
||||
*/
|
||||
# define u2_ax_cap(a_w) (0x2 | (a_w >> (u2_ax_dep(a_w) - 1)))
|
||||
|
||||
/* u2_ax_mas(): remainder after cap.
|
||||
*/
|
||||
# define u2_ax_mas(a_w) \
|
||||
( (a_w & ~(1 << u2_ax_dep(a_w))) | (1 << (u2_ax_dep(a_w) - 1)) )
|
||||
|
||||
/* u2_ax_peg(): connect two axes.
|
||||
*/
|
||||
# define u2_ax_peg(a_w, b_w) \
|
||||
( (a_w << u2_ax_dep(b_w)) | (b_w &~ (1 << u2_ax_dep(b_w))) )
|
||||
|
||||
/** Constants and macros.
|
||||
**/
|
||||
/* u2_none:
|
||||
**
|
||||
** An exceptional value, comparable to NaN for floats.
|
||||
*/
|
||||
# define u2_none u2_dog_of(u2_ray_of(0, 0), 0, 0)
|
||||
|
||||
/* Small atoms.
|
||||
*/
|
||||
# define _0 0
|
||||
# define _1 1
|
||||
# define _2 2
|
||||
# define _3 3
|
||||
# define _4 4
|
||||
# define _5 5
|
||||
# define _6 6
|
||||
# define _7 7
|
||||
# define _8 8
|
||||
# define _9 9
|
||||
# define _10 10
|
||||
# define _11 11
|
||||
# define _12 12
|
||||
# define _13 13
|
||||
# define _14 14
|
||||
# define _15 15
|
||||
|
||||
/* Nock operators.
|
||||
*/
|
||||
# define u2_nock_frag 0
|
||||
# define u2_nock_bone 1
|
||||
# define u2_nock_sail 2
|
||||
# define u2_nock_dust 3
|
||||
# define u2_nock_vint 4
|
||||
# define u2_nock_sing 5
|
||||
# define u2_nock_trol 6
|
||||
# define u2_nock_flac 7
|
||||
# define u2_nock_gant 8
|
||||
# define u2_nock_kick 9
|
||||
# define u2_nock_hint 10
|
||||
|
||||
# define u2_nock_0 0
|
||||
# define u2_nock_1 1
|
||||
# define u2_nock_2 2
|
||||
# define u2_nock_3 3
|
||||
# define u2_nock_4 4
|
||||
# define u2_nock_5 5
|
||||
# define u2_nock_6 6
|
||||
# define u2_nock_7 7
|
||||
# define u2_nock_8 8
|
||||
# define u2_nock_9 9
|
||||
# define u2_nock_10 10
|
||||
|
||||
|
||||
/* New (Nock 5) conventional axes for gate call.
|
||||
*/
|
||||
#if 1
|
||||
# define u2_cv_pay 3 // payload
|
||||
# define u2_cv_sam 6 // sample
|
||||
# define u2_cv_sam_1 6
|
||||
# define u2_cv_sam_2 12
|
||||
# define u2_cv_sam_3 13
|
||||
# define u2_cv_sam_4 24
|
||||
# define u2_cv_sam_5 25
|
||||
# define u2_cv_sam_6 26
|
||||
# define u2_cv_sam_12 52
|
||||
# define u2_cv_sam_13 53
|
||||
# define u2_cv_sam_7 27
|
||||
# define u2_cv_con 7 // context
|
||||
# define u2_cv_con_2 14 // context
|
||||
# define u2_cv_con_3 15 // context
|
||||
# define u2_cv_con_sam 30 // sample in gate context
|
||||
# define u2_cv_noc 2 // deprecated
|
||||
# define u2_cv_bat 2 // battery
|
||||
#endif
|
||||
|
||||
/* u2_yes, u2_no, u2_nul;
|
||||
**
|
||||
** Our Martian booleans and list terminator; empty string.
|
||||
*/
|
||||
# define u2_yes 0
|
||||
# define u2_no 1
|
||||
# define u2_nul 0
|
||||
# define u2_blip 0
|
||||
|
||||
/* Tools for Martian booleans.
|
||||
*/
|
||||
# define u2_na(x) (u2_no == (x))
|
||||
# define u2_so(x) (u2_yes == (x))
|
||||
# define u2_say(x) ( (x) ? u2_yes : u2_no )
|
||||
# define u2_not(x) ( (x == u2_yes) ? u2_no : u2_yes )
|
||||
# define u2_and(x, y) ( (u2_so(x) && u2_so(y)) ? u2_yes : u2_no )
|
||||
# define u2_or(x, y) ( (u2_so(x) || u2_so(y)) ? u2_yes : u2_no )
|
||||
|
||||
/** Typedefs.
|
||||
***
|
||||
*** Noun typedefs may reflect usage, structure, or both. Any noun
|
||||
*** typedef is a noun - that is, it may not be (u2_none).
|
||||
**/
|
||||
/* u2_noun:
|
||||
**
|
||||
** A fly which is not u2_none.
|
||||
*/
|
||||
typedef u2_fly u2_noun;
|
||||
|
||||
/* u2_weak:
|
||||
**
|
||||
** A fly which may be (and must be tested for) u2_none.
|
||||
*/
|
||||
typedef u2_fly u2_weak;
|
||||
|
||||
/* u2_atom:
|
||||
**
|
||||
** A noun which is an atom.
|
||||
*/
|
||||
typedef u2_noun u2_atom;
|
||||
|
||||
/* u2_cell:
|
||||
**
|
||||
** A noun which is a cell.
|
||||
*/
|
||||
typedef u2_noun u2_cell;
|
||||
|
||||
/* u2_bean:
|
||||
**
|
||||
** A Martian boolean (0 = yes, 1 = no).
|
||||
*/
|
||||
typedef u2_noun u2_bean;
|
||||
|
||||
/* u2_axis:
|
||||
**
|
||||
** An atomic tree address.
|
||||
*/
|
||||
typedef u2_noun u2_axis;
|
||||
|
||||
/* u2_mote:
|
||||
**
|
||||
** An atom < (1 << 31).
|
||||
*/
|
||||
typedef u2_atom u2_mote;
|
||||
|
||||
/* u2_term:
|
||||
**
|
||||
** A Watt symbol.
|
||||
*/
|
||||
typedef u2_noun u2_term;
|
||||
|
||||
/* u2_list:
|
||||
**
|
||||
** A zero-terminated, tailward list.
|
||||
*/
|
||||
typedef u2_noun u2_list;
|
||||
|
||||
/* u2_tool:
|
||||
**
|
||||
** A valid or presumptive Nock formula.
|
||||
*/
|
||||
typedef u2_noun u2_tool;
|
||||
|
||||
/* u2_pool:
|
||||
**
|
||||
** A set, stored as binary treap by mug.
|
||||
*/
|
||||
typedef u2_noun u2_pool;
|
||||
|
||||
/* u2_book:
|
||||
**
|
||||
** An associative array, stored as binary treap by mug.
|
||||
*/
|
||||
typedef u2_noun u2_book;
|
||||
|
||||
/* u2_unit:
|
||||
**
|
||||
** A conditional (maybe), `[0 n]` or `0`.
|
||||
*/
|
||||
typedef u2_noun u2_unit;
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Lifecycle.
|
||||
**/
|
||||
/* u2_loom_boot():
|
||||
**
|
||||
** Instantiate the loom as a new image.
|
||||
*/
|
||||
void
|
||||
u2_loom_boot(void);
|
||||
|
||||
/* u2_loom_clip():
|
||||
**
|
||||
** Clip top and bottom.
|
||||
*/
|
||||
void
|
||||
u2_loom_clip(c3_w bot_w, c3_w top_w);
|
||||
|
||||
/* u2_loom_load():
|
||||
**
|
||||
** Load the loom from a file.
|
||||
*/
|
||||
u2_bean
|
||||
u2_loom_load(void);
|
||||
|
||||
/* u2_loom_exit():
|
||||
**
|
||||
** Quit out of the loom.
|
||||
*/
|
||||
void
|
||||
u2_loom_exit(void);
|
||||
|
||||
/* u2_loom_save():
|
||||
**
|
||||
** Save the current loom at the current event number.
|
||||
*/
|
||||
u2_bean
|
||||
u2_loom_save(c3_d ent_d);
|
||||
|
||||
/** General.
|
||||
**/
|
||||
|
||||
/* u2_dust():
|
||||
**
|
||||
** Yes iff (a) is a cell.
|
||||
*/
|
||||
#if 0
|
||||
u2_bean
|
||||
u2_dust(u2_noun a)
|
||||
#else
|
||||
# define u2_dust(a) \
|
||||
(u2_fly_is_atom(a) ? u2_no : u2_yes)
|
||||
#endif
|
||||
|
||||
/* u2_frag():
|
||||
**
|
||||
** Return fragment (a) of (b), or u2_none if not applicable.
|
||||
*/
|
||||
u2_weak
|
||||
u2_frag(u2_atom a,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_mean():
|
||||
**
|
||||
** Attempt to deconstruct `a` by axis, noun pairs; 0 terminates.
|
||||
** Axes must be sorted in tree order.
|
||||
*/
|
||||
u2_bean
|
||||
u2_mean(u2_noun a,
|
||||
...);
|
||||
|
||||
/* u2_mug():
|
||||
**
|
||||
** Compute and/or recall the mug (31-bit hash) of (a).
|
||||
*/
|
||||
c3_w
|
||||
u2_mug(u2_noun a);
|
||||
|
||||
/* u2_mug():
|
||||
**
|
||||
** Compute and/or recall the mug (31-bit hash) of (a).
|
||||
*/
|
||||
c3_w
|
||||
u2_mum(u2_noun a);
|
||||
|
||||
/* u2_mur_words(): MurmurHash3 on raw words.
|
||||
*/
|
||||
c3_w
|
||||
u2_mur_words(c3_w syd_w, c3_w len_w, c3_w* key_w);
|
||||
|
||||
/* u2_mug_string():
|
||||
**
|
||||
** Compute the mug of `a`, LSB first.
|
||||
*/
|
||||
c3_w
|
||||
u2_mug_string(const c3_c *a_c);
|
||||
|
||||
/* u2_mug_words():
|
||||
**
|
||||
** Compute the mug of `buf`, `len`, LSW first.
|
||||
*/
|
||||
c3_w
|
||||
u2_mug_words(const c3_w *buf_w,
|
||||
c3_w len_w);
|
||||
|
||||
/* u2_mug_cell():
|
||||
**
|
||||
** Compute the mug of `[a b]`.
|
||||
*/
|
||||
c3_w
|
||||
u2_mug_cell(u2_noun a,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_mug_trel():
|
||||
**
|
||||
** Compute the mug of `[a b c]`.
|
||||
*/
|
||||
c3_w
|
||||
u2_mug_trel(u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun c);
|
||||
|
||||
/* u2_mug_qual():
|
||||
**
|
||||
** Compute the mug of `[a b c d]`.
|
||||
*/
|
||||
c3_w
|
||||
u2_mug_qual(u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun c,
|
||||
u2_noun d);
|
||||
|
||||
/* u2_mug_both():
|
||||
**
|
||||
** Join two mugs.
|
||||
*/
|
||||
c3_w
|
||||
u2_mug_both(c3_w a_w,
|
||||
c3_w b_w);
|
||||
|
||||
/* u2_fing():
|
||||
**
|
||||
** Yes iff (a) and (b) are the same copy of the same noun.
|
||||
** (Ie, by pointer equality - u2_sing with false negatives.)
|
||||
*/
|
||||
u2_bean
|
||||
u2_fing(u2_noun a,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_fing_c():
|
||||
**
|
||||
** Yes iff (b) is the same copy of the same noun as the C string [a].
|
||||
*/
|
||||
u2_bean
|
||||
u2_fing_c(const c3_c* a_c,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_fing_cell():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_fing_cell(u2_noun p,
|
||||
u2_noun q,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_fing_mixt():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_fing_mixt(const c3_c* p_c,
|
||||
u2_noun q,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_fing_trel():
|
||||
**
|
||||
** Yes iff `[p q r]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_fing_trel(u2_noun p,
|
||||
u2_noun q,
|
||||
u2_noun r,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_fing_qual():
|
||||
**
|
||||
** Yes iff `[p q r s]` and `b` are the same copy of the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_fing_qual(u2_noun p,
|
||||
u2_noun q,
|
||||
u2_noun r,
|
||||
u2_noun s,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_sing():
|
||||
**
|
||||
** Yes iff (a) and (b) are the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_sing(u2_noun a,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_sing_c():
|
||||
**
|
||||
** Yes iff (b) is the same noun as the C string [a].
|
||||
*/
|
||||
u2_bean
|
||||
u2_sing_c(const c3_c* a_c,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_sing_cell():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_sing_cell(u2_noun p,
|
||||
u2_noun q,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_sing_mixt():
|
||||
**
|
||||
** Yes iff `[p q]` and `b` are the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_sing_mixt(const c3_c* p_c,
|
||||
u2_noun q,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_sing_trel():
|
||||
**
|
||||
** Yes iff `[p q r]` and `b` are the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_sing_trel(u2_noun p,
|
||||
u2_noun q,
|
||||
u2_noun r,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_sing_qual():
|
||||
**
|
||||
** Yes iff `[p q r s]` and `b` are the same noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_sing_qual(u2_noun p,
|
||||
u2_noun q,
|
||||
u2_noun r,
|
||||
u2_noun s,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_nord():
|
||||
**
|
||||
** Return 0, 1 or 2 if `a` is below, equal to, or above `b`.
|
||||
*/
|
||||
u2_atom
|
||||
u2_nord(u2_noun a,
|
||||
u2_noun b);
|
||||
|
||||
/* u2_stud():
|
||||
**
|
||||
** Yes iff (a) is an atom.
|
||||
*/
|
||||
#if 0
|
||||
u2_bean
|
||||
u2_stud(u2_noun a)
|
||||
#else
|
||||
# define u2_stud(a) \
|
||||
(u2_fly_is_atom(a) ? u2_yes : u2_no)
|
||||
#endif
|
||||
|
||||
/** Cell access.
|
||||
**/
|
||||
/* u2_as_bush():
|
||||
**
|
||||
** Factor [a] as a bush [b.[p q] c].
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_bush(u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c);
|
||||
|
||||
/* u2_as_cell():
|
||||
**
|
||||
** Factor (a) as a cell (b c).
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_cell(u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c);
|
||||
|
||||
/* u2_as_hext():
|
||||
**
|
||||
** Factor (a) as a hext (b c d e f g)
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_hext(u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c,
|
||||
u2_noun* d,
|
||||
u2_noun* e,
|
||||
u2_noun* f,
|
||||
u2_noun* g);
|
||||
|
||||
/* u2_as_p():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c].
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_p(u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun* c);
|
||||
|
||||
/* u2_as_pq():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c d].
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_pq(u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun* c,
|
||||
u2_noun* d);
|
||||
|
||||
/* u2_as_pqr():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c *d *e].
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_pqr(u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun* c,
|
||||
u2_noun* d,
|
||||
u2_noun* e);
|
||||
|
||||
/* u2_as_pqrs():
|
||||
**
|
||||
** & [0] if [a] is of the form [b *c *d *e *f].
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_pqrs(u2_noun a,
|
||||
u2_noun b,
|
||||
u2_noun* c,
|
||||
u2_noun* d,
|
||||
u2_noun* e,
|
||||
u2_noun* f);
|
||||
|
||||
/* u2_as_qual():
|
||||
**
|
||||
** Factor (a) as a qual (b c d e).
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_qual(u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c,
|
||||
u2_noun* d,
|
||||
u2_noun* e);
|
||||
|
||||
/* u2_as_quil():
|
||||
**
|
||||
** Factor (a) as a quil (b c d e f).
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_quil(u2_noun a,
|
||||
u2_noun* b,
|
||||
u2_noun* c,
|
||||
u2_noun* d,
|
||||
u2_noun* e,
|
||||
u2_noun* f);
|
||||
|
||||
/* u2_as_trel():
|
||||
**
|
||||
** Factor (a) as a trel (b c d).
|
||||
*/
|
||||
u2_bean
|
||||
u2_as_trel(u2_noun a,
|
||||
u2_noun *b,
|
||||
u2_noun *c,
|
||||
u2_noun *d);
|
||||
|
||||
/* u2_h(), u2_sh():
|
||||
**
|
||||
** Return the head of `a`, unsafely or safely.
|
||||
*/
|
||||
#if 0
|
||||
u2_noun
|
||||
u2_h(u2_noun a);
|
||||
#else
|
||||
# define u2_h(a) (*u2_at_pom_hed(a))
|
||||
#endif
|
||||
u2_noun
|
||||
u2_sh(u2_noun a);
|
||||
|
||||
/* u2_t(), u2_st():
|
||||
**
|
||||
** Return the tail of `a`, unsafely or safely.
|
||||
*/
|
||||
#if 0
|
||||
u2_noun
|
||||
u2_t(u2_noun a);
|
||||
#else
|
||||
# define u2_t(a) (*u2_at_pom_tel(a))
|
||||
#endif
|
||||
u2_noun
|
||||
u2_st(u2_noun a);
|
||||
|
||||
/** Atom access.
|
||||
**/
|
||||
/* u2_met():
|
||||
**
|
||||
** Return the size of (b) in bits, rounded up to
|
||||
** (1 << a_y).
|
||||
**
|
||||
** For example, (a_y == 3) returns the size in bytes.
|
||||
*/
|
||||
c3_w
|
||||
u2_met(c3_y a_y,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_bit():
|
||||
**
|
||||
** Return bit (a_w) of (b).
|
||||
*/
|
||||
c3_b
|
||||
u2_bit(c3_w a_w,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_byte():
|
||||
**
|
||||
** Return byte (a_w) of (b).
|
||||
*/
|
||||
c3_y
|
||||
u2_byte(c3_w a_w,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_bytes():
|
||||
**
|
||||
** Copy bytes (a_w) through (a_w + b_w - 1) from (d) to (c).
|
||||
*/
|
||||
void
|
||||
u2_bytes(c3_w a_w,
|
||||
c3_w b_w,
|
||||
c3_y* c_y,
|
||||
u2_atom d);
|
||||
|
||||
/* u2_chop():
|
||||
**
|
||||
** Into the bloq space of `met`, from position `fum` for a
|
||||
** span of `wid`, to position `tou`, XOR from atom `src`
|
||||
** into ray `dst`.
|
||||
*/
|
||||
void
|
||||
u2_chop(c3_g met_g,
|
||||
c3_w fum_w,
|
||||
c3_w wid_w,
|
||||
c3_w tou_w,
|
||||
u2_ray dst_r,
|
||||
u2_atom src);
|
||||
|
||||
/* u2_mp():
|
||||
**
|
||||
** Copy (b) into (a_mp).
|
||||
*/
|
||||
void
|
||||
u2_mp(mpz_t a_mp,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_word():
|
||||
**
|
||||
** Return word (a_w) of (b).
|
||||
*/
|
||||
c3_w
|
||||
u2_word(c3_w a_w,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_chub():
|
||||
**
|
||||
** Return double-word (a_w) of (b).
|
||||
*/
|
||||
c3_d
|
||||
u2_chub(c3_w a_w,
|
||||
u2_atom b);
|
||||
|
||||
/* u2_words():
|
||||
**
|
||||
** Copy words (a_w) through (a_w + b_w - 1) from (d) to (c).
|
||||
*/
|
||||
void
|
||||
u2_words(c3_w a_w,
|
||||
c3_w b_w,
|
||||
c3_w* c_w,
|
||||
u2_atom d);
|
@ -1,49 +0,0 @@
|
||||
/* include/nock.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_nk_nock():
|
||||
**
|
||||
** Compute `(nock bus fol)`.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_nk_nock(u2_wire wir_r,
|
||||
u2_weak bus, // transfer
|
||||
u2_weak fol); // retain
|
||||
|
||||
/* u2_nk_soft():
|
||||
**
|
||||
** Compute `(nock bus fol)`, interpreter first.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_nk_soft(u2_wire wir_r,
|
||||
u2_weak bus, // transfer
|
||||
u2_weak fol); // retain
|
||||
|
||||
/* u2_nk_nold():
|
||||
**
|
||||
** Really compute `(nock bus fol)`, interpreter first.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_nk_nold(u2_wire wir_r,
|
||||
u2_weak bus, // transfer
|
||||
u2_weak fol); // retain
|
||||
|
||||
/* u2_nk_mong():
|
||||
**
|
||||
** Compute `(nock gat(-> sam) +.gat)` - new calling convention.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_nk_mong(u2_wire wir_r,
|
||||
u2_weak gat, // retain
|
||||
u2_weak sam); // transfer
|
||||
|
||||
/* u2_nk_kick():
|
||||
**
|
||||
** Fire `gat` without changing the sample.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_nk_kick(u2_wire wir_r,
|
||||
u2_weak gat); // retain
|
673
include/f/rail.h
673
include/f/rail.h
@ -1,673 +0,0 @@
|
||||
/* include/rail.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Configurations.
|
||||
**/
|
||||
# undef U2_LEAK_DEBUG
|
||||
|
||||
# ifdef U2_LEAK_DEBUG
|
||||
# define u2_leak_on(x) (COD_w = x)
|
||||
extern c3_w COD_w;
|
||||
# define u2_leak_off (COD_w = 0)
|
||||
# endif
|
||||
|
||||
/** Data types.
|
||||
**/
|
||||
/** Ray types.
|
||||
**/
|
||||
/* u2_rail: an allocation control frame.
|
||||
*/
|
||||
typedef u2_ray u2_rail;
|
||||
|
||||
/* u2_wire: an execution context, inheriting rail
|
||||
*/
|
||||
typedef u2_ray u2_wire;
|
||||
|
||||
/** Structures - in loom space.
|
||||
**/
|
||||
/* Base rail.
|
||||
*/
|
||||
typedef struct _u2_loom_rail {
|
||||
u2_ray cap_r; // top of transient region
|
||||
u2_ray hat_r; // top of new durable region
|
||||
u2_ray mat_r; // bottom of transient region
|
||||
u2_ray rut_r; // bottom of new durable region
|
||||
c3_m hip_m; // memory model in durable; c3__rock, c3__sand
|
||||
} u2_loom_rail;
|
||||
|
||||
# define u2_rail_cap_r(ral_r) *u2_at(ral_r, u2_loom_rail, cap_r)
|
||||
# define u2_rail_hat_r(ral_r) *u2_at(ral_r, u2_loom_rail, hat_r)
|
||||
# define u2_rail_mat_r(ral_r) *u2_at(ral_r, u2_loom_rail, mat_r)
|
||||
# define u2_rail_rut_r(ral_r) *u2_at(ral_r, u2_loom_rail, rut_r)
|
||||
# define u2_rail_hip_m(ral_r) *u2_at(ral_r, u2_loom_rail, hip_m)
|
||||
|
||||
/* Pork - base of frame.
|
||||
*/
|
||||
typedef struct {
|
||||
u2_ray mut_r; // parent mat
|
||||
u2_ray rit_r; // parent rut
|
||||
c3_m hap_m; // parent hip
|
||||
} u2_loom_pork;
|
||||
# define u2_pork_mut_r(pik_r) *u2_at(pik_r, u2_loom_pork, mut_r)
|
||||
# define u2_pork_rit_r(pik_r) *u2_at(pik_r, u2_loom_pork, rit_r)
|
||||
# define u2_pork_hap_m(pik_r) *u2_at(pik_r, u2_loom_pork, hap_m)
|
||||
|
||||
/* Floe - a solid rail allocator. Implied by `hip_m == c3__sand`.
|
||||
*/
|
||||
typedef struct {
|
||||
} u2_loom_floe;
|
||||
|
||||
/* Soup - a liquid rail allocator.
|
||||
*/
|
||||
# define u2_soup_free_no 28
|
||||
|
||||
typedef struct {
|
||||
u2_ray fre_r[u2_soup_free_no]; // doubly-linked free lists
|
||||
u2_cash_slot lot_s; // modern memo cache
|
||||
#ifdef U2_PROFILE_MEMORY
|
||||
c3_w liv_w; // number of words live
|
||||
#endif
|
||||
} u2_loom_soup;
|
||||
# define u2_soup_fre_r(sop_r, x) *u2_at(sop_r, u2_loom_soup, fre_r[x])
|
||||
# define u2_soup_lot_r(sop_r) u2_aftr(sop_r, u2_loom_soup, lot_s)
|
||||
# define u2_soup_liv_w(sop_r) *u2_at(sop_r, u2_loom_soup, liv_w)
|
||||
|
||||
/* A noun box, for liquid hats. Behind pointer, addressed fwd.
|
||||
**
|
||||
** The box size is also stored at the end of the box in classic
|
||||
** bad ass malloc style. Hence a box is:
|
||||
**
|
||||
** ---
|
||||
** siz_w
|
||||
** use_w
|
||||
** user data
|
||||
** siz_w
|
||||
** ---
|
||||
**
|
||||
** Do not attempt to adjust this structure!
|
||||
*/
|
||||
typedef struct _u2_loom_rail_box {
|
||||
c3_w siz_w; // size of this box
|
||||
c3_w use_w; // reference count; free if 0
|
||||
#ifdef U2_LEAK_DEBUG
|
||||
c3_w cod_w; // allocation code
|
||||
#endif
|
||||
} u2_loom_rail_box;
|
||||
|
||||
# define u2_rail_box_siz(box) *u2_at(box, u2_loom_rail_box, siz_w)
|
||||
# define u2_rail_box_use(box) *u2_at(box, u2_loom_rail_box, use_w)
|
||||
# define u2_rail_box_cod(box) *u2_at(box, u2_loom_rail_box, cod_w)
|
||||
|
||||
/* A free node. Addressed from the box.
|
||||
*/
|
||||
typedef struct _u2_loom_rail_hut {
|
||||
u2_loom_rail_box b;
|
||||
u2_ray pre_r; // next on free list
|
||||
u2_ray nex_r; // next on free list
|
||||
} u2_loom_rail_hut;
|
||||
|
||||
# define u2_rail_hut_siz(hut) *u2_at(hut, u2_loom_rail_hut, b.siz_w)
|
||||
# define u2_rail_hut_use(hut) *u2_at(hut, u2_loom_rail_hut, b.use_w)
|
||||
# define u2_rail_hut_pre(hut) *u2_at(hut, u2_loom_rail_hut, pre_r)
|
||||
# define u2_rail_hut_nex(hut) *u2_at(hut, u2_loom_rail_hut, nex_r)
|
||||
|
||||
# define u2_rail_box(som) \
|
||||
( u2_fly_is_cat(som) \
|
||||
? 0 \
|
||||
: (u2_dog_a(som) - c3_wiseof(u2_loom_rail_box)) )
|
||||
|
||||
/** Abbreviations.
|
||||
**/
|
||||
# define u2_rc(ral_r, a, b) u2_rl_cell(ral_r, a, b)
|
||||
# define u2_rt(ral_r, a, b, c) u2_rl_trel(ral_r, a, b, c)
|
||||
# define u2_rq(ral_r, a, b, c, d) u2_rl_qual(ral_r, a, b, c, d)
|
||||
# define u2_ri(ral_r, a, b, c, d, e) u2_rl_quil(ral_r, a, b, c, d, e)
|
||||
# define u2_ro(ral_r, a) u2_rl_lone(ral_r, a)
|
||||
# define u2_ru(ral_r, a) u2_rl_unit(ral_r, a)
|
||||
# define u2_rx(ral_r, a) u2_rl_take(ral_r, a)
|
||||
# define u2_rz(ral_r, a) u2_rl_lose(ral_r, a)
|
||||
# define u2_rl u2_rl_list
|
||||
# define u2_rk u2_rl_rack
|
||||
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Miscellaneous and interesting.
|
||||
**/
|
||||
/* u2_rl_boot():
|
||||
**
|
||||
** Create an empty rail in an empty loom, with memory model `hip`.
|
||||
** See u2_rl_leap() for storage policies.
|
||||
*/
|
||||
u2_ray
|
||||
u2_rl_boot(c3_m hip_m);
|
||||
|
||||
/* u2_rl_clear():
|
||||
**
|
||||
** Yes iff [lef] does not point to any word >= [net]
|
||||
** and < [bat].
|
||||
*/
|
||||
u2_bean
|
||||
u2_rl_clear(u2_noun lef,
|
||||
u2_ray net_r,
|
||||
u2_ray bat_r);
|
||||
|
||||
/* u2_rl_init():
|
||||
**
|
||||
** Install an empty rail within `hat_r` and `mat_r` in the loom,
|
||||
** with memory model `hip`.
|
||||
**
|
||||
** Returns ray to rail, which always equalls the passed `mat_r`.
|
||||
*/
|
||||
u2_ray
|
||||
u2_rl_init(c3_m hip_m,
|
||||
u2_ray hat_r,
|
||||
u2_ray mat_r);
|
||||
|
||||
/* u2_rl_dump():
|
||||
**
|
||||
** Print memory structure for benefit of archeologists.
|
||||
*/
|
||||
void
|
||||
u2_rl_dump(u2_ray ral_r);
|
||||
|
||||
/* u2_rl_drain():
|
||||
**
|
||||
** Clear the memo cache (soup).
|
||||
*/
|
||||
void
|
||||
u2_rl_drain(u2_ray ral_r);
|
||||
|
||||
/* u2_rl_fall():
|
||||
**
|
||||
** Reverse the beams backward, restoring the old frame.
|
||||
*/
|
||||
void
|
||||
u2_rl_fall(u2_ray ral_r);
|
||||
|
||||
/* u2_rl_fall_part():
|
||||
**
|
||||
** Fall on `ral`, also releasing the partition `aux`.
|
||||
*/
|
||||
void
|
||||
u2_rl_fall_part(u2_ray ral_r,
|
||||
u2_ray aux_r);
|
||||
|
||||
/* u2_rl_flog():
|
||||
**
|
||||
** Release the can, setting cap to mat.
|
||||
*/
|
||||
void
|
||||
u2_rl_flog(u2_ray ral_r);
|
||||
|
||||
/* u2_rl_gain():
|
||||
**
|
||||
** Gain a reference to `som`, returning it.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_gain(u2_ray ral_r,
|
||||
u2_weak som); // retain
|
||||
|
||||
/* u2_rl_free():
|
||||
**
|
||||
** Free storage allocated by u2_rl_malloc().
|
||||
*/
|
||||
void
|
||||
u2_rl_free(u2_ray ral_r,
|
||||
void* lag_v);
|
||||
|
||||
/* u2_rl_ok():
|
||||
**
|
||||
** Ensure that all reference counts are valid in `som`.
|
||||
*/
|
||||
void
|
||||
u2_rl_ok(u2_ray ral_r,
|
||||
u2_noun som); // retain
|
||||
|
||||
/* u2_rl_junior():
|
||||
**
|
||||
** Yes iff `dus` is junior in `ral` - ie, must be copied
|
||||
** to be referenced on the hat.
|
||||
*/
|
||||
u2_bean
|
||||
u2_rl_junior(u2_ray ral_r,
|
||||
u2_noun dus); // retain
|
||||
|
||||
/* u2_rl_leap():
|
||||
**
|
||||
** Reverse the beams forward, with memory model `hip`.
|
||||
** Memory models at present:
|
||||
**
|
||||
** c3__sand solid, no boxes or reference counts
|
||||
** c3__rock liquid, boxes, reference-counted heap
|
||||
**
|
||||
** Returns u2_yes on success.
|
||||
*/
|
||||
u2_bean
|
||||
u2_rl_leap(u2_ray ral_r,
|
||||
c3_m hip_m);
|
||||
|
||||
/* u2_rl_leap_part():
|
||||
**
|
||||
** Reverse and split rail, inserting partition of size `num/dem`
|
||||
** plus `tip`.
|
||||
**
|
||||
** Returns partition rail, `aux_r`.
|
||||
*/
|
||||
u2_ray
|
||||
u2_rl_leap_part(u2_ray ral_r,
|
||||
c3_m hop_m,
|
||||
c3_w num_w,
|
||||
c3_w dem_w,
|
||||
c3_w tip_w);
|
||||
|
||||
/* u2_rl_lose():
|
||||
**
|
||||
** Lose a reference to `som`. Free it if refcount == 0.
|
||||
*/
|
||||
void
|
||||
u2_rl_lose(u2_ray ral_r,
|
||||
u2_weak som); // transfer
|
||||
|
||||
/* u2_rl_gc_mark_noun():
|
||||
**
|
||||
** Mark a noun for gc. Return allocated words.
|
||||
*/
|
||||
c3_w
|
||||
u2_rl_gc_mark_noun(u2_ray ral_r,
|
||||
u2_noun som);
|
||||
|
||||
/* u2_rl_gc_mark_ptr():
|
||||
**
|
||||
** Mark a pointer allocated with ralloc. Return allocated words.
|
||||
*/
|
||||
c3_w
|
||||
u2_rl_gc_mark_ptr(u2_ray ral_r,
|
||||
u2_ray ptr_r);
|
||||
|
||||
/* u2_rl_gc_mark():
|
||||
**
|
||||
** Mark a rail (mainly memo cache). Return allocated words.
|
||||
*/
|
||||
c3_w
|
||||
u2_rl_gc_mark(u2_ray ral_r);
|
||||
|
||||
/* u2_rl_gc_sweep():
|
||||
**
|
||||
** Sweep memory, freeing unused blocks. Match live, save leaked.
|
||||
*/
|
||||
c3_w
|
||||
u2_rl_gc_sweep(u2_ray ral_r, c3_w sav_w);
|
||||
|
||||
/* u2_rl_malloc():
|
||||
**
|
||||
** Allocate `sib_w` *bytes* of raw C storage.
|
||||
*/
|
||||
void*
|
||||
u2_rl_malloc(u2_ray ral_r,
|
||||
c3_w sib_w);
|
||||
|
||||
/* u2_rl_malt():
|
||||
**
|
||||
** Initialize slab `sal` as an atom, internally measured.
|
||||
*/
|
||||
u2_atom // transfer
|
||||
u2_rl_malt(u2_rail ral_r,
|
||||
u2_ray sal_r);
|
||||
|
||||
/* u2_rl_mint():
|
||||
**
|
||||
** Initialize slab `sal` as an atom, externally measured.
|
||||
*/
|
||||
u2_atom // transfer
|
||||
u2_rl_mint(u2_rail ral_r,
|
||||
u2_ray sal_r,
|
||||
c3_w len_w);
|
||||
|
||||
/* u2_rl_moot():
|
||||
**
|
||||
** Initialize slab `sal` as an atom, originally measured.
|
||||
*/
|
||||
u2_atom // transfer
|
||||
u2_rl_moot(u2_rail ral_r,
|
||||
u2_ray sal_r);
|
||||
|
||||
/* u2_rl_open():
|
||||
**
|
||||
** Yes iff [a] more words remain in the pad.
|
||||
*/
|
||||
u2_bean
|
||||
u2_rl_open(u2_ray ral_r,
|
||||
c3_w a_w);
|
||||
|
||||
/* u2_rl_ralloc():
|
||||
**
|
||||
** Allocate `siz_w` words of raw ray storage.
|
||||
*/
|
||||
u2_ray
|
||||
u2_rl_ralloc(u2_ray ral_r,
|
||||
c3_w siz_w);
|
||||
|
||||
/* u2_rl_rfree():
|
||||
**
|
||||
** Free raw ray storage allocated by `u2_rl_ralloc()`.
|
||||
*/
|
||||
void
|
||||
u2_rl_rfree(u2_ray ral_r,
|
||||
u2_ray nov_r);
|
||||
|
||||
/* u2_rl_senior():
|
||||
**
|
||||
** Yes iff `dus` is senior in `ral` - ie, does not
|
||||
** require reference counting.
|
||||
*/
|
||||
u2_bean
|
||||
u2_rl_senior(u2_ray ral_r,
|
||||
u2_noun dus); // retain
|
||||
|
||||
/* u2_rl_slab():
|
||||
**
|
||||
** Create a blank atomic slab of `len` words.
|
||||
*/
|
||||
u2_ray
|
||||
u2_rl_slab(u2_rail ral_r,
|
||||
c3_w len_w);
|
||||
|
||||
/* u2_rl_slaq():
|
||||
**
|
||||
** Create a blank atomic slab of `len` bloqs of size `met`.
|
||||
*/
|
||||
u2_ray
|
||||
u2_rl_slaq(u2_wire wir_r,
|
||||
c3_g met_g,
|
||||
c3_w len_w);
|
||||
|
||||
/* u2_rl_refs():
|
||||
**
|
||||
** Return the reference count of (som). For debugging, etc.
|
||||
*/
|
||||
c3_w
|
||||
u2_rl_refs(u2_ray ral_r,
|
||||
u2_noun som);
|
||||
|
||||
/* u2_rl_copy():
|
||||
**
|
||||
** Copy indirect noun `fiz` into main storage, preserving dags.
|
||||
** Must be followed by `rl_wash(fiz)` if `fiz` is to be preserved.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_copy(u2_ray ral_r,
|
||||
u2_dog fiz); // retain
|
||||
|
||||
/* u2_rl_take():
|
||||
**
|
||||
** Produce `a`, as eligible result. Copy juniors; reference peers.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_take(u2_ray ral_r,
|
||||
u2_weak a); // retain
|
||||
# define u2_rl_ice(ral_r, a) \
|
||||
u2_rl_take(ral_r, a)
|
||||
|
||||
/* u2_rl_tamp():
|
||||
**
|
||||
** Tamp, eliding the segment from `net` up to `bat`,
|
||||
** preserving the root `lef`.
|
||||
**
|
||||
** Assumes u2_rl_clear() with the same arguments.
|
||||
*/
|
||||
u2_noun
|
||||
u2_rl_tamp(u2_ray ral_r,
|
||||
u2_noun lef,
|
||||
u2_ray net_r,
|
||||
u2_ray bat_r);
|
||||
|
||||
/* u2_rl_valid():
|
||||
**
|
||||
** Validate rail for memory bugs.
|
||||
*/
|
||||
void
|
||||
u2_rl_valid(u2_ray ral_r);
|
||||
|
||||
/* u2_rl_water():
|
||||
**
|
||||
** Return east and west watermarks, respectively.
|
||||
*/
|
||||
void
|
||||
u2_rl_water(u2_ray ral_r,
|
||||
c3_w* maz_w,
|
||||
c3_w* buc_w);
|
||||
|
||||
/** Basic noun fabrication.
|
||||
**/
|
||||
/* u2_rl_bytes():
|
||||
**
|
||||
** Copy `a` bytes from `b` to an LSB first atom.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_bytes(u2_ray ral_r,
|
||||
c3_w a_w,
|
||||
const c3_y* b_y);
|
||||
|
||||
/* u2_rl_cell():
|
||||
**
|
||||
** Produce the cell `[a b]`.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_cell(u2_ray ral_r,
|
||||
u2_weak a, // transfer
|
||||
u2_weak b); // transfer
|
||||
|
||||
/* u2_rl_list():
|
||||
**
|
||||
** Produce a null-terminated list, terminating `...` with `u2_none`.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_list(u2_rail ral_r,
|
||||
...); // transfer
|
||||
|
||||
/* u2_rl_lone():
|
||||
**
|
||||
** Create the unit `[0 a]`.
|
||||
*/
|
||||
#if 0
|
||||
u2_weak // transfer
|
||||
u2_rl_lone(u2_rail ral_r,
|
||||
u2_weak a); // transfer
|
||||
#else
|
||||
# define u2_rl_lone(ral_r, a) \
|
||||
u2_rc(ral_r, a, u2_nul)
|
||||
#endif
|
||||
|
||||
/* u2_rl_molt():
|
||||
**
|
||||
** Mutate `som` with a 0-terminated list of axis, noun pairs.
|
||||
** Axes must be cats (31 bit).
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_molt(u2_rail ral_r,
|
||||
u2_weak som, // retain
|
||||
...); // transfer
|
||||
|
||||
/* u2_rl_molv():
|
||||
**
|
||||
** As u2_rl_molt(), by argument pointer.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_molv(u2_rail ral_r,
|
||||
u2_weak som, // retain
|
||||
va_list vap); // transfer
|
||||
|
||||
/* u2_rl_mp():
|
||||
**
|
||||
** Copy the GMP integer [a] into an atom.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_mp(u2_ray ral_r,
|
||||
mpz_t a_mp); // transfer
|
||||
|
||||
/* u2_rl_qual():
|
||||
**
|
||||
** Produce the triple `[a b c d]`.
|
||||
*/
|
||||
#if 0
|
||||
u2_weak // transfer
|
||||
u2_rl_qual(u2_rail ral_r,
|
||||
u2_weak a, // transfer
|
||||
u2_weak b, // transfer
|
||||
u2_weak c, // transfer
|
||||
u2_weak d); // transfer
|
||||
#else
|
||||
# define u2_rl_qual(ral_r, a, b, c, d) \
|
||||
u2_rc(ral_r, a, u2_rt(ral_r, b, c, d))
|
||||
#endif
|
||||
|
||||
/* u2_rl_rack():
|
||||
**
|
||||
** Produce an n-tuple, terminating `...` with `u2_none`.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_rack(u2_rail ral_r,
|
||||
...); // transfer
|
||||
|
||||
/* u2_rl_string():
|
||||
**
|
||||
** Produce an LSB-first atom from the C string `a`.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_string(u2_ray ral_r,
|
||||
const c3_c* a_c);
|
||||
|
||||
/* u2_rl_trel():
|
||||
**
|
||||
** Create the triple `[a b c]`.
|
||||
*/
|
||||
#if 0
|
||||
u2_weak // transfer
|
||||
u2_rl_trel(u2_rail ral_r,
|
||||
u2_weak a, // transfer
|
||||
u2_weak b, // transfer
|
||||
u2_weak c); // transfer
|
||||
#else
|
||||
# define u2_rl_trel(ral_r, a, b, c) \
|
||||
u2_rc(ral_r, a, u2_rc(ral_r, b, c))
|
||||
#endif
|
||||
|
||||
/* u2_rl_unit():
|
||||
**
|
||||
** Create the unit `[0 a]`.
|
||||
*/
|
||||
#if 0
|
||||
u2_weak // transfer
|
||||
u2_rl_unit(u2_rail ral_r,
|
||||
u2_weak a); // transfer
|
||||
#else
|
||||
# define u2_rl_unit(ral_r, a) \
|
||||
u2_rc(ral_r, u2_nul, a)
|
||||
#endif
|
||||
|
||||
/* u2_rl_vint():
|
||||
**
|
||||
** Create `a + 1`.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_vint(u2_rail ral_r,
|
||||
u2_weak a); // transfer
|
||||
|
||||
/* u2_rl_words():
|
||||
**
|
||||
** Copy [a] words from [b] into an atom.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_words(u2_ray ral_r,
|
||||
c3_w a_w,
|
||||
const c3_w* b_w);
|
||||
|
||||
/** Caching.
|
||||
**/
|
||||
/* u2_rl_find():
|
||||
**
|
||||
** Cache search for function (0 means nock) and sample.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_find(u2_ray ral_r,
|
||||
u2_mote fun_m,
|
||||
u2_noun sam); // retain
|
||||
|
||||
/* u2_rl_save():
|
||||
**
|
||||
** Cache store for function (0 means nock), sample and product.
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_save(u2_ray ral_r,
|
||||
u2_mote fun_m, // retain
|
||||
u2_noun sam, // retain
|
||||
u2_noun pro); // transfer
|
||||
|
||||
/* u2_rl_uniq():
|
||||
**
|
||||
** Use cache to render object unique.
|
||||
*/
|
||||
u2_noun // produce
|
||||
u2_rl_uniq(u2_ray ral_r,
|
||||
u2_noun som); // submit
|
||||
|
||||
/* u2_rl_find_cell(): as u2_rl_find(), for `sam=[a b]`.
|
||||
** u2_rl_find_trel(): as u2_rl_find(), for `sam=[a b c]`.
|
||||
** u2_rl_find_qual(): as u2_rl_find(), for `sam=[a b d]`.
|
||||
** u2_rl_find_quil(): as u2_rl_find(), for `sam=[a b c d e]`.
|
||||
**
|
||||
** Extend as needed...
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_find_cell(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun); // retain
|
||||
u2_weak // transfer
|
||||
u2_rl_find_trel(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun); // retain
|
||||
u2_weak // transfer
|
||||
u2_rl_find_qual(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun); // retain
|
||||
u2_weak // transfer
|
||||
u2_rl_find_quil(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun); // retain
|
||||
|
||||
/* u2_rl_save_cell(): as u2_rl_save(), for `sam=[a b]`.
|
||||
** u2_rl_save_trel(): as u2_rl_save(), for `sam=[a b c]`.
|
||||
** u2_rl_save_qual(): as u2_rl_save(), for `sam=[a b c d]`.
|
||||
** u2_rl_save_quil(): as u2_rl_save(), for `sam=[a b c d e]`.
|
||||
**
|
||||
** Extended
|
||||
*/
|
||||
u2_weak // transfer
|
||||
u2_rl_save_cell(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun); // transfer
|
||||
|
||||
u2_weak // transfer
|
||||
u2_rl_save_trel(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun); // transfer
|
||||
|
||||
u2_weak // transfer
|
||||
u2_rl_save_qual(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun); // transfer
|
||||
|
||||
u2_weak // transfer
|
||||
u2_rl_save_quil(u2_ray, u2_mote, u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun, // retain
|
||||
u2_noun); // transfer
|
@ -1,93 +0,0 @@
|
||||
/* include/shed.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data types.
|
||||
**/
|
||||
/* u2_seal: identification in objective battery declaration.
|
||||
**
|
||||
** |?
|
||||
** lef=*term
|
||||
** [std=*term kel=@]
|
||||
** [ven=*term pro=*term kel=@]
|
||||
** [ven=*term pro=*term ver=@ kel=@]
|
||||
** ==
|
||||
*/
|
||||
typedef u2_noun u2_seal;
|
||||
|
||||
/* u2_clue: programmer's declaration hint
|
||||
**
|
||||
** [bud=*tool sil=*seal nut=*(list &[p=*term q=*tool])]
|
||||
*/
|
||||
typedef u2_noun u2_clue;
|
||||
|
||||
/* u2_disc: declaration layer (list should be map)
|
||||
**
|
||||
** [sil=*seal nut=*(list &[p=*term q=*tool])]
|
||||
*/
|
||||
typedef u2_noun u2_disc;
|
||||
|
||||
/* u2_chip: complete battery record
|
||||
**
|
||||
** [dac=*disc bat=* pet=<~ [axe=*axis led=*chip]>]
|
||||
*/
|
||||
typedef u2_noun u2_chip;
|
||||
|
||||
/* u2_loom_shed: jet registration hangar.
|
||||
*/
|
||||
typedef struct {
|
||||
u2_loom_rail o;
|
||||
|
||||
/* cad_c: hash from battery to chip.
|
||||
*/
|
||||
u2_loom_chad cad_c;
|
||||
|
||||
/* dip_c: hash from battery, term to formula.
|
||||
*/
|
||||
u2_loom_chad dip_c;
|
||||
} u2_loom_shed;
|
||||
|
||||
# define u2_shed_cad_r(sad_r) u2_aftr(sad_r, u2_loom_shed, cad_c)
|
||||
# define u2_shed_dip_r(sad_r) u2_aftr(sad_r, u2_loom_shed, dip_c)
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_sh_init():
|
||||
**
|
||||
** Initialize shed, with parent if any.
|
||||
*/
|
||||
void
|
||||
u2_sh_init(u2_wire wir_r);
|
||||
|
||||
/* u2_sh_find(): find chip by core, or none. Includes validate.
|
||||
*/
|
||||
u2_weak // senior
|
||||
u2_sh_find(u2_wire wir_r,
|
||||
u2_noun cor); // retain
|
||||
|
||||
/* u2_sh_mine():
|
||||
**
|
||||
** Register and/or replace core.
|
||||
*/
|
||||
u2_noun // transfer
|
||||
u2_sh_mine(u2_wire wir_r,
|
||||
u2_noun hod, // retain
|
||||
u2_noun cor); // transfer
|
||||
|
||||
/* u2_sh_cook():
|
||||
**
|
||||
** Produce hook formula from chip, or u2_none.
|
||||
*/
|
||||
u2_weak // senior
|
||||
u2_sh_cook(u2_wire wir_r,
|
||||
u2_noun xip, // retain
|
||||
const c3_c* tam_c);
|
||||
|
||||
/* u2_sh_look():
|
||||
**
|
||||
** Produce hook formula from core, or u2_none.
|
||||
*/
|
||||
u2_weak // senior
|
||||
u2_sh_look(u2_wire wir_r,
|
||||
u2_noun cor, // retain
|
||||
const c3_c* tam_c);
|
273
include/f/trac.h
273
include/f/trac.h
@ -1,273 +0,0 @@
|
||||
/* include/trac.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u2_loom_marx: profile watermark.
|
||||
*/
|
||||
struct u2_loom_marx {
|
||||
/* Measure.
|
||||
*/
|
||||
c3_w med_w;
|
||||
|
||||
/* Maximum.
|
||||
*/
|
||||
c3_w max_w;
|
||||
};
|
||||
|
||||
/* u2_loom_knot: profile node.
|
||||
*/
|
||||
typedef struct _u2_loom_knot {
|
||||
/* Task name - 31-byte prefix.
|
||||
*/
|
||||
c3_c lic_c[32];
|
||||
|
||||
/* Number of hits in this task.
|
||||
*/
|
||||
c3_w fin_w;
|
||||
|
||||
/* Subtask list, if any.
|
||||
*/
|
||||
struct _u2_loom_knot *fam_k;
|
||||
struct _u2_loom_knot *nex_k;
|
||||
} u2_loom_knot;
|
||||
|
||||
/* u2_loom_trac: tracing/profiling control structure.
|
||||
*/
|
||||
typedef struct _u2_loom_trac {
|
||||
/* Control.
|
||||
*/
|
||||
struct {
|
||||
/* u2_yes iff debugging is on.
|
||||
*/
|
||||
u2_bean deb;
|
||||
|
||||
/* u2_yes iff profiling is on.
|
||||
*/
|
||||
u2_bean pro;
|
||||
} cor;
|
||||
|
||||
/* Tracing.
|
||||
*/
|
||||
struct {
|
||||
/* Position stack: *(list shoe) [XX not used, still wire->tax]
|
||||
*/
|
||||
u2_noun ryp;
|
||||
|
||||
/* Mode bit - u2_yes == C/system, u2_no == interpreted
|
||||
*/
|
||||
u2_bean sys;
|
||||
|
||||
/* Function bit for sys - u2_yes == overhead, u2_no == function
|
||||
*/
|
||||
u2_bean glu;
|
||||
|
||||
/* Number of samples in random C code.
|
||||
*/
|
||||
c3_d com_d;
|
||||
|
||||
/* Number of samples in jet code.
|
||||
*/
|
||||
c3_d jet_d;
|
||||
|
||||
/* Number of samples in interpreted code.
|
||||
*/
|
||||
c3_d erp_d;
|
||||
} wer;
|
||||
|
||||
/* Profiling.
|
||||
*/
|
||||
struct {
|
||||
/* Task stack: *(list term)
|
||||
*/
|
||||
u2_noun don;
|
||||
|
||||
/* Act count: *(map term num)
|
||||
*/
|
||||
u2_noun cot;
|
||||
} duz;
|
||||
|
||||
/* Built-in system acts and counters.
|
||||
*/
|
||||
struct {
|
||||
/* Nock reductions.
|
||||
*/
|
||||
c3_d hop_d;
|
||||
|
||||
/* Jet activations.
|
||||
*/
|
||||
c3_d jet_d;
|
||||
|
||||
/* Jet tests.
|
||||
*/
|
||||
c3_d tes_d;
|
||||
|
||||
/* Matching comparisons.
|
||||
*/
|
||||
c3_d nod_d;
|
||||
|
||||
/* Memoization searches.
|
||||
*/
|
||||
c3_d fin_d;
|
||||
|
||||
/* Memoization productions.
|
||||
*/
|
||||
c3_d pod_d;
|
||||
|
||||
/* C stack record.
|
||||
*/
|
||||
struct u2_loom_marx cas_x;
|
||||
|
||||
/* Main memory usage record.
|
||||
*/
|
||||
struct u2_loom_marx men_x;
|
||||
|
||||
/* Basket memory usage record.
|
||||
*/
|
||||
struct u2_loom_marx bek_x;
|
||||
|
||||
/* Unix time in seconds at analysis instantiation.
|
||||
*/
|
||||
c3_w sec_w;
|
||||
|
||||
/* Unix time in microseconds at analysis instantiation.
|
||||
*/
|
||||
c3_w usc_w;
|
||||
|
||||
/* Original words in wire.
|
||||
*/
|
||||
c3_w lif_w;
|
||||
|
||||
/* Original words in basket.
|
||||
*/
|
||||
c3_w bos_w;
|
||||
} sys;
|
||||
} u2_loom_trac;
|
||||
|
||||
#define u2_trac_at(rac_r, wof) (*u2_at(rac_r, u2_loom_trac, wof))
|
||||
#define u2_trac_be(rac_r, ite, wof) (*u2_be(rac_r, u2_loom_trac, ite, wof))
|
||||
|
||||
#define u2_wrac_at(wir_r, wof) u2_trac_at(u2_wire_rac_r(wir_r), wof)
|
||||
#define u2_wrac_be(wir_r, ite, wof) u2_trac_be(u2_wire_rac_r(wir_r), ite, wof)
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Lifecycle.
|
||||
**/
|
||||
/* u2_tx_init(): initialize state.
|
||||
*/
|
||||
u2_ray
|
||||
u2_tx_init(u2_ray wir_r);
|
||||
|
||||
/* u2_tx_done(): produce a profile slab to render. Close tracing.
|
||||
**
|
||||
** type:
|
||||
*/
|
||||
u2_noun // produce
|
||||
u2_tx_done(u2_ray wir_r);
|
||||
|
||||
/* u2_tx_open(): open tracing.
|
||||
*/
|
||||
void
|
||||
u2_tx_open(u2_ray wir_r);
|
||||
|
||||
/* u2_tx_do_*(): set debug/profile bean. Return old value.
|
||||
*/
|
||||
u2_bean u2_tx_do_debug(u2_ray wir_r, u2_bean lag);
|
||||
u2_bean u2_tx_do_profile(u2_ray wir_r, u2_bean lag);
|
||||
|
||||
/* u2_tx_in_*(): get debug/profile bean.
|
||||
*/
|
||||
u2_bean u2_tx_in_debug(u2_ray wir_r);
|
||||
u2_bean u2_tx_in_profile(u2_ray wir_r);
|
||||
|
||||
/** Actions.
|
||||
**/
|
||||
/* u2_tx_did_*(): record system actions.
|
||||
*/
|
||||
#if 0
|
||||
# define u2_tx_did(wir_r, wof, det_ws) \
|
||||
( u2_wrac_be(wir_r, c3_d, wof) += det_ws )
|
||||
#else
|
||||
# define u2_tx_did(wir_r, wof, det_ws)
|
||||
#endif
|
||||
|
||||
# define u2_tx_did_hop(wir_r, det_ws) u2_tx_did(wir_r, sys.hop_d, det_ws)
|
||||
# define u2_tx_did_jet(wir_r, det_ws) u2_tx_did(wir_r, sys.jet_d, det_ws)
|
||||
# define u2_tx_did_tes(wir_r, det_ws) u2_tx_did(wir_r, sys.tes_d, det_ws)
|
||||
# define u2_tx_did_nod(wir_r, det_ws) u2_tx_did(wir_r, sys.nod_d, det_ws)
|
||||
# define u2_tx_did_fin(wir_r, det_ws) u2_tx_did(wir_r, sys.fin_d, det_ws)
|
||||
# define u2_tx_did_pod(wir_r, det_ws) u2_tx_did(wir_r, sys.pod_d, det_ws)
|
||||
|
||||
/* u2_tx_mex*(): record signed change in watermarks.
|
||||
*/
|
||||
# define u2_tx_mex(wir_r, wof, det_ws) \
|
||||
( ( u2_wrac_at(wir_r, wof.med_w) += det_ws), \
|
||||
( u2_wrac_at(wir_r, wof.max_w) = \
|
||||
( u2_wrac_at(wir_r, wof.med_w) > \
|
||||
u2_wrac_at(wir_r, wof.max_w) ) \
|
||||
? u2_wrac_at(wir_r, wof.med_w) \
|
||||
: u2_wrac_at(wir_r, wof.max_w) ) )
|
||||
|
||||
# define u2_tx_add_cas(wir_r, det_ws) u2_tx_mex(wir_r, sys.cas_x, det_ws)
|
||||
# define u2_tx_add_men(wir_r, det_ws) u2_tx_mex(wir_r, sys.men_x, det_ws)
|
||||
# define u2_tx_add_bek(wir_r, det_ws) u2_tx_mex(wir_r, sys.bek_x, det_ws)
|
||||
|
||||
# define u2_tx_sink_cas(wir_r) u2_tx_add_cas(wir_r, 1)
|
||||
# define u2_tx_rise_cas(wir_r) u2_tx_add_cas(wir_r, -1)
|
||||
|
||||
/* u2_tx_add_mem(): add memory to rail. A hack. Not used.
|
||||
*/
|
||||
# define u2_tx_add_mem(ral_r, det_ws) \
|
||||
( (0 == ral_r) ? u2_tx_add_men(ral_r, det_ws) \
|
||||
: u2_tx_add_bek(0, det_ws)
|
||||
|
||||
/* u2_tx_did_act(): record user actions.
|
||||
*/
|
||||
void
|
||||
u2_tx_did_act(u2_ray wir_r,
|
||||
u2_noun did); // retain
|
||||
|
||||
/* u2_tx_sys_bit(): set system bit, returning old value.
|
||||
*/
|
||||
u2_bean
|
||||
u2_tx_sys_bit(u2_ray wir_r,
|
||||
u2_bean val);
|
||||
|
||||
/* u2_tx_glu_bit(): set glue bit within system bit.
|
||||
*/
|
||||
u2_bean
|
||||
u2_tx_glu_bit(u2_ray wir_r,
|
||||
u2_bean val);
|
||||
/** Tasks.
|
||||
**/
|
||||
/* u2_tx_task_in(): enter a task for profiling purposes.
|
||||
**
|
||||
** u2_yes iff the task is not already in the stack.
|
||||
*/
|
||||
u2_bean
|
||||
u2_tx_task_in(u2_ray wir_r,
|
||||
u2_noun tak); // retain
|
||||
|
||||
/* u2_tx_task_out(): leave a task for profiling purposes.
|
||||
*/
|
||||
void
|
||||
u2_tx_task_out(u2_ray wir_r);
|
||||
|
||||
/** Direct logging.
|
||||
**/
|
||||
/* u2_tx_slog(): print debug syslog [0-3 tank] 0=debug 3=alarm
|
||||
*/
|
||||
void
|
||||
u2_tx_slog(u2_ray wir_r,
|
||||
u2_noun luf); // retain
|
||||
|
||||
/* u2_tx_warn(): report a warning by internal file and line.
|
||||
*/
|
||||
void
|
||||
u2_tx_warn(u2_ray wir_r,
|
||||
const c3_c* fil_c,
|
||||
c3_w lyn_w);
|
||||
# define u2_tx_warn_here(wir_r) u2_bx_warn(wir_r, __FILE__, __LINE__)
|
||||
|
@ -1,78 +0,0 @@
|
||||
/* include/unix.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Structures.
|
||||
**/
|
||||
/* u2_life: a monitored file.
|
||||
*/
|
||||
typedef struct _u2_life {
|
||||
const c3_c* src_c; // source path
|
||||
const c3_c* dat_c; // data path
|
||||
c3_d act_d; // tick updated at
|
||||
struct timespec tim_p; // date of source at update
|
||||
u2_weak src; // source noun
|
||||
u2_weak dat; // data noun
|
||||
void* han_v; // dlopen handle
|
||||
struct _u2_life* nex_l;
|
||||
} *u2_life;
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/* u2_ux_life(): create a monitored file, not loading.
|
||||
*/
|
||||
u2_life
|
||||
u2_ux_life(u2_wire wir_r,
|
||||
const c3_c* src_c,
|
||||
const c3_c* dat_c,
|
||||
const c3_c* oxt_c,
|
||||
u2_life nex_l);
|
||||
|
||||
/* u2_ux_live(): load/reload a monitored source; u2_yes for change.
|
||||
*/
|
||||
u2_bean
|
||||
u2_ux_live(u2_wire wir_r,
|
||||
u2_life lif_l);
|
||||
|
||||
/* u2_ux_lose(): forget a monitored file.
|
||||
*/
|
||||
void
|
||||
u2_ux_lose(u2_wire wir_r,
|
||||
u2_life lif_l);
|
||||
|
||||
/* u2_ux_read(): read a path/extension into an atom.
|
||||
*/
|
||||
u2_weak
|
||||
u2_ux_read(u2_wire wir_r,
|
||||
const c3_c* paf_c,
|
||||
const c3_c* ext_c);
|
||||
|
||||
/* u2_ux_read_deep(): read a filesystem path as a generic noun.
|
||||
*/
|
||||
u2_weak
|
||||
u2_ux_read_deep(u2_wire wir_r,
|
||||
const c3_c* paf_c,
|
||||
const c3_c* ext_c);
|
||||
|
||||
/* u2_ux_write(): write a path/extension as an atom.
|
||||
*/
|
||||
u2_bean
|
||||
u2_ux_write(u2_wire wir_r,
|
||||
u2_atom som,
|
||||
const c3_c* paf_c,
|
||||
const c3_c* ext_c);
|
||||
|
||||
/* u2_ux_write_deep(): write a path/extension as a generic noun.
|
||||
*/
|
||||
u2_bean
|
||||
u2_ux_write_deep(u2_wire wir_r,
|
||||
u2_noun som,
|
||||
const c3_c* paf_c,
|
||||
const c3_c* ext_c);
|
||||
|
||||
/* u2_ux_fresh(): true iff `oxt` is as fresh as `ext`.
|
||||
*/
|
||||
u2_bean
|
||||
u2_ux_fresh(const c3_c* paf_c,
|
||||
const c3_c* ext_c,
|
||||
const c3_c* oxt_c);
|
108
include/f/wire.h
108
include/f/wire.h
@ -1,108 +0,0 @@
|
||||
/* include/wire.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data types.
|
||||
**/
|
||||
/** Structures - in loom space.
|
||||
**/
|
||||
/* u2_loom_wire: one per thread.
|
||||
*/
|
||||
typedef struct _u2_loom_wire {
|
||||
u2_loom_rail o;
|
||||
|
||||
/* Clean bean. u2_no when there may be garbage.
|
||||
*/
|
||||
u2_noun lan;
|
||||
|
||||
/* Basket; u2_loom_bask; senior storage (for dashboard).
|
||||
*/
|
||||
u2_ray bas_r;
|
||||
|
||||
/* Dashboard; u2_loom_dash; map battery to chip list.
|
||||
*/
|
||||
u2_cash_slot des_s;
|
||||
|
||||
/* Ray to jet exception buffer, or 0.
|
||||
*/
|
||||
u2_ray kit_r;
|
||||
|
||||
/* Ray to OS state.
|
||||
*/
|
||||
u2_ray arv_r;
|
||||
|
||||
/* Ray to performance log.
|
||||
*/
|
||||
u2_ray bex_r;
|
||||
|
||||
/* Interpreter trace.
|
||||
*/
|
||||
u2_noun tax;
|
||||
|
||||
/* Ray to new tracer.
|
||||
*/
|
||||
u2_ray rac_r;
|
||||
|
||||
/* Heaven.
|
||||
*/
|
||||
u2_ray hev_r;
|
||||
} u2_loom_wire;
|
||||
|
||||
# define u2_wire_bas_r(wir_r) *u2_at(wir_r, u2_loom_wire, bas_r)
|
||||
# define u2_wire_des_r(wir_r) u2_aftr(wir_r, u2_loom_wire, des_s)
|
||||
# define u2_wire_kit_r(wir_r) *u2_at(wir_r, u2_loom_wire, kit_r)
|
||||
# define u2_wire_bex_r(wir_r) *u2_at(wir_r, u2_loom_wire, bex_r)
|
||||
# define u2_wire_rac_r(wir_r) *u2_at(wir_r, u2_loom_wire, rac_r)
|
||||
# define u2_wire_hev_r(wir_r) *u2_at(wir_r, u2_loom_wire, hev_r)
|
||||
# define u2_wire_arv_r(wir_r) *u2_at(wir_r, u2_loom_wire, arv_r)
|
||||
|
||||
# define u2_wire_tax(wir_r) *u2_at(wir_r, u2_loom_wire, tax)
|
||||
# define u2_wire_lan(wir_r) *u2_at(wir_r, u2_loom_wire, lan)
|
||||
|
||||
|
||||
/** Functions.
|
||||
**/
|
||||
/** Administration.
|
||||
**/
|
||||
/* u2_wr_init():
|
||||
**
|
||||
** Install an empty wire within `hat_r` and `mat_r` in the loom,
|
||||
** with memory model `hip`.
|
||||
**
|
||||
** Returns ray to wire, which always equalls the passed `mat_r`.
|
||||
*/
|
||||
u2_ray
|
||||
u2_wr_init(c3_m hip_m,
|
||||
u2_ray hat_r,
|
||||
u2_ray mat_r);
|
||||
|
||||
/* u2_wr_check_init(): initialize checkpoint segments and/or files.
|
||||
*/
|
||||
void
|
||||
u2_wr_check_init(c3_c* cpu_c);
|
||||
|
||||
/* u2_wr_check_save(): checkpoint wire in global structure.
|
||||
*/
|
||||
void
|
||||
u2_wr_check_save();
|
||||
|
||||
/* u2_wr_ice(): u2_rl_ice(), with u2_bx_copy().
|
||||
*/
|
||||
u2_weak
|
||||
u2_wr_ice(u2_ray wir_r,
|
||||
u2_noun fiz);
|
||||
|
||||
/* u2_wr_gc():
|
||||
**
|
||||
** Garbage-collect all current storage in a wire, given
|
||||
** a 0-terminated list of external roots.
|
||||
*/
|
||||
void
|
||||
u2_wr_gc(u2_ray wir_r, ...);
|
||||
|
||||
/* u2_wr_mark():
|
||||
**
|
||||
** Mark all roots in a wire and return their allocation size.
|
||||
*/
|
||||
c3_w
|
||||
u2_wr_mark(u2_ray wir_r);
|
137
include/g/a.h
137
include/g/a.h
@ -1,137 +0,0 @@
|
||||
/* include/g/a.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
|
||||
/** Allocation.
|
||||
**/
|
||||
/* Basic allocation.
|
||||
*/
|
||||
/* u3_ca_walloc(): allocate storage measured in words.
|
||||
*/
|
||||
void*
|
||||
u3_ca_walloc(c3_w len_w);
|
||||
|
||||
/* u3_ca_malloc(): allocate storage measured in bytes.
|
||||
*/
|
||||
void*
|
||||
u3_ca_malloc(c3_w len_w);
|
||||
|
||||
/* u3_ca_free(): free storage.
|
||||
*/
|
||||
void
|
||||
u3_ca_free(void* lag_v);
|
||||
|
||||
/* u3_ca_wealloc(): word realloc.
|
||||
*/
|
||||
void*
|
||||
u3_ca_wealloc(void* lag_v, c3_w len_w);
|
||||
|
||||
/* u3_ca_realloc(): byte realloc.
|
||||
*/
|
||||
void*
|
||||
u3_ca_realloc(void* lag_v, c3_w len_w);
|
||||
|
||||
|
||||
/* Reference and arena control.
|
||||
*/
|
||||
/* u3_ca_gain(): gain a reference count in normal space.
|
||||
*/
|
||||
u3_weak
|
||||
u3_ca_gain(u3_weak som);
|
||||
|
||||
/* u3_ca_take(): gain, copying juniors.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ca_take(u3_noun som);
|
||||
|
||||
/* u3_ca_left(): true of junior if preserved.
|
||||
*/
|
||||
c3_o
|
||||
u3_ca_left(u3_noun som);
|
||||
|
||||
/* u3_ca_lose(): lose a reference.
|
||||
*/
|
||||
void
|
||||
u3_ca_lose(u3_weak som);
|
||||
|
||||
/* u3_ca_wash(): wash all lazy mugs in subtree. RETAIN.
|
||||
*/
|
||||
void
|
||||
u3_ca_wash(u3_noun som);
|
||||
|
||||
/* u3_ca_use(): reference count.
|
||||
*/
|
||||
c3_w
|
||||
u3_ca_use(u3_noun som);
|
||||
|
||||
/* u3_ca_mark_ptr(): mark a pointer for gc. Produce size.
|
||||
*/
|
||||
c3_w
|
||||
u3_ca_mark_ptr(void* ptr_v);
|
||||
|
||||
/* u3_ca_mark_noun(): mark a noun for gc. Produce size.
|
||||
*/
|
||||
c3_w
|
||||
u3_ca_mark_noun(u3_noun som);
|
||||
|
||||
/* u3_ca_sweep(): sweep a fully marked road.
|
||||
*/
|
||||
void
|
||||
u3_ca_sweep(c3_c* cap_c);
|
||||
|
||||
/* u3_ca_sane(): check allocator sanity.
|
||||
*/
|
||||
void
|
||||
u3_ca_sane(void);
|
||||
|
||||
/* u3_ca_detect(): axis (som) is referenced from (fum).
|
||||
**
|
||||
** (som) and (fum) are both RETAINED.
|
||||
*/
|
||||
c3_d
|
||||
u3_ca_detect(u3_noun fum, u3_noun som);
|
||||
|
||||
/* u3_ca_lush(): leak push.
|
||||
*/
|
||||
c3_w
|
||||
u3_ca_lush(c3_w lab_w);
|
||||
|
||||
/* u3_ca_lop(): leak pop.
|
||||
*/
|
||||
void
|
||||
u3_ca_lop(c3_w lab_w);
|
||||
|
||||
/* u3_ca_print_memory: print memory amount.
|
||||
*/
|
||||
void
|
||||
u3_ca_print_memory(c3_c* cap_c, c3_w wor_w);
|
||||
|
||||
/* Atoms from proto-atoms.
|
||||
*/
|
||||
/* u3_ca_slab(): create a length-bounded proto-atom.
|
||||
*/
|
||||
c3_w*
|
||||
u3_ca_slab(c3_w len_w);
|
||||
|
||||
/* u3_ca_slaq(): u3_ca_slaq() with a defined blocksize.
|
||||
*/
|
||||
c3_w*
|
||||
u3_ca_slaq(c3_g met_g, c3_w len_w);
|
||||
|
||||
/* u3_ca_malt(): measure and finish a proto-atom.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ca_malt(c3_w* sal_w);
|
||||
|
||||
/* u3_ca_moot(): finish a pre-measured proto-atom; dangerous.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ca_moot(c3_w* sal_w);
|
||||
|
||||
/* u3_ca_mint(): finish a measured proto-atom.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ca_mint(c3_w* sal_w, c3_w len_w);
|
||||
|
||||
|
@ -1,35 +0,0 @@
|
||||
/* include/g/e.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Functions.
|
||||
**/
|
||||
/* u3_ce_fault(): handle a memory event with libsigsegv protocol.
|
||||
*/
|
||||
c3_i
|
||||
u3_ce_fault(void* adr_v, c3_i ser_i);
|
||||
|
||||
/* u3_ce_save():
|
||||
*/
|
||||
void
|
||||
u3_ce_save(void);
|
||||
|
||||
/* u3_ce_boot(): start the memory system.
|
||||
*/
|
||||
void
|
||||
u3_ce_boot(c3_o nuu_o, c3_o bug_o, c3_c* cpu_c);
|
||||
|
||||
/* u3_ce_init(): start the environment, with/without checkpointing.
|
||||
*/
|
||||
void
|
||||
u3_ce_init(c3_o chk_o);
|
||||
|
||||
/* u3_ce_grab(): garbage-collect the world, plus extra roots.
|
||||
*/
|
||||
void
|
||||
u3_ce_grab(c3_c* cap_c, u3_noun som, ...); // terminate with u3_none
|
||||
|
||||
/* u3_ce_dirty(): count dirty pages.
|
||||
*/
|
||||
c3_w
|
||||
u3_ce_dirty(void);
|
@ -1,48 +0,0 @@
|
||||
/* include/g/h.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Functions.
|
||||
***
|
||||
*** Needs: delete and merge functions; clock reclamation function.
|
||||
**/
|
||||
/* u3_ch_new(): create hashtable.
|
||||
*/
|
||||
u3p(u3_ch_root)
|
||||
u3_ch_new(void);
|
||||
|
||||
/* u3_ch_put(): insert in hashtable.
|
||||
**
|
||||
** `key` is RETAINED; `val` is transferred.
|
||||
*/
|
||||
void
|
||||
u3_ch_put(u3p(u3_ch_root) har_p, u3_noun key, u3_noun val);
|
||||
|
||||
/* u3_ch_get(): read from hashtable.
|
||||
**
|
||||
** `key` is RETAINED.
|
||||
*/
|
||||
u3_weak
|
||||
u3_ch_get(u3p(u3_ch_root) har_p, u3_noun key);
|
||||
|
||||
/* u3_ch_gut(): read from hashtable, unifying key nouns.
|
||||
**
|
||||
** `key` is RETAINED.
|
||||
*/
|
||||
u3_weak
|
||||
u3_ch_gut(u3p(u3_ch_root) har_p, u3_noun key);
|
||||
|
||||
/* u3_ch_free(): free hashtable.
|
||||
*/
|
||||
void
|
||||
u3_ch_free(u3p(u3_ch_root) har_p);
|
||||
|
||||
/* u3_ch_mark(): mark hashtable for gc.
|
||||
*/
|
||||
void
|
||||
u3_ch_mark(u3p(u3_ch_root) har_p);
|
||||
|
||||
/* u3_ch_walk(): traverse hashtable with key, value fn; RETAINS.
|
||||
*/
|
||||
void
|
||||
u3_ch_walk(u3p(u3_ch_root) har_p, void (*fun_f)(u3_noun));
|
@ -1,69 +0,0 @@
|
||||
/* include/g/j.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Jets.
|
||||
**/
|
||||
/* u3_cj_boot(): initialize jet system.
|
||||
*/
|
||||
void
|
||||
u3_cj_boot(void);
|
||||
|
||||
/* u3_cj_clear(): clear jet table to re-register.
|
||||
*/
|
||||
void
|
||||
u3_cj_clear(void);
|
||||
|
||||
/* u3_cj_hook():
|
||||
**
|
||||
** Execute hook from core.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cj_hook(u3_noun cor,
|
||||
const c3_c* tam_c);
|
||||
|
||||
/* u3_cj_soft():
|
||||
**
|
||||
** Execute hook from core, without jet.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cj_soft(u3_noun cor,
|
||||
const c3_c* tam_c);
|
||||
|
||||
/* u3_cj_find(): battery to driver number, or 0.
|
||||
**
|
||||
** `bat` is RETAINED by the caller.
|
||||
*/
|
||||
c3_l
|
||||
u3_cj_find(u3_noun bat);
|
||||
|
||||
/* u3_cj_kick(): try to kick by jet. If no kick, produce u3_none.
|
||||
**
|
||||
** `axe` is RETAINED by the caller; `cor` is RETAINED iff there
|
||||
** is no kick, TRANSFERRED if one.
|
||||
*/
|
||||
u3_weak
|
||||
u3_cj_kick(u3_noun cor,
|
||||
u3_noun axe);
|
||||
|
||||
/* u3_cj_kink(): kick either by jet or by nock.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cj_kink(u3_noun cor,
|
||||
u3_noun axe);
|
||||
|
||||
/* u3_cj_mine(): register core for jets.
|
||||
*/
|
||||
void
|
||||
u3_cj_mine(u3_noun clu,
|
||||
u3_noun cor);
|
||||
|
||||
/* u3_cj_ream(): refresh after restoring from checkpoint.
|
||||
*/
|
||||
void
|
||||
u3_cj_ream(void);
|
||||
|
||||
/* u3_cj_reap(): promote jet state. RETAINS.
|
||||
*/
|
||||
void
|
||||
u3_cj_reap(u3_noun das, u3p(u3_ch_root) har_p);
|
173
include/g/m.h
173
include/g/m.h
@ -1,173 +0,0 @@
|
||||
/* include/g/m.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** System management.
|
||||
**/
|
||||
/* u3_cm_boot(): set up top-level road.
|
||||
*/
|
||||
void
|
||||
u3_cm_boot(c3_o nuu_o, c3_o bug_o);
|
||||
|
||||
/* u3_cm_trap(): setjmp within road.
|
||||
*/
|
||||
#if 0
|
||||
u3_bean
|
||||
u3_cm_trap(void);
|
||||
#else
|
||||
# define u3_cm_trap() (u3_noun)(setjmp(u3R->esc.buf))
|
||||
#endif
|
||||
|
||||
/* u3_cm_signal(): treat a nock-level exception as a signal interrupt.
|
||||
*/
|
||||
void
|
||||
u3_cm_signal(u3_noun sig_l);
|
||||
|
||||
/* u3_cm_bail(): bail out. Does not return.
|
||||
**
|
||||
** Bail motes:
|
||||
**
|
||||
** %exit :: semantic failure
|
||||
** %evil :: bad crypto
|
||||
** %intr :: interrupt
|
||||
** %fail :: execution failure
|
||||
** %foul :: assert failure
|
||||
** %need :: network block
|
||||
** %meme :: out of memory
|
||||
*/
|
||||
c3_i
|
||||
u3_cm_bail(c3_m how_m);
|
||||
|
||||
/* u3_cm_dump(): dump the current road to stderr.
|
||||
*/
|
||||
void
|
||||
u3_cm_dump(void);
|
||||
|
||||
/* u3_cm_file(): load file, as atom, or bail.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_file(c3_c* pas_c);
|
||||
|
||||
/* u3_cm_clear(): clear all allocated data in road.
|
||||
*/
|
||||
void
|
||||
u3_cm_clear(void);
|
||||
|
||||
/* u3_cm_mark(): mark all nouns in the road.
|
||||
*/
|
||||
void
|
||||
u3_cm_mark(void);
|
||||
|
||||
/* u3_cm_error(): bail out with %exit, ct_pushing error.
|
||||
*/
|
||||
c3_i
|
||||
u3_cm_error(c3_c* str_c);
|
||||
|
||||
/* u3_cm_check(): checkpoint memory to file. Asserts u3R == u3H.
|
||||
*/
|
||||
void
|
||||
u3_cm_check(void);
|
||||
|
||||
/* u3_cm_fall(): return to parent road.
|
||||
*/
|
||||
void
|
||||
u3_cm_fall(void);
|
||||
|
||||
/* u3_cm_hate(): new, integrated leap mechanism (enter).
|
||||
*/
|
||||
void
|
||||
u3_cm_hate(c3_w pad_w);
|
||||
|
||||
/* u3_cm_love(): return product from leap.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_love(u3_noun pro);
|
||||
|
||||
/* u3_cm_leap(): in u3R, create a new road within the existing one.
|
||||
*/
|
||||
void
|
||||
u3_cm_leap(c3_w pad_w);
|
||||
|
||||
/* u3_cm_golf(): record cap length for u3_flog().
|
||||
*/
|
||||
c3_w
|
||||
u3_cm_golf(void);
|
||||
|
||||
/* u3_cm_flog(): pop the cap.
|
||||
**
|
||||
** A common sequence for inner allocation is:
|
||||
**
|
||||
** c3_w gof_w = u3_cm_golf();
|
||||
** u3_cm_leap();
|
||||
** // allocate some inner stuff...
|
||||
** u3_cm_fall();
|
||||
** // inner stuff is still valid, but on cap
|
||||
** u3_cm_flog(gof_w);
|
||||
**
|
||||
** u3_cm_flog(0) simply clears the cap.
|
||||
*/
|
||||
void
|
||||
u3_cm_flog(c3_w gof_w);
|
||||
|
||||
/* u3_cm_soft(): system soft wrapper. unifies unix and nock errors.
|
||||
**
|
||||
** Produces [%$ result] or [%error (list tank)].
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_soft(c3_w sec_w, u3_funk fun_f, u3_noun arg);
|
||||
|
||||
/* u3_cm_soft_top(): top-level safety wrapper.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_soft_top(c3_w sec_w, // timer seconds
|
||||
c3_w pad_w, // base memory pad
|
||||
u3_funk fun_f,
|
||||
u3_noun arg);
|
||||
|
||||
/* u3_cm_soft_slam: top-level call.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_soft_slam(u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3_cm_soft_sure(): top-level call assumed correct.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_soft_sure(u3_funk fun_f, u3_noun arg);
|
||||
|
||||
/* u3_cm_soft_run(): descend into virtualization context.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_soft_run(u3_noun fly,
|
||||
u3_funq fun_f,
|
||||
u3_noun aga,
|
||||
u3_noun agb);
|
||||
|
||||
/* u3_cm_soft_esc(): namespace lookup to (unit ,*).
|
||||
*/
|
||||
u3_noun
|
||||
u3_cm_soft_esc(u3_noun sam);
|
||||
|
||||
/* u3_cm_water(): produce high and low watermarks. Asserts u3R == u3H.
|
||||
*/
|
||||
void
|
||||
u3_cm_water(c3_w *low_w, c3_w *hig_w);
|
||||
|
||||
/* u3_cm_pretty(): dumb prettyprint to string. RETAIN.
|
||||
*/
|
||||
c3_c*
|
||||
u3_cm_pretty(u3_noun som);
|
||||
|
||||
/* u3_cm_p(): dumb print with caption. RETAIN.
|
||||
*/
|
||||
void
|
||||
u3_cm_p(const c3_c* cap_c, u3_noun som);
|
||||
|
||||
/* u3_cm_tape(): dump a tape to stdout.
|
||||
*/
|
||||
void
|
||||
u3_cm_tape(u3_noun tep);
|
||||
|
||||
/* u3_cm_wall(): dump a wall to stdout.
|
||||
*/
|
||||
void
|
||||
u3_cm_wall(u3_noun wol);
|
@ -1,48 +0,0 @@
|
||||
/* include/g/n.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Generic computation.
|
||||
**/
|
||||
/* u3_cn_nock_on(): produce .*(bus fol).
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_nock_on(u3_noun bus, u3_noun fol);
|
||||
|
||||
/* u3_cn_slam_on(): produce (gat sam).
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_slam_on(u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3_cn_kick_on(): fire `gat` without changing the sample.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_kick_on(u3_noun gat);
|
||||
|
||||
/* u3_cn_nock_un(): produce .*(bus fol), as ++toon.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_nock_un(u3_noun bus, u3_noun fol);
|
||||
|
||||
/* u3_cn_slam_un(): produce (gat sam), as ++toon.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_slam_un(u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3_cn_nock_in(): produce .*(bus fol), as ++toon, in namespace.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_nock_in(u3_noun fly, u3_noun bus, u3_noun fol);
|
||||
|
||||
/* u3_cn_slam_in(): produce (gat sam), as ++toon, in namespace.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_slam_in(u3_noun fly, u3_noun gat, u3_noun sam);
|
||||
|
||||
/* u3_cn_nock_an(): as slam_in(), but with empty fly.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cn_nock_an(u3_noun bus, u3_noun fol);
|
||||
|
||||
|
||||
|
@ -1,60 +0,0 @@
|
||||
/* include/g/t.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tracing.
|
||||
**/
|
||||
/* u3_ct_push(): push on trace stack.
|
||||
*/
|
||||
void
|
||||
u3_ct_push(u3_noun mon);
|
||||
|
||||
/* u3_ct_mean(): push `[%mean roc]` on trace stack.
|
||||
*/
|
||||
void
|
||||
u3_ct_mean(u3_noun roc);
|
||||
|
||||
/* u3_ct_drop(): drop from meaning stack.
|
||||
*/
|
||||
void
|
||||
u3_ct_drop(void);
|
||||
|
||||
/* u3_ct_slog(): print directly.
|
||||
*/
|
||||
void
|
||||
u3_ct_slog(u3_noun hod);
|
||||
|
||||
/* u3_ct_heck(): profile point.
|
||||
*/
|
||||
void
|
||||
u3_ct_heck(u3_atom cog);
|
||||
|
||||
/* u3_ct_samp(): sample.
|
||||
*/
|
||||
void
|
||||
u3_ct_samp(void);
|
||||
|
||||
/* u3_ct_come(): push on profile stack.
|
||||
*/
|
||||
void
|
||||
u3_ct_come(u3_atom cog);
|
||||
|
||||
/* u3_ct_flee(): pop off profile stack.
|
||||
*/
|
||||
void
|
||||
u3_ct_flee(void);
|
||||
|
||||
/* u3_ct_damp(): print and clear profile data.
|
||||
*/
|
||||
void
|
||||
u3_ct_damp(void);
|
||||
|
||||
/* u3_ct_boff(): turn profile sampling off.
|
||||
*/
|
||||
void
|
||||
u3_ct_boff(void);
|
||||
|
||||
/* u3_ct_boot(): turn sampling on.
|
||||
*/
|
||||
void
|
||||
u3_ct_boot(void);
|
127
include/g/v.h
127
include/g/v.h
@ -1,127 +0,0 @@
|
||||
/* include/g/v.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Arvo macros.
|
||||
**/
|
||||
# define u3_do(txt_c, arg) u3_cv_do(txt_c, arg)
|
||||
# define u3_dc(txt_c, a, b) u3_cv_do(txt_c, u3nc(a, b))
|
||||
# define u3_dt(txt_c, a, b, c) u3_cv_do(txt_c, u3nt(a, b, c))
|
||||
# define u3_dq(txt_c, a, b, c, d) u3_cv_do(txt_c, u3nt(a, b, c, d))
|
||||
|
||||
/** Arvo functions. Rather unstructured.
|
||||
**/
|
||||
/* u3_cv_do(): use a kernel function.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_do(const c3_c* txt_c, u3_noun arg);
|
||||
|
||||
/* u3_cv_make(): make a new pier by loading a pill.
|
||||
*/
|
||||
void
|
||||
u3_cv_make(c3_c* pas_c);
|
||||
|
||||
/* u3_cv_jack(): execute kernel formula to bind jets.
|
||||
*/
|
||||
void
|
||||
u3_cv_jack(void);
|
||||
|
||||
/* u3_cv_start(): start time.
|
||||
*/
|
||||
void
|
||||
u3_cv_start(u3_noun now);
|
||||
|
||||
/* u3_cv_arm(): load a kernel arm.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_arm(const c3_c* txt_c);
|
||||
|
||||
/* u3_cv_pike(): poke with floating core.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_pike(u3_noun ovo, u3_noun cor);
|
||||
|
||||
/* u3_cv_nick(): transform enveloped packets, [vir cor].
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_nick(u3_noun vir, u3_noun cor);
|
||||
|
||||
/* u3_cv_do(): use a kernel function.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_do(const c3_c* txt_c, u3_noun arg);
|
||||
|
||||
/* u3_cv_wish(): text expression with cache.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_wish(const c3_c* str_c);
|
||||
|
||||
/* u3_cv_numb(): set the instance number.
|
||||
*/
|
||||
void
|
||||
u3_cv_numb(void);
|
||||
|
||||
/* u3_cv_time(): set the reck time.
|
||||
*/
|
||||
void
|
||||
u3_cv_time(u3_noun now);
|
||||
|
||||
/* u3_cv_peek(): query the reck namespace.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_peek(u3_noun hap);
|
||||
|
||||
/* u3_cv_keep(): measure timer.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_keep(u3_noun hap);
|
||||
|
||||
/* u3_cv_poke(): insert and apply an input ovum (protected).
|
||||
*/
|
||||
u3_noun
|
||||
u3_cv_poke(u3_noun ovo);
|
||||
|
||||
/* u3_cv_http_request(): hear http request on channel (unprotected).
|
||||
*/
|
||||
void
|
||||
u3_cv_http_request(u3_bean sec, u3_noun pox, u3_noun req);
|
||||
|
||||
/* u3_cv_tank(): dump single tank.
|
||||
*/
|
||||
void
|
||||
u3_cv_tank(u3_noun blu, c3_l tab_l, u3_noun tac);
|
||||
|
||||
/* u3_cv_punt(): dump tank list.
|
||||
*/
|
||||
void
|
||||
u3_cv_punt(u3_noun blu, c3_l tab_l, u3_noun tac);
|
||||
|
||||
/* u3_cv_sway(): print trace.
|
||||
*/
|
||||
void
|
||||
u3_cv_sway(u3_noun blu, c3_l tab_l, u3_noun tax);
|
||||
|
||||
/* u3_cv_plan(): queue ovum (external).
|
||||
*/
|
||||
void
|
||||
u3_cv_plan(u3_noun pax, u3_noun fav);
|
||||
|
||||
/* u3_cv_plow(): queue multiple ova (external).
|
||||
*/
|
||||
void
|
||||
u3_cv_plow(u3_noun ova);
|
||||
|
||||
/* u3_cv_hose(): clear initial ovum queue.
|
||||
*/
|
||||
void
|
||||
u3_cv_hose(void);
|
||||
|
||||
/* u3_cv_louse(): last-minute deviltry upon a bail.
|
||||
*/
|
||||
void
|
||||
u3_cv_louse(c3_m how_m);
|
||||
|
||||
/* u3_cv_mark(): mark arvo kernel.
|
||||
*/
|
||||
void
|
||||
u3_cv_mark(void);
|
@ -1,34 +0,0 @@
|
||||
/* include/g/z.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Memoization.
|
||||
***
|
||||
*** The memo cache is keyed by an arbitrary symbolic function
|
||||
*** and a noun argument to that (logical) function. Functions
|
||||
*** are predefined by C-level callers, but 0 means nock.
|
||||
***
|
||||
*** The memo cache is within its road and dies when it falls.
|
||||
***
|
||||
*** Memo functions RETAIN keys and transfer values.
|
||||
**/
|
||||
/* u3_cz_find*(): find in memo cache.
|
||||
*/
|
||||
u3_weak u3_cz_find(u3_mote, u3_noun);
|
||||
u3_weak u3_cz_find_2(u3_mote, u3_noun, u3_noun);
|
||||
u3_weak u3_cz_find_3(u3_mote, u3_noun, u3_noun, u3_noun);
|
||||
u3_weak u3_cz_find_4(u3_mote, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
|
||||
/* u3_cz_save*(): save in memo cache.
|
||||
*/
|
||||
u3_noun u3_cz_save(u3_mote, u3_noun, u3_noun);
|
||||
u3_noun u3_cz_save_2(u3_mote, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cz_save_3(u3_mote, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cz_save_4
|
||||
(u3_mote, u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
|
||||
/* u3_cz_uniq(): uniquify with memo cache.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cz_uniq(u3_noun som);
|
||||
|
@ -1,96 +0,0 @@
|
||||
/* include/f/kjet.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tier 1.
|
||||
**/
|
||||
u3_noun u3_cka_add(u3_noun a, u3_noun b);
|
||||
u3_noun u3_cka_sub(u3_noun a, u3_noun b);
|
||||
u3_noun u3_cka_mul(u3_noun a, u3_noun b);
|
||||
u3_noun u3_cka_gth(u3_noun a, u3_noun b);
|
||||
u3_bean u3_cka_lte(u3_noun a, u3_noun b);
|
||||
|
||||
/** Tier 2.
|
||||
**/
|
||||
u3_noun u3_ckb_lent(u3_noun a);
|
||||
u3_noun u3_ckb_weld(u3_noun a, u3_noun b);
|
||||
u3_noun u3_ckb_flop(u3_noun a);
|
||||
|
||||
/* u3_ckc: tier 3 functions
|
||||
*/
|
||||
/* u3_ckc_lsh(): left shift.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ckc_lsh(u3_noun a, u3_noun b, u3_noun c);
|
||||
|
||||
/* u3_ckc_rsh(): right shift.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ckc_rsh(u3_noun a, u3_noun b, u3_noun c);
|
||||
|
||||
/* u3_ckd: tier 4 functions
|
||||
*/
|
||||
/* u3_ckdb_get(): map get for key `b` in map `a` with u3_none.
|
||||
*/
|
||||
u3_weak
|
||||
u3_ckdb_get(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ckdb_got(): map get for key `b` in map `a` with bail.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ckdb_got(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ckdb_put(): map put for key `b`, value `c` in map `a`.
|
||||
*/
|
||||
u3_weak
|
||||
u3_ckdb_put(u3_noun a, u3_noun b, u3_noun c);
|
||||
|
||||
/* u3_ckdb_has(): test for get.
|
||||
*/
|
||||
u3_bean
|
||||
u3_ckdb_has(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ckdb_gas(): list to map.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ckdb_gas(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ckdi_gas(): list to map.
|
||||
*/
|
||||
u3_noun
|
||||
u3_ckdi_gas(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ckdi_has(): test for presence.
|
||||
*/
|
||||
u3_bean
|
||||
u3_ckdi_has(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ckdi_tap(): map/set convert to list. (solves by_tap also.)
|
||||
*/
|
||||
u3_noun
|
||||
u3_ckdi_tap(u3_noun a, u3_noun b);
|
||||
|
||||
/* u3_ckdi_put(): put in set.
|
||||
*/
|
||||
u3_weak
|
||||
u3_ckdi_put(u3_noun a, u3_noun b);
|
||||
|
||||
# define u3_ckdb_tap(a, b) u3_ckdi_tap(a, b)
|
||||
|
||||
/* u3_cke: tier 5 functions
|
||||
*/
|
||||
/* u3_cke_cue(): expand saved pill.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cke_cue(u3_atom a);
|
||||
|
||||
/* u3_cke_jam(): pack noun as atom.
|
||||
*/
|
||||
u3_atom
|
||||
u3_cke_jam(u3_noun a);
|
||||
|
||||
/* u3_cke_trip: atom to tape.
|
||||
*/
|
||||
u3_noun
|
||||
u3_cke_trip(u3_noun a);
|
||||
|
184
include/j/q.h
184
include/j/q.h
@ -1,184 +0,0 @@
|
||||
/* include/f/qjet.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tier 1.
|
||||
**/
|
||||
u3_noun u3_cqa_add(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_dec(u3_atom);
|
||||
u3_noun u3_cqa_div(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_gte(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_gth(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_inc(u3_atom);
|
||||
u3_noun u3_cqa_lte(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_lth(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_mod(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_mul(u3_atom, u3_atom);
|
||||
u3_noun u3_cqa_sub(u3_atom, u3_atom);
|
||||
|
||||
/** Tier 2.
|
||||
**/
|
||||
u3_noun u3_cqb_bind(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_clap(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_drop(u3_noun);
|
||||
u3_noun u3_cqb_flop(u3_noun);
|
||||
u3_noun u3_cqb_lent(u3_noun);
|
||||
u3_noun u3_cqb_levy(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_lien(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_need(u3_noun);
|
||||
u3_noun u3_cqb_reel(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_roll(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_skim(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_skip(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_scag(u3_atom, u3_noun);
|
||||
u3_noun u3_cqb_slag(u3_atom, u3_noun);
|
||||
u3_noun u3_cqb_snag(u3_atom, u3_noun);
|
||||
u3_noun u3_cqb_sort(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_turn(u3_noun, u3_noun);
|
||||
u3_noun u3_cqb_weld(u3_noun, u3_noun);
|
||||
|
||||
/** Tier 3.
|
||||
**/
|
||||
u3_noun u3_cqc_bex(u3_atom);
|
||||
u3_noun u3_cqc_can(u3_atom, u3_noun);
|
||||
u3_noun u3_cqc_cap(u3_atom);
|
||||
u3_noun u3_cqc_cat(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_con(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_cut(u3_atom, u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_dis(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_dor(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_end(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_gor(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_hor(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_lsh(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_mas(u3_atom);
|
||||
u3_noun u3_cqc_met(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_mix(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_peg(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_rap(u3_atom, u3_noun);
|
||||
u3_noun u3_cqc_rip(u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_rsh(u3_atom, u3_atom, u3_atom);
|
||||
u3_noun u3_cqc_vor(u3_atom, u3_atom);
|
||||
|
||||
/** Tier 4.
|
||||
**/
|
||||
u3_noun u3_cqdb_gas(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdb_get(u3_noun, u3_noun);
|
||||
u3_bean u3_cqdb_has(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdb_int(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdb_put(u3_noun, u3_noun, u3_noun);
|
||||
# define u3_cqdb_tap u3_cqdi_tap
|
||||
u3_noun u3_cqdb_uni(u3_noun, u3_noun);
|
||||
|
||||
u3_noun u3_cqdi_gas(u3_noun, u3_noun);
|
||||
u3_bean u3_cqdi_has(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdi_int(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdi_mer(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdi_put(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdi_tap(u3_noun, u3_noun);
|
||||
u3_noun u3_cqdi_uni(u3_noun, u3_noun);
|
||||
|
||||
/** Tier 5.
|
||||
**/
|
||||
u3_noun u3_cqe_cue(u3_atom);
|
||||
u3_noun u3_cqe_jam(u3_atom);
|
||||
u3_noun u3_cqe_mat(u3_atom);
|
||||
u3_noun u3_cqe_rub(u3_atom, u3_atom);
|
||||
u3_noun u3_cqe_lore(u3_atom);
|
||||
u3_noun u3_cqe_loss(u3_noun, u3_noun);
|
||||
u3_noun u3_cqe_repg(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqe_rexp(u3_noun, u3_noun);
|
||||
u3_noun u3_cqe_trip(u3_atom);
|
||||
|
||||
u3_noun u3_cqea_de(u3_atom, u3_atom);
|
||||
u3_noun u3_cqea_en(u3_atom, u3_atom);
|
||||
|
||||
u3_noun u3_cqe_shax(u3_atom);
|
||||
u3_noun u3_cqe_shas(u3_atom, u3_atom);
|
||||
u3_noun u3_cqe_shal(u3_atom, u3_atom);
|
||||
|
||||
u3_noun u3_cqeo_raw(u3_atom, u3_atom);
|
||||
|
||||
u3_noun u3_cqer_sun(u3_atom);
|
||||
u3_noun u3_cqer_mul(u3_atom, u3_atom);
|
||||
u3_noun u3_cqer_div(u3_atom, u3_atom);
|
||||
u3_noun u3_cqer_add(u3_atom, u3_atom);
|
||||
u3_noun u3_cqer_sub(u3_atom, u3_atom);
|
||||
u3_noun u3_cqer_lte(u3_atom, u3_atom);
|
||||
u3_noun u3_cqer_lth(u3_atom, u3_atom);
|
||||
u3_noun u3_cqer_gte(u3_atom, u3_atom);
|
||||
u3_noun u3_cqer_gth(u3_atom, u3_atom);
|
||||
|
||||
|
||||
/** Tier 6.
|
||||
**/
|
||||
u3_noun u3_cqf_bull(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_cell(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_comb(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_cons(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_core(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_cube(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_face(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_fine(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_fitz(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_flan(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_flay(u3_noun);
|
||||
u3_noun u3_cqf_flip(u3_noun);
|
||||
u3_noun u3_cqf_flor(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_fork(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_hike(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_look(u3_noun, u3_noun);
|
||||
u3_noun u3_cqf_slot(u3_atom, u3_noun);
|
||||
u3_noun u3_cqf_type(u3_noun);
|
||||
|
||||
u3_noun u3_cqfl_bunt(u3_noun, u3_noun);
|
||||
u3_noun u3_cqfl_whip(u3_noun, u3_noun, u3_noun);
|
||||
|
||||
u3_noun u3_cqfp_hack(u3_noun, u3_noun);
|
||||
u3_noun u3_cqfp_late(u3_noun);
|
||||
u3_noun u3_cqfp_open(u3_noun, u3_noun);
|
||||
u3_noun u3_cqfp_rake(u3_noun);
|
||||
|
||||
# define u3_cqfu_van_fan 28
|
||||
# define u3_cqfu_van_rib 58
|
||||
# define u3_cqfu_van_vrf 59
|
||||
# define u3_cqfu_van_vet 118
|
||||
# define u3_cqfu_van_fab 119
|
||||
|
||||
u3_noun u3_cqfu_burn(u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_busk(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_bust(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_conk(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_crop(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_cull(u3_noun, u3_noun, u3_bean, u3_atom, u3_noun);
|
||||
u3_noun u3_cqfu_duck(u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_dung(u3_noun, u3_noun cap, u3_noun);
|
||||
u3_noun u3_cqfu_dunq(u3_noun, const c3_c*, u3_noun);
|
||||
u3_noun u3_cqfu_find(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_fino(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_fink(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_fire(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_firm(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_fish(u3_noun, u3_noun, u3_atom);
|
||||
u3_noun u3_cqfu_fuse(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_gain(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_heal(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_lose(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_mint(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_mull(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_bean u3_cqfu_nest(u3_noun, u3_noun, u3_bean, u3_noun);
|
||||
u3_bean u3_cqfu_orth(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_park(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_peek(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_play(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_repo(u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_rest(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_seek(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_seep(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_shep(u3_noun, const c3_c*, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_shew(u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_sift(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_snub(u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_tack(u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_tock(u3_noun, u3_noun, u3_noun, u3_noun, u3_noun);
|
||||
u3_noun u3_cqfu_wrap(u3_noun, u3_noun, u3_noun);
|
197
include/j/w.h
197
include/j/w.h
@ -1,197 +0,0 @@
|
||||
/* include/f/qjet.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tier 1.
|
||||
**/
|
||||
u3_noun u3_cwa_add(u3_noun);
|
||||
u3_noun u3_cwa_dec(u3_noun);
|
||||
u3_noun u3_cwa_div(u3_noun);
|
||||
u3_noun u3_cwa_gte(u3_noun);
|
||||
u3_noun u3_cwa_gth(u3_noun);
|
||||
u3_noun u3_cwa_lte(u3_noun);
|
||||
u3_noun u3_cwa_lth(u3_noun);
|
||||
u3_noun u3_cwa_mod(u3_noun);
|
||||
u3_noun u3_cwa_mul(u3_noun);
|
||||
u3_noun u3_cwa_sub(u3_noun);
|
||||
|
||||
/** Tier 2.
|
||||
**/
|
||||
u3_noun u3_cwb_bind(u3_noun);
|
||||
u3_noun u3_cwb_clap(u3_noun);
|
||||
u3_noun u3_cwb_drop(u3_noun);
|
||||
u3_noun u3_cwb_flop(u3_noun);
|
||||
u3_noun u3_cwb_lent(u3_noun);
|
||||
u3_noun u3_cwb_levy(u3_noun);
|
||||
u3_noun u3_cwb_lien(u3_noun);
|
||||
u3_noun u3_cwb_need(u3_noun);
|
||||
u3_noun u3_cwb_reel(u3_noun);
|
||||
u3_noun u3_cwb_roll(u3_noun);
|
||||
u3_noun u3_cwb_skim(u3_noun);
|
||||
u3_noun u3_cwb_skip(u3_noun);
|
||||
u3_noun u3_cwb_scag(u3_noun);
|
||||
u3_noun u3_cwb_slag(u3_noun);
|
||||
u3_noun u3_cwb_snag(u3_noun);
|
||||
u3_noun u3_cwb_sort(u3_noun);
|
||||
u3_noun u3_cwb_turn(u3_noun);
|
||||
u3_noun u3_cwb_weld(u3_noun);
|
||||
|
||||
/** Tier 3.
|
||||
**/
|
||||
u3_noun u3_cwc_bex(u3_noun);
|
||||
u3_noun u3_cwc_can(u3_noun);
|
||||
u3_noun u3_cwc_cap(u3_noun);
|
||||
u3_noun u3_cwc_cat(u3_noun);
|
||||
u3_noun u3_cwc_con(u3_noun);
|
||||
u3_noun u3_cwc_cut(u3_noun);
|
||||
u3_noun u3_cwc_dis(u3_noun);
|
||||
u3_noun u3_cwc_dor(u3_noun);
|
||||
u3_noun u3_cwc_end(u3_noun);
|
||||
u3_noun u3_cwc_gor(u3_noun);
|
||||
u3_noun u3_cwc_hor(u3_noun);
|
||||
u3_noun u3_cwc_lsh(u3_noun);
|
||||
u3_noun u3_cwc_mas(u3_noun);
|
||||
u3_noun u3_cwc_met(u3_noun);
|
||||
u3_noun u3_cwc_mix(u3_noun);
|
||||
u3_noun u3_cwc_mug(u3_noun);
|
||||
u3_noun u3_cwc_peg(u3_noun);
|
||||
u3_noun u3_cwc_rap(u3_noun);
|
||||
u3_noun u3_cwc_rip(u3_noun);
|
||||
u3_noun u3_cwc_rsh(u3_noun);
|
||||
u3_noun u3_cwc_vor(u3_noun);
|
||||
|
||||
u3_noun u3_cwcp_ins(u3_noun);
|
||||
u3_noun u3_cwcp_ind(u3_noun);
|
||||
u3_noun u3_cwcp_tos(u3_noun);
|
||||
u3_noun u3_cwcp_tod(u3_noun);
|
||||
|
||||
/** Tier 4.
|
||||
**/
|
||||
u3_noun u3_cwdb_gas(u3_noun);
|
||||
u3_noun u3_cwdb_get(u3_noun);
|
||||
u3_bean u3_cwdb_has(u3_noun);
|
||||
u3_noun u3_cwdb_int(u3_noun);
|
||||
u3_noun u3_cwdb_put(u3_noun);
|
||||
# define u3_cwdb_tap u3_cwdi_tap
|
||||
u3_noun u3_cwdb_uni(u3_noun);
|
||||
|
||||
u3_noun u3_cwdi_gas(u3_noun);
|
||||
u3_bean u3_cwdi_has(u3_noun);
|
||||
u3_noun u3_cwdi_int(u3_noun);
|
||||
u3_noun u3_cwdi_mer(u3_noun);
|
||||
u3_noun u3_cwdi_put(u3_noun);
|
||||
u3_noun u3_cwdi_tap(u3_noun);
|
||||
u3_noun u3_cwdi_uni(u3_noun);
|
||||
|
||||
/** Tier 5.
|
||||
**/
|
||||
u3_noun u3_cwe_cue(u3_noun);
|
||||
u3_noun u3_cwe_jam(u3_noun);
|
||||
u3_noun u3_cwe_mat(u3_noun);
|
||||
u3_noun u3_cwe_rub(u3_noun);
|
||||
u3_noun u3_cwe_lore(u3_noun);
|
||||
u3_noun u3_cwe_loss(u3_noun);
|
||||
u3_noun u3_cwe_mink(u3_noun);
|
||||
u3_noun u3_cwe_mule(u3_noun);
|
||||
u3_noun u3_cwe_repg(u3_noun);
|
||||
u3_noun u3_cwe_rexp(u3_noun);
|
||||
u3_noun u3_cwe_trip(u3_noun);
|
||||
|
||||
u3_noun u3_cwe_pfix(u3_noun);
|
||||
u3_noun u3_cwe_plug(u3_noun);
|
||||
u3_noun u3_cwe_pose(u3_noun);
|
||||
u3_noun u3_cwe_sfix(u3_noun);
|
||||
|
||||
u3_noun u3_cwea_de(u3_noun);
|
||||
u3_noun u3_cwea_en(u3_noun);
|
||||
|
||||
u3_noun u3_cwe_shax(u3_noun);
|
||||
u3_noun u3_cwe_shas(u3_noun);
|
||||
u3_noun u3_cwe_shal(u3_noun);
|
||||
|
||||
u3_noun u3_cweo_raw(u3_noun);
|
||||
|
||||
u3_noun u3_cwee_puck(u3_noun);
|
||||
u3_noun u3_cwee_sign(u3_noun);
|
||||
u3_noun u3_cwee_veri(u3_noun);
|
||||
|
||||
u3_noun u3_cwe_bend_fun(u3_noun);
|
||||
u3_noun u3_cwe_cold_fun(u3_noun);
|
||||
u3_noun u3_cwe_cook_fun(u3_noun);
|
||||
u3_noun u3_cwe_comp_fun(u3_noun);
|
||||
u3_noun u3_cwe_easy_fun(u3_noun);
|
||||
u3_noun u3_cwe_glue_fun(u3_noun);
|
||||
u3_noun u3_cwe_here_fun(u3_noun);
|
||||
u3_noun u3_cwe_just_fun(u3_noun);
|
||||
u3_noun u3_cwe_mask_fun(u3_noun);
|
||||
u3_noun u3_cwe_shim_fun(u3_noun);
|
||||
u3_noun u3_cwe_stag_fun(u3_noun);
|
||||
u3_noun u3_cwe_stew_fun(u3_noun);
|
||||
u3_noun u3_cwe_stir_fun(u3_noun);
|
||||
|
||||
u3_noun u3_cwer_sun(u3_noun);
|
||||
u3_noun u3_cwer_mul(u3_noun);
|
||||
u3_noun u3_cwer_div(u3_noun);
|
||||
u3_noun u3_cwer_add(u3_noun);
|
||||
u3_noun u3_cwer_sub(u3_noun);
|
||||
u3_noun u3_cwer_lte(u3_noun);
|
||||
u3_noun u3_cwer_lth(u3_noun);
|
||||
u3_noun u3_cwer_gte(u3_noun);
|
||||
u3_noun u3_cwer_gth(u3_noun);
|
||||
|
||||
|
||||
/** Tier 6.
|
||||
**/
|
||||
u3_noun u3_cwf_bull(u3_noun);
|
||||
u3_noun u3_cwf_cell(u3_noun);
|
||||
u3_noun u3_cwf_comb(u3_noun);
|
||||
u3_noun u3_cwf_cons(u3_noun);
|
||||
u3_noun u3_cwf_core(u3_noun);
|
||||
u3_noun u3_cwf_cube(u3_noun);
|
||||
u3_noun u3_cwf_face(u3_noun);
|
||||
u3_noun u3_cwf_fine(u3_noun);
|
||||
u3_noun u3_cwf_fitz(u3_noun);
|
||||
u3_noun u3_cwf_flan(u3_noun);
|
||||
u3_noun u3_cwf_flay(u3_noun);
|
||||
u3_noun u3_cwf_flip(u3_noun);
|
||||
u3_noun u3_cwf_flor(u3_noun);
|
||||
u3_noun u3_cwf_fork(u3_noun);
|
||||
u3_noun u3_cwf_hike(u3_noun);
|
||||
u3_noun u3_cwf_look(u3_noun);
|
||||
|
||||
u3_noun u3_cwfl_bunt(u3_noun);
|
||||
u3_noun u3_cwfl_whip(u3_noun);
|
||||
|
||||
u3_noun u3_cwfp_hack(u3_noun);
|
||||
u3_noun u3_cwfp_late(u3_noun);
|
||||
u3_noun u3_cwfp_open(u3_noun);
|
||||
u3_noun u3_cwfp_rake(u3_noun);
|
||||
|
||||
u3_noun u3_cwfu_burn(u3_noun);
|
||||
u3_noun u3_cwfu_busk(u3_noun);
|
||||
u3_noun u3_cwfu_bust(u3_noun);
|
||||
u3_noun u3_cwfu_conk(u3_noun);
|
||||
u3_noun u3_cwfu_crop(u3_noun);
|
||||
u3_noun u3_cwfu_cull(u3_noun);
|
||||
u3_noun u3_cwfu_duck(u3_noun);
|
||||
u3_noun u3_cwfu_find(u3_noun);
|
||||
u3_noun u3_cwfu_fino(u3_noun);
|
||||
u3_noun u3_cwfu_fink(u3_noun);
|
||||
u3_noun u3_cwfu_fire(u3_noun);
|
||||
u3_noun u3_cwfu_firm(u3_noun);
|
||||
u3_noun u3_cwfu_fish(u3_noun);
|
||||
u3_noun u3_cwfu_fuse(u3_noun);
|
||||
u3_noun u3_cwfu_heal(u3_noun);
|
||||
u3_noun u3_cwfu_mint(u3_noun);
|
||||
u3_noun u3_cwfu_mull(u3_noun);
|
||||
u3_bean u3_cwfu_nest(u3_noun);
|
||||
u3_noun u3_cwfu_park(u3_noun);
|
||||
u3_noun u3_cwfu_peek(u3_noun);
|
||||
u3_noun u3_cwfu_play(u3_noun);
|
||||
u3_noun u3_cwfu_repo(u3_noun);
|
||||
u3_noun u3_cwfu_rest(u3_noun);
|
||||
u3_noun u3_cwfu_seek(u3_noun);
|
||||
u3_noun u3_cwfu_seep(u3_noun);
|
||||
u3_noun u3_cwfu_snub(u3_noun);
|
||||
u3_noun u3_cwfu_tock(u3_noun);
|
||||
u3_noun u3_cwfu_wrap(u3_noun);
|
@ -1,40 +0,0 @@
|
||||
/* include/f/arvo.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3_cart: ovum carton.
|
||||
*/
|
||||
struct _u3_cs_arvo;
|
||||
|
||||
typedef struct _u3_cs_cart {
|
||||
u3_noun vir; // effects of ovum
|
||||
u3_bean did; // cart considered for commit?
|
||||
u3_bean cit; // cart committed?
|
||||
c3_d ent_d; // entry in raft queue?
|
||||
u3p(struct _u3_cs_cart) nex_p;
|
||||
} u3_cs_cart;
|
||||
|
||||
/* u3_cs_arvo: modern arvo structure.
|
||||
*/
|
||||
typedef struct _u3_cs_arvo {
|
||||
c3_d ent_d; // event number
|
||||
u3_noun yot; // cached gates
|
||||
u3_noun now; // current time, as noun
|
||||
u3_noun wen; // current time, as text
|
||||
u3_noun sev_l; // instance number
|
||||
u3_noun sen; // instance string
|
||||
u3_noun own; // owner list
|
||||
|
||||
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
|
||||
u3p(u3_cs_cart) egg_p; // exit of ovum queue
|
||||
u3p(u3_cs_cart) geg_p; // entry of ovum queue
|
||||
} ova;
|
||||
} u3_cs_arvo;
|
@ -1,54 +0,0 @@
|
||||
/* include/n/glob.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3_cs_home: all internal (within image) state.
|
||||
*/
|
||||
typedef struct _u3_cs_home {
|
||||
u3_cs_road rod_u; // storage state
|
||||
u3_cs_arvo arv_u; // arvo state
|
||||
} u3_cs_home;
|
||||
|
||||
|
||||
/** Globals.
|
||||
**/
|
||||
/* u3_Loom: base of loom, as a word pointer.
|
||||
*/
|
||||
#if 0
|
||||
c3_global c3_w* u3_Loom;
|
||||
#else
|
||||
# define u3_Loom ((c3_w *)(void *)0x200000000)
|
||||
#endif
|
||||
/* u3_Home / u3H: root of thread. Always north.
|
||||
*/
|
||||
c3_global u3_cs_home* u3_Home;
|
||||
# define u3H u3_Home
|
||||
# define u3A (&(u3_Home->arv_u))
|
||||
|
||||
/* u3_Road / u3R: current road (thread-local).
|
||||
*/
|
||||
c3_global u3_road* u3_Road;
|
||||
# define u3R u3_Road
|
||||
|
||||
/* u3_Dash: jet dashboard.
|
||||
*/
|
||||
extern u3_cs_dash u3_Dash;
|
||||
# define u3D u3_Dash
|
||||
|
||||
/* u3_Pool / u3P: global memory control.
|
||||
*/
|
||||
c3_global u3_cs_pool u3_Pool;
|
||||
# define u3P u3_Pool
|
||||
|
||||
/* u3_Code: memory code.
|
||||
*/
|
||||
#ifdef U3_MEMORY_DEBUG
|
||||
c3_global c3_w u3_Code;
|
||||
#endif
|
||||
|
||||
/* u3_Nock: nock instruction counter.
|
||||
*/
|
||||
c3_global c3_d u3_Nock;
|
||||
# define u3N u3_Nock
|
@ -1,73 +0,0 @@
|
||||
/* include/n/hash.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Straightforward implementation of the classic Bagwell
|
||||
*** HAMT (hash array mapped trie), using a mug hash.
|
||||
***
|
||||
*** Because a mug is 31 bits, the root table is 64 wide.
|
||||
*** Thereupon 5 bits each are warm for each layer. The
|
||||
*** final leaf is simply a linear search.
|
||||
***
|
||||
*** We store an extra "freshly warm" bit for a simple
|
||||
*** clock-algorithm reclamation policy, not yet implemented.
|
||||
*** Search "clock algorithm" to figure it out.
|
||||
**/
|
||||
/* u3_ch_slot: map slot.
|
||||
**
|
||||
** Either a key-value cell or a loom offset, decoded as a pointer
|
||||
** to a u3_ch_node. Matches the u3_noun format - coordinate with
|
||||
** meme.h. The top two bits are:
|
||||
**
|
||||
** 00 - empty (in the root table only)
|
||||
** 01 - table
|
||||
** 02 - entry, stale
|
||||
** 03 - entry, fresh
|
||||
*/
|
||||
typedef c3_w u3_ch_slot;
|
||||
|
||||
/* u3_ch_node: map node.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w map_w;
|
||||
u3_ch_slot sot_w[0];
|
||||
} u3_ch_node;
|
||||
|
||||
/* u3_ch_root: hash root table, with future-proof clock.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w clk_w;
|
||||
u3_ch_slot sot_w[64];
|
||||
} u3_ch_root;
|
||||
|
||||
/* u3_ch_buck: bottom bucket.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w len_w;
|
||||
u3_noun kev[0];
|
||||
} u3_ch_buck;
|
||||
|
||||
/** HAMT macros.
|
||||
***
|
||||
*** Coordinate with u3_noun definition!
|
||||
**/
|
||||
/* u3_ch_slot_is_null(): yes iff slot is empty
|
||||
** u3_ch_slot_is_noun(): yes iff slot contains a key/value cell
|
||||
** u3_ch_slot_is_node(): yes iff slot contains a subtable/bucket
|
||||
** u3_ch_slot_is_warm(): yes iff fresh bit is set
|
||||
** u3_ch_slot_to_node(): slot to node pointer
|
||||
** u3_ch_node_to_slot(): node pointer to slot
|
||||
** u3_ch_slot_to_noun(): slot to cell
|
||||
** u3_ch_noun_to_slot(): cell to slot
|
||||
*/
|
||||
# define u3_ch_slot_is_null(sot) ((0 == ((sot) >> 30)) ? u3_yes : u3_no)
|
||||
# define u3_ch_slot_is_node(sot) ((1 == ((sot) >> 30)) ? u3_yes : u3_no)
|
||||
# define u3_ch_slot_is_noun(sot) ((1 == ((sot) >> 31)) ? u3_yes : u3_no)
|
||||
# define u3_ch_slot_is_warm(sot) (((sot) & 0x40000000) ? u3_yes : u3_no)
|
||||
# define u3_ch_slot_to_node(sot) (u3_co_into((sot) & 0x3fffffff))
|
||||
# define u3_ch_node_to_slot(ptr) (u3_co_outa(ptr) | 0x40000000)
|
||||
# define u3_ch_slot_to_noun(sot) (0x40000000 | (sot))
|
||||
# define u3_ch_noun_to_slot(som) (som)
|
||||
# define u3_ch_noun_be_warm(sot) ((sot) | 0x40000000)
|
||||
# define u3_ch_noun_be_cold(sot) ((sot) & ~0x40000000)
|
||||
|
@ -1,83 +0,0 @@
|
||||
/* include/f/meze.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Nock-specific typedefs.
|
||||
**/
|
||||
/* u3_yes, u3_no, u3_nul;
|
||||
**
|
||||
** Our Martian booleans and list terminator; empty string; not a noun.
|
||||
*/
|
||||
# define u3_yes 0
|
||||
# define u3_no 1
|
||||
# define u3_nul 0
|
||||
# define u3_blip 0
|
||||
|
||||
/* Tools for Martian booleans.
|
||||
*/
|
||||
# define u3_so(x) (u3_yes == (x))
|
||||
# define u3_ne(x) (u3_no == (x))
|
||||
# define u3_say(x) ( (x) ? u3_yes : u3_no )
|
||||
# define u3_not(x) ( (x == u3_yes) ? u3_no : u3_yes )
|
||||
# define u3_and(x, y) ( (u3_so(x) && u3_so(y)) ? u3_yes : u3_no )
|
||||
# define u3_or(x, y) ( (u3_so(x) || u3_so(y)) ? u3_yes : u3_no )
|
||||
|
||||
# define u3_assure(x) if ( u3_ne(x) ) { u3_cm_bail(c3__fail); }
|
||||
# define u3_assent(x) if ( u3_ne(x) ) { u3_cm_bail(c3__exit); }
|
||||
|
||||
/* Word axis macros. For 31-bit axes only.
|
||||
*/
|
||||
/* u3_ax_dep(): number of axis bits.
|
||||
*/
|
||||
# define u3_ax_dep(a_w) (c3_bits_word(a_w) - 1)
|
||||
|
||||
/* u3_ax_cap(): root axis, 2 or 3.
|
||||
*/
|
||||
# define u3_ax_cap(a_w) (0x2 | (a_w >> (u3_ax_dep(a_w) - 1)))
|
||||
|
||||
/* u3_ax_mas(): remainder after cap.
|
||||
*/
|
||||
# define u3_ax_mas(a_w) \
|
||||
( (a_w & ~(1 << u3_ax_dep(a_w))) | (1 << (u3_ax_dep(a_w) - 1)) )
|
||||
|
||||
/* u3_ax_peg(): connect two axes.
|
||||
*/
|
||||
# define u3_ax_peg(a_w, b_w) \
|
||||
( (a_w << u3_ax_dep(b_w)) | (b_w &~ (1 << u3_ax_dep(b_w))) )
|
||||
|
||||
/* Conventional axes for gate call.
|
||||
*/
|
||||
# define u3_cv_pay 3 // payload
|
||||
# define u3_cv_sam 6 // sample
|
||||
# define u3_cv_sam_1 6
|
||||
# define u3_cv_sam_2 12
|
||||
# define u3_cv_sam_3 13
|
||||
# define u3_cv_sam_4 24
|
||||
# define u3_cv_sam_5 25
|
||||
# define u3_cv_sam_6 26
|
||||
# define u3_cv_sam_12 52
|
||||
# define u3_cv_sam_13 53
|
||||
# define u3_cv_sam_7 27
|
||||
# define u3_cv_con 7 // context
|
||||
# define u3_cv_con_2 14 // context
|
||||
# define u3_cv_con_3 15 // context
|
||||
# define u3_cv_con_sam 30 // sample in gate context
|
||||
# define u3_cv_noc 2 // deprecated
|
||||
# define u3_cv_bat 2 // battery
|
||||
|
||||
/** Aliases - selective and syntactically unique.
|
||||
**/
|
||||
# define u3h(som) u3_cx_h(som)
|
||||
# define u3t(som) u3_cx_t(som)
|
||||
# define u3at(axe, som) u3_cx_at(axe, som)
|
||||
|
||||
# define u3nc(a, b) u3_ci_cell(a, b)
|
||||
# define u3nt(a, b, c) u3_ci_trel(a, b, c)
|
||||
# define u3nq(a, b, c, d) u3_ci_qual(a, b, c, d)
|
||||
|
||||
# define u3du(som) (u3_cr_du(som))
|
||||
# define u3ud(som) (u3_cr_ud(som))
|
||||
|
||||
# define u3k(som) u3_ca_gain(som)
|
||||
# define u3z(som) u3_ca_lose(som)
|
||||
|
@ -1,89 +0,0 @@
|
||||
/* include/f/noun.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3_post: pointer offset into u3_Loom; _p suffix; declare as u3p().
|
||||
*/
|
||||
typedef c3_w u3_post;
|
||||
# define u3p(type) u3_post
|
||||
|
||||
/* u3_noun: tagged pointer.
|
||||
**
|
||||
** If bit 31 is 0, a u3_noun is a direct 31-bit atom ("cat").
|
||||
** If bit 31 is 1 and bit 30 0, an indirect atom ("pug").
|
||||
** If bit 31 is 1 and bit 30 1, an indirect cell ("pom").
|
||||
**
|
||||
** Bits 0-29 are a word offset against u3_Loom (u3_post).
|
||||
*/
|
||||
typedef c3_w u3_noun;
|
||||
|
||||
/* u3_none - out-of-band noun.
|
||||
*/
|
||||
# define u3_none (u3_noun)0xffffffff
|
||||
|
||||
/* Informative typedefs. Use if you like.
|
||||
*/
|
||||
typedef u3_noun u3_atom; // must be atom
|
||||
typedef u3_noun u3_term; // @tas
|
||||
typedef u3_noun u3_mote; // @tas
|
||||
typedef u3_noun u3_cell; // must be cell
|
||||
typedef u3_noun u3_trel; // must be triple
|
||||
typedef u3_noun u3_qual; // must be quadruple
|
||||
typedef u3_noun u3_quin; // must be quintuple
|
||||
typedef u3_noun u3_bean; // loobean: 0 == u3_yes, 1 == u3_no
|
||||
typedef u3_noun u3_weak; // may be u3_none
|
||||
typedef u3_noun (*u3_funk)(u3_noun);
|
||||
typedef u3_noun (*u3_funq)(u3_noun, u3_noun);
|
||||
|
||||
/** Typedefs.
|
||||
**/
|
||||
/* u3_atom, u3_cell: logical atom and cell structures.
|
||||
*/
|
||||
typedef struct {
|
||||
c3_w mug_w;
|
||||
} u3_cs_noun;
|
||||
|
||||
typedef struct {
|
||||
c3_w mug_w;
|
||||
c3_w len_w;
|
||||
c3_w buf_w[0];
|
||||
} u3_cs_atom;
|
||||
|
||||
typedef struct {
|
||||
c3_w mug_w;
|
||||
u3_noun hed;
|
||||
u3_noun tel;
|
||||
} u3_cs_cell;
|
||||
|
||||
/* Inside a noun.
|
||||
*/
|
||||
# define u3_co_is_cat(som) (((som) >> 31) ? u3_no : u3_yes)
|
||||
# define u3_co_is_dog(som) (((som) >> 31) ? u3_yes : u3_no)
|
||||
|
||||
# define u3_co_is_pug(som) ((2 == ((som) >> 30)) ? u3_yes : u3_no)
|
||||
# define u3_co_is_pom(som) ((3 == ((som) >> 30)) ? u3_yes : u3_no)
|
||||
# define u3_co_to_off(som) ((som) & 0x3fffffff)
|
||||
# define u3_co_to_ptr(som) (u3_co_into(u3_co_to_off(som)))
|
||||
# define u3_co_to_wtr(som) ((c3_w *)u3_co_to_ptr(som))
|
||||
# define u3_co_to_pug(off) (off | 0x80000000)
|
||||
# define u3_co_to_pom(off) (off | 0xc0000000)
|
||||
|
||||
# define u3_co_is_atom(som) u3_or(u3_co_is_cat(som), \
|
||||
u3_co_is_pug(som))
|
||||
# define u3_co_is_cell(som) u3_co_is_pom(som)
|
||||
# define u3_co_de_twin(dog, dog_w) ((dog & 0xc0000000) | u3_co_outa(dog_w))
|
||||
|
||||
# define u3_co_h(som) \
|
||||
( u3_so(u3_co_is_cell(som)) \
|
||||
? ( ((u3_cs_cell *)u3_co_to_ptr(som))->hed )\
|
||||
: u3_cm_bail(c3__exit) )
|
||||
|
||||
# define u3_co_t(som) \
|
||||
( u3_so(u3_co_is_cell(som)) \
|
||||
? ( ((u3_cs_cell *)u3_co_to_ptr(som))->tel )\
|
||||
: u3_cm_bail(c3__exit) )
|
||||
|
||||
/* u3_cs_hold, u3_cs_move: iterators for memory control.
|
||||
*/
|
238
include/n/road.h
238
include/n/road.h
@ -1,238 +0,0 @@
|
||||
/* include/n/road.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3_cs_box: classic allocation box.
|
||||
**
|
||||
** The box size is also stored at the end of the box in classic
|
||||
** bad ass malloc style. Hence a box is:
|
||||
**
|
||||
** ---
|
||||
** siz_w
|
||||
** use_w
|
||||
** if(debug) cod_w
|
||||
** user data
|
||||
** siz_w
|
||||
** ---
|
||||
**
|
||||
** Do not attempt to adjust this structure!
|
||||
*/
|
||||
typedef struct _u3_cs_box {
|
||||
c3_w siz_w; // size of this box
|
||||
c3_w use_w; // reference count; free if 0
|
||||
# ifdef U3_MEMORY_DEBUG
|
||||
c3_w eus_w; // recomputed refcount
|
||||
c3_w cod_w; // tracing code
|
||||
# endif
|
||||
} u3_cs_box;
|
||||
|
||||
# define u3_co_boxed(len_w) (len_w + c3_wiseof(u3_cs_box) + 1)
|
||||
# define u3_co_boxto(box_v) ( (void *) \
|
||||
( ((c3_w *)(void*)(box_v)) + \
|
||||
c3_wiseof(u3_cs_box) ) )
|
||||
# define u3_co_botox(tox_v) ( (struct _u3_cs_box *) \
|
||||
(void *) \
|
||||
( ((c3_w *)(void*)(tox_v)) - \
|
||||
c3_wiseof(u3_cs_box) ) )
|
||||
|
||||
/* u3_cs_fbox: free node in heap. Sets minimum node size.
|
||||
**
|
||||
*/
|
||||
typedef struct _u3_cs_fbox {
|
||||
u3_cs_box box_u;
|
||||
u3p(struct _u3_cs_fbox) pre_p;
|
||||
u3p(struct _u3_cs_fbox) nex_p;
|
||||
} u3_cs_fbox;
|
||||
|
||||
# define u3_cc_minimum 6
|
||||
# define u3_cc_fbox_no 28
|
||||
|
||||
|
||||
/* u3_cs_road: contiguous allocation and execution context.
|
||||
**
|
||||
** A road is a normal heap-stack system, except that the heap
|
||||
** and stack can point in either direction. Therefore, inside
|
||||
** a road, we can nest another road in the opposite direction.
|
||||
**
|
||||
** When the opposite road completes, its heap is left on top of
|
||||
** the opposite heap's stack. It's no more than the normal
|
||||
** behavior of a stack machine for all subcomputations to push
|
||||
** their results, internally durable, on the stack.
|
||||
**
|
||||
** The performance tradeoff of "leaping" - reversing directions
|
||||
** in the road - is that if the outer computation wants to
|
||||
** preserve the results of the inner one, not just use them for
|
||||
** temporary purposes, it has to copy them.
|
||||
**
|
||||
** This is a trivial cost in some cases, a prohibitive cost in
|
||||
** others. The upside, of course, is that all garbage accrued
|
||||
** in the inner computation is discarded at zero cost.
|
||||
**
|
||||
** The goal of the road system is the ability to *layer* memory
|
||||
** models. If you are allocating on a road, you have no idea
|
||||
** how deep within a nested road system you are - in other words,
|
||||
** you have no idea exactly how durable your result may be.
|
||||
** But free space is never fragmented within a road.
|
||||
**
|
||||
** Roads do not reduce the generality or performance of a memory
|
||||
** system, since even the most complex GC system can be nested
|
||||
** within a road at no particular loss of performance - a road
|
||||
** is just a block of memory. The cost of road allocation is,
|
||||
** at least in theory, the branch prediction hits when we try to
|
||||
** decide which side of the road we're allocating on. The road
|
||||
** system imposes no pointer read or write barriers, of course.
|
||||
**
|
||||
** The road can point in either direction. If cap > hat, it
|
||||
** looks like this ("north"):
|
||||
**
|
||||
** 0 rut hat ffff
|
||||
** | | | |
|
||||
** |~~~~~~~~~~~~-------##########################+++++++$~~~~~|
|
||||
** | | | |
|
||||
** 0 cap mat ffff
|
||||
**
|
||||
** Otherwise, it looks like this ("south"):
|
||||
**
|
||||
** 0 mat cap ffff
|
||||
** | | | |
|
||||
** |~~~~~~~~~~~~$++++++##########################--------~~~~~|
|
||||
** | | | |
|
||||
** 0 hat rut ffff
|
||||
**
|
||||
** Legend: - is durable storage (heap); + is temporary storage
|
||||
** (stack); ~ is deep storage (immutable); $ is the allocation block;
|
||||
** # is free memory.
|
||||
**
|
||||
** Pointer restrictions: pointers stored in + can point anywhere,
|
||||
** except to more central pointers in +. (Ie, all pointers from
|
||||
** stack to stack must point downward on the stack.) Pointers in
|
||||
** - can only point to - or ~; pointers in ~ only point to ~.
|
||||
**
|
||||
** To "leap" is to create a new inner road in the ### free space.
|
||||
** but in the reverse direction, so that when the inner road
|
||||
** "falls" (terminates), its durable storage is left on the
|
||||
** temporary storage of the outer road.
|
||||
**
|
||||
** In all cases, the pointer in a u3_noun is a word offset into
|
||||
** u3H, the top-level road.
|
||||
*/
|
||||
typedef struct _u3_cs_road {
|
||||
struct _u3_cs_road* par_u; // parent road
|
||||
|
||||
struct _u3_cs_road* kid_u; // child road list
|
||||
struct _u3_cs_road* nex_u; // sibling road
|
||||
struct _u3_cs_road* now_u; // current road pointer
|
||||
|
||||
u3p(c3_w) cap_p; // top of transient region
|
||||
u3p(c3_w) hat_p; // top of durable region
|
||||
u3p(c3_w) mat_p; // bottom of transient region
|
||||
u3p(c3_w) rut_p; // bottom of durable region
|
||||
u3p(c3_w) ear_p; // original cap if kid is live
|
||||
|
||||
c3_w fut_w[32]; // futureproof buffer
|
||||
|
||||
struct { // escape buffer
|
||||
union {
|
||||
jmp_buf buf;
|
||||
c3_w buf_w[256]; // futureproofing
|
||||
};
|
||||
} esc;
|
||||
|
||||
struct { // miscellaneous config
|
||||
c3_w fag_w; // flag bits
|
||||
} how; //
|
||||
|
||||
struct { // allocation pools
|
||||
u3p(u3_cs_fbox) fre_p[u3_cc_fbox_no]; // heap by node size log
|
||||
c3_w fre_w; // number of free words
|
||||
} all;
|
||||
|
||||
struct { // jet dashboard
|
||||
u3p(u3_ch_root) har_p; // jet index (old style)
|
||||
u3_noun das; // dashboard (new style)
|
||||
} jed;
|
||||
|
||||
struct { // namespace
|
||||
u3_noun flu; // (list $+(* (unit))), inward
|
||||
} ski;
|
||||
|
||||
struct { // trace stack
|
||||
u3_noun tax; // (list ,*)
|
||||
u3_noun mer; // emergency buffer to release
|
||||
} bug;
|
||||
|
||||
struct { // profile stack
|
||||
c3_d nox_d; // nock steps
|
||||
u3_noun don; // ++path
|
||||
u3_noun day; // profile data, ++doss
|
||||
} pro;
|
||||
|
||||
struct { // memoization
|
||||
u3p(u3_ch_root) har_p; // (map (pair term noun) noun)
|
||||
} cax;
|
||||
} u3_cs_road;
|
||||
typedef u3_cs_road u3_road;
|
||||
|
||||
/** Flags.
|
||||
**/
|
||||
enum u3_cs_flag {
|
||||
u3_cs_flag_debug = 0x1, // debug memory
|
||||
u3_cs_flag_gc = 0x2, // garbage collect once
|
||||
u3_cs_flag_sand = 0x4, // sand mode, bump allocation
|
||||
u3_cs_flag_die = 0x8 // process was asked to exit
|
||||
};
|
||||
|
||||
/** Macros.
|
||||
**/
|
||||
# define u3_co_into(x) ((void *)(u3_Loom + (x)))
|
||||
# define u3_co_outa(p) (((c3_w*)(void*)(p)) - u3_Loom)
|
||||
|
||||
# define u3to(type, x) ((type *) u3_co_into(x))
|
||||
# define u3of(type, x) (u3_co_outa((type *)x))
|
||||
|
||||
# define u3_co_is_north(r) ((r->cap_p > r->hat_p) ? u3_yes : u3_no)
|
||||
# define u3_co_is_south(r) ((u3_so(u3_co_is_north(r))) ? u3_no : u3_yes)
|
||||
|
||||
# define u3_co_open(r) ( (u3_yes == u3_co_is_north(r)) \
|
||||
? (c3_w)(r->cap_p - r->hat_p) \
|
||||
: (c3_w)(r->hat_p - r->cap_p) )
|
||||
|
||||
# define u3_co_north_is_senior(r, dog) \
|
||||
u3_say((u3_co_to_off(dog) < r->rut_p) || \
|
||||
(u3_co_to_off(dog) >= r->mat_p))
|
||||
|
||||
# define u3_co_north_is_junior(r, dog) \
|
||||
u3_say((u3_co_to_off(dog) >= r->cap_p) && \
|
||||
(u3_co_to_off(dog) < r->mat_p))
|
||||
|
||||
# define u3_co_north_is_normal(r, dog) \
|
||||
u3_and(u3_not(u3_co_north_is_senior(r, dog)), \
|
||||
u3_not(u3_co_north_is_junior(r, dog)))
|
||||
|
||||
# define u3_co_south_is_senior(r, dog) \
|
||||
u3_say((u3_co_to_off(dog) < r->mat_p) || \
|
||||
(u3_co_to_off(dog) >= r->rut_p))
|
||||
|
||||
# define u3_co_south_is_junior(r, dog) \
|
||||
u3_say((u3_co_to_off(dog) < r->cap_p) && \
|
||||
(u3_co_to_off(dog) >= r->mat_p))
|
||||
|
||||
# define u3_co_south_is_normal(r, dog) \
|
||||
u3_and(u3_not(u3_co_south_is_senior(r, dog)), \
|
||||
u3_not(u3_co_south_is_junior(r, dog)))
|
||||
|
||||
# define u3_co_is_junior(r, som) \
|
||||
( u3_so(u3_co_is_cat(som)) \
|
||||
? u3_no \
|
||||
: u3_so(u3_co_is_north(r)) \
|
||||
? u3_co_north_is_junior(r, som) \
|
||||
: u3_co_south_is_junior(r, som) )
|
||||
|
||||
# define u3_co_is_senior(r, som) \
|
||||
( u3_so(u3_co_is_cat(som)) \
|
||||
? u3_yes \
|
||||
: u3_so(u3_co_is_north(r)) \
|
||||
? u3_co_north_is_senior(r, som) \
|
||||
: u3_co_south_is_senior(r, som) )
|
@ -1,49 +0,0 @@
|
||||
/* include/n/save.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Data structures.
|
||||
**/
|
||||
/* u3_cs_line: control line.
|
||||
*/
|
||||
typedef struct _u3_cs_line {
|
||||
c3_w pag_w;
|
||||
c3_w mug_w;
|
||||
} u3_cs_line;
|
||||
|
||||
/* u3_cs_control: memory change, control file.
|
||||
*/
|
||||
typedef struct _u3_cs_control {
|
||||
c3_d evt_d; // event number
|
||||
c3_w nor_w; // new page count north
|
||||
c3_w sou_w; // new page count south
|
||||
c3_w pgs_w; // number of changed pages
|
||||
u3_cs_line mem_u[0]; // per page
|
||||
} u3_cs_control;
|
||||
|
||||
/* u3_cs_patch: memory change, top level.
|
||||
*/
|
||||
typedef struct _u3_cs_patch {
|
||||
c3_i ctl_i;
|
||||
c3_i mem_i;
|
||||
u3_cs_control* con_u;
|
||||
} u3_cs_patch;
|
||||
|
||||
/* u3_cs_image: memory segment, open file.
|
||||
*/
|
||||
typedef struct _u3_cs_image {
|
||||
c3_c* nam_c; // segment name
|
||||
c3_i fid_i; // open file, or 0
|
||||
c3_w pgs_w; // length in pages
|
||||
} u3_cs_image;
|
||||
|
||||
/* u3_cs_pool: entire memory system.
|
||||
*/
|
||||
typedef struct _u3_cs_pool {
|
||||
c3_c* cpu_c; // path to
|
||||
c3_d evt_d; // last patch written at event
|
||||
c3_w dit_w[u3_cc_pages >> 5]; // touched since last save
|
||||
u3_cs_image nor_u; // north segment
|
||||
u3_cs_image sou_u; // south segment
|
||||
} u3_cs_pool;
|
||||
|
@ -1,17 +0,0 @@
|
||||
/* include/n/tune.h
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
/** Tuning and configuration.
|
||||
**/
|
||||
# undef U3_MEMORY_DEBUG
|
||||
# ifdef U3_MEMORY_DEBUG
|
||||
# define u3_leak_on(x) (u3_Code = x)
|
||||
# define u3_leak_off (u3_Code = 0)
|
||||
# endif
|
||||
|
||||
# define u3_cc_bits U2_OS_LoomBits // 28, max 29
|
||||
# define u3_cc_page 12 // 16Kbyte pages
|
||||
# define u3_cc_pages (1 << (u3_cc_bits - u3_cc_page)) // 2^16 pages
|
||||
# define u3_cc_words (1 << u3_cc_bits)
|
||||
# define u3_cc_bytes (c3_w)((1 << (2 + u3_cc_bits)))
|
53
j/1/add.c
53
j/1/add.c
@ -1,53 +0,0 @@
|
||||
/* j/1/add.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_add(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
c3_w c = a + b;
|
||||
|
||||
return u3_ci_words(1, &c);
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
mpz_add(a_mp, a_mp, b_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return u3_ci_mp(a_mp);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_add(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_add(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3_cka_add(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_noun c = u3_cqa_add(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
return c;
|
||||
}
|
48
j/1/dec.c
48
j/1/dec.c
@ -1,48 +0,0 @@
|
||||
/* j/1/dec.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_inc(u3_atom a)
|
||||
{
|
||||
return u3_ci_vint(u3k(a));
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3_cqa_dec(u3_atom a)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return u3_cm_error("decrement-underflow");
|
||||
}
|
||||
else {
|
||||
if ( u3_so(u3_co_is_cat(a)) ) {
|
||||
return a - 1;
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
mpz_sub_ui(a_mp, a_mp, 1);
|
||||
|
||||
return u3_ci_mp(a_mp);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_dec(u3_noun cor)
|
||||
{
|
||||
u3_noun a;
|
||||
|
||||
if ( (u3_none == (a = u3_cr_at(u3_cv_sam, cor))) ||
|
||||
(u3_no == u3ud(a)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_dec(a);
|
||||
}
|
||||
}
|
47
j/1/div.c
47
j/1/div.c
@ -1,47 +0,0 @@
|
||||
/* j/1/div.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_div(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
if ( 0 == b ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
return a / b;
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
mpz_tdiv_q(a_mp, a_mp, b_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return u3_ci_mp(a_mp);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_div(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_div(a, b);
|
||||
}
|
||||
}
|
45
j/1/gte.c
45
j/1/gte.c
@ -1,45 +0,0 @@
|
||||
/* j/1/gte.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_gte(u3_atom a, u3_atom b)
|
||||
{
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
return u3_say(a >= b);
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
u3_bean cmp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
cmp = (mpz_cmp(a_mp, b_mp) >= 0) ? u3_yes : u3_no;
|
||||
|
||||
mpz_clear(a_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_gte(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_gte(a, b);
|
||||
}
|
||||
}
|
54
j/1/gth.c
54
j/1/gth.c
@ -1,54 +0,0 @@
|
||||
/* j/1/gth.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_gth(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
return u3_say(a > b);
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
u3_bean cmp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
cmp = (mpz_cmp(a_mp, b_mp) > 0) ? u3_yes : u3_no;
|
||||
|
||||
mpz_clear(a_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_gth(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_gth(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3_cka_gth(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_noun c = u3_cqa_gth(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
return c;
|
||||
}
|
52
j/1/lte.c
52
j/1/lte.c
@ -1,52 +0,0 @@
|
||||
/* j/1/lte.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_lte(u3_atom a, u3_atom b)
|
||||
{
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
return u3_say(a <= b);
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
u3_bean cmp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
cmp = (mpz_cmp(a_mp, b_mp) <= 0) ? u3_yes : u3_no;
|
||||
|
||||
mpz_clear(a_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_lte(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_lte(a, b);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cka_lte(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_noun c = u3_cqa_lte(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
return c;
|
||||
}
|
45
j/1/lth.c
45
j/1/lth.c
@ -1,45 +0,0 @@
|
||||
/* j/1/lth.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_lth(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
return u3_say(a < b);
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
u3_bean cmp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
cmp = (mpz_cmp(a_mp, b_mp) < 0) ? u3_yes : u3_no;
|
||||
|
||||
mpz_clear(a_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_lth(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_lth(a, b);
|
||||
}
|
||||
}
|
53
j/1/mul.c
53
j/1/mul.c
@ -1,53 +0,0 @@
|
||||
/* j/1/mul.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_mul(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
c3_d c = ((c3_d) a) * ((c3_d) b);
|
||||
|
||||
return u3_ci_chubs(1, &c);
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
mpz_mul(a_mp, a_mp, b_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return u3_ci_mp(a_mp);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwa_mul(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_mul(a, b);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cka_mul(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_noun c = u3_cqa_mul(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
return c;
|
||||
}
|
||||
|
60
j/1/sub.c
60
j/1/sub.c
@ -1,60 +0,0 @@
|
||||
/* j/1/sub.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqa_sub(u3_atom a, u3_atom b)
|
||||
{
|
||||
if ( u3_so(u3_co_is_cat(a)) && u3_so(u3_co_is_cat(b)) ) {
|
||||
if ( a < b ) {
|
||||
return u3_cm_error("subtract-underflow");
|
||||
}
|
||||
else return (a - b);
|
||||
}
|
||||
else {
|
||||
mpz_t a_mp, b_mp;
|
||||
|
||||
u3_cr_mp(a_mp, a);
|
||||
u3_cr_mp(b_mp, b);
|
||||
|
||||
if ( mpz_cmp(a_mp, b_mp) < 0 ) {
|
||||
mpz_clear(a_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return u3_cm_error("subtract-underflow");
|
||||
}
|
||||
mpz_sub(a_mp, a_mp, b_mp);
|
||||
mpz_clear(b_mp);
|
||||
|
||||
return u3_ci_mp(a_mp);
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3_cwa_sub(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqa_sub(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3_cka_sub(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_noun c = u3_cqa_sub(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
return c;
|
||||
}
|
37
j/2/clap.c
37
j/2/clap.c
@ -1,37 +0,0 @@
|
||||
/* j/2/clap.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_clap(u3_noun a,
|
||||
u3_noun b,
|
||||
u3_noun c)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return u3k(b);
|
||||
}
|
||||
else if ( 0 == b ) {
|
||||
return u3k(a);
|
||||
}
|
||||
else {
|
||||
return u3nc(0, u3_cn_slam_on(u3k(c), u3nc(u3k(u3t(a)), u3k(u3t(b)))));
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_clap(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b, c;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a,
|
||||
u3_cv_sam_6, &b,
|
||||
u3_cv_sam_7, &c, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_clap(a, b, c);
|
||||
}
|
||||
}
|
42
j/2/levy.c
42
j/2/levy.c
@ -1,42 +0,0 @@
|
||||
/* j/2/levy.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_levy(
|
||||
u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return u3_yes;
|
||||
} else {
|
||||
u3_noun loz;
|
||||
|
||||
if ( u3_no == u3du(a) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else switch ( (loz = u3_cn_slam_on(u3k(b), u3k(u3h(a)))) ) {
|
||||
case u3_yes: return u3_cqb_levy(u3t(a), b);
|
||||
case u3_no: return u3_no;
|
||||
default: u3z(loz);
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_levy(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_levy(a, b);
|
||||
}
|
||||
}
|
40
j/2/lien.c
40
j/2/lien.c
@ -1,40 +0,0 @@
|
||||
/* j/2/lien.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_lien(u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return u3_no;
|
||||
} else {
|
||||
u3_noun loz;
|
||||
|
||||
if ( u3_no == u3du(a) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else switch ( (loz = u3_cn_slam_on(u3k(b), u3k(u3h(a)))) ) {
|
||||
case u3_yes: return u3_yes;
|
||||
case u3_no: return u3_cqb_lien(u3t(a), b);
|
||||
default: u3z(loz);
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_lien(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_lien(a, b);
|
||||
}
|
||||
}
|
39
j/2/reel.c
39
j/2/reel.c
@ -1,39 +0,0 @@
|
||||
/* j/2/reel.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_reel(
|
||||
u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return u3k(u3_cr_at(u3_cv_sam_3, b));
|
||||
}
|
||||
else if ( u3_no == u3du(a) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
u3_noun gim = u3k(u3h(a));
|
||||
u3_noun hur = u3_cqb_reel(u3t(a), b);
|
||||
|
||||
return u3_cn_slam_on(u3k(b), u3nc(gim, hur));
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_reel(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_reel(a, b);
|
||||
}
|
||||
}
|
47
j/2/roll.c
47
j/2/roll.c
@ -1,47 +0,0 @@
|
||||
/* j/2/roll.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_roll(u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return u3k(u3_cr_at(u3_cv_sam_3, b));
|
||||
}
|
||||
else if ( u3_no == u3du(a) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
u3_noun gim = u3k(u3h(a));
|
||||
u3_noun zor = u3k(u3_cr_at(u3_cv_sam_3, b));
|
||||
u3_noun daz = u3_cn_slam_on(u3k(b), u3nc(gim, zor));
|
||||
u3_noun vel = u3_ci_molt(u3k(b), u3_cv_sam_3, daz, 0);
|
||||
|
||||
if ( u3_none == vel ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
u3_noun hox = u3_cqb_roll(u3t(a), vel);
|
||||
|
||||
u3z(vel);
|
||||
return hox;
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_roll(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_roll(a, b);
|
||||
}
|
||||
}
|
||||
|
45
j/2/skim.c
45
j/2/skim.c
@ -1,45 +0,0 @@
|
||||
/* j/2/skim.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_skim(
|
||||
u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return a;
|
||||
}
|
||||
else if ( u3_no == u3du(a) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
u3_noun hoz = u3_cn_slam_on(u3k(b), u3k(u3h(a)));
|
||||
u3_noun vyr = u3_cqb_skim(u3t(a), b);
|
||||
|
||||
switch ( hoz ) {
|
||||
case u3_yes: return u3nc(u3k(u3h(a)), vyr);
|
||||
case u3_no: return vyr;
|
||||
default: u3z(hoz);
|
||||
u3z(vyr);
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_skim(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_skim(a, b);
|
||||
}
|
||||
}
|
||||
|
45
j/2/snag.c
45
j/2/snag.c
@ -1,45 +0,0 @@
|
||||
/* j/2/snag.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_snag(u3_atom a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( u3_ne(u3_co_is_cat(a)) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else {
|
||||
c3_w len_w = a;
|
||||
|
||||
while ( len_w ) {
|
||||
if ( u3_no == u3du(b) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
b = u3t(b);
|
||||
len_w--;
|
||||
}
|
||||
if ( u3_no == u3du(b) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
return u3k(u3h(b));
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_snag(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_snag(a, b);
|
||||
}
|
||||
}
|
37
j/2/turn.c
37
j/2/turn.c
@ -1,37 +0,0 @@
|
||||
/* j/2/turn.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_turn(u3_noun a, u3_noun b)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return a;
|
||||
}
|
||||
else if ( u3_no == u3du(a) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
u3_noun one = u3_cn_slam_on(u3k(b), u3k(u3h(a)));
|
||||
u3_noun two = u3_cqb_turn(u3t(a), b);
|
||||
|
||||
return u3nc(one, two);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_turn(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_turn(a, b);
|
||||
}
|
||||
}
|
||||
|
43
j/2/weld.c
43
j/2/weld.c
@ -1,43 +0,0 @@
|
||||
/* j/2/weld.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqb_weld(u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( 0 == a ) {
|
||||
return u3k(b);
|
||||
}
|
||||
else if ( u3_no == u3du(a) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
return u3nc(u3k(u3h(a)), u3_cqb_weld(u3t(a), b));
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwb_weld(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqb_weld(a, b);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_ckb_weld(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_noun c = u3_cqb_weld(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
return c;
|
||||
}
|
||||
|
59
j/3/cat.c
59
j/3/cat.c
@ -1,59 +0,0 @@
|
||||
/* j/3/cat.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_cat(u3_atom a,
|
||||
u3_atom b,
|
||||
u3_atom c)
|
||||
{
|
||||
if ( u3_ne(u3_co_is_cat(a)) || (a >= 32) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else {
|
||||
c3_g a_g = a;
|
||||
c3_w lew_w = u3_cr_met(a_g, b);
|
||||
c3_w ler_w = u3_cr_met(a_g, c);
|
||||
c3_w all_w = (lew_w + ler_w);
|
||||
|
||||
if ( 0 == all_w ) {
|
||||
return 0;
|
||||
} else {
|
||||
c3_w* sal_w = u3_ca_slaq(a_g, all_w);
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else {
|
||||
u3_cr_chop(a_g, 0, lew_w, 0, sal_w, b);
|
||||
u3_cr_chop(a_g, 0, ler_w, lew_w, sal_w, c);
|
||||
}
|
||||
// return u3_ca_moot(sal_w);
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3_cwc_cat(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b, c;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a,
|
||||
u3_cv_sam_6, &b,
|
||||
u3_cv_sam_7, &c, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) ||
|
||||
(u3_no == u3ud(c)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_cat(a, b, c);
|
||||
}
|
||||
}
|
||||
|
52
j/3/con.c
52
j/3/con.c
@ -1,52 +0,0 @@
|
||||
/* j/3/con.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_con(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
c3_w lna_w = u3_cr_met(5, a);
|
||||
c3_w lnb_w = u3_cr_met(5, b);
|
||||
|
||||
if ( (lna_w == 0) && (lnb_w == 0) ) {
|
||||
return 0;
|
||||
} else {
|
||||
c3_w len_w = c3_max(lna_w, lnb_w);
|
||||
c3_w* sal_w = u3_ca_slab(len_w);
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else {
|
||||
c3_w i_w;
|
||||
|
||||
u3_cr_chop(5, 0, lna_w, 0, sal_w, a);
|
||||
|
||||
for ( i_w = 0; i_w < lnb_w; i_w++ ) {
|
||||
sal_w[i_w] |= u3_cr_word(i_w, b);
|
||||
}
|
||||
// return u3_ca_moot(sal_w);
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_con(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_con(a, b);
|
||||
}
|
||||
}
|
74
j/3/cut.c
74
j/3/cut.c
@ -1,74 +0,0 @@
|
||||
/* j/3/cut.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_cut(
|
||||
u3_atom a,
|
||||
u3_atom b,
|
||||
u3_atom c,
|
||||
u3_atom d)
|
||||
{
|
||||
if ( u3_ne(u3_co_is_cat(a)) || (a >= 32) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
if ( u3_ne(u3_co_is_cat(b)) ) {
|
||||
return 0;
|
||||
}
|
||||
if ( u3_ne(u3_co_is_cat(c)) ) {
|
||||
c = 0x7fffffff;
|
||||
}
|
||||
|
||||
{
|
||||
c3_g a_g = a;
|
||||
c3_w b_w = b;
|
||||
c3_w c_w = c;
|
||||
c3_w len_w = u3_cr_met(a_g, d);
|
||||
|
||||
if ( (0 == c_w) || (b_w >= len_w) ) {
|
||||
return 0;
|
||||
}
|
||||
if ( b_w + c_w > len_w ) {
|
||||
c_w = (len_w - b_w);
|
||||
}
|
||||
if ( (b_w == 0) && (c_w == len_w) ) {
|
||||
return u3k(d);
|
||||
}
|
||||
else {
|
||||
c3_w* sal_w = u3_ca_slaq(a_g, c_w);
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
u3_cr_chop(a_g, b_w, c_w, 0, sal_w, d);
|
||||
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_cut(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b, c, d;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a,
|
||||
u3_cv_sam_12, &b,
|
||||
u3_cv_sam_13, &c,
|
||||
u3_cv_sam_7, &d, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) ||
|
||||
(u3_no == u3ud(c)) ||
|
||||
(u3_no == u3ud(d)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_cut(a, b, c, d);
|
||||
}
|
||||
}
|
||||
|
52
j/3/dis.c
52
j/3/dis.c
@ -1,52 +0,0 @@
|
||||
/* j/3/dis.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_dis(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
c3_w lna_w = u3_cr_met(5, a);
|
||||
c3_w lnb_w = u3_cr_met(5, b);
|
||||
|
||||
if ( (lna_w == 0) && (lnb_w == 0) ) {
|
||||
return 0;
|
||||
} else {
|
||||
c3_w len_w = c3_max(lna_w, lnb_w);
|
||||
c3_w* sal_w = u3_ca_slab(len_w);
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else {
|
||||
c3_w i_w;
|
||||
|
||||
u3_cr_chop(5, 0, lna_w, 0, sal_w, a);
|
||||
|
||||
for ( i_w = 0; i_w < len_w; i_w++ ) {
|
||||
sal_w[i_w] &= (i_w >= lnb_w) ? 0 : u3_cr_word(i_w, b);
|
||||
}
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_dis(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_dis(a, b);
|
||||
}
|
||||
}
|
||||
|
52
j/3/dor.c
52
j/3/dor.c
@ -1,52 +0,0 @@
|
||||
/* j/3/dor.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_dor(
|
||||
u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
if ( u3_yes == u3_cr_sing(a, b) ) {
|
||||
return u3_yes;
|
||||
}
|
||||
else {
|
||||
if ( u3_yes == u3ud(a) ) {
|
||||
if ( u3_yes == u3ud(b) ) {
|
||||
return u3_cqa_lth(a, b);
|
||||
}
|
||||
else {
|
||||
return u3_yes;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( u3_yes == u3ud(b) ) {
|
||||
return u3_no;
|
||||
}
|
||||
else {
|
||||
if ( u3_yes == u3_cr_sing(u3h(a), u3h(b)) ) {
|
||||
return u3_cqc_dor(u3t(a), u3t(b));
|
||||
}
|
||||
else return u3_cqc_dor(u3h(a), u3h(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_dor(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_dor(a, b);
|
||||
}
|
||||
}
|
||||
|
63
j/3/end.c
63
j/3/end.c
@ -1,63 +0,0 @@
|
||||
/* j/3/end.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_end(
|
||||
u3_atom a,
|
||||
u3_atom b,
|
||||
u3_atom c)
|
||||
{
|
||||
if ( u3_ne(u3_co_is_cat(a)) || (a >= 32) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else if ( u3_ne(u3_co_is_cat(b)) ) {
|
||||
return u3k(c);
|
||||
}
|
||||
else {
|
||||
c3_g a_g = a;
|
||||
c3_w b_w = b;
|
||||
c3_w len_w = u3_cr_met(a_g, c);
|
||||
|
||||
if ( 0 == b_w ) {
|
||||
return 0;
|
||||
}
|
||||
else if ( b_w >= len_w ) {
|
||||
return u3k(c);
|
||||
}
|
||||
else {
|
||||
c3_w* sal_w = u3_ca_slaq(a_g, b_w);
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
u3_cr_chop(a_g, 0, b_w, 0, sal_w, c);
|
||||
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_end(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b, c;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a,
|
||||
u3_cv_sam_6, &b,
|
||||
u3_cv_sam_7, &c, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) ||
|
||||
(u3_no == u3ud(c)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_end(a, b, c);
|
||||
}
|
||||
}
|
||||
|
33
j/3/gor.c
33
j/3/gor.c
@ -1,33 +0,0 @@
|
||||
/* j/3/gor.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_gor(u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
c3_w c_w = u3_cr_mug(a);
|
||||
c3_w d_w = u3_cr_mug(b);
|
||||
|
||||
if ( c_w == d_w ) {
|
||||
return u3_cqc_dor(a, b);
|
||||
}
|
||||
else return (c_w < d_w) ? u3_yes : u3_no;
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_gor(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_gor(a, b);
|
||||
}
|
||||
}
|
||||
|
47
j/3/hor.c
47
j/3/hor.c
@ -1,47 +0,0 @@
|
||||
/* j/3/hor.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_hor(u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( u3_yes == u3ud(a) ) {
|
||||
if ( u3_yes == u3ud(b) ) {
|
||||
return u3_cqc_gor(a, b);
|
||||
} else {
|
||||
return u3_yes;
|
||||
}
|
||||
} else {
|
||||
if ( u3_yes == u3ud(b) ) {
|
||||
return u3_no;
|
||||
}
|
||||
else {
|
||||
u3_noun h_a = u3h(a);
|
||||
u3_noun h_b = u3h(b);
|
||||
|
||||
if ( u3_yes == u3_cr_sing(h_a, h_b) ) {
|
||||
return u3_cqc_gor(u3t(a), u3t(b));
|
||||
} else {
|
||||
return u3_cqc_gor(h_a, h_b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_hor(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_hor(a, b);
|
||||
}
|
||||
}
|
||||
|
68
j/3/lsh.c
68
j/3/lsh.c
@ -1,68 +0,0 @@
|
||||
/* j/3/lsh.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_lsh(u3_atom a, u3_atom b, u3_atom c)
|
||||
{
|
||||
if ( u3_ne(u3_co_is_cat(a)) || (a >= 32) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else if ( u3_ne(u3_co_is_cat(b)) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else {
|
||||
c3_g a_g = a;
|
||||
c3_w b_w = b;
|
||||
c3_w len_w = u3_cr_met(a_g, c);
|
||||
|
||||
if ( 0 == len_w ) {
|
||||
return 0;
|
||||
}
|
||||
else if ( (b_w + len_w) < len_w ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
c3_w* sal_w = u3_ca_slaq(a_g, (b_w + len_w));
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
u3_cr_chop(a_g, 0, len_w, b_w, sal_w, c);
|
||||
|
||||
// return u3_ca_moot(sal_w);
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_lsh(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b, c;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a,
|
||||
u3_cv_sam_6, &b,
|
||||
u3_cv_sam_7, &c, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) ||
|
||||
(u3_no == u3ud(c)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_lsh(a, b, c);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_ckc_lsh(u3_noun a, u3_noun b, u3_noun c)
|
||||
{
|
||||
u3_noun d = u3_cqc_lsh(a, b, c);
|
||||
|
||||
u3z(a); u3z(b); u3z(c);
|
||||
return d;
|
||||
}
|
||||
|
46
j/3/mas.c
46
j/3/mas.c
@ -1,46 +0,0 @@
|
||||
/* j/3/mas.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_mas(u3_atom a)
|
||||
{
|
||||
c3_w b_w;
|
||||
u3_atom c, d, e, f;
|
||||
|
||||
b_w = u3_cr_met(0, a);
|
||||
if ( b_w < 2 ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
c = u3_cqc_bex((b_w - 1));
|
||||
d = u3_cqc_bex((b_w - 2));
|
||||
e = u3_cqa_sub(a, c);
|
||||
f = u3_cqc_con(e, d);
|
||||
|
||||
u3z(c);
|
||||
u3z(d);
|
||||
u3z(e);
|
||||
|
||||
return f;
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_mas(u3_noun cor)
|
||||
{
|
||||
u3_noun a;
|
||||
|
||||
if ( (u3_none == (a = u3_cr_at(u3_cv_sam, cor))) ||
|
||||
(u3_no == u3ud(a)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_mas(a);
|
||||
}
|
||||
}
|
||||
|
44
j/3/met.c
44
j/3/met.c
@ -1,44 +0,0 @@
|
||||
/* j/3/met.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_met(
|
||||
u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
if ( u3_ne(u3_co_is_cat(a)) || (a >= 32) ) {
|
||||
if ( 0 == b ) {
|
||||
return 0;
|
||||
} else return 1;
|
||||
}
|
||||
else {
|
||||
c3_w met_w = u3_cr_met(a, b);
|
||||
|
||||
if ( u3_ne(u3_co_is_cat(met_w)) ) {
|
||||
return u3_ci_words(1, &met_w);
|
||||
}
|
||||
else return u3_cr_met(a, b);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_met(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_met(a, b);
|
||||
}
|
||||
}
|
||||
|
52
j/3/mix.c
52
j/3/mix.c
@ -1,52 +0,0 @@
|
||||
/* j/3/mix.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_mix(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
c3_w lna_w = u3_cr_met(5, a);
|
||||
c3_w lnb_w = u3_cr_met(5, b);
|
||||
|
||||
if ( (lna_w == 0) && (lnb_w == 0) ) {
|
||||
return 0;
|
||||
} else {
|
||||
c3_w len_w = c3_max(lna_w, lnb_w);
|
||||
c3_w* sal_w = u3_ca_slab(len_w);
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else {
|
||||
c3_w i_w;
|
||||
|
||||
u3_cr_chop(5, 0, lna_w, 0, sal_w, a);
|
||||
|
||||
for ( i_w = 0; i_w < lnb_w; i_w++ ) {
|
||||
sal_w[i_w] ^= u3_cr_word(i_w, b);
|
||||
}
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_mix(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_mix(a, b);
|
||||
}
|
||||
}
|
||||
|
69
j/3/rsh.c
69
j/3/rsh.c
@ -1,69 +0,0 @@
|
||||
/* j/3/rsh.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_rsh(
|
||||
u3_atom a,
|
||||
u3_atom b,
|
||||
u3_atom c)
|
||||
{
|
||||
if ( u3_ne(u3_co_is_cat(a)) || (a >= 32) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
else if ( u3_ne(u3_co_is_cat(b)) ) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
c3_g a_g = a;
|
||||
c3_w b_w = b;
|
||||
c3_w len_w = u3_cr_met(a_g, c);
|
||||
|
||||
if ( b_w >= len_w ) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
c3_w* sal_w = u3_ca_slaq(a_g, (len_w - b_w));
|
||||
|
||||
if ( 0 == sal_w ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
}
|
||||
u3_cr_chop(a_g, b_w, (len_w - b_w), 0, sal_w, c);
|
||||
|
||||
// return u3_ca_moot(sal_w);
|
||||
return u3_ca_malt(sal_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_rsh(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b, c;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a,
|
||||
u3_cv_sam_6, &b,
|
||||
u3_cv_sam_7, &c, 0)) ||
|
||||
(u3_no == u3ud(a)) ||
|
||||
(u3_no == u3ud(b)) ||
|
||||
(u3_no == u3ud(c)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_rsh(a, b, c);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_ckc_rsh(u3_noun a, u3_noun b, u3_noun c)
|
||||
{
|
||||
u3_noun d = u3_cqc_rsh(a, b, c);
|
||||
|
||||
u3z(a); u3z(b); u3z(c);
|
||||
return d;
|
||||
}
|
||||
|
32
j/3/vor.c
32
j/3/vor.c
@ -1,32 +0,0 @@
|
||||
/* j/3/vor.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqc_vor(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
c3_w c_w = u3_cr_mug(u3_cr_mug(a));
|
||||
c3_w d_w = u3_cr_mug(u3_cr_mug(b));
|
||||
|
||||
if ( c_w == d_w ) {
|
||||
return u3_cqc_dor(a, b);
|
||||
}
|
||||
else return (c_w < d_w) ? u3_yes : u3_no;
|
||||
}
|
||||
u3_noun
|
||||
u3_cwc_vor(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(cor, u3_cv_sam_2, &a, u3_cv_sam_3, &b, 0)) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqc_vor(a, b);
|
||||
}
|
||||
}
|
76
j/4/by_get.c
76
j/4/by_get.c
@ -1,76 +0,0 @@
|
||||
/* j/4/by_get.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_noun
|
||||
u3_cqdb_get(u3_noun a, u3_noun b)
|
||||
{
|
||||
if ( u3_nul == a ) {
|
||||
return u3_nul;
|
||||
}
|
||||
else {
|
||||
u3_noun l_a, n_a, r_a;
|
||||
u3_noun pn_a, qn_a;
|
||||
|
||||
if ( (u3_no == u3_cr_trel(a, &n_a, &l_a, &r_a)) ||
|
||||
(u3_no == u3_cr_cell(n_a, &pn_a, &qn_a) ) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
if ( (u3_yes == u3_cr_sing(b, pn_a)) ) {
|
||||
return u3nc(u3_nul, u3k(qn_a));
|
||||
}
|
||||
else {
|
||||
if ( u3_yes == u3_cqc_gor(b, pn_a) ) {
|
||||
return u3_cqdb_get(l_a, b);
|
||||
}
|
||||
else return u3_cqdb_get(r_a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwdb_get(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam, &b, u3_cv_con_sam, &a, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqdb_get(a, b);
|
||||
}
|
||||
}
|
||||
u3_weak
|
||||
u3_ckdb_get(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_noun c = u3_cqdb_get(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
if ( u3_no == u3_cr_du(c) ) {
|
||||
u3z(c);
|
||||
return u3_none;
|
||||
} else {
|
||||
u3_noun pro = u3k(u3t(c));
|
||||
|
||||
u3z(c);
|
||||
return pro;
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_ckdb_got(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_weak c = u3_ckdb_get(a, b);
|
||||
|
||||
if ( u3_none == c ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else return c;
|
||||
}
|
||||
|
63
j/4/by_has.c
63
j/4/by_has.c
@ -1,63 +0,0 @@
|
||||
/* j/4/by_has.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_bean
|
||||
u3_cqdb_has(
|
||||
u3_noun a,
|
||||
u3_noun b)
|
||||
{
|
||||
if ( u3_nul == a ) {
|
||||
return u3_no;
|
||||
}
|
||||
else {
|
||||
u3_noun l_a, n_a, r_a;
|
||||
u3_noun pn_a, qn_a;
|
||||
|
||||
if ( (u3_no == u3_cr_trel(a, &n_a, &l_a, &r_a)) ||
|
||||
(u3_no == u3_cr_cell(n_a, &pn_a, &qn_a)) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
if ( (u3_yes == u3_cr_sing(b, pn_a)) ) {
|
||||
return u3_yes;
|
||||
}
|
||||
else {
|
||||
if ( u3_yes == u3_cqc_gor(b, pn_a) ) {
|
||||
return u3_cqdb_has(l_a, b);
|
||||
}
|
||||
else return u3_cqdb_has(r_a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwdb_has(
|
||||
u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam, &b, u3_cv_con_sam, &a, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqdb_has(a, b);
|
||||
}
|
||||
}
|
||||
u3_bean
|
||||
u3_ckdb_has(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_weak c = u3_cqdb_has(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
if ( u3_none == c ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else return c;
|
||||
}
|
||||
|
57
j/4/in_has.c
57
j/4/in_has.c
@ -1,57 +0,0 @@
|
||||
/* j/4/in_has.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
/* functions
|
||||
*/
|
||||
u3_bean
|
||||
u3_cqdi_has(u3_noun a, u3_noun b)
|
||||
{
|
||||
if ( u3_nul == a ) {
|
||||
return u3_no;
|
||||
}
|
||||
else {
|
||||
u3_noun l_a, n_a, r_a;
|
||||
|
||||
if ( (u3_no == u3_cr_mean(a, 2, &n_a, 6, &l_a, 7, &r_a, 0)) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
if ( (u3_yes == u3_cr_sing(b, n_a)) ) {
|
||||
return u3_yes;
|
||||
}
|
||||
else {
|
||||
if ( u3_yes == u3_cqc_hor(b, n_a) ) {
|
||||
return u3_cqdi_has(l_a, b);
|
||||
}
|
||||
else return u3_cqdi_has(r_a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cwdi_has(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam, &b, u3_cv_con_sam, &a, 0) ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
} else {
|
||||
return u3_cqdi_has(a, b);
|
||||
}
|
||||
}
|
||||
u3_bean
|
||||
u3_ckdi_has(u3_noun a, u3_noun b)
|
||||
{
|
||||
u3_weak c = u3_cqdi_has(a, b);
|
||||
|
||||
u3z(a); u3z(b);
|
||||
if ( u3_none == c ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else return c;
|
||||
}
|
||||
|
97
j/5/cue.c
97
j/5/cue.c
@ -1,97 +0,0 @@
|
||||
/* j/5/cue.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
static u3_noun
|
||||
_cue_in(u3p(u3_ch_root) har_p,
|
||||
u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
u3_noun p, q;
|
||||
|
||||
if ( 0 == u3_cqc_cut(0, b, 1, a) ) {
|
||||
u3_noun x = u3_cqa_inc(b);
|
||||
u3_noun c = u3_cqe_rub(x, a);
|
||||
|
||||
p = u3_cqa_inc(u3k(u3h(c)));
|
||||
q = u3k(u3t(c));
|
||||
|
||||
u3_ch_put(har_p, u3k(b), u3k(q));
|
||||
|
||||
u3z(c);
|
||||
u3z(x);
|
||||
}
|
||||
else {
|
||||
u3_noun c = u3_cqa_add(2, b);
|
||||
u3_noun l = u3_cqa_inc(b);
|
||||
|
||||
if ( 0 == u3_cqc_cut(0, l, 1, a) ) {
|
||||
u3_noun u, v, w;
|
||||
u3_noun x, y;
|
||||
|
||||
u = _cue_in(har_p, a, c);
|
||||
x = u3_cqa_add(u3h(u), c);
|
||||
v = _cue_in(har_p, a, x);
|
||||
w = u3nc(u3k(u3h(u3t(u))), u3k(u3h(u3t(v))));
|
||||
|
||||
y = u3_cqa_add(u3h(u), u3h(v));
|
||||
p = u3_cqa_add(2, y);
|
||||
|
||||
q = w;
|
||||
u3_ch_put(har_p, u3k(b), u3k(q));
|
||||
|
||||
u3z(u); u3z(v); u3z(x); u3z(y);
|
||||
}
|
||||
else {
|
||||
u3_noun d = u3_cqe_rub(c, a);
|
||||
u3_noun x = u3_ch_get(har_p, u3k(u3t(d)));
|
||||
|
||||
p = u3_cqa_add(2, u3h(d));
|
||||
if ( u3_none == x ) {
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
q = x;
|
||||
u3z(d);
|
||||
}
|
||||
u3z(l);
|
||||
u3z(c);
|
||||
}
|
||||
return u3nt(p, q, 0);
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3_cqe_cue(u3_atom a)
|
||||
{
|
||||
u3p(u3_ch_root) har_p = u3_ch_new();
|
||||
|
||||
u3_noun x = _cue_in(har_p, a, 0);
|
||||
u3_noun y = u3k(u3h(u3t(x)));
|
||||
|
||||
u3_ch_free(har_p);
|
||||
|
||||
u3z(x);
|
||||
return y;
|
||||
}
|
||||
u3_noun
|
||||
u3_cwe_cue(u3_noun cor)
|
||||
{
|
||||
u3_noun a;
|
||||
|
||||
if ( (u3_none == (a = u3_cr_at(u3_cv_sam, cor))) ) {
|
||||
return u3_cm_bail(c3__fail);
|
||||
} else {
|
||||
return u3_cqe_cue(a);
|
||||
}
|
||||
}
|
||||
u3_noun
|
||||
u3_cke_cue(u3_atom a)
|
||||
{
|
||||
u3_noun b = u3_cqe_cue(a);
|
||||
|
||||
u3z(a);
|
||||
return b;
|
||||
}
|
||||
|
23
j/5/mink.c
23
j/5/mink.c
@ -1,23 +0,0 @@
|
||||
/* j/5/mink.c
|
||||
**
|
||||
** This file is in the public domain.
|
||||
*/
|
||||
#include "all.h"
|
||||
|
||||
|
||||
u3_noun
|
||||
u3_cwe_mink(u3_noun cor)
|
||||
{
|
||||
u3_noun bus, fol, fly;
|
||||
|
||||
if ( u3_no == u3_cr_mean(cor, u3_cv_sam_4, &bus,
|
||||
u3_cv_sam_5, &fol,
|
||||
u3_cv_sam_3, &fly,
|
||||
0) )
|
||||
{
|
||||
return u3_cm_bail(c3__exit);
|
||||
}
|
||||
else {
|
||||
return u3_cn_nock_in(u3k(fly), u3k(bus), u3k(fol));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user