Login
7 branches 0 tags
Ben (X13/Arch) WIP a25bc3e 3 years ago 651 Commits
nujel / bootstrap / binlib.no
#{
05v "Nujel Standalone"
0Es test-context
0D
25v help v [i] v #@[documentation: "Describe 10 functions at offset 1" source: ["Describe 10 functions at offset 1" [when-not [int? i] [set! i [int i]]] [for-each [map [symbol-table off 10] string] [fn [l] [def desc [describe l]] [pfmtln "{l} {desc}"]]] [def sc [/ [symbol-count] 10]] [pfmtln "Help page {i} of {sc}"]]] v #{
10s i
08i 1 v int?
0Bo 7
24
09o 16
10s i
08i 1 v int
0Fs i
0D
10s off
02i 10
08i 2 v symbol-table
10s string
08i 2 v map
25v 'anonymous v [l] v #@[source: [[def desc [describe l]] [pfmtln "{l} {desc}"]]] v #{
10s l
08i 1 v describe
0Es desc
0D
10s l
05v " "
10s desc
08i 3 v cat
08i 1 v println
01
}
08i 2 v for-each
0D
08i 0 v symbol-count
02i 10
08i 2 v /
0Es sc
0D
05v "Help page "
10s i
05v " of "
10s sc
08i 4 v cat
08i 1 v println
01
}
0Es help
0D
25v file/eval v [path environment] v #@[documentation: "Evaluate a Nujel source file in the current context" source: ["Evaluate a Nujel source file in the current context" [when-not environment [set! environment root-closure]] [def source [cons 'do [read [file/read path]]]] [macroexpand/forms source environment]]] v #{
10s environment
0Bo 7
24
09o 11
10s root-closure
0Fs environment
0D
23s do
10s path
08i 1 v file/read
08i 1 v read
14
0Es source
0D
10s source
10s environment
08i 2 v macroexpand/forms
01
}
0Es file/eval
0D
25v file/file? v [filename] v #@[source: [[ref [file/stat filename] :regular-file?]]] v #{
10s filename
08i 1 v file/stat
05v :regular-file?
08i 2 v ref
01
}
0Es file/file?
0D
25v file/dir? v [filename] v #@[source: [[ref [file/stat filename] :directory?]]] v #{
10s filename
08i 1 v file/stat
05v :directory?
08i 2 v ref
01
}
0Es file/dir?
0D
25v directory/read-relative v [path] v #@[source: [[map [directory/read path] [fn [a] [cat path "/" a]]]]] v #{
10s path
08i 1 v directory/read
25v 'anonymous v [a] v #@[source: [[cat path "/" a]]] v #{
10s path
05v "/"
10s a
08i 3 v cat
01
}
08i 2 v map
01
}
0Es directory/read-relative
0D
25v directory/read-recursive v [path] v #@[source: [[flatten [map [directory/read-relative path] [fn [A] [if [file/dir? A] [directory/read-recursive A] A]]]]]] v #{
10s path
08i 1 v directory/read-relative
25v 'anonymous v [A] v #@[source: [[if [file/dir? A] [directory/read-recursive A] A]]] v #{
10s A
08i 1 v file/dir?
0Bo 15
10s A
08i 1 v directory/read-recursive
09o 7
10s A
01
}
08i 2 v map
08i 1 v flatten
01
}
0Es directory/read-recursive
0D
25v popen/trim v [cmd] v #@[documentation: "Run CMD using popen and return the trimmed stdout" source: ["Run CMD using popen and return the trimmed stdout" [trim [cdr [popen cmd]]]]] v #{
10s cmd
08i 1 v popen
12
08i 1 v trim
01
}
0Es popen/trim
01
}#{
05v "nujel"
0Es repl/executable-name
0D
05v #f
0Es repl/parse-args/eval-next
0D
05v #t
0Es repl/parse-args/run-repl
0D
24
08i 1 v tree/new
0Es repl/options
0D
24
08i 1 v tree/new
0Es repl/option-map
0D
25v repl/exception-handler v [error] v #@[source: [[display/error error]]] v #{
10s error
08i 1 v display/error
01
}
0Es repl/exception-handler
0D
24
0Es repl/history
0D
25v repl/prompt v [] v #@[documentation: ">" source: ["> "]] v #{
05v "> "
01
}
0Es repl/prompt
0D
25v repl/wasm v [line] v #@[documentation: "Evaluate LINE in the wasm context" source: ["Evaluate LINE in the wasm context" [try repl/exception-handler [eval-in root-closure [cons do [read line]]]]]] v #{
10s repl/exception-handler
19o 27
10s root-closure
10s do
10s line
08i 1 v read
14
08i 2 v eval-in
16
01
}
0Es repl/wasm
0D
25v repl/readline v [ctx] v #@[source: [[def line [readline [repl/prompt]]] [when [nil? line] [display "Bye!\r\n"] [exit 0]] [def result [eval-in ctx [cons do [read line]]]] [set! repl/history [cons line repl/history]] [println [cat [if [nil? result] "" [str/write result]]]]]] v #{
08i 0 v repl/prompt
08i 1 v readline
0Es line
0D
10s line
08i 1 v nil?
0Bo 23
05v "Bye!\r\n"
08i 1 v print
0D
02i 0
08i 1 v exit
09o 4
24
0D
10s ctx
10s do
10s line
08i 1 v read
14
08i 2 v eval-in
0Es result
0D
10s line
10s repl/history
14
0Fs repl/history
0D
10s result
08i 1 v nil?
0Bo 10
05v ""
09o 12
10s result
08i 1 v str/write
08i 1 v cat
08i 1 v println
01
}
0Es repl/readline
0D
25v repl v [] v #@[source: [[while #t [try repl/exception-handler [repl/readline root-closure]]]]] v #{
02i 0
1B
1C
05v #t
0Bo 24
0D
10s repl/exception-handler
19o 13
10s root-closure
08i 1 v repl/readline
16
09o -26
01
}
0Es repl
0D
25v repl/print-help v [] v #@[source: [[println [cat [ansi-rainbow "Nujel"] " - A Lisp dialect for games.\n"]] [println [cat [ansi-green "Usage:"] " nujel [options] [command_string | file]"]] [println [cat "\nLow-level options - for work on the runtime itself"]] [println [cat "  " [ansi-yellow "v"] " - be verbose"]] [println [cat "\nHigh-level options - for working with/on Nujel code"]] [println [cat "  " [ansi-blue "x"] " - Run the expression following this argument directly"]] [println [cat "  " [ansi-blue "h"] " - Print this help screen"]] [println [cat "\nLong options - for working with/on Nujel code"]] [println [cat "  " [ansi-blue "no-color"] " - Disable ANSI color"]] [println [cat "  " [ansi-blue "color   "] " - Enable ANSI color"]]]] v #{
05v "Nujel"
08i 1 v ansi-rainbow
05v " - A Lisp dialect for games.\n"
08i 2 v cat
08i 1 v println
0D
05v "Usage:"
08i 1 v ansi-green
05v " nujel [options] [command_string | file]"
08i 2 v cat
08i 1 v println
0D
05v "\nLow-level options - for work on the runtime itself"
08i 1 v cat
08i 1 v println
0D
05v "  "
05v "v"
08i 1 v ansi-yellow
05v " - be verbose"
08i 3 v cat
08i 1 v println
0D
05v "\nHigh-level options - for working with/on Nujel code"
08i 1 v cat
08i 1 v println
0D
05v "  "
05v "x"
08i 1 v ansi-blue
05v " - Run the expression following this argument directly"
08i 3 v cat
08i 1 v println
0D
05v "  "
05v "h"
08i 1 v ansi-blue
05v " - Print this help screen"
08i 3 v cat
08i 1 v println
0D
05v "\nLong options - for working with/on Nujel code"
08i 1 v cat
08i 1 v println
0D
05v "  "
05v "no-color"
08i 1 v ansi-blue
05v " - Disable ANSI color"
08i 3 v cat
08i 1 v println
0D
05v "  "
05v "color   "
08i 1 v ansi-blue
05v " - Enable ANSI color"
08i 3 v cat
08i 1 v println
01
}
0Es repl/print-help
0D
10s repl/option-map
23s h
25v 'anonymous v [option] v #@[source: [[repl/print-help] [set! repl/parse-args/run-repl #f]]] v #{
08i 0 v repl/print-help
0D
05v #f
0Fs repl/parse-args/run-repl
01
}
08i 3 v tree/set!
0D
10s repl/option-map
23s no-color
25v 'anonymous v [option] v #@[source: [[set! ansi/disabled ""]]] v #{
05v ""
0Fs ansi/disabled
01
}
08i 3 v tree/set!
0D
10s repl/option-map
23s color
25v 'anonymous v [option] v #@[source: [[set! ansi/disabled #f]]] v #{
05v #f
0Fs ansi/disabled
01
}
08i 3 v tree/set!
0D
10s repl/option-map
23s x
25v 'anonymous v [option] v #@[source: [[set! repl/parse-args/eval-next #t] [set! repl/parse-args/run-repl #f]]] v #{
05v #t
0Fs repl/parse-args/eval-next
0D
05v #f
0Fs repl/parse-args/run-repl
01
}
08i 3 v tree/set!
0D
10s repl/option-map
05v :default
25v 'anonymous v [option] v #@[source: [[tree/set! repl/options option #t]]] v #{
10s repl/options
10s option
05v #t
08i 3 v tree/set!
01
}
08i 3 v tree/set!
0D
25v repl/parse-option v [option] v #@[source: [[[or [ref repl/option-map option] [ref repl/option-map :default]] option]]] v #{
10s repl/option-map
10s option
08i 2 v ref
0C
0Ao 26
0D
10s repl/option-map
05v :default
08i 2 v ref
0C
0Ao 8
0D
05v #f
10s option
1Ai 1
01
}
0Es repl/parse-option
0D
25v repl/parse-options v [options] v #@[source: [[if [== [char-at options 0] 45] [repl/parse-option [string->keyword [cut options 1]]] [for-each [map [split options ""] str->sym] repl/parse-option]]]] v #{
10s options
02i 0
08i 2 v char-at
02i 45
20
0Bo 32
10s options
02i 1
08i 2 v cut
08i 1 v str->sym
08i 1 v symbol->keyword
08i 1 v repl/parse-option
09o 34
10s options
05v ""
08i 2 v split
10s str->sym
08i 2 v map
10s repl/parse-option
08i 2 v for-each
01
}
0Es repl/parse-options
0D
25v repl/parse-arg v [arg] v #@[source: [[cond [repl/parse-args/eval-next [try display/error [eval-in root-closure [cons do [read arg]]] [set! repl/parse-args/eval-next #f]]] [[== [char-at arg 0] 45] [repl/parse-options [string/cut arg 1]]] [#t [try display/error [file/eval arg]] [set! repl/parse-args/run-repl #f]]]]] v #{
10s repl/parse-args/eval-next
0Bo 46
10s display/error
19o 36
10s root-closure
10s do
10s arg
08i 1 v read
14
08i 2 v eval-in
0D
05v #f
0Fs repl/parse-args/eval-next
16
09o 76
10s arg
02i 0
08i 2 v char-at
02i 45
20
0Bo 22
10s arg
02i 1
08i 2 v string/cut
08i 1 v repl/parse-options
09o 40
05v #t
0Bo 32
10s display/error
19o 13
10s arg
08i 1 v file/eval
16
0D
05v #f
0Fs repl/parse-args/run-repl
09o 4
24
01
}
0Es repl/parse-arg
0D
25v repl/parse-args v [args] v #@[source: [[if args [do [repl/parse-arg [car args]] [repl/parse-args [cdr args]]] repl/parse-args/run-repl]]] v #{
10s args
0Bo 27
10s args
11
08i 1 v repl/parse-arg
0D
10s args
12
08i 1 v repl/parse-args
09o 7
10s repl/parse-args/run-repl
01
}
0Es repl/parse-args
0D
25v repl/init/wasm v [args] v #@[source: [[println [cat [ansi-rainbow "Nujel"] " heißt euch willkommen!"]]]] v #{
05v "Nujel"
08i 1 v ansi-rainbow
05v " heißt euch willkommen!"
08i 2 v cat
08i 1 v println
01
}
0Es repl/init/wasm
0D
25v repl/init/bin v [args] v #@[source: [[try repl/exception-handler [set! repl/executable-name [car args]] [when [repl/parse-args [cdr args]] [repl]]]]] v #{
10s repl/exception-handler
19o 36
10s args
11
0Fs repl/executable-name
0D
10s args
12
08i 1 v repl/parse-args
0Bo 11
08i 0 v repl
09o 4
24
16
01
}
0Es repl/init/bin
0D
25v repl/init v args v #@[source: [[if [== System/Architecture 'wasm] [repl/init/wasm args] [repl/init/bin args]]]] v #{
10s System/Architecture
23s wasm
20
0Bo 15
10s args
08i 1 v repl/init/wasm
09o 12
10s args
08i 1 v repl/init/bin
01
}
0Es repl/init
01
}