builds for all buildtypes

This commit is contained in:
Zander Thannhauser 2024-12-02 16:37:48 -06:00
parent 0c87f929f4
commit dcc4c1b65a
143 changed files with 599 additions and 140 deletions

2
.gitignore vendored
View file

@ -1,3 +1,3 @@
bin/
examples/sandbox.txt

View file

@ -4,6 +4,7 @@
-I .
-D _GNU_SOURCE
-D DEBUG_BUILD
-D DOTOUT_BUILD
-D VALGRIND_BUILD
@ -12,6 +13,19 @@
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-unused
-Wno-override-init

View file

@ -4,6 +4,7 @@
-I .
-D _GNU_SOURCE
-D DEBUG_BUILD
-D DOTOUT_BUILD
@ -11,6 +12,19 @@
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-unused
-Wno-override-init

View file

@ -4,6 +4,7 @@
-I .
-D _GNU_SOURCE
-D DEBUG_BUILD
-D VALGRIND_BUILD
@ -11,6 +12,19 @@
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-unused
-Wno-override-init

View file

@ -6,13 +6,25 @@
-D _GNU_SOURCE
-D DEBUG_BUILD
-D VALGRIND_BUILD
-Wall
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-unused
-Wno-override-init

View file

@ -1,12 +1,31 @@
-I .
-D _GNU_SOURCE
-D RELEASE_BUILD
-O3
-std=c17
-Wall
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-override-init
-Wno-unused-parameter

View file

@ -4,6 +4,7 @@
-I .
-D _GNU_SOURCE
-D TEST_BUILD
-D DOTOUT_BUILD
-D VALGRIND_BUILD
@ -12,6 +13,19 @@
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-unused
-Wno-override-init

View file

@ -4,6 +4,7 @@
-I .
-D _GNU_SOURCE
-D TEST_BUILD
-D DOTOUT_BUILD
@ -11,6 +12,19 @@
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-unused
-Wno-override-init

View file

