-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lone: extract system structure from interpreter
When I started lone I tried to force myself to keep things as simple as possible in order to maintain focus on the task at hand. As a result, I wrote code that was tightly coupled on purpose because I thought I'd get bogged down in library development if I didn't. Or worse, build system development. Hey, it's certainly happened before. I believe that approach was instrumental in conjuring up lone lisp into the realm of existence. I have created a freestanding interpreter that can successfully run programs. That's no small feat, no matter how simple and slow it is. Now comes the truly difficult part: making it useful for something other than running fibonacci calculations. For that, I need to continuously improve the system, the interpreter, the language, the modules and everything in-between. It's truly a lifetime of work. Before I start walking down that road, it is wise to finally pay back some of the mounting tech debt in this project. I'll begin by separating the lone lisp interpreter from the underlying lone system libraries. Lone was initially conceived as a freestanding lisp interpreter. As its complexity grew, a library of vital functions was implemented in order to support basic program operations such as memory allocation even in the absence of the standard C library. They were meant to be tightly integrated with the interpreter but their utility increased to the point they supported the development of tools such as lone-embed. The utility of the lone system is likely to increase even further as development of lone continues. My desire to use them to build general Linux software is also likely to increase. Decoupling the system functions from the interpreter is therefore desirable. So I am reorganizing the project in order to make the lone runtime usable without the lone interpreter. This commit marks the beginning of the lone system, a library for freestanding Linux development. The liblinux reborn, better than it ever was. May this help pave the way for amazing Linux free software.
- Loading branch information
1 parent
6a4fdbb
commit 935743f
Showing
123 changed files
with
5,131 additions
and
4,813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_LISP_DEFINITIONS_HEADER | ||
#define LONE_LISP_DEFINITIONS_HEADER | ||
|
||
#include <lone/definitions.h> | ||
|
||
#define LONE_LISP_DECIMAL_DIGITS_PER_INTEGER LONE_DECIMAL_DIGITS_PER_LONG | ||
|
||
#ifndef LONE_LISP_BUFFER_SIZE | ||
#define LONE_LISP_BUFFER_SIZE 4096 | ||
#endif | ||
|
||
#ifndef LONE_LISP_MEMORY_SIZE | ||
#define LONE_LISP_MEMORY_SIZE (1024 * 1024) | ||
#endif | ||
|
||
#ifndef LONE_LISP_HEAP_VALUE_COUNT | ||
#define LONE_LISP_HEAP_VALUE_COUNT 512 | ||
#endif | ||
|
||
#ifndef LONE_LISP_TABLE_LOAD_FACTOR | ||
#define LONE_LISP_TABLE_LOAD_FACTOR 0.7 | ||
#endif | ||
|
||
#ifndef LONE_LISP_TABLE_GROWTH_FACTOR | ||
#define LONE_LISP_TABLE_GROWTH_FACTOR 2 | ||
#endif | ||
|
||
#define LONE_LISP_PRIMITIVE(name) \ | ||
struct lone_lisp_value lone_lisp_primitive_ ## name \ | ||
( \ | ||
struct lone_lisp *lone, \ | ||
struct lone_lisp_value module, \ | ||
struct lone_lisp_value environment, \ | ||
struct lone_lisp_value arguments, \ | ||
struct lone_lisp_value closure \ | ||
) | ||
|
||
#endif /* LONE_LISP_DEFINITIONS_HEADER */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_LISP_GARBAGE_COLLECTOR_HEADER | ||
#define LONE_LISP_GARBAGE_COLLECTOR_HEADER | ||
|
||
#include <lone/lisp/types.h> | ||
|
||
void lone_lisp_garbage_collector(struct lone_lisp *lone); | ||
|
||
#endif /* LONE_LISP_GARBAGE_COLLECTOR_HEADER */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_LISP_HASH_HEADER | ||
#define LONE_LISP_HASH_HEADER | ||
|
||
#include <lone/lisp/types.h> | ||
|
||
size_t lone_lisp_hash(struct lone_lisp *lone, struct lone_lisp_value value); | ||
|
||
#endif /* LONE_LISP_HASH_HEADER */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_LISP_HEAP_HEADER | ||
#define LONE_LISP_HEAP_HEADER | ||
|
||
#include <lone/lisp/definitions.h> | ||
#include <lone/lisp/types.h> | ||
|
||
void lone_lisp_heap_initialize(struct lone_lisp *lone); | ||
struct lone_lisp_heap_value *lone_lisp_heap_allocate_value(struct lone_lisp *lone); | ||
void lone_lisp_deallocate_dead_heaps(struct lone_lisp *lone); | ||
|
||
#endif /* LONE_LISP_HEAP_HEADER */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_LISP_MODULE_HEADER | ||
#define LONE_LISP_MODULE_HEADER | ||
|
||
#include <lone/lisp/definitions.h> | ||
#include <lone/lisp/types.h> | ||
|
||
/* ╭───────────────────────────┨ LONE / MODULES ┠───────────────────────────╮ | ||
│ │ | ||
│ Module importing, exporting and loading operations. │ | ||
│ │ | ||
╰────────────────────────────────────────────────────────────────────────╯ */ | ||
|
||
struct lone_lisp_value lone_lisp_module_null(struct lone_lisp *lone); | ||
struct lone_lisp_value lone_lisp_module_for_name(struct lone_lisp *lone, struct lone_lisp_value name); | ||
struct lone_lisp_value lone_lisp_module_load(struct lone_lisp *lone, struct lone_lisp_value name); | ||
void lone_lisp_module_load_from_bytes(struct lone_lisp *lone, struct lone_lisp_value module, struct lone_bytes bytes); | ||
void lone_lisp_module_load_null_from_file_descriptor(struct lone_lisp *lone, int file_descriptor); | ||
void lone_lisp_module_load_null_from_standard_input(struct lone_lisp *lone); | ||
void lone_lisp_module_path_push(struct lone_lisp *lone, struct lone_lisp_value directory); | ||
void lone_lisp_module_path_push_c_string(struct lone_lisp *lone, char *directory); | ||
void lone_lisp_module_path_push_va_list(struct lone_lisp *lone, size_t count, va_list directories); | ||
void lone_lisp_module_path_push_all(struct lone_lisp *lone, size_t count, ...); | ||
|
||
void lone_lisp_module_export( | ||
struct lone_lisp *lone, | ||
struct lone_lisp_value module, | ||
struct lone_lisp_value symbol | ||
); | ||
|
||
void lone_lisp_module_set_and_export( | ||
struct lone_lisp *lone, | ||
struct lone_lisp_value module, | ||
struct lone_lisp_value symbol, | ||
struct lone_lisp_value value | ||
); | ||
|
||
LONE_LISP_PRIMITIVE(module_import); | ||
LONE_LISP_PRIMITIVE(module_export); | ||
|
||
#endif /* LONE_LISP_MODULE_HEADER */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_LISP_MODULES_EMBEDDED_HEADER | ||
#define LONE_LISP_MODULES_EMBEDDED_HEADER | ||
|
||
#include <lone/types.h> | ||
#include <lone/lisp/types.h> | ||
|
||
void lone_lisp_modules_embedded_load(struct lone_lisp *lone, lone_elf_segment *values); | ||
|
||
#endif /* LONE_LISP_MODULES_EMBEDDED_HEADER */ |
9 changes: 5 additions & 4 deletions
9
include/lone/modules/intrinsic.h → include/lone/lisp/modules/intrinsic.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_MODULES_INTRINSIC_HEADER | ||
#define LONE_MODULES_INTRINSIC_HEADER | ||
#ifndef LONE_LISP_MODULES_INTRINSIC_HEADER | ||
#define LONE_LISP_MODULES_INTRINSIC_HEADER | ||
|
||
#include <lone/types.h> | ||
#include <lone/lisp/types.h> | ||
|
||
/* ╭─────────────────────┨ LONE / MODULES / INTRINSIC ┠─────────────────────╮ | ||
│ │ | ||
│ Initialization for built-in modules with essential functionality. │ | ||
│ │ | ||
╰────────────────────────────────────────────────────────────────────────╯ */ | ||
|
||
void lone_modules_intrinsic_initialize( | ||
void lone_lisp_modules_intrinsic_initialize( | ||
struct lone_lisp *lone, | ||
int argument_count, | ||
char **argument_vector, | ||
char **environment, | ||
struct lone_auxiliary_vector *auxiliary_vector | ||
); | ||
|
||
#endif /* LONE_MODULES_INTRINSIC_HEADER */ | ||
#endif /* LONE_LISP_MODULES_INTRINSIC_HEADER */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_LISP_MODULES_INTRINSIC_BYTES_HEADER | ||
#define LONE_LISP_MODULES_INTRINSIC_BYTES_HEADER | ||
|
||
#include <lone/lisp/definitions.h> | ||
#include <lone/lisp/types.h> | ||
|
||
/* ╭────────────────────────────────────────────────────────────────────────╮ | ||
│ │ | ||
│ Bytes operations. │ | ||
│ │ | ||
╰────────────────────────────────────────────────────────────────────────╯ */ | ||
|
||
void lone_lisp_modules_intrinsic_bytes_initialize(struct lone_lisp *lone); | ||
|
||
LONE_LISP_PRIMITIVE(bytes_new); | ||
|
||
LONE_LISP_PRIMITIVE(bytes_read_u8); | ||
LONE_LISP_PRIMITIVE(bytes_read_s8); | ||
LONE_LISP_PRIMITIVE(bytes_read_u16); | ||
LONE_LISP_PRIMITIVE(bytes_read_s16); | ||
LONE_LISP_PRIMITIVE(bytes_read_u32); | ||
LONE_LISP_PRIMITIVE(bytes_read_s32); | ||
|
||
LONE_LISP_PRIMITIVE(bytes_write_u8); | ||
LONE_LISP_PRIMITIVE(bytes_write_s8); | ||
LONE_LISP_PRIMITIVE(bytes_write_u16); | ||
LONE_LISP_PRIMITIVE(bytes_write_s16); | ||
LONE_LISP_PRIMITIVE(bytes_write_u32); | ||
LONE_LISP_PRIMITIVE(bytes_write_s32); | ||
|
||
#endif /* LONE_LISP_MODULES_INTRINSIC_BYTES_HEADER */ |
15 changes: 8 additions & 7 deletions
15
include/lone/modules/intrinsic/linux.h → include/lone/lisp/modules/intrinsic/linux.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
/* SPDX-License-Identifier: AGPL-3.0-or-later */ | ||
|
||
#ifndef LONE_MODULES_INTRINSIC_LINUX_HEADER | ||
#define LONE_MODULES_INTRINSIC_LINUX_HEADER | ||
#ifndef LONE_LISP_MODULES_INTRINSIC_LINUX_HEADER | ||
#define LONE_LISP_MODULES_INTRINSIC_LINUX_HEADER | ||
|
||
#include <lone/definitions.h> | ||
#include <lone/types.h> | ||
#include <lone/lisp/definitions.h> | ||
#include <lone/lisp/types.h> | ||
|
||
/* ╭────────────────────────┨ LONE / MODULE / LINUX ┠───────────────────────╮ | ||
│ │ | ||
│ Linux system calls and process parameters. │ | ||
│ │ | ||
╰────────────────────────────────────────────────────────────────────────╯ */ | ||
|
||
void lone_modules_intrinsic_linux_initialize(struct lone_lisp *lone, int argc, char **argv, char **envp, struct lone_auxiliary_vector *auxv); | ||
void lone_lisp_modules_intrinsic_linux_initialize(struct lone_lisp *lone, | ||
int argc, char **argv, char **envp, struct lone_auxiliary_vector *auxv); | ||
|
||
LONE_PRIMITIVE(linux_system_call); | ||
LONE_LISP_PRIMITIVE(linux_system_call); | ||
|
||
#endif /* LONE_MODULES_INTRINSIC_LINUX_HEADER */ | ||
#endif /* LONE_LISP_MODULES_INTRINSIC_LINUX_HEADER */ |
Oops, something went wrong.