gcc_jit_context (was Re: Python API (was Re: Build errors))

Basile Starynkevitch basile@starynkevitch.net
Tue Jan 1 00:00:00 GMT 2013


On Thu, 2013-10-24 at 14:20 -0400, David Malcolm wrote:
[...]
> So I've been thinking about reworking some of the existing C API to do
> this, eliminating the context ptr from them.  So e.g. 
> 
>   extern gcc_jit_rvalue *
>   gcc_jit_context_new_rvalue_from_int (gcc_jit_context *ctxt,
>                                        gcc_jit_type *type,
>                                        int value);
>   extern gcc_jit_rvalue *
>   gcc_jit_context_zero (gcc_jit_context *ctxt,
>                         gcc_jit_type *type);
> 
> might become:
> 
>   extern gcc_jit_rvalue *
>   gcc_jit_type_rvalue_from_int (gcc_jit_type *type,
>                                 int value);
>   extern gcc_jit_rvalue *
>   gcc_jit_type_zero (gcc_jit_type *type);


For readability reasons, I am not sure it is a good decision. Having one
argument passing the full context of the compilation everywhere is
probably more readable. (It might be preferable for performance reasons,
but you'll need to benchmark to be sure).

But it is really a matter of taste. At least if you don't pass a
gcc_jit_context explicitly document very loudly that it is getting
wrapped in gcc_jit_type, and perhaps publish a function retrieving the
context from a type, etc etc.

Cheers.


-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***




More information about the Jit mailing list