Embedding K/Kona interpreter

168 views
Skip to first unread message

Greg S

unread,
Apr 28, 2017, 11:05:23 AM4/28/17
to Kona Developers
Hi,

Looking back at the list I see a little bit of effort has been made recently to make a Kona shared library with a definitive C API. I'm wondering if it's in a usable state yet. 

I'm having a bit of trouble getting my bearings in the code and haven't identified the main entry point to the interpreter yet which isn't a great start :/ Also, I tried doing "make kapi-test" and running it but I immediately got a seg fault as X(".pi") seems to be returning a 32-bit integer rather than a pointer. In fact there are a number of warnings like this that might be related:

src/kapi-test.c:72:4: warning: incompatible integer to pointer conversion assigning to 'K' (aka 'struct k0 *') from 'int' [-Wint-conversion]
        a = X(".z.y");
          ^ ~~~~~~~~~

How easy would it be to make use Kona as a simple embedded interpreter currently?

Bakul Shah

unread,
Apr 28, 2017, 3:37:50 PM4/28/17
to kona...@googlegroups.com
I added the original code for libkona about 4 years back but
haven't done anything with it since then.

kapi-test passes its tests on arm and x86 but not on x86_64.
Adding the below externs does the trick on both FreeBSD & OSX
(and should work on other platforms):

extern K X(S);
extern K show(K);
extern I attend();
extern void boilerplate();

I will try to submit a pull request with a few more fixes.
IIRC, last when I left it, there was still some issue about
the sfn() function so need to do some testing. Do let me know
if you discover any new issues.

Thanks
Bakul

Reply all
Reply to author
Forward
0 new messages