diff options
33 files changed, 614 insertions, 397 deletions
@@ -13,7 +13,7 @@ project version mediator ----------------------------------------------------------------------- ffmpeg build 4715 Mike Melanson -goom 2k4-dev15 +goom 2k4-dev18 gsm610 1.0.10 Mike Melanson liba52 0.7.4 libcdio 0.68 @@ -4,7 +4,7 @@ xine-lib (1-rc6) * remove XInitThreads() call from some video out plugins, because it might lead to undefined behaviour; calling XInitThreads() is entirely the frontend's job - * include goom2k4-dev15 + * include goom2k4-dev18 * make sure the streams are played till their very end * support for Annodex files * VobSub-in-Matroska support diff --git a/src/post/goom/Makefile.am b/src/post/goom/Makefile.am index 9d0db451a..69891f709 100644 --- a/src/post/goom/Makefile.am +++ b/src/post/goom/Makefile.am @@ -22,17 +22,14 @@ endif xineplug_post_goom_la_SOURCES = $(extra_files) xine_goom.c \ config_param.c convolve_fx.c cpu_info.c drawmethods.c filters.c flying_stars_fx.c \ - gfontlib.c gfontrle.c goom_core.c goom_hash.c goom_script.c goom_script_scanner.c \ - goom_script_scanner.tab.c goom_tools.c graphic.c ifs.c lines.c mathtools.c \ + gfontlib.c gfontrle.c goom_core.c goom_hash.c goom_script.c goom_script_lex.c \ + goom_script_yacc.c goom_tools.c graphic.c ifs.c lines.c mathtools.c \ plugin_info.c sound_tester.c surf3d.c tentacle3d.c v3d.c xineplug_post_goom_la_LIBADD = $(XINE_LIB) xineplug_post_goom_la_LDFLAGS = -avoid-version -module $(XINE_PLUGIN_MIN_SYMS) noinst_HEADERS = cpu_info.h default_scripts.h drawmethods.h gfontlib.h gfontrle.h goom.h \ goom_config.h goom_config_param.h goom_filters.h goom_fx.h goom_graphic.h goom_hash.h \ - goom_plugin_info.h goom_script.h goom_script_scanner.h goom_script_scanner.tab.h \ + goom_plugin_info.h goom_script.h goom_script_scanner.h goom_script_yacc.h \ goom_tools.h goom_typedefs.h goom_visual_fx.h ifs.h lines.h mathtools.h mmx.h \ ppc_drawings.h ppc_zoom_ultimate.h sound_tester.h surf3d.h tentacle3d.h v3d.h - -# automake will delete goom_script_scanner.tab.c without the line below -distclean-compile: diff --git a/src/post/goom/config_param.c b/src/post/goom/config_param.c index a88adec39..2be4bafc9 100644 --- a/src/post/goom/config_param.c +++ b/src/post/goom/config_param.c @@ -11,7 +11,7 @@ #include "goom_config_param.h" #include <string.h> -void empty_fct() { +static void empty_fct(PluginParam *dummy) { } PluginParam secure_param() { diff --git a/src/post/goom/convolve_fx.c b/src/post/goom/convolve_fx.c index 518875824..c73b541f9 100644 --- a/src/post/goom/convolve_fx.c +++ b/src/post/goom/convolve_fx.c @@ -8,10 +8,19 @@ #include <string.h> static const char DEF_SCRIPT[] = -"float goom = Sound.Goom_Detection;\n" -"float factor = Bright_Flash.Factor;\n" -"(0.8 < goom)? factor = factor + Sound.Goom_Power * 1.5;\n" -"Bright_Flash.Factor = factor * 0.96;\n"; +"-> config;\n" +"-> main;\n" +"\n" +"<config>\n" +" float INCREASE_RATE = 150%;\n" +" float DECAY_RATE = 96%;\n" +"\n" +"<main>\n" +" (Sound.Goom_Detection > 0.8) ?\n" +" Bright_Flash.Factor = Bright_Flash.Factor + Sound.Goom_Power * INCREASE_RATE;\n" +"\n" +" Bright_Flash.Factor = Bright_Flash.Factor * DECAY_RATE;\n" +"\n"; #define MAX 2.0f @@ -123,7 +132,7 @@ static void convolve_apply(VisualFX *_this, Pixel *src, Pixel *dest, PluginInfo info->methods.create_output_with_brightness(src,dest,info->screen.size,iff); } -VisualFX convolve_create() { +VisualFX convolve_create(void) { VisualFX vfx = { init: convolve_init, free: convolve_free, diff --git a/src/post/goom/cpu_info.c b/src/post/goom/cpu_info.c index d392ee3d3..2ebca754b 100644 --- a/src/post/goom/cpu_info.c +++ b/src/post/goom/cpu_info.c @@ -8,6 +8,7 @@ */ #include "cpu_info.h" +#include "mmx.h" static unsigned int CPU_FLAVOUR = 0; diff --git a/src/post/goom/filters.c b/src/post/goom/filters.c index d4633ed2b..92fb16bc6 100644 --- a/src/post/goom/filters.c +++ b/src/post/goom/filters.c @@ -24,11 +24,12 @@ #include "goom_graphic.h" #include "goom_tools.h" #include "goom_plugin_info.h" +#include "goom_fx.h" #include "v3d.h" /* TODO : MOVE THIS AWAY !!! */ /* jeko: j'ai essayer de le virer, mais si on veut les laisser inline c'est un peu lourdo... */ -inline void setPixelRGB (PluginInfo *goomInfo, Pixel *buffer, Uint x, Uint y, Color c) +static inline void setPixelRGB (PluginInfo *goomInfo, Pixel *buffer, Uint x, Uint y, Color c) { Pixel i; @@ -38,14 +39,14 @@ inline void setPixelRGB (PluginInfo *goomInfo, Pixel *buffer, Uint x, Uint y, Co *(buffer + (x + y * goomInfo->screen.width)) = i; } -inline void setPixelRGB_ (Pixel *buffer, Uint x, Color c) +static inline void setPixelRGB_ (Pixel *buffer, Uint x, Color c) { buffer[x].channels.r = c.r; buffer[x].channels.g = c.v; buffer[x].channels.b = c.b; } -inline void getPixelRGB (PluginInfo *goomInfo, Pixel *buffer, Uint x, Uint y, Color * c) +static inline void getPixelRGB (PluginInfo *goomInfo, Pixel *buffer, Uint x, Uint y, Color * c) { Pixel i = *(buffer + (x + y * goomInfo->screen.width)); c->b = i.channels.b; @@ -53,7 +54,7 @@ inline void getPixelRGB (PluginInfo *goomInfo, Pixel *buffer, Uint x, Uint y, Co c->r = i.channels.r; } -inline void getPixelRGB_ (Pixel *buffer, Uint x, Color * c) +static inline void getPixelRGB_ (Pixel *buffer, Uint x, Color * c) { Pixel i = *(buffer + x); c->b = i.channels.b; @@ -137,7 +138,7 @@ typedef struct _ZOOM_FILTER_FX_WRAPPER_DATA { -inline v2g zoomVector(ZoomFilterFXWrapperData *data, float X, float Y) +static inline v2g zoomVector(ZoomFilterFXWrapperData *data, float X, float Y) { v2g vecteur; float vx, vy; @@ -234,7 +235,7 @@ inline v2g zoomVector(ZoomFilterFXWrapperData *data, float X, float Y) * Translation (-data->middleX, -data->middleY) * Homothetie (Center : 0,0 Coeff : 2/data->prevX) */ -void makeZoomBufferStripe(ZoomFilterFXWrapperData * data, int INTERLACE_INCR) +static void makeZoomBufferStripe(ZoomFilterFXWrapperData * data, int INTERLACE_INCR) { // Position of the pixel to compute in pixmap coordinates Uint x, y; @@ -684,7 +685,7 @@ static void generatePrecalCoef (int precalCoef[16][16]) /* VisualFX Wrapper */ -void zoomFilterVisualFXWrapper_init (struct _VISUAL_FX *_this) +static void zoomFilterVisualFXWrapper_init (struct _VISUAL_FX *_this) { ZoomFilterFXWrapperData *data = (ZoomFilterFXWrapperData*)malloc(sizeof(ZoomFilterFXWrapperData)); @@ -729,16 +730,16 @@ void zoomFilterVisualFXWrapper_init (struct _VISUAL_FX *_this) generatePrecalCoef(data->precalCoef); } -void zoomFilterVisualFXWrapper_free (struct _VISUAL_FX *_this) +static void zoomFilterVisualFXWrapper_free (struct _VISUAL_FX *_this) { free(_this->fx_data); } -void zoomFilterVisualFXWrapper_apply (struct _VISUAL_FX *_this, Pixel *src, Pixel *dest, PluginInfo *info) +static void zoomFilterVisualFXWrapper_apply (struct _VISUAL_FX *_this, Pixel *src, Pixel *dest, PluginInfo *info) { } -VisualFX zoomFilterVisualFXWrapper_create() +VisualFX zoomFilterVisualFXWrapper_create(void) { VisualFX fx; fx.init = zoomFilterVisualFXWrapper_init; diff --git a/src/post/goom/flying_stars_fx.c b/src/post/goom/flying_stars_fx.c index 72231e9c8..ff1d5b9b6 100644 --- a/src/post/goom/flying_stars_fx.c +++ b/src/post/goom/flying_stars_fx.c @@ -269,7 +269,7 @@ static void fs_apply(VisualFX *_this, Pixel *src, Pixel *dest, PluginInfo *info) } } -VisualFX flying_star_create() { +VisualFX flying_star_create(void) { VisualFX vfx = { init: fs_init, free: fs_free, diff --git a/src/post/goom/gfontlib.c b/src/post/goom/gfontlib.c index 960ca43b9..710c23520 100755 --- a/src/post/goom/gfontlib.c +++ b/src/post/goom/gfontlib.c @@ -11,7 +11,7 @@ static Pixel ***small_font_chars; static int *small_font_width; static int *small_font_height; -void gfont_load () { +void gfont_load (void) { unsigned char *gfont; unsigned int i = 0, j = 0; unsigned int nba = 0; diff --git a/src/post/goom/gfontlib.h b/src/post/goom/gfontlib.h index f5b82917b..0520b7da9 100755 --- a/src/post/goom/gfontlib.h +++ b/src/post/goom/gfontlib.h @@ -3,7 +3,7 @@ #include "goom_graphic.h" -void gfont_load (); +void gfont_load (void); void goom_draw_text (Pixel * buf,int resolx,int resoly, int x, int y, const char *str, float chspace, int center); diff --git a/src/post/goom/goom_config_param.h b/src/post/goom/goom_config_param.h index bd8753e7e..cfa16917b 100644 --- a/src/post/goom/goom_config_param.h +++ b/src/post/goom/goom_config_param.h @@ -1,5 +1,5 @@ -#ifndef _GOOM_CONFIG_PARAM_H -#define _GOOM_CONFIG_PARAM_H +#ifndef _CONFIG_PARAM_H +#define _CONFIG_PARAM_H #include <stdlib.h> @@ -79,9 +79,7 @@ typedef struct _PARAM { #define IMAX(p) ((p).param.ival.max) #define ISTEP(p) ((p).param.ival.step) -void empty_fct(); - -PluginParam secure_param(); +PluginParam secure_param(void); PluginParam secure_f_param(char *name); PluginParam secure_i_param(char *name); diff --git a/src/post/goom/goom_filters.h b/src/post/goom/goom_filters.h index bf64c166a..f015499a8 100644 --- a/src/post/goom/goom_filters.h +++ b/src/post/goom/goom_filters.h @@ -1,12 +1,12 @@ -#ifndef _GOOM_FILTERS_H -#define _GOOM_FILTERS_H +#ifndef FILTERS_H +#define FILTERS_H #include "goom_config.h" #include "goom_typedefs.h" #include "goom_visual_fx.h" #include "goom_graphic.h" -VisualFX zoomFilterVisualFXWrapper_create(); +VisualFX zoomFilterVisualFXWrapper_create(void); struct _ZOOM_FILTER_DATA { diff --git a/src/post/goom/goom_fx.h b/src/post/goom/goom_fx.h index 0a0e1287b..fec5e2b40 100644 --- a/src/post/goom/goom_fx.h +++ b/src/post/goom/goom_fx.h @@ -4,7 +4,10 @@ #include "goom_visual_fx.h" #include "goom_plugin_info.h" -VisualFX convolve_create (); -VisualFX flying_star_create (); +VisualFX convolve_create (void); +VisualFX flying_star_create (void); + +void zoom_filter_c(int sizeX, int sizeY, Pixel *src, Pixel *dest, int *brutS, int *brutD, int buffratio, int precalCoef[16][16]); +void create_output_with_brightness(Pixel *src, Pixel *dest, int screensize, int iff); #endif diff --git a/src/post/goom/goom_graphic.h b/src/post/goom/goom_graphic.h index 8f0a12c49..1d78f1d4e 100644 --- a/src/post/goom/goom_graphic.h +++ b/src/post/goom/goom_graphic.h @@ -1,5 +1,5 @@ -#ifndef _GOOM_GRAPHIC_H -#define _GOOM_GRAPHIC_H +#ifndef GRAPHIC_H +#define GRAPHIC_H typedef unsigned int Uint; @@ -63,4 +63,4 @@ inline void getPixelRGB (Pixel * buffer, Uint x, Uint y, Color * c); */ -#endif /* _GOOM_GRAPHIC_H */ +#endif /* GRAPHIC_H */ diff --git a/src/post/goom/goom_hash.c b/src/post/goom/goom_hash.c index 09052ed90..f21a6d6c3 100644 --- a/src/post/goom/goom_hash.c +++ b/src/post/goom/goom_hash.c @@ -57,7 +57,7 @@ static HashValue *entry_get(GoomHashEntry *entry, const char *key) { return &(entry->value); } -GoomHash *goom_hash_new() { +GoomHash *goom_hash_new(void) { GoomHash *_this = (GoomHash*)malloc(sizeof(GoomHash)); _this->root = NULL; return _this; diff --git a/src/post/goom/goom_hash.h b/src/post/goom/goom_hash.h index c869e67e4..c8eae37ed 100644 --- a/src/post/goom/goom_hash.h +++ b/src/post/goom/goom_hash.h @@ -21,7 +21,7 @@ struct GOOM_HASH { GoomHashEntry *root; }; -GoomHash *goom_hash_new(); +GoomHash *goom_hash_new(void); void goom_hash_free(GoomHash *gh); void goom_hash_put(GoomHash *gh, const char *key, HashValue value); diff --git a/src/post/goom/goom_plugin_info.h b/src/post/goom/goom_plugin_info.h index c28df65dd..1ec562e39 100644 --- a/src/post/goom/goom_plugin_info.h +++ b/src/post/goom/goom_plugin_info.h @@ -1,5 +1,5 @@ -#ifndef _GOOM_PLUGIN_INFO_H -#define _GOOM_PLUGIN_INFO_H +#ifndef _PLUGIN_INFO_H +#define _PLUGIN_INFO_H #include "goom_typedefs.h" diff --git a/src/post/goom/goom_script.h b/src/post/goom/goom_script.h index 8b5bfb648..ca1cb5665 100644 --- a/src/post/goom/goom_script.h +++ b/src/post/goom/goom_script.h @@ -12,5 +12,6 @@ void goom_execute_main_script(PluginInfo *pluginInfo); /* return a script containing the current goom state */ char *goom_create_state_script(PluginInfo *pluginInfo); +PluginParam *goom_script_get_param(PluginInfo *pluginInfo, const char *name); #endif /* _GOOM_SCRIPT_H */ diff --git a/src/post/goom/goom_script_scanner.c b/src/post/goom/goom_script_lex.c index 5aec843b4..f50882d29 100644 --- a/src/post/goom/goom_script_scanner.c +++ b/src/post/goom/goom_script_lex.c @@ -1,6 +1,5 @@ -#line 2 "goom_script_scanner.c" -#line 4 "goom_script_scanner.c" +#line 3 "lex.yy.c" #define YY_INT_ALIGNED short int @@ -352,8 +351,8 @@ static void yy_fatal_error (yyconst char msg[] ); *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 14 -#define YY_END_OF_BUFFER 15 +#define YY_NUM_RULES 15 +#define YY_END_OF_BUFFER 16 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -361,12 +360,12 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[35] = +static yyconst flex_int16_t yy_accept[36] = { 0, - 0, 0, 0, 0, 15, 13, 12, 1, 13, 13, - 9, 8, 8, 8, 3, 3, 12, 9, 4, 11, - 10, 0, 8, 8, 8, 2, 10, 7, 8, 6, - 7, 8, 5, 0 + 0, 0, 0, 0, 16, 14, 13, 1, 14, 14, + 10, 9, 9, 9, 3, 3, 13, 10, 7, 4, + 12, 11, 0, 9, 9, 9, 2, 11, 8, 9, + 6, 8, 9, 5, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -377,14 +376,14 @@ static yyconst flex_int32_t yy_ec[256] = 1, 2, 1, 1, 1, 1, 4, 1, 1, 1, 1, 5, 1, 1, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, - 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 1, 1, 1, 1, 10, 1, 11, 10, 10, 10, - - 10, 12, 10, 10, 13, 10, 10, 14, 10, 15, - 16, 10, 10, 10, 10, 17, 10, 10, 10, 10, - 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 10, 1, 1, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 1, 1, 1, 1, 11, 1, 12, 11, 11, 11, + + 11, 13, 11, 11, 14, 11, 11, 15, 11, 16, + 17, 11, 11, 11, 11, 18, 11, 11, 11, 11, + 11, 11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -401,50 +400,50 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[18] = +static yyconst flex_int32_t yy_meta[19] = { 0, - 1, 1, 1, 1, 1, 1, 2, 1, 3, 4, - 4, 4, 4, 4, 4, 4, 4 + 1, 1, 1, 1, 1, 1, 2, 1, 3, 1, + 4, 4, 4, 4, 4, 4, 4, 4 } ; -static yyconst flex_int16_t yy_base[39] = +static yyconst flex_int16_t yy_base[40] = { 0, - 0, 0, 15, 16, 57, 58, 54, 58, 46, 49, - 18, 46, 16, 17, 58, 44, 49, 0, 58, 58, - 41, 0, 42, 19, 21, 58, 39, 0, 22, 30, - 0, 19, 17, 58, 38, 41, 27, 43 + 0, 0, 16, 17, 59, 60, 56, 60, 14, 52, + 21, 49, 19, 20, 60, 47, 52, 0, 60, 60, + 60, 44, 0, 45, 22, 24, 60, 32, 0, 25, + 33, 0, 20, 17, 60, 42, 45, 29, 47 } ; -static yyconst flex_int16_t yy_def[39] = +static yyconst flex_int16_t yy_def[40] = { 0, - 34, 1, 35, 35, 34, 34, 34, 34, 34, 34, - 34, 36, 36, 36, 34, 34, 34, 11, 34, 34, - 34, 37, 36, 36, 36, 34, 34, 38, 36, 36, - 38, 25, 25, 0, 34, 34, 34, 34 + 35, 1, 36, 36, 35, 35, 35, 35, 35, 35, + 35, 37, 37, 37, 35, 35, 35, 11, 35, 35, + 35, 35, 38, 37, 37, 37, 35, 35, 39, 37, + 37, 39, 26, 26, 0, 35, 35, 35, 35 } ; -static yyconst flex_int16_t yy_nxt[76] = +static yyconst flex_int16_t yy_nxt[79] = { 0, - 6, 7, 8, 6, 6, 9, 6, 10, 11, 12, - 12, 13, 14, 12, 12, 12, 12, 8, 8, 16, - 16, 20, 22, 22, 21, 22, 18, 22, 22, 24, - 28, 25, 32, 23, 29, 33, 22, 30, 15, 15, - 15, 15, 23, 23, 23, 31, 31, 27, 22, 27, - 17, 26, 22, 19, 18, 17, 34, 5, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34 + 6, 7, 8, 6, 6, 9, 6, 10, 11, 6, + 12, 12, 13, 14, 12, 12, 12, 12, 8, 8, + 16, 16, 18, 19, 21, 23, 23, 22, 23, 18, + 23, 23, 29, 25, 24, 26, 33, 34, 30, 23, + 28, 31, 15, 15, 15, 15, 24, 24, 24, 32, + 32, 23, 28, 17, 27, 23, 20, 17, 35, 5, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35 } ; -static yyconst flex_int16_t yy_chk[76] = +static yyconst flex_int16_t yy_chk[79] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 4, 3, - 4, 11, 13, 14, 11, 24, 11, 25, 29, 13, - 37, 14, 29, 33, 24, 32, 30, 25, 35, 35, - 35, 35, 36, 36, 36, 38, 38, 27, 23, 21, - 17, 16, 12, 10, 9, 7, 5, 34, 34, 34, - 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 34, 34 + 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, + 3, 4, 9, 9, 11, 13, 14, 11, 25, 11, + 26, 30, 38, 13, 34, 14, 30, 33, 25, 31, + 28, 26, 36, 36, 36, 36, 37, 37, 37, 39, + 39, 24, 22, 17, 16, 12, 10, 7, 5, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35 } ; static yy_state_type yy_last_accepting_state; @@ -461,14 +460,14 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "goom_script_scanner.lex" -#line 2 "goom_script_scanner.lex" +#line 1 "goom_script_lex.l" +#line 2 "goom_script_lex.l" #include <math.h> #include <stdlib.h> #include <string.h> #include "goom_script_scanner.h" -#include "goom_script_scanner.tab.h" +#include "goom_script_yacc.h" void yyerror(char *); void yyparse(); @@ -503,6 +502,12 @@ void yyparse(); #define INSTR_ISEQUALI_VAR_VAR 27 #define INSTR_ISEQUALI_VAR_INTEGER 28 /* #define INSTR_JZERO 29 */ +#define INSTR_DIVF_VAR_FLOAT 30 +#define INSTR_DIVF_VAR_VAR 31 +#define INSTR_SUBF_VAR_FLOAT 32 +#define INSTR_SUBF_VAR_VAR 33 +/* #define INSTR_CALL 34 */ +/* #define INSTR_RET 35 */ #define VALIDATE_OK "ok" #define VALIDATE_ERROR "error while validating" @@ -514,7 +519,7 @@ void yyparse(); #define VALIDATE_NO_SUCH_DEST_VAR "no such destination variable" #define VALIDATE_NO_SUCH_SRC_VAR "no such src variable" - PluginParam *goom_script_get_param(PluginInfo *pluginInfo, const char *name); +#include "goom_script.h" /* ------------- SCRIPT_EXEC_ENV ------------ */ @@ -526,7 +531,7 @@ void yyparse(); /* ----------- INSTRUCTION_FLOW ------------- */ - static InstructionFlow *iflow_new(); + static InstructionFlow *iflow_new(void); static void iflow_add_instr(InstructionFlow *_this, Instruction *instr); static void iflow_clean(InstructionFlow *_this); static void iflow_execute(InstructionFlow *_this, ScriptExecEnv *exec_env); @@ -540,7 +545,7 @@ void yyparse(); _this->labels = goom_hash_new(); } - InstructionFlow *iflow_new() { + InstructionFlow *iflow_new(void) { InstructionFlow *_this = (InstructionFlow*)malloc(sizeof(InstructionFlow)); _this->number = 0; @@ -842,6 +847,18 @@ void yyparse(); } return VALIDATE_SYNTHAX_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: @@ -904,6 +921,14 @@ void yyparse(); case INSTR_MULF: return validate_f(_this, INSTR_MULF_VAR_FLOAT, INSTR_MULF_VAR_VAR); + /* sub.f */ + case INSTR_SUBF: + return validate_f(_this, INSTR_SUBF_VAR_FLOAT, INSTR_SUBF_VAR_VAR); + + /* div.f */ + case INSTR_DIVF: + return validate_f(_this, INSTR_DIVF_VAR_FLOAT, INSTR_DIVF_VAR_VAR); + default: return VALIDATE_TODO; } @@ -913,7 +938,13 @@ void yyparse(); /** EXECUTE **/ void iflow_execute(InstructionFlow *_this, ScriptExecEnv *exec_env) { + int ip = 0; + int stack[512]; + int stack_pointer = 0; + + stack[stack_pointer++] = _this->number + 1; + while (ip < _this->number) { Instruction *instr = _this->instr[ip]; #ifdef TRACE_SCRIPT @@ -1043,39 +1074,40 @@ void yyparse(); ++ip; break; /* MUL.F */ + case INSTR_MULF_VAR_FLOAT: + instr->data.v_f.var->f *= instr->data.v_f.value; + ++ip; break; + case INSTR_MULF_VAR_VAR: instr->data.v_v.var_dest->f *= instr->data.v_v.var_src->f; ++ip; break; - case INSTR_MULF_VAR_FLOAT: - instr->data.v_f.var->f *= instr->data.v_f.value; + /* DIV.F */ + case INSTR_DIVF_VAR_FLOAT: + instr->data.v_f.var->f /= instr->data.v_f.value; + ++ip; break; + + case INSTR_DIVF_VAR_VAR: + instr->data.v_v.var_dest->f /= instr->data.v_v.var_src->f; ++ip; break; - /* EQUALS.I * / - case INSTR_EQUALSI_VAR_VAR: - return (instr->data.v_v.var_src->i == instr->data.v_v.var_dest->i)?1:2; - - case INSTR_EQUALSI_VAR_INTEGER: - return (instr->data.v_i.var->i == instr->data.v_i.value)?1:2; + /* SUB.F */ + case INSTR_SUBF_VAR_FLOAT: + instr->data.v_f.var->f -= instr->data.v_f.value; + ++ip; break; - / * EQUALS.F * / - case INSTR_EQUALSF_VAR_VAR: - return (instr->data.v_v.var_src->f == instr->data.v_v.var_dest->f)?1:2; - case INSTR_EQUALSF_VAR_FLOAT: - return (instr->data.v_f.var->f == instr->data.v_f.value)?1:2; + case INSTR_SUBF_VAR_VAR: + instr->data.v_v.var_dest->f -= instr->data.v_v.var_src->f; + ++ip; break; - / * LOWER.I * / - case INSTR_LOWERI_VAR_VAR: - return (instr->data.v_v.var_src->i > instr->data.v_v.var_dest->i)?1:2; - case INSTR_LOWERI_VAR_INTEGER: - return (instr->data.v_i.var->i < instr->data.v_i.value)?1:2; + /* CALL */ + case INSTR_CALL: + stack[stack_pointer++] = ip + 1; + ip += instr->data.jump_offset; break; - / * LOWER.F * / - case INSTR_LOWERF_VAR_VAR: - return (instr->data.v_v.var_src->f > instr->data.v_v.var_dest->f)?1:2; - case INSTR_LOWERF_VAR_FLOAT: - return (instr->data.v_f.var->f < instr->data.v_f.value)?1:2; - */ + /* RET */ + case INSTR_RET: + ip = stack[--stack_pointer]; break; default: printf("NOT IMPLEMENTED : %d\n", instr->id); @@ -1086,7 +1118,7 @@ void yyparse(); GoomScriptScanner *currentScanner; -#line 1090 "goom_script_scanner.c" +#line 1122 "lex.yy.c" #define INITIAL 0 #define COMMENT 1 @@ -1238,10 +1270,10 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 631 "goom_script_scanner.lex" +#line 664 "goom_script_lex.l" -#line 1245 "goom_script_scanner.c" +#line 1277 "lex.yy.c" if ( (yy_init) ) { @@ -1294,13 +1326,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 35 ) + if ( yy_current_state >= 36 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 58 ); + while ( yy_base[yy_current_state] != 60 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1327,92 +1359,80 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 633 "goom_script_scanner.lex" +#line 666 "goom_script_lex.l" { ++currentScanner->num_lines; } YY_BREAK case 2: YY_RULE_SETUP -#line 635 "goom_script_scanner.lex" +#line 668 "goom_script_lex.l" { BEGIN INITIAL; } YY_BREAK case 3: YY_RULE_SETUP -#line 636 "goom_script_scanner.lex" +#line 669 "goom_script_lex.l" { /* eat up comment */ } YY_BREAK case 4: YY_RULE_SETUP -#line 638 "goom_script_scanner.lex" +#line 671 "goom_script_lex.l" { BEGIN COMMENT; } YY_BREAK -/* - <INITIAL>set"."i { currentScanner->instr = instr_init(currentScanner, "set.i", INSTR_SETI, 2); } - <INITIAL>set"."f { currentScanner->instr = instr_init(currentScanner, "set.f", INSTR_SETF, 2); } - <INITIAL>add"."i { currentScanner->instr = instr_init(currentScanner, "add.i", INSTR_ADDI, 2); } - <INITIAL>add"."f { currentScanner->instr = instr_init(currentScanner, "add.f", INSTR_ADDF, 2); } - <INITIAL>mul"."i { currentScanner->instr = instr_init(currentScanner, "mul.i", INSTR_MULI, 2); } - <INITIAL>mul"."f { currentScanner->instr = instr_init(currentScanner, "mul.f", INSTR_MULF, 2); } - <INITIAL>bool { currentScanner->instr = instr_init(currentScanner, "bool", INSTR_INT, 1); } - <INITIAL>jump { currentScanner->instr = instr_init(currentScanner, "jump", INSTR_JUMP, 1); } - <INITIAL>label { currentScanner->instr = instr_init(currentScanner, "label", INSTR_LABEL, 1); } - <INITIAL>equals"."i { currentScanner->instr = instr_init(currentScanner, "equals.i", INSTR_EQUALSI, 2); } - <INITIAL>equals"."f { currentScanner->instr = instr_init(currentScanner, "equals.f", INSTR_EQUALSF, 2); } - <INITIAL>lower"."i { currentScanner->instr = instr_init(currentScanner, "lower.i", INSTR_LOWERI, 2); } - <INITIAL>lower"."f { currentScanner->instr = instr_init(currentScanner, "lower.f", INSTR_LOWERF, 2); } - <INITIAL>":"{ID}":" { instr_add_param(currentScanner->instr, yytext, TYPE_LABEL); } - <INITIAL>{ID}"."{ID} { instr_add_param(currentScanner->instr, yytext, TYPE_PARAM); } - */ case 5: YY_RULE_SETUP -#line 657 "goom_script_scanner.lex" +#line 673 "goom_script_lex.l" { return FLOAT_TK; } YY_BREAK case 6: YY_RULE_SETUP -#line 658 "goom_script_scanner.lex" +#line 674 "goom_script_lex.l" { return INT_TK; } YY_BREAK case 7: YY_RULE_SETUP -#line 659 "goom_script_scanner.lex" -{ strncpy(yylval.strValue, yytext, 2047); return TYPE_PARAM; } +#line 675 "goom_script_lex.l" +{ return ARROW_TK; } YY_BREAK case 8: YY_RULE_SETUP -#line 660 "goom_script_scanner.lex" -{ strncpy(yylval.strValue, yytext, 2047); return TYPE_VAR; } +#line 676 "goom_script_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return TYPE_PARAM; } YY_BREAK case 9: YY_RULE_SETUP -#line 661 "goom_script_scanner.lex" -{ strncpy(yylval.strValue, yytext, 2047); return TYPE_INTEGER; } +#line 677 "goom_script_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return TYPE_VAR; } YY_BREAK case 10: YY_RULE_SETUP -#line 662 "goom_script_scanner.lex" -{ strncpy(yylval.strValue, yytext, 2047); return TYPE_FLOAT; } +#line 678 "goom_script_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return TYPE_INTEGER; } YY_BREAK case 11: YY_RULE_SETUP -#line 663 "goom_script_scanner.lex" -{ sprintf(yylval.strValue, "%3.2f", atof(yytext)/100.0f); return TYPE_FLOAT; } +#line 679 "goom_script_lex.l" +{ strncpy(yylval.strValue, yytext, 2047); return TYPE_FLOAT; } YY_BREAK case 12: YY_RULE_SETUP -#line 664 "goom_script_scanner.lex" -/* eat up whitespace */ +#line 680 "goom_script_lex.l" +{ sprintf(yylval.strValue, "%3.2f", atof(yytext)/100.0f); return TYPE_FLOAT; } YY_BREAK case 13: YY_RULE_SETUP -#line 665 "goom_script_scanner.lex" -{ yylval.charValue = *yytext; return *yytext; } +#line 681 "goom_script_lex.l" +/* eat up whitespace */ YY_BREAK case 14: YY_RULE_SETUP -#line 667 "goom_script_scanner.lex" +#line 682 "goom_script_lex.l" +{ yylval.charValue = *yytext; return *yytext; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 684 "goom_script_lex.l" ECHO; YY_BREAK -#line 1416 "goom_script_scanner.c" +#line 1436 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): yyterminate(); @@ -1697,7 +1717,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 35 ) + if ( yy_current_state >= 36 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1725,11 +1745,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 35 ) + if ( yy_current_state >= 36 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 34); + yy_is_jam = (yy_current_state == 35); return yy_is_jam ? 0 : yy_current_state; } @@ -2379,7 +2399,7 @@ void yyfree (void * ptr ) #undef YY_DECL_IS_OURS #undef YY_DECL #endif -#line 667 "goom_script_scanner.lex" +#line 684 "goom_script_lex.l" @@ -2389,6 +2409,11 @@ static void reset_scanner(GoomScriptScanner *gss) { gss->instr = NULL; iflow_clean(gss->iflow); gss->current_flow = gss->iflow; + + /* reset variables */ + goom_hash_free(gss->vars); + gss->vars = goom_hash_new(); + gss->compilationOK = 1; } @@ -2415,14 +2440,20 @@ void goom_script_scanner_compile(GoomScriptScanner *_currentScanner, PluginInfo #ifdef VERBOSE printf("\n=== Starting Compilation ===\n"); #endif + + /* 0- reset */ currentScanner = _currentScanner; reset_scanner(currentScanner); currentScanner->pluginInfo = pluginInfo; + /* 1- create the syntaxic tree */ yy_scan_string(script); yyparse(); + + /* 2- generate code */ gsl_commit_compilation(); + /* 3- resolve symbols */ calculate_labels(currentScanner->iflow); #ifdef VERBOSE diff --git a/src/post/goom/goom_script_scanner.h b/src/post/goom/goom_script_scanner.h index fb969ce36..40360dc24 100644 --- a/src/post/goom/goom_script_scanner.h +++ b/src/post/goom/goom_script_scanner.h @@ -7,7 +7,7 @@ void goom_script_scanner_compile(GoomScriptScanner *scanner, PluginInfo *pluginI void goom_script_scanner_execute(GoomScriptScanner *scanner); int goom_script_scanner_is_compiled(GoomScriptScanner *gss); -GoomScriptScanner *goom_script_scanner_new(); +GoomScriptScanner *goom_script_scanner_new(void); void goom_script_scanner_free(GoomScriptScanner *gss); @@ -20,7 +20,8 @@ void goom_script_scanner_free(GoomScriptScanner *gss); #define CONST_FLOAT_NODE 2 #define VAR_NODE 3 #define PARAM_NODE 4 -#define OPR_NODE 5 +#define READ_PARAM_NODE 5 +#define OPR_NODE 6 #define OPR_SET 1 #define OPR_DECLARE_INT 2 @@ -31,6 +32,11 @@ void goom_script_scanner_free(GoomScriptScanner *gss); #define OPR_MUL 7 #define OPR_EQU 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 typedef struct { /* char *name;*/ @@ -64,10 +70,10 @@ typedef struct _NODE_TYPE{ ConstIntNodeType constInt; ConstFloatNodeType constFloat; OprNodeType opr; - } val; + } unode; } NodeType; -void gsl_commit_compilation(); +void gsl_commit_compilation(void); /* ------------- SCRIPT_EXEC_ENV ------------ */ @@ -190,8 +196,12 @@ struct _GoomScriptScanner { #define INSTR_ADDF 10008 #define INSTR_MULI 10009 #define INSTR_MULF 10010 -#define INSTR_ISEQUALI 10011 -#define INSTR_ISEQUALF 10012 +#define INSTR_DIVF 10011 +#define INSTR_SUBF 10012 +#define INSTR_ISEQUALI 10013 +#define INSTR_ISEQUALF 10014 #define INSTR_JZERO 29 +#define INSTR_CALL 34 +#define INSTR_RET 35 #endif diff --git a/src/post/goom/goom_script_scanner.tab.c b/src/post/goom/goom_script_yacc.c index be633a9bc..50a1ec90f 100644 --- a/src/post/goom/goom_script_scanner.tab.c +++ b/src/post/goom/goom_script_yacc.c @@ -58,7 +58,8 @@ TYPE_VAR = 260, TYPE_PARAM = 261, INT_TK = 262, - FLOAT_TK = 263 + FLOAT_TK = 263, + ARROW_TK = 264 }; #endif #define TYPE_INTEGER 258 @@ -67,12 +68,13 @@ #define TYPE_PARAM 261 #define INT_TK 262 #define FLOAT_TK 263 +#define ARROW_TK 264 /* Copy the first part of user declarations. */ -#line 6 "goom_script_scanner.y" +#line 6 "goom_script_yacc.y" #include <stdio.h> #include <string.h> @@ -93,55 +95,76 @@ static NodeType *new_constFloat(const char *str); static NodeType *new_var(const char *str); static NodeType *new_param(const char *str); + static NodeType *new_read_param(const char *str); static NodeType *new_nop(const char *str); static NodeType *new_op(const char *str, int type, int nbOp); - static int allocateLabel(); + static int allocateLabel(void); #define allocateTemp allocateLabel /* SETTER */ static NodeType *new_set(NodeType *lvalue, NodeType *expression) { NodeType *set = new_op("set", OPR_SET, 2); - set->val.opr.op[0] = lvalue; - set->val.opr.op[1] = expression; + set->unode.opr.op[0] = lvalue; + set->unode.opr.op[1] = expression; return set; } static void commit_set(NodeType *set) { - precommit_node(set->val.opr.op[1]); + precommit_node(set->unode.opr.op[1]); #ifdef VERBOSE - printf("set.f %s %s\n", set->val.opr.op[0]->str, set->val.opr.op[1]->str); + printf("set.f %s %s\n", set->unode.opr.op[0]->str, set->unode.opr.op[1]->str); #endif currentScanner->instr = instr_init(currentScanner, "set.f", INSTR_SETF, 2); - commit_node(set->val.opr.op[0]); - commit_node(set->val.opr.op[1]); + commit_node(set->unode.opr.op[0]); + commit_node(set->unode.opr.op[1]); } /* FLOAT */ static NodeType *new_float_decl(NodeType *name) { NodeType *fld = new_op("float", OPR_DECLARE_FLOAT, 1); - fld->val.opr.op[0] = name; + fld->unode.opr.op[0] = name; return fld; } static void commit_float(NodeType *var) { #ifdef VERBOSE - printf("float %s\n", var->val.opr.op[0]->str); + printf("float %s\n", var->unode.opr.op[0]->str); #endif currentScanner->instr = instr_init(currentScanner, "float", INSTR_INT, 1); - commit_node(var->val.opr.op[0]); + commit_node(var->unode.opr.op[0]); } /* INT */ static NodeType *new_int_decl(NodeType *name) { NodeType *intd = new_op("int", OPR_DECLARE_INT, 1); - intd->val.opr.op[0] = name; + intd->unode.opr.op[0] = name; return intd; } static void commit_int(NodeType *var) { #ifdef VERBOSE - printf("int %s\n", var->val.opr.op[0]->str); + printf("int %s\n", var->unode.opr.op[0]->str); #endif currentScanner->instr = instr_init(currentScanner, "int", INSTR_INT, 1); - commit_node(var->val.opr.op[0]); + commit_node(var->unode.opr.op[0]); + } + + /* precommit read_param: a read param is a param for reading. + * precommit copy it to a temporary variable. + */ + static void precommit_read_param(NodeType *rparam) { + char stmp[256]; + NodeType *tmp; + + /* declare a float to store the result */ + sprintf(stmp,"__tmp%i",allocateTemp()); + commit_node(new_float_decl(new_var(stmp))); + /* set the float to the value of "op1" */ + commit_node(new_set(new_var(stmp),new_param(rparam->str))); + + /* redefine the ADD node now as the computed variable */ + nodeFreeInternals(rparam); + tmp = new_var(stmp); + *rparam = *tmp; + free(tmp); } /* commodity method for add, mult, ... */ @@ -157,15 +180,15 @@ int toAdd; /* compute "left" and "right" */ - precommit_node(expr->val.opr.op[0]); - precommit_node(expr->val.opr.op[1]); + precommit_node(expr->unode.opr.op[0]); + precommit_node(expr->unode.opr.op[1]); - if (is_tmp_expr(expr->val.opr.op[0])) { - strcpy(stmp, expr->val.opr.op[0]->str); + if (is_tmp_expr(expr->unode.opr.op[0])) { + strcpy(stmp, expr->unode.opr.op[0]->str); toAdd = 1; } - else if (is_tmp_expr(expr->val.opr.op[1])) { - strcpy(stmp,expr->val.opr.op[1]->str); + else if (is_tmp_expr(expr->unode.opr.op[1])) { + strcpy(stmp,expr->unode.opr.op[1]->str); toAdd = 0; } else { @@ -173,17 +196,17 @@ sprintf(stmp,"__tmp%i",allocateTemp()); commit_node(new_float_decl(new_var(stmp))); /* set the float to the value of "op1" */ - commit_node(new_set(new_var(stmp),expr->val.opr.op[0])); + commit_node(new_set(new_var(stmp),expr->unode.opr.op[0])); toAdd = 1; } /* add op2 to tmp */ #ifdef VERBOSE - printf("%s %s %s\n", type, stmp, expr->val.opr.op[toAdd]->str); + printf("%s %s %s\n", type, stmp, expr->unode.opr.op[toAdd]->str); #endif currentScanner->instr = instr_init(currentScanner, type, instr_id, 2); commit_node(new_var(stmp)); - commit_node(expr->val.opr.op[toAdd]); + commit_node(expr->unode.opr.op[toAdd]); /* redefine the ADD node now as the computed variable */ nodeFreeInternals(expr); @@ -194,8 +217,8 @@ static NodeType *new_expr2(const char *name, int id, NodeType *expr1, NodeType *expr2) { NodeType *add = new_op(name, id, 2); - add->val.opr.op[0] = expr1; - add->val.opr.op[1] = expr2; + add->unode.opr.op[0] = expr1; + add->unode.opr.op[1] = expr2; return add; } @@ -207,6 +230,14 @@ precommit_expr(add,"add.f",INSTR_ADDF); } + /* SUB */ + static NodeType *new_sub(NodeType *expr1, NodeType *expr2) { + return new_expr2("sub.f", OPR_SUB, expr1, expr2); + } + static void precommit_sub(NodeType *sub) { + precommit_expr(sub,"sub.f",INSTR_SUBF); + } + /* MUL */ static NodeType *new_mul(NodeType *expr1, NodeType *expr2) { return new_expr2("mul.f", OPR_MUL, expr1, expr2); @@ -215,6 +246,14 @@ precommit_expr(mul,"mul.f",INSTR_MULF); } + /* DIV */ + static NodeType *new_div(NodeType *expr1, NodeType *expr2) { + return new_expr2("div.f", OPR_DIV, expr1, expr2); + } + static void precommit_div(NodeType *mul) { + precommit_expr(mul,"div.f",INSTR_DIVF); + } + /* EQU */ static NodeType *new_equ(NodeType *expr1, NodeType *expr2) { return new_expr2("isequal.f", OPR_EQU, expr1, expr2); @@ -230,30 +269,30 @@ static void precommit_low(NodeType *mul) { precommit_expr(mul,"islower.f",INSTR_ISLOWERF); } - + /* IF */ static NodeType *new_if(NodeType *expression, NodeType *instr) { NodeType *node = new_op("if", OPR_IF, 2); - node->val.opr.op[0] = expression; - node->val.opr.op[1] = instr; + node->unode.opr.op[0] = expression; + node->unode.opr.op[1] = instr; return node; } static void commit_if(NodeType *node) { char slab[1024]; - precommit_node(node->val.opr.op[0]); + precommit_node(node->unode.opr.op[0]); /* jzero.i <expression> <endif> */ sprintf(slab, "|eif%d|", allocateLabel()); #ifdef VERBOSE - printf("jzero.i %s %s\n", node->val.opr.op[0]->str, slab); + printf("jzero.i %s %s\n", node->unode.opr.op[0]->str, slab); #endif currentScanner->instr = instr_init(currentScanner, "jzero.i", INSTR_JZERO, 2); - commit_node(node->val.opr.op[0]); + commit_node(node->unode.opr.op[0]); instr_add_param(currentScanner->instr, slab, TYPE_LABEL); /* [... instrs of the if ...] */ - commit_node(node->val.opr.op[1]); + commit_node(node->unode.opr.op[1]); /* label <endif> */ #ifdef VERBOSE printf("label %s\n", slab); @@ -265,38 +304,79 @@ /* BLOCK */ static NodeType *new_block(NodeType *lastNode) { NodeType *blk = new_op("block", OPR_BLOCK, 2); - blk->val.opr.op[0] = new_nop("start_of_block"); - blk->val.opr.op[1] = lastNode; + blk->unode.opr.op[0] = new_nop("start_of_block"); + blk->unode.opr.op[1] = lastNode; return blk; } static void commit_block(NodeType *node) { - commit_node(node->val.opr.op[0]->val.opr.next); + commit_node(node->unode.opr.op[0]->unode.opr.next); + } + + /* FUNCTION INTRO */ + static NodeType *new_function_intro(const char *name) { + char stmp[256]; + if (strlen(name) < 200) { + sprintf(stmp, "|__func_%s|", name); + } + return new_op(stmp, OPR_FUNC_INTRO, 0); + } + static void commit_function_intro(NodeType *node) { + currentScanner->instr = instr_init(currentScanner, "label", INSTR_LABEL, 1); + instr_add_param(currentScanner->instr, node->str, TYPE_LABEL); +#ifdef VERBOSE + printf("label %s\n", node->str); +#endif } + /* FUNCTION OUTRO */ + static NodeType *new_function_outro(void) { + return new_op("ret", OPR_FUNC_OUTRO, 0); + } + static void commit_function_outro(NodeType *node) { + currentScanner->instr = instr_init(currentScanner, "ret", INSTR_RET, 1); + instr_add_param(currentScanner->instr, "|dummy|", TYPE_LABEL); +#ifdef VERBOSE + printf("ret\n"); +#endif + } + + /* FUNCTION CALL */ + static NodeType *new_call(const char *name) { + char stmp[256]; + if (strlen(name) < 200) { + sprintf(stmp, "|__func_%s|", name); + } + return new_op(stmp, OPR_CALL, 0); + } + static void commit_call(NodeType *node) { + currentScanner->instr = instr_init(currentScanner, "call", INSTR_CALL, 1); + instr_add_param(currentScanner->instr, node->str, TYPE_LABEL); +#ifdef VERBOSE + printf("call %s\n", node->str); +#endif + } + + /** **/ static NodeType *rootNode = 0; // TODO: reinitialiser a chaque compilation. static NodeType *lastNode = 0; static NodeType *gsl_append(NodeType *curNode) { if (lastNode) - lastNode->val.opr.next = curNode; + lastNode->unode.opr.next = curNode; lastNode = curNode; - while(lastNode->val.opr.next) lastNode = lastNode->val.opr.next; + while(lastNode->unode.opr.next) lastNode = lastNode->unode.opr.next; if (rootNode == 0) rootNode = curNode; return curNode; } static int lastLabel = 0; - int allocateLabel() { + int allocateLabel(void) { return ++lastLabel; } - void releaseLabel(int n) { - if (n == lastLabel) - lastLabel--; - } - void gsl_commit_compilation() { + void gsl_commit_compilation(void) { commit_node(rootNode); rootNode = 0; lastNode = 0; @@ -306,12 +386,17 @@ /* do here stuff for expression.. for exemple */ switch(node->type) { case OPR_NODE: - switch(node->val.opr.type) { + switch(node->unode.opr.type) { case OPR_ADD: precommit_add(node); break; + case OPR_SUB: precommit_sub(node); break; case OPR_MUL: precommit_mul(node); break; + case OPR_DIV: precommit_div(node); break; case OPR_EQU: precommit_equ(node); break; case OPR_LOW: precommit_low(node); break; } + break; + case READ_PARAM_NODE: + precommit_read_param(node); break; } } @@ -321,18 +406,21 @@ switch(node->type) { case OPR_NODE: - switch(node->val.opr.type) { + switch(node->unode.opr.type) { case OPR_DECLARE_FLOAT: commit_float(node); break; case OPR_DECLARE_INT: commit_int(node); break; case OPR_SET: commit_set(node); break; case OPR_IF: commit_if(node); break; case OPR_BLOCK: commit_block(node); break; + case OPR_FUNC_INTRO: commit_function_intro(node); break; + case OPR_FUNC_OUTRO: commit_function_outro(node); break; + case OPR_CALL: commit_call(node); break; #ifdef VERBOSE case EMPTY_NODE: printf("NOP\n"); break; #endif } - commit_node(node->val.opr.next); /* recursive for the moment, maybe better to do something iterative? */ + commit_node(node->unode.opr.next); /* recursive for the moment, maybe better to do something iterative? */ break; case PARAM_NODE: instr_add_param(currentScanner->instr, node->str, TYPE_PARAM); break; @@ -358,7 +446,7 @@ #endif #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 263 "goom_script_scanner.y" +#line 361 "goom_script_yacc.y" typedef union YYSTYPE { int intValue; float floatValue; @@ -367,7 +455,7 @@ typedef union YYSTYPE { NodeType *nPtr; } YYSTYPE; /* Line 191 of yacc.c. */ -#line 357 "goom_script_scanner.tab.c" +#line 457 "y.tab.c" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -379,7 +467,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c. */ -#line 369 "goom_script_scanner.tab.c" +#line 469 "y.tab.c" #if ! defined (yyoverflow) || YYERROR_VERBOSE @@ -476,22 +564,22 @@ union yyalloc #endif /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 2 +#define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 79 +#define YYLAST 80 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 19 +#define YYNTOKENS 23 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 7 +#define YYNNTS 13 /* YYNRULES -- Number of rules. */ -#define YYNRULES 22 +#define YYNRULES 34 /* YYNRULES -- Number of states. */ -#define YYNSTATES 44 +#define YYNSTATES 65 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 263 +#define YYMAXUTOK 264 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -503,15 +591,15 @@ static const unsigned char yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 14, 15, 10, 9, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, - 8, 7, 2, 16, 2, 2, 2, 2, 2, 2, + 18, 19, 15, 13, 2, 14, 2, 16, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 17, + 11, 10, 12, 20, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 17, 2, 18, 2, 2, 2, 2, + 2, 2, 2, 21, 2, 22, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -525,7 +613,7 @@ static const unsigned char yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 11, 12 + 5, 6, 7, 8, 9 }; #if YYDEBUG @@ -533,30 +621,35 @@ static const unsigned char yytranslate[] = YYRHS. */ static const unsigned char yyprhs[] = { - 0, 0, 3, 6, 7, 12, 18, 22, 26, 32, - 37, 39, 40, 42, 44, 48, 52, 56, 60, 64, - 66, 68, 70 + 0, 0, 3, 7, 10, 11, 14, 15, 19, 23, + 24, 29, 35, 39, 43, 49, 54, 58, 60, 61, + 63, 65, 69, 73, 77, 81, 85, 89, 93, 97, + 99, 101, 103, 105, 107 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yysigned_char yyrhs[] = { - 20, 0, -1, 20, 21, -1, -1, 24, 7, 23, - 13, -1, 12, 5, 7, 23, 13, -1, 12, 5, - 13, -1, 11, 5, 13, -1, 14, 23, 15, 16, - 21, -1, 17, 22, 20, 18, -1, 13, -1, -1, - 24, -1, 25, -1, 23, 10, 23, -1, 23, 9, - 23, -1, 23, 7, 23, -1, 23, 8, 23, -1, - 14, 23, 15, -1, 5, -1, 6, -1, 4, -1, - 3, -1 + 24, 0, -1, 25, 29, 26, -1, 25, 30, -1, + -1, 26, 27, -1, -1, 28, 25, 29, -1, 11, + 5, 12, -1, -1, 34, 10, 32, 17, -1, 8, + 5, 10, 32, 17, -1, 8, 5, 17, -1, 7, + 5, 17, -1, 18, 32, 19, 20, 30, -1, 21, + 31, 24, 22, -1, 9, 5, 17, -1, 17, -1, + -1, 33, -1, 35, -1, 32, 15, 32, -1, 32, + 16, 32, -1, 32, 13, 32, -1, 32, 14, 32, + -1, 32, 10, 32, -1, 32, 11, 32, -1, 32, + 12, 32, -1, 18, 32, 19, -1, 5, -1, 6, + -1, 5, -1, 6, -1, 4, -1, 3, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short yyrline[] = { - 0, 284, 284, 285, 288, 289, 291, 292, 293, 294, - 295, 298, 301, 302, 303, 304, 305, 306, 307, 310, - 311, 314, 315 + 0, 384, 384, 386, 387, 390, 391, 394, 396, 397, + 399, 400, 402, 403, 404, 405, 406, 407, 410, 413, + 414, 415, 416, 417, 418, 419, 420, 421, 422, 425, + 426, 429, 430, 433, 434 }; #endif @@ -566,9 +659,11 @@ static const unsigned short yyrline[] = static const char *const yytname[] = { "$end", "error", "$undefined", "TYPE_INTEGER", "TYPE_FLOAT", "TYPE_VAR", - "TYPE_PARAM", "'='", "'<'", "'+'", "'*'", "INT_TK", "FLOAT_TK", "';'", - "'('", "')'", "'?'", "'{'", "'}'", "$accept", "gsl", "instruction", - "start_block", "expression", "variable", "constValue", 0 + "TYPE_PARAM", "INT_TK", "FLOAT_TK", "ARROW_TK", "'='", "'<'", "'>'", + "'+'", "'-'", "'*'", "'/'", "';'", "'('", "')'", "'?'", "'{'", "'}'", + "$accept", "gsl", "gsl_code", "gsl_def_functions", "function", + "function_intro", "function_outro", "instruction", "start_block", + "expression", "read_variable", "write_variable", "constValue", 0 }; #endif @@ -577,25 +672,28 @@ static const char *const yytname[] = token YYLEX-NUM. */ static const unsigned short yytoknum[] = { - 0, 256, 257, 258, 259, 260, 261, 61, 60, 43, - 42, 262, 263, 59, 40, 41, 63, 123, 125 + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 61, 60, 62, 43, 45, 42, 47, 59, 40, 41, + 63, 123, 125 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const unsigned char yyr1[] = { - 0, 19, 20, 20, 21, 21, 21, 21, 21, 21, - 21, 22, 23, 23, 23, 23, 23, 23, 23, 24, - 24, 25, 25 + 0, 23, 24, 25, 25, 26, 26, 27, 28, 29, + 30, 30, 30, 30, 30, 30, 30, 30, 31, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, + 33, 34, 34, 35, 35 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const unsigned char yyr2[] = { - 0, 2, 2, 0, 4, 5, 3, 3, 5, 4, - 1, 0, 1, 1, 3, 3, 3, 3, 3, 1, - 1, 1, 1 + 0, 2, 3, 2, 0, 2, 0, 3, 3, 0, + 4, 5, 3, 3, 5, 4, 3, 1, 0, 1, + 1, 3, 3, 3, 3, 3, 3, 3, 3, 1, + 1, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -603,35 +701,41 @@ static const unsigned char yyr2[] = means the default is an error. */ static const unsigned char yydefact[] = { - 3, 0, 1, 19, 20, 0, 0, 10, 0, 11, - 2, 0, 0, 0, 22, 21, 0, 0, 12, 13, - 3, 0, 7, 0, 6, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 18, 16, 17, 15, 14, 0, - 9, 4, 5, 8 + 4, 0, 9, 1, 31, 32, 0, 0, 0, 17, + 0, 18, 6, 3, 0, 0, 0, 0, 34, 33, + 29, 30, 0, 0, 19, 20, 4, 2, 0, 13, + 0, 12, 16, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 5, 4, 0, 0, 28, 25, + 26, 27, 23, 24, 21, 22, 0, 15, 0, 9, + 10, 11, 14, 8, 7 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yysigned_char yydefgoto[] = { - -1, 1, 10, 20, 17, 18, 19 + -1, 1, 2, 27, 44, 45, 12, 13, 26, 23, + 24, 14, 25 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -8 +#define YYPACT_NINF -23 static const yysigned_char yypact[] = { - -8, 1, -8, -8, -8, 0, 22, -8, 5, -8, - -8, -3, 8, 13, -8, -8, 5, 46, -8, -8, - -8, 5, -8, 5, -8, 50, 5, 5, 5, 5, - 15, 11, 59, 66, -8, -7, -7, 23, -8, 35, - -8, -8, -8, -8 + -23, 1, 14, -23, -23, -23, 0, 2, 5, -23, + 21, -23, -23, -23, 18, -6, -8, 12, -23, -23, + -23, -23, 21, 30, -23, -23, -23, 19, 21, -23, + 21, -23, -23, 40, 21, 21, 21, 21, 21, 21, + 21, 13, 15, 29, -23, -23, 50, 58, -23, 63, + 63, 63, -12, -12, 20, -23, 14, -23, 26, 14, + -23, -23, -23, -23, -23 }; /* YYPGOTO[NTERM-NUM]. */ static const yysigned_char yypgoto[] = { - -8, 14, -4, -8, 16, -1, -8 + -23, 22, 35, -23, -23, -23, -2, -9, -23, -22, + -23, -23, -23 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -641,37 +745,41 @@ static const yysigned_char yypgoto[] = #define YYTABLE_NINF -1 static const unsigned char yytable[] = { - 11, 2, 28, 29, 21, 12, 3, 4, 14, 15, - 3, 4, 5, 6, 7, 8, 3, 4, 9, 16, - 23, 22, 5, 6, 7, 8, 24, 13, 9, 40, - 11, 39, 25, 29, 31, 43, 0, 32, 11, 33, - 3, 4, 35, 36, 37, 38, 5, 6, 7, 8, - 0, 0, 9, 26, 27, 28, 29, 26, 27, 28, - 29, 30, 0, 0, 0, 34, 26, 27, 28, 29, - 0, 0, 41, 26, 27, 28, 29, 0, 0, 42 + 33, 3, 30, 39, 40, 15, 46, 16, 47, 31, + 17, 29, 49, 50, 51, 52, 53, 54, 55, 4, + 5, 6, 7, 8, 18, 19, 20, 21, 28, 32, + 43, 9, 10, 56, 58, 11, 40, 57, 63, 22, + 34, 35, 36, 37, 38, 39, 40, 62, 42, 41, + 34, 35, 36, 37, 38, 39, 40, 64, 0, 48, + 34, 35, 36, 37, 38, 39, 40, 60, 34, 35, + 36, 37, 38, 39, 40, 61, 37, 38, 39, 40, + 59 }; static const yysigned_char yycheck[] = { - 1, 0, 9, 10, 7, 5, 5, 6, 3, 4, - 5, 6, 11, 12, 13, 14, 5, 6, 17, 14, - 7, 13, 11, 12, 13, 14, 13, 5, 17, 18, - 31, 16, 16, 10, 20, 39, -1, 21, 39, 23, - 5, 6, 26, 27, 28, 29, 11, 12, 13, 14, - -1, -1, 17, 7, 8, 9, 10, 7, 8, 9, - 10, 15, -1, -1, -1, 15, 7, 8, 9, 10, - -1, -1, 13, 7, 8, 9, 10, -1, -1, 13 + 22, 0, 10, 15, 16, 5, 28, 5, 30, 17, + 5, 17, 34, 35, 36, 37, 38, 39, 40, 5, + 6, 7, 8, 9, 3, 4, 5, 6, 10, 17, + 11, 17, 18, 20, 5, 21, 16, 22, 12, 18, + 10, 11, 12, 13, 14, 15, 16, 56, 26, 19, + 10, 11, 12, 13, 14, 15, 16, 59, -1, 19, + 10, 11, 12, 13, 14, 15, 16, 17, 10, 11, + 12, 13, 14, 15, 16, 17, 13, 14, 15, 16, + 45 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const unsigned char yystos[] = { - 0, 20, 0, 5, 6, 11, 12, 13, 14, 17, - 21, 24, 5, 5, 3, 4, 14, 23, 24, 25, - 22, 7, 13, 7, 13, 23, 7, 8, 9, 10, - 15, 20, 23, 23, 15, 23, 23, 23, 23, 16, - 18, 13, 13, 21 + 0, 24, 25, 0, 5, 6, 7, 8, 9, 17, + 18, 21, 29, 30, 34, 5, 5, 5, 3, 4, + 5, 6, 18, 32, 33, 35, 31, 26, 10, 17, + 10, 17, 17, 32, 10, 11, 12, 13, 14, 15, + 16, 19, 24, 11, 27, 28, 32, 32, 19, 32, + 32, 32, 32, 32, 32, 32, 20, 22, 5, 25, + 17, 17, 30, 12, 29 }; #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) @@ -1281,104 +1389,144 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: -#line 284 "goom_script_scanner.y" + case 3: +#line 386 "goom_script_yacc.y" { gsl_append(yyvsp[0].nPtr); } break; - case 4: -#line 288 "goom_script_scanner.y" + case 8: +#line 396 "goom_script_yacc.y" + { gsl_append(new_function_intro(yyvsp[-1].strValue)); } + break; + + case 9: +#line 397 "goom_script_yacc.y" + { gsl_append(new_function_outro()); } + break; + + case 10: +#line 399 "goom_script_yacc.y" { yyval.nPtr = new_set(yyvsp[-3].nPtr,yyvsp[-1].nPtr); } break; - case 5: -#line 289 "goom_script_scanner.y" + case 11: +#line 400 "goom_script_yacc.y" { yyval.nPtr = new_float_decl(new_var(yyvsp[-3].strValue)); - yyval.nPtr->val.opr.next = new_set(new_var(yyvsp[-3].strValue), yyvsp[-1].nPtr); } + yyval.nPtr->unode.opr.next = new_set(new_var(yyvsp[-3].strValue), yyvsp[-1].nPtr); } break; - case 6: -#line 291 "goom_script_scanner.y" + case 12: +#line 402 "goom_script_yacc.y" { yyval.nPtr = new_float_decl(new_var(yyvsp[-1].strValue)); } break; - case 7: -#line 292 "goom_script_scanner.y" + case 13: +#line 403 "goom_script_yacc.y" { yyval.nPtr = new_int_decl(new_var(yyvsp[-1].strValue)); } break; - case 8: -#line 293 "goom_script_scanner.y" + case 14: +#line 404 "goom_script_yacc.y" { yyval.nPtr = new_if(yyvsp[-3].nPtr,yyvsp[0].nPtr); } break; - case 9: -#line 294 "goom_script_scanner.y" - { lastNode = yyvsp[-2].nPtr->val.opr.op[1]; yyval.nPtr=yyvsp[-2].nPtr; } + case 15: +#line 405 "goom_script_yacc.y" + { lastNode = yyvsp[-2].nPtr->unode.opr.op[1]; yyval.nPtr=yyvsp[-2].nPtr; } break; - case 10: -#line 295 "goom_script_scanner.y" + case 16: +#line 406 "goom_script_yacc.y" + { yyval.nPtr = new_call(yyvsp[-1].strValue); } + break; + + case 17: +#line 407 "goom_script_yacc.y" { yyval.nPtr = new_nop("nop"); } break; - case 11: -#line 298 "goom_script_scanner.y" - { yyval.nPtr = new_block(lastNode); lastNode = yyval.nPtr->val.opr.op[0]; } + case 18: +#line 410 "goom_script_yacc.y" + { yyval.nPtr = new_block(lastNode); lastNode = yyval.nPtr->unode.opr.op[0]; } break; - case 12: -#line 301 "goom_script_scanner.y" + case 19: +#line 413 "goom_script_yacc.y" { yyval.nPtr = yyvsp[0].nPtr; } break; - case 13: -#line 302 "goom_script_scanner.y" + case 20: +#line 414 "goom_script_yacc.y" { yyval.nPtr = yyvsp[0].nPtr; } break; - case 14: -#line 303 "goom_script_scanner.y" + case 21: +#line 415 "goom_script_yacc.y" { yyval.nPtr = new_mul(yyvsp[-2].nPtr,yyvsp[0].nPtr); } break; - case 15: -#line 304 "goom_script_scanner.y" + case 22: +#line 416 "goom_script_yacc.y" + { yyval.nPtr = new_div(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 23: +#line 417 "goom_script_yacc.y" { yyval.nPtr = new_add(yyvsp[-2].nPtr,yyvsp[0].nPtr); } break; - case 16: -#line 305 "goom_script_scanner.y" + case 24: +#line 418 "goom_script_yacc.y" + { yyval.nPtr = new_sub(yyvsp[-2].nPtr,yyvsp[0].nPtr); } + break; + + case 25: +#line 419 "goom_script_yacc.y" { yyval.nPtr = new_equ(yyvsp[-2].nPtr,yyvsp[0].nPtr); } break; - case 17: -#line 306 "goom_script_scanner.y" + case 26: +#line 420 "goom_script_yacc.y" { yyval.nPtr = new_low(yyvsp[-2].nPtr,yyvsp[0].nPtr); } break; - case 18: -#line 307 "goom_script_scanner.y" + case 27: +#line 421 "goom_script_yacc.y" + { yyval.nPtr = new_low(yyvsp[0].nPtr,yyvsp[-2].nPtr); } + break; + + case 28: +#line 422 "goom_script_yacc.y" { yyval.nPtr = yyvsp[-1].nPtr; } break; - case 19: -#line 310 "goom_script_scanner.y" + case 29: +#line 425 "goom_script_yacc.y" { yyval.nPtr = new_var(yyvsp[0].strValue); } break; - case 20: -#line 311 "goom_script_scanner.y" + case 30: +#line 426 "goom_script_yacc.y" + { yyval.nPtr = new_read_param(yyvsp[0].strValue); } + break; + + case 31: +#line 429 "goom_script_yacc.y" + { yyval.nPtr = new_var(yyvsp[0].strValue); } + break; + + case 32: +#line 430 "goom_script_yacc.y" { yyval.nPtr = new_param(yyvsp[0].strValue); } break; - case 21: -#line 314 "goom_script_scanner.y" + case 33: +#line 433 "goom_script_yacc.y" { yyval.nPtr = new_constFloat(yyvsp[0].strValue); } break; - case 22: -#line 315 "goom_script_scanner.y" + case 34: +#line 434 "goom_script_yacc.y" { yyval.nPtr = new_constInt(yyvsp[0].strValue); } break; @@ -1386,7 +1534,7 @@ yyreduce: } /* Line 999 of yacc.c. */ -#line 1376 "goom_script_scanner.tab.c" +#line 1536 "y.tab.c" yyvsp -= yylen; yyssp -= yylen; @@ -1580,7 +1728,7 @@ yyreturn: } -#line 318 "goom_script_scanner.y" +#line 437 "goom_script_yacc.y" NodeType *nodeNew(const char *str, int type) { @@ -1602,13 +1750,13 @@ yyreturn: NodeType *new_constInt(const char *str) { NodeType *node = nodeNew(str, CONST_INT_NODE); - node->val.constInt.val = atoi(str); + node->unode.constInt.val = atoi(str); return node; } NodeType *new_constFloat(const char *str) { NodeType *node = nodeNew(str, CONST_FLOAT_NODE); - node->val.constFloat.val = atof(str); + node->unode.constFloat.val = atof(str); return node; } @@ -1617,6 +1765,11 @@ yyreturn: return node; } + NodeType *new_read_param(const char *str) { + NodeType *node = nodeNew(str, READ_PARAM_NODE); + return node; + } + NodeType *new_param(const char *str) { NodeType *node = nodeNew(str, PARAM_NODE); return node; @@ -1630,13 +1783,15 @@ yyreturn: NodeType *new_op(const char *str, int type, int nbOp) { int i; NodeType *node = nodeNew(str, OPR_NODE); - node->val.opr.next = 0; - node->val.opr.type = type; - node->val.opr.nbOp = nbOp; - for (i=0;i<nbOp;++i) node->val.opr.op[i] = 0; + node->unode.opr.next = 0; + node->unode.opr.type = type; + node->unode.opr.nbOp = nbOp; + for (i=0;i<nbOp;++i) node->unode.opr.op[i] = 0; return node; } void yyerror(char *str) { fprintf(stderr, "GSL ERROR: %s\n", str); } + + diff --git a/src/post/goom/goom_script_scanner.tab.h b/src/post/goom/goom_script_yacc.h index 6b9a2e04a..e35d93f82 100644 --- a/src/post/goom/goom_script_scanner.tab.h +++ b/src/post/goom/goom_script_yacc.h @@ -34,7 +34,8 @@ TYPE_VAR = 260, TYPE_PARAM = 261, INT_TK = 262, - FLOAT_TK = 263 + FLOAT_TK = 263, + ARROW_TK = 264 }; #endif #define TYPE_INTEGER 258 @@ -43,12 +44,13 @@ #define TYPE_PARAM 261 #define INT_TK 262 #define FLOAT_TK 263 +#define ARROW_TK 264 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 263 "goom_script_scanner.y" +#line 361 "goom_script_yacc.y" typedef union YYSTYPE { int intValue; float floatValue; @@ -57,7 +59,7 @@ typedef union YYSTYPE { NodeType *nPtr; } YYSTYPE; /* Line 1240 of yacc.c. */ -#line 61 "goom_script_scanner.tab.h" +#line 63 "y.tab.h" # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 diff --git a/src/post/goom/goom_tools.h b/src/post/goom/goom_tools.h index 9ee0e8082..31d044e4a 100644 --- a/src/post/goom/goom_tools.h +++ b/src/post/goom/goom_tools.h @@ -1,5 +1,5 @@ -#ifndef _GOOM_TOOLS_H -#define _GOOM_TOOLS_H +#ifndef _GOOMTOOLS_H +#define _GOOMTOOLS_H /** * Random number generator wrapper for faster random number. diff --git a/src/post/goom/goom_visual_fx.h b/src/post/goom/goom_visual_fx.h index 6cc798350..bb5c8f164 100644 --- a/src/post/goom/goom_visual_fx.h +++ b/src/post/goom/goom_visual_fx.h @@ -1,5 +1,5 @@ -#ifndef _GOOM_VISUAL_FX_H -#define _GOOM_VISUAL_FX_H +#ifndef _VISUAL_FX_H +#define _VISUAL_FX_H /** * File created on 2003-05-21 by Jeko. diff --git a/src/post/goom/ifs.c b/src/post/goom/ifs.c index a955b95d2..901bf7348 100644 --- a/src/post/goom/ifs.c +++ b/src/post/goom/ifs.c @@ -201,7 +201,7 @@ free_ifs (FRACTAL * Fractal) /***************************************************************/ -void +static void init_ifs (PluginInfo *goomInfo, IfsData *data) { int i; @@ -376,7 +376,7 @@ Draw_Fractal (IfsData *data) } -IFSPoint * +static IFSPoint * draw_ifs (PluginInfo *goomInfo, int *nbpt, IfsData *data) { int i; @@ -724,7 +724,7 @@ static void ifs_update (PluginInfo *goomInfo, Pixel * data, Pixel * back, int in /** VISUAL_FX WRAPPER FOR IFS */ -void ifs_vfx_apply(VisualFX *_this, Pixel *src, Pixel *dest, PluginInfo *goomInfo) { +static void ifs_vfx_apply(VisualFX *_this, Pixel *src, Pixel *dest, PluginInfo *goomInfo) { IfsData *data = (IfsData*)_this->fx_data; if (!data->initalized) { @@ -735,7 +735,7 @@ void ifs_vfx_apply(VisualFX *_this, Pixel *src, Pixel *dest, PluginInfo *goomInf /*TODO: trouver meilleur soluce pour increment (mettre le code de gestion de l'ifs dans ce fichier: ifs_vfx_apply) */ } -void ifs_vfx_init(VisualFX *_this) { +static void ifs_vfx_init(VisualFX *_this) { IfsData *data = (IfsData*)malloc(sizeof(IfsData)); data->Root = (FRACTAL*)NULL; @@ -743,13 +743,13 @@ void ifs_vfx_init(VisualFX *_this) { _this->fx_data = data; } -void ifs_vfx_free(VisualFX *_this) { +static void ifs_vfx_free(VisualFX *_this) { IfsData *data = (IfsData*)_this->fx_data; release_ifs(data); free(data); } -VisualFX ifs_visualfx_create() { +VisualFX ifs_visualfx_create(void) { VisualFX vfx; vfx.init = ifs_vfx_init; vfx.free = ifs_vfx_free; diff --git a/src/post/goom/ifs.h b/src/post/goom/ifs.h index 909838bd3..fab042668 100644 --- a/src/post/goom/ifs.h +++ b/src/post/goom/ifs.h @@ -10,7 +10,7 @@ #include "goom_plugin_info.h" #include "goom_visual_fx.h" -VisualFX ifs_visualfx_create(); +VisualFX ifs_visualfx_create(void); /* init ifs for a (width)x(height) output. * / void init_ifs (PluginInfo *goomInfo, int width, int height); @@ -20,7 +20,7 @@ void init_ifs (PluginInfo *goomInfo, int width, int height); void ifs_update (PluginInfo *goomInfo, Pixel * buffer, Pixel * back, int width, int height, int increment); / * free all ifs's data. * / -void release_ifs (); +void release_ifs (void); */ diff --git a/src/post/goom/lines.c b/src/post/goom/lines.c index a6a268337..877f1894c 100644 --- a/src/post/goom/lines.c +++ b/src/post/goom/lines.c @@ -44,7 +44,7 @@ static void lightencolor (guint32 *col, float power) -void +static void genline (int id, float param, GMUnitPointer * l, int rx, int ry) { int i; @@ -78,7 +78,7 @@ genline (int id, float param, GMUnitPointer * l, int rx, int ry) } } -guint32 getcouleur (int mode) +static guint32 getcouleur (int mode) { switch (mode) { case GML_RED: @@ -111,7 +111,7 @@ goom_lines_set_res (GMLine * gml, int rx, int ry) } -void +static void goom_lines_move (GMLine * l) { int i; diff --git a/src/post/goom/mmx.c b/src/post/goom/mmx.c index 3188d9bed..fdf06492a 100644 --- a/src/post/goom/mmx.c +++ b/src/post/goom/mmx.c @@ -1,3 +1,5 @@ +#ifdef HAVE_MMX + #define BUFFPOINTNB 16 #define BUFFPOINTMASK 0xffff #define BUFFINCR 0xff @@ -11,12 +13,12 @@ // faire : a / sqrtperte <=> a >> PERTEDEC #define PERTEDEC 4 -int mmx_supported () { +int mmx_supported (void) { return (mm_support()&0x1); } void zoom_filter_mmx (int prevX, int prevY, - unsigned int *expix1, unsigned int *expix2, + Pixel *expix1, Pixel *expix2, int *brutS, int *brutD, int buffratio, int precalCoef[16][16]) { @@ -270,3 +272,4 @@ end_of_line: /* __asm__ __volatile__ ("emms"); */ } +#endif diff --git a/src/post/goom/mmx.h b/src/post/goom/mmx.h index fe095de12..53c1cc5d9 100755 --- a/src/post/goom/mmx.h +++ b/src/post/goom/mmx.h @@ -27,6 +27,8 @@ #ifndef _MMX_H #define _MMX_H +#include "goom_graphic.h" + /* Warning: at this writing, the version of GAS packaged with most Linux distributions does not handle the parallel AND operation mnemonic correctly. If the @@ -58,7 +60,7 @@ typedef union { /* Function to test if multimedia instructions are supported... */ -inline extern int +static int mm_support(void) { /* Returns 1 if MMX instructions are supported, @@ -223,13 +225,25 @@ mm_support(void) /* Function to test if mmx instructions are supported... */ -inline extern int +static inline int mmx_ok(void) { /* Returns 1 if MMX instructions are supported, 0 otherwise */ return ( mm_support() & 0x1 ); } +int mmx_supported (void); +int xmmx_supported (void); + + +/* MMX optimized implementations */ +void draw_line_mmx (Pixel *data, int x1, int y1, int x2, int y2, int col, int screenx, int screeny); +void draw_line_xmmx (Pixel *data, int x1, int y1, int x2, int y2, int col, int screenx, int screeny); +void zoom_filter_mmx (int prevX, int prevY, Pixel *expix1, Pixel *expix2, + int *brutS, int *brutD, int buffratio, int precalCoef[16][16]); +void zoom_filter_xmmx (int prevX, int prevY, Pixel *expix1, Pixel *expix2, + int *lbruS, int *lbruD, int buffratio, int precalCoef[16][16]); + /* Helper functions for the instruction macros that follow... (note that memory-to-register, m2r, instructions are nearly diff --git a/src/post/goom/plugin_info.c b/src/post/goom/plugin_info.c index 31627f96f..c6d57dc5e 100644 --- a/src/post/goom/plugin_info.c +++ b/src/post/goom/plugin_info.c @@ -1,4 +1,5 @@ #include "goom_plugin_info.h" +#include "goom_fx.h" #include "cpu_info.h" #include "default_scripts.h" #include "drawmethods.h" @@ -15,24 +16,11 @@ #ifdef CPU_X86 -/* TODO: PUT THIS IN SEPARATE HEADERS */ -extern int xmmx_supported (); -extern int mmx_supported (); -extern void draw_line_mmx (Pixel *data, int x1, int y1, int x2, int y2, int col, int screenx, int screeny); -extern void zoom_filter_mmx (int sizeX, int sizeY, Pixel *src, Pixel *dest, int *brutS, int *brutD, int buffratio, int precalCoef[16][16]); -extern void zoom_filter_xmmx (int sizeX, int sizeY, Pixel *src, Pixel *dest, int *brutS, int *brutD, int buffratio, int precalCoef[16][16]); -/* END TODO */ +#include "mmx.h" #endif /* CPU_X86 */ - -/* prototypes of methods */ - -void zoom_filter_c (int sizeX, int sizeY, Pixel *src, Pixel *dest, int *brutS, int *brutD, int buffratio, int precalCoef[16][16]); -void create_output_with_brightness(Pixel *src, Pixel *output_buffer, int screensize, int iff); - - static void setOptimizedMethods(PluginInfo *p) { unsigned int cpuFlavour = cpu_flavour(); diff --git a/src/post/goom/tentacle3d.c b/src/post/goom/tentacle3d.c index 600511327..b42e80525 100755 --- a/src/post/goom/tentacle3d.c +++ b/src/post/goom/tentacle3d.c @@ -38,16 +38,16 @@ typedef struct _TENTACLE_FX_DATA { int lock; } TentacleFXData; -void tentacle_new (TentacleFXData *data); -void tentacle_update(PluginInfo *goomInfo, Pixel *buf, Pixel *back, int W, int H, +static void tentacle_new (TentacleFXData *data); +static void tentacle_update(PluginInfo *goomInfo, Pixel *buf, Pixel *back, int W, int H, short[2][512], float, int drawit, TentacleFXData *data); -void tentacle_free (TentacleFXData *data); +static void tentacle_free (TentacleFXData *data); /* * VisualFX wrapper for the tentacles */ -void tentacle_fx_init(VisualFX *_this) { +static void tentacle_fx_init(VisualFX *_this) { TentacleFXData *data = (TentacleFXData*)malloc(sizeof(TentacleFXData)); @@ -77,18 +77,18 @@ void tentacle_fx_init(VisualFX *_this) { _this->fx_data = (void*)data; } -void tentacle_fx_apply(VisualFX *_this, Pixel *src, Pixel *dest, PluginInfo *goomInfo) { +static void tentacle_fx_apply(VisualFX *_this, Pixel *src, Pixel *dest, PluginInfo *goomInfo) { tentacle_update(goomInfo, dest, src, goomInfo->screen.width, goomInfo->screen.height, goomInfo->sound.samples, (float)goomInfo->sound.accelvar, goomInfo->curGState->drawTentacle, (TentacleFXData*)_this->fx_data); } -void tentacle_fx_free(VisualFX *_this) { +static void tentacle_fx_free(VisualFX *_this) { tentacle_free((TentacleFXData*)_this->fx_data); free(_this->fx_data); } -VisualFX tentacle_fx_create() { +VisualFX tentacle_fx_create(void) { VisualFX fx; fx.init = tentacle_fx_init; fx.apply = tentacle_fx_apply; @@ -98,12 +98,12 @@ VisualFX tentacle_fx_create() { /* ----- */ -void tentacle_free (TentacleFXData *data) { +static void tentacle_free (TentacleFXData *data) { /* TODO : un vrai FREE GRID!! */ free (data->vals); } -void tentacle_new (TentacleFXData *data) { +static void tentacle_new (TentacleFXData *data) { int tmp; v3d center = {0,-17.0,0}; @@ -221,7 +221,7 @@ static void pretty_move (PluginInfo *goomInfo, float cycle, float *dist, float * *rotangle = fx_data->rot = (tmp + 15.0f*fx_data->rot) / 16.0f; } -void tentacle_update(PluginInfo *goomInfo, Pixel *buf, Pixel *back, int W, int H, +static void tentacle_update(PluginInfo *goomInfo, Pixel *buf, Pixel *back, int W, int H, short data[2][512], float rapport, int drawit, TentacleFXData *fx_data) { int tmp; diff --git a/src/post/goom/tentacle3d.h b/src/post/goom/tentacle3d.h index adc5f7721..ad0858fad 100755 --- a/src/post/goom/tentacle3d.h +++ b/src/post/goom/tentacle3d.h @@ -3,6 +3,6 @@ #include "goom_visual_fx.h" -VisualFX tentacle_fx_create(); +VisualFX tentacle_fx_create(void); #endif diff --git a/src/post/goom/xmmx.c b/src/post/goom/xmmx.c index 87589e863..a5d57b395 100644 --- a/src/post/goom/xmmx.c +++ b/src/post/goom/xmmx.c @@ -1,6 +1,9 @@ /* a definir pour avoir exactement le meme resultat que la fonction C * (un chouillat plus lent) */ + +#ifdef HAVE_MMX + #define STRICT_COMPAT //#define HAVE_ATHLON @@ -21,12 +24,12 @@ /*#include "xmmx.h"*/ #include "goom_graphic.h" -int xmmx_supported () { +int xmmx_supported (void) { return (mm_support()&0x8)>>3; } void zoom_filter_xmmx (int prevX, int prevY, - unsigned int *expix1, unsigned int *expix2, + Pixel *expix1, Pixel *expix2, int *lbruS, int *lbruD, int buffratio, int precalCoef[16][16]) { @@ -40,7 +43,7 @@ void zoom_filter_xmmx (int prevX, int prevY, volatile mmx_t ratiox; /* volatile mmx_t interpix; */ - expix1[0]=expix1[prevX-1]=expix1[prevX*prevY-1]=expix1[prevX*prevY-prevX]=0; + expix1[0].val=expix1[prevX-1].val=expix1[prevX*prevY-1].val=expix1[prevX*prevY-prevX].val=0; prevXY.ud[0] = (prevX-1)<<PERTEDEC; prevXY.ud[1] = (prevY-1)<<PERTEDEC; @@ -393,3 +396,4 @@ end_of_line: __asm__ __volatile__ ("femms\n"); } +#endif |