shrub/include/noun/xtract.h

133 lines
3.1 KiB
C
Raw Normal View History

2014-11-08 01:54:59 +03:00
/* i/n/x.h
2014-09-04 07:44:53 +04:00
**
** This file is in the public domain.
*/
2014-11-18 02:24:40 +03:00
/** Constants.
**/
/* Conventional axes for gate call.
*/
# define u3x_pay 3 // payload
# define u3x_sam 6 // sample
# define u3x_sam_1 6
# define u3x_sam_2 12
# define u3x_sam_3 13
# define u3x_sam_4 24
# define u3x_sam_5 25
# define u3x_sam_6 26
# define u3x_sam_12 52
# define u3x_sam_13 53
# define u3x_sam_7 27
# define u3x_sam_14 54
# define u3x_sam_15 55
2014-11-18 02:24:40 +03:00
# define u3x_con 7 // context
# define u3x_con_2 14 // context
# define u3x_con_3 15 // context
# define u3x_con_sam 30 // sample in gate context
# define u3x_bat 2 // battery
/** Macros.
**/
/* Word axis macros. For 31-bit axes only.
*/
/* u3x_dep(): number of axis bits.
*/
# define u3x_dep(a_w) (c3_bits_word(a_w) - 1)
/* u3x_cap(): root axis, 2 or 3.
*/
# define u3x_cap(a_w) (0x2 | (a_w >> (u3x_dep(a_w) - 1)))
/* u3x_mas(): remainder after cap.
*/
# define u3x_mas(a_w) \
( (a_w & ~(1 << u3x_dep(a_w))) | (1 << (u3x_dep(a_w) - 1)) )
/* u3x_peg(): connect two axes.
*/
# define u3x_peg(a_w, b_w) \
( (a_w << u3x_dep(b_w)) | (b_w &~ (1 << u3x_dep(b_w))) )
/** Functions.
**/
2014-11-06 03:20:01 +03:00
/** u3x_*: read, but bail with c3__exit on a crash.
2014-09-04 07:44:53 +04:00
**/
#if 1
2014-11-06 03:20:01 +03:00
# define u3x_h(som) u3a_h(som)
# define u3x_t(som) u3a_t(som)
2014-09-04 07:44:53 +04:00
#else
2014-11-06 03:20:01 +03:00
/* u3x_h (u3h): head.
2014-09-04 07:44:53 +04:00
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 03:20:01 +03:00
u3x_h(u3_noun som);
2014-09-04 07:44:53 +04:00
2014-11-06 03:20:01 +03:00
/* u3x_t (u3t): tail.
2014-09-04 07:44:53 +04:00
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 03:20:01 +03:00
u3x_t(u3_noun som);
2014-09-04 07:44:53 +04:00
#endif
2014-11-06 03:20:01 +03:00
/* u3x_good(): test for u3_none.
2014-09-04 07:44:53 +04:00
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 03:20:01 +03:00
u3x_good(u3_weak som);
2014-09-04 07:44:53 +04:00
2014-11-06 03:20:01 +03:00
/* u3x_at (u3at): fragment.
2014-09-04 07:44:53 +04:00
*/
2014-09-06 00:13:24 +04:00
u3_noun
2014-11-06 03:20:01 +03:00
u3x_at(u3_noun axe, u3_noun som);
2014-09-04 07:44:53 +04:00
2014-11-06 03:20:01 +03:00
/* u3x_cell():
2014-09-04 07:44:53 +04:00
**
** Divide `a` as a cell `[b c]`.
*/
void
2014-11-06 03:20:01 +03:00
u3x_cell(u3_noun a,
2014-09-06 00:13:24 +04:00
u3_noun* b,
u3_noun* c);
2014-09-04 07:44:53 +04:00
2014-11-06 03:20:01 +03:00
/* u3x_trel():
2014-09-04 07:44:53 +04:00
**
** Divide `a` as a trel `[b c d]`, or bail.
*/
void
2014-11-06 03:20:01 +03:00
u3x_trel(u3_noun a,
2014-09-06 00:13:24 +04:00
u3_noun* b,
u3_noun* c,
u3_noun* d);
2014-09-04 07:44:53 +04:00
2014-11-06 03:20:01 +03:00
/* u3x_qual():
2014-09-04 07:44:53 +04:00
**
** Divide `a` as a quadruple `[b c d e]`.
*/
void
2014-11-06 03:20:01 +03:00
u3x_qual(u3_noun a,
2014-09-06 00:13:24 +04:00
u3_noun* b,
u3_noun* c,
u3_noun* d,
u3_noun* e);
2014-10-22 00:53:27 +04:00
2014-11-06 03:20:01 +03:00
/* u3x_quil():
2014-10-22 00:53:27 +04:00
**
** Divide `a` as a quintuple `[b c d e f]`.
*/
void
2014-11-06 03:20:01 +03:00
u3x_quil(u3_noun a,
2014-10-22 00:53:27 +04:00
u3_noun* b,
u3_noun* c,
u3_noun* d,
u3_noun* e,
u3_noun* f);
/* u3x_hext():
**
** Divide `a` as a hextuple `[b c d e f g]`.
*/
void
u3x_hext(u3_noun a,
u3_noun* b,
u3_noun* c,
u3_noun* d,
u3_noun* e,
u3_noun* f,
u3_noun* g);