build: mes-snarf.scm: Resurrect.
* build-aux/mes-snarf.scm (snarf-functions): Strip whitespace from parameter list. (function->source): Use function-scm-name, add (function1_t). * build-aux/snarf.sh: Resurrect, combined dump to s, h, c. * include/mes/builtins.h:
This commit is contained in:
parent
94143959af
commit
9cbbb2fc78
|
@ -85,8 +85,7 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
||||||
(cut string-replace-string <> "_to_" "->")
|
(cut string-replace-string <> "_to_" "->")
|
||||||
(cut string-replace-suffix <> "_x" "!")
|
(cut string-replace-suffix <> "_x" "!")
|
||||||
(cut string-replace-suffix <> "_x_" "!-")
|
(cut string-replace-suffix <> "_x_" "!-")
|
||||||
(cut string-replace-suffix <> "_p" "?")
|
(cut string-replace-suffix <> "_p" "?"))
|
||||||
)
|
|
||||||
(function.name f))))
|
(function.name f))))
|
||||||
(if (not (string-suffix? "-" name)) name
|
(if (not (string-suffix? "-" name)) name
|
||||||
(string-append "core:" (string-drop-right name 1))))))
|
(string-append "core:" (string-drop-right name 1))))))
|
||||||
|
@ -117,7 +116,7 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
||||||
(if (string-null? (function.formals f)) 0
|
(if (string-null? (function.formals f)) 0
|
||||||
(length (string-split (function.formals f) #\,)))))
|
(length (string-split (function.formals f) #\,)))))
|
||||||
(n (if (eq? arity 'n) -1 arity)))
|
(n (if (eq? arity 'n) -1 arity)))
|
||||||
(format #f " a = init_builtin (builtin_type, ~s, ~a, &~a, a);\n" (function.name f) n (function.name f))))
|
(format #f " a = init_builtin (builtin_type, ~s, ~a, (function1_t) & ~a, a);\n" (function-scm-name f) n (function.name f))))
|
||||||
|
|
||||||
(define (disjoin . predicates)
|
(define (disjoin . predicates)
|
||||||
(lambda (. arguments)
|
(lambda (. arguments)
|
||||||
|
@ -151,8 +150,15 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
||||||
rest
|
rest
|
||||||
(receive (parameter-list annotation)
|
(receive (parameter-list annotation)
|
||||||
(apply values (string-split-string rest " ///"))
|
(apply values (string-split-string rest " ///"))
|
||||||
(let* ((parameters (string-drop parameter-list 1))
|
(let* ((parameters (string-trim-both parameter-list))
|
||||||
|
(parameters (string-drop parameters 1))
|
||||||
(parameters (string-drop-right parameters 1))
|
(parameters (string-drop-right parameters 1))
|
||||||
|
(annotation (if (string? annotation) (string-trim-both annotation)
|
||||||
|
annotation))
|
||||||
|
(annotation (if (and (string? annotation)
|
||||||
|
(string-suffix? "*/" annotation))
|
||||||
|
(string-drop-right annotation 2)
|
||||||
|
annotation))
|
||||||
(formals (if (string-null? parameters) '()
|
(formals (if (string-null? parameters) '()
|
||||||
(string-split parameters #\,)))
|
(string-split parameters #\,)))
|
||||||
(formals (map string-trim formals)))
|
(formals (map string-trim formals)))
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
. ${srcdest}build-aux/config.sh
|
srcdest=${srcdest-./}
|
||||||
|
. ${srcdest}config.sh
|
||||||
. ${srcdest}build-aux/trace.sh
|
. ${srcdest}build-aux/trace.sh
|
||||||
|
|
||||||
trace "SNARF$snarf builtins.c" ${srcdest}build-aux/mes-snarf.scm src/builtins.c
|
trace "SNARF$snarf builtins.c" ${srcdest}build-aux/mes-snarf.scm src/builtins.c
|
||||||
|
@ -35,3 +36,22 @@ trace "SNARF$snarf reader.c" ${srcdest}build-aux/mes-snarf.scm src/reader.c
|
||||||
trace "SNARF$snarf strings.c" ${srcdest}build-aux/mes-snarf.scm src/string.c
|
trace "SNARF$snarf strings.c" ${srcdest}build-aux/mes-snarf.scm src/string.c
|
||||||
trace "SNARF$snarf struct.c" ${srcdest}build-aux/mes-snarf.scm src/struct.c
|
trace "SNARF$snarf struct.c" ${srcdest}build-aux/mes-snarf.scm src/struct.c
|
||||||
trace "SNARF$snarf vector.c" ${srcdest}build-aux/mes-snarf.scm src/vector.c
|
trace "SNARF$snarf vector.c" ${srcdest}build-aux/mes-snarf.scm src/vector.c
|
||||||
|
|
||||||
|
for i in src/*.symbols.h; do
|
||||||
|
n=$(basename $i .symbols.h)
|
||||||
|
echo "/* src/$n.c */"
|
||||||
|
cat $i
|
||||||
|
mv $i $(basename $i .symbols.h).s
|
||||||
|
done > s
|
||||||
|
|
||||||
|
for i in src/*.h; do
|
||||||
|
n=$(basename $i .h)
|
||||||
|
echo "/* src/$n.c */"
|
||||||
|
cat $i
|
||||||
|
done > h
|
||||||
|
|
||||||
|
for i in src/*.i; do
|
||||||
|
n=$(basename $i .i)
|
||||||
|
echo " /* src/$n.c */"
|
||||||
|
cat $i
|
||||||
|
done > c
|
||||||
|
|
|
@ -21,15 +21,16 @@
|
||||||
#ifndef __MES_BUILTINS_H
|
#ifndef __MES_BUILTINS_H
|
||||||
#define __MES_BUILTINS_H
|
#define __MES_BUILTINS_H
|
||||||
|
|
||||||
/* src/builtins.mes */
|
/* src/builtins.c */
|
||||||
SCM make_builtin (SCM builtin_type, SCM name, SCM arity, SCM function);
|
SCM make_builtin (SCM builtin_type, SCM name, SCM arity, SCM function);
|
||||||
|
SCM builtin_name (SCM builtin);
|
||||||
SCM builtin_arity (SCM builtin);
|
SCM builtin_arity (SCM builtin);
|
||||||
SCM builtin_p (SCM x);
|
SCM builtin_p (SCM x);
|
||||||
SCM builtin_printer (SCM builtin);
|
SCM builtin_printer (SCM builtin);
|
||||||
/* src/gc.mes */
|
/* src/gc.c */
|
||||||
SCM gc_check ();
|
SCM gc_check ();
|
||||||
SCM gc ();
|
SCM gc ();
|
||||||
/* src/hash.mes */
|
/* src/hash.c */
|
||||||
SCM hashq (SCM x, SCM size);
|
SCM hashq (SCM x, SCM size);
|
||||||
SCM hash (SCM x, SCM size);
|
SCM hash (SCM x, SCM size);
|
||||||
SCM hashq_get_handle (SCM table, SCM key, SCM dflt);
|
SCM hashq_get_handle (SCM table, SCM key, SCM dflt);
|
||||||
|
@ -39,8 +40,7 @@ SCM hashq_set_x (SCM table, SCM key, SCM value);
|
||||||
SCM hash_set_x (SCM table, SCM key, SCM value);
|
SCM hash_set_x (SCM table, SCM key, SCM value);
|
||||||
SCM hash_table_printer (SCM table);
|
SCM hash_table_printer (SCM table);
|
||||||
SCM make_hash_table (SCM x);
|
SCM make_hash_table (SCM x);
|
||||||
/* src/lib.mes */
|
/* src/lib.c */
|
||||||
SCM procedure_name_ (SCM x);
|
|
||||||
SCM display_ (SCM x);
|
SCM display_ (SCM x);
|
||||||
SCM display_error_ (SCM x);
|
SCM display_error_ (SCM x);
|
||||||
SCM display_port_ (SCM x, SCM p);
|
SCM display_port_ (SCM x, SCM p);
|
||||||
|
@ -57,7 +57,7 @@ SCM memq (SCM x, SCM a);
|
||||||
SCM equal2_p (SCM a, SCM b);
|
SCM equal2_p (SCM a, SCM b);
|
||||||
SCM last_pair (SCM x);
|
SCM last_pair (SCM x);
|
||||||
SCM pair_p (SCM x);
|
SCM pair_p (SCM x);
|
||||||
/* src/math.mes */
|
/* src/math.c */
|
||||||
SCM greater_p (SCM x);
|
SCM greater_p (SCM x);
|
||||||
SCM less_p (SCM x);
|
SCM less_p (SCM x);
|
||||||
SCM is_p (SCM x);
|
SCM is_p (SCM x);
|
||||||
|
@ -71,12 +71,11 @@ SCM logior (SCM x);
|
||||||
SCM lognot (SCM x);
|
SCM lognot (SCM x);
|
||||||
SCM logxor (SCM x);
|
SCM logxor (SCM x);
|
||||||
SCM ash (SCM n, SCM count);
|
SCM ash (SCM n, SCM count);
|
||||||
/* src/mes.mes */
|
/* src/mes.c */
|
||||||
SCM make_cell_ (SCM type, SCM car, SCM cdr);
|
SCM make_cell_ (SCM type, SCM car, SCM cdr);
|
||||||
SCM type_ (SCM x);
|
SCM type_ (SCM x);
|
||||||
SCM car_ (SCM x);
|
SCM car_ (SCM x);
|
||||||
SCM cdr_ (SCM x);
|
SCM cdr_ (SCM x);
|
||||||
SCM arity_ (SCM x);
|
|
||||||
SCM cons (SCM x, SCM y);
|
SCM cons (SCM x, SCM y);
|
||||||
SCM car (SCM x);
|
SCM car (SCM x);
|
||||||
SCM cdr (SCM x);
|
SCM cdr (SCM x);
|
||||||
|
@ -91,7 +90,6 @@ SCM append2 (SCM x, SCM y);
|
||||||
SCM append_reverse (SCM x, SCM y);
|
SCM append_reverse (SCM x, SCM y);
|
||||||
SCM reverse_x_ (SCM x, SCM t);
|
SCM reverse_x_ (SCM x, SCM t);
|
||||||
SCM pairlis (SCM x, SCM y, SCM a);
|
SCM pairlis (SCM x, SCM y, SCM a);
|
||||||
SCM call (SCM fn, SCM x);
|
|
||||||
SCM assq (SCM x, SCM a);
|
SCM assq (SCM x, SCM a);
|
||||||
SCM assoc (SCM x, SCM a);
|
SCM assoc (SCM x, SCM a);
|
||||||
SCM set_car_x (SCM x, SCM e);
|
SCM set_car_x (SCM x, SCM e);
|
||||||
|
@ -100,13 +98,13 @@ SCM set_env_x (SCM x, SCM e, SCM a);
|
||||||
SCM macro_get_handle (SCM name);
|
SCM macro_get_handle (SCM name);
|
||||||
SCM add_formals (SCM formals, SCM x);
|
SCM add_formals (SCM formals, SCM x);
|
||||||
SCM eval_apply ();
|
SCM eval_apply ();
|
||||||
/* src/module.mes */
|
/* src/module.c */
|
||||||
SCM make_module_type ();
|
SCM make_module_type ();
|
||||||
SCM module_printer (SCM module);
|
SCM module_printer (SCM module);
|
||||||
SCM module_variable (SCM module, SCM name);
|
SCM module_variable (SCM module, SCM name);
|
||||||
SCM module_ref (SCM module, SCM name);
|
SCM module_ref (SCM module, SCM name);
|
||||||
SCM module_define_x (SCM module, SCM name, SCM value);
|
SCM module_define_x (SCM module, SCM name, SCM value);
|
||||||
/* src/posix.mes */
|
/* src/posix.c */
|
||||||
SCM peek_byte ();
|
SCM peek_byte ();
|
||||||
SCM read_byte ();
|
SCM read_byte ();
|
||||||
SCM unread_byte (SCM i);
|
SCM unread_byte (SCM i);
|
||||||
|
@ -127,7 +125,6 @@ SCM current_error_port ();
|
||||||
SCM open_output_file (SCM x);
|
SCM open_output_file (SCM x);
|
||||||
SCM set_current_output_port (SCM port);
|
SCM set_current_output_port (SCM port);
|
||||||
SCM set_current_error_port (SCM port);
|
SCM set_current_error_port (SCM port);
|
||||||
SCM force_output (SCM p);
|
|
||||||
SCM chmod_ (SCM file_name, SCM mode);
|
SCM chmod_ (SCM file_name, SCM mode);
|
||||||
SCM isatty_p (SCM port);
|
SCM isatty_p (SCM port);
|
||||||
SCM primitive_fork ();
|
SCM primitive_fork ();
|
||||||
|
@ -140,7 +137,7 @@ SCM getcwd_ ();
|
||||||
SCM dup_ (SCM port);
|
SCM dup_ (SCM port);
|
||||||
SCM dup2_ (SCM old, SCM new);
|
SCM dup2_ (SCM old, SCM new);
|
||||||
SCM delete_file (SCM file_name);
|
SCM delete_file (SCM file_name);
|
||||||
/* src/reader.mes */
|
/* src/reader.c */
|
||||||
SCM read_input_file_env_ (SCM e, SCM a);
|
SCM read_input_file_env_ (SCM e, SCM a);
|
||||||
SCM read_input_file_env (SCM a);
|
SCM read_input_file_env (SCM a);
|
||||||
SCM read_env (SCM a);
|
SCM read_env (SCM a);
|
||||||
|
@ -150,7 +147,7 @@ SCM reader_read_binary ();
|
||||||
SCM reader_read_octal ();
|
SCM reader_read_octal ();
|
||||||
SCM reader_read_hex ();
|
SCM reader_read_hex ();
|
||||||
SCM reader_read_string ();
|
SCM reader_read_string ();
|
||||||
/* src/strings.mes */
|
/* src/string.c */
|
||||||
SCM string_equal_p (SCM a, SCM b);
|
SCM string_equal_p (SCM a, SCM b);
|
||||||
SCM symbol_to_string (SCM symbol);
|
SCM symbol_to_string (SCM symbol);
|
||||||
SCM symbol_to_keyword (SCM symbol);
|
SCM symbol_to_keyword (SCM symbol);
|
||||||
|
@ -163,12 +160,12 @@ SCM read_string (SCM port);
|
||||||
SCM string_append (SCM x);
|
SCM string_append (SCM x);
|
||||||
SCM string_length (SCM string);
|
SCM string_length (SCM string);
|
||||||
SCM string_ref (SCM str, SCM k);
|
SCM string_ref (SCM str, SCM k);
|
||||||
/* src/struct.mes */
|
/* src/struct.c */
|
||||||
SCM make_struct (SCM type, SCM fields, SCM printer);
|
SCM make_struct (SCM type, SCM fields, SCM printer);
|
||||||
SCM struct_length (SCM x);
|
SCM struct_length (SCM x);
|
||||||
SCM struct_ref (SCM x, SCM i);
|
SCM struct_ref (SCM x, SCM i);
|
||||||
SCM struct_set_x (SCM x, SCM i, SCM e);
|
SCM struct_set_x (SCM x, SCM i, SCM e);
|
||||||
/* src/vector.mes */
|
/* src/vector.c */
|
||||||
SCM make_vector_ (SCM n);
|
SCM make_vector_ (SCM n);
|
||||||
SCM vector_length (SCM x);
|
SCM vector_length (SCM x);
|
||||||
SCM vector_ref (SCM x, SCM i);
|
SCM vector_ref (SCM x, SCM i);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
/* Symbols */
|
/* Symbols */
|
||||||
|
|
||||||
|
/* src/mes.c */
|
||||||
// CONSTANT cell_nil 1
|
// CONSTANT cell_nil 1
|
||||||
#define cell_nil 1
|
#define cell_nil 1
|
||||||
// CONSTANT cell_f 2
|
// CONSTANT cell_f 2
|
||||||
|
@ -45,7 +46,6 @@
|
||||||
#define cell_begin 10
|
#define cell_begin 10
|
||||||
// CONSTANT cell_call_with_current_continuation 11
|
// CONSTANT cell_call_with_current_continuation 11
|
||||||
#define cell_call_with_current_continuation 11
|
#define cell_call_with_current_continuation 11
|
||||||
|
|
||||||
// CONSTANT cell_vm_apply 12
|
// CONSTANT cell_vm_apply 12
|
||||||
#define cell_vm_apply 12
|
#define cell_vm_apply 12
|
||||||
// CONSTANT cell_vm_apply2 13
|
// CONSTANT cell_vm_apply2 13
|
||||||
|
@ -114,7 +114,6 @@
|
||||||
#define cell_vm_macro_expand_set_x 44
|
#define cell_vm_macro_expand_set_x 44
|
||||||
// CONSTANT cell_vm_return 45
|
// CONSTANT cell_vm_return 45
|
||||||
#define cell_vm_return 45
|
#define cell_vm_return 45
|
||||||
|
|
||||||
// CONSTANT cell_symbol_dot 46
|
// CONSTANT cell_symbol_dot 46
|
||||||
#define cell_symbol_dot 46
|
#define cell_symbol_dot 46
|
||||||
// CONSTANT cell_symbol_lambda 47
|
// CONSTANT cell_symbol_lambda 47
|
||||||
|
@ -129,7 +128,6 @@
|
||||||
#define cell_symbol_define 51
|
#define cell_symbol_define 51
|
||||||
// CONSTANT cell_symbol_define_macro 52
|
// CONSTANT cell_symbol_define_macro 52
|
||||||
#define cell_symbol_define_macro 52
|
#define cell_symbol_define_macro 52
|
||||||
|
|
||||||
// CONSTANT cell_symbol_quasiquote 53
|
// CONSTANT cell_symbol_quasiquote 53
|
||||||
#define cell_symbol_quasiquote 53
|
#define cell_symbol_quasiquote 53
|
||||||
// CONSTANT cell_symbol_unquote 54
|
// CONSTANT cell_symbol_unquote 54
|
||||||
|
@ -144,10 +142,8 @@
|
||||||
#define cell_symbol_unsyntax 58
|
#define cell_symbol_unsyntax 58
|
||||||
// CONSTANT cell_symbol_unsyntax_splicing 59
|
// CONSTANT cell_symbol_unsyntax_splicing 59
|
||||||
#define cell_symbol_unsyntax_splicing 59
|
#define cell_symbol_unsyntax_splicing 59
|
||||||
|
|
||||||
// CONSTANT cell_symbol_set_x 60
|
// CONSTANT cell_symbol_set_x 60
|
||||||
#define cell_symbol_set_x 60
|
#define cell_symbol_set_x 60
|
||||||
|
|
||||||
// CONSTANT cell_symbol_sc_expand 61
|
// CONSTANT cell_symbol_sc_expand 61
|
||||||
#define cell_symbol_sc_expand 61
|
#define cell_symbol_sc_expand 61
|
||||||
// CONSTANT cell_symbol_macro_expand 62
|
// CONSTANT cell_symbol_macro_expand 62
|
||||||
|
@ -156,7 +152,6 @@
|
||||||
#define cell_symbol_portable_macro_expand 63
|
#define cell_symbol_portable_macro_expand 63
|
||||||
// CONSTANT cell_symbol_sc_expander_alist 64
|
// CONSTANT cell_symbol_sc_expander_alist 64
|
||||||
#define cell_symbol_sc_expander_alist 64
|
#define cell_symbol_sc_expander_alist 64
|
||||||
|
|
||||||
// CONSTANT cell_symbol_call_with_values 65
|
// CONSTANT cell_symbol_call_with_values 65
|
||||||
#define cell_symbol_call_with_values 65
|
#define cell_symbol_call_with_values 65
|
||||||
// CONSTANT cell_symbol_call_with_current_continuation 66
|
// CONSTANT cell_symbol_call_with_current_continuation 66
|
||||||
|
@ -173,7 +168,6 @@
|
||||||
#define cell_symbol_write 71
|
#define cell_symbol_write 71
|
||||||
// CONSTANT cell_symbol_display 72
|
// CONSTANT cell_symbol_display 72
|
||||||
#define cell_symbol_display 72
|
#define cell_symbol_display 72
|
||||||
|
|
||||||
// CONSTANT cell_symbol_car 73
|
// CONSTANT cell_symbol_car 73
|
||||||
#define cell_symbol_car 73
|
#define cell_symbol_car 73
|
||||||
// CONSTANT cell_symbol_cdr 74
|
// CONSTANT cell_symbol_cdr 74
|
||||||
|
@ -192,7 +186,6 @@
|
||||||
#define cell_symbol_wrong_number_of_args 80
|
#define cell_symbol_wrong_number_of_args 80
|
||||||
// CONSTANT cell_symbol_wrong_type_arg 81
|
// CONSTANT cell_symbol_wrong_type_arg 81
|
||||||
#define cell_symbol_wrong_type_arg 81
|
#define cell_symbol_wrong_type_arg 81
|
||||||
|
|
||||||
// CONSTANT cell_symbol_buckets 82
|
// CONSTANT cell_symbol_buckets 82
|
||||||
#define cell_symbol_buckets 82
|
#define cell_symbol_buckets 82
|
||||||
// CONSTANT cell_symbol_builtin 83
|
// CONSTANT cell_symbol_builtin 83
|
||||||
|
@ -211,14 +204,12 @@
|
||||||
#define cell_symbol_size 89
|
#define cell_symbol_size 89
|
||||||
// CONSTANT cell_symbol_stack 90
|
// CONSTANT cell_symbol_stack 90
|
||||||
#define cell_symbol_stack 90
|
#define cell_symbol_stack 90
|
||||||
|
|
||||||
// CONSTANT cell_symbol_argv 91
|
// CONSTANT cell_symbol_argv 91
|
||||||
#define cell_symbol_argv 91
|
#define cell_symbol_argv 91
|
||||||
// CONSTANT cell_symbol_mes_datadir 92
|
// CONSTANT cell_symbol_mes_datadir 92
|
||||||
#define cell_symbol_mes_datadir 92
|
#define cell_symbol_mes_datadir 92
|
||||||
// CONSTANT cell_symbol_mes_version 93
|
// CONSTANT cell_symbol_mes_version 93
|
||||||
#define cell_symbol_mes_version 93
|
#define cell_symbol_mes_version 93
|
||||||
|
|
||||||
// CONSTANT cell_symbol_internal_time_units_per_second 94
|
// CONSTANT cell_symbol_internal_time_units_per_second 94
|
||||||
#define cell_symbol_internal_time_units_per_second 94
|
#define cell_symbol_internal_time_units_per_second 94
|
||||||
// CONSTANT cell_symbol_compiler 95
|
// CONSTANT cell_symbol_compiler 95
|
||||||
|
@ -229,7 +220,6 @@
|
||||||
#define cell_symbol_pmatch_car 97
|
#define cell_symbol_pmatch_car 97
|
||||||
// CONSTANT cell_symbol_pmatch_cdr 98
|
// CONSTANT cell_symbol_pmatch_cdr 98
|
||||||
#define cell_symbol_pmatch_cdr 98
|
#define cell_symbol_pmatch_cdr 98
|
||||||
|
|
||||||
// CONSTANT cell_type_bytes 99
|
// CONSTANT cell_type_bytes 99
|
||||||
#define cell_type_bytes 99
|
#define cell_type_bytes 99
|
||||||
// CONSTANT cell_type_char 100
|
// CONSTANT cell_type_char 100
|
||||||
|
@ -268,7 +258,6 @@
|
||||||
#define cell_type_vector 116
|
#define cell_type_vector 116
|
||||||
// CONSTANT cell_type_broken_heart 117
|
// CONSTANT cell_type_broken_heart 117
|
||||||
#define cell_type_broken_heart 117
|
#define cell_type_broken_heart 117
|
||||||
|
|
||||||
// CONSTANT cell_symbol_test 118
|
// CONSTANT cell_symbol_test 118
|
||||||
#define cell_symbol_test 118
|
#define cell_symbol_test 118
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue