From d4cf195c8ad0338fef7ccb08d0767360378b24d2 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 19 Jan 2020 16:01:04 -0500 Subject: fixed foreign for release build --- README.html | 2 +- README.md | 2 +- foreign.c | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.html b/README.html index 2bf99bb..f00bf27 100644 --- a/README.html +++ b/README.html @@ -48,7 +48,7 @@ it is nearly as fast in theory.

Most of the source code for the toc compiler is licensed under the GNU General Public License, version 3. See LICENSE for more information.

-

toc is written in C, for speed and portability. It has no dependencies, other than the C runtime library.

+

toc is written in C, for speed and portability. It has no dependencies, other than the C runtime library. If you want to be able to call external C functions at compile time, however, you will need libffcall and libdl (so this is only currently supported on Unix-y systems).

Build system

diff --git a/README.md b/README.md index 22ca0cf..acc64ba 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ On other systems, you can just compile main.c with a C compiler. `toc` uses seve Most of the source code for the `toc` compiler is licensed under the GNU General Public License, version 3. See `LICENSE` for more information. -`toc` is written in C, for speed and portability. It has no dependencies, other than the C runtime library. +`toc` is written in C, for speed and portability. It has no dependencies, other than the C runtime library. If you want to be able to call external C functions at compile time, however, you will need `libffcall` and `libdl` (so this is only currently supported on Unix-y systems). #### Build system `toc` is set up as a unity build, meaning that there is only one translation unit. So, `main.c` `#include`s `toc.c`, which `#include`s all of `toc`'s files. diff --git a/foreign.c b/foreign.c index cad605c..8a1b7b6 100644 --- a/foreign.c +++ b/foreign.c @@ -165,6 +165,10 @@ static bool arg_list_add(av_alist *arg_list, Value *val, Type *type, Location wh case TYPE_PTR: av_ptr(*arg_list, void *, val->ptr); break; + case TYPE_FN: + warn_print(where, "Passing toc function pointer to foreign function. This will not work if the function expects a C-style function pointer."); + av_ptr(*arg_list, FnExpr *, val->fn); + break; case TYPE_BUILTIN: switch (type->builtin) { case BUILTIN_I8: @@ -261,8 +265,8 @@ static bool foreign_call(FnExpr *fn, Type *fn_type, Value *args, Location call_w return true; } #else -static bool foreign_call(FnExpr *fn, Type *fn_type, Value *args, Location call_where) { - (void)fn; (void)fn_type; (void)args; +static bool foreign_call(FnExpr *fn, Type *fn_type, Value *args, Location call_where, Value *ret) { + (void)fn; (void)fn_type; (void)args; (void)ret; err_print(call_where, "You have not compiled toc with compile time foreign function support."); return false; } -- cgit v1.2.3