move builtins.h to root of src
This commit is contained in:
parent
b38e8c9aeb
commit
c53b4b2294
@ -23,23 +23,23 @@ src/
|
|||||||
md2.c 2-modifiers
|
md2.c 2-modifiers
|
||||||
sysfn.c •-definitions
|
sysfn.c •-definitions
|
||||||
internal.c •internal
|
internal.c •internal
|
||||||
opt/ files which aren't needed for every build configuration
|
utils/ utilities included as needed
|
||||||
gen/ generated files
|
|
||||||
jit/ simple JIT compiler for x86-64
|
|
||||||
utils/ utilities included as needed
|
|
||||||
builtins.h definitions of all built-in functions (excluding things defined by means of nfns.c)
|
|
||||||
file.h file system operations
|
file.h file system operations
|
||||||
hash.h hashing things
|
hash.h hashing things
|
||||||
mut.h copying multiple arrays into a single array
|
mut.h copying multiple arrays into a single array
|
||||||
talloc.h temporary allocations (described more below)
|
talloc.h temporary allocations (described more below)
|
||||||
utf.h UTF-8 things
|
utf.h UTF-8 things
|
||||||
core/ things included everywhere
|
opt/ files which aren't needed for every build configuration
|
||||||
core.h file imported everywhere that defines the base BQN model
|
gen/ generated files
|
||||||
nfns.c native functions for things that need to keep some state (e.g. •FLines needs to also hold the path its relative to)
|
jit/ simple JIT compiler for x86-64
|
||||||
load.c loads the self-hosted compiler, runtime and formatter, initializes CBQN globals
|
core/ things included everywhere
|
||||||
main.c main function & commandline stuff
|
builtins.h definitions of all built-in functions (excluding things defined by means of nfns.c)
|
||||||
ns.c namespaces
|
core.h file imported everywhere that defines the base BQN model
|
||||||
vm.c virtual machine interpreter
|
nfns.c native functions for things that need to keep some state (e.g. •FLines needs to also hold the path its relative to)
|
||||||
|
load.c loads the self-hosted compiler, runtime and formatter, initializes CBQN globals
|
||||||
|
main.c main function & commandline stuff
|
||||||
|
ns.c namespaces
|
||||||
|
vm.c virtual machine interpreter
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -125,13 +125,13 @@ All virtual method accesses require that the argument is heap-allocated.
|
|||||||
|
|
||||||
You can get a virtual function of a `B` instance with `TI(x, something)`. There's also `TIv(x, something)` for a pointer `x` instead. See `#define FOR_TI` in `src/h.h` for available functions.
|
You can get a virtual function of a `B` instance with `TI(x, something)`. There's also `TIv(x, something)` for a pointer `x` instead. See `#define FOR_TI` in `src/h.h` for available functions.
|
||||||
|
|
||||||
Call a BQN function with `c1(f, x)` or `c2(f, w, x)`. A specific builtin can be called by looking up the appropriate name in `src/utils/builtins.h` (and adding the `bi_` prefix).
|
Call a BQN function with `c1(f, x)` or `c2(f, w, x)`. A specific builtin can be called by looking up the appropriate name in `src/builtins.h` (and adding the `bi_` prefix).
|
||||||
|
|
||||||
Calling a modifier involves deriving it with `m1_d`/`m2_d`, using a regular `c1`/`c2`, and managing the refcounts of everything while at that.
|
Calling a modifier involves deriving it with `m1_d`/`m2_d`, using a regular `c1`/`c2`, and managing the refcounts of everything while at that.
|
||||||
|
|
||||||
## Builtin implementations
|
## Builtin implementations
|
||||||
|
|
||||||
The list of builtin functions is specified in the initial macros of `src/utils/builtins.h`, where `A`/`M`/`D` are used for ambivalent/monadic/dyadic. Once added, `bi_yourName` will be available, and the required of the following functions must be defined somewhere in the source:
|
The list of builtin functions is specified in the initial macros of `src/builtins.h`, where `A`/`M`/`D` are used for ambivalent/monadic/dyadic. Once added, `bi_yourName` will be available, and the required of the following functions must be defined somewhere in the source:
|
||||||
|
|
||||||
```C
|
```C
|
||||||
// functions:
|
// functions:
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../utils/each.h"
|
#include "../utils/each.h"
|
||||||
#include "../utils/builtins.h"
|
#include "../builtins.h"
|
||||||
#include "../nfns.h"
|
#include "../nfns.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../utils/mut.h"
|
#include "../utils/mut.h"
|
||||||
#include "../utils/builtins.h"
|
#include "../builtins.h"
|
||||||
|
|
||||||
B itype_c1(B t, B x) {
|
B itype_c1(B t, B x) {
|
||||||
B r;
|
B r;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../utils/each.h"
|
#include "../utils/each.h"
|
||||||
#include "../utils/file.h"
|
#include "../utils/file.h"
|
||||||
#include "../utils/builtins.h"
|
#include "../builtins.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../utils/builtins.h"
|
|
||||||
#include "../utils/talloc.h"
|
#include "../utils/talloc.h"
|
||||||
|
#include "../builtins.h"
|
||||||
|
|
||||||
B md2BI_uc1(B t, B o, B f, B g, B x) { return c(BMd2,t)->uc1(t, o, f, g, x); }
|
B md2BI_uc1(B t, B o, B f, B g, B x) { return c(BMd2,t)->uc1(t, o, f, g, x); }
|
||||||
B md2BI_ucw(B t, B o, B f, B g, B w, B x) { return c(BMd2,t)->ucw(t, o, f, g, w, x); }
|
B md2BI_ucw(B t, B o, B f, B g, B w, B x) { return c(BMd2,t)->ucw(t, o, f, g, w, x); }
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../utils/each.h"
|
#include "../utils/each.h"
|
||||||
#include "../utils/mut.h"
|
#include "../utils/mut.h"
|
||||||
#include "../utils/builtins.h"
|
|
||||||
#include "../utils/talloc.h"
|
#include "../utils/talloc.h"
|
||||||
|
#include "../builtins.h"
|
||||||
|
|
||||||
static Arr* take_impl(usz ria, B x) { // consumes x; returns v↑⥊𝕩 without set shape; v is non-negative
|
static Arr* take_impl(usz ria, B x) { // consumes x; returns v↑⥊𝕩 without set shape; v is non-negative
|
||||||
usz xia = a(x)->ia;
|
usz xia = a(x)->ia;
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
#include "../utils/hash.h"
|
#include "../utils/hash.h"
|
||||||
#include "../utils/file.h"
|
#include "../utils/file.h"
|
||||||
#include "../utils/wyhash.h"
|
#include "../utils/wyhash.h"
|
||||||
#include "../utils/builtins.h"
|
|
||||||
#include "../utils/mut.h"
|
#include "../utils/mut.h"
|
||||||
|
#include "../builtins.h"
|
||||||
#include "../ns.h"
|
#include "../ns.h"
|
||||||
#include "../nfns.h"
|
#include "../nfns.h"
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
#include "../utils/mut.h"
|
#include "../utils/mut.h"
|
||||||
#include "../utils/utf.h"
|
#include "../utils/utf.h"
|
||||||
#include "../utils/talloc.h"
|
#include "../utils/talloc.h"
|
||||||
#include "../utils/builtins.h"
|
#include "../builtins.h"
|
||||||
|
|
||||||
|
|
||||||
NORETURN NOINLINE void err(char* s) {
|
NORETURN NOINLINE void err(char* s) {
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "vm.h"
|
|
||||||
#include "ns.h"
|
|
||||||
#include "utils/mut.h"
|
#include "utils/mut.h"
|
||||||
#include "utils/file.h"
|
#include "utils/file.h"
|
||||||
#include "utils/builtins.h"
|
#include "vm.h"
|
||||||
|
#include "ns.h"
|
||||||
|
#include "builtins.h"
|
||||||
|
|
||||||
#define FOR_INIT(F) F(base) F(harr) F(mutF) F(fillarr) F(tyarr) F(hash) F(sfns) F(fns) F(arith) F(md1) F(md2) F(derv) F(comp) F(rtWrap) F(ns) F(nfn) F(sysfn) F(load) F(sysfnPost)
|
#define FOR_INIT(F) F(base) F(harr) F(mutF) F(fillarr) F(tyarr) F(hash) F(sfns) F(fns) F(arith) F(md1) F(md2) F(derv) F(comp) F(rtWrap) F(ns) F(nfn) F(sysfn) F(load) F(sysfnPost)
|
||||||
#define F(X) void X##_init(void);
|
#define F(X) void X##_init(void);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#ifdef RT_PERF
|
#ifdef RT_PERF
|
||||||
#include "utils/builtins.h"
|
#include "builtins.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RT_WRAP
|
#ifdef RT_WRAP
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user