@ -4,12 +4,26 @@
-I .
-D _GNU_SOURCE
-D TEST_BUILD
-Wall
-Werror
-Wfatal-errors
-Wstrict-prototypes
-Wextra
-Wdouble-promotion
-Wformat=2
-Wformat-truncation=2
-Wimplicit-fallthrough
-Wconversion
-Wshadow
-Wcast-align=strict
-Wformat-security
-Wnested-externs
-Wuninitialized
-Wmaybe-uninitialized
-Wno-comment
-Wno-unused
-Wno-override-init

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,7 @@
#if 0
#include <assert.h>
#include <debug.h>
#include "../defines/BUILTIN_PARAMETER_DECLARATION.h"
@ -68,3 +71,4 @@ struct value* builtin_let(
#endif

View file

@ -1,6 +1,8 @@
#if 0
#include "../defines/BUILTIN_PARAMETER_PROTOTYPE.h"
struct value* builtin_let(
BUILTIN_PARAMETER_PROTOTYPE);
#endif

View file

@ -1,4 +1,7 @@
struct value;
struct gc;
#define BUILTIN_PARAMETER_PROTOTYPE \
struct value*, \
struct value*, \

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

14
debug.h
View file

@ -81,26 +81,26 @@ extern int debug_depth;
{ \
printf("TODO hit at %s:%i!\n", __FILE__, __LINE__); \
\
pid_t child = fork(); \
pid_t __child = fork(); \
\
if (child < 0) \
if (__child < 0) \
{\
perror("fork");\
}\
else if (child)\
else if (__child)\
{\
int wstatus = 0;\
\
if (waitpid(child, &wstatus, 0) < 0)\
if (waitpid(__child, &wstatus, 0) < 0)\
perror("waitpid");\
else if (wstatus)\
fprintf(stderr, "child failed!");\
}\
else\
{\
char buffer[100]; \
snprintf(buffer, 100, "+%u", __LINE__); \
execlp("gedit", "gedit", __FILE__, buffer, NULL); \
char __buffer[100]; \
snprintf(__buffer, 100, "+%u", __LINE__); \
execlp("gedit", "gedit", __FILE__, __buffer, NULL); \
}\
\
exit(1); \

View file

@ -1,4 +1,8 @@
#include <assert.h>
#include <stdio.h>
#include <debug.h>
#include <string/struct.h>
@ -8,6 +12,7 @@
#include <value/struct.h>
#include <value/user_lambda/new.h>
#include <value/environment/new.h>
#include <value/environment/define.h>
#include <value/environment/lookup.h>
@ -112,15 +117,27 @@ struct value* evaluate(
gc_dec_external_refcount(gc, parameter_value);
}
if (false
|| parameter_names->kind == vk_list
|| parameter_expressions->kind == vk_list)
if (parameter_names->kind == vk_list)
{
assert(parameter_expressions->kind == vk_null);
retval = new_user_lambda_value(
/* garbage collection: */ gc,
/* environment: */ parameter_environment,
/* parameter names: */ parameter_names,
/* body: */ lambda->body);
}
else if (parameter_expressions->kind == vk_list)
{
assert(parameter_names->kind == vk_null);
TODO;
exit(1);
}
else
{
retval = evaluate(lambda->body, parameter_environment, gc);
}
gc_dec_external_refcount(gc, parameter_environment);

View file

@ -1,75 +1,114 @@
# comments
(def range
(lambda (x y)
(?: (< x y)
(cons x (range (+ x 1) y))
`())))
# # (define fib
# # (lambda (x)
# # (?: (> x 1)
# # (+ (fib (- x 1)) (fib (- x 2)))
# # 1)))
(define range0 (range 0))
(range 1 10)
(range0 10)
# (def map
# (lambda (func list)
# (if/else (null? list)
# list
# (cons (func (car list)) (map func (cdr list))))))
#
# # (fib 1)
# # (fib 2)
# # (fib 3)
# # (fib 4)
# # (fib 5)
(define! let1!
(lambda! (a b c)
((lambda (list! a) c) b)))
(let1! x 3 (+ x 2))
# (define! let2!
# (lambda! (a b c d e)
# ((lambda (list! a b) e) c d)))
# (map (lambda (x) (+ x 1)) (range 1 10))
#
# (let2! x y 3 5 (+ x y 2))
# (define! let3!
# (def filter
# (lambda (func list)
# (if/else (null? list)
# list
# (let1! a (filter func (cdr list))
# (if/else (func (car list))
# (cons (car list) a)
# a
# )
# )
# )
# )
# )
#
# (filter (lambda (x) (== (% x 2) 0)) (range0 20))
#
# (apply + 1 2 3)
#
#
# # comments
#
# # # (define fib
# # # (lambda (x)
# # # (?: (> x 1)
# # # (+ (fib (- x 1)) (fib (- x 2)))
# # # 1)))
# #
# # # (fib 1)
# # # (fib 2)
# # # (fib 3)
# # # (fib 4)
# # # (fib 5)
#
# (define! let1!
# (lambda! (a b c)
# (cons! (lambda a c) b)))
# ((lambda (list! a) c) b)))
#
# (let3! (x y z) (1 2 3) (+ x y z 2))
# (define Y
# (lambda (f)
# (f (lambda (x) ((Y f) x)))))
# (let1! x 3 (+ x 2))
#
# (define almost-factorial
# (lambda (f)
# (lambda (n)
# # (define! let2!
# # (lambda! (a b c d e)
# # ((lambda (list! a b) e) c d)))
# #
# # (let2! x y 3 5 (+ x y 2))
#
# # (define! let3!
# # (lambda! (a b c)
# # (cons! (lambda a c) b)))
# #
# # (let3! (x y z) (1 2 3) (+ x y z 2))
#
# # (define Y
# # (lambda (f)
# # (f (lambda (x) ((Y f) x)))))
# #
# # (define almost-factorial
# # (lambda (f)
# # (lambda (n)
# # (if/else (= n 0)
# # 1
# # (* n (f (- n 1)))))))
# #
# # (define factorial (Y almost-factorial))
# #
# # (factorial 1)
# # (factorial 2)
# # (factorial 3)
# # (factorial 4)
#
# # (let1! x 3 (+ x 2))
#
# # (define almost
# # (lambda (f n)
# # (if/else (= n 0)
# # 1
# # (* n (f f (- n 1))))))
#
# (define factorial
# (let1! almost
# (lambda (f n)
# (if/else (= n 0)
# 1
# (* n (f (- n 1)))))))
#
# (define factorial (Y almost-factorial))
# (* n (f f (- n 1)))))
# (lambda (x) (almost almost x))))
#
# (factorial 1)
# (factorial 2)
# (factorial 3)
# (factorial 4)
# (let1! x 3 (+ x 2))
# (define almost
# (lambda (f n)
# (if/else (= n 0)
# 1
# (* n (f f (- n 1))))))
(define factorial
(let1! almost
(lambda (f n)
(if/else (= n 0)
1
(* n (f f (- n 1)))))
(lambda (x) (almost almost x))))
(factorial 1)
(factorial 2)
(factorial 3)
(factorial 4)
#
#
#
#

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>
@ -153,6 +155,8 @@ struct value* gc_allocate_node(
/* element: */ white,
/* offset of link: */ offsetof(struct value, reaped));
this->bytes_currently_allocated -= sizeof(struct value);
#ifdef DOTOUT_BUILD
if (this->flags->dotout)
{
@ -202,8 +206,6 @@ struct value* gc_allocate_node(
/* link offset: */ offsetof(struct value, grey));
}
}
this->bytes_of_last_garbage_collection = this->bytes_currently_allocated;
}
#ifdef DOTOUT_BUILD
@ -213,6 +215,8 @@ struct value* gc_allocate_node(
}
#endif
}
this->bytes_of_last_garbage_collection = this->bytes_currently_allocated;
}
// check if the free-list is empty:

View file

@ -1,3 +1,5 @@
struct gc;
struct value* gc_allocate_node(
struct gc* this);

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,7 @@
struct gc;
struct value;
void gc_dec_external_refcount(
struct gc* gc,
struct value* value);

View file

@ -4,6 +4,6 @@
#ifdef RELEASE_BUILD
#define GARBAGE_COLLECTION_MINIMUM (10 * 1024 * 1024)
#else
#define GARBAGE_COLLECTION_MINIMUM (10 * 10)
#define GARBAGE_COLLECTION_MINIMUM (10 * 1024)
#endif

View file

@ -4,7 +4,7 @@
#ifdef RELEASE_BUILD
#define GARBAGE_COLLECTION_PROCESS_LIMIT (2 * 1024 * 1024)
#else
#define GARBAGE_COLLECTION_PROCESS_LIMIT (2 * 10)
#define GARBAGE_COLLECTION_PROCESS_LIMIT (2 * 1024)
#endif
// must be *at least* the run every

View file

@ -3,8 +3,8 @@
#ifdef RELEASE_BUILD
#define GARBAGE_COLLECTION_RUN_EVERY (1024 * 1024)
#define GARBAGE_COLLECTION_RUN_EVERY (10 * 1024 * 1024)
#else
#define GARBAGE_COLLECTION_RUN_EVERY (10)
#define GARBAGE_COLLECTION_RUN_EVERY (10 * 1024)
#endif

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
struct gc;
struct value* gc_inc_external_refcount(
struct gc* gc,
struct value* value);

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "struct.h"

View file

@ -1,4 +1,9 @@
#include <stddef.h>
struct linked_list;
struct value;
void linked_list_append(
struct linked_list* this,
struct value* value,

View file

@ -1,4 +1,9 @@
#include <stdlib.h>
struct linked_list;
struct link;
void linked_list_deep_clear(
struct linked_list* list,
size_t link_offset);

View file

@ -1,4 +1,6 @@
#include <stddef.h>
#include <debug.h>
#include "struct.h"

View file

@ -1,4 +1,8 @@
struct linked_list;
struct link;
void linked_list_init(
struct linked_list* list);

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <value/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "struct.h"

View file

@ -1,4 +1,10 @@
#include <stddef.h>
struct linked_list;
struct value;
void linked_list_remove(
struct linked_list* list,
struct value* element,

View file

@ -2,6 +2,8 @@
#ifndef STRUCT_LINKED_LIST
#define STRUCT_LINKED_LIST
#include <stdbool.h>
struct linked_list
{
struct value* head;

2
main.c
View file

@ -38,7 +38,7 @@
int main(
int argc, char* const* argv)
{
int i;
unsigned i;
ENTER;
struct cmdln_flags* flags = process_cmdln_flags(argc, argv);

View file

@ -1,4 +1,7 @@
#include <assert.h>
#include <stdlib.h>
#include <debug.h>
#include "srealloc.h"

View file

@ -1,4 +1,6 @@
#include <stddef.h>
void* srealloc(
void* oldptr,
size_t size);

View file

@ -1,4 +1,6 @@
#include <unistd.h>
#include <debug.h>
#include "struct.h"

View file

@ -1,4 +1,7 @@
#include <assert.h>
#include <fcntl.h>
#include <debug.h>
#include "../new.h"

View file

@ -1,4 +1,8 @@
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
#include <debug.h>
#include "struct.h"
@ -32,7 +36,7 @@ void file_istream_read(
else
{
this->i = 0;
this->n = read_retval;
this->n = (size_t) read_retval;
super->c = this->buffer[this->i++];

View file

@ -1,4 +1,7 @@
#include <stddef.h>
#include <stdint.h>
#include "../struct.h"
struct file_istream

View file

@ -1,4 +1,7 @@
#include <stdlib.h>
#include <assert.h>
#include <debug.h>
#include "inheritance.h"

View file

@ -1,3 +1,5 @@
struct istream;
void free_istream(
struct istream* this);

View file

@ -2,6 +2,8 @@
#ifndef STRUCT_ISTREAM_INHERITANCE
#define STRUCT_ISTREAM_INHERITANCE
struct istream;
struct istream_inheritance
{
void (*read)(

View file

@ -1,4 +1,7 @@
#include <stddef.h>
struct istream_inheritance;
struct istream* new_istream(
const struct istream_inheritance* inheritance,

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "inheritance.h"

View file

@ -1,4 +1,6 @@
#include <stdint.h>
struct istream_inheritance;
struct istream

View file

@ -1,4 +1,9 @@
#include <assert.h>
#include <inttypes.h>
#include <string.h>
#include <errno.h>
#include <debug.h>
#include <string/new.h>
@ -57,13 +62,13 @@ struct value* parse(
{
intmax_t val;
const char* s = tokenizer->rawtoken.data;
const char* s = (char*) tokenizer->rawtoken.data;
char *m;
errno = 0;
val = strtoul(s, &m, 0);
val = strtoimax(s, &m, 0);
if (errno || *m)
{

View file

@ -1,4 +1,6 @@
#include <stdlib.h>
#include <debug.h>
#include "../istream/free.h"

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <memory/srealloc.h>

View file

@ -1,4 +1,7 @@
#include <stddef.h>
#include <stdint.h>
#include "token.h"
struct tokenizer
@ -8,7 +11,7 @@ struct tokenizer
enum token token;
struct {
char* data;
uint8_t* data;
size_t n, cap;
} rawtoken;

View file

@ -1,4 +1,6 @@
struct string;
int compare_strings(
const struct string* a,
const struct string* b);

View file

@ -1,4 +1,6 @@
#include <stdlib.h>
#include <debug.h>
#include "struct.h"

View file

@ -1,3 +1,5 @@
struct string;
void free_string(
struct string* this);

View file

@ -1,4 +1,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include <debug.h>
#include <memory/smalloc.h>
@ -7,16 +13,16 @@
#include "new.h"
struct string* new_string(
const char* str,
const uint8_t* str,
size_t olen)
{
ENTER;
struct string* this = smalloc(sizeof(*this));
uint8_t* copy = (void*) strndup(str, olen);
uint8_t* copy = (uint8_t*) strndup((char*) str, olen);
unsigned len = strlen((void*) copy);
size_t len = strlen((void*) copy);
this->data = copy;
this->n = len;
@ -27,7 +33,7 @@ struct string* new_string(
}
struct string* new_string_from_format(
const char* fmt, ...)
const char* fmt __attribute((unused)), ...)
{
ENTER;
@ -51,7 +57,7 @@ struct string* new_string_from_vargs(
TODO;
}
struct string* new = new_string(buffer, ret);
struct string* new = new_string((uint8_t*) buffer, (size_t) ret);
free(buffer);

View file

@ -1,7 +1,11 @@
#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
struct string* new_string(
const char* str,
size_t len);
const uint8_t* str,
size_t olen);
struct string* new_string_from_format(
const char* fmt, ...);

View file

@ -1,4 +1,7 @@
#include <stddef.h>
#include <stdint.h>
struct string
{
uint8_t* data;

View file

@ -1,4 +1,7 @@
#include <stdlib.h>
#include <assert.h>
#include <debug.h>
#include <string/free.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <memory/smalloc.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <string/struct.h>

View file

@ -1,4 +1,8 @@
#include <stdio.h>
struct stringtree;
void stringtree_print(
const struct stringtree* this,
FILE* stream);

View file

@ -1,11 +1,13 @@
#include <assert.h>
#include <debug.h>
#include "compare.h"
int compare_boolean_values(
const struct value* a,
const struct value* b)
const struct value* a __attribute((unused)),
const struct value* b __attribute((unused)))
{
TODO;
}

View file

@ -1,4 +1,6 @@
struct value;
int compare_boolean_values(
const struct value* a,
const struct value* b);

View file

@ -4,9 +4,9 @@
#include "foreach_accessible_subvalue.h"
void boolean_value_foreach_accessible_subvalue(
const struct value* super,
const struct value* super __attribute((unused)),
void (*callback)(
struct value* subvalue))
struct value* subvalue) __attribute((unused)))
{
ENTER;

View file

@ -1,4 +1,6 @@
#include <stdbool.h>
struct value* new_boolean_value(
struct gc* gc,
bool literal);

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <stringtree/new.h>

View file

@ -9,7 +9,7 @@
#include "shallow_free.h"
void shallow_free_boolean_value(
struct value* super)
struct value* super __attribute((unused)))
{
ENTER;

View file

@ -1,11 +1,13 @@
#include <assert.h>
#include <debug.h>
#include "compare.h"
int compare_builtin_lambda_values(
const struct value* a,
const struct value* b)
const struct value* a __attribute((unused)),
const struct value* b __attribute((unused)))
{
TODO;
}

View file

@ -1,4 +1,6 @@
struct value;
int compare_builtin_lambda_values(
const struct value* a,
const struct value* b);

View file

@ -4,9 +4,9 @@
#include "foreach_accessible_subvalue.h"
void builtin_lambda_value_foreach_accessible_subvalue(
const struct value* super,
const struct value* super __attribute((unused)),
void (*callback)(
struct value* subvalue))
struct value* subvalue) __attribute((unused)))
{
ENTER;

View file

@ -1,6 +1,9 @@
#include <builtins/typedefs/builtin_funcptr_t.h>
struct gc;
struct string;
struct value* new_builtin_lambda_value(
struct gc* gc,
struct string* name,

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <stringtree/new.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <string/free.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include "inheritance.h"

View file

@ -1,4 +1,6 @@
#include <string.h>
#include <debug.h>
#include <defines/MAX_MACRO_DEPTH.h>
@ -49,18 +51,26 @@ void environment_value_add_builtins(
#define DECLARE_LAMBDA(name, funcptr) \
{ \
char buffer[100 + MAX_MACRO_DEPTH + 1]; \
char* m = stpcpy(buffer, name); \
uint8_t buffer[100 + MAX_MACRO_DEPTH + 1]; \
uint8_t* m = (uint8_t*) stpcpy((char*) buffer, name); \
for (unsigned i = 0; i < macro_level; i++) \
*m++ = '!'; \
*m = 0; \
struct string* string = new_string(buffer, -1); \
struct string* string = new_string(buffer, (unsigned) -1); \
struct value* value = new_builtin_lambda_value(this->gc, string, funcptr); \
environment_value_define(super, string, value); \
gc_dec_external_refcount(this->gc, value); \
free_string(string); \
}
// class checks
/* DECLARE_LAMBDA("null?", builtin_class_null);*/
/* DECLARE_LAMBDA("list?", builtin_class_list);*/
/* DECLARE_LAMBDA("int?", builtin_class_int);*/
/* DECLARE_LAMBDA("float?", builtin_class_float);*/
/* DECLARE_LAMBDA("string?", builtin_class_string);*/
// arthmietic:
DECLARE_LAMBDA("+", builtin_add);
DECLARE_LAMBDA("-", builtin_sub);
DECLARE_LAMBDA("*", builtin_mul);
@ -79,21 +89,30 @@ void environment_value_add_builtins(
DECLARE_LAMBDA("!=", builtin_not_equal_to);
DECLARE_LAMBDA("<>", builtin_not_equal_to);
// itertools:
/* DECLARE_LAMBDA("all", builtin_itertools_all);*/
/* DECLARE_LAMBDA("any", builtin_itertools_any);*/
/* DECLARE_LAMBDA("∃", builtin_itertools_any);*/
// logic:
/* DECLARE_LAMBDA("⊕", builtin_logical_xor);*/
/* DECLARE_LAMBDA("&&", builtin_logical_and);*/
/* DECLARE_LAMBDA("∀", builtin_logical_and);*/
/* DECLARE_LAMBDA("||", builtin_logical_or);*/
/* DECLARE_LAMBDA("∃", builtin_logical_or);*/
/* DECLARE_LAMBDA("!", builtin_logical_not);*/
/* DECLARE_LAMBDA("¬", builtin_logical_not);*/
// λ, lambda
DECLARE_LAMBDA("λ", builtin_lambda);
DECLARE_LAMBDA("lambda", builtin_lambda);
// define
DECLARE_LAMBDA("def", builtin_define);
DECLARE_LAMBDA("define", builtin_define);
// apply
// let
// DECLARE_LAMBDA("let", builtin_let);
// DECLARE_LAMBDA("letrec", builtin_letrec);
// letrec
// ?:, if/else
DECLARE_LAMBDA("?:", builtin_ifelse);
DECLARE_LAMBDA("if/else", builtin_ifelse);

View file

@ -1,11 +1,13 @@
#include <assert.h>
#include <debug.h>
#include "compare.h"
int compare_environment_values(
const struct value* a,
const struct value* b)
const struct value* a __attribute((unused)),
const struct value* b __attribute((unused)))
{
TODO;
}

View file

@ -1,4 +1,6 @@
struct value;
int compare_environment_values(
const struct value* a,
const struct value* b);

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <avl/avl.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <avl/avl.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <string/struct.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <avl/avl.h>

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <stringtree/new.h>
@ -16,7 +18,7 @@ struct stringtree* environment_value_prettyprint(
assert(super->kind == vk_envrionment);
const struct environment_value* this = &super->subclass.environment;
// const struct environment_value* this = &super->subclass.environment;
struct stringtree* tree = new_stringtree();

View file

@ -1,4 +1,6 @@
#include <assert.h>
#include <debug.h>
#include <avl/avl.h>

View file

@ -1,4 +1,6 @@
#include <stdlib.h>
#include <debug.h>
#include <string/free.h>

Some files were not shown because too many files have changed in this diff Show more