Neko VM module globals and fields

38 views
Skip to first unread message

Milla Von Weiss

unread,
Nov 19, 2015, 5:36:08 AM11/19/15
to haxe...@googlegroups.com
I have looked into neko.mod.h:

typedef struct _neko_module {
    void *jit;
    unsigned int nglobals;
    unsigned int nfields;
    unsigned int codesize;
    value name;
    value *globals;
    value *fields;
    value loader;
    value exports;
    value dbgtbl;
    neko_debug *dbgidxs;
    int_val *code;
    value jit_gc;
} neko_module;

What are globals and fields pointers for?
Can I expose some of my object to a Neko VM module by injecting the objects to the arrays pointed by globals or fields pointers just before calling neko_vm_execute()?

Nicolas Cannasse

unread,
Nov 19, 2015, 8:13:07 AM11/19/15
to haxe...@googlegroups.com
Le 19/11/2015 11:36, Milla Von Weiss a écrit :
> I have looked into *neko.mod.h*:
>
> typedef struct _neko_module {
> void *jit;
> unsigned int nglobals;
> unsigned int nfields;
> unsigned int codesize;
> value name;
> value *globals;
> value *fields;
> value loader;
> value exports;
> value dbgtbl;
> neko_debug *dbgidxs;
> int_val *code;
> value jit_gc;
> } neko_module;
>
> What are *globals* and *fields* pointers for?
> Can I expose some of my object to a Neko VM module by injecting the
> objects to the arrays pointed by globals or fields pointers just before
> calling neko_vm_execute()?

You cannot dynamicaly add globals to a neko module, since their unique
id is allocated at compilation.

You can however do the following:

config = $loader.loadprim("mylib@get_config",0)();

This will load the FFI function which can return a complete object
containing anything you need.

Best,
Nicolas

Reply all
Reply to author
Forward
0 new messages