mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 05:22:27 +03:00
Merge branch 'master' of https://github.com/urbit/urbit
This commit is contained in:
commit
0be5716a46
16
Makefile
16
Makefile
@ -1,15 +1,15 @@
|
||||
# A simple makefile.
|
||||
#
|
||||
|
||||
default: all
|
||||
-include .make.conf
|
||||
|
||||
CORE=.MAKEFILE-VERSION
|
||||
|
||||
# Pick one of:
|
||||
# linux
|
||||
# osx
|
||||
|
||||
default: all
|
||||
-include make.conf
|
||||
|
||||
CORE=.MAKEFILE-VERSION
|
||||
|
||||
UNAME=$(shell uname)
|
||||
ifeq ($(UNAME),Darwin)
|
||||
OS=osx
|
||||
@ -352,12 +352,12 @@ LIBCOMMONMARK=outside/commonmark/build/src/libcmark.a
|
||||
|
||||
all: vere
|
||||
|
||||
.MAKEFILE-VERSION: Makefile make.conf
|
||||
.MAKEFILE-VERSION: Makefile .make.conf
|
||||
@echo "Makefile update."
|
||||
@touch .MAKEFILE-VERSION
|
||||
|
||||
make.conf:
|
||||
@echo "# Set custom configuration here, please!" > "make.conf"
|
||||
.make.conf:
|
||||
@echo "# Set custom configuration here, please!" > ".make.conf"
|
||||
|
||||
vere: $(BIN)/vere
|
||||
meme: $(BIN)/meme
|
||||
|
@ -1,9 +1,14 @@
|
||||
;;; hoon-mode.el --- Major mode for editing hoon files for urbit
|
||||
|
||||
;; Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 20014 -2015 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Adam Bliss <abliss@gmail.com>
|
||||
;; Keywords: extensions
|
||||
;; Author:
|
||||
;; * Adam Bliss https://github.com/abliss <abliss@gmail.com>
|
||||
;; Contributors:
|
||||
;; * N Gvrnd https://github.com/ngvrnd
|
||||
;; * TJamesCorcoran https://github.com/TJamesCorcoran <jamescorcoran@gmail.com>
|
||||
;;
|
||||
;; Keywords: extensions, hoon, nock, urbit, neoreaction, Mars
|
||||
|
||||
;; This file is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
@ -25,6 +30,7 @@
|
||||
;; This is my first Major Mode, so don't expect much. It's heavily based on
|
||||
;; SampleMode from the emacs wiki.
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defvar hoon-mode-hook nil)
|
||||
@ -37,6 +43,7 @@
|
||||
|
||||
;;;###autoload
|
||||
(add-to-list 'auto-mode-alist '("\\.hoon$" . hoon-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.hook$" . hoon-mode))
|
||||
|
||||
(defvar hoon-mode-syntax-table
|
||||
(let ((st (make-syntax-table lisp-mode-syntax-table)))
|
||||
@ -95,5 +102,78 @@
|
||||
0) ;;TODO
|
||||
|
||||
|
||||
|
||||
;;----------
|
||||
;; hack the mode line
|
||||
;;----------
|
||||
|
||||
; In the urbit webserver a directory is basically a resource fork,
|
||||
; and contains a single file, always named "hymn.hook". Emacs'
|
||||
; default buffer-naming will, of course, name this hymn.hook.
|
||||
;
|
||||
; But if you are visitng two files, 5/hymn.hook and 6/hymn.hook, they
|
||||
; will both appear the same on the mode line.
|
||||
;
|
||||
; This sucks, and we'd rather have them appear as "5/hymn.hook" and "6/hymn.hook".
|
||||
;
|
||||
; Trivial, right? No.
|
||||
|
||||
; The mode line is an interesting beast.
|
||||
; 1) it's defined in two variables:
|
||||
; * mode-line-format, which includes in turn the variable...
|
||||
; * mode-line-buffer-identification
|
||||
; 2) both of these include "magic" string components which
|
||||
; constitute a micro-DSL (domain specific language), which includes tags like
|
||||
; '%b', indicating that the buffer-name should be substituted in
|
||||
; (see emacs variable docs for 'mode-line-format')
|
||||
; 3) this magic DSL is evaluated by lisp funcs that are written in C
|
||||
; and thus which can not be monkey-patched
|
||||
; https://www.gnu.org/software/emacs/manual/html_node/elisp/Primitive-Function-Type.html
|
||||
; translation: "do not sharpen chainsaw while it is running"
|
||||
; 4) the commands that are executed when the DSL is interpreted are likewise written in C
|
||||
;
|
||||
; The upshot is...
|
||||
;
|
||||
; WAIT. A better way exists. Instead of hacking the mode-line format,
|
||||
; just invoke 'rename-buffer, which also lives down in the C
|
||||
; underbelly. Everything falls out nicely.
|
||||
|
||||
(defvar hoon-buffer-string "")
|
||||
(make-variable-buffer-local 'hoon-buffer-string)
|
||||
|
||||
(defun hoon-mode-hack-the-modeline ()
|
||||
;; (setq mode-line-format
|
||||
;; '("%e"
|
||||
;; mode-line-front-space
|
||||
;; mode-line-mule-info
|
||||
;; mode-line-client
|
||||
;; mode-line-modified
|
||||
;; mode-line-remote
|
||||
;; mode-line-frame-identification
|
||||
;; hoon-buffer-string
|
||||
;; " "
|
||||
;; mode-line-position
|
||||
;; (vc-mode vc-mode)
|
||||
;; " "
|
||||
;; mode-line-modes
|
||||
;; mode-line-misc-info
|
||||
;; mode-line-end-spaces))
|
||||
;; (setq hoon-buffer-string
|
||||
;; (concat
|
||||
;; (nth 1 (reverse (split-string (file-name-directory (buffer-file-name)) "/")))
|
||||
;; "/"
|
||||
;; (file-name-nondirectory (buffer-file-name))))
|
||||
|
||||
(rename-buffer
|
||||
(concat
|
||||
(nth 1 (reverse (split-string (file-name-directory (buffer-file-name)) "/")))
|
||||
"/"
|
||||
(file-name-nondirectory (buffer-file-name))))
|
||||
)
|
||||
|
||||
(add-hook 'hoon-mode-hook 'hoon-mode-hack-the-modeline)
|
||||
|
||||
|
||||
|
||||
(provide 'hoon-mode)
|
||||
;;; hoon.el ends here
|
||||
|
@ -300,6 +300,7 @@
|
||||
# define c3__do c3_s2('d','o')
|
||||
# define c3__doc c3_s3('d','o','c')
|
||||
# define c3__dogo c3_s4('d','o','g','o')
|
||||
# define c3__dojo c3_s4('d','o','j','o')
|
||||
# define c3__dome c3_s4('d','o','m','e')
|
||||
# define c3__done c3_s4('d','o','n','e')
|
||||
# define c3__door c3_s4('d','o','o','r')
|
||||
@ -412,6 +413,7 @@
|
||||
# define c3__gab c3_s3('g','a','b')
|
||||
# define c3__galb c3_s4('g','a','l','b')
|
||||
# define c3__gald c3_s4('g','a','l','d')
|
||||
# define c3__galk c3_s4('g','a','l','k')
|
||||
# define c3__game c3_s4('g','a','m','e')
|
||||
# define c3__gamp c3_s4('g','a','m','p')
|
||||
# define c3__gant c3_s4('g','a','n','t')
|
||||
@ -477,6 +479,7 @@
|
||||
# define c3__head c3_s4('h','e','a','d')
|
||||
# define c3__heal c3_s4('h','e','a','l')
|
||||
# define c3__hear c3_s4('h','e','a','r')
|
||||
# define c3__helm c3_s4('h','e','l','m')
|
||||
# define c3__helo c3_s4('h','e','l','o')
|
||||
# define c3__hep c3_s3('h','e','p')
|
||||
# define c3__hept c3_s4('h','e','p','t')
|
||||
@ -886,6 +889,7 @@
|
||||
# define c3__scry c3_s4('s','c','r','y')
|
||||
# define c3__scsg c3_s4('s','c','s','g')
|
||||
# define c3__seal c3_s4('s','e','a','l')
|
||||
# define c3__seat c3_s4('s','e','a','t')
|
||||
# define c3__see c3_s3('s','e','e')
|
||||
# define c3__seed c3_s4('s','e','e','d')
|
||||
# define c3__seek c3_s4('s','e','e','k')
|
||||
|
@ -178,3 +178,12 @@
|
||||
# else
|
||||
# error "port: timeconvert"
|
||||
# endif
|
||||
|
||||
/* Entropy
|
||||
*/
|
||||
# if defined(U3_OS_bsd) && defined(__OpenBSD__)
|
||||
# define c3_rand(rd) (getentropy((void*)rd, 32) == 0 ? \
|
||||
(void)0 : c3_assert(!"ent"))
|
||||
# else
|
||||
# define c3_rand u3_sist_rand
|
||||
# endif
|
||||
|
1
i/j/q.h
1
i/j/q.h
@ -94,6 +94,7 @@
|
||||
u3_noun u3qea_en(u3_atom, u3_atom);
|
||||
|
||||
u3_noun u3qe_shax(u3_atom);
|
||||
u3_noun u3qe_shay(u3_atom, u3_atom);
|
||||
u3_noun u3qe_shas(u3_atom, u3_atom);
|
||||
u3_noun u3qe_shal(u3_atom, u3_atom);
|
||||
|
||||
|
1
i/j/w.h
1
i/j/w.h
@ -106,6 +106,7 @@
|
||||
u3_noun u3wea_en(u3_noun);
|
||||
|
||||
u3_noun u3we_shax(u3_noun);
|
||||
u3_noun u3we_shay(u3_noun);
|
||||
u3_noun u3we_shas(u3_noun);
|
||||
u3_noun u3we_shal(u3_noun);
|
||||
|
||||
|
@ -1094,6 +1094,11 @@
|
||||
void
|
||||
u3_sist_get(const c3_c* key_c, c3_y* val_y);
|
||||
|
||||
/* u3_sist_rand(): fill 8 words (32 bytes) with high-quality entropy.
|
||||
*/
|
||||
void
|
||||
u3_sist_rand(c3_w* rad_w);
|
||||
|
||||
/** New timer system.
|
||||
**/
|
||||
/* u3_temp_io_init(): initialize time timer.
|
||||
|
61
j/e/shax.c
61
j/e/shax.c
@ -12,7 +12,44 @@
|
||||
|
||||
/* functions
|
||||
*/
|
||||
|
||||
u3_noun
|
||||
u3qe_shay(u3_atom a,
|
||||
u3_atom b)
|
||||
{
|
||||
c3_assert(_(u3a_is_cat(a)));
|
||||
c3_y* fat_y = c3_malloc(a + 1);
|
||||
|
||||
u3r_bytes(0, a, fat_y, b);
|
||||
{
|
||||
c3_y dig_y[32];
|
||||
#if defined(U3_OS_osx)
|
||||
CC_SHA256_CTX ctx_h;
|
||||
|
||||
CC_SHA256_Init(&ctx_h);
|
||||
CC_SHA256_Update(&ctx_h, fat_y, a);
|
||||
CC_SHA256_Final(dig_y, &ctx_h);
|
||||
#else
|
||||
SHA256_CTX ctx_h;
|
||||
|
||||
SHA256_Init(&ctx_h);
|
||||
SHA256_Update(&ctx_h, fat_y, a);
|
||||
SHA256_Final(dig_y, &ctx_h);
|
||||
#endif
|
||||
free(fat_y);
|
||||
return u3i_bytes(32, dig_y);
|
||||
}
|
||||
}
|
||||
|
||||
// u3_noun
|
||||
// u3qe_shax(
|
||||
// u3_atom a)
|
||||
// {
|
||||
// c3_w met_w = u3r_met(3, a);
|
||||
// return u3qe_shay(met_w, a);
|
||||
// }
|
||||
// XX preformance
|
||||
u3_noun
|
||||
u3qe_shax(
|
||||
u3_atom a)
|
||||
{
|
||||
@ -40,6 +77,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
// XX end preformance
|
||||
|
||||
u3_noun
|
||||
u3qe_shal(u3_atom a,
|
||||
u3_atom b)
|
||||
@ -95,6 +134,28 @@
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3we_shay(u3_noun cor)
|
||||
{
|
||||
u3_noun a, b;
|
||||
|
||||
// static int few = 0;
|
||||
// if(few == 0) printf("foo\r\n");
|
||||
// few++; few %= 1000;
|
||||
|
||||
|
||||
if ( (u3_none == (a = u3r_at(u3x_sam_2, cor))) ||
|
||||
(u3_none == (b = u3r_at(u3x_sam_3, cor))) ||
|
||||
(c3n == u3ud(a)) ||
|
||||
(c3n == u3a_is_cat(a)) ||
|
||||
(c3n == u3ud(b)) )
|
||||
{
|
||||
return u3m_bail(c3__exit);
|
||||
} else {
|
||||
return u3qe_shay(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
u3_noun
|
||||
u3we_shal(u3_noun cor)
|
||||
{
|
||||
|
4
j/f/ap.c
4
j/f/ap.c
@ -403,6 +403,7 @@
|
||||
u3k(p_gen),
|
||||
u3k(q_gen)));
|
||||
}
|
||||
#if 0
|
||||
_open_do_pq(cncl) // %:
|
||||
{
|
||||
return u3nq
|
||||
@ -411,6 +412,7 @@
|
||||
u3k(p_gen),
|
||||
u3k(q_gen));
|
||||
}
|
||||
#endif
|
||||
_open_do_pq(cndt) // %.
|
||||
{
|
||||
return u3nt
|
||||
@ -816,7 +818,7 @@
|
||||
_open_p (cltr);
|
||||
_open_p (clsg);
|
||||
_open_pq (cncb);
|
||||
_open_pq (cncl);
|
||||
// _open_pq (cncl);
|
||||
_open_pq (cndt);
|
||||
_open_pqrs(cnkt);
|
||||
_open_pq (cnhp);
|
||||
|
2
j/tree.c
2
j/tree.c
@ -236,6 +236,7 @@ static u3j_harm _mood__hoon_plug_a[] = {{".2", u3we_plug}, {}};
|
||||
static u3j_harm _mood__hoon_pose_a[] = {{".2", u3we_pose}, {}};
|
||||
static u3j_harm _mood__hoon_sfix_a[] = {{".2", u3we_sfix}, {}};
|
||||
static u3j_harm _mood__hoon_shax_a[] = {{".2", u3we_shax}, {}};
|
||||
static u3j_harm _mood__hoon_shay_a[] = {{".2", u3we_shay}, {}};
|
||||
static u3j_harm _mood__hoon_shas_a[] = {{".2", u3we_shas}, {}};
|
||||
static u3j_harm _mood__hoon_shal_a[] = {{".2", u3we_shal}, {}};
|
||||
|
||||
@ -454,6 +455,7 @@ static u3j_core _mood__hoon_d[] =
|
||||
{ "sfix", _mood__hoon_sfix_a },
|
||||
|
||||
{ "shax", _mood__hoon_shax_a },
|
||||
{ "shay", _mood__hoon_shay_a },
|
||||
{ "shas", _mood__hoon_shas_a },
|
||||
{ "shal", _mood__hoon_shal_a },
|
||||
|
||||
|
5
n/a.c
5
n/a.c
@ -522,7 +522,10 @@ void*
|
||||
u3a_calloc(size_t num_i, size_t len_i)
|
||||
{
|
||||
size_t byt_i = num_i * len_i;
|
||||
c3_w* out_w = u3a_malloc(byt_i);
|
||||
c3_w* out_w;
|
||||
|
||||
c3_assert(byt_i / len_i == num_i);
|
||||
out_w = u3a_malloc(byt_i);
|
||||
memset(out_w, 0, byt_i);
|
||||
|
||||
return out_w;
|
||||
|
13
n/t.c
13
n/t.c
@ -44,17 +44,20 @@ void
|
||||
u3t_slog(u3_noun hod)
|
||||
{
|
||||
#ifdef GHETTO
|
||||
static int old;
|
||||
static int old;
|
||||
static struct timeval b4, f2, d0;
|
||||
c3_w ms_w;
|
||||
|
||||
|
||||
if ( old ) {
|
||||
gettimeofday(&f2, 0);
|
||||
gettimeofday(&f2, 0);
|
||||
timersub(&f2, &b4, &d0);
|
||||
ms_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000);
|
||||
printf("%d.%dms ", ms_w, (d0.tv_usec % 1000) / 10);
|
||||
if(ms_w > 10 || 1){
|
||||
printf("%3d.%02dms ", ms_w, (d0.tv_usec % 1000) / 10);
|
||||
gettimeofday(&b4, 0);
|
||||
}
|
||||
}
|
||||
gettimeofday(&b4, 0);
|
||||
else gettimeofday(&b4, 0);
|
||||
old = 1;
|
||||
#endif
|
||||
|
||||
|
11
v/raft.c
11
v/raft.c
@ -1566,18 +1566,25 @@ _raft_punk(u3_noun ovo)
|
||||
#ifdef GHETTO
|
||||
struct timeval b4, f2, d0;
|
||||
gettimeofday(&b4, 0);
|
||||
uL(fprintf(uH, "%%soft %s\n", txt_c));
|
||||
if( c3__belt != u3h(u3t(ovo)) ){
|
||||
uL(fprintf(uH, "%%soft %s\n", txt_c));
|
||||
}
|
||||
#endif
|
||||
|
||||
gon = u3m_soft(sec_w, u3v_poke, u3k(ovo));
|
||||
|
||||
#ifdef GHETTO
|
||||
c3_w ms_w;
|
||||
c3_w clr_w;
|
||||
|
||||
gettimeofday(&f2, 0);
|
||||
timersub(&f2, &b4, &d0);
|
||||
ms_w = (d0.tv_sec * 1000) + (d0.tv_usec / 1000);
|
||||
uL(fprintf(uH, "%%punk %s %d.%dms\n", txt_c, ms_w, (d0.tv_usec % 1000) / 10));
|
||||
clr_w = ms_w > 1000 ? 1 : ms_w < 100 ? 2 : 3; // red, green, yellow
|
||||
if(c3__belt != u3h(u3t(ovo)) || clr_w != 2){
|
||||
uL(fprintf(uH, "\x1b[3%dm%%punk %s %d.%dms\x1b[0m\n",
|
||||
clr_w, txt_c, ms_w, (d0.tv_usec % 1000) / 10));
|
||||
}
|
||||
free(txt_c);
|
||||
#endif
|
||||
|
||||
|
12
v/sist.c
12
v/sist.c
@ -444,10 +444,10 @@ _sist_bask(c3_c* pop_c, u3_noun may)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* _sist_rand(): fill a 256-bit (8-word) buffer.
|
||||
/* u3_sist_rand(): fill a 256-bit (8-word) buffer.
|
||||
*/
|
||||
static void
|
||||
_sist_rand(c3_w* rad_w)
|
||||
void
|
||||
u3_sist_rand(c3_w* rad_w)
|
||||
{
|
||||
c3_i fid_i = open(DEVRANDOM, O_RDONLY);
|
||||
|
||||
@ -589,7 +589,7 @@ _sist_zest()
|
||||
{
|
||||
c3_w rad_w[8];
|
||||
|
||||
_sist_rand(rad_w);
|
||||
c3_rand(rad_w);
|
||||
sal_l = (0x7fffffff & rad_w[0]);
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ _sist_zest()
|
||||
c3_w rad_w[8];
|
||||
u3_noun pas;
|
||||
|
||||
_sist_rand(rad_w);
|
||||
c3_rand(rad_w);
|
||||
pas = u3i_words(2, rad_w);
|
||||
|
||||
u3A->key = _sist_fatt(sal_l, u3k(pas));
|
||||
@ -1201,7 +1201,7 @@ _sist_zen()
|
||||
{
|
||||
c3_w rad_w[8];
|
||||
|
||||
_sist_rand(rad_w);
|
||||
c3_rand(rad_w);
|
||||
return u3i_words(8, rad_w);
|
||||
}
|
||||
|
||||
|
19
v/term.c
19
v/term.c
@ -303,6 +303,7 @@ _term_listen_cb(uv_stream_t *wax_u, int sas_i)
|
||||
{
|
||||
u3_noun tid = u3dc("scot", c3__ud, tty_u->tid_l);
|
||||
u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul);
|
||||
// u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul));
|
||||
u3v_plan(u3k(pax), u3nc(c3__blew, u3nc(80, 25)));
|
||||
u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul));
|
||||
u3z(pax);
|
||||
@ -667,6 +668,20 @@ _term_it_save(u3_noun pax, u3_noun pad)
|
||||
free(pax_c);
|
||||
}
|
||||
|
||||
/* _term_io_flow(): send flow.
|
||||
*/
|
||||
static void
|
||||
_term_io_flow(u3_utty* uty_u)
|
||||
{
|
||||
u3_noun tid = u3dc("scot", c3__ud, uty_u->tid_l);
|
||||
u3_noun pax = u3nq(u3_blip, c3__term, tid, u3_nul);
|
||||
|
||||
u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__talk, u3_nul));
|
||||
// u3v_plan(pax, u3nt(c3__flow, c3__seat, u3_nul));
|
||||
// u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__dojo, u3_nul));
|
||||
// u3v_plan(pax, u3nq(c3__flow, c3__seat, c3__helm, u3_nul));
|
||||
}
|
||||
|
||||
/* _term_io_belt(): send belt.
|
||||
*/
|
||||
static void
|
||||
@ -817,6 +832,9 @@ _term_io_suck_char(u3_utty* uty_u, c3_y cay_y)
|
||||
else if ( 13 == cay_y ) {
|
||||
_term_io_belt(uty_u, u3nc(c3__ret, u3_nul));
|
||||
}
|
||||
else if ( 6 == cay_y ) {
|
||||
_term_io_flow(uty_u); // XX hack
|
||||
}
|
||||
else if ( cay_y <= 26 ) {
|
||||
_term_io_belt(uty_u, u3nc(c3__ctl, ('a' + (cay_y - 1))));
|
||||
}
|
||||
@ -1014,6 +1032,7 @@ u3_term_ef_bake(u3_noun fav)
|
||||
u3_noun pax = u3nq(u3_blip, c3__term, '1', u3_nul);
|
||||
|
||||
u3v_plan(u3k(pax), u3nc(c3__boot, fav));
|
||||
// u3v_plan(u3k(pax), u3nq(c3__flow, c3__seat, c3__dojo, u3_nul));
|
||||
u3v_plan(u3k(pax), u3nc(c3__blew, u3_term_get_blew(1)));
|
||||
u3v_plan(u3k(pax), u3nc(c3__hail, u3_nul));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user