├── .gdbinit ├── .github ├── FUNDING.yml └── workflows │ └── lone.yml ├── .gitignore ├── .woodpecker.yaml ├── GNUmakefile ├── LICENSE.AGPLv3 ├── README.md ├── architecture ├── aarch64 │ └── include │ │ └── lone │ │ └── architecture │ │ ├── garbage_collector.c │ │ └── linux │ │ ├── entry_point.c │ │ └── system_calls.c └── x86_64 │ └── include │ └── lone │ └── architecture │ ├── garbage_collector.c │ └── linux │ ├── entry_point.c │ └── system_calls.c ├── documentation └── linux │ └── memory-map.md ├── include ├── lone.h └── lone │ ├── auxiliary_vector.h │ ├── bits.h │ ├── definitions.h │ ├── elf.h │ ├── hash.h │ ├── hash │ └── fnv_1a.h │ ├── linux.h │ ├── lisp.h │ ├── lisp │ ├── definitions.h │ ├── evaluator.h │ ├── garbage_collector.h │ ├── hash.h │ ├── heap.h │ ├── module.h │ ├── modules │ │ ├── embedded.h │ │ ├── intrinsic.h │ │ └── intrinsic │ │ │ ├── bytes.h │ │ │ ├── linux.h │ │ │ ├── list.h │ │ │ ├── lone.h │ │ │ ├── math.h │ │ │ ├── table.h │ │ │ ├── text.h │ │ │ └── vector.h │ ├── printer.h │ ├── reader.h │ ├── segment.h │ ├── types.h │ ├── utilities.h │ ├── value.h │ └── value │ │ ├── bytes.h │ │ ├── function.h │ │ ├── integer.h │ │ ├── list.h │ │ ├── module.h │ │ ├── primitive.h │ │ ├── symbol.h │ │ ├── table.h │ │ ├── text.h │ │ └── vector.h │ ├── memory.h │ ├── memory │ ├── allocator.h │ ├── array.h │ └── functions.h │ ├── segment.h │ ├── stack.h │ ├── system.h │ ├── test.h │ ├── types.h │ └── utilities.h ├── scripts ├── NR.filter ├── NR.generate ├── create-symlinked-directory.bash ├── test.bash └── test.new ├── source ├── lone.c ├── lone │ ├── auxiliary_vector.c │ ├── bits.c │ ├── elf.c │ ├── hash.c │ ├── hash │ │ └── fnv_1a.c │ ├── linux.c │ ├── lisp.c │ ├── lisp │ │ ├── evaluator.c │ │ ├── garbage_collector.c │ │ ├── hash.c │ │ ├── heap.c │ │ ├── module.c │ │ ├── modules │ │ │ ├── embedded.c │ │ │ ├── intrinsic.c │ │ │ └── intrinsic │ │ │ │ ├── bytes.c │ │ │ │ ├── linux.c │ │ │ │ ├── list.c │ │ │ │ ├── lone.c │ │ │ │ ├── math.c │ │ │ │ ├── table.c │ │ │ │ ├── text.c │ │ │ │ └── vector.c │ │ ├── printer.c │ │ ├── reader.c │ │ ├── segment.c │ │ ├── types.c │ │ ├── utilities.c │ │ ├── value.c │ │ └── value │ │ │ ├── bytes.c │ │ │ ├── function.c │ │ │ ├── integer.c │ │ │ ├── list.c │ │ │ ├── module.c │ │ │ ├── primitive.c │ │ │ ├── symbol.c │ │ │ ├── table.c │ │ │ ├── text.c │ │ │ └── vector.c │ ├── memory.c │ ├── memory │ │ ├── allocator.c │ │ ├── array.c │ │ └── functions.c │ ├── segment.c │ ├── stack.c │ ├── system.c │ ├── test.c │ ├── types.c │ └── utilities.c ├── tests │ ├── lone │ │ ├── bits.c │ │ ├── stack.c │ │ └── types.c │ └── system-call.c └── tools │ └── lone-embed.c └── test ├── c └── linux │ └── system-call │ ├── executable │ └── output ├── executable ├── lone ├── bits │ └── executable ├── lisp │ ├── language │ │ ├── semantics │ │ │ ├── hashing │ │ │ │ └── distinguishes-bytes-types │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── tables │ │ │ │ ├── allow-lists-as-keys │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── are-applicable │ │ │ │ │ ├── get │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── set │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ └── are-insertion-ordered │ │ │ │ │ ├── after │ │ │ │ │ ├── deletion-then-insertion │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── deletion │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── insertion │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── update │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── when-parsed │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ └── vectors │ │ │ │ ├── are-applicable │ │ │ │ ├── get │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── set │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── support-setting-values-at-arbitrary-indexes │ │ │ │ ├── input │ │ │ │ └── output │ │ └── syntax │ │ │ ├── ' │ │ │ ├── input │ │ │ └── output │ │ │ ├── list │ │ │ └── dotted-pair │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── number │ │ │ └── 0 │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── table │ │ │ ├── empty │ │ │ │ ├── input │ │ │ │ └── output │ │ │ └── single-value │ │ │ │ ├── input │ │ │ │ └── output │ │ │ └── vector │ │ │ ├── 0 │ │ │ ├── input │ │ │ └── output │ │ │ ├── 1 │ │ │ ├── input │ │ │ └── output │ │ │ ├── 2 │ │ │ ├── input │ │ │ └── output │ │ │ └── 3 │ │ │ ├── input │ │ │ └── output │ ├── modules │ │ └── intrinsic │ │ │ ├── bytes │ │ │ ├── new │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── write-then-read │ │ │ │ ├── 8 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 16 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── 32 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ └── zero? │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── linux │ │ │ ├── argument-count │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 1 │ │ │ │ │ ├── arguments │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── 2 │ │ │ │ │ ├── arguments │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── arguments │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 1 │ │ │ │ │ ├── arguments │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── 2 │ │ │ │ │ ├── arguments │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── environment │ │ │ │ ├── all │ │ │ │ │ ├── environment │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── specific │ │ │ │ │ ├── environment │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ └── program-name │ │ │ │ ├── input │ │ │ │ ├── output │ │ │ │ └── program-name │ │ │ ├── list │ │ │ ├── construct │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── first │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── flatten │ │ │ │ └── levels │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 4 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 5 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── map │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── reduce │ │ │ │ ├── + │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── concatenate │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ └── rest │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── lone │ │ │ ├── begin │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── return-value │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── equal? │ │ │ │ ├── arity │ │ │ │ │ ├── 1 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── integers │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── lists │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── symbols │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── tables │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── texts │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ └── vectors │ │ │ │ │ ├── different │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── equivalent? │ │ │ │ ├── arity │ │ │ │ │ ├── 1 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── integers │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── lists │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── symbols │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── tables │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── texts │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ └── vectors │ │ │ │ │ ├── different │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── identical? │ │ │ │ ├── arity │ │ │ │ │ ├── 1 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── lists │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── symbols │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── tables │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── texts │ │ │ │ │ ├── different │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ └── vectors │ │ │ │ │ ├── different │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── same │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── if │ │ │ │ ├── conditional-evaluation │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── consequent+alternative │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── consequent │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── set │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── lambda │ │ │ │ ├── ! │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── arity │ │ │ │ │ ├── 0 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── 2 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── higher-order │ │ │ │ │ ├── argument │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── return │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ ├── no-code │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── returns-last-value │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── set │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── side-effects │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── variadic │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── let │ │ │ │ ├── multiple │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── no-expressions │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── recursive │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── simple │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── quasiquote │ │ │ │ ├── plain │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── unquote* │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── unquote │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── quote │ │ │ │ ├── list │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── symbol │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── set │ │ │ │ ├── chained │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── simple │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── without-value │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── unless │ │ │ │ ├── false │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── true │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ └── when │ │ │ │ ├── false │ │ │ │ ├── input │ │ │ │ └── output │ │ │ │ └── true │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── math │ │ │ ├── * │ │ │ │ └── arity │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── + │ │ │ │ └── arity │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── - │ │ │ │ ├── arity │ │ │ │ │ ├── 0 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ ├── 3 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ │ └── 4 │ │ │ │ │ │ ├── input │ │ │ │ │ │ └── output │ │ │ │ └── negation │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── < │ │ │ │ └── arity │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── <= │ │ │ │ └── arity │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── > │ │ │ │ └── arity │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── >= │ │ │ │ └── arity │ │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── division │ │ │ │ └── arity │ │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 2 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ ├── 3 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ │ └── 4 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── negative? │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 100 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── -1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── -100 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── positive? │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 100 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── -1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── -100 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ ├── sign │ │ │ │ ├── 0 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── 100 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ ├── -1 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ │ └── -100 │ │ │ │ │ ├── input │ │ │ │ │ └── output │ │ │ └── zero? │ │ │ │ ├── 0 │ │ │ │ ├── input │ │ │ │ └── output │ │ │ │ ├── 1 │ │ │ │ ├── input │ │ │ │ └── output │ │ │ │ ├── 100 │ │ │ │ ├── input │ │ │ │ └── output │ │ │ │ ├── -1 │ │ │ │ ├── input │ │ │ │ └── output │ │ │ │ └── -100 │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── table │ │ │ ├── count │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── delete │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── each │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── get │ │ │ │ ├── input │ │ │ │ └── output │ │ │ └── set │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── text │ │ │ ├── concatenate │ │ │ │ ├── input │ │ │ │ └── output │ │ │ ├── join │ │ │ │ ├── input │ │ │ │ └── output │ │ │ └── to-symbol │ │ │ │ ├── input │ │ │ │ └── output │ │ │ └── vector │ │ │ ├── count │ │ │ ├── input │ │ │ └── output │ │ │ ├── each │ │ │ ├── input │ │ │ └── output │ │ │ ├── get │ │ │ ├── input │ │ │ └── output │ │ │ ├── set │ │ │ ├── input │ │ │ └── output │ │ │ └── slice │ │ │ ├── input │ │ │ └── output │ └── programs │ │ ├── fibonacci │ │ ├── input │ │ └── output │ │ └── hello-world │ │ ├── input │ │ └── output └── types │ └── executable └── tools └── lone-embed ├── script └── segment /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: matheusmoreira 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build directory or symlink 2 | build 3 | -------------------------------------------------------------------------------- /.woodpecker.yaml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: lone 3 | image: archlinux:base-devel 4 | pull: true 5 | when: 6 | - event: [push, pull_request, manual] 7 | branch: master 8 | path: 9 | include: 10 | - 'include/**/*' 11 | - 'source/**/*' 12 | - 'architecture/**/*' 13 | - 'scripts/**/*' 14 | - 'test/**/*' 15 | - 'GNUMakefile' 16 | - '.woodpecker.yaml' 17 | commands: 18 | - make lone 19 | - make tools 20 | - make test 21 | -------------------------------------------------------------------------------- /architecture/aarch64/include/lone/architecture/garbage_collector.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | /** 4 | * Registers may contain pointers to garbage collector roots. 5 | * They must be spilled onto the stack so that they can be marked. 6 | * Link register is the only architectural register, others are conventional. 7 | * Nearly all of arm64's registers may be used as scratch or result registers. 8 | * Probably best to just save all 30 of them just in case. 9 | **/ 10 | typedef long lone_registers[30]; 11 | extern void lone_save_registers(lone_registers); 12 | 13 | __asm__ 14 | ( 15 | 16 | ".global lone_save_registers" "\n" 17 | ".type lone_save_registers,@function" "\n" 18 | 19 | "lone_save_registers:" "\n" // x0 = &lone_registers 20 | "stp x0, x1, [x0, #0 ]" "\n" 21 | "stp x2, x3, [x0, #16 ]" "\n" 22 | "stp x4, x5, [x0, #32 ]" "\n" 23 | "stp x6, x7, [x0, #48 ]" "\n" 24 | "stp x8, x9, [x0, #64 ]" "\n" 25 | "stp x10, x11, [x0, #80 ]" "\n" 26 | "stp x12, x13, [x0, #96 ]" "\n" 27 | "stp x14, x15, [x0, #112]" "\n" 28 | "stp x16, x17, [x0, #128]" "\n" 29 | "stp x18, x19, [x0, #144]" "\n" 30 | "stp x20, x21, [x0, #160]" "\n" 31 | "stp x22, x23, [x0, #176]" "\n" 32 | "stp x24, x25, [x0, #192]" "\n" 33 | "stp x26, x27, [x0, #208]" "\n" 34 | "stp x28, x29, [x0, #224]" "\n" 35 | "ret" "\n" 36 | 37 | ); 38 | -------------------------------------------------------------------------------- /architecture/aarch64/include/lone/architecture/linux/entry_point.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | 7 | /** 8 | * 9 | * initial stack layout - logical 10 | * 11 | * sp → 0 | argc 12 | * 1 | argv 13 | * argv + *argc + 1 | envp 14 | * &(*envp++ == 0) + 1 | auxv 15 | * 16 | * initial stack layout - bytes 17 | * 18 | * sp → 0 | argc 19 | * 8 | argv 20 | * argv + 8 * (*argc + 1) | envp 21 | * &(*envp++ == 0) + 8 | auxv 22 | * 23 | **/ 24 | __asm__ 25 | ( 26 | 27 | ".global lone_start" "\n" // place lone_start in the symbol table 28 | "lone_start:" "\n" // program entry point 29 | 30 | // compute argc, argv, envp and auxv 31 | "ldr x0, [sp]" "\n" // argc: x0 = *sp 32 | "add x1, sp, 8" "\n" // argv: x1 = sp + 8 33 | "add x2, x0, 1" "\n" // x2 = argc + 1 34 | "lsl x2, x2, 3" "\n" // x2 = x2 * 8 35 | "add x2, x1, x2" "\n" // envp: x2 = argv + x2 36 | "mov x3, x2" "\n" // x3 = envp 37 | "0:" "\n" // null finder loop: 38 | "ldr x8, [x3], 8" "\n" // x8 = *x3 39 | // x3 = x3 + 8 40 | "cbnz x8, 0b" "\n" // goto loop if x8 != 0 41 | // auxv: x3 42 | 43 | "and sp, x1, -16" "\n" // ensure 16 byte alignment 44 | 45 | "bl lone" "\n" // call lone; returns status code in x0 46 | 47 | #define S2(s) #s 48 | #define S(s) S2(s) 49 | 50 | "mov x8, " S(__NR_exit) "\n" // ensure clean process termination 51 | "svc 0" "\n" // exit with returned status code 52 | 53 | #undef S2 54 | #undef S 55 | 56 | ); 57 | -------------------------------------------------------------------------------- /architecture/x86_64/include/lone/architecture/garbage_collector.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | /** 4 | * Registers may contain pointers to garbage collector roots. 5 | * They must be spilled onto the stack so that they can be marked. 6 | * The x86_64 provides 16 general purpose registers. 7 | **/ 8 | typedef long lone_registers[16]; 9 | extern void lone_save_registers(lone_registers); 10 | 11 | __asm__ 12 | ( 13 | 14 | ".global lone_save_registers" "\n" 15 | ".type lone_save_registers,@function" "\n" 16 | 17 | "lone_save_registers:" "\n" // rdi = &lone_registers 18 | "mov %rax, 0(%rdi)" "\n" 19 | "mov %rbx, 8(%rdi)" "\n" 20 | "mov %rcx, 16(%rdi)" "\n" 21 | "mov %rdx, 24(%rdi)" "\n" 22 | "mov %rsp, 32(%rdi)" "\n" 23 | "mov %rbp, 40(%rdi)" "\n" 24 | "mov %rsi, 48(%rdi)" "\n" 25 | "mov %rdi, 56(%rdi)" "\n" 26 | "mov %r8, 64(%rdi)" "\n" 27 | "mov %r9, 72(%rdi)" "\n" 28 | "mov %r10, 80(%rdi)" "\n" 29 | "mov %r11, 88(%rdi)" "\n" 30 | "mov %r12, 96(%rdi)" "\n" 31 | "mov %r13, 104(%rdi)" "\n" 32 | "mov %r14, 112(%rdi)" "\n" 33 | "mov %r15, 120(%rdi)" "\n" 34 | "ret" "\n" 35 | 36 | ); 37 | -------------------------------------------------------------------------------- /architecture/x86_64/include/lone/architecture/linux/entry_point.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | 7 | /** 8 | * 9 | * initial stack layout - logical 10 | * 11 | * sp → 0 | argc 12 | * 1 | argv 13 | * argv + *argc + 1 | envp 14 | * &(*envp++ == 0) + 1 | auxv 15 | * 16 | * initial stack layout - bytes 17 | * 18 | * sp → 0 | argc 19 | * 8 | argv 20 | * argv + (*argc * 8) + 8 | envp 21 | * &(*envp++ == 0) + 8 | auxv 22 | * 23 | **/ 24 | __asm__ 25 | ( 26 | 27 | ".global lone_start" "\n" // place lone_start in the symbol table 28 | "lone_start:" "\n" // program entry point 29 | 30 | // compute argc, argv, envp and auxv 31 | 32 | "pop %rdi" "\n" // argc: rdi = pop 33 | "mov %rsp, %rsi" "\n" // argv: rsi = sp 34 | "lea 8(%rsi, %rdi, 8), %rdx" "\n" // envp: rdx = rsi + (rdi * 8) + 8 35 | 36 | "lea 0(%rdx), %rcx" "\n" // rcx = rdx 37 | "0:" "\n" // loop: 38 | "add $8, %rcx" "\n" // rcx = rcx + 9 39 | "cmpq $0, -8(%rcx)" "\n" // *(rcx - 8) == 0 ? 40 | "jnz 0b" "\n" // loop if not zero 41 | // rcx - 8 == 0 42 | // auxv: rcx 43 | 44 | // x86_64 SysV ABI requirements: 45 | "xor %rbp, %rbp" "\n" // zero the deepest stack frame 46 | "and $-16, %rsp" "\n" // ensure 16 byte stack alignment 47 | 48 | "call lone" "\n" // call lone 49 | "mov %rax, %rdi" "\n" // status code returned in rax 50 | 51 | #define S2(s) #s 52 | #define S(s) S2(s) 53 | 54 | "mov $" S(__NR_exit) ", %rax" "\n" // ensure clean process termination 55 | "syscall" "\n" // exit with returned status code 56 | 57 | #undef S2 58 | #undef S 59 | 60 | ); 61 | -------------------------------------------------------------------------------- /documentation/linux/memory-map.md: -------------------------------------------------------------------------------- 1 | # Linux user space memory maps 2 | 3 | | Architecture | Start | End | Address space bits | Page size | Translation tables | 4 | | :----------: | -----------------: | :----------------- | :----------------: | :-------: | :----------------: | 5 | | `x86_64` | `0000000000000000` | `00007fffffffffff` | 47 | 4 KB | 4 | 6 | | `x86_64` | `0000000000000000` | `00ffffffffffffff` | 56 | 4 KB | 5 | 7 | | `arm64` | `0000000000000000` | `0000007fffffffff` | 39 | 4 KB | 3 | 8 | | `arm64` | `0000000000000000` | `0000ffffffffffff` | 48 | 4 KB | 4 | 9 | | `arm64` | `0000000000000000` | `000003ffffffffff` | 42 | 64 KB | 2 | 10 | | `arm64` | `0000000000000000` | `000fffffffffffff` | 52 | 64 KB | 3 | 11 | 12 | # References 13 | 14 | - [`x86_64`][x86_64] 15 | - [`arm64`][arm64] 16 | 17 | [x86_64]: https://www.kernel.org/doc/html/latest/arch/x86/x86_64/mm.html 18 | [arm64]: https://www.kernel.org/doc/html/latest/arch/arm64/memory.html 19 | -------------------------------------------------------------------------------- /include/lone.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_HEADER 4 | #define LONE_HEADER 5 | 6 | #include 7 | 8 | long lone(int argc, char **argv, char **envp, struct lone_auxiliary_vector *auxv); 9 | 10 | #endif /* LONE_HEADER */ 11 | -------------------------------------------------------------------------------- /include/lone/auxiliary_vector.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_AUXILIARY_VECTOR_HEADER 4 | #define LONE_AUXILIARY_VECTOR_HEADER 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | struct lone_auxiliary_value lone_auxiliary_vector_value(struct lone_auxiliary_vector *values, unsigned long type); 11 | size_t lone_auxiliary_vector_page_size(struct lone_auxiliary_vector *values); 12 | struct lone_bytes lone_auxiliary_vector_random(struct lone_auxiliary_vector *values); 13 | struct lone_elf_native_segments lone_auxiliary_vector_elf_segments(struct lone_auxiliary_vector *values); 14 | lone_elf_native_segment *lone_auxiliary_vector_embedded_segment(struct lone_auxiliary_vector *values); 15 | struct lone_bytes lone_auxiliary_vector_embedded_bytes(struct lone_auxiliary_vector *values); 16 | 17 | #endif /* LONE_AUXILIARY_VECTOR_HEADER */ 18 | -------------------------------------------------------------------------------- /include/lone/definitions.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_DEFINITIONS_HEADER 4 | #define LONE_DEFINITIONS_HEADER 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | /* ╭────────────────────────────────────────────────────────────────────────╮ 11 | │ │ 12 | │ bits = 32 | bits = 64 │ 13 | │ digits = ceil(bits * log10(2)) = 10 | 20 │ 14 | │ │ 15 | ╰────────────────────────────────────────────────────────────────────────╯ */ 16 | #if __BITS_PER_LONG == 64 17 | #define LONE_DECIMAL_DIGITS_PER_LONG 20 18 | #elif __BITS_PER_LONG == 32 19 | #define LONE_DECIMAL_DIGITS_PER_LONG 10 20 | #else 21 | #error "Unsupported architecture" 22 | #endif 23 | 24 | #ifndef LONE_ALIGNMENT 25 | #define LONE_ALIGNMENT 16 26 | #endif 27 | 28 | #ifndef PT_LONE 29 | // PT_LONE l o n e 30 | #define PT_LONE 0x6c6f6e65 31 | #endif 32 | 33 | #if PT_LONE < PT_LOOS || PT_LONE > PT_HIOS 34 | #warning "PT_LONE outside reserved operating system specific range" 35 | #endif 36 | 37 | #define LONE_SIZE_OF_MEMBER(type, member) sizeof(((type) { 0 }).member) 38 | 39 | #define LONE_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 40 | 41 | #endif /* LONE_DEFINITIONS_HEADER */ 42 | -------------------------------------------------------------------------------- /include/lone/hash.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_HASH_HEADER 4 | #define LONE_HASH_HEADER 5 | 6 | #include 7 | 8 | void lone_hash_initialize(struct lone_system *system, struct lone_bytes random); 9 | 10 | #endif /* LONE_HASH_HEADER */ 11 | -------------------------------------------------------------------------------- /include/lone/hash/fnv_1a.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_HASH_FNV_1A_HEADER 4 | #define LONE_HASH_FNV_1A_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ https://en.wikipedia.org/wiki/FNV_hash │ 12 | │ https://datatracker.ietf.org/doc/draft-eastlake-fnv/ │ 13 | │ │ 14 | ╰────────────────────────────────────────────────────────────────────────╯ */ 15 | #if __BITS_PER_LONG == 64 16 | #define FNV_PRIME 0x00000100000001B3UL 17 | #define FNV_OFFSET_BASIS 0xCBF29CE484222325UL 18 | #elif __BITS_PER_LONG == 32 19 | #define FNV_PRIME 0x01000193UL 20 | #define FNV_OFFSET_BASIS 0x811C9DC5 21 | #else 22 | #error "Unsupported architecture" 23 | #endif 24 | 25 | void lone_hash_fnv_1a_initialize(struct lone_system *system, struct lone_bytes random); 26 | 27 | unsigned long 28 | __attribute__((pure)) 29 | lone_hash_fnv_1a(struct lone_bytes data, unsigned long offset_basis); 30 | 31 | #endif /* LONE_HASH_FNV_1A_HEADER */ 32 | -------------------------------------------------------------------------------- /include/lone/linux.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LINUX_HEADER 4 | #define LONE_LINUX_HEADER 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | long linux_system_call_0(long n); 15 | long linux_system_call_1(long n, long _1); 16 | long linux_system_call_2(long n, long _1, long _2); 17 | long linux_system_call_3(long n, long _1, long _2, long _3); 18 | long linux_system_call_4(long n, long _1, long _2, long _3, long _4); 19 | long linux_system_call_5(long n, long _1, long _2, long _3, long _4, long _5); 20 | long linux_system_call_6(long n, long _1, long _2, long _3, long _4, long _5, long _6); 21 | 22 | void 23 | __attribute__((noreturn)) 24 | linux_exit(int code); 25 | 26 | long 27 | __attribute__((tainted_args)) 28 | linux_openat(int dirfd, unsigned char *path, int flags); 29 | 30 | long 31 | __attribute__((tainted_args)) 32 | linux_close(int fd); 33 | 34 | ssize_t 35 | __attribute__((fd_arg_read(1), tainted_args)) 36 | linux_read(int fd, const void *buffer, size_t count); 37 | 38 | ssize_t 39 | __attribute__((fd_arg_write(1), tainted_args)) 40 | linux_write(int fd, const void *buffer, size_t count); 41 | 42 | off_t 43 | __attribute__((tainted_args)) 44 | linux_lseek(int fd, off_t offset, int origin); 45 | 46 | intptr_t 47 | __attribute__((tainted_args)) 48 | linux_mmap(void *address, size_t length, int protections, int flags, int file_descriptor, off_t offset); 49 | 50 | int 51 | __attribute__((tainted_args)) 52 | linux_munmap(void *address, size_t length); 53 | 54 | #endif /* LONE_LINUX_HEADER */ 55 | -------------------------------------------------------------------------------- /include/lone/lisp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_HEADER 4 | #define LONE_LISP_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ The lone lisp structure represents the lone lisp interpreter. │ 12 | │ A pointer to this structure is passed to nearly every function. │ 13 | │ It must be initialized before running lone lisp programs. │ 14 | │ │ 15 | ╰────────────────────────────────────────────────────────────────────────╯ */ 16 | 17 | void lone_lisp_initialize(struct lone_lisp *lone, struct lone_system *system, void *native_stack); 18 | 19 | #endif /* LONE_LISP_HEADER */ 20 | -------------------------------------------------------------------------------- /include/lone/lisp/definitions.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_DEFINITIONS_HEADER 4 | #define LONE_LISP_DEFINITIONS_HEADER 5 | 6 | #include 7 | 8 | #define LONE_LISP_DECIMAL_DIGITS_PER_INTEGER LONE_DECIMAL_DIGITS_PER_LONG 9 | 10 | #ifndef LONE_LISP_BUFFER_SIZE 11 | #define LONE_LISP_BUFFER_SIZE 4096 12 | #endif 13 | 14 | #ifndef LONE_LISP_MEMORY_SIZE 15 | #define LONE_LISP_MEMORY_SIZE (1024 * 1024) 16 | #endif 17 | 18 | #ifndef LONE_LISP_HEAP_VALUE_COUNT 19 | #define LONE_LISP_HEAP_VALUE_COUNT 512 20 | #endif 21 | 22 | #ifndef LONE_LISP_TABLE_LOAD_FACTOR 23 | #define LONE_LISP_TABLE_LOAD_FACTOR 0.7 24 | #endif 25 | 26 | #ifndef LONE_LISP_TABLE_GROWTH_FACTOR 27 | #define LONE_LISP_TABLE_GROWTH_FACTOR 2 28 | #endif 29 | 30 | #define LONE_LISP_PRIMITIVE(name) \ 31 | struct lone_lisp_value lone_lisp_primitive_ ## name \ 32 | ( \ 33 | struct lone_lisp *lone, \ 34 | struct lone_lisp_value module, \ 35 | struct lone_lisp_value environment, \ 36 | struct lone_lisp_value arguments, \ 37 | struct lone_lisp_value closure \ 38 | ) 39 | 40 | #endif /* LONE_LISP_DEFINITIONS_HEADER */ 41 | -------------------------------------------------------------------------------- /include/lone/lisp/evaluator.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_EVALUATOR_HEADER 4 | #define LONE_LISP_EVALUATOR_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────┨ LONE LISP EVALUATOR ┠─────────────────────────╮ 9 | │ │ 10 | │ The heart of the language. This is what actually executes code. │ 11 | │ │ 12 | │ Evaluator features: │ 13 | │ │ 14 | │ ◦ Symbol resolution │ 15 | │ ◦ Application of arguments │ 16 | │ ◦ Functions │ 17 | │ ◦ Evaluated and unevaluated arguments │ 18 | │ ◦ Evaluated and unevaluated result │ 19 | │ ◦ Variadic │ 20 | │ ◦ Primitives │ 21 | │ ◦ Evaluated and unevaluated arguments │ 22 | │ ◦ Evaluated and unevaluated result │ 23 | │ ◦ Vectors │ 24 | │ ◦ Indexing │ 25 | │ ◦ Assignment │ 26 | │ ◦ Tables │ 27 | │ ◦ Lookup │ 28 | │ ◦ Assignment │ 29 | │ │ 30 | ╰────────────────────────────────────────────────────────────────────────╯ */ 31 | 32 | struct lone_lisp_value lone_lisp_evaluate( 33 | struct lone_lisp *lone, 34 | struct lone_lisp_value module, 35 | struct lone_lisp_value environment, 36 | struct lone_lisp_value value 37 | ); 38 | 39 | struct lone_lisp_value lone_lisp_evaluate_all( 40 | struct lone_lisp *lone, 41 | struct lone_lisp_value module, 42 | struct lone_lisp_value environment, 43 | struct lone_lisp_value list 44 | ); 45 | 46 | struct lone_lisp_value lone_lisp_evaluate_in_module( 47 | struct lone_lisp *lone, 48 | struct lone_lisp_value module, 49 | struct lone_lisp_value value 50 | ); 51 | 52 | struct lone_lisp_value lone_lisp_apply( 53 | struct lone_lisp *lone, 54 | struct lone_lisp_value module, 55 | struct lone_lisp_value environment, 56 | struct lone_lisp_value applicable, 57 | struct lone_lisp_value arguments 58 | ); 59 | 60 | #endif /* LONE_LISP_EVALUATOR_HEADER */ 61 | -------------------------------------------------------------------------------- /include/lone/lisp/garbage_collector.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_GARBAGE_COLLECTOR_HEADER 4 | #define LONE_LISP_GARBAGE_COLLECTOR_HEADER 5 | 6 | #include 7 | 8 | void lone_lisp_garbage_collector(struct lone_lisp *lone); 9 | 10 | #endif /* LONE_LISP_GARBAGE_COLLECTOR_HEADER */ 11 | -------------------------------------------------------------------------------- /include/lone/lisp/hash.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_HASH_HEADER 4 | #define LONE_LISP_HASH_HEADER 5 | 6 | #include 7 | 8 | size_t lone_lisp_hash(struct lone_lisp *lone, struct lone_lisp_value value); 9 | 10 | #endif /* LONE_LISP_HASH_HEADER */ 11 | -------------------------------------------------------------------------------- /include/lone/lisp/heap.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_HEAP_HEADER 4 | #define LONE_LISP_HEAP_HEADER 5 | 6 | #include 7 | #include 8 | 9 | void lone_lisp_heap_initialize(struct lone_lisp *lone); 10 | struct lone_lisp_heap_value *lone_lisp_heap_allocate_value(struct lone_lisp *lone); 11 | void lone_lisp_deallocate_dead_heaps(struct lone_lisp *lone); 12 | 13 | #endif /* LONE_LISP_HEAP_HEADER */ 14 | -------------------------------------------------------------------------------- /include/lone/lisp/module.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULE_HEADER 4 | #define LONE_LISP_MODULE_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭───────────────────────────┨ LONE / MODULES ┠───────────────────────────╮ 10 | │ │ 11 | │ Module importing, exporting and loading operations. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | struct lone_lisp_value lone_lisp_module_null(struct lone_lisp *lone); 16 | struct lone_lisp_value lone_lisp_module_for_name(struct lone_lisp *lone, struct lone_lisp_value name); 17 | struct lone_lisp_value lone_lisp_module_load(struct lone_lisp *lone, struct lone_lisp_value name); 18 | void lone_lisp_module_load_from_bytes(struct lone_lisp *lone, struct lone_lisp_value module, struct lone_bytes bytes); 19 | void lone_lisp_module_load_null_from_file_descriptor(struct lone_lisp *lone, int file_descriptor); 20 | void lone_lisp_module_load_null_from_standard_input(struct lone_lisp *lone); 21 | void lone_lisp_module_path_push(struct lone_lisp *lone, struct lone_lisp_value directory); 22 | void lone_lisp_module_path_push_c_string(struct lone_lisp *lone, char *directory); 23 | void lone_lisp_module_path_push_va_list(struct lone_lisp *lone, size_t count, va_list directories); 24 | void lone_lisp_module_path_push_all(struct lone_lisp *lone, size_t count, ...); 25 | 26 | void lone_lisp_module_export( 27 | struct lone_lisp *lone, 28 | struct lone_lisp_value module, 29 | struct lone_lisp_value symbol 30 | ); 31 | 32 | void lone_lisp_module_set_and_export( 33 | struct lone_lisp *lone, 34 | struct lone_lisp_value module, 35 | struct lone_lisp_value symbol, 36 | struct lone_lisp_value value 37 | ); 38 | 39 | void lone_lisp_module_set_and_export_c_string(struct lone_lisp *lone, 40 | struct lone_lisp_value module, char *symbol, struct lone_lisp_value value); 41 | 42 | void lone_lisp_module_export_primitive(struct lone_lisp *lone, 43 | struct lone_lisp_value module, char *symbol, char *name, 44 | lone_lisp_primitive_function function, struct lone_lisp_value closure, 45 | struct lone_lisp_function_flags flags); 46 | 47 | LONE_LISP_PRIMITIVE(module_import); 48 | LONE_LISP_PRIMITIVE(module_export); 49 | 50 | #endif /* LONE_LISP_MODULE_HEADER */ 51 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/embedded.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_EMBEDDED_HEADER 4 | #define LONE_LISP_MODULES_EMBEDDED_HEADER 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | void lone_lisp_modules_embedded_load(struct lone_lisp *lone, lone_elf_native_segment *values); 11 | 12 | #endif /* LONE_LISP_MODULES_EMBEDDED_HEADER */ 13 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭─────────────────────┨ LONE / MODULES / INTRINSIC ┠─────────────────────╮ 10 | │ │ 11 | │ Initialization for built-in modules with essential functionality. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_initialize( 16 | struct lone_lisp *lone, 17 | int argument_count, 18 | char **argument_vector, 19 | char **environment, 20 | struct lone_auxiliary_vector *auxiliary_vector 21 | ); 22 | 23 | #endif /* LONE_LISP_MODULES_INTRINSIC_HEADER */ 24 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/bytes.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_BYTES_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_BYTES_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ Bytes operations. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_bytes_initialize(struct lone_lisp *lone); 16 | 17 | LONE_LISP_PRIMITIVE(bytes_new); 18 | LONE_LISP_PRIMITIVE(bytes_is_zero); 19 | 20 | LONE_LISP_PRIMITIVE(bytes_read_u8); 21 | LONE_LISP_PRIMITIVE(bytes_read_s8); 22 | 23 | LONE_LISP_PRIMITIVE(bytes_write_u8); 24 | LONE_LISP_PRIMITIVE(bytes_write_s8); 25 | 26 | LONE_LISP_PRIMITIVE(bytes_read_u16); 27 | LONE_LISP_PRIMITIVE(bytes_read_s16); 28 | LONE_LISP_PRIMITIVE(bytes_read_u32); 29 | LONE_LISP_PRIMITIVE(bytes_read_s32); 30 | 31 | LONE_LISP_PRIMITIVE(bytes_write_u16); 32 | LONE_LISP_PRIMITIVE(bytes_write_s16); 33 | LONE_LISP_PRIMITIVE(bytes_write_u32); 34 | LONE_LISP_PRIMITIVE(bytes_write_s32); 35 | 36 | LONE_LISP_PRIMITIVE(bytes_read_u16le); 37 | LONE_LISP_PRIMITIVE(bytes_read_s16le); 38 | LONE_LISP_PRIMITIVE(bytes_read_u32le); 39 | LONE_LISP_PRIMITIVE(bytes_read_s32le); 40 | 41 | LONE_LISP_PRIMITIVE(bytes_read_u16be); 42 | LONE_LISP_PRIMITIVE(bytes_read_s16be); 43 | LONE_LISP_PRIMITIVE(bytes_read_u32be); 44 | LONE_LISP_PRIMITIVE(bytes_read_s32be); 45 | 46 | LONE_LISP_PRIMITIVE(bytes_write_u16le); 47 | LONE_LISP_PRIMITIVE(bytes_write_s16le); 48 | LONE_LISP_PRIMITIVE(bytes_write_u32le); 49 | LONE_LISP_PRIMITIVE(bytes_write_s32le); 50 | 51 | LONE_LISP_PRIMITIVE(bytes_write_u16be); 52 | LONE_LISP_PRIMITIVE(bytes_write_s16be); 53 | LONE_LISP_PRIMITIVE(bytes_write_u32be); 54 | LONE_LISP_PRIMITIVE(bytes_write_s32be); 55 | 56 | #endif /* LONE_LISP_MODULES_INTRINSIC_BYTES_HEADER */ 57 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/linux.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_LINUX_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_LINUX_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────┨ LONE / MODULE / LINUX ┠───────────────────────╮ 10 | │ │ 11 | │ Linux system calls and process parameters. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_linux_initialize(struct lone_lisp *lone, 16 | int argc, char **argv, char **envp, struct lone_auxiliary_vector *auxv); 17 | 18 | LONE_LISP_PRIMITIVE(linux_system_call); 19 | 20 | #endif /* LONE_LISP_MODULES_INTRINSIC_LINUX_HEADER */ 21 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/list.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_LIST_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_LIST_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ List operations. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_list_initialize(struct lone_lisp *lone); 16 | 17 | LONE_LISP_PRIMITIVE(list_construct); 18 | LONE_LISP_PRIMITIVE(list_first); 19 | LONE_LISP_PRIMITIVE(list_rest); 20 | LONE_LISP_PRIMITIVE(list_map); 21 | LONE_LISP_PRIMITIVE(list_reduce); 22 | LONE_LISP_PRIMITIVE(list_flatten); 23 | 24 | #endif /* LONE_LISP_MODULES_INTRINSIC_LIST_HEADER */ 25 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/lone.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_LONE_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_LONE_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭───────────────────┨ LONE LISP PRIMITIVE FUNCTIONS ┠────────────────────╮ 10 | │ │ 11 | │ Lone lisp functions implemented in C. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_lone_initialize(struct lone_lisp *lone); 16 | 17 | LONE_LISP_PRIMITIVE(lone_begin); 18 | LONE_LISP_PRIMITIVE(lone_when); 19 | LONE_LISP_PRIMITIVE(lone_unless); 20 | LONE_LISP_PRIMITIVE(lone_if); 21 | LONE_LISP_PRIMITIVE(lone_let); 22 | LONE_LISP_PRIMITIVE(lone_set); 23 | LONE_LISP_PRIMITIVE(lone_quote); 24 | LONE_LISP_PRIMITIVE(lone_quasiquote); 25 | LONE_LISP_PRIMITIVE(lone_lambda); 26 | LONE_LISP_PRIMITIVE(lone_lambda_bang); 27 | LONE_LISP_PRIMITIVE(lone_lambda_star); 28 | LONE_LISP_PRIMITIVE(lone_is_list); 29 | LONE_LISP_PRIMITIVE(lone_is_vector); 30 | LONE_LISP_PRIMITIVE(lone_is_table); 31 | LONE_LISP_PRIMITIVE(lone_is_symbol); 32 | LONE_LISP_PRIMITIVE(lone_is_text); 33 | LONE_LISP_PRIMITIVE(lone_is_integer); 34 | LONE_LISP_PRIMITIVE(lone_is_identical); 35 | LONE_LISP_PRIMITIVE(lone_is_equivalent); 36 | LONE_LISP_PRIMITIVE(lone_is_equal); 37 | LONE_LISP_PRIMITIVE(lone_print); 38 | 39 | #endif /* LONE_LISP_MODULES_INTRINSIC_LONE_HEADER */ 40 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/math.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_MATH_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_MATH_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ Built-in mathematical and numeric operations. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_math_initialize(struct lone_lisp *lone); 16 | 17 | LONE_LISP_PRIMITIVE(math_add); 18 | LONE_LISP_PRIMITIVE(math_subtract); 19 | LONE_LISP_PRIMITIVE(math_multiply); 20 | LONE_LISP_PRIMITIVE(math_divide); 21 | LONE_LISP_PRIMITIVE(math_is_less_than); 22 | LONE_LISP_PRIMITIVE(math_is_less_than_or_equal_to); 23 | LONE_LISP_PRIMITIVE(math_is_greater_than); 24 | LONE_LISP_PRIMITIVE(math_is_greater_than_or_equal_to); 25 | LONE_LISP_PRIMITIVE(math_sign); 26 | LONE_LISP_PRIMITIVE(math_is_zero); 27 | LONE_LISP_PRIMITIVE(math_is_positive); 28 | LONE_LISP_PRIMITIVE(math_is_negative); 29 | 30 | #endif /* LONE_LISP_MODULES_INTRINSIC_MATH_HEADER */ 31 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_TABLE_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_TABLE_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ Table operations. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_table_initialize(struct lone_lisp *lone); 16 | 17 | LONE_LISP_PRIMITIVE(table_get); 18 | LONE_LISP_PRIMITIVE(table_set); 19 | LONE_LISP_PRIMITIVE(table_delete); 20 | LONE_LISP_PRIMITIVE(table_each); 21 | LONE_LISP_PRIMITIVE(table_count); 22 | 23 | #endif /* LONE_LISP_MODULES_INTRINSIC_TABLE_HEADER */ 24 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/text.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_TEXT_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_TEXT_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ Text operations. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_text_initialize(struct lone_lisp *lone); 16 | 17 | LONE_LISP_PRIMITIVE(text_to_symbol); 18 | LONE_LISP_PRIMITIVE(text_join); 19 | LONE_LISP_PRIMITIVE(text_concatenate); 20 | 21 | #endif /* LONE_LISP_MODULES_INTRINSIC_TEXT_HEADER */ 22 | -------------------------------------------------------------------------------- /include/lone/lisp/modules/intrinsic/vector.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_MODULES_INTRINSIC_VECTOR_HEADER 4 | #define LONE_LISP_MODULES_INTRINSIC_VECTOR_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭────────────────────────────────────────────────────────────────────────╮ 10 | │ │ 11 | │ Vector operations. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | void lone_lisp_modules_intrinsic_vector_initialize(struct lone_lisp *lone); 16 | 17 | LONE_LISP_PRIMITIVE(vector_get); 18 | LONE_LISP_PRIMITIVE(vector_set); 19 | LONE_LISP_PRIMITIVE(vector_slice); 20 | LONE_LISP_PRIMITIVE(vector_each); 21 | LONE_LISP_PRIMITIVE(vector_count); 22 | 23 | #endif /* LONE_LISP_MODULES_INTRINSIC_VECTOR_HEADER */ 24 | -------------------------------------------------------------------------------- /include/lone/lisp/printer.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_PRINTER_HEADER 4 | #define LONE_LISP_PRINTER_HEADER 5 | 6 | #include 7 | 8 | /* ╭─────────────────────────┨ LONE LISP PRINTER ┠──────────────────────────╮ 9 | │ │ 10 | │ Transforms lone lisp objects into text and writes them out. │ 11 | │ │ 12 | ╰────────────────────────────────────────────────────────────────────────╯ */ 13 | 14 | void lone_lisp_print(struct lone_lisp *lone, struct lone_lisp_value value, int file_descriptor); 15 | 16 | #endif /* LONE_LISP_PRINTER_HEADER */ 17 | -------------------------------------------------------------------------------- /include/lone/lisp/reader.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_READER_HEADER 4 | #define LONE_LISP_READER_HEADER 5 | 6 | #include 7 | #include 8 | 9 | /* ╭─────────────────────────┨ LONE LISP READER ┠───────────────────────────╮ 10 | │ │ 11 | │ The reader's job is to transform input into lone lisp values. │ 12 | │ It accomplishes the task by reading input from a given file │ 13 | │ descriptor and then lexing and parsing the results. │ 14 | │ │ 15 | │ The lexer or tokenizer transforms a linear stream of characters │ 16 | │ into a linear stream of tokens suitable for parser consumption. │ 17 | │ This gets rid of insignificant whitespace and reduces the size │ 18 | │ of the parser's input significantly. │ 19 | │ │ 20 | │ It consists of an input buffer, its current position in it │ 21 | │ as well as two functions: │ 22 | │ │ 23 | │ ◦ peek(k) which returns the character at i+k │ 24 | │ ◦ consume(k) which advances i by k positions │ 25 | │ │ 26 | │ The parser transforms a linear sequence of tokens into a nested │ 27 | │ sequence of lisp objects suitable for evaluation. │ 28 | │ Its main task is to match nested structures such as lists. │ 29 | │ │ 30 | ╰────────────────────────────────────────────────────────────────────────╯ */ 31 | 32 | void lone_lisp_reader_for_bytes(struct lone_lisp *lone, struct lone_lisp_reader *reader, 33 | struct lone_bytes bytes); 34 | 35 | void lone_lisp_reader_for_file_descriptor(struct lone_lisp *lone, struct lone_lisp_reader *reader, 36 | size_t buffer_size, int file_descriptor); 37 | 38 | void lone_lisp_reader_finalize(struct lone_lisp *lone, struct lone_lisp_reader *reader); 39 | 40 | struct lone_lisp_value lone_lisp_read(struct lone_lisp *lone, struct lone_lisp_reader *reader); 41 | 42 | #endif /* LONE_LISP_READER_HEADER */ 43 | -------------------------------------------------------------------------------- /include/lone/lisp/segment.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_SEGMENT_HEADER 4 | #define LONE_LISP_SEGMENT_HEADER 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | struct lone_lisp_value lone_lisp_segment_read_descriptor(struct lone_lisp *lone, lone_elf_native_segment *segment); 12 | 13 | #endif /* LONE_LISP_SEGMENT_HEADER */ 14 | -------------------------------------------------------------------------------- /include/lone/lisp/utilities.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_UTILITIES_HEADER 4 | #define LONE_LISP_UTILITIES_HEADER 5 | 6 | #include 7 | 8 | struct lone_lisp_value lone_lisp_apply_predicate(struct lone_lisp *lone, 9 | struct lone_lisp_value arguments, lone_lisp_predicate_function function); 10 | 11 | struct lone_lisp_value lone_lisp_apply_comparator(struct lone_lisp *lone, 12 | struct lone_lisp_value arguments, lone_lisp_comparator_function function); 13 | 14 | struct lone_bytes lone_lisp_join(struct lone_lisp *lone, 15 | struct lone_lisp_value separator, struct lone_lisp_value arguments, 16 | lone_lisp_predicate_function is_valid); 17 | 18 | struct lone_bytes lone_lisp_concatenate(struct lone_lisp *lone, 19 | struct lone_lisp_value arguments, lone_lisp_predicate_function is_valid); 20 | 21 | #endif /* LONE_LISP_UTILITIES_HEADER */ 22 | -------------------------------------------------------------------------------- /include/lone/lisp/value.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_HEADER 4 | #define LONE_LISP_VALUE_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ General constructor for lone heap values. │ 11 | │ Meant for other constructors to use. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | struct lone_lisp_value lone_lisp_value_from_heap_value(struct lone_lisp_heap_value *heap_value); 16 | 17 | #endif /* LONE_LISP_VALUE_HEADER */ 18 | -------------------------------------------------------------------------------- /include/lone/lisp/value/bytes.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_BYTES_HEADER 4 | #define LONE_LISP_VALUE_BYTES_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Lone bytes values can be created zero-filled for a given size │ 11 | │ or they can be initialized with a pointer to a memory block │ 12 | │ of known size. │ 13 | │ │ 14 | │ They can take ownership of arbitrary memory blocks via transfers │ 15 | │ or make copies of their input data. │ 16 | │ │ 17 | │ Transferring memory blocks allows control over deallocation. │ 18 | │ Disabling deallocation on garbage collection allows pointing to │ 19 | │ data such as statically allocated buffers and C string literals. │ 20 | │ Enabling deallocation will cause the pointer to be deallocated │ 21 | │ when the bytes object is garbage collected. Two bytes objects │ 22 | │ cannot own the same memory block; it would lead to double free. │ 23 | │ This mode of operation is suitable for memory allocated by lone. │ 24 | │ │ 25 | │ Copies will automatically include a hidden trailing null │ 26 | │ byte to ease compatibility with code expecting C strings. │ 27 | │ It's impossible to escape from them since system calls use them. │ 28 | │ Transferred buffers should also contain that null byte │ 29 | │ but the lone bytes type currently has no way to enforce this. │ 30 | │ │ 31 | ╰────────────────────────────────────────────────────────────────────────╯ */ 32 | 33 | struct lone_lisp_value lone_lisp_bytes_transfer(struct lone_lisp *lone, 34 | unsigned char *pointer, size_t count, bool should_deallocate); 35 | 36 | struct lone_lisp_value lone_lisp_bytes_transfer_bytes(struct lone_lisp *lone, 37 | struct lone_bytes bytes, bool should_deallocate); 38 | 39 | struct lone_lisp_value lone_lisp_bytes_copy(struct lone_lisp *lone, 40 | unsigned char *pointer, size_t count); 41 | 42 | struct lone_lisp_value lone_lisp_bytes_create(struct lone_lisp *lone, 43 | size_t count); 44 | 45 | #endif /* LONE_LISP_VALUE_BYTES_HEADER */ 46 | -------------------------------------------------------------------------------- /include/lone/lisp/value/function.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_FUNCTION_HEADER 4 | #define LONE_LISP_VALUE_FUNCTION_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Lone functions represent a body of executable lone lisp code. │ 11 | │ They have a list of argument names to be bound during function │ 12 | │ application, a list of expressions to be evaluated when called │ 13 | │ and a closure: a reference to the environment it was defined in. │ 14 | │ │ 15 | │ To apply a function is to create a new environment with its │ 16 | │ argument names bound to the given arguments and then evaluate │ 17 | │ the function's expressions in the context of that environment. │ 18 | │ │ 19 | │ The function flags control how the function is applied. │ 20 | │ It may be configured to receive evaluated or unevaluated │ 21 | │ arguments as well as to evaluate the result automatically. │ 22 | │ These features allow code manipulation and generation. │ 23 | │ It may also be configured to be variadic: all arguments │ 24 | │ are collected into a list and passed as a single argument. │ 25 | │ │ 26 | ╰────────────────────────────────────────────────────────────────────────╯ */ 27 | 28 | struct lone_lisp_value lone_lisp_function_create(struct lone_lisp *lone, 29 | struct lone_lisp_value arguments, struct lone_lisp_value code, 30 | struct lone_lisp_value environment, struct lone_lisp_function_flags flags); 31 | 32 | #endif /* LONE_LISP_VALUE_FUNCTION_HEADER */ 33 | -------------------------------------------------------------------------------- /include/lone/lisp/value/integer.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_INTEGER_HEADER 4 | #define LONE_LISP_VALUE_INTEGER_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Lone integers are currently signed fixed-length integers. │ 11 | │ │ 12 | ╰────────────────────────────────────────────────────────────────────────╯ */ 13 | 14 | struct lone_lisp_value lone_lisp_integer_create(lone_lisp_integer integer); 15 | struct lone_lisp_value lone_lisp_integer_from_pointer(void *pointer); 16 | 17 | struct lone_lisp_value lone_lisp_integer_parse(struct lone_lisp *lone, 18 | unsigned char *digits, size_t count); 19 | 20 | struct lone_lisp_value lone_lisp_zero(void); 21 | struct lone_lisp_value lone_lisp_one(void); 22 | struct lone_lisp_value lone_lisp_minus_one(void); 23 | 24 | #endif /* LONE_LISP_VALUE_INTEGER_HEADER */ 25 | -------------------------------------------------------------------------------- /include/lone/lisp/value/module.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_MODULE_HEADER 4 | #define LONE_LISP_VALUE_MODULE_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Lone modules are named isolated environments for evaluation. │ 11 | │ │ 12 | │ The lisp interpreter contains a top level environment. │ 13 | │ This environment contains only the import/export primitives. │ 14 | │ New modules have clean environments which inherit from it. │ 15 | │ This allows complete control over the symbols and the namespace. │ 16 | │ │ 17 | │ Each module corresponds roughly to one .ln file on disk. │ 18 | │ These module files are text files containing lone lisp code │ 19 | │ which may import or export symbols from or to other modules. │ 20 | │ The lone interpreter's import primitive will search for files │ 21 | │ to load in conventional locations, enabling library development. │ 22 | │ │ 23 | │ A special nameless module known as the null module │ 24 | │ contains code read in from standard input. │ 25 | │ │ 26 | ╰────────────────────────────────────────────────────────────────────────╯ */ 27 | 28 | struct lone_lisp_value lone_lisp_module_create(struct lone_lisp *lone, struct lone_lisp_value name); 29 | 30 | #endif /* LONE_LISP_VALUE_MODULE_HEADER */ 31 | -------------------------------------------------------------------------------- /include/lone/lisp/value/primitive.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_PRIMITIVE_HEADER 4 | #define LONE_LISP_VALUE_PRIMITIVE_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Primitives are lone functions implemented in C. │ 11 | │ They are always variadic and must check their arguments. │ 12 | │ All of them must follow the primitive function prototype. │ 13 | │ They also have closures which are pointers to arbitrary data. │ 14 | │ │ 15 | ╰────────────────────────────────────────────────────────────────────────╯ */ 16 | 17 | struct lone_lisp_value lone_lisp_primitive_create(struct lone_lisp *lone, char *name, 18 | lone_lisp_primitive_function function, struct lone_lisp_value closure, 19 | struct lone_lisp_function_flags flags); 20 | 21 | #endif /* LONE_LISP_VALUE_PRIMITIVE_HEADER */ 22 | -------------------------------------------------------------------------------- /include/lone/lisp/value/symbol.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_SYMBOL_HEADER 4 | #define LONE_LISP_VALUE_SYMBOL_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Lone symbols are like lone texts but are interned in a table. │ 11 | │ Symbol table interning deduplicates them in memory, │ 12 | │ enabling fast identity-based comparisons via pointer equality. │ 13 | │ However, this means they won't be garbage collected. │ 14 | │ │ 15 | ╰────────────────────────────────────────────────────────────────────────╯ */ 16 | 17 | struct lone_lisp_value lone_lisp_intern(struct lone_lisp *lone, 18 | unsigned char *bytes, size_t count, bool should_deallocate); 19 | 20 | struct lone_lisp_value lone_lisp_intern_bytes(struct lone_lisp *lone, 21 | struct lone_bytes bytes, bool should_deallocate); 22 | 23 | struct lone_lisp_value lone_lisp_intern_c_string(struct lone_lisp *lone, 24 | char *c_string); 25 | 26 | struct lone_lisp_value lone_lisp_intern_text(struct lone_lisp *lone, 27 | struct lone_lisp_value text); 28 | 29 | #endif /* LONE_LISP_VALUE_SYMBOL_HEADER */ 30 | -------------------------------------------------------------------------------- /include/lone/lisp/value/table.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_VALUE_TABLE_HEADER 4 | #define LONE_VALUE_TABLE_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Hash table functions. │ 11 | │ │ 12 | ╰────────────────────────────────────────────────────────────────────────╯ */ 13 | 14 | struct lone_lisp_value lone_lisp_table_create(struct lone_lisp *lone, 15 | size_t capacity, struct lone_lisp_value prototype); 16 | 17 | struct lone_lisp_value lone_lisp_table_get(struct lone_lisp *lone, 18 | struct lone_lisp_value table, struct lone_lisp_value key); 19 | 20 | void lone_lisp_table_set(struct lone_lisp *lone, struct lone_lisp_value table, 21 | struct lone_lisp_value key, struct lone_lisp_value value); 22 | 23 | void lone_lisp_table_delete(struct lone_lisp *lone, 24 | struct lone_lisp_value table, struct lone_lisp_value key); 25 | 26 | size_t lone_lisp_table_count(struct lone_lisp_value table); 27 | struct lone_lisp_value lone_lisp_table_key_at(struct lone_lisp_value table, lone_size i); 28 | struct lone_lisp_value lone_lisp_table_value_at(struct lone_lisp_value table, lone_size i); 29 | 30 | #define LONE_LISP_TABLE_FOR_EACH(entry, table, i) \ 31 | for ((i) = 0, (entry) = &lone_lisp_heap_value_of(table)->as.table.entries[0]; \ 32 | (i) < lone_lisp_heap_value_of(table)->as.table.count; \ 33 | ++(i), (entry) = &lone_lisp_heap_value_of(table)->as.table.entries[i]) 34 | 35 | #endif /* LONE_VALUE_TABLE_HEADER */ 36 | -------------------------------------------------------------------------------- /include/lone/lisp/value/text.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_TEXT_HEADER 4 | #define LONE_LISP_VALUE_TEXT_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Lone texts are lone's strings and represent UTF-8 encoded text. │ 11 | │ Transfer and creation functions work like lone bytes. │ 12 | │ │ 13 | ╰────────────────────────────────────────────────────────────────────────╯ */ 14 | 15 | struct lone_lisp_value lone_lisp_text_transfer(struct lone_lisp *lone, 16 | unsigned char *text, size_t length, bool should_deallocate); 17 | 18 | struct lone_lisp_value lone_lisp_text_transfer_bytes(struct lone_lisp *lone, 19 | struct lone_bytes bytes, bool should_deallocate); 20 | 21 | struct lone_lisp_value lone_lisp_text_copy(struct lone_lisp *lone, 22 | unsigned char *text, size_t length); 23 | 24 | struct lone_lisp_value lone_lisp_text_from_c_string(struct lone_lisp *lone, 25 | char *c_string); 26 | 27 | struct lone_lisp_value lone_lisp_text_to_symbol(struct lone_lisp *lone, 28 | struct lone_lisp_value text); 29 | 30 | #endif /* LONE_LISP_VALUE_TEXT_HEADER */ 31 | -------------------------------------------------------------------------------- /include/lone/lisp/value/vector.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_LISP_VALUE_VECTOR_HEADER 4 | #define LONE_LISP_VALUE_VECTOR_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ Lone vectors are simple dynamic arrays of lone values. │ 11 | │ They grow automatically as elements are added. │ 12 | │ Any index may be used regardless of current length: │ 13 | │ all the elements remain unset as the array grows. │ 14 | │ The array is zero filled which makes unset elements nil. │ 15 | │ │ 16 | ╰────────────────────────────────────────────────────────────────────────╯ */ 17 | 18 | struct lone_lisp_value lone_lisp_vector_create(struct lone_lisp *lone, size_t capacity); 19 | 20 | /* ╭────────────────────────────────────────────────────────────────────────╮ 21 | │ │ 22 | │ Functions for vectors, lone's dynamic arrays. │ 23 | │ │ 24 | ╰────────────────────────────────────────────────────────────────────────╯ */ 25 | 26 | size_t lone_lisp_vector_count(struct lone_lisp_value vector); 27 | 28 | void lone_lisp_vector_resize(struct lone_lisp *lone, 29 | struct lone_lisp_value vector, size_t new_capacity); 30 | 31 | struct lone_lisp_value lone_lisp_vector_get_value_at(struct lone_lisp_value vector, size_t i); 32 | 33 | struct lone_lisp_value lone_lisp_vector_get(struct lone_lisp *lone, 34 | struct lone_lisp_value vector, struct lone_lisp_value index); 35 | 36 | void lone_lisp_vector_set_value_at(struct lone_lisp *lone, 37 | struct lone_lisp_value vector, size_t i, 38 | struct lone_lisp_value value); 39 | 40 | void lone_lisp_vector_set(struct lone_lisp *lone, struct lone_lisp_value vector, 41 | struct lone_lisp_value index, struct lone_lisp_value value); 42 | 43 | void lone_lisp_vector_push(struct lone_lisp *lone, 44 | struct lone_lisp_value vector, struct lone_lisp_value value); 45 | 46 | void lone_lisp_vector_push_va_list(struct lone_lisp *lone, 47 | struct lone_lisp_value vector, size_t count, va_list arguments); 48 | 49 | void lone_lisp_vector_push_all(struct lone_lisp *lone, 50 | struct lone_lisp_value vector, size_t count, ...); 51 | 52 | struct lone_lisp_value lone_lisp_vector_build(struct lone_lisp *lone, 53 | size_t count, ...); 54 | 55 | bool lone_lisp_vector_contains(struct lone_lisp_value vector, 56 | struct lone_lisp_value value); 57 | 58 | #define LONE_LISP_VECTOR_FOR_EACH(entry, vector, i) \ 59 | for ((i) = 0, (entry) = lone_lisp_vector_get_value_at((vector), 0); \ 60 | (i) < lone_lisp_vector_count((vector)); \ 61 | ++(i), (entry) = lone_lisp_vector_get_value_at((vector), i)) 62 | 63 | #endif /* LONE_LISP_VALUE_VECTOR_HEADER */ 64 | -------------------------------------------------------------------------------- /include/lone/memory.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_MEMORY_HEADER 4 | #define LONE_MEMORY_HEADER 5 | 6 | #include 7 | 8 | void lone_memory_initialize(struct lone_system *system, struct lone_bytes initial_static_memory); 9 | 10 | #endif /* LONE_MEMORY_HEADER */ 11 | -------------------------------------------------------------------------------- /include/lone/memory/allocator.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_MEMORY_ALLOCATOR_HEADER 4 | #define LONE_MEMORY_ALLOCATOR_HEADER 5 | 6 | #include 7 | #include 8 | 9 | size_t 10 | __attribute__((const)) 11 | lone_align(size_t size, size_t alignment); 12 | 13 | void * 14 | __attribute__((malloc, alloc_size(2), alloc_align(3))) 15 | lone_allocate_aligned(struct lone_system *system, size_t requested_size, size_t alignment); 16 | 17 | void * 18 | __attribute__((malloc, alloc_size(2), alloc_align(3))) 19 | lone_allocate_aligned_uninitialized(struct lone_system *system, size_t requested_size, size_t alignment); 20 | 21 | void * 22 | __attribute__((malloc, alloc_size(2), assume_aligned(LONE_ALIGNMENT))) 23 | lone_allocate(struct lone_system *system, size_t requested_size); 24 | 25 | void * 26 | __attribute__((malloc, alloc_size(2), assume_aligned(LONE_ALIGNMENT))) 27 | lone_allocate_uninitialized(struct lone_system *system, size_t requested_size); 28 | 29 | void * 30 | __attribute__((alloc_size(3))) 31 | lone_reallocate(struct lone_system *system, void *pointer, size_t size); 32 | 33 | void lone_deallocate(struct lone_system *system, void *pointer); 34 | 35 | #endif /* LONE_MEMORY_ALLOCATOR_HEADER */ 36 | -------------------------------------------------------------------------------- /include/lone/memory/array.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_MEMORY_ARRAY_HEADER 4 | #define LONE_MEMORY_ARRAY_HEADER 5 | 6 | #include 7 | 8 | size_t lone_memory_array_size_in_bytes(size_t element_count, size_t element_size); 9 | bool lone_memory_array_is_bounded(size_t element_index, size_t element_capacity, size_t element_size); 10 | void * lone_memory_array(struct lone_system *system, void *buffer_or_null, size_t element_count, size_t element_size); 11 | 12 | #endif /* LONE_MEMORY_ARRAY_HEADER */ 13 | -------------------------------------------------------------------------------- /include/lone/memory/functions.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_MEMORY_FUNCTIONS_HEADER 4 | #define LONE_MEMORY_FUNCTIONS_HEADER 5 | 6 | #include 7 | 8 | int lone_memory_compare(void *a, void *b, size_t count); 9 | bool lone_memory_is_equal(void *a, void *b, size_t count); 10 | bool lone_memory_is_zero(void *x, size_t count); 11 | void lone_memory_move(void *from, void *to, size_t count); 12 | void lone_memory_set(void *to, unsigned char byte, size_t count); 13 | void lone_memory_zero(void *to, size_t count); 14 | size_t lone_c_string_length(char *c_string); 15 | 16 | /* Compilers emit calls to mem* functions even with -nostdlib */ 17 | void *memset(void *to, int byte, size_t count); 18 | void *memcpy(void *to, void *from, size_t count); 19 | 20 | #endif /* LONE_MEMORY_FUNCTIONS_HEADER */ 21 | -------------------------------------------------------------------------------- /include/lone/segment.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_SEGMENT_HEADER 4 | #define LONE_SEGMENT_HEADER 5 | 6 | #include 7 | #include 8 | 9 | struct lone_bytes lone_segment_bytes(lone_elf_native_segment *segment); 10 | 11 | #endif /* LONE_SEGMENT_HEADER */ 12 | -------------------------------------------------------------------------------- /include/lone/system.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_SYSTEM_HEADER 4 | #define LONE_SYSTEM_HEADER 5 | 6 | #include 7 | 8 | /* ╭────────────────────────────────────────────────────────────────────────╮ 9 | │ │ 10 | │ The lone structure represents low level system state │ 11 | │ such as allocated memory and hash function state. │ 12 | │ It must be initialized before everything else. │ 13 | │ │ 14 | ╰────────────────────────────────────────────────────────────────────────╯ */ 15 | 16 | void lone_system_initialize(struct lone_system *system, struct lone_bytes initial_static_memory, struct lone_bytes random_bytes); 17 | 18 | #endif /* LONE_SYSTEM_HEADER */ 19 | -------------------------------------------------------------------------------- /include/lone/utilities.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #ifndef LONE_UTILITIES_HEADER 4 | #define LONE_UTILITIES_HEADER 5 | 6 | long lone_min(long x, long y); 7 | long lone_max(long x, long y); 8 | 9 | #endif /* LONE_UTILITIES_HEADER */ 10 | 11 | -------------------------------------------------------------------------------- /scripts/NR.filter: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | grep __NR_ | sed 's/#define //g' | cut -d ' ' -f 1 5 | -------------------------------------------------------------------------------- /scripts/NR.generate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | while read -r NR; do 5 | printf '{ "%s", %s },\n' "${NR#__NR_}" "${NR}" 6 | done 7 | -------------------------------------------------------------------------------- /scripts/create-symlinked-directory.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | directory="${1}" 4 | linked="$(readlink "${directory}")" 5 | result="${?}" 6 | 7 | if [[ "${result}" -eq 0 && ! -d "${linked}" ]]; then 8 | mkdir -p "${linked}" 9 | fi 10 | -------------------------------------------------------------------------------- /scripts/test.new: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | if [[ -z "${1}" ]]; then 5 | 1>&2 printf "Test name not specified\n" 6 | exit 1 7 | fi 8 | 9 | test_name="${1}" 10 | test_directory=test/"${test_name}" 11 | shift 12 | 13 | test-file-path() { 14 | printf "%s/%s" "${test_directory}" "${1}" 15 | } 16 | 17 | declare -a arguments=("${@}") 18 | 19 | if (( "${#arguments[@]}" == 0 )); then 20 | arguments+=(input output) 21 | fi 22 | 23 | declare -A parameters 24 | 25 | for parameter in "${arguments[@]}"; do 26 | parameters["${parameter}"]="$(test-file-path "${parameter}")" 27 | done 28 | 29 | parameters[input]="$(test-file-path input)" 30 | 31 | for parameter in "${!parameters[@]}"; do 32 | case "${parameter}" in 33 | input | output | error | status | arguments | environment) 34 | ;; 35 | *) 36 | 1>&2 printf "Invalid test parameter file: '%s'\n" "${parameter}" 37 | exit 2 38 | ;; 39 | esac 40 | done 41 | 42 | mkdir -p "${test_directory}" && "${EDITOR:-vim}" "${parameters[@]}" 43 | -------------------------------------------------------------------------------- /source/lone.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | /* ╭─────────────────────────────┨ LONE LISP ┠──────────────────────────────╮ 4 | │ │ 5 | │ The standalone Linux Lisp │ 6 | │ │ 7 | ╰────────────────────────────────────────────────────────────────────────╯ */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | /* ╭───────────────────────┨ LONE LISP ENTRY POINT ┠────────────────────────╮ 23 | │ │ 24 | │ Linux places argument, environment and auxiliary value arrays │ 25 | │ on the stack before jumping to the entry point of the process. │ 26 | │ Architecture-specific code collects this data and passes it to │ 27 | │ the lone function which begins execution of the lisp code. │ 28 | │ │ 29 | │ During early initialization, lone has no dynamic memory │ 30 | │ allocation capabilities and so this function statically │ 31 | │ allocates 64 KiB of memory for the early bootstrapping process. │ 32 | │ │ 33 | ╰────────────────────────────────────────────────────────────────────────╯ */ 34 | 35 | #include 36 | 37 | long lone(int argc, char **argv, char **envp, struct lone_auxiliary_vector *auxv) 38 | { 39 | void *stack = __builtin_frame_address(0); 40 | static unsigned char __attribute__((aligned(LONE_ALIGNMENT))) bytes[LONE_LISP_MEMORY_SIZE]; 41 | struct lone_bytes memory = { sizeof(bytes), bytes }, random = lone_auxiliary_vector_random(auxv); 42 | struct lone_system system; 43 | struct lone_lisp lone; 44 | 45 | lone_system_initialize(&system, memory, random); 46 | lone_lisp_initialize(&lone, &system, stack); 47 | 48 | lone_lisp_modules_intrinsic_initialize(&lone, argc, argv, envp, auxv); 49 | 50 | lone_lisp_module_path_push_all(&lone, 4, 51 | 52 | ".", 53 | "~/.lone/modules", 54 | "~/.local/lib/lone/modules", 55 | "/usr/lib/lone/modules" 56 | 57 | ); 58 | 59 | lone_lisp_modules_embedded_load(&lone, lone_auxiliary_vector_embedded_segment(auxv)); 60 | 61 | lone_lisp_module_load_null_from_standard_input(&lone); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /source/lone/auxiliary_vector.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | struct lone_auxiliary_value lone_auxiliary_vector_value(struct lone_auxiliary_vector *auxiliary, unsigned long type) 6 | { 7 | for (/* auxiliary */; auxiliary->type != AT_NULL; ++auxiliary) { 8 | if (auxiliary->type == type) { 9 | return auxiliary->value; 10 | } 11 | } 12 | 13 | return (struct lone_auxiliary_value) { .as.unsigned_integer = 0 }; 14 | } 15 | 16 | size_t lone_auxiliary_vector_page_size(struct lone_auxiliary_vector *auxiliary) 17 | { 18 | return lone_auxiliary_vector_value(auxiliary, AT_PAGESZ).as.unsigned_integer; 19 | } 20 | 21 | struct lone_bytes lone_auxiliary_vector_random(struct lone_auxiliary_vector *auxiliary) 22 | { 23 | struct lone_bytes random = { 0, 0 }; 24 | 25 | random.pointer = lone_auxiliary_vector_value(auxiliary, AT_RANDOM).as.pointer; 26 | random.count = 16; 27 | 28 | return random; 29 | } 30 | 31 | struct lone_elf_native_segments lone_auxiliary_vector_elf_segments(struct lone_auxiliary_vector *auxiliary) 32 | { 33 | return (struct lone_elf_native_segments) { 34 | .segment.size = lone_auxiliary_vector_value(auxiliary, AT_PHENT).as.unsigned_integer, 35 | .segment.count = lone_auxiliary_vector_value(auxiliary, AT_PHNUM).as.unsigned_integer, 36 | .segments = lone_auxiliary_vector_value(auxiliary, AT_PHDR).as.pointer 37 | }; 38 | } 39 | 40 | lone_elf_native_segment *lone_auxiliary_vector_embedded_segment(struct lone_auxiliary_vector *values) 41 | { 42 | struct lone_elf_native_segments table; 43 | lone_u16 i; 44 | 45 | table = lone_auxiliary_vector_elf_segments(values); 46 | 47 | for (i = 0; i < table.segment.count; ++i) { 48 | lone_elf_native_segment *entry = &table.segments[i]; 49 | 50 | if (entry->p_type == PT_LONE) { 51 | return entry; 52 | } 53 | } 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /source/lone/bits.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct bit_position { 4 | unsigned char *byte; 5 | unsigned char bit; 6 | }; 7 | 8 | static struct bit_position 9 | bit_position(void *bits, lone_size index) 10 | { 11 | unsigned char *bytes = bits; 12 | 13 | return (struct bit_position) { 14 | .byte = bytes + (index / 8), 15 | .bit = 8 - (index % 8) - 1, 16 | }; 17 | } 18 | 19 | static bool get_bit(struct bit_position position) 20 | { 21 | return (*position.byte) & (1 << position.bit); 22 | } 23 | 24 | static bool set_bit(struct bit_position position, bool bit) 25 | { 26 | if (bit) { 27 | *position.byte |= (1 << position.bit); 28 | } else { 29 | *position.byte &= ~(1 << position.bit); 30 | } 31 | 32 | return bit; 33 | } 34 | 35 | bool lone_bits_get(void *bits, lone_size index) 36 | { 37 | return get_bit(bit_position(bits, index)); 38 | } 39 | 40 | bool lone_bits_set(void *bits, lone_size index, bool bit) 41 | { 42 | return set_bit(bit_position(bits, index), bit); 43 | } 44 | 45 | lone_size lone_bits_find_first_one(const void * restrict bits, lone_size size) 46 | { 47 | lone_size bit_offset, bit_position, i; 48 | const unsigned char * restrict bytes; 49 | unsigned char byte; 50 | 51 | for (bytes = bits, i = 0; i < size; ++i) { 52 | byte = bytes[i]; 53 | 54 | if (byte != 0) { 55 | bit_offset = i * 8 * sizeof(byte); 56 | bit_position = __builtin_clz(byte); 57 | 58 | /* integer promotion adds leading bits */ 59 | bit_position -= ((sizeof(int) - 1) * 8); 60 | 61 | return bit_offset + bit_position; 62 | } else { 63 | continue; 64 | } 65 | } 66 | 67 | return -1; 68 | } 69 | 70 | lone_size lone_bits_find_first_zero(const void * restrict bits, lone_size size) 71 | { 72 | lone_size bit_offset, bit_position, i; 73 | const unsigned char * restrict bytes; 74 | unsigned char byte; 75 | 76 | for (bytes = bits, i = 0; i < size; ++i) { 77 | byte = bytes[i]; 78 | 79 | if (byte != 255) { 80 | byte = ~byte; 81 | 82 | bit_offset = i * 8 * sizeof(byte); 83 | bit_position = __builtin_clz(byte); 84 | 85 | /* integer promotion adds leading bits */ 86 | bit_position -= ((sizeof(int) - 1) * 8); 87 | 88 | return bit_offset + bit_position; 89 | } else { 90 | continue; 91 | } 92 | } 93 | 94 | return -1; 95 | } 96 | -------------------------------------------------------------------------------- /source/lone/hash.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | void lone_hash_initialize(struct lone_system *system, struct lone_bytes random) 9 | { 10 | lone_hash_fnv_1a_initialize(system, random); 11 | } 12 | -------------------------------------------------------------------------------- /source/lone/hash/fnv_1a.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | unsigned long __attribute__((pure)) lone_hash_fnv_1a(struct lone_bytes data, unsigned long offset_basis) 6 | { 7 | unsigned long hash = offset_basis; 8 | unsigned char *bytes = data.pointer; 9 | size_t count = data.count; 10 | 11 | while (count--) { 12 | hash ^= *bytes++; 13 | hash *= FNV_PRIME; 14 | } 15 | 16 | return hash; 17 | } 18 | 19 | void lone_hash_fnv_1a_initialize(struct lone_system *system, struct lone_bytes random) 20 | { 21 | system->hash.fnv_1a.offset_basis = lone_hash_fnv_1a(random, FNV_OFFSET_BASIS); 22 | } 23 | -------------------------------------------------------------------------------- /source/lone/linux.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | 7 | void linux_exit(int code) 8 | { 9 | linux_system_call_1(__NR_exit, code); 10 | __builtin_unreachable(); 11 | } 12 | 13 | long linux_openat(int dirfd, unsigned char *path, int flags) 14 | { 15 | return linux_system_call_4(__NR_openat, dirfd, (long) path, flags, 0); 16 | } 17 | 18 | long linux_close(int fd) 19 | { 20 | return linux_system_call_1(__NR_close, fd); 21 | } 22 | 23 | ssize_t linux_read(int fd, const void *buffer, size_t count) 24 | { 25 | return linux_system_call_3(__NR_read, fd, (long) buffer, (long) count); 26 | } 27 | 28 | ssize_t linux_write(int fd, const void *buffer, size_t count) 29 | { 30 | return linux_system_call_3(__NR_write, fd, (long) buffer, (long) count); 31 | } 32 | 33 | off_t linux_lseek(int fd, off_t offset, int origin) 34 | { 35 | return linux_system_call_3(__NR_lseek, fd, (long) offset, (long) origin); 36 | } 37 | 38 | intptr_t linux_mmap(void *address, size_t length, int protections, int flags, int file_descriptor, off_t offset) 39 | { 40 | return linux_system_call_6(__NR_mmap, (long) address, (long) length, (long) protections, (long) flags, (long) file_descriptor, (long) offset); 41 | } 42 | 43 | int linux_munmap(void *address, size_t length) 44 | { 45 | return linux_system_call_2(__NR_munmap, (long) address, (long) length); 46 | } 47 | -------------------------------------------------------------------------------- /source/lone/lisp.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void lone_lisp_initialize(struct lone_lisp *lone, struct lone_system *system, void *native_stack) 15 | { 16 | struct lone_lisp_function_flags flags = { .evaluate_arguments = 0, .evaluate_result = 0 }; 17 | struct lone_lisp_value import, export; 18 | 19 | lone->system = system; 20 | lone->native_stack = native_stack; 21 | 22 | lone_lisp_heap_initialize(lone); 23 | 24 | /* system, memory, stack and heap initialized 25 | * can now use lisp value creation functions 26 | */ 27 | 28 | lone->symbol_table = lone_lisp_table_create(lone, 256, lone_lisp_nil()); 29 | 30 | lone->modules.loaded = lone_lisp_table_create(lone, 32, lone_lisp_nil()); 31 | lone->modules.embedded = lone_lisp_nil(); 32 | lone->modules.top_level_environment = lone_lisp_table_create(lone, 8, lone_lisp_nil()); 33 | lone->modules.path = lone_lisp_vector_create(lone, 8); 34 | 35 | import = lone_lisp_primitive_create(lone, "import", lone_lisp_primitive_module_import, lone_lisp_nil(), flags); 36 | export = lone_lisp_primitive_create(lone, "export", lone_lisp_primitive_module_export, lone_lisp_nil(), flags); 37 | lone_lisp_table_set(lone, lone->modules.top_level_environment, lone_lisp_intern_c_string(lone, "import"), import); 38 | lone_lisp_table_set(lone, lone->modules.top_level_environment, lone_lisp_intern_c_string(lone, "export"), export); 39 | 40 | lone->modules.null = lone_lisp_module_create(lone, lone_lisp_nil()); 41 | } 42 | -------------------------------------------------------------------------------- /source/lone/lisp/hash.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | static size_t lone_lisp_hash_heap_value_recursively(struct lone_lisp_heap_value *value, unsigned long hash); 11 | 12 | static size_t lone_lisp_hash_value_recursively(struct lone_lisp_value value, unsigned long hash) 13 | { 14 | struct lone_bytes bytes; 15 | enum lone_lisp_value_type type; 16 | lone_lisp_integer integer; 17 | 18 | type = lone_lisp_type_of(value); 19 | 20 | bytes.pointer = (unsigned char *) &type; 21 | bytes.count = sizeof(type); 22 | hash = lone_hash_fnv_1a(bytes, hash); 23 | 24 | switch (type) { 25 | case LONE_LISP_TYPE_NIL: 26 | case LONE_LISP_TYPE_TRUE: 27 | case LONE_LISP_TYPE_FALSE: 28 | return hash; 29 | case LONE_LISP_TYPE_HEAP_VALUE: 30 | return lone_lisp_hash_heap_value_recursively(lone_lisp_heap_value_of(value), hash); 31 | case LONE_LISP_TYPE_INTEGER: 32 | integer = lone_lisp_integer_of(value); 33 | bytes.pointer = (unsigned char *) &integer; 34 | bytes.count = sizeof(integer); 35 | break; 36 | } 37 | 38 | hash = lone_hash_fnv_1a(bytes, hash); 39 | return hash; 40 | } 41 | 42 | static size_t lone_lisp_hash_heap_value_recursively(struct lone_lisp_heap_value *value, unsigned long hash) 43 | { 44 | struct lone_bytes bytes; 45 | 46 | bytes.pointer = (unsigned char *) &value->type; 47 | bytes.count = sizeof(value->type); 48 | hash = lone_hash_fnv_1a(bytes, hash); 49 | 50 | switch (value->type) { 51 | case LONE_LISP_TYPE_MODULE: 52 | case LONE_LISP_TYPE_FUNCTION: 53 | case LONE_LISP_TYPE_PRIMITIVE: 54 | case LONE_LISP_TYPE_VECTOR: 55 | case LONE_LISP_TYPE_TABLE: 56 | linux_exit(-1); 57 | case LONE_LISP_TYPE_LIST: 58 | hash = lone_lisp_hash_value_recursively(value->as.list.first, hash); 59 | hash = lone_lisp_hash_value_recursively(value->as.list.rest, hash); 60 | return hash; 61 | case LONE_LISP_TYPE_SYMBOL: 62 | bytes.pointer = (unsigned char *) &value; 63 | bytes.count = sizeof(value); 64 | break; 65 | case LONE_LISP_TYPE_TEXT: 66 | case LONE_LISP_TYPE_BYTES: 67 | bytes = value->as.bytes; 68 | break; 69 | } 70 | 71 | hash = lone_hash_fnv_1a(bytes, hash); 72 | return hash; 73 | } 74 | 75 | size_t lone_lisp_hash(struct lone_lisp *lone, struct lone_lisp_value value) 76 | { 77 | return lone_lisp_hash_value_recursively(value, lone->system->hash.fnv_1a.offset_basis); 78 | } 79 | -------------------------------------------------------------------------------- /source/lone/lisp/heap.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | 7 | struct lone_lisp_heap_value *lone_lisp_heap_allocate_value(struct lone_lisp *lone) 8 | { 9 | struct lone_lisp_heap_value *element; 10 | struct lone_lisp_heap *heap, *prev; 11 | size_t i; 12 | 13 | for (prev = lone->heaps, heap = prev; heap; prev = heap, heap = heap->next) { 14 | for (i = 0; i < LONE_LISP_HEAP_VALUE_COUNT; ++i) { 15 | element = &heap->values[i]; 16 | 17 | if (!element->live) { 18 | goto resurrect; 19 | } 20 | } 21 | } 22 | 23 | heap = lone_allocate(lone->system, sizeof(struct lone_lisp_heap)); 24 | prev->next = heap; 25 | heap->next = 0; 26 | element = &heap->values[0]; 27 | 28 | resurrect: 29 | element->live = true; 30 | return element; 31 | } 32 | 33 | void lone_lisp_deallocate_dead_heaps(struct lone_lisp *lone) 34 | { 35 | struct lone_lisp_heap *prev = lone->heaps, *heap = prev->next; 36 | size_t i; 37 | 38 | while (heap) { 39 | for (i = 0; i < LONE_LISP_HEAP_VALUE_COUNT; ++i) { 40 | if (heap->values[i].live) { /* at least one live object */ goto next_heap; } 41 | } 42 | 43 | /* no live objects */ 44 | prev->next = heap->next; 45 | lone_deallocate(lone->system, heap); 46 | heap = prev->next; 47 | continue; 48 | next_heap: 49 | prev = heap; 50 | heap = heap->next; 51 | } 52 | } 53 | 54 | void lone_lisp_heap_initialize(struct lone_lisp *lone) 55 | { 56 | lone->heaps = lone_allocate(lone->system, sizeof(struct lone_lisp_heap)); 57 | } 58 | -------------------------------------------------------------------------------- /source/lone/lisp/modules/embedded.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | static struct lone_bytes slice(struct lone_bytes bytes, struct lone_lisp_value pair) 16 | { 17 | struct lone_lisp_value first, second; 18 | size_t start, end, size; 19 | 20 | if (!lone_lisp_is_list(pair)) { /* unexpected value type */ linux_exit(-1); } 21 | first = lone_lisp_list_first(pair); 22 | if (!lone_lisp_is_integer(first)) { /* unexpected value type */ linux_exit(-1); } 23 | second = lone_lisp_list_rest(pair); 24 | if (!lone_lisp_is_integer(second)) { /* unexpected value type */ linux_exit(-1); } 25 | 26 | start = lone_lisp_integer_of(first); 27 | size = lone_lisp_integer_of(second); 28 | end = start + size; 29 | 30 | if (start >= bytes.count || end >= bytes.count) { 31 | /* segment overrun */ linux_exit(-1); 32 | } 33 | 34 | return (struct lone_bytes) { 35 | .count = size, 36 | .pointer = bytes.pointer + start 37 | }; 38 | } 39 | 40 | void lone_lisp_modules_embedded_load(struct lone_lisp *lone, lone_elf_native_segment *segment) 41 | { 42 | struct lone_lisp_value descriptor; 43 | struct lone_lisp_value symbol, data, module, locations; 44 | struct lone_bytes bytes, code; 45 | 46 | descriptor = lone_lisp_segment_read_descriptor(lone, segment); 47 | 48 | if (lone_lisp_is_nil(descriptor)) { /* nothing to load */ return; } 49 | 50 | symbol = lone_lisp_intern_c_string(lone, "data"); 51 | data = lone_lisp_table_get(lone, descriptor, symbol); 52 | bytes = lone_lisp_heap_value_of(data)->as.bytes; 53 | 54 | symbol = lone_lisp_intern_c_string(lone, "modules"); 55 | lone->modules.embedded = lone_lisp_table_get(lone, descriptor, symbol); 56 | 57 | symbol = lone_lisp_intern_c_string(lone, "run"); 58 | locations = lone_lisp_table_get(lone, descriptor, symbol); 59 | 60 | if (lone_lisp_is_nil(locations)) { /* no code to evaluate */ return; } 61 | 62 | code = slice(bytes, locations); 63 | 64 | module = lone_lisp_module_for_name(lone, symbol); 65 | lone_lisp_module_load_from_bytes(lone, module, code); 66 | } 67 | -------------------------------------------------------------------------------- /source/lone/lisp/modules/intrinsic.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | void lone_lisp_modules_intrinsic_initialize(struct lone_lisp *lone, 15 | int argc, char **argv, char **envp, 16 | struct lone_auxiliary_vector *auxv) 17 | { 18 | lone_lisp_modules_intrinsic_linux_initialize(lone, argc, argv, envp, auxv); 19 | lone_lisp_modules_intrinsic_lone_initialize(lone); 20 | lone_lisp_modules_intrinsic_math_initialize(lone); 21 | lone_lisp_modules_intrinsic_bytes_initialize(lone); 22 | lone_lisp_modules_intrinsic_text_initialize(lone); 23 | lone_lisp_modules_intrinsic_list_initialize(lone); 24 | lone_lisp_modules_intrinsic_vector_initialize(lone); 25 | lone_lisp_modules_intrinsic_table_initialize(lone); 26 | } 27 | -------------------------------------------------------------------------------- /source/lone/lisp/modules/intrinsic/text.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | void lone_lisp_modules_intrinsic_text_initialize(struct lone_lisp *lone) 17 | { 18 | struct lone_lisp_value name, module; 19 | struct lone_lisp_function_flags flags; 20 | 21 | name = lone_lisp_intern_c_string(lone, "text"); 22 | module = lone_lisp_module_for_name(lone, name); 23 | flags.evaluate_arguments = true; 24 | flags.evaluate_result = false; 25 | 26 | lone_lisp_module_export_primitive(lone, module, "to-symbol", 27 | "text_to_symbol", lone_lisp_primitive_text_to_symbol, module, flags); 28 | 29 | lone_lisp_module_export_primitive(lone, module, "join", 30 | "text_join", lone_lisp_primitive_text_join, module, flags); 31 | 32 | lone_lisp_module_export_primitive(lone, module, "concatenate", 33 | "text_concatenate", lone_lisp_primitive_text_concatenate, module, flags); 34 | } 35 | 36 | LONE_LISP_PRIMITIVE(text_to_symbol) 37 | { 38 | struct lone_lisp_value text; 39 | 40 | if (lone_lisp_list_destructure(arguments, 1, &text)) { 41 | /* wrong number of arguments */ linux_exit(-1); 42 | } 43 | 44 | if (!lone_lisp_is_text(text)) { 45 | /* argument not a text value: (to-symbol 123) */ linux_exit(-1); 46 | } 47 | 48 | return lone_lisp_text_to_symbol(lone, text); 49 | } 50 | 51 | LONE_LISP_PRIMITIVE(text_join) 52 | { 53 | struct lone_bytes joined; 54 | 55 | joined = lone_lisp_join(lone, 56 | lone_lisp_list_first(arguments), 57 | lone_lisp_list_rest(arguments), 58 | lone_lisp_is_text); 59 | 60 | return lone_lisp_text_transfer_bytes(lone, joined, true); 61 | } 62 | 63 | LONE_LISP_PRIMITIVE(text_concatenate) 64 | { 65 | return lone_lisp_text_transfer_bytes(lone, lone_lisp_concatenate(lone, arguments, lone_lisp_is_text), true); 66 | } 67 | -------------------------------------------------------------------------------- /source/lone/lisp/segment.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | struct lone_lisp_value lone_lisp_segment_read_descriptor(struct lone_lisp *lone, lone_elf_native_segment *segment) 15 | { 16 | struct lone_bytes bytes; 17 | struct lone_lisp_value descriptor, symbol, data; 18 | struct lone_lisp_reader reader; 19 | size_t offset; 20 | 21 | bytes = lone_segment_bytes(segment); 22 | 23 | if (bytes.count == 0) { 24 | /* empty lone segment */ return lone_lisp_nil(); 25 | } 26 | 27 | lone_lisp_reader_for_bytes(lone, &reader, bytes); 28 | descriptor = lone_lisp_read(lone, &reader); 29 | if (reader.status.error || !lone_lisp_is_table(descriptor)) { 30 | /* corrupt or invalid segment */ linux_exit(-1); 31 | } 32 | 33 | offset = reader.buffer.position.read; 34 | symbol = lone_lisp_intern_c_string(lone, "data"); 35 | data = lone_lisp_bytes_transfer(lone, bytes.pointer + offset, bytes.count - offset, false); 36 | lone_lisp_table_set(lone, descriptor, symbol, data); 37 | 38 | return descriptor; 39 | } 40 | -------------------------------------------------------------------------------- /source/lone/lisp/value.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | 6 | struct lone_lisp_value lone_lisp_value_from_heap_value(struct lone_lisp_heap_value *heap_value) 7 | { 8 | return (struct lone_lisp_value) { 9 | .tagged = (long) heap_value, 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /source/lone/lisp/value/bytes.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | struct lone_lisp_value lone_lisp_bytes_transfer(struct lone_lisp *lone, 11 | unsigned char *pointer, size_t count, 12 | bool should_deallocate) 13 | { 14 | struct lone_lisp_heap_value *actual = lone_lisp_heap_allocate_value(lone); 15 | actual->type = LONE_LISP_TYPE_BYTES; 16 | actual->as.bytes.count = count; 17 | actual->as.bytes.pointer = pointer; 18 | actual->should_deallocate_bytes = should_deallocate; 19 | return lone_lisp_value_from_heap_value(actual); 20 | } 21 | 22 | struct lone_lisp_value lone_lisp_bytes_transfer_bytes(struct lone_lisp *lone, 23 | struct lone_bytes bytes, bool should_deallocate) 24 | { 25 | return lone_lisp_bytes_transfer(lone, bytes.pointer, bytes.count, should_deallocate); 26 | } 27 | 28 | struct lone_lisp_value lone_lisp_bytes_copy(struct lone_lisp *lone, unsigned char *pointer, size_t count) 29 | { 30 | unsigned char *copy = lone_allocate_uninitialized(lone->system, count + 1); 31 | lone_memory_move(pointer, copy, count); 32 | copy[count] = '\0'; 33 | return lone_lisp_bytes_transfer(lone, copy, count, true); 34 | } 35 | 36 | struct lone_lisp_value lone_lisp_bytes_create(struct lone_lisp *lone, size_t count) 37 | { 38 | unsigned char *pointer = lone_allocate(lone->system, count + 1); 39 | return lone_lisp_bytes_transfer(lone, pointer, count, true); 40 | } 41 | -------------------------------------------------------------------------------- /source/lone/lisp/value/function.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | struct lone_lisp_value lone_lisp_function_create(struct lone_lisp *lone, 9 | struct lone_lisp_value arguments, struct lone_lisp_value code, 10 | struct lone_lisp_value environment, struct lone_lisp_function_flags flags) 11 | { 12 | struct lone_lisp_heap_value *actual = lone_lisp_heap_allocate_value(lone); 13 | actual->type = LONE_LISP_TYPE_FUNCTION; 14 | actual->as.function.arguments = arguments; 15 | actual->as.function.code = code; 16 | actual->as.function.environment = environment; 17 | actual->as.function.flags = flags; 18 | return lone_lisp_value_from_heap_value(actual); 19 | } 20 | -------------------------------------------------------------------------------- /source/lone/lisp/value/integer.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | struct lone_lisp_value lone_lisp_integer_create(lone_lisp_integer integer) 6 | { 7 | return (struct lone_lisp_value) { 8 | .tagged = (integer << 1) | LONE_LISP_TYPE_INTEGER, 9 | }; 10 | } 11 | 12 | struct lone_lisp_value lone_lisp_integer_from_pointer(void *pointer) 13 | { 14 | return lone_lisp_integer_create((intptr_t) pointer); 15 | } 16 | 17 | struct lone_lisp_value lone_lisp_integer_parse(struct lone_lisp *lone, unsigned char *digits, size_t count) 18 | { 19 | size_t i = 0; 20 | long integer = 0; 21 | 22 | switch (*digits) { case '+': case '-': ++i; break; } 23 | 24 | while (i < count) { 25 | integer *= 10; 26 | integer += digits[i++] - '0'; 27 | } 28 | 29 | if (*digits == '-') { integer *= -1; } 30 | 31 | return lone_lisp_integer_create(integer); 32 | } 33 | 34 | struct lone_lisp_value lone_lisp_zero(void) 35 | { 36 | return lone_lisp_integer_create(0); 37 | } 38 | 39 | struct lone_lisp_value lone_lisp_one(void) 40 | { 41 | return lone_lisp_integer_create(+1); 42 | } 43 | 44 | struct lone_lisp_value lone_lisp_minus_one(void) 45 | { 46 | return lone_lisp_integer_create(-1); 47 | } 48 | -------------------------------------------------------------------------------- /source/lone/lisp/value/module.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct lone_lisp_value lone_lisp_module_create(struct lone_lisp *lone, struct lone_lisp_value name) 10 | { 11 | struct lone_lisp_heap_value *actual = lone_lisp_heap_allocate_value(lone); 12 | actual->type = LONE_LISP_TYPE_MODULE; 13 | actual->as.module.name = name; 14 | actual->as.module.environment = lone_lisp_table_create(lone, 64, lone->modules.top_level_environment); 15 | actual->as.module.exports = lone_lisp_vector_create(lone, 16); 16 | return lone_lisp_value_from_heap_value(actual); 17 | } 18 | -------------------------------------------------------------------------------- /source/lone/lisp/value/primitive.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | struct lone_lisp_value lone_lisp_primitive_create(struct lone_lisp *lone, 10 | char *name, lone_lisp_primitive_function function, 11 | struct lone_lisp_value closure, struct lone_lisp_function_flags flags) 12 | { 13 | struct lone_lisp_heap_value *actual = lone_lisp_heap_allocate_value(lone); 14 | actual->type = LONE_LISP_TYPE_PRIMITIVE; 15 | actual->as.primitive.name = lone_lisp_intern_c_string(lone, name); 16 | actual->as.primitive.function = function; 17 | actual->as.primitive.closure = closure; 18 | actual->as.primitive.flags = flags; 19 | return lone_lisp_value_from_heap_value(actual); 20 | } 21 | -------------------------------------------------------------------------------- /source/lone/lisp/value/symbol.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | static struct lone_lisp_value lone_lisp_symbol_transfer(struct lone_lisp *lone, 10 | unsigned char *text, size_t length, bool should_deallocate) 11 | { 12 | struct lone_lisp_value value = lone_lisp_bytes_transfer(lone, text, length, should_deallocate); 13 | lone_lisp_heap_value_of(value)->type = LONE_LISP_TYPE_SYMBOL; 14 | return value; 15 | } 16 | 17 | static struct lone_lisp_value lone_lisp_symbol_transfer_bytes(struct lone_lisp *lone, 18 | struct lone_bytes bytes, bool should_deallocate) 19 | { 20 | return lone_lisp_symbol_transfer(lone, bytes.pointer, bytes.count, should_deallocate); 21 | } 22 | 23 | static struct lone_lisp_value lone_lisp_symbol_copy(struct lone_lisp *lone, 24 | unsigned char *text, size_t length) 25 | { 26 | struct lone_lisp_value value = lone_lisp_bytes_copy(lone, text, length); 27 | lone_lisp_heap_value_of(value)->type = LONE_LISP_TYPE_SYMBOL; 28 | return value; 29 | } 30 | 31 | struct lone_lisp_value lone_lisp_intern(struct lone_lisp *lone, 32 | unsigned char *bytes, size_t count, bool should_deallocate) 33 | { 34 | struct lone_lisp_value key, value; 35 | 36 | key = should_deallocate? 37 | lone_lisp_bytes_copy(lone, bytes, count) 38 | : lone_lisp_bytes_transfer(lone, bytes, count, should_deallocate); 39 | 40 | value = lone_lisp_table_get(lone, lone->symbol_table, key); 41 | 42 | if (lone_lisp_is_nil(value)) { 43 | value = should_deallocate? 44 | lone_lisp_symbol_copy(lone, bytes, count) 45 | : lone_lisp_symbol_transfer(lone, bytes, count, should_deallocate); 46 | 47 | lone_lisp_table_set(lone, lone->symbol_table, key, value); 48 | } 49 | 50 | return value; 51 | } 52 | 53 | struct lone_lisp_value lone_lisp_intern_bytes(struct lone_lisp *lone, 54 | struct lone_bytes bytes, bool should_deallocate) 55 | { 56 | return lone_lisp_intern(lone, bytes.pointer, bytes.count, should_deallocate); 57 | } 58 | 59 | struct lone_lisp_value lone_lisp_intern_c_string(struct lone_lisp *lone, char *c_string) 60 | { 61 | return lone_lisp_intern(lone, (unsigned char *) c_string, lone_c_string_length(c_string), false); 62 | } 63 | 64 | struct lone_lisp_value lone_lisp_intern_text(struct lone_lisp *lone, struct lone_lisp_value text) 65 | { 66 | return lone_lisp_intern_bytes(lone, lone_lisp_heap_value_of(text)->as.bytes, true); 67 | } 68 | -------------------------------------------------------------------------------- /source/lone/lisp/value/text.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | struct lone_lisp_value lone_lisp_text_transfer(struct lone_lisp *lone, 11 | unsigned char *text, size_t length, bool should_deallocate) 12 | { 13 | struct lone_lisp_value value = lone_lisp_bytes_transfer(lone, text, length, should_deallocate); 14 | lone_lisp_heap_value_of(value)->type = LONE_LISP_TYPE_TEXT; 15 | return value; 16 | } 17 | 18 | struct lone_lisp_value lone_lisp_text_transfer_bytes(struct lone_lisp *lone, 19 | struct lone_bytes bytes, bool should_deallocate) 20 | { 21 | return lone_lisp_text_transfer(lone, bytes.pointer, bytes.count, should_deallocate); 22 | } 23 | 24 | struct lone_lisp_value lone_lisp_text_copy(struct lone_lisp *lone, unsigned char *text, size_t length) 25 | { 26 | struct lone_lisp_value value = lone_lisp_bytes_copy(lone, text, length); 27 | lone_lisp_heap_value_of(value)->type = LONE_LISP_TYPE_TEXT; 28 | return value; 29 | } 30 | 31 | struct lone_lisp_value lone_lisp_text_from_c_string(struct lone_lisp *lone, char *c_string) 32 | { 33 | return lone_lisp_text_transfer(lone, (unsigned char *) c_string, lone_c_string_length(c_string), false); 34 | } 35 | 36 | struct lone_lisp_value lone_lisp_text_to_symbol(struct lone_lisp *lone, struct lone_lisp_value text) 37 | { 38 | return lone_lisp_intern_text(lone, text); 39 | } 40 | -------------------------------------------------------------------------------- /source/lone/memory.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void lone_memory_initialize(struct lone_system *system, struct lone_bytes initial_static_memory) 8 | { 9 | system->memory = (struct lone_memory *) __builtin_assume_aligned(initial_static_memory.pointer, LONE_ALIGNMENT); 10 | system->memory->prev = system->memory->next = 0; 11 | system->memory->free = 1; 12 | system->memory->size = initial_static_memory.count - sizeof(struct lone_memory); 13 | } 14 | -------------------------------------------------------------------------------- /source/lone/memory/array.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define MULTIPLICATION_OVERFLOWED(result, x, y) __builtin_mul_overflow((x), (y), (result)) 8 | 9 | size_t __attribute__((const)) lone_memory_array_size_in_bytes(size_t element_count, size_t element_size) 10 | { 11 | size_t size_in_bytes; 12 | 13 | /* size_in_bytes = element_count * element_size; overflowed? */ 14 | if (MULTIPLICATION_OVERFLOWED(&size_in_bytes, element_count, element_size)) { 15 | linux_exit(-1); /* integer overflow */ 16 | } 17 | 18 | return size_in_bytes; 19 | } 20 | 21 | bool lone_memory_array_is_bounded(size_t element_index, size_t element_capacity, size_t element_size) 22 | { 23 | size_t end_of_indexed_element = lone_memory_array_size_in_bytes(element_index + 1, element_size); 24 | size_t end_of_buffer = lone_memory_array_size_in_bytes(element_capacity, element_size); 25 | 26 | if (end_of_indexed_element > end_of_buffer) { 27 | return false; /* buffer overrun */ 28 | } else { 29 | return true; 30 | } 31 | } 32 | 33 | void * lone_memory_array(struct lone_system *system, void *buffer_or_null, size_t element_count, size_t element_size) 34 | { 35 | return lone_reallocate(system, buffer_or_null, lone_memory_array_size_in_bytes(element_count, element_size)); 36 | } 37 | -------------------------------------------------------------------------------- /source/lone/memory/functions.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | int lone_memory_compare(void *a, void *b, size_t count) 6 | { 7 | size_t i; 8 | unsigned char *p, *q, x, y; 9 | 10 | if (a == b || count == 0) { 11 | return 0; 12 | } 13 | 14 | p = a; 15 | q = b; 16 | 17 | for (i = 0; i < count; ++i) { 18 | x = p[i]; 19 | y = q[i]; 20 | 21 | if (x == y) { 22 | continue; 23 | } 24 | 25 | return x - y; 26 | } 27 | 28 | return 0; 29 | } 30 | 31 | bool lone_memory_is_equal(void *a, void *b, size_t count) 32 | { 33 | return lone_memory_compare(a, b, count) == 0; 34 | } 35 | 36 | bool lone_memory_is_zero(void *x, size_t count) 37 | { 38 | unsigned char *p; 39 | lone_size i; 40 | 41 | if (!x) { 42 | return true; 43 | } 44 | 45 | for (i = 0, p = x; i < count; ++i) { 46 | if (p[i]) { return false; } 47 | } 48 | 49 | return true; 50 | } 51 | 52 | void lone_memory_move(void *from, void *to, size_t count) 53 | { 54 | unsigned char *source = from, *destination = to; 55 | 56 | if (source >= destination) { 57 | /* destination is at or behind source, copy forwards */ 58 | while (count--) { *destination++ = *source++; } 59 | } else { 60 | /* destination is ahead of source, copy backwards */ 61 | source += count; destination += count; 62 | while (count--) { *--destination = *--source; } 63 | } 64 | } 65 | 66 | void lone_memory_set(void *to, unsigned char byte, size_t count) 67 | { 68 | unsigned char *memory = to; 69 | size_t i; 70 | 71 | for (i = 0; i < count; ++i) { 72 | memory[i] = byte; 73 | } 74 | } 75 | 76 | void lone_memory_zero(void *to, size_t count) 77 | { 78 | lone_memory_set(to, 0, count); 79 | } 80 | 81 | size_t lone_c_string_length(char *c_string) 82 | { 83 | size_t length = 0; 84 | if (!c_string) { return 0; } 85 | while (c_string[length++]); 86 | return length - 1; 87 | } 88 | 89 | /* Compilers emit calls to mem* functions even with -nostdlib */ 90 | void *memset(void *to, int byte, size_t count) 91 | { 92 | lone_memory_set(to, (unsigned char) byte, count); 93 | return to; 94 | } 95 | 96 | void *memcpy(void *to, void *from, size_t count) 97 | { 98 | lone_memory_move(from, to, count); 99 | return to; 100 | } 101 | -------------------------------------------------------------------------------- /source/lone/segment.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | struct lone_bytes lone_segment_bytes(lone_elf_native_segment *segment) 6 | { 7 | if (!segment) { 8 | return LONE_BYTES_VALUE_NULL(); 9 | } 10 | 11 | return LONE_BYTES_VALUE(segment->p_memsz, segment->p_vaddr); 12 | } 13 | -------------------------------------------------------------------------------- /source/lone/system.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void lone_system_initialize(struct lone_system *system, struct lone_bytes initial_static_memory, struct lone_bytes random_bytes) 8 | { 9 | lone_memory_initialize(system, initial_static_memory); 10 | lone_hash_initialize(system, random_bytes); 11 | } 12 | -------------------------------------------------------------------------------- /source/lone/utilities.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | 5 | long lone_min(long x, long y) 6 | { 7 | if (x <= y) { return x; } else { return y; } 8 | } 9 | 10 | long lone_max(long x, long y) 11 | { 12 | if (x >= y) { return x; } else { return y; } 13 | } 14 | -------------------------------------------------------------------------------- /source/tests/lone/bits.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | static LONE_TEST_FUNCTION(test_lone_bits_get) 9 | { 10 | unsigned char bits[] = { 11 | 0, /* 0 - 7 */ 12 | 0, /* 8 - 15 */ 13 | 0, /* 16 - 23 */ 14 | 0, /* 24 - 31 */ 15 | 0, /* 32 - 39 */ 16 | 0, /* 40 - 47 */ 17 | 1, /* 48 - 55 */ 18 | 0, /* 56 - 63 */ 19 | }; 20 | 21 | lone_test_assert_true(suite, test, lone_bits_get(bits, 55)); 22 | lone_test_assert_false(suite, test, lone_bits_get(bits, 48)); 23 | } 24 | 25 | static LONE_TEST_FUNCTION(test_lone_bits_set) 26 | { 27 | unsigned char bits[] = { 28 | 0, /* 0 - 7 */ 29 | 0, /* 8 - 15 */ 30 | 0, /* 16 - 23 */ 31 | 0, /* 24 - 31 */ 32 | 0, /* 32 - 39 */ 33 | 0, /* 40 - 47 */ 34 | 0, /* 48 - 55 */ 35 | 0, /* 56 - 63 */ 36 | }; 37 | 38 | lone_bits_set(bits, 20, 1); 39 | lone_bits_set(bits, 48, 1); 40 | 41 | lone_test_assert_unsigned_char_equal(suite, test, bits[2], 8); 42 | lone_test_assert_unsigned_char_equal(suite, test, bits[6], 128); 43 | } 44 | 45 | static LONE_TEST_FUNCTION(test_lone_bits_find_first_zero) 46 | { 47 | unsigned char bits[] = { 48 | 255, /* 0 - 7 */ 49 | 255, /* 8 - 15 */ 50 | 255, /* 16 - 23 */ 51 | 255, /* 24 - 31 */ 52 | 255, /* 32 - 39 */ 53 | 255, /* 40 - 47 */ 54 | 239, /* 48 - 55 */ 55 | 255, /* 56 - 63 */ 56 | }; 57 | 58 | lone_size i = lone_bits_find_first_zero(bits, sizeof(bits)); 59 | lone_test_assert_true(suite, test, i == 51); 60 | } 61 | 62 | static LONE_TEST_FUNCTION(test_lone_bits_find_first_one) 63 | { 64 | unsigned char bits[] = { 65 | 0, /* 0 - 7 */ 66 | 0, /* 8 - 15 */ 67 | 0, /* 16 - 23 */ 68 | 0, /* 24 - 31 */ 69 | 4, /* 32 - 39 */ 70 | 0, /* 40 - 47 */ 71 | 0, /* 48 - 55 */ 72 | 0, /* 56 - 63 */ 73 | }; 74 | 75 | lone_size i = lone_bits_find_first_one(bits, sizeof(bits)); 76 | lone_test_assert_true(suite, test, i == 37); 77 | } 78 | 79 | long lone(int argc, char **argv, char **envp, struct lone_auxiliary_vector *auxv) 80 | { 81 | 82 | static struct lone_test_case cases[] = { 83 | 84 | LONE_TEST_CASE("lone/bits/get", test_lone_bits_get), 85 | LONE_TEST_CASE("lone/bits/set", test_lone_bits_set), 86 | LONE_TEST_CASE("lone/bits/find-first/zero", test_lone_bits_find_first_zero), 87 | LONE_TEST_CASE("lone/bits/find-first/one", test_lone_bits_find_first_one), 88 | 89 | LONE_TEST_CASE_NULL(), 90 | }; 91 | 92 | struct lone_test_suite suite = LONE_TEST_SUITE(cases); 93 | enum lone_test_result result; 94 | 95 | result = lone_test_suite_run(&suite); 96 | 97 | switch (result) { 98 | case LONE_TEST_RESULT_PASS: 99 | return 0; 100 | case LONE_TEST_RESULT_FAIL: 101 | return 1; 102 | case LONE_TEST_RESULT_SKIP: 103 | return 2; 104 | default: 105 | return -1; 106 | } 107 | } 108 | 109 | #include 110 | -------------------------------------------------------------------------------- /source/tests/system-call.c: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: AGPL-3.0-or-later */ 2 | 3 | #include 4 | #include 5 | 6 | long lone(int argc, char **argv, char **envp, struct lone_auxiliary_vector *auxvec) 7 | { 8 | char message[] = "Hello, world!\n"; 9 | linux_system_call_3(__NR_write, 1, (long) message, sizeof(message) - 1); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /test/c/linux/system-call/executable: -------------------------------------------------------------------------------- 1 | tests/system-call 2 | -------------------------------------------------------------------------------- /test/c/linux/system-call/output: -------------------------------------------------------------------------------- 1 | Hello, world! 2 | -------------------------------------------------------------------------------- /test/executable: -------------------------------------------------------------------------------- 1 | lone 2 | -------------------------------------------------------------------------------- /test/lone/bits/executable: -------------------------------------------------------------------------------- 1 | tests/lone/bits 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/hashing/distinguishes-bytes-types/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote set)) 2 | 3 | (set t { symbol "symbol" "symbol" "text"}) 4 | (print (t 'symbol) (t "symbol")) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/hashing/distinguishes-bytes-types/output: -------------------------------------------------------------------------------- 1 | "symbol" 2 | "text" 3 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/allow-lists-as-keys/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote)) 2 | 3 | (set table {}) 4 | (table '(a b c) 10) 5 | (table '(x y z) 20) 6 | (table '() 30) 7 | 8 | (print (table '(a b c)) (table '(x y z)) (table '())) 9 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/allow-lists-as-keys/output: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-applicable/get/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print ({"key" "value"} "key")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-applicable/get/output: -------------------------------------------------------------------------------- 1 | "value" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-applicable/set/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print ({"key" "value"} "key" "another value")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-applicable/set/output: -------------------------------------------------------------------------------- 1 | "another value" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/deletion-then-insertion/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) prefixed (table set delete)) 2 | 3 | (set t {}) 4 | 5 | (table.set t 'first 1) 6 | (table.set t 'second 2) 7 | (table.set t 'third 3) 8 | 9 | (table.delete t 'second) 10 | (table.set t 'second 2) 11 | 12 | (print t) 13 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/deletion-then-insertion/output: -------------------------------------------------------------------------------- 1 | { first 1 third 3 second 2 } 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/deletion/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) prefixed (table set delete)) 2 | 3 | (set t {}) 4 | 5 | (table.set t 'first 1) 6 | (table.set t 'second 2) 7 | (table.set t 'third 3) 8 | (table.set t 'fourth 4) 9 | (table.set t 'fifth 5) 10 | 11 | (table.delete t 'second) 12 | (table.delete t 'fourth) 13 | 14 | (print t) 15 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/deletion/output: -------------------------------------------------------------------------------- 1 | { first 1 third 3 fifth 5 } 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/insertion/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) prefixed (table set)) 2 | 3 | (set t {}) 4 | 5 | (table.set t 'first 1) 6 | (table.set t 'second 2) 7 | (table.set t 'third 3) 8 | 9 | (print t) 10 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/insertion/output: -------------------------------------------------------------------------------- 1 | { first 1 second 2 third 3 } 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/update/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) prefixed (table set)) 2 | 3 | (set t {}) 4 | 5 | (table.set t 'first 1) 6 | (table.set t 'second 2) 7 | (table.set t 'third 3) 8 | 9 | (table.set t 'third 3) 10 | (table.set t 'second 2) 11 | (table.set t 'first 1) 12 | 13 | (print t) 14 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/after/update/output: -------------------------------------------------------------------------------- 1 | { first 1 second 2 third 3 } 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/when-parsed/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print { first 1 second 2 third 3 }) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/tables/are-insertion-ordered/when-parsed/output: -------------------------------------------------------------------------------- 1 | { first 1 second 2 third 3 } 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/vectors/are-applicable/get/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print ([1 2 3 4 5] 2)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/vectors/are-applicable/get/output: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/vectors/are-applicable/set/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print ([1 2 3 4 5] 2 42)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/vectors/are-applicable/set/output: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/vectors/support-setting-values-at-arbitrary-indexes/input: -------------------------------------------------------------------------------- 1 | (import (lone set print quote) prefixed (vector set)) 2 | (set v []) 3 | (vector.set v 5 "this comes after 5 nils") 4 | (print v) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/language/semantics/vectors/support-setting-values-at-arbitrary-indexes/output: -------------------------------------------------------------------------------- 1 | [ nil nil nil nil nil "this comes after 5 nils" ] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/'/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print)) 2 | 3 | (print 'x) 4 | (print ''x) 5 | (print '''x) 6 | (print ''''x) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/'/output: -------------------------------------------------------------------------------- 1 | x 2 | (quote x) 3 | (quote (quote x)) 4 | (quote (quote (quote x))) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/list/dotted-pair/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote equal?) (list construct)) 2 | 3 | (print (equal? '(1 . (2 . ())) '(1 2))) 4 | (print (equal? '(1 2 . (3 . ())) '(1 2 3))) 5 | (print (equal? '(1 . 2) (construct 1 2))) 6 | (print (equal? '(1 . (2 . 3)) (construct 1 (construct 2 3)))) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/list/dotted-pair/output: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | true 4 | true 5 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/number/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print 0) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/number/0/output: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/table/empty/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print {}) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/table/empty/output: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/table/single-value/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print { "key" "value" }) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/table/single-value/output: -------------------------------------------------------------------------------- 1 | { "key" "value" } 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print []) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/0/output: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print [1]) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/1/output: -------------------------------------------------------------------------------- 1 | [ 1 ] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print [1 2]) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/2/output: -------------------------------------------------------------------------------- 1 | [ 1 2 ] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print [1 2 3]) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/language/syntax/vector/3/output: -------------------------------------------------------------------------------- 1 | [ 1 2 3 ] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/new/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (bytes new)) 2 | 3 | (print (new 16)) 4 | (print (new 128)) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/new/output: -------------------------------------------------------------------------------- 1 | bytes[0x00000000000000000000000000000000] 2 | bytes[0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000] 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/write-then-read/16/input: -------------------------------------------------------------------------------- 1 | (import 2 | (lone print set) 3 | (math /) 4 | (bytes 5 | new 6 | read-u16 write-u16 7 | read-s16 write-s16 8 | read-u16le write-u16le 9 | read-s16le write-s16le 10 | read-u16be write-u16be 11 | read-s16be write-s16be)) 12 | 13 | (set max-bits 16) 14 | (set memory (new (/ max-bits 8))) 15 | 16 | (print (write-u16 memory 0 +60000)) 17 | (print (read-u16 memory 0)) 18 | (print (read-s16 memory 0)) 19 | 20 | (print (write-s16 memory 0 -30000)) 21 | (print (read-u16 memory 0)) 22 | (print (read-s16 memory 0)) 23 | 24 | (print (write-u16le memory 0 +60000)) 25 | (print memory) 26 | (print (read-u16le memory 0)) 27 | (print (read-s16le memory 0)) 28 | (print (read-u16be memory 0)) 29 | (print (read-s16be memory 0)) 30 | 31 | (print (write-u16be memory 0 +60000)) 32 | (print memory) 33 | (print (read-u16le memory 0)) 34 | (print (read-s16le memory 0)) 35 | (print (read-u16be memory 0)) 36 | (print (read-s16be memory 0)) 37 | 38 | (print (write-s16le memory 0 -30000)) 39 | (print memory) 40 | (print (read-u16le memory 0)) 41 | (print (read-s16le memory 0)) 42 | (print (read-u16be memory 0)) 43 | (print (read-s16be memory 0)) 44 | 45 | (print (write-s16be memory 0 -30000)) 46 | (print memory) 47 | (print (read-u16le memory 0)) 48 | (print (read-s16le memory 0)) 49 | (print (read-u16be memory 0)) 50 | (print (read-s16be memory 0)) 51 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/write-then-read/16/output: -------------------------------------------------------------------------------- 1 | 60000 2 | 60000 3 | -5536 4 | -30000 5 | 35536 6 | -30000 7 | 60000 8 | bytes[0x60EA] 9 | 60000 10 | -5536 11 | 24810 12 | 24810 13 | 60000 14 | bytes[0xEA60] 15 | 24810 16 | 24810 17 | 60000 18 | -5536 19 | -30000 20 | bytes[0xD08A] 21 | 35536 22 | -30000 23 | 53386 24 | -12150 25 | -30000 26 | bytes[0x8AD0] 27 | 53386 28 | -12150 29 | 35536 30 | -30000 31 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/write-then-read/32/input: -------------------------------------------------------------------------------- 1 | (import 2 | (lone print set) 3 | (math /) 4 | (bytes 5 | new 6 | read-u32 write-u32 7 | read-s32 write-s32 8 | read-u32le write-u32le 9 | read-s32le write-s32le 10 | read-u32be write-u32be 11 | read-s32be write-s32be)) 12 | 13 | (set max-bits 32) 14 | (set memory (new (/ max-bits 8))) 15 | 16 | (print (write-u32 memory 0 +4000000000)) 17 | (print (read-u32 memory 0)) 18 | (print (read-s32 memory 0)) 19 | 20 | (print (write-s32 memory 0 -2000000000)) 21 | (print (read-u32 memory 0)) 22 | (print (read-s32 memory 0)) 23 | 24 | (print (write-u32le memory 0 +4000000000)) 25 | (print memory) 26 | (print (read-u32le memory 0)) 27 | (print (read-s32le memory 0)) 28 | (print (read-u32be memory 0)) 29 | (print (read-s32be memory 0)) 30 | 31 | (print (write-s32le memory 0 -2000000000)) 32 | (print memory) 33 | (print (read-u32le memory 0)) 34 | (print (read-s32le memory 0)) 35 | (print (read-u32be memory 0)) 36 | (print (read-s32be memory 0)) 37 | 38 | (print (write-u32be memory 0 +4000000000)) 39 | (print memory) 40 | (print (read-u32le memory 0)) 41 | (print (read-s32le memory 0)) 42 | (print (read-u32be memory 0)) 43 | (print (read-s32be memory 0)) 44 | 45 | (print (write-s32be memory 0 -2000000000)) 46 | (print memory) 47 | (print (read-u32le memory 0)) 48 | (print (read-s32le memory 0)) 49 | (print (read-u32be memory 0)) 50 | (print (read-s32be memory 0)) 51 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/write-then-read/32/output: -------------------------------------------------------------------------------- 1 | 4000000000 2 | 4000000000 3 | -294967296 4 | -2000000000 5 | 2294967296 6 | -2000000000 7 | 4000000000 8 | bytes[0x00286BEE] 9 | 4000000000 10 | -294967296 11 | 2649070 12 | 2649070 13 | -2000000000 14 | bytes[0x006CCA88] 15 | 2294967296 16 | -2000000000 17 | 7129736 18 | 7129736 19 | 4000000000 20 | bytes[0xEE6B2800] 21 | 2649070 22 | 2649070 23 | 4000000000 24 | -294967296 25 | -2000000000 26 | bytes[0x88CA6C00] 27 | 7129736 28 | 7129736 29 | 2294967296 30 | -2000000000 31 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/write-then-read/8/input: -------------------------------------------------------------------------------- 1 | (import 2 | (lone print set) 3 | (math /) 4 | (bytes 5 | new 6 | read-u8 write-u8 7 | read-s8 write-s8)) 8 | 9 | (set max-bits 8) 10 | (set memory (new (/ max-bits 8))) 11 | 12 | (print (write-u8 memory 0 +250)) 13 | (print (read-u8 memory 0)) 14 | (print (read-s8 memory 0)) 15 | 16 | (print (write-s8 memory 0 -100)) 17 | (print (read-u8 memory 0)) 18 | (print (read-s8 memory 0)) 19 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/write-then-read/8/output: -------------------------------------------------------------------------------- 1 | 250 2 | 250 3 | -6 4 | -100 5 | 156 6 | -100 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/zero?/input: -------------------------------------------------------------------------------- 1 | (import (lone print set) (bytes new zero? write-u8)) 2 | 3 | (set buffer (new 16)) 4 | (print (zero? buffer)) 5 | (write-u8 buffer 7 42) 6 | (print (zero? buffer)) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/bytes/zero?/output: -------------------------------------------------------------------------------- 1 | true 2 | false 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux argument-count)) 2 | 3 | (print argument-count) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/0/output: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/1/arguments: -------------------------------------------------------------------------------- 1 | argument 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux argument-count)) 2 | 3 | (print argument-count) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/1/output: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/2/arguments: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux argument-count)) 2 | 3 | (print argument-count) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/argument-count/2/output: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux arguments)) 2 | 3 | (print arguments) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/0/output: -------------------------------------------------------------------------------- 1 | [ "lone" ] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/1/arguments: -------------------------------------------------------------------------------- 1 | argument 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux arguments)) 2 | 3 | (print arguments) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/1/output: -------------------------------------------------------------------------------- 1 | [ "lone" "argument" ] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/2/arguments: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux arguments)) 2 | 3 | (print arguments) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/arguments/2/output: -------------------------------------------------------------------------------- 1 | [ "lone" "1" "2" ] 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/environment/all/environment: -------------------------------------------------------------------------------- 1 | VARIABLE=value 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/environment/all/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux environment)) 2 | 3 | (print environment) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/environment/all/output: -------------------------------------------------------------------------------- 1 | { "VARIABLE" "value" } 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/environment/specific/environment: -------------------------------------------------------------------------------- 1 | A=X 2 | B=Y 3 | C=Z 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/environment/specific/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux environment)) 2 | 3 | (print (environment "A")) 4 | (print (environment "B")) 5 | (print (environment "C")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/environment/specific/output: -------------------------------------------------------------------------------- 1 | "X" 2 | "Y" 3 | "Z" 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/program-name/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (linux arguments)) 2 | 3 | (print (arguments 0)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/program-name/output: -------------------------------------------------------------------------------- 1 | "custom-name" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/linux/program-name/program-name: -------------------------------------------------------------------------------- 1 | custom-name 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/construct/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (list construct)) 2 | 3 | (print (construct 1 ())) 4 | (print (construct 1 (construct 2 ()))) 5 | (print (construct 1 2)) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/construct/output: -------------------------------------------------------------------------------- 1 | (1) 2 | (1 2) 3 | (1 . 2) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/first/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list first)) 2 | 3 | (print (first '("x"))) 4 | (print (first '("x" "y"))) 5 | (print (first '("x" "y" "z"))) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/first/output: -------------------------------------------------------------------------------- 1 | "x" 2 | "x" 3 | "x" 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list flatten)) 2 | 3 | (print (flatten '(a b c d e f))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/0/output: -------------------------------------------------------------------------------- 1 | (a b c d e f) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list flatten)) 2 | 3 | (print (flatten '(a (b c) d (e f)))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/1/output: -------------------------------------------------------------------------------- 1 | (a b c d e f) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list flatten)) 2 | 3 | (print (flatten '(a (b (c d)) e (f)))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/2/output: -------------------------------------------------------------------------------- 1 | (a b c d e f) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list flatten)) 2 | 3 | (print (flatten '(a (b (c (d e f)))))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/3/output: -------------------------------------------------------------------------------- 1 | (a b c d e f) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/4/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list flatten)) 2 | 3 | (print (flatten '(a (b (c (d (e f))))))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/4/output: -------------------------------------------------------------------------------- 1 | (a b c d e f) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/5/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list flatten)) 2 | 3 | (print (flatten '(a (b (c (d (e (f)))))))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/flatten/levels/5/output: -------------------------------------------------------------------------------- 1 | (a b c d e f) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/map/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote set lambda) (list map) (math +)) 2 | 3 | (set ++ (lambda (x) (+ 1 x))) 4 | 5 | (print (map ++ '())) 6 | (print (map ++ '(1))) 7 | (print (map ++ '(1 2))) 8 | (print (map ++ '(1 2 3))) 9 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/map/output: -------------------------------------------------------------------------------- 1 | nil 2 | (2) 3 | (2 3) 4 | (2 3 4) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/reduce/+/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) (list reduce) (math +)) 2 | 3 | (print (reduce + 0 '())) 4 | (print (reduce + 0 '(1))) 5 | (print (reduce + 0 '(1 2))) 6 | (print (reduce + 0 '(1 2 3))) 7 | 8 | (print (reduce + 10 '())) 9 | (print (reduce + 15 '(1))) 10 | (print (reduce + 20 '(1 2))) 11 | (print (reduce + 36 '(1 2 3))) 12 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/reduce/+/output: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 3 4 | 6 5 | 10 6 | 16 7 | 23 8 | 42 9 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/reduce/concatenate/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) (list reduce) (text concatenate)) 2 | 3 | (print (reduce concatenate "" '())) 4 | (print (reduce concatenate "" '("a"))) 5 | (print (reduce concatenate "" '("a" "b"))) 6 | (print (reduce concatenate "" '("a" "b" "c"))) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/reduce/concatenate/output: -------------------------------------------------------------------------------- 1 | "" 2 | "a" 3 | "ab" 4 | "abc" 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/rest/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote) (list rest)) 2 | 3 | (print (rest '("x"))) 4 | (print (rest '("x" "y"))) 5 | (print (rest '("x" "y" "z"))) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/list/rest/output: -------------------------------------------------------------------------------- 1 | nil 2 | ("y") 3 | ("y" "z") 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/0/input: -------------------------------------------------------------------------------- 1 | (import (lone begin print)) 2 | 3 | (print 4 | (begin)) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/0/output: -------------------------------------------------------------------------------- 1 | nil 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/1/input: -------------------------------------------------------------------------------- 1 | (import (lone begin print)) 2 | 3 | (print 4 | (begin 5 | (print 1))) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/1/output: -------------------------------------------------------------------------------- 1 | 1 2 | nil 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/2/input: -------------------------------------------------------------------------------- 1 | (import (lone begin print)) 2 | 3 | (print 4 | (begin 5 | (print 1) 6 | (print 2))) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/2/output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | nil 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/3/input: -------------------------------------------------------------------------------- 1 | (import (lone begin print)) 2 | 3 | (print 4 | (begin 5 | (print 1) 6 | (print 2) 7 | (print 3))) 8 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/3/output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | nil 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/return-value/input: -------------------------------------------------------------------------------- 1 | (import (lone begin print)) 2 | 3 | (print 4 | (begin 5 | "first" 6 | "middle" 7 | "last")) 8 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/begin/return-value/output: -------------------------------------------------------------------------------- 1 | "last" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print equal?)) 2 | 3 | (print (equal? "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/arity/1/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print equal?)) 2 | 3 | (print (equal? "x" "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/arity/2/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equal?)) 2 | 3 | (print (equal? '(x) '(x) '(x))) 4 | (print (equal? '(y) '(x) '(x))) 5 | (print (equal? '(x) '(y) '(x))) 6 | (print (equal? '(x) '(x) '(y))) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/arity/3/output: -------------------------------------------------------------------------------- 1 | true 2 | false 3 | false 4 | false 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/integers/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print equal?)) 2 | 3 | (print (equal? 10 20)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/integers/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/integers/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print equal?)) 2 | 3 | (print (equal? 10 10)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/integers/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/lists/different/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equal?)) 2 | 3 | (print (equal? '(1 2 3) '(4 5 6))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/lists/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/lists/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equal?)) 2 | 3 | (print (equal? '(1 2 3) '(1 2 3))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/lists/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/symbols/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote equal?)) 2 | 3 | (print (equal? 'x 'y)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/symbols/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/symbols/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote equal?)) 2 | 3 | (print (equal? 'x 'x)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/symbols/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/tables/different/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equal?)) 2 | 3 | (print (equal? { a "b" c "d" } { x "y" z "w" })) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/tables/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/tables/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equal?)) 2 | 3 | (print (equal? { a "b" c "d" } { a "b" c "d" })) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/tables/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/texts/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print equal?)) 2 | 3 | (print (equal? "x" "y")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/texts/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/texts/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote equal?)) 2 | 3 | (print (equal? "x" "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/texts/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/vectors/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print equal?)) 2 | 3 | (print (equal? [1 2 3] [4 5 6])) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/vectors/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/vectors/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print equal?)) 2 | 3 | (print (equal? [1 2 3] [1 2 3])) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equal?/vectors/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/arity/1/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? "x" "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/arity/2/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equivalent?)) 2 | 3 | (print (equivalent? "x" "x" "x")) 4 | (print (equivalent? "y" "x" "x")) 5 | (print (equivalent? "x" "y" "x")) 6 | (print (equivalent? "x" "x" "y")) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/arity/3/output: -------------------------------------------------------------------------------- 1 | true 2 | false 3 | false 4 | false 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/integers/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? 10 20)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/integers/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/integers/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? 10 10)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/integers/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/lists/different/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equivalent?)) 2 | 3 | (print (equivalent? '(1 2 3) '(4 5 6))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/lists/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/lists/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print equivalent?)) 2 | 3 | (print (equivalent? '(1 2 3) '(1 2 3))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/lists/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/symbols/different/input: -------------------------------------------------------------------------------- 1 | (import (lone quote equivalent? print)) 2 | 3 | (print (equivalent? 'x 'y)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/symbols/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/symbols/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote equivalent? print)) 2 | 3 | (print (equivalent? 'x 'x)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/symbols/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/tables/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? { a "b" c "d" } { x "y" z "w" })) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/tables/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/tables/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? { a "b" c "d" } { a "b" c "d" })) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/tables/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/texts/different/input: -------------------------------------------------------------------------------- 1 | (import (lone equivalent? print)) 2 | 3 | (print (equivalent? "x" "y")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/texts/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/texts/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote equivalent? print)) 2 | 3 | (print (equivalent? "x" "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/texts/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/vectors/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? [1 2 3] [4 5 6])) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/vectors/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/vectors/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print equivalent?)) 2 | 3 | (print (equivalent? [1 2 3] [1 2 3])) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/equivalent?/vectors/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print identical?)) 2 | 3 | (print (identical? "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/arity/1/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print identical?)) 2 | 3 | (print (identical? 'x 'x)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/arity/2/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print identical?)) 2 | 3 | (print (identical? 'x 'x 'x)) 4 | (print (identical? 'y 'x 'x)) 5 | (print (identical? 'x 'y 'x)) 6 | (print (identical? 'x 'x 'y)) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/arity/3/output: -------------------------------------------------------------------------------- 1 | true 2 | false 3 | false 4 | false 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/lists/different/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print identical?)) 2 | 3 | (print (identical? '(1 2 3) '(4 5 6))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/lists/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/lists/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print identical?)) 2 | 3 | (print (identical? '(1 2 3) '(1 2 3))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/lists/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/symbols/different/input: -------------------------------------------------------------------------------- 1 | (import (lone quote identical? print)) 2 | 3 | (print (identical? 'x 'y)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/symbols/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/symbols/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote identical? print)) 2 | 3 | (print (identical? 'x 'x)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/symbols/same/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/tables/different/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print identical?)) 2 | 3 | (print (identical? { a "b" c "d" } { x "y" z "w" })) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/tables/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/tables/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print identical?)) 2 | 3 | (print (identical? { a "b" c "d" } { a "b" c "d" })) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/tables/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/texts/different/input: -------------------------------------------------------------------------------- 1 | (import (lone identical? print)) 2 | 3 | (print (identical? "x" "y")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/texts/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/texts/same/input: -------------------------------------------------------------------------------- 1 | (import (lone quote identical? print)) 2 | 3 | (print (identical? "x" "x")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/texts/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/vectors/different/input: -------------------------------------------------------------------------------- 1 | (import (lone print identical?)) 2 | 3 | (print (identical? [1 2 3] [4 5 6])) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/vectors/different/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/vectors/same/input: -------------------------------------------------------------------------------- 1 | (import (lone print identical?)) 2 | 3 | (print (identical? [1 2 3] [1 2 3])) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/identical?/vectors/same/output: -------------------------------------------------------------------------------- 1 | false 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/conditional-evaluation/input: -------------------------------------------------------------------------------- 1 | (import (lone if print)) 2 | 3 | (print (if false (print "error") "expected")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/conditional-evaluation/output: -------------------------------------------------------------------------------- 1 | "expected" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/consequent+alternative/input: -------------------------------------------------------------------------------- 1 | (import (lone if print)) 2 | 3 | (print (if 0 "true" "false")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/consequent+alternative/output: -------------------------------------------------------------------------------- 1 | "true" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/consequent/input: -------------------------------------------------------------------------------- 1 | (import (lone if print)) 2 | 3 | (print (if 0 "true")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/consequent/output: -------------------------------------------------------------------------------- 1 | "true" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/set/input: -------------------------------------------------------------------------------- 1 | (import (lone if set print)) 2 | 3 | (if non-existent-returns-nil (set result-if-true "true") (set result-if-false "false")) 4 | (print result-if-true result-if-false) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/if/set/output: -------------------------------------------------------------------------------- 1 | nil 2 | "false" 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/!/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda! set print)) 2 | 3 | (set inspect (lambda! (x y z w) (print x y z w))) 4 | (inspect () unset (unset) 5 | (a 6 | (s 7 | (d 8 | (f))))) 9 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/!/output: -------------------------------------------------------------------------------- 1 | nil 2 | unset 3 | (unset) 4 | (a (s (d (f)))) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/arity/0/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print)) 2 | 3 | (print 4 | ((lambda () 10))) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/arity/0/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print)) 2 | 3 | (print 4 | ((lambda (x) x) 10)) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/arity/1/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print)) 2 | 3 | (print 4 | ((lambda (x y) y x y) 10 20)) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/arity/2/output: -------------------------------------------------------------------------------- 1 | 20 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/higher-order/argument/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda set print)) 2 | 3 | (set applicator (lambda (f x) (lambda () (f x)))) 4 | (set returner (lambda (x) x)) 5 | (set return-10 (applicator returner 10)) 6 | (print (return-10)) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/higher-order/argument/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/higher-order/return/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda set print)) 2 | 3 | (set returner 4 | (lambda (x) 5 | (lambda () x))) 6 | (set return-10 (returner 10)) 7 | (print (return-10)) 8 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/higher-order/return/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/no-code/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print)) 2 | 3 | (print ((lambda ()))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/no-code/output: -------------------------------------------------------------------------------- 1 | nil 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/returns-last-value/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print)) 2 | 3 | (print ((lambda () "first" "middle" "last"))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/returns-last-value/output: -------------------------------------------------------------------------------- 1 | "last" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/set/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda set print)) 2 | 3 | (set f (lambda (x) x)) 4 | (print (f 10)) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/set/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/side-effects/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print)) 2 | 3 | ((lambda (x) (print x)) 10) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/side-effects/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/variadic/0/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda set print)) 2 | 3 | (set variadic (lambda ((arguments)) (print arguments))) 4 | 5 | (variadic) 6 | (variadic 1) 7 | (variadic 1 2) 8 | (variadic 1 2 3) 9 | (variadic 1 2 3 4) 10 | (variadic 1 2 3 4 5) 11 | (variadic 1 2 3 4 5 6) 12 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/variadic/0/output: -------------------------------------------------------------------------------- 1 | nil 2 | (1) 3 | (1 2) 4 | (1 2 3) 5 | (1 2 3 4) 6 | (1 2 3 4 5) 7 | (1 2 3 4 5 6) 8 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/variadic/1/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda set print)) 2 | 3 | (set variadic 4 | (lambda (x (arguments)) 5 | (print x) 6 | (print arguments))) 7 | 8 | (variadic 1) 9 | (variadic 1 2) 10 | (variadic 1 2 3) 11 | (variadic 1 2 3 4) 12 | (variadic 1 2 3 4 5) 13 | (variadic 1 2 3 4 5 6) 14 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/variadic/1/output: -------------------------------------------------------------------------------- 1 | 1 2 | nil 3 | 1 4 | (2) 5 | 1 6 | (2 3) 7 | 1 8 | (2 3 4) 9 | 1 10 | (2 3 4 5) 11 | 1 12 | (2 3 4 5 6) 13 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/variadic/2/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda set print)) 2 | 3 | (set variadic 4 | (lambda (x y (arguments)) 5 | (print x) 6 | (print y) 7 | (print arguments))) 8 | 9 | (variadic 1 2) 10 | (variadic 1 2 3) 11 | (variadic 1 2 3 4) 12 | (variadic 1 2 3 4 5) 13 | (variadic 1 2 3 4 5 6) 14 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/lambda/variadic/2/output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | nil 4 | 1 5 | 2 6 | (3) 7 | 1 8 | 2 9 | (3 4) 10 | 1 11 | 2 12 | (3 4 5) 13 | 1 14 | 2 15 | (3 4 5 6) 16 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/multiple/input: -------------------------------------------------------------------------------- 1 | (import (lone let print)) 2 | 3 | (print (let (x 10 y 20 z 30) z)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/multiple/output: -------------------------------------------------------------------------------- 1 | 30 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/no-expressions/input: -------------------------------------------------------------------------------- 1 | (import (lone let print)) 2 | 3 | (print (let (x 10))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/no-expressions/output: -------------------------------------------------------------------------------- 1 | nil 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/recursive/input: -------------------------------------------------------------------------------- 1 | (import (lone let print)) 2 | 3 | (print (let (x 10 y x z y) z)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/recursive/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/simple/input: -------------------------------------------------------------------------------- 1 | (import (lone let print)) 2 | 3 | (print (let (x 10) x)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/let/simple/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quasiquote/plain/input: -------------------------------------------------------------------------------- 1 | (import (lone print quasiquote)) 2 | 3 | (print (quasiquote (x y z))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quasiquote/plain/output: -------------------------------------------------------------------------------- 1 | (x y z) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quasiquote/unquote*/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote quasiquote)) 2 | 3 | (print (quasiquote (1 2 3 (unquote* '(4 5 6)) 7 8 9))) 4 | (print (quasiquote (1 (unquote* 2) 3))) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quasiquote/unquote*/output: -------------------------------------------------------------------------------- 1 | (1 2 3 4 5 6 7 8 9) 2 | (1 2 3) 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quasiquote/unquote/input: -------------------------------------------------------------------------------- 1 | (import (lone print quote quasiquote) (math +)) 2 | 3 | (print (quasiquote (0 (unquote (+ 1 2)) 7))) 4 | (print (quasiquote (1 2 3 (unquote '(4 5 6)) 7 8 9))) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quasiquote/unquote/output: -------------------------------------------------------------------------------- 1 | (0 3 7) 2 | (1 2 3 (4 5 6) 7 8 9) 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quote/list/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print)) 2 | 3 | (print (quote (a b c))) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quote/list/output: -------------------------------------------------------------------------------- 1 | (a b c) 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quote/symbol/input: -------------------------------------------------------------------------------- 1 | (import (lone quote print)) 2 | 3 | (print (quote test)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/quote/symbol/output: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/set/chained/input: -------------------------------------------------------------------------------- 1 | (import (lone set print)) 2 | 3 | (set y (set x 10)) 4 | (print y) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/set/chained/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/set/simple/input: -------------------------------------------------------------------------------- 1 | (import (lone set print)) 2 | 3 | (set x 10) 4 | (print x) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/set/simple/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/set/without-value/input: -------------------------------------------------------------------------------- 1 | (import (lone set print)) 2 | 3 | (set should-be-nil) 4 | (print should-be-nil) 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/set/without-value/output: -------------------------------------------------------------------------------- 1 | nil 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/unless/false/input: -------------------------------------------------------------------------------- 1 | (import (lone unless print)) 2 | 3 | (print 4 | (unless () 5 | (print "unless false executes") 6 | "false")) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/unless/false/output: -------------------------------------------------------------------------------- 1 | "unless false executes" 2 | "false" 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/unless/true/input: -------------------------------------------------------------------------------- 1 | (import (lone unless print)) 2 | 3 | (print 4 | (unless 1 5 | (print "unless true does not execute") 6 | "true")) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/unless/true/output: -------------------------------------------------------------------------------- 1 | nil 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/when/false/input: -------------------------------------------------------------------------------- 1 | (import (lone when print)) 2 | 3 | (print 4 | (when () 5 | (print "when false does not execute") 6 | "false")) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/when/false/output: -------------------------------------------------------------------------------- 1 | nil 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/when/true/input: -------------------------------------------------------------------------------- 1 | (import (lone when print)) 2 | 3 | (print 4 | (when 1 5 | (print "when true executes") 6 | "true")) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/lone/when/true/output: -------------------------------------------------------------------------------- 1 | "when true executes" 2 | "true" 3 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math *)) 2 | 3 | (print (*)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/0/output: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math *)) 2 | 3 | (print (* 2)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/1/output: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math *)) 2 | 3 | (print (* 2 2)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/2/output: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math *)) 2 | 3 | (print (* 2 2 2)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/*/arity/3/output: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math +)) 2 | 3 | (print (+)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/0/output: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math +)) 2 | 3 | (print (+ 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/1/output: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math +)) 2 | 3 | (print (+ 1 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/2/output: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math +)) 2 | 3 | (print (+ 1 1 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/+/arity/3/output: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math -)) 2 | 3 | (print (-)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/0/output: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math -)) 2 | 3 | (print (- 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/1/output: -------------------------------------------------------------------------------- 1 | -1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math -)) 2 | 3 | (print (- 1 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/2/output: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math -)) 2 | 3 | (print (- 1 1 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/3/output: -------------------------------------------------------------------------------- 1 | -1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/4/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math -)) 2 | 3 | (print (- 1 1 1 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/arity/4/output: -------------------------------------------------------------------------------- 1 | -2 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/negation/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math -)) 2 | 3 | (print (- -1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/-/negation/output: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math//arity/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >)) 2 | 3 | (print (>)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>/arity/0/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >)) 2 | 3 | (print (> 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>/arity/1/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >)) 2 | 3 | (print (> 1 1)) 4 | (print (> 1 2)) 5 | (print (> 2 1)) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>/arity/2/output: -------------------------------------------------------------------------------- 1 | false 2 | false 3 | true 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >)) 2 | 3 | (print (> 1 1 1)) 4 | (print (> 1 1 2)) 5 | (print (> 1 2 2)) 6 | (print (> 2 1 1)) 7 | (print (> 1 2 3)) 8 | (print (> 1 3 2)) 9 | (print (> 2 1 3)) 10 | (print (> 2 3 2)) 11 | (print (> 3 1 2)) 12 | (print (> 3 2 1)) 13 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>/arity/3/output: -------------------------------------------------------------------------------- 1 | false 2 | false 3 | false 4 | false 5 | false 6 | false 7 | false 8 | false 9 | false 10 | true 11 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >=)) 2 | 3 | (print (>=)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/0/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >=)) 2 | 3 | (print (>= 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/1/output: -------------------------------------------------------------------------------- 1 | true 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >=)) 2 | 3 | (print (>= 1 1)) 4 | (print (>= 1 2)) 5 | (print (>= 2 1)) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/2/output: -------------------------------------------------------------------------------- 1 | true 2 | false 3 | true 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math >=)) 2 | 3 | (print (>= 1 1 1)) 4 | (print (>= 1 1 2)) 5 | (print (>= 1 2 2)) 6 | (print (>= 2 1 1)) 7 | (print (>= 1 2 3)) 8 | (print (>= 1 3 2)) 9 | (print (>= 2 1 3)) 10 | (print (>= 2 3 2)) 11 | (print (>= 3 1 2)) 12 | (print (>= 3 2 1)) 13 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/>=/arity/3/output: -------------------------------------------------------------------------------- 1 | true 2 | false 3 | false 4 | true 5 | false 6 | false 7 | false 8 | false 9 | false 10 | true 11 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math /)) 2 | 3 | (print (/ 2)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/1/output: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/2/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math /)) 2 | 3 | (print (/ 20 2)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/2/output: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/3/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math /)) 2 | 3 | (print (/ 20 2 2)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/3/output: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/4/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math /)) 2 | 3 | (print (/ 90 2 3 5)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/division/arity/4/output: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/-1/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math negative?)) 2 | 3 | (if (negative? -1) 4 | (print "negative") 5 | (print "not negative")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/-1/output: -------------------------------------------------------------------------------- 1 | "negative" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/-100/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math negative?)) 2 | 3 | (if (negative? -100) 4 | (print "negative") 5 | (print "not negative")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/-100/output: -------------------------------------------------------------------------------- 1 | "negative" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/0/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math negative?)) 2 | 3 | (if (negative? 0) 4 | (print "negative") 5 | (print "not negative")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/0/output: -------------------------------------------------------------------------------- 1 | "not negative" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/1/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math negative?)) 2 | 3 | (if (negative? 1) 4 | (print "negative") 5 | (print "not negative")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/1/output: -------------------------------------------------------------------------------- 1 | "not negative" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/100/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math negative?)) 2 | 3 | (if (negative? 100) 4 | (print "negative") 5 | (print "not negative")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/negative?/100/output: -------------------------------------------------------------------------------- 1 | "not negative" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/-1/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math positive?)) 2 | 3 | (if (positive? -1) 4 | (print "positive") 5 | (print "not positive")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/-1/output: -------------------------------------------------------------------------------- 1 | "not positive" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/-100/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math positive?)) 2 | 3 | (if (positive? -100) 4 | (print "positive") 5 | (print "not positive")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/-100/output: -------------------------------------------------------------------------------- 1 | "not positive" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/0/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math positive?)) 2 | 3 | (if (positive? 0) 4 | (print "positive") 5 | (print "not positive")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/0/output: -------------------------------------------------------------------------------- 1 | "not positive" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/1/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math positive?)) 2 | 3 | (if (positive? 1) 4 | (print "positive") 5 | (print "not positive")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/1/output: -------------------------------------------------------------------------------- 1 | "positive" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/100/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math positive?)) 2 | 3 | (if (positive? 100) 4 | (print "positive") 5 | (print "not positive")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/positive?/100/output: -------------------------------------------------------------------------------- 1 | "positive" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/-1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math sign)) 2 | 3 | (print (sign -1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/-1/output: -------------------------------------------------------------------------------- 1 | -1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/-100/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math sign)) 2 | 3 | (print (sign -100)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/-100/output: -------------------------------------------------------------------------------- 1 | -1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/0/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math sign)) 2 | 3 | (print (sign 0)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/0/output: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/1/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math sign)) 2 | 3 | (print (sign 1)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/1/output: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/100/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (math sign)) 2 | 3 | (print (sign 100)) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/sign/100/output: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/-1/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math zero?)) 2 | 3 | (if (zero? -1) 4 | (print "zero") 5 | (print "not zero")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/-1/output: -------------------------------------------------------------------------------- 1 | "not zero" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/-100/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math zero?)) 2 | 3 | (if (zero? -100) 4 | (print "zero") 5 | (print "not zero")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/-100/output: -------------------------------------------------------------------------------- 1 | "not zero" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/0/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math zero?)) 2 | 3 | (if (zero? 0) 4 | (print "zero") 5 | (print "not zero")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/0/output: -------------------------------------------------------------------------------- 1 | "zero" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/1/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math zero?)) 2 | 3 | (if (zero? 1) 4 | (print "zero") 5 | (print "not zero")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/1/output: -------------------------------------------------------------------------------- 1 | "not zero" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/100/input: -------------------------------------------------------------------------------- 1 | (import (lone if print) (math zero?)) 2 | 3 | (if (zero? 100) 4 | (print "zero") 5 | (print "not zero")) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/math/zero?/100/output: -------------------------------------------------------------------------------- 1 | "not zero" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/count/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (table count)) 2 | 3 | (print (count {})) 4 | (print (count { 'x 1 })) 5 | (print (count { 'x 1 'y 2 })) 6 | (print (count { 'x 1 'y 2 'z 3 })) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/count/output: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/delete/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) (table count get delete)) 2 | 3 | (set t { first 1 second 2 third 3 fourth 4 fifth 5 }) 4 | 5 | (print (count t)) 6 | 7 | (delete t 'second) 8 | (delete t 'fourth) 9 | 10 | (print (count t)) 11 | 12 | (print (get t 'first)) 13 | (print (get t 'second)) 14 | (print (get t 'third)) 15 | (print (get t 'fourth)) 16 | (print (get t 'fifth)) 17 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/delete/output: -------------------------------------------------------------------------------- 1 | 5 2 | 3 3 | 1 4 | nil 5 | 3 6 | nil 7 | 5 8 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/each/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print quote) (table each)) 2 | 3 | (each { 'x 10 'y 20 'z 30 } 4 | (lambda (key value) 5 | (print key) 6 | (print value))) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/each/output: -------------------------------------------------------------------------------- 1 | x 2 | 10 3 | y 4 | 20 5 | z 6 | 30 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/get/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) (table get)) 2 | 3 | (set t { first 1 second 2 third 3 }) 4 | (print (get t 'first)) 5 | (print (get t 'second)) 6 | (print (get t 'third)) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/get/output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/set/input: -------------------------------------------------------------------------------- 1 | (import (lone print set quote) prefixed (table get set)) 2 | 3 | (set t {}) 4 | 5 | (table.set t 'first 1) 6 | (table.set t 'second 2) 7 | (table.set t 'third 3) 8 | 9 | (print (table.get t 'first)) 10 | (print (table.get t 'second)) 11 | (print (table.get t 'third)) 12 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/table/set/output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/text/concatenate/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (text concatenate)) 2 | 3 | (print (concatenate "a" "b" "c" "d" "e")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/text/concatenate/output: -------------------------------------------------------------------------------- 1 | "abcde" 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/text/join/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (text join)) 2 | 3 | (print (join)) 4 | (print (join ", ")) 5 | (print (join ", " "a")) 6 | (print (join ", " "a" "b")) 7 | (print (join ", " "a" "b" "c")) 8 | (print (join ", " "a" "b" "c" "d")) 9 | (print (join ", " "a" "b" "c" "d" "e")) 10 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/text/join/output: -------------------------------------------------------------------------------- 1 | "" 2 | "" 3 | "a" 4 | "a, b" 5 | "a, b, c" 6 | "a, b, c, d" 7 | "a, b, c, d, e" 8 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/text/to-symbol/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (text to-symbol)) 2 | 3 | (print (to-symbol "test")) 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/text/to-symbol/output: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/count/input: -------------------------------------------------------------------------------- 1 | (import (lone print) (vector count)) 2 | 3 | (print (count [])) 4 | (print (count [1])) 5 | (print (count [1 2])) 6 | (print (count [1 2 3])) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/count/output: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 2 4 | 3 5 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/each/input: -------------------------------------------------------------------------------- 1 | (import (lone lambda print) (vector each)) 2 | 3 | (each [10 20 30] 4 | (lambda (value) 5 | (print value))) 6 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/each/output: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/get/input: -------------------------------------------------------------------------------- 1 | (import (lone print set) (vector get)) 2 | 3 | (set v [1 2 3]) 4 | (print (get v 0)) 5 | (print (get v 1)) 6 | (print (get v 2)) 7 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/get/output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/set/input: -------------------------------------------------------------------------------- 1 | (import (lone print set) prefixed (vector get set)) 2 | 3 | (set v []) 4 | 5 | (vector.set v 0 1) 6 | (vector.set v 1 2) 7 | (vector.set v 2 3) 8 | 9 | (print (vector.get v 0)) 10 | (print (vector.get v 1)) 11 | (print (vector.get v 2)) 12 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/set/output: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/slice/input: -------------------------------------------------------------------------------- 1 | (import (lone set print) (vector slice)) 2 | 3 | (set v [1 2 3 4 5 6 7 8 9 10]) 4 | 5 | (print (slice v 0)) 6 | (print (slice v 1)) 7 | (print (slice v 5)) 8 | (print (slice v 2 6)) 9 | -------------------------------------------------------------------------------- /test/lone/lisp/modules/intrinsic/vector/slice/output: -------------------------------------------------------------------------------- 1 | [ 1 2 3 4 5 6 7 8 9 10 ] 2 | [ 2 3 4 5 6 7 8 9 10 ] 3 | [ 6 7 8 9 10 ] 4 | [ 3 4 5 6 ] 5 | -------------------------------------------------------------------------------- /test/lone/lisp/programs/fibonacci/input: -------------------------------------------------------------------------------- 1 | (import (lone set lambda if print) (math + - <)) 2 | 3 | (set fibonacci (lambda (n) 4 | (if (< n 2) 5 | n 6 | (+ (fibonacci (- n 1)) 7 | (fibonacci (- n 2)))))) 8 | 9 | (print (fibonacci 10)) 10 | -------------------------------------------------------------------------------- /test/lone/lisp/programs/fibonacci/output: -------------------------------------------------------------------------------- 1 | 55 2 | -------------------------------------------------------------------------------- /test/lone/lisp/programs/hello-world/input: -------------------------------------------------------------------------------- 1 | (import (lone print)) 2 | 3 | (print "Hello, world!") 4 | -------------------------------------------------------------------------------- /test/lone/lisp/programs/hello-world/output: -------------------------------------------------------------------------------- 1 | "Hello, world!" 2 | -------------------------------------------------------------------------------- /test/lone/types/executable: -------------------------------------------------------------------------------- 1 | tests/lone/types 2 | -------------------------------------------------------------------------------- /test/tools/lone-embed/script: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | # SPDX-License-Identifier: AGPL-3.0-or-later 3 | 4 | exe="$(type -P lone)" 5 | patched="${exe}".patched 6 | segment="$(dirname ${0})"/segment 7 | 8 | cp -f "${exe}" "${patched}" 9 | code="${?}" 10 | 11 | if [[ "${code}" != 0 ]]; then 12 | printf 'Error copying lone executable for patching 13 | From: %s 14 | To: %s 15 | Code: %s 16 | ' "${exe}" "${patched}" "${code}" 17 | exit 1 18 | fi 19 | 20 | lone-embed "${patched}" "${segment}" 21 | code="${?}" 22 | 23 | if [[ "${code}" != 0 ]]; then 24 | printf 'Error patching lone segment into interpreter 25 | Segment: %s 26 | Interpreter: %s 27 | Code: %s 28 | ' "${segment}" "${patched}" "${code}" 29 | exit 2 30 | fi 31 | 32 | "${patched}" < /dev/null 33 | code="${?}" 34 | 35 | if [[ "${code}" != 42 ]]; then 36 | printf 'Interpreter did not correctly run the code in the embedded lone segment 37 | Segment: %s 38 | Interpreter: %s 39 | Code: %s 40 | ' "${segment}" "${patched}" "${code}" 41 | exit 3 42 | fi 43 | -------------------------------------------------------------------------------- /test/tools/lone-embed/segment: -------------------------------------------------------------------------------- 1 | { run (1 . 53) } 2 | (import (linux system-call)) 3 | 4 | (system-call "exit" 42) 5 | --------------------------------------------------------------------------------