From a8dec12d9846d82a7d1d86aa1d20c69f9300d878 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Wed, 16 Apr 2008 10:31:17 +0000 Subject: Strip out the config/script parsing stuff, we don't need it. Original commit message from CVS: * configure.ac: * gst/goom/Makefile.am: * gst/goom/convolve_fx.c: * gst/goom/default_scripts.h: * gst/goom/goom.h: * gst/goom/goom_core.c: (choose_a_goom_line): * gst/goom/goom_plugin_info.h: * gst/goom/goomsl.c: * gst/goom/goomsl.h: * gst/goom/goomsl_hash.c: * gst/goom/goomsl_hash.h: * gst/goom/goomsl_heap.c: * gst/goom/goomsl_heap.h: * gst/goom/goomsl_private.h: * gst/goom/plugin_info.c: Strip out the config/script parsing stuff, we don't need it. Fixes #527999. --- gst/goom/Makefile.am | 43 +- gst/goom/convolve_fx.c | 3 - gst/goom/default_scripts.h | 6 - gst/goom/goom.h | 1 - gst/goom/goom_core.c | 1 - gst/goom/goom_plugin_info.h | 5 - gst/goom/goomsl.c | 1664 ------------------------------------------- gst/goom/goomsl.h | 34 - gst/goom/goomsl_hash.c | 153 ---- gst/goom/goomsl_hash.h | 40 -- gst/goom/goomsl_heap.c | 126 ---- gst/goom/goomsl_heap.h | 29 - gst/goom/goomsl_private.h | 251 ------- gst/goom/plugin_info.c | 5 - 14 files changed, 3 insertions(+), 2358 deletions(-) delete mode 100644 gst/goom/default_scripts.h delete mode 100644 gst/goom/goomsl.c delete mode 100644 gst/goom/goomsl.h delete mode 100644 gst/goom/goomsl_hash.c delete mode 100644 gst/goom/goomsl_hash.h delete mode 100644 gst/goom/goomsl_heap.c delete mode 100644 gst/goom/goomsl_heap.h delete mode 100644 gst/goom/goomsl_private.h (limited to 'gst/goom') diff --git a/gst/goom/Makefile.am b/gst/goom/Makefile.am index 83088780..4360d9e2 100644 --- a/gst/goom/Makefile.am +++ b/gst/goom/Makefile.am @@ -1,3 +1,4 @@ + plugin_LTLIBRARIES = libgstgoom.la PPC_FILES=ppc_zoom_ultimate.s ppc_drawings.s ppc_drawings.h ppc_zoom_ultimate.h @@ -23,16 +24,13 @@ libgstgoom_la_SOURCES = \ drawmethods.c drawmethods.h \ sound_tester.c sound_tester.h \ mathtools.c mathtools.h \ - goomsl_heap.c goomsl_heap.h \ - goomsl_hash.c goomsl_hash.h \ - goomsl.c goomsl_private.h \ lines.c lines.h ifs.c ifs.h surf3d.c surf3d.h \ tentacle3d.c tentacle3d.h v3d.c v3d.h \ convolve_fx.c flying_stars_fx.c \ goom_fx.h goom_visual_fx.h \ motif_goom1.h motif_goom2.h \ plugin_info.c goom_plugin_info.h \ - default_scripts.h goom_tools.c \ + goom_tools.c \ config_param.c filters.c goom_core.c graphic.c \ goom.h goom_typedefs.h goom_graphic.h \ goom_config_param.h goom_visual_fx.h goom_filters.h \ @@ -40,45 +38,10 @@ libgstgoom_la_SOURCES = \ $(ARCH_FILES) libgstgoom_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GOOM_FILTER_CFLAGS) $(LIBOIL_CFLAGS) $(ARCH_CFLAGS) -libgstgoom_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) $(LIBOIL_LIBS) libgstgoomconfigparse.la +libgstgoom_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(LIBM) $(LIBOIL_LIBS) libgstgoom_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) EXTRA_DIST = filters.c $(PPC_FILES) $(MMX_FILES) -goomsl_yacc.c goomsl_yacc.h: goomsl_yacc.y - $(BISON_PATH) -d $(srcdir)/goomsl_yacc.y -o goomsl_yacc.c && \ - mv goomsl_yacc.c goomsl_yacc_tmp.c && \ - echo '#ifdef HAVE_CONFIG_H' > goomsl_yacc_tmp2.c && \ - echo '#include ' >> goomsl_yacc_tmp2.c && \ - echo '#endif' >> goomsl_yacc_tmp2.c && \ - cat goomsl_yacc_tmp.c >> goomsl_yacc_tmp2.c && \ - rm goomsl_yacc_tmp.c && \ - mv goomsl_yacc_tmp2.c goomsl_yacc.c - -goomsl_lex.c: goomsl_lex.l goomsl_yacc.h - $(FLEX_PATH) -ogoomsl_lex.c $(srcdir)/goomsl_lex.l && \ - mv goomsl_lex.c goomsl_lex_tmp.c && \ - echo '#ifdef HAVE_CONFIG_H' > goomsl_lex_tmp2.c && \ - echo '#include ' >> goomsl_lex_tmp2.c && \ - echo '#endif' >> goomsl_lex_tmp2.c && \ - cat goomsl_lex_tmp.c >> goomsl_lex_tmp2.c && \ - rm goomsl_lex_tmp.c && \ - mv goomsl_lex_tmp2.c goomsl_lex.c - -# libgstgoomconfigparse.la is library linked into the goom plugin -noinst_LTLIBRARIES = libgstgoomconfigparse.la - -# uncomment these lines to dist the generated sources -#BUILT_SOURCES = goomsl_yacc.h goomsl_yacc.c goomsl_lex.c -#libgstgoomconfigparse_la_SOURCES = goomsl_lex.c goomsl_yacc.c goomsl_yacc.h -#libgstgoomconfigparse_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GOOM_FILTER_CFLAGS) $(LIBOIL_CFLAGS) $(ARCH_CFLAGS) - -# uncomment these lines to _NOT_ dist the generated sources -nodist_libgstgoomconfigparse_la_SOURCES = goomsl_lex.c goomsl_yacc.c -libgstgoomconfigparse_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GOOM_FILTER_CFLAGS) $(LIBOIL_CFLAGS) $(ARCH_CFLAGS) -CLEANFILES=goomsl_yacc.c goomsl_lex.c goomsl_yacc.h - -EXTRA_DIST += goomsl_yacc.y goomsl_lex.l - .NOTPARALLEL: diff --git a/gst/goom/convolve_fx.c b/gst/goom/convolve_fx.c index 8128c650..0e4666dd 100644 --- a/gst/goom/convolve_fx.c +++ b/gst/goom/convolve_fx.c @@ -1,6 +1,5 @@ #include "goom_fx.h" #include "goom_plugin_info.h" -#include "goomsl.h" #include "goom_config.h" #include #include @@ -29,8 +28,6 @@ typedef struct _CONV_DATA PluginParam factor_p; PluginParameters params; - GoomSL *script; - /* rotozoom */ int theta; float ftheta; diff --git a/gst/goom/default_scripts.h b/gst/goom/default_scripts.h deleted file mode 100644 index 5984d705..00000000 --- a/gst/goom/default_scripts.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _DEFAULT_SCRIPTS_H -#define _DEFAULT_SCRIPTS_H - -#define GOOM_MAIN_SCRIPT "" - -#endif diff --git a/gst/goom/goom.h b/gst/goom/goom.h index 88f82f23..35937bfd 100644 --- a/gst/goom/goom.h +++ b/gst/goom/goom.h @@ -3,7 +3,6 @@ #include "goom_config.h" #include "goom_plugin_info.h" -#include "goomsl.h" #define NB_FX 10 diff --git a/gst/goom/goom_core.c b/gst/goom/goom_core.c index 65b0160b..5b222ab9 100644 --- a/gst/goom/goom_core.c +++ b/gst/goom/goom_core.c @@ -24,7 +24,6 @@ #include "sound_tester.h" #include "goom_plugin_info.h" #include "goom_fx.h" -#include "goomsl.h" /* #define VERBOSE */ diff --git a/gst/goom/goom_plugin_info.h b/gst/goom/goom_plugin_info.h index 3d47ef58..30c3d102 100644 --- a/gst/goom/goom_plugin_info.h +++ b/gst/goom/goom_plugin_info.h @@ -10,7 +10,6 @@ #include "goom_visual_fx.h" #include "goom_filters.h" #include "goom_tools.h" -#include "goomsl.h" typedef struct { char drawIFS; @@ -153,10 +152,6 @@ struct _PLUGIN_INFO { } methods; GoomRandom *gRandom; - - GoomSL *scanner; - GoomSL *main_scanner; - const char *main_script_str; }; void plugin_info_init(PluginInfo *p, int nbVisual); diff --git a/gst/goom/goomsl.c b/gst/goom/goomsl.c deleted file mode 100644 index 6f407754..00000000 --- a/gst/goom/goomsl.c +++ /dev/null @@ -1,1664 +0,0 @@ -#include -#include -#include -#include -#include -#include "goomsl.h" -#include "goomsl_private.h" -#include "goomsl_yacc.h" - -/*#define TRACE_SCRIPT*/ - - /* {{{ definition of the instructions number */ -#define INSTR_SETI_VAR_INTEGER 1 -#define INSTR_SETI_VAR_VAR 2 -#define INSTR_SETF_VAR_FLOAT 3 -#define INSTR_SETF_VAR_VAR 4 -#define INSTR_NOP 5 -/* #define INSTR_JUMP 6 */ -#define INSTR_SETP_VAR_PTR 7 -#define INSTR_SETP_VAR_VAR 8 -#define INSTR_SUBI_VAR_INTEGER 9 -#define INSTR_SUBI_VAR_VAR 10 -#define INSTR_SUBF_VAR_FLOAT 11 -#define INSTR_SUBF_VAR_VAR 12 -#define INSTR_ISLOWERF_VAR_VAR 13 -#define INSTR_ISLOWERF_VAR_FLOAT 14 -#define INSTR_ISLOWERI_VAR_VAR 15 -#define INSTR_ISLOWERI_VAR_INTEGER 16 -#define INSTR_ADDI_VAR_INTEGER 17 -#define INSTR_ADDI_VAR_VAR 18 -#define INSTR_ADDF_VAR_FLOAT 19 -#define INSTR_ADDF_VAR_VAR 20 -#define INSTR_MULI_VAR_INTEGER 21 -#define INSTR_MULI_VAR_VAR 22 -#define INSTR_MULF_VAR_FLOAT 23 -#define INSTR_MULF_VAR_VAR 24 -#define INSTR_DIVI_VAR_INTEGER 25 -#define INSTR_DIVI_VAR_VAR 26 -#define INSTR_DIVF_VAR_FLOAT 27 -#define INSTR_DIVF_VAR_VAR 28 -/* #define INSTR_JZERO 29 */ -#define INSTR_ISEQUALP_VAR_VAR 30 -#define INSTR_ISEQUALP_VAR_PTR 31 -#define INSTR_ISEQUALI_VAR_VAR 32 -#define INSTR_ISEQUALI_VAR_INTEGER 33 -#define INSTR_ISEQUALF_VAR_VAR 34 -#define INSTR_ISEQUALF_VAR_FLOAT 35 -/* #define INSTR_CALL 36 */ -/* #define INSTR_RET 37 */ -/* #define INSTR_EXT_CALL 38 */ -#define INSTR_NOT_VAR 39 -/* #define INSTR_JNZERO 40 */ -#define INSTR_SETS_VAR_VAR 41 -#define INSTR_ISEQUALS_VAR_VAR 42 -#define INSTR_ADDS_VAR_VAR 43 -#define INSTR_SUBS_VAR_VAR 44 -#define INSTR_MULS_VAR_VAR 45 -#define INSTR_DIVS_VAR_VAR 46 - - /* }}} */ -/* {{{ definition of the validation error types */ -static const char *VALIDATE_OK = "ok"; - -#define VALIDATE_ERROR "error while validating " -#define VALIDATE_TODO "todo" -#define VALIDATE_SYNTHAX_ERROR "synthax error" -#define VALIDATE_NO_SUCH_INT "no such integer variable" -#define VALIDATE_NO_SUCH_VAR "no such variable" -#define VALIDATE_NO_SUCH_DEST_VAR "no such destination variable" -#define VALIDATE_NO_SUCH_SRC_VAR "no such src variable" -/* }}} */ - - /***********************************/ - /* PROTOTYPE OF INTERNAL FUNCTIONS */ -/***********************************/ - -/* {{{ */ -static void gsl_instr_free (Instruction * _this); -static const char *gsl_instr_validate (Instruction * _this); -static void gsl_instr_display (Instruction * _this); - -static InstructionFlow *iflow_new (void); -static void iflow_add_instr (InstructionFlow * _this, Instruction * instr); -static void iflow_clean (InstructionFlow * _this); -static void iflow_free (InstructionFlow * _this); -static void iflow_execute (FastInstructionFlow * _this, GoomSL * gsl); - -/* }}} */ - - /************************************/ - /* DEFINITION OF INTERNAL FUNCTIONS */ -/************************************/ - -void -iflow_free (InstructionFlow * _this) -{ /* {{{ */ - goom_hash_free (_this->labels); - free (_this); /*TODO: finir cette fonction */ -} /* }}} */ - -void -iflow_clean (InstructionFlow * _this) -{ /* {{{ */ - /* TODO: clean chaque instruction du flot */ - _this->number = 0; - goom_hash_free (_this->labels); - _this->labels = goom_hash_new (); -} /* }}} */ - -InstructionFlow * -iflow_new (void) -{ /* {{{ */ - InstructionFlow *_this = - (InstructionFlow *) malloc (sizeof (InstructionFlow)); - _this->number = 0; - _this->tabsize = 6; - _this->instr = - (Instruction **) malloc (_this->tabsize * sizeof (Instruction *)); - _this->labels = goom_hash_new (); - - return _this; -} /* }}} */ - -void -iflow_add_instr (InstructionFlow * _this, Instruction * instr) -{ /* {{{ */ - if (_this->number == _this->tabsize) { - _this->tabsize *= 2; - _this->instr = - (Instruction **) realloc (_this->instr, - _this->tabsize * sizeof (Instruction *)); - } - _this->instr[_this->number] = instr; - instr->address = _this->number; - _this->number++; -} /* }}} */ - -void -gsl_instr_set_namespace (Instruction * _this, GoomHash * ns) -{ /* {{{ */ - if (_this->cur_param <= 0) { - fprintf (stderr, "ERROR: Line %d, No more params to instructions\n", - _this->line_number); - exit (1); - } - _this->vnamespace[_this->cur_param - 1] = ns; -} /* }}} */ - -void -gsl_instr_add_param (Instruction * instr, char *param, int type) -{ /* {{{ */ - int len; - - if (instr == NULL) - return; - if (instr->cur_param == 0) - return; - --instr->cur_param; - len = strlen (param); - instr->params[instr->cur_param] = (char *) malloc (len + 1); - strcpy (instr->params[instr->cur_param], param); - instr->types[instr->cur_param] = type; - if (instr->cur_param == 0) { - - const char *result = gsl_instr_validate (instr); - - if (result != VALIDATE_OK) { - printf ("ERROR: Line %d: ", instr->parent->num_lines + 1); - gsl_instr_display (instr); - printf ("... %s\n", result); - instr->parent->compilationOK = 0; - exit (1); - } -#if USE_JITC_X86 - iflow_add_instr (instr->parent->iflow, instr); -#else - if (instr->id != INSTR_NOP) - iflow_add_instr (instr->parent->iflow, instr); - else - gsl_instr_free (instr); -#endif - } -} /* }}} */ - -Instruction * -gsl_instr_init (GoomSL * parent, const char *name, int id, int nb_param, - int line_number) -{ /* {{{ */ - Instruction *instr = (Instruction *) malloc (sizeof (Instruction)); - instr->params = (char **) malloc (nb_param * sizeof (char *)); - instr->vnamespace = (GoomHash **) malloc (nb_param * sizeof (GoomHash *)); - instr->types = (int *) malloc (nb_param * sizeof (int)); - instr->cur_param = instr->nb_param = nb_param; - instr->parent = parent; - instr->id = id; - instr->name = name; - instr->jump_label = NULL; - instr->line_number = line_number; - return instr; -} /* }}} */ - -void -gsl_instr_free (Instruction * _this) -{ /* {{{ */ - int i; - - free (_this->types); - for (i = _this->cur_param; i < _this->nb_param; ++i) - free (_this->params[i]); - free (_this->params); - free (_this); -} /* }}} */ - -void -gsl_instr_display (Instruction * _this) -{ /* {{{ */ - int i = _this->nb_param - 1; - - printf ("%s", _this->name); - while (i >= _this->cur_param) { - printf (" %s", _this->params[i]); - --i; - } -} /* }}} */ - - /****************************************/ - /* VALIDATION OF INSTRUCTION PARAMETERS */ -/****************************************/ - -static const char * -validate_v_v (Instruction * _this) -{ /* {{{ */ - HashValue *dest = goom_hash_get (_this->vnamespace[1], _this->params[1]); - HashValue *src = goom_hash_get (_this->vnamespace[0], _this->params[0]); - - if (dest == NULL) { - return VALIDATE_NO_SUCH_DEST_VAR; - } - if (src == NULL) { - return VALIDATE_NO_SUCH_SRC_VAR; - } - _this->data.udest.var = dest->ptr; - _this->data.usrc.var = src->ptr; - return VALIDATE_OK; -} /* }}} */ - -static const char * -validate_v_i (Instruction * _this) -{ /* {{{ */ - HashValue *dest = goom_hash_get (_this->vnamespace[1], _this->params[1]); - - _this->data.usrc.value_int = strtol (_this->params[0], NULL, 0); - - if (dest == NULL) { - return VALIDATE_NO_SUCH_INT; - } - _this->data.udest.var = dest->ptr; - return VALIDATE_OK; -} /* }}} */ - -static const char * -validate_v_p (Instruction * _this) -{ /* {{{ */ - HashValue *dest = goom_hash_get (_this->vnamespace[1], _this->params[1]); - - _this->data.usrc.value_ptr = strtol (_this->params[0], NULL, 0); - - if (dest == NULL) { - return VALIDATE_NO_SUCH_INT; - } - _this->data.udest.var = dest->ptr; - return VALIDATE_OK; -} /* }}} */ - -static const char * -validate_v_f (Instruction * _this) -{ /* {{{ */ - HashValue *dest = goom_hash_get (_this->vnamespace[1], _this->params[1]); - - _this->data.usrc.value_float = atof (_this->params[0]); - - if (dest == NULL) { - return VALIDATE_NO_SUCH_VAR; - } - _this->data.udest.var = dest->ptr; - return VALIDATE_OK; -} /* }}} */ - -static const char * -validate (Instruction * _this, - int vf_f_id, int vf_v_id, - int vi_i_id, int vi_v_id, int vp_p_id, int vp_v_id, int vs_v_id) -{ /* {{{ */ - if ((_this->types[1] == TYPE_FVAR) && (_this->types[0] == TYPE_FLOAT)) { - _this->id = vf_f_id; - return validate_v_f (_this); - } else if ((_this->types[1] == TYPE_FVAR) && (_this->types[0] == TYPE_FVAR)) { - _this->id = vf_v_id; - return validate_v_v (_this); - } else if ((_this->types[1] == TYPE_IVAR) - && (_this->types[0] == TYPE_INTEGER)) { - _this->id = vi_i_id; - return validate_v_i (_this); - } else if ((_this->types[1] == TYPE_IVAR) && (_this->types[0] == TYPE_IVAR)) { - _this->id = vi_v_id; - return validate_v_v (_this); - } else if ((_this->types[1] == TYPE_PVAR) && (_this->types[0] == TYPE_PTR)) { - if (vp_p_id == INSTR_NOP) - return VALIDATE_ERROR; - _this->id = vp_p_id; - return validate_v_p (_this); - } else if ((_this->types[1] == TYPE_PVAR) && (_this->types[0] == TYPE_PVAR)) { - _this->id = vp_v_id; - if (vp_v_id == INSTR_NOP) - return VALIDATE_ERROR; - return validate_v_v (_this); - } else if ((_this->types[1] < FIRST_RESERVED) && (_this->types[1] >= 0) - && (_this->types[0] == _this->types[1])) { - _this->id = vs_v_id; - if (vs_v_id == INSTR_NOP) - return "Impossible operation to perform between two structs"; - return validate_v_v (_this); - } - return VALIDATE_ERROR; -} /* }}} */ - -const char * -gsl_instr_validate (Instruction * _this) -{ /* {{{ */ - if (_this->id != INSTR_EXT_CALL) { - int i = _this->nb_param; - - while (i > 0) { - i--; - if (_this->types[i] == TYPE_VAR) { - int type = gsl_type_of_var (_this->vnamespace[i], _this->params[i]); - - if (type == INSTR_INT) - _this->types[i] = TYPE_IVAR; - else if (type == INSTR_FLOAT) - _this->types[i] = TYPE_FVAR; - else if (type == INSTR_PTR) - _this->types[i] = TYPE_PVAR; - else if ((type >= 0) && (type < FIRST_RESERVED)) - _this->types[i] = type; - else - fprintf (stderr, "WARNING: Line %d, %s has no namespace\n", - _this->line_number, _this->params[i]); - } - } - } - - switch (_this->id) { - - /* set */ - case INSTR_SET: - return validate (_this, - INSTR_SETF_VAR_FLOAT, INSTR_SETF_VAR_VAR, - INSTR_SETI_VAR_INTEGER, INSTR_SETI_VAR_VAR, - INSTR_SETP_VAR_PTR, INSTR_SETP_VAR_VAR, INSTR_SETS_VAR_VAR); - - /* extcall */ - case INSTR_EXT_CALL: - if (_this->types[0] == TYPE_VAR) { - HashValue *fval = - goom_hash_get (_this->parent->functions, _this->params[0]); - if (fval) { - _this->data.udest.external_function = - (struct _ExternalFunctionStruct *) fval->ptr; - return VALIDATE_OK; - } - } - return VALIDATE_ERROR; - - /* call */ - case INSTR_CALL: - if (_this->types[0] == TYPE_LABEL) { - _this->jump_label = _this->params[0]; - return VALIDATE_OK; - } - return VALIDATE_ERROR; - - /* ret */ - case INSTR_RET: - return VALIDATE_OK; - - /* jump */ - case INSTR_JUMP: - - if (_this->types[0] == TYPE_LABEL) { - _this->jump_label = _this->params[0]; - return VALIDATE_OK; - } - return VALIDATE_ERROR; - - /* jzero / jnzero */ - case INSTR_JZERO: - case INSTR_JNZERO: - - if (_this->types[0] == TYPE_LABEL) { - _this->jump_label = _this->params[0]; - return VALIDATE_OK; - } - return VALIDATE_ERROR; - - /* label */ - case INSTR_LABEL: - - if (_this->types[0] == TYPE_LABEL) { - _this->id = INSTR_NOP; - _this->nop_label = _this->params[0]; - goom_hash_put_int (_this->parent->iflow->labels, _this->params[0], - _this->parent->iflow->number); - return VALIDATE_OK; - } - return VALIDATE_ERROR; - - /* isequal */ - case INSTR_ISEQUAL: - return validate (_this, - INSTR_ISEQUALF_VAR_FLOAT, INSTR_ISEQUALF_VAR_VAR, - INSTR_ISEQUALI_VAR_INTEGER, INSTR_ISEQUALI_VAR_VAR, - INSTR_ISEQUALP_VAR_PTR, INSTR_ISEQUALP_VAR_VAR, - INSTR_ISEQUALS_VAR_VAR); - - /* not */ - case INSTR_NOT: - _this->id = INSTR_NOT_VAR; - return VALIDATE_OK; - - /* islower */ - case INSTR_ISLOWER: - return validate (_this, - INSTR_ISLOWERF_VAR_FLOAT, INSTR_ISLOWERF_VAR_VAR, - INSTR_ISLOWERI_VAR_INTEGER, INSTR_ISLOWERI_VAR_VAR, - INSTR_NOP, INSTR_NOP, INSTR_NOP); - - /* add */ - case INSTR_ADD: - return validate (_this, - INSTR_ADDF_VAR_FLOAT, INSTR_ADDF_VAR_VAR, - INSTR_ADDI_VAR_INTEGER, INSTR_ADDI_VAR_VAR, - INSTR_NOP, INSTR_NOP, INSTR_ADDS_VAR_VAR); - - /* mul */ - case INSTR_MUL: - return validate (_this, - INSTR_MULF_VAR_FLOAT, INSTR_MULF_VAR_VAR, - INSTR_MULI_VAR_INTEGER, INSTR_MULI_VAR_VAR, - INSTR_NOP, INSTR_NOP, INSTR_MULS_VAR_VAR); - - /* sub */ - case INSTR_SUB: - return validate (_this, - INSTR_SUBF_VAR_FLOAT, INSTR_SUBF_VAR_VAR, - INSTR_SUBI_VAR_INTEGER, INSTR_SUBI_VAR_VAR, - INSTR_NOP, INSTR_NOP, INSTR_SUBS_VAR_VAR); - - /* div */ - case INSTR_DIV: - return validate (_this, - INSTR_DIVF_VAR_FLOAT, INSTR_DIVF_VAR_VAR, - INSTR_DIVI_VAR_INTEGER, INSTR_DIVI_VAR_VAR, - INSTR_NOP, INSTR_NOP, INSTR_DIVS_VAR_VAR); - - default: - return VALIDATE_TODO; - } -} /* }}} */ - - /*************/ - /* EXECUTION */ -/*************/ -void -iflow_execute (FastInstructionFlow * _this, GoomSL * gsl) -{ /* {{{ */ - int flag = 0; - int ip = 0; - FastInstruction *instr = _this->instr; - int stack[0x10000]; - int stack_pointer = 0; - - stack[stack_pointer++] = -1; - - /* Quelques Macro pour rendre le code plus lisible */ -#define pSRC_VAR instr[ip].data.usrc.var -#define SRC_VAR_INT *instr[ip].data.usrc.var_int -#define SRC_VAR_FLOAT *instr[ip].data.usrc.var_float -#define SRC_VAR_PTR *instr[ip].data.usrc.var_ptr - -#define pDEST_VAR instr[ip].data.udest.var -#define DEST_VAR_INT *instr[ip].data.udest.var_int -#define DEST_VAR_FLOAT *instr[ip].data.udest.var_float -#define DEST_VAR_PTR *instr[ip].data.udest.var_ptr - -#define VALUE_INT instr[ip].data.usrc.value_int -#define VALUE_FLOAT instr[ip].data.usrc.value_float -#define VALUE_PTR instr[ip].data.usrc.value_ptr - -#define JUMP_OFFSET instr[ip].data.udest.jump_offset - -#define SRC_STRUCT_ID instr[ip].data.usrc.var_int[-1] -#define DEST_STRUCT_ID instr[ip].data.udest.var_int[-1] -#define SRC_STRUCT_IBLOCK(i) gsl->gsl_struct[SRC_STRUCT_ID]->iBlock[i] -#define SRC_STRUCT_FBLOCK(i) gsl->gsl_struct[SRC_STRUCT_ID]->fBlock[i] -#define DEST_STRUCT_IBLOCK(i) gsl->gsl_struct[DEST_STRUCT_ID]->iBlock[i] -#define DEST_STRUCT_FBLOCK(i) gsl->gsl_struct[DEST_STRUCT_ID]->fBlock[i] -#define DEST_STRUCT_IBLOCK_VAR(i,j) \ - ((int*)((char*)pDEST_VAR + gsl->gsl_struct[DEST_STRUCT_ID]->iBlock[i].data))[j] -#define DEST_STRUCT_FBLOCK_VAR(i,j) \ - ((float*)((char*)pDEST_VAR + gsl->gsl_struct[DEST_STRUCT_ID]->fBlock[i].data))[j] -#define SRC_STRUCT_IBLOCK_VAR(i,j) \ - ((int*)((char*)pSRC_VAR + gsl->gsl_struct[SRC_STRUCT_ID]->iBlock[i].data))[j] -#define SRC_STRUCT_FBLOCK_VAR(i,j) \ - ((float*)((char*)pSRC_VAR + gsl->gsl_struct[SRC_STRUCT_ID]->fBlock[i].data))[j] -#define DEST_STRUCT_SIZE gsl->gsl_struct[DEST_STRUCT_ID]->size - - while (1) { - int i; - -#ifdef TRACE_SCRIPT - printf ("execute "); - gsl_instr_display (instr[ip].proto); - printf ("\n"); -#endif - switch (instr[ip].id) { - - /* SET.I */ - case INSTR_SETI_VAR_INTEGER: - DEST_VAR_INT = VALUE_INT; - ++ip; - break; - - case INSTR_SETI_VAR_VAR: - DEST_VAR_INT = SRC_VAR_INT; - ++ip; - break; - - /* SET.F */ - case INSTR_SETF_VAR_FLOAT: - DEST_VAR_FLOAT = VALUE_FLOAT; - ++ip; - break; - - case INSTR_SETF_VAR_VAR: - DEST_VAR_FLOAT = SRC_VAR_FLOAT; - ++ip; - break; - - /* SET.P */ - case INSTR_SETP_VAR_VAR: - DEST_VAR_PTR = SRC_VAR_PTR; - ++ip; - break; - - case INSTR_SETP_VAR_PTR: - DEST_VAR_PTR = VALUE_PTR; - ++ip; - break; - - /* JUMP */ - case INSTR_JUMP: - ip += JUMP_OFFSET; - break; - - /* JZERO */ - case INSTR_JZERO: - ip += (flag ? 1 : JUMP_OFFSET); - break; - - case INSTR_NOP: - ++ip; - break; - - /* ISEQUAL.P */ - case INSTR_ISEQUALP_VAR_VAR: - flag = (DEST_VAR_PTR == SRC_VAR_PTR); - ++ip; - break; - - case INSTR_ISEQUALP_VAR_PTR: - flag = (DEST_VAR_PTR == VALUE_PTR); - ++ip; - break; - - /* ISEQUAL.I */ - case INSTR_ISEQUALI_VAR_VAR: - flag = (DEST_VAR_INT == SRC_VAR_INT); - ++ip; - break; - - case INSTR_ISEQUALI_VAR_INTEGER: - flag = (DEST_VAR_INT == VALUE_INT); - ++ip; - break; - - /* ISEQUAL.F */ - case INSTR_ISEQUALF_VAR_VAR: - flag = (DEST_VAR_FLOAT == SRC_VAR_FLOAT); - ++ip; - break; - - case INSTR_ISEQUALF_VAR_FLOAT: - flag = (DEST_VAR_FLOAT == VALUE_FLOAT); - ++ip; - break; - - /* ISLOWER.I */ - case INSTR_ISLOWERI_VAR_VAR: - flag = (DEST_VAR_INT < SRC_VAR_INT); - ++ip; - break; - - case INSTR_ISLOWERI_VAR_INTEGER: - flag = (DEST_VAR_INT < VALUE_INT); - ++ip; - break; - - /* ISLOWER.F */ - case INSTR_ISLOWERF_VAR_VAR: - flag = (DEST_VAR_FLOAT < SRC_VAR_FLOAT); - ++ip; - break; - - case INSTR_ISLOWERF_VAR_FLOAT: - flag = (DEST_VAR_FLOAT < VALUE_FLOAT); - ++ip; - break; - - /* ADD.I */ - case INSTR_ADDI_VAR_VAR: - DEST_VAR_INT += SRC_VAR_INT; - ++ip; - break; - - case INSTR_ADDI_VAR_INTEGER: - DEST_VAR_INT += VALUE_INT; - ++ip; - break; - - /* ADD.F */ - case INSTR_ADDF_VAR_VAR: - DEST_VAR_FLOAT += SRC_VAR_FLOAT; - ++ip; - break; - - case INSTR_ADDF_VAR_FLOAT: - DEST_VAR_FLOAT += VALUE_FLOAT; - ++ip; - break; - - /* MUL.I */ - case INSTR_MULI_VAR_VAR: - DEST_VAR_INT *= SRC_VAR_INT; - ++ip; - break; - - case INSTR_MULI_VAR_INTEGER: - DEST_VAR_INT *= VALUE_INT; - ++ip; - break; - - /* MUL.F */ - case INSTR_MULF_VAR_FLOAT: - DEST_VAR_FLOAT *= VALUE_FLOAT; - ++ip; - break; - - case INSTR_MULF_VAR_VAR: - DEST_VAR_FLOAT *= SRC_VAR_FLOAT; - ++ip; - break; - - /* DIV.I */ - case INSTR_DIVI_VAR_VAR: - DEST_VAR_INT /= SRC_VAR_INT; - ++ip; - break; - - case INSTR_DIVI_VAR_INTEGER: - DEST_VAR_INT /= VALUE_INT; - ++ip; - break; - - /* DIV.F */ - case INSTR_DIVF_VAR_FLOAT: - DEST_VAR_FLOAT /= VALUE_FLOAT; - ++ip; - break; - - case INSTR_DIVF_VAR_VAR: - DEST_VAR_FLOAT /= SRC_VAR_FLOAT; - ++ip; - break; - - /* SUB.I */ - case INSTR_SUBI_VAR_VAR: - DEST_VAR_INT -= SRC_VAR_INT; - ++ip; - break; - - case INSTR_SUBI_VAR_INTEGER: - DEST_VAR_INT -= VALUE_INT; - ++ip; - break; - - /* SUB.F */ - case INSTR_SUBF_VAR_FLOAT: - DEST_VAR_FLOAT -= VALUE_FLOAT; - ++ip; - break; - - case INSTR_SUBF_VAR_VAR: - DEST_VAR_FLOAT -= SRC_VAR_FLOAT; - ++ip; - break; - - /* CALL */ - case INSTR_CALL: - stack[stack_pointer++] = ip + 1; - ip += JUMP_OFFSET; - break; - - /* RET */ - case INSTR_RET: - ip = stack[--stack_pointer]; - if (ip < 0) - return; - break; - - /* EXT_CALL */ - case INSTR_EXT_CALL: - instr[ip].data.udest.external_function->function (gsl, gsl->vars, - instr[ip].data.udest.external_function->vars); - ++ip; - break; - - /* NOT */ - case INSTR_NOT_VAR: - flag = !flag; - ++ip; - break; - - /* JNZERO */ - case INSTR_JNZERO: - ip += (flag ? JUMP_OFFSET : 1); - break; - - case INSTR_SETS_VAR_VAR: - memcpy (pDEST_VAR, pSRC_VAR, DEST_STRUCT_SIZE); - ++ip; - break; - - case INSTR_ISEQUALS_VAR_VAR: - break; - - case INSTR_ADDS_VAR_VAR: - /* process integers */ - i = 0; - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { - DEST_STRUCT_IBLOCK_VAR (i, j) += SRC_STRUCT_IBLOCK_VAR (i, j); - } - ++i; - } - /* process floats */ - i = 0; - while (DEST_STRUCT_FBLOCK (i).size > 0) { - int j = DEST_STRUCT_FBLOCK (i).size; - - while (j--) { - DEST_STRUCT_FBLOCK_VAR (i, j) += SRC_STRUCT_FBLOCK_VAR (i, j); - } - ++i; - } - ++ip; - break; - - case INSTR_SUBS_VAR_VAR: - /* process integers */ - i = 0; - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { - DEST_STRUCT_IBLOCK_VAR (i, j) -= SRC_STRUCT_IBLOCK_VAR (i, j); - } - ++i; - } - /* process floats */ - i = 0; - while (DEST_STRUCT_FBLOCK (i).size > 0) { - int j = DEST_STRUCT_FBLOCK (i).size; - - while (j--) { - DEST_STRUCT_FBLOCK_VAR (i, j) -= SRC_STRUCT_FBLOCK_VAR (i, j); - } - ++i; - } - ++ip; - break; - - case INSTR_MULS_VAR_VAR: - /* process integers */ - i = 0; - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { - DEST_STRUCT_IBLOCK_VAR (i, j) *= SRC_STRUCT_IBLOCK_VAR (i, j); - } - ++i; - } - /* process floats */ - i = 0; - while (DEST_STRUCT_FBLOCK (i).size > 0) { - int j = DEST_STRUCT_FBLOCK (i).size; - - while (j--) { - DEST_STRUCT_FBLOCK_VAR (i, j) *= SRC_STRUCT_FBLOCK_VAR (i, j); - } - ++i; - } - ++ip; - break; - - case INSTR_DIVS_VAR_VAR: - /* process integers */ - i = 0; - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { - DEST_STRUCT_IBLOCK_VAR (i, j) /= SRC_STRUCT_IBLOCK_VAR (i, j); - } - ++i; - } - /* process floats */ - i = 0; - while (DEST_STRUCT_FBLOCK (i).size > 0) { - int j = DEST_STRUCT_FBLOCK (i).size; - - while (j--) { - DEST_STRUCT_FBLOCK_VAR (i, j) /= SRC_STRUCT_FBLOCK_VAR (i, j); - } - ++i; - } - ++ip; - break; - - default: - printf ("NOT IMPLEMENTED : %d\n", instr[ip].id); - ++ip; - exit (1); - } - } -} /* }}} */ - -int -gsl_malloc (GoomSL * _this, int size) -{ /* {{{ */ - if (_this->nbPtr >= _this->ptrArraySize) { - _this->ptrArraySize *= 2; - _this->ptrArray = - (void **) realloc (_this->ptrArray, - sizeof (void *) * _this->ptrArraySize); - } - _this->ptrArray[_this->nbPtr] = malloc (size); - return _this->nbPtr++; -} /* }}} */ - -void * -gsl_get_ptr (GoomSL * _this, int id) -{ /* {{{ */ - if ((id >= 0) && (id < _this->nbPtr)) - return _this->ptrArray[id]; - fprintf (stderr, "INVALID GET PTR 0x%08x\n", id); - return NULL; -} /* }}} */ - -void -gsl_free_ptr (GoomSL * _this, int id) -{ /* {{{ */ - if ((id >= 0) && (id < _this->nbPtr)) { - free (_this->ptrArray[id]); - _this->ptrArray[id] = 0; - } -} /* }}} */ - -void -gsl_enternamespace (const char *name) -{ /* {{{ */ - HashValue *val = goom_hash_get (currentGoomSL->functions, name); - - if (val) { - ExternalFunctionStruct *function = (ExternalFunctionStruct *) val->ptr; - - currentGoomSL->currentNS++; - currentGoomSL->namespaces[currentGoomSL->currentNS] = function->vars; - } else { - fprintf (stderr, "ERROR: Line %d, Could not find namespace: %s\n", - currentGoomSL->num_lines, name); - exit (1); - } -} /* }}} */ - -void -gsl_reenternamespace (GoomHash * nsinfo) -{ - currentGoomSL->currentNS++; - currentGoomSL->namespaces[currentGoomSL->currentNS] = nsinfo; -} - -GoomHash * -gsl_leavenamespace (void) -{ /* {{{ */ - currentGoomSL->currentNS--; - return currentGoomSL->namespaces[currentGoomSL->currentNS + 1]; -} /* }}} */ - -GoomHash * -gsl_find_namespace (const char *name) -{ /* {{{ */ - int i; - - for (i = currentGoomSL->currentNS; i >= 0; --i) { - if (goom_hash_get (currentGoomSL->namespaces[i], name)) - return currentGoomSL->namespaces[i]; - } - return NULL; -} /* }}} */ - -void -gsl_declare_task (const char *name) -{ /* {{{ */ - if (goom_hash_get (currentGoomSL->functions, name)) { - return; - } else { - ExternalFunctionStruct *gef = - (ExternalFunctionStruct *) malloc (sizeof (ExternalFunctionStruct)); - gef->function = 0; - gef->vars = goom_hash_new (); - gef->is_extern = 0; - goom_hash_put_ptr (currentGoomSL->functions, name, (void *) gef); - } -} /* }}} */ - -void -gsl_declare_external_task (const char *name) -{ /* {{{ */ - if (goom_hash_get (currentGoomSL->functions, name)) { - fprintf (stderr, "ERROR: Line %d, Duplicate declaration of %s\n", - currentGoomSL->num_lines, name); - return; - } else { - ExternalFunctionStruct *gef = - (ExternalFunctionStruct *) malloc (sizeof (ExternalFunctionStruct)); - gef->function = 0; - gef->vars = goom_hash_new (); - gef->is_extern = 1; - goom_hash_put_ptr (currentGoomSL->functions, name, (void *) gef); - } -} /* }}} */ - -static void -reset_scanner (GoomSL * gss) -{ /* {{{ */ - gss->num_lines = 0; - gss->instr = NULL; - iflow_clean (gss->iflow); - - /* reset variables */ - goom_hash_free (gss->vars); - gss->vars = goom_hash_new (); - gss->currentNS = 0; - gss->namespaces[0] = gss->vars; - - goom_hash_free (gss->structIDS); - gss->structIDS = goom_hash_new (); - - while (gss->nbStructID > 0) { - int i; - - gss->nbStructID--; - for (i = 0; i < gss->gsl_struct[gss->nbStructID]->nbFields; ++i) - free (gss->gsl_struct[gss->nbStructID]->fields[i]); - free (gss->gsl_struct[gss->nbStructID]); - } - - gss->compilationOK = 1; - - goom_heap_delete (gss->data_heap); - gss->data_heap = goom_heap_new (); -} /* }}} */ - -static void -calculate_labels (InstructionFlow * iflow) -{ /* {{{ */ - int i = 0; - - while (i < iflow->number) { - Instruction *instr = iflow->instr[i]; - - if (instr->jump_label) { - HashValue *label = goom_hash_get (iflow->labels, instr->jump_label); - - if (label) { - instr->data.udest.jump_offset = -instr->address + label->i; - } else { - fprintf (stderr, "ERROR: Line %d, Could not find label %s\n", - instr->line_number, instr->jump_label); - instr->id = INSTR_NOP; - instr->nop_label = 0; - exit (1); - } - } - ++i; - } -} /* }}} */ - -#ifdef USE_JITC_X86 -static int -powerOfTwo (int i) -{ - int b; - - for (b = 0; b < 31; b++) - if (i == (1 << b)) - return b; - return 0; -} -#endif - -/* Cree un flow d'instruction optimise */ -static void -gsl_create_fast_iflow (void) -{ /* {{{ */ - int number = currentGoomSL->iflow->number; - int i; - -#ifdef USE_JITC_X86 - - /* pour compatibilite avec les MACROS servant a execution */ - int ip = 0; - GoomSL *gsl = currentGoomSL; - - JitcX86Env *jitc; - - if (currentGoomSL->jitc != NULL) - jitc_x86_delete (currentGoomSL->jitc); - jitc = currentGoomSL->jitc = jitc_x86_env_new (0xffff); - currentGoomSL->jitc_func = jitc_prepare_func (jitc); - -#if 0 -#define SRC_STRUCT_ID instr[ip].data.usrc.var_int[-1] -#define DEST_STRUCT_ID instr[ip].data.udest.var_int[-1] -#define SRC_STRUCT_IBLOCK(i) gsl->gsl_struct[SRC_STRUCT_ID]->iBlock[i] -#define SRC_STRUCT_FBLOCK(i) gsl->gsl_struct[SRC_STRUCT_ID]->fBlock[i] -#define DEST_STRUCT_IBLOCK(i) gsl->gsl_struct[DEST_STRUCT_ID]->iBlock[i] -#define DEST_STRUCT_FBLOCK(i) gsl->gsl_struct[DEST_STRUCT_ID]->fBlock[i] -#define DEST_STRUCT_IBLOCK_VAR(i,j) \ - ((int*)((char*)pDEST_VAR + gsl->gsl_struct[DEST_STRUCT_ID]->iBlock[i].data))[j] -#define DEST_STRUCT_FBLOCK_VAR(i,j) \ - ((float*)((char*)pDEST_VAR + gsl->gsl_struct[DEST_STRUCT_ID]->fBlock[i].data))[j] -#define SRC_STRUCT_IBLOCK_VAR(i,j) \ - ((int*)((char*)pSRC_VAR + gsl->gsl_struct[SRC_STRUCT_ID]->iBlock[i].data))[j] -#define SRC_STRUCT_FBLOCK_VAR(i,j) \ - ((float*)((char*)pSRC_VAR + gsl->gsl_struct[SRC_STRUCT_ID]->fBlock[i].data))[j] -#define DEST_STRUCT_SIZE gsl->gsl_struct[DEST_STRUCT_ID]->size -#endif - - JITC_JUMP_LABEL (jitc, "__very_end__"); - JITC_ADD_LABEL (jitc, "__very_start__"); - - for (i = 0; i < number; ++i) { - Instruction *instr = currentGoomSL->iflow->instr[i]; - - switch (instr->id) { - case INSTR_SETI_VAR_INTEGER: - jitc_add (jitc, "mov [$d], $d", instr->data.udest.var_int, - instr->data.usrc.value_int); - break; - case INSTR_SETI_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.usrc.var_int); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - break; - /* SET.F */ - case INSTR_SETF_VAR_FLOAT: - jitc_add (jitc, "mov [$d], $d", instr->data.udest.var_float, - *(int *) (&instr->data.usrc.value_float)); - break; - case INSTR_SETF_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.usrc.var_float); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_float); - break; - case INSTR_NOP: - if (instr->nop_label != 0) - JITC_ADD_LABEL (jitc, instr->nop_label); - break; - case INSTR_JUMP: - JITC_JUMP_LABEL (jitc, instr->jump_label); - break; - case INSTR_SETP_VAR_PTR: - jitc_add (jitc, "mov [$d], $d", instr->data.udest.var_ptr, - instr->data.usrc.value_ptr); - break; - case INSTR_SETP_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.usrc.var_ptr); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_ptr); - break; - case INSTR_SUBI_VAR_INTEGER: - jitc_add (jitc, "add [$d], $d", instr->data.udest.var_int, - -instr->data.usrc.value_int); - break; - case INSTR_SUBI_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "sub eax, [$d]", instr->data.usrc.var_int); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - break; - case INSTR_SUBF_VAR_FLOAT: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_SUBF_VAR_VAR: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_ISLOWERF_VAR_VAR: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_ISLOWERF_VAR_FLOAT: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_ISLOWERI_VAR_VAR: - jitc_add (jitc, "mov edx, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "sub edx, [$d]", instr->data.usrc.var_int); - jitc_add (jitc, "shr edx, $d", 31); - break; - case INSTR_ISLOWERI_VAR_INTEGER: - jitc_add (jitc, "mov edx, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "sub edx, $d", instr->data.usrc.value_int); - jitc_add (jitc, "shr edx, $d", 31); - break; - case INSTR_ADDI_VAR_INTEGER: - jitc_add (jitc, "add [$d], $d", instr->data.udest.var_int, - instr->data.usrc.value_int); - break; - case INSTR_ADDI_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "add eax, [$d]", instr->data.usrc.var_int); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - break; - case INSTR_ADDF_VAR_FLOAT: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_ADDF_VAR_VAR: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_MULI_VAR_INTEGER: - if (instr->data.usrc.value_int != 1) { - int po2 = powerOfTwo (instr->data.usrc.value_int); - - if (po2) { - /* performs (V / 2^n) by doing V >> n */ - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "sal eax, $d", po2); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - } else { - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "imul eax, $d", instr->data.usrc.value_int); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - } - } - break; - case INSTR_MULI_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "imul eax, [$d]", instr->data.usrc.var_int); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - break; - case INSTR_MULF_VAR_FLOAT: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_MULF_VAR_VAR: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_DIVI_VAR_INTEGER: - if ((instr->data.usrc.value_int != 1) - && (instr->data.usrc.value_int != 0)) { - int po2 = powerOfTwo (instr->data.usrc.value_int); - - if (po2) { - /* performs (V / 2^n) by doing V >> n */ - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "sar eax, $d", po2); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - } else { - /* performs (V/n) by doing (V*(32^2/n)) */ - long coef; - double dcoef = - (double) 4294967296.0 / (double) instr->data.usrc.value_int; - if (dcoef < 0.0) - dcoef = -dcoef; - coef = (long) floor (dcoef); - dcoef -= floor (dcoef); - if (dcoef < 0.5) - coef += 1; - - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "mov edx, $d", coef); - jitc_add (jitc, "imul edx"); - if (instr->data.usrc.value_int < 0) - jitc_add (jitc, "neg edx"); - jitc_add (jitc, "mov [$d], edx", instr->data.udest.var_int); - } - } - break; - case INSTR_DIVI_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "cdq"); /* sign extend eax into edx */ - jitc_add (jitc, "idiv [$d]", instr->data.usrc.var_int); - jitc_add (jitc, "mov [$d], eax", instr->data.udest.var_int); - break; - case INSTR_DIVF_VAR_FLOAT: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_DIVF_VAR_VAR: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_JZERO: - jitc_add (jitc, "cmp edx, $d", 0); - jitc_add (jitc, "je $s", instr->jump_label); - break; - case INSTR_ISEQUALP_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_ptr); - jitc_add (jitc, "mov edx, $d", 0); - jitc_add (jitc, "cmp eax, [$d]", instr->data.usrc.var_ptr); - jitc_add (jitc, "jne $d", 1); - jitc_add (jitc, "inc edx"); - break; - case INSTR_ISEQUALP_VAR_PTR: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_ptr); - jitc_add (jitc, "mov edx, $d", 0); - jitc_add (jitc, "cmp eax, $d", instr->data.usrc.value_ptr); - jitc_add (jitc, "jne $d", 1); - jitc_add (jitc, "inc edx"); - break; - case INSTR_ISEQUALI_VAR_VAR: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "mov edx, $d", 0); - jitc_add (jitc, "cmp eax, [$d]", instr->data.usrc.var_int); - jitc_add (jitc, "jne $d", 1); - jitc_add (jitc, "inc edx"); - break; - case INSTR_ISEQUALI_VAR_INTEGER: - jitc_add (jitc, "mov eax, [$d]", instr->data.udest.var_int); - jitc_add (jitc, "mov edx, $d", 0); - jitc_add (jitc, "cmp eax, $d", instr->data.usrc.value_int); - jitc_add (jitc, "jne $d", 1); - jitc_add (jitc, "inc edx"); - break; - case INSTR_ISEQUALF_VAR_VAR: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_ISEQUALF_VAR_FLOAT: - printf ("NOT IMPLEMENTED : %d\n", instr->id); - break; - case INSTR_CALL: - jitc_add (jitc, "call $s", instr->jump_label); - break; - case INSTR_RET: - jitc_add (jitc, "ret"); - break; - case INSTR_EXT_CALL: - jitc_add (jitc, "mov eax, [$d]", - &(instr->data.udest.external_function->vars)); - jitc_add (jitc, "push eax"); - jitc_add (jitc, "mov edx, [$d]", &(currentGoomSL->vars)); - jitc_add (jitc, "push edx"); - jitc_add (jitc, "mov eax, [$d]", &(currentGoomSL)); - jitc_add (jitc, "push eax"); - - jitc_add (jitc, "mov eax, [$d]", - &(instr->data.udest.external_function)); - jitc_add (jitc, "mov eax, [eax]"); - jitc_add (jitc, "call [eax]"); - jitc_add (jitc, "add esp, $d", 12); - break; - case INSTR_NOT_VAR: - jitc_add (jitc, "mov eax, edx"); - jitc_add (jitc, "mov edx, $d", 1); - jitc_add (jitc, "sub edx, eax"); - break; - case INSTR_JNZERO: - jitc_add (jitc, "cmp edx, $d", 0); - jitc_add (jitc, "jne $s", instr->jump_label); - break; - case INSTR_SETS_VAR_VAR: - { - int loop = DEST_STRUCT_SIZE / sizeof (int); - int dst = (int) pDEST_VAR; - int src = (int) pSRC_VAR; - - while (loop--) { - jitc_add (jitc, "mov eax, [$d]", src); - jitc_add (jitc, "mov [$d], eax", dst); - src += 4; - dst += 4; - } - } - break; - case INSTR_ISEQUALS_VAR_VAR: - break; - case INSTR_ADDS_VAR_VAR: - { - /* process integers */ - int i = 0; - - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { /* TODO interlace 2 */ - jitc_add (jitc, "mov eax, [$d]", &DEST_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "add eax, [$d]", &SRC_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "mov [$d], eax", &DEST_STRUCT_IBLOCK_VAR (i, j)); - } - ++i; - } - /* process floats */ - i = 0; - while (DEST_STRUCT_FBLOCK (i).size > 0) { - int j = DEST_STRUCT_FBLOCK (i).size; - - while (j--) { - /* DEST_STRUCT_FBLOCK_VAR(i,j) += SRC_STRUCT_FBLOCK_VAR(i,j); */ - /* TODO */ - } - ++i; - } - break; - } - case INSTR_SUBS_VAR_VAR: - { - /* process integers */ - int i = 0; - - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { - jitc_add (jitc, "mov eax, [$d]", &DEST_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "sub eax, [$d]", &SRC_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "mov [$d], eax", &DEST_STRUCT_IBLOCK_VAR (i, j)); - } - ++i; - } - break; - } - case INSTR_MULS_VAR_VAR: - { - /* process integers */ - int i = 0; - - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { - jitc_add (jitc, "mov eax, [$d]", &DEST_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "imul eax, [$d]", &SRC_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "mov [$d], eax", &DEST_STRUCT_IBLOCK_VAR (i, j)); - } - ++i; - } - break; - } - case INSTR_DIVS_VAR_VAR: - { - /* process integers */ - int i = 0; - - while (DEST_STRUCT_IBLOCK (i).size > 0) { - int j = DEST_STRUCT_IBLOCK (i).size; - - while (j--) { - jitc_add (jitc, "mov eax, [$d]", &DEST_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "cdq"); - jitc_add (jitc, "idiv [$d]", &SRC_STRUCT_IBLOCK_VAR (i, j)); - jitc_add (jitc, "mov [$d], eax", &DEST_STRUCT_IBLOCK_VAR (i, j)); - } - ++i; - } - break; - } - } - } - - JITC_ADD_LABEL (jitc, "__very_end__"); - jitc_add (jitc, "call $s", "__very_start__"); - jitc_add (jitc, "mov eax, $d", 0); - jitc_validate_func (jitc); -#else - InstructionFlow *iflow = currentGoomSL->iflow; - FastInstructionFlow *fastiflow = - (FastInstructionFlow *) malloc (sizeof (FastInstructionFlow)); - fastiflow->mallocedInstr = calloc (number * 16, sizeof (FastInstruction)); - /* fastiflow->instr = (FastInstruction*)(((int)fastiflow->mallocedInstr) + 16 - (((int)fastiflow->mallocedInstr)%16)); */ - fastiflow->instr = (FastInstruction *) fastiflow->mallocedInstr; - fastiflow->number = number; - for (i = 0; i < number; ++i) { - fastiflow->instr[i].id = iflow->instr[i]->id; - fastiflow->instr[i].data = iflow->instr[i]->data; - fastiflow->instr[i].proto = iflow->instr[i]; - } - currentGoomSL->fastiflow = fastiflow; -#endif -} /* }}} */ - -void yy_scan_string (const char *str); -void yyparse (void); - -GoomHash * -gsl_globals (GoomSL * _this) -{ - return _this->vars; -} - - -/** - * Some native external functions - */ -static void -ext_charAt (GoomSL * gsl, GoomHash * global, GoomHash * local) -{ - char *string = GSL_LOCAL_PTR (gsl, local, "value"); - int index = GSL_LOCAL_INT (gsl, local, "index"); - - GSL_GLOBAL_INT (gsl, "charAt") = 0; - if (string == NULL) { - return; - } - if (index < strlen (string)) - GSL_GLOBAL_INT (gsl, "charAt") = string[index]; -} - -static void -ext_i2f (GoomSL * gsl, GoomHash * global, GoomHash * local) -{ - int i = GSL_LOCAL_INT (gsl, local, "value"); - - GSL_GLOBAL_FLOAT (gsl, "i2f") = i; -} - -static void -ext_f2i (GoomSL * gsl, GoomHash * global, GoomHash * local) -{ - float f = GSL_LOCAL_FLOAT (gsl, local, "value"); - - GSL_GLOBAL_INT (gsl, "f2i") = f; -} - -/** - * - */ -void -gsl_compile (GoomSL * _currentGoomSL, const char *script) -{ /* {{{ */ - char *script_and_externals; - static const char *sBinds = - "external : int\n" - "external : int\n" - "external : float\n"; - -#ifdef VERBOSE - printf ("\n=== Starting Compilation ===\n"); -#endif - - script_and_externals = malloc (strlen (script) + strlen (sBinds) + 2); - strcpy (script_and_externals, sBinds); - strcat (script_and_externals, script); - - /* 0- reset */ - currentGoomSL = _currentGoomSL; - reset_scanner (currentGoomSL); - - /* 1- create the syntaxic tree */ - yy_scan_string (script_and_externals); - yyparse (); - - /* 2- generate code */ - gsl_commit_compilation (); - - /* 3- resolve symbols */ - calculate_labels (currentGoomSL->iflow); - - /* 4- optimize code */ - gsl_create_fast_iflow (); - - /* 5- bind a few internal functions */ - gsl_bind_function (currentGoomSL, "charAt", ext_charAt); - gsl_bind_function (currentGoomSL, "f2i", ext_f2i); - gsl_bind_function (currentGoomSL, "i2f", ext_i2f); - free (script_and_externals); - -#ifdef VERBOSE - printf ("=== Compilation done. # of lines: %d. # of instr: %d ===\n", - currentGoomSL->num_lines, currentGoomSL->iflow->number); -#endif -} /* }}} */ - -void -gsl_execute (GoomSL * scanner) -{ /* {{{ */ - if (scanner->compilationOK) { -#if USE_JITC_X86 - scanner->jitc_func (); -#else - iflow_execute (scanner->fastiflow, scanner); -#endif - } -} /* }}} */ - -GoomSL * -gsl_new (void) -{ /* {{{ */ - GoomSL *gss = (GoomSL *) malloc (sizeof (GoomSL)); - - gss->iflow = iflow_new (); - gss->vars = goom_hash_new (); - gss->functions = goom_hash_new (); - gss->nbStructID = 0; - gss->structIDS = goom_hash_new (); - gss->gsl_struct_size = 32; - gss->gsl_struct = - (GSL_Struct **) malloc (gss->gsl_struct_size * sizeof (GSL_Struct *)); - gss->currentNS = 0; - gss->namespaces[0] = gss->vars; - gss->data_heap = goom_heap_new (); - - reset_scanner (gss); - - gss->compilationOK = 0; - gss->nbPtr = 0; - gss->ptrArraySize = 256; - gss->ptrArray = (void **) malloc (gss->ptrArraySize * sizeof (void *)); -#ifdef USE_JITC_X86 - gss->jitc = NULL; -#endif - return gss; -} /* }}} */ - -void -gsl_bind_function (GoomSL * gss, const char *fname, - GoomSL_ExternalFunction func) -{ /* {{{ */ - HashValue *val = goom_hash_get (gss->functions, fname); - - if (val) { - ExternalFunctionStruct *gef = (ExternalFunctionStruct *) val->ptr; - - gef->function = func; - } else - fprintf (stderr, "Unable to bind function %s\n", fname); -} /* }}} */ - -int -gsl_is_compiled (GoomSL * gss) -{ /* {{{ */ - return gss->compilationOK; -} /* }}} */ - -void -gsl_free (GoomSL * gss) -{ /* {{{ */ - iflow_free (gss->iflow); - free (gss->vars); - free (gss->functions); - free (gss); -} /* }}} */ - - -static int gsl_nb_import; -static char gsl_already_imported[256][256]; - -char * -gsl_init_buffer (const char *fname) -{ - char *fbuffer; - - fbuffer = (char *) malloc (512); - fbuffer[0] = 0; - gsl_nb_import = 0; - if (fname) - gsl_append_file_to_buffer (fname, &fbuffer); - return fbuffer; -} - -static char * -gsl_read_file (const char *fname) -{ - FILE *f; - char *buffer; - int fsize; - - f = fopen (fname, "rt"); - if (!f) { - fprintf (stderr, "ERROR: Could not load file %s\n", fname); - exit (1); - } - fseek (f, 0, SEEK_END); - fsize = ftell (f); - rewind (f); - buffer = (char *) malloc (fsize + 512); - if (fread (buffer, 1, fsize, f) != fsize) { - buffer[0] = '\0'; - } - fclose (f); - buffer[fsize] = 0; - return buffer; -} - -void -gsl_append_file_to_buffer (const char *fname, char **buffer) -{ - char *fbuffer; - int size, fsize, i = 0; - char reset_msg[256]; - - /* look if the file have not been already imported */ - for (i = 0; i < gsl_nb_import; ++i) { - if (strcmp (gsl_already_imported[i], fname) == 0) - return; - } - - /* add fname to the already imported files. */ - strcpy (gsl_already_imported[gsl_nb_import++], fname); - - /* load the file */ - fbuffer = gsl_read_file (fname); - fsize = strlen (fbuffer); - - /* look for #import */ - while (fbuffer[i]) { - if ((fbuffer[i] == '#') && (fbuffer[i + 1] == 'i')) { - char impName[256]; - int j; - - while (fbuffer[i] && (fbuffer[i] != ' ')) - i++; - i++; - j = 0; - while (fbuffer[i] && (fbuffer[i] != '\n')) - impName[j++] = fbuffer[i++]; - impName[j++] = 0; - gsl_append_file_to_buffer (impName, buffer); - } - i++; - } - - sprintf (reset_msg, "\n#FILE %s#\n#RST_LINE#\n", fname); - strcat (*buffer, reset_msg); - size = strlen (*buffer); - *buffer = (char *) realloc (*buffer, size + fsize + 256); - strcat ((*buffer) + size, fbuffer); - free (fbuffer); -} diff --git a/gst/goom/goomsl.h b/gst/goom/goomsl.h deleted file mode 100644 index b9f20d6c..00000000 --- a/gst/goom/goomsl.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _GOOMSL_H -#define _GOOMSL_H - -#include "goomsl_hash.h" - -typedef struct _GoomSL GoomSL; -typedef void (*GoomSL_ExternalFunction)(GoomSL *gsl, GoomHash *global_vars, GoomHash *local_vars); - -GoomSL*gsl_new(void); -void gsl_free(GoomSL *gss); - -char *gsl_init_buffer(const char *file_name); -void gsl_append_file_to_buffer(const char *file_name, char **buffer); - -void gsl_compile (GoomSL *scanner, const char *script); -void gsl_execute (GoomSL *scanner); -int gsl_is_compiled (GoomSL *gss); -void gsl_bind_function(GoomSL *gss, const char *fname, GoomSL_ExternalFunction func); - -int gsl_malloc (GoomSL *_this, int size); -void *gsl_get_ptr (GoomSL *_this, int id); -void gsl_free_ptr(GoomSL *_this, int id); - -GoomHash *gsl_globals(GoomSL *_this); - -#define GSL_LOCAL_PTR(gsl,local,name) gsl_get_ptr(gsl, *(int*)goom_hash_get(local,name)->ptr) -#define GSL_LOCAL_INT(gsl,local,name) (*(int*)goom_hash_get(local,name)->ptr) -#define GSL_LOCAL_FLOAT(gsl,local,name) (*(float*)goom_hash_get(local,name)->ptr) - -#define GSL_GLOBAL_PTR(gsl,name) gsl_get_ptr(gsl, *(int*)goom_hash_get(gsl_globals(gsl),name)->ptr) -#define GSL_GLOBAL_INT(gsl,name) (*(int*)goom_hash_get(gsl_globals(gsl),name)->ptr) -#define GSL_GLOBAL_FLOAT(gsl,name) (*(float*)goom_hash_get(gsl_globals(gsl),name)->ptr) - -#endif diff --git a/gst/goom/goomsl_hash.c b/gst/goom/goomsl_hash.c deleted file mode 100644 index 3ce38a72..00000000 --- a/gst/goom/goomsl_hash.c +++ /dev/null @@ -1,153 +0,0 @@ -#include "goomsl_hash.h" -#include -#include - -static GoomHashEntry * -entry_new (const char *key, HashValue value) -{ - - int len = strlen (key); - GoomHashEntry *entry = (GoomHashEntry *) malloc (sizeof (GoomHashEntry)); - - entry->key = (char *) malloc (len + 1); - memcpy (entry->key, key, len + 1); - entry->value = value; - entry->lower = NULL; - entry->upper = NULL; - - return entry; -} - -static void -entry_free (GoomHashEntry * entry) -{ - if (entry != NULL) { - entry_free (entry->lower); - entry_free (entry->upper); - free (entry->key); - free (entry); - } -} - -static void -entry_put (GoomHashEntry * entry, const char *key, HashValue value) -{ - int cmp = strcmp (key, entry->key); - - if (cmp == 0) { - entry->value = value; - } else if (cmp > 0) { - if (entry->upper == NULL) - entry->upper = entry_new (key, value); - else - entry_put (entry->upper, key, value); - } else { - if (entry->lower == NULL) - entry->lower = entry_new (key, value); - else - entry_put (entry->lower, key, value); - } -} - -static HashValue * -entry_get (GoomHashEntry * entry, const char *key) -{ - - int cmp; - - if (entry == NULL) - return NULL; - cmp = strcmp (key, entry->key); - if (cmp > 0) - return entry_get (entry->upper, key); - else if (cmp < 0) - return entry_get (entry->lower, key); - else - return &(entry->value); -} - -GoomHash * -goom_hash_new () -{ - GoomHash *_this = (GoomHash *) malloc (sizeof (GoomHash)); - - _this->root = NULL; - _this->number_of_puts = 0; - return _this; -} - -void -goom_hash_free (GoomHash * _this) -{ - entry_free (_this->root); - free (_this); -} - -void -goom_hash_put (GoomHash * _this, const char *key, HashValue value) -{ - _this->number_of_puts += 1; - if (_this->root == NULL) - _this->root = entry_new (key, value); - else - entry_put (_this->root, key, value); -} - -HashValue * -goom_hash_get (GoomHash * _this, const char *key) -{ - if (_this == NULL) - return NULL; - return entry_get (_this->root, key); -} - -void -goom_hash_put_int (GoomHash * _this, const char *key, int i) -{ - HashValue value; - - value.i = i; - goom_hash_put (_this, key, value); -} - -void -goom_hash_put_float (GoomHash * _this, const char *key, float f) -{ - HashValue value; - - value.f = f; - goom_hash_put (_this, key, value); -} - -void -goom_hash_put_ptr (GoomHash * _this, const char *key, void *ptr) -{ - HashValue value; - - value.ptr = ptr; - goom_hash_put (_this, key, value); -} - -/* FOR EACH */ - -static void -_goom_hash_for_each (GoomHash * _this, GoomHashEntry * entry, GH_Func func) -{ - if (entry == NULL) - return; - func (_this, entry->key, &(entry->value)); - _goom_hash_for_each (_this, entry->lower, func); - _goom_hash_for_each (_this, entry->upper, func); -} - -void -goom_hash_for_each (GoomHash * _this, GH_Func func) -{ - _goom_hash_for_each (_this, _this->root, func); -} - -int -goom_hash_number_of_puts (GoomHash * _this) -{ - return _this->number_of_puts; -} diff --git a/gst/goom/goomsl_hash.h b/gst/goom/goomsl_hash.h deleted file mode 100644 index 26f45167..00000000 --- a/gst/goom/goomsl_hash.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _GOOMSL_HASH_H -#define _GOOMSL_HASH_H - -typedef struct GOOM_HASH_ENTRY GoomHashEntry; -typedef struct GOOM_HASH GoomHash; - -typedef union { - void *ptr; - int i; - float f; -} HashValue; - -struct GOOM_HASH_ENTRY { - char *key; - HashValue value; - GoomHashEntry *lower; - GoomHashEntry *upper; -}; - -struct GOOM_HASH { - GoomHashEntry *root; - int number_of_puts; -}; - -GoomHash *goom_hash_new(); -void goom_hash_free(GoomHash *gh); - -void goom_hash_put(GoomHash *gh, const char *key, HashValue value); -HashValue *goom_hash_get(GoomHash *gh, const char *key); - -void goom_hash_put_int (GoomHash *_this, const char *key, int i); -void goom_hash_put_float(GoomHash *_this, const char *key, float f); -void goom_hash_put_ptr (GoomHash *_this, const char *key, void *ptr); - -typedef void (*GH_Func)(GoomHash *caller, const char *key, HashValue *value); - -void goom_hash_for_each(GoomHash *_this, GH_Func func); -int goom_hash_number_of_puts(GoomHash *_this); - -#endif /* _GOOM_HASH_H */ diff --git a/gst/goom/goomsl_heap.c b/gst/goom/goomsl_heap.c deleted file mode 100644 index e418a2af..00000000 --- a/gst/goom/goomsl_heap.c +++ /dev/null @@ -1,126 +0,0 @@ -#include "goomsl_heap.h" -#include - -struct _GOOM_HEAP -{ - void **arrays; - int number_of_arrays; - int size_of_each_array; - int consumed_in_last_array; -}; - -/* Constructors / Destructor */ -GoomHeap * -goom_heap_new (void) -{ - return goom_heap_new_with_granularity (4096); -} - -GoomHeap * -goom_heap_new_with_granularity (int granularity) -{ - GoomHeap *_this; - - _this = (GoomHeap *) malloc (sizeof (GoomHeap)); - _this->number_of_arrays = 0; - _this->size_of_each_array = granularity; - _this->consumed_in_last_array = 0; - _this->arrays = (void **) malloc (sizeof (void *)); - return _this; -} - -void -goom_heap_delete (GoomHeap * _this) -{ - int i; - - for (i = 0; i < _this->number_of_arrays; ++i) { - free (_this->arrays[i]); - } - free (_this->arrays); - free (_this); -} - -static void -align_it (GoomHeap * _this, int alignment) -{ - if ((alignment > 1) && (_this->number_of_arrays > 0)) { - void *last_array = _this->arrays[_this->number_of_arrays - 1]; - long last_address = (long) last_array + _this->consumed_in_last_array; - long decal = (last_address % alignment); - - if (decal != 0) { - _this->consumed_in_last_array += alignment - decal; - } - } -} - -void * -goom_heap_malloc_with_alignment_prefixed (GoomHeap * _this, int nb_bytes, - int alignment, int prefix_bytes) -{ - void *retval = NULL; - - /* d'abord on gere les problemes d'alignement */ - _this->consumed_in_last_array += prefix_bytes; - align_it (_this, alignment); - - /* ensuite on verifie que la quantite de memoire demandee tient dans le buffer */ - if ((_this->consumed_in_last_array + nb_bytes >= _this->size_of_each_array) - || (_this->number_of_arrays == 0)) { - - if (prefix_bytes + nb_bytes + alignment >= _this->size_of_each_array) { - - /* Si la zone demandee est plus grosse que la granularitee */ - /* On alloue un buffer plus gros que les autres */ - _this->arrays = - (void **) realloc (_this->arrays, - sizeof (void *) * (_this->number_of_arrays + 2)); - - _this->number_of_arrays += 1; - _this->consumed_in_last_array = prefix_bytes; - - _this->arrays[_this->number_of_arrays - 1] = - malloc (prefix_bytes + nb_bytes + alignment); - align_it (_this, alignment); - retval = - (void *) ((char *) _this->arrays[_this->number_of_arrays - 1] + - _this->consumed_in_last_array); - - /* puis on repart sur un nouveau buffer vide */ - _this->number_of_arrays += 1; - _this->consumed_in_last_array = 0; - _this->arrays[_this->number_of_arrays - 1] = - malloc (_this->size_of_each_array); - return retval; - } else { - _this->number_of_arrays += 1; - _this->consumed_in_last_array = prefix_bytes; - _this->arrays = - (void **) realloc (_this->arrays, - sizeof (void *) * _this->number_of_arrays); - - _this->arrays[_this->number_of_arrays - 1] = - malloc (_this->size_of_each_array); - align_it (_this, alignment); - } - } - retval = - (void *) ((char *) _this->arrays[_this->number_of_arrays - 1] + - _this->consumed_in_last_array); - _this->consumed_in_last_array += nb_bytes; - return retval; -} - -void * -goom_heap_malloc_with_alignment (GoomHeap * _this, int nb_bytes, int alignment) -{ - return goom_heap_malloc_with_alignment_prefixed (_this, nb_bytes, alignment, - 0); -} - -void * -goom_heap_malloc (GoomHeap * _this, int nb_bytes) -{ - return goom_heap_malloc_with_alignment (_this, nb_bytes, 1); -} diff --git a/gst/goom/goomsl_heap.h b/gst/goom/goomsl_heap.h deleted file mode 100644 index a22bac69..00000000 --- a/gst/goom/goomsl_heap.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef GOOMSL_HEAP -#define GOOMSL_HEAP - -/** - * Resizable Array that guarranty that resizes don't change address of - * the stored datas. - * - * This is implemented as an array of arrays... granularity is the size - * of each arrays. - */ - -typedef struct _GOOM_HEAP GoomHeap; - -/* Constructors / Destructor */ -GoomHeap *goom_heap_new(void); -GoomHeap *goom_heap_new_with_granularity(int granularity); -void goom_heap_delete(GoomHeap *_this); - -/* This method behaves like malloc. */ -void *goom_heap_malloc(GoomHeap *_this, int nb_bytes); -/* This adds an alignment constraint. */ -void *goom_heap_malloc_with_alignment(GoomHeap *_this, int nb_bytes, int alignment); - -/* Returns a pointeur on the bytes... prefix is before */ -void *goom_heap_malloc_with_alignment_prefixed(GoomHeap *_this, int nb_bytes, - int alignment, int prefix_bytes); - -#endif - diff --git a/gst/goom/goomsl_private.h b/gst/goom/goomsl_private.h deleted file mode 100644 index 8be15157..00000000 --- a/gst/goom/goomsl_private.h +++ /dev/null @@ -1,251 +0,0 @@ -#ifndef _GSL_PRIVATE_H -#define _GSL_PRIVATE_H - -/* -- internal use -- */ - -#include "goomsl.h" - -#ifdef USE_JITC_X86 -#include "jitc_x86.h" -#endif - -#include "goomsl_heap.h" - -/* {{{ type of nodes */ -#define EMPTY_NODE 0 -#define CONST_INT_NODE 1 -#define CONST_FLOAT_NODE 2 -#define CONST_PTR_NODE 3 -#define VAR_NODE 4 -#define PARAM_NODE 5 -#define READ_PARAM_NODE 6 -#define OPR_NODE 7 -/* }}} */ -/* {{{ type of operations */ -#define OPR_SET 1 -#define OPR_IF 2 -#define OPR_WHILE 3 -#define OPR_BLOCK 4 -#define OPR_ADD 5 -#define OPR_MUL 6 -#define OPR_EQU 7 -#define OPR_NOT 8 -#define OPR_LOW 9 -#define OPR_DIV 10 -#define OPR_SUB 11 -#define OPR_FUNC_INTRO 12 -#define OPR_FUNC_OUTRO 13 -#define OPR_CALL 14 -#define OPR_EXT_CALL 15 -#define OPR_PLUS_EQ 16 -#define OPR_SUB_EQ 17 -#define OPR_MUL_EQ 18 -#define OPR_DIV_EQ 19 -#define OPR_CALL_EXPR 20 -#define OPR_AFFECT_LIST 21 -#define OPR_FOREACH 22 -#define OPR_VAR_LIST 23 - -/* }}} */ - -typedef struct _ConstIntNodeType { /* {{{ */ - int val; -} ConstIntNodeType; /* }}} */ -typedef struct _ConstFloatNodeType { /* {{{ */ - float val; -} ConstFloatNodeType; /* }}} */ -typedef struct _ConstPtrNodeType { /* {{{ */ - int id; -} ConstPtrNodeType; /* }}} */ -typedef struct _OprNodeType { /* {{{ */ - int type; - int nbOp; - struct _NODE_TYPE *op[3]; /* maximal number of operand needed */ - struct _NODE_TYPE *next; -} OprNodeType; /* }}} */ -typedef struct _NODE_TYPE { /* {{{ */ - int type; - char *str; - GoomHash *vnamespace; - int line_number; - union { - ConstIntNodeType constInt; - ConstFloatNodeType constFloat; - ConstPtrNodeType constPtr; - OprNodeType opr; - } unode; -} NodeType; /* }}} */ -typedef struct _INSTRUCTION_DATA { /* {{{ */ - - union { - void *var; - int *var_int; - int *var_ptr; - float *var_float; - int jump_offset; - struct _ExternalFunctionStruct *external_function; - } udest; - - union { - void *var; - int *var_int; - int *var_ptr; - float *var_float; - int value_int; - int value_ptr; - float value_float; - } usrc; -} InstructionData; -/* }}} */ -typedef struct _INSTRUCTION { /* {{{ */ - - int id; - InstructionData data; - GoomSL *parent; - const char *name; /* name of the instruction */ - - char **params; /* parametres de l'instruction */ - GoomHash **vnamespace; - int *types; /* type des parametres de l'instruction */ - int cur_param; - int nb_param; - - int address; - char *jump_label; - char *nop_label; - - int line_number; - -} Instruction; -/* }}} */ -typedef struct _INSTRUCTION_FLOW { /* {{{ */ - - Instruction **instr; - int number; - int tabsize; - GoomHash *labels; -} InstructionFlow; -/* }}} */ -typedef struct _FAST_INSTRUCTION { /* {{{ */ - int id; - InstructionData data; - Instruction *proto; -} FastInstruction; -/* }}} */ -typedef struct _FastInstructionFlow { /* {{{ */ - int number; - FastInstruction *instr; - void *mallocedInstr; -} FastInstructionFlow; -/* }}} */ -typedef struct _ExternalFunctionStruct { /* {{{ */ - GoomSL_ExternalFunction function; - GoomHash *vars; - int is_extern; -} ExternalFunctionStruct; -/* }}} */ -typedef struct _Block { - int data; - int size; -} Block; -typedef struct _GSL_StructField { /* {{{ */ - int type; - char name[256]; - int offsetInStruct; /* Where this field is stored... */ -} GSL_StructField; - /* }}} */ -typedef struct _GSL_Struct { /* {{{ */ - int nbFields; - GSL_StructField *fields[64]; - int size; - Block iBlock[64]; - Block fBlock[64]; -} GSL_Struct; - /* }}} */ -struct _GoomSL { /* {{{ */ - int num_lines; - Instruction *instr; /* instruction en cours de construction */ - - InstructionFlow *iflow; /* flow d'instruction 'normal' */ - FastInstructionFlow *fastiflow; /* flow d'instruction optimise */ - - GoomHash *vars; /* table de variables */ - int currentNS; - GoomHash *namespaces[16]; - - GoomHash *functions; /* table des fonctions externes */ - - GoomHeap *data_heap; /* GSL Heap-like memory space */ - - int nbStructID; - GoomHash *structIDS; - GSL_Struct **gsl_struct; - int gsl_struct_size; - - int nbPtr; - int ptrArraySize; - void **ptrArray; - - int compilationOK; -#ifdef USE_JITC_X86 - JitcX86Env *jitc; - JitcFunc jitc_func; -#endif -}; /* }}} */ - -extern GoomSL *currentGoomSL; - -Instruction *gsl_instr_init(GoomSL *parent, const char *name, int id, int nb_param, int line_number); -void gsl_instr_add_param(Instruction *_this, char *param, int type); -void gsl_instr_set_namespace(Instruction *_this, GoomHash *ns); - -void gsl_declare_task(const char *name); -void gsl_declare_external_task(const char *name); - -int gsl_type_of_var(GoomHash *namespace, const char *name); - -void gsl_enternamespace(const char *name); -void gsl_reenternamespace(GoomHash *ns); -GoomHash *gsl_leavenamespace(void); -GoomHash *gsl_find_namespace(const char *name); - -void gsl_commit_compilation(void); - -/* #define TYPE_PARAM 1 */ - -#define FIRST_RESERVED 0x80000 - -#define TYPE_INTEGER 0x90001 -#define TYPE_FLOAT 0x90002 -#define TYPE_VAR 0x90003 -#define TYPE_PTR 0x90004 -#define TYPE_LABEL 0x90005 - -#define TYPE_OP_EQUAL 6 -#define TYPE_IVAR 0xa0001 -#define TYPE_FVAR 0xa0002 -#define TYPE_PVAR 0xa0003 -#define TYPE_SVAR 0xa0004 - -#define INSTR_JUMP 6 -#define INSTR_JZERO 29 -#define INSTR_CALL 36 -#define INSTR_RET 37 -#define INSTR_EXT_CALL 38 -#define INSTR_JNZERO 40 - -#define INSTR_SET 0x80001 -#define INSTR_INT 0x80002 -#define INSTR_FLOAT 0x80003 -#define INSTR_PTR 0x80004 -#define INSTR_LABEL 0x80005 -#define INSTR_ISLOWER 0x80006 -#define INSTR_ADD 0x80007 -#define INSTR_MUL 0x80008 -#define INSTR_DIV 0x80009 -#define INSTR_SUB 0x80010 -#define INSTR_ISEQUAL 0x80011 -#define INSTR_NOT 0x80012 - - -#endif diff --git a/gst/goom/plugin_info.c b/gst/goom/plugin_info.c index cb2f58b2..7ef1a715 100644 --- a/gst/goom/plugin_info.c +++ b/gst/goom/plugin_info.c @@ -8,7 +8,6 @@ #include "goom_plugin_info.h" #include "goom_fx.h" -#include "default_scripts.h" #include "drawmethods.h" #include #include @@ -196,10 +195,6 @@ plugin_info_init (PluginInfo * pp, int nbVisuals) setOptimizedMethods (pp); - pp->scanner = gsl_new (); - pp->main_scanner = gsl_new (); - pp->main_script_str = GOOM_MAIN_SCRIPT; - for (i = 0; i < 0xffff; i++) { pp->sintable[i] = (int) (1024 * sin ((double) i * 360 / (sizeof (pp->sintable) / -- cgit