mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 13:37:35 +02:00
Fixing static libs and immutable strings builds.
This commit is contained in:
parent
8120744f2a
commit
a7d6998a96
5 changed files with 15 additions and 10 deletions
13
eval.c
13
eval.c
|
@ -1065,8 +1065,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
||||||
sexp_library_entry_t *entry = sexp_find_static_library(sexp_string_data(file));
|
sexp_library_entry_t *entry = sexp_find_static_library(sexp_string_data(file));
|
||||||
if (! entry)
|
if (! entry)
|
||||||
return sexp_compile_error(ctx, "couldn't find builtin library", file);
|
return sexp_compile_error(ctx, "couldn't find builtin library", file);
|
||||||
|
return entry->init(ctx, NULL, 3, env, sexp_version, SEXP_ABI_IDENTIFIER);
|
||||||
return entry->init(ctx, NULL, 1, env);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define sexp_find_static_library(path) NULL
|
#define sexp_find_static_library(path) NULL
|
||||||
|
@ -1074,16 +1073,16 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
||||||
sexp_proc4 init;
|
sexp_init_proc init;
|
||||||
HINSTANCE handle = LoadLibraryA(sexp_string_data(file));
|
HINSTANCE handle = LoadLibraryA(sexp_string_data(file));
|
||||||
if(!handle)
|
if(!handle)
|
||||||
return sexp_compile_error(ctx, "couldn't load dynamic library", file);
|
return sexp_compile_error(ctx, "couldn't load dynamic library", file);
|
||||||
init = (sexp_proc4) GetProcAddress(handle, "sexp_init_library");
|
init = (sexp_init_proc) GetProcAddress(handle, "sexp_init_library");
|
||||||
if(!init) {
|
if(!init) {
|
||||||
FreeLibrary(handle);
|
FreeLibrary(handle);
|
||||||
return sexp_compile_error(ctx, "dynamic library has no sexp_init_library", file);
|
return sexp_compile_error(ctx, "dynamic library has no sexp_init_library", file);
|
||||||
}
|
}
|
||||||
return init(ctx, NULL, 3, env, (sexp)sexp_version, (sexp)SEXP_ABI_IDENTIFIER);
|
return init(ctx, NULL, 3, env, sexp_version, SEXP_ABI_IDENTIFIER);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static sexp sexp_make_dl (sexp ctx, sexp file, void* handle) {
|
static sexp sexp_make_dl (sexp ctx, sexp file, void* handle) {
|
||||||
|
@ -1093,7 +1092,7 @@ static sexp sexp_make_dl (sexp ctx, sexp file, void* handle) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
||||||
sexp_proc4 init;
|
sexp_init_proc init;
|
||||||
sexp_gc_var2(res, old_dl);
|
sexp_gc_var2(res, old_dl);
|
||||||
void *handle = dlopen(sexp_string_data(file), RTLD_LAZY);
|
void *handle = dlopen(sexp_string_data(file), RTLD_LAZY);
|
||||||
if (! handle)
|
if (! handle)
|
||||||
|
@ -1106,7 +1105,7 @@ static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
|
||||||
sexp_gc_preserve2(ctx, res, old_dl);
|
sexp_gc_preserve2(ctx, res, old_dl);
|
||||||
old_dl = sexp_context_dl(ctx);
|
old_dl = sexp_context_dl(ctx);
|
||||||
sexp_context_dl(ctx) = sexp_make_dl(ctx, file, handle);
|
sexp_context_dl(ctx) = sexp_make_dl(ctx, file, handle);
|
||||||
res = init(ctx, NULL, 3, env, (sexp)sexp_version, (sexp)SEXP_ABI_IDENTIFIER);
|
res = init(ctx, NULL, 3, env, sexp_version, SEXP_ABI_IDENTIFIER);
|
||||||
sexp_context_dl(ctx) = old_dl;
|
sexp_context_dl(ctx) = old_dl;
|
||||||
sexp_gc_release2(ctx);
|
sexp_gc_release2(ctx);
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -206,6 +206,7 @@ typedef sexp (*sexp_proc4) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp);
|
||||||
typedef sexp (*sexp_proc5) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp);
|
typedef sexp (*sexp_proc5) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp);
|
||||||
typedef sexp (*sexp_proc6) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp);
|
typedef sexp (*sexp_proc6) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp);
|
||||||
typedef sexp (*sexp_proc7) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp);
|
typedef sexp (*sexp_proc7) (sexp, sexp, sexp_sint_t, sexp, sexp, sexp, sexp, sexp, sexp);
|
||||||
|
typedef sexp (*sexp_init_proc)(sexp, sexp, sexp_sint_t, sexp, const char*, sexp_abi_identifier_t);
|
||||||
|
|
||||||
typedef struct sexp_free_list_t *sexp_free_list;
|
typedef struct sexp_free_list_t *sexp_free_list;
|
||||||
struct sexp_free_list_t {
|
struct sexp_free_list_t {
|
||||||
|
|
|
@ -188,7 +188,9 @@ _FN2(_I(SEXP_NUMBER), _I(SEXP_NUMBER), _I(SEXP_NUMBER), "expt", 0, sexp_expt_op)
|
||||||
#if SEXP_USE_UTF8_STRINGS
|
#if SEXP_USE_UTF8_STRINGS
|
||||||
_FN2(_I(SEXP_FIXNUM), _I(SEXP_STRING), _I(SEXP_FIXNUM), "string-index->offset", 0, sexp_string_index_to_offset),
|
_FN2(_I(SEXP_FIXNUM), _I(SEXP_STRING), _I(SEXP_FIXNUM), "string-index->offset", 0, sexp_string_index_to_offset),
|
||||||
_FN2(_I(SEXP_CHAR), _I(SEXP_STRING), _I(SEXP_FIXNUM), "string-ref", 0, sexp_string_utf8_index_ref),
|
_FN2(_I(SEXP_CHAR), _I(SEXP_STRING), _I(SEXP_FIXNUM), "string-ref", 0, sexp_string_utf8_index_ref),
|
||||||
|
#if SEXP_USE_MUTABLE_STRINGS
|
||||||
_FN3(SEXP_VOID, _I(SEXP_STRING), _I(SEXP_FIXNUM), _I(SEXP_CHAR), "string-set!", 0, sexp_string_utf8_index_set),
|
_FN3(SEXP_VOID, _I(SEXP_STRING), _I(SEXP_FIXNUM), _I(SEXP_CHAR), "string-set!", 0, sexp_string_utf8_index_set),
|
||||||
|
#endif
|
||||||
_FN3OPT(_I(SEXP_STRING), _I(SEXP_STRING), _I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "substring-cursor", SEXP_FALSE, sexp_substring_op),
|
_FN3OPT(_I(SEXP_STRING), _I(SEXP_STRING), _I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "substring-cursor", SEXP_FALSE, sexp_substring_op),
|
||||||
_FN3OPT(_I(SEXP_STRING), _I(SEXP_STRING), _I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "substring", SEXP_FALSE, sexp_utf8_substring_op),
|
_FN3OPT(_I(SEXP_STRING), _I(SEXP_STRING), _I(SEXP_FIXNUM), _I(SEXP_FIXNUM), "substring", SEXP_FALSE, sexp_utf8_substring_op),
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#! /usr/bin/env chibi-scheme
|
#! /usr/bin/env chibi-scheme
|
||||||
|
|
||||||
(import (chibi filesystem)
|
(import (chibi filesystem)
|
||||||
(chibi pathname))
|
(chibi pathname)
|
||||||
|
(only (meta) find-module))
|
||||||
|
|
||||||
(define c-libs '())
|
(define c-libs '())
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@
|
||||||
(mod-name (map (lambda (x) (or (string->number x) (string->symbol x)))
|
(mod-name (map (lambda (x) (or (string->number x) (string->symbol x)))
|
||||||
(path-split mod-path))))
|
(path-split mod-path))))
|
||||||
(cond
|
(cond
|
||||||
((eval `(find-module ',mod-name) *meta-env*)
|
((find-module mod-name)
|
||||||
=> (lambda (mod)
|
=> (lambda (mod)
|
||||||
(cond
|
(cond
|
||||||
((assq 'include-shared (vector-ref mod 2))
|
((assq 'include-shared (vector-ref mod 2))
|
||||||
|
@ -131,7 +132,7 @@
|
||||||
(newline)
|
(newline)
|
||||||
(display "typedef struct {\n")
|
(display "typedef struct {\n")
|
||||||
(display " const char *name;\n")
|
(display " const char *name;\n")
|
||||||
(display " sexp (*init)(sexp ctx, sexp self, sexp_sint_t n, sexp env, const char* version, sexp_abi_identifier_t abi);\n")
|
(display " sexp_init_proc init;\n")
|
||||||
(display "} sexp_library_entry_t;\n")
|
(display "} sexp_library_entry_t;\n")
|
||||||
(newline)
|
(newline)
|
||||||
(display "static sexp_library_entry_t sexp_static_libraries[] = {\n")
|
(display "static sexp_library_entry_t sexp_static_libraries[] = {\n")
|
||||||
|
|
2
vm.c
2
vm.c
|
@ -1215,6 +1215,7 @@ sexp sexp_apply (sexp ctx, sexp proc, sexp args) {
|
||||||
sexp_bytes_set(_ARG1, _ARG2, _ARG3);
|
sexp_bytes_set(_ARG1, _ARG2, _ARG3);
|
||||||
top-=3;
|
top-=3;
|
||||||
break;
|
break;
|
||||||
|
#if SEXP_USE_MUTABLE_STRINGS
|
||||||
case SEXP_OP_STRING_SET:
|
case SEXP_OP_STRING_SET:
|
||||||
if (! sexp_stringp(_ARG1))
|
if (! sexp_stringp(_ARG1))
|
||||||
sexp_raise("string-set!: not a string", sexp_list1(ctx, _ARG1));
|
sexp_raise("string-set!: not a string", sexp_list1(ctx, _ARG1));
|
||||||
|
@ -1235,6 +1236,7 @@ sexp sexp_apply (sexp ctx, sexp proc, sexp args) {
|
||||||
#endif
|
#endif
|
||||||
top-=3;
|
top-=3;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
#if SEXP_USE_UTF8_STRINGS
|
#if SEXP_USE_UTF8_STRINGS
|
||||||
case SEXP_OP_STRING_CURSOR_NEXT:
|
case SEXP_OP_STRING_CURSOR_NEXT:
|
||||||
if (! sexp_stringp(_ARG1))
|
if (! sexp_stringp(_ARG1))
|
||||||
|
|
Loading…
Add table
Reference in a new issue