a865d9e227
* 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
73 lines
1.7 KiB
C++
73 lines
1.7 KiB
C++
/***************************************************************************
|
|
|
|
main.c
|
|
|
|
gb.jit component
|
|
|
|
(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 1, 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 __MAIN_C
|
|
|
|
#include "gambas.h"
|
|
#include "main.h"
|
|
#include <llvm/Config/config.h>
|
|
|
|
extern "C" {
|
|
GB_INTERFACE GB EXPORT;
|
|
bool MAIN_debug = false;
|
|
}
|
|
|
|
void *GB_JIT_1[] EXPORT = {
|
|
(void *)1,
|
|
(void *)JIT_init,
|
|
(void *)JIT_compile_and_execute,
|
|
(void *)JIT_load_class,
|
|
NULL
|
|
};
|
|
|
|
|
|
GB_DESC *GB_CLASSES[] EXPORT =
|
|
{
|
|
NULL
|
|
};
|
|
|
|
|
|
extern "C" int EXPORT GB_INIT(void)
|
|
{
|
|
char *env = getenv("GB_JIT");
|
|
|
|
if (env && *env)
|
|
MAIN_debug = true;
|
|
|
|
if (LLVM_VERSION_MAJOR < 3 || (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR < 1))
|
|
fprintf(stderr, "gb.jit: warning: LLVM %d.%d is not supported.\n", LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR);
|
|
else
|
|
{
|
|
if (MAIN_debug)
|
|
fprintf(stderr, "gb.jit: using LLVM %d.%d.\n", LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
extern "C" void EXPORT GB_EXIT()
|
|
{
|
|
JIT_end();
|
|
}
|