gambas-source-code/main/gbx/gbx_jit.c
Benoît Minisini a865d9e227 [INTERPRETER]
* NEW: Support for variable number of arguments in extern functions.
* BUG: Fix use of static classes as extern function argument.

[COMPILER]
* NEW: Support for variable number of arguments in extern functions.

[GB.JIT]
* BUG: The GB_JIT environment variable has really no effect if it is 
  defined but a null string.


git-svn-id: svn://localhost/gambas/trunk@4796 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-06-01 00:18:38 +00:00

75 lines
1.9 KiB
C

/***************************************************************************
gbx_jit.c
(c) 2012 Emil Lenngren <emil.lenngren [at] gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
***************************************************************************/
#define __GBX_JIT_C
#include "gbx_jit.h"
#include "gbx_api.h"
#include "gbx_event.h"
JIT_INTERFACE JIT;
bool JIT_load()
{
static bool loaded = FALSE;
static bool available = TRUE;
COMPONENT *comp;
if (loaded)
return TRUE;
if (!available)
return FALSE;
TRY
{
comp = COMPONENT_create("gb.jit");
//comp->preload = TRUE; // Prevent from being unloaded before exit() is called
COMPONENT_load(comp);
LIBRARY_get_interface_by_name("gb.jit", JIT_INTERFACE_VERSION, &JIT);
JIT.Init((GB_JIT_INTERFACE *)(void *)GAMBAS_JitApi, &EXEC_current, &SP, &TEMP, &RET, &GAMBAS_StopEvent,
(char **)&EXEC_enum, &EXEC, &EXEC_unknown_name, &EVENT_Last, &ERROR_current, &ERROR_handler, &STRING_char_string[0]);
loaded = TRUE;
}
CATCH
{
char *env = getenv("GB_JIT");
available = FALSE;
if (env && *env)
ERROR_warning("JIT compiler not available");
}
END_TRY
return loaded;
}
void JIT_default_jit_function()
{
JIT.CompileAndExecute();
}