Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cc9e057^
Choose a base ref
...
head repository: m-labs/flickernoise
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d755a0b
Choose a head ref
  • 13 commits
  • 24 files changed
  • 1 contributor

Commits on Jan 5, 2012

  1. compiler: define op_not such that we don't trigger a warning

    lm32-rtems4.11-gcc doesn't like to compare enums "inherited" from other
    enums. We just "manually" code the offset instead.
    wpwrak committed Jan 5, 2012
    Copy the full SHA
    cc9e057 View commit details

Commits on Jan 7, 2012

  1. compiler: track reduction of "label" use in libfpvm

    First, we use the new node_is_op in parse_free. Second, we no longer
    have a good error message if op_not "leaks" in test/not.
    wpwrak committed Jan 7, 2012
    Copy the full SHA
    36ef9cd View commit details

Commits on Jan 10, 2012

  1. compiler: don't predefine identifiers for function names

    Since function names are normally not used for variables, we keep them
    separate and only allocate an identifier when needed. This will help
    with a future migration towards a proper symbol table.
    
    This also reduces the size of the table of predefined identifiers,
    slightly accelerating the compiler.
    wpwrak committed Jan 10, 2012
    Copy the full SHA
    eaf4b67 View commit details
  2. test: allow leak tests to fail and count the failed tests

    This adds instrumentation to expect() to make test failure non-fatal if
    FAIL_ON_ERROR is set to "false", then uses it in the "leak" target.
    wpwrak committed Jan 10, 2012
    Copy the full SHA
    55805a1 View commit details
  3. ptest: new option -s to dump all variables/symbols

    Also added the corresponding infrastructure to unique.c/unique.h
    wpwrak committed Jan 10, 2012
    Copy the full SHA
    484399e View commit details
  4. Copy the full SHA
    8e581f9 View commit details
  5. test/nsyms: count the number of user-defined variables/symbols in pat…

    …ch pool
    
    This is less a regression test bit more an indicator for how adaquate
    the structure of the symbol table is.
    wpwrak committed Jan 10, 2012
    Copy the full SHA
    38815b5 View commit details
  6. Copy the full SHA
    565d57d View commit details
  7. Copy the full SHA
    c0f929b View commit details
  8. compiler: "struct sym" megapatch

    This changes the compiler to use "struct sym" instead of "const char *"
    to refer to variables when communicating with libfpvm. This also
    implies that the symbol table moves to "struct sym" and that things
    that are not a variable have no identifier associated with them.
    wpwrak committed Jan 10, 2012
    Copy the full SHA
    9783fb2 View commit details
  9. compiler: separate file names more clearly from symbols

    The goal is to get rid of "label", which now only serves as a pointer
    into the source (or a copy thereof), for diagnostics.
    wpwrak committed Jan 10, 2012
    Copy the full SHA
    bda6e87 View commit details

Commits on Jan 11, 2012

  1. compiler: adapt to libfpvm use of "struct fpvm_sym" and introduce "st…

    …ruct sym"
    
    We now have a Flickernoise-local "struct sym" that contains the libfpvm
    symbol.
    wpwrak committed Jan 11, 2012
    Copy the full SHA
    35ec434 View commit details
  2. compiler: record index of system variables in symbol table

    This removes the list of variable names from compiler.c and lets
    fnp.ids provide the mapping from name to index.
    wpwrak committed Jan 11, 2012
    Copy the full SHA
    d755a0b View commit details
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ OBJS += $(addprefix renderer/,framedescriptor.o analyzer.o sampler.o \
eval.o line.o wave.o font.o osd.o raster.o renderer.o \
videoinreconf.o)
OBJS += $(addprefix compiler/,compiler.o parser_helper.o scanner.o \
parser.o unique.o)
parser.o symtab.o)

POBJS=$(addprefix $(OBJDIR)/,$(OBJS))

@@ -99,7 +99,7 @@ compiler/infra-fnp.h: \
compiler/parser.h: compiler/parser.c
obj/compiler/scanner.o: compiler/parser.h
obj/compiler/parser_helper.o: compiler/parser.h
obj/compiler/unique.o: compiler/fnp.inc
obj/compiler/symtab.o: compiler/fnp.inc
obj/compiler/compiler.o: compiler/infra-fnp.h compiler/parser.h

# boot images for Milkymist One
18 changes: 12 additions & 6 deletions src/compiler/Makefile
Original file line number Diff line number Diff line change
@@ -7,18 +7,24 @@ all:
# ----- Tests -----------------------------------------------------------------

test tests: all
LANG= sh -c \
'passed=0 && cd test && \
for n in [a-z]*; do \
[ $$n != core ] && SCRIPT=$$n . ./$$n; done; \
echo "Passed all $$passed tests"'
LANG= sh -c \
'passed=0 && failed=0 && cd test && \
for n in [a-z]*; do \
[ $$n != core ] && SCRIPT=$$n . ./$$n; done; \
if [ $$failed = 0 ]; then \
echo "Passed all $$passed tests"; \
else \
total=`expr $$passed + $$failed`; \
echo "Failed $$failed/$$total tests"; \
exit 1; \
fi'

valgrind:
VALGRIND="valgrind -q" $(MAKE) tests

leak leaks:
VALGRIND="valgrind -q --leak-check=full --show-reachable=yes" \
$(MAKE) tests
FAIL_ON_ERROR=false $(MAKE) tests

# ----- Cleanup ---------------------------------------------------------------

244 changes: 24 additions & 220 deletions src/compiler/compiler.c
Original file line number Diff line number Diff line change
@@ -23,12 +23,13 @@
#include <string.h>

#include <fpvm/fpvm.h>
#include <fpvm/symbol.h>
#include <fpvm/ast.h>
#include <fpvm/schedulers.h>
#include <fpvm/pfpu.h>

#include "../pixbuf/pixbuf.h"
#include "unique.h"
#include "symtab.h"
#include "parser_helper.h"
#include "parser.h"
#include "compiler.h"
@@ -65,20 +66,20 @@ static void init_fpvm(struct fpvm_fragment *fragment, int vector_mode)
* the same. We can get rid of these calls to unique() later.
*/

_Xi = unique("_Xi");
_Xo = unique("_Xo");
_Yi = unique("_Yi");
_Yo = unique("_Yo");
_Xi = &unique("_Xi")->fpvm_sym;
_Xo = &unique("_Xo")->fpvm_sym;
_Yi = &unique("_Yi")->fpvm_sym;
_Yo = &unique("_Yo")->fpvm_sym;
fpvm_do_init(fragment, vector_mode);
}

/* ----- Compilation of internal per-fragment setup code ------------------- */


static const char *assign_chunk(struct parser_comm *comm,
const char *label, struct ast_node *node)
struct sym *sym, struct ast_node *node)
{
if(fpvm_do_assign(comm->u.fragment, label, node))
if(fpvm_do_assign(comm->u.fragment, &sym->fpvm_sym, node))
return NULL;
else
return strdup(fpvm_get_last_error(comm->u.fragment));
@@ -107,139 +108,9 @@ static int compile_chunk(struct fpvm_fragment *fragment, const char *chunk)
/* PER-FRAME VARIABLES */
/****************************************************************/

const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN] = {
"sx",
"sy",
"cx",
"cy",
"rot",
"dx",
"dy",
"zoom",
"decay",
"wave_mode",
"wave_scale",
"wave_additive",
"wave_usedots",
"wave_brighten",
"wave_thick",
"wave_x",
"wave_y",
"wave_r",
"wave_g",
"wave_b",
"wave_a",

"ob_size",
"ob_r",
"ob_g",
"ob_b",
"ob_a",
"ib_size",
"ib_r",
"ib_g",
"ib_b",
"ib_a",

"nMotionVectorsX",
"nMotionVectorsY",
"mv_dx",
"mv_dy",
"mv_l",
"mv_r",
"mv_g",
"mv_b",
"mv_a",

"bTexWrap",

"time",
"bass",
"mid",
"treb",
"bass_att",
"mid_att",
"treb_att",

"warp",
"fWarpAnimSpeed",
"fWarpScale",

"q1",
"q2",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8",

"fVideoEchoAlpha",
"fVideoEchoZoom",
"nVideoEchoOrientation",

"dmx1",
"dmx2",
"dmx3",
"dmx4",
"dmx5",
"dmx6",
"dmx7",
"dmx8",

"idmx1",
"idmx2",
"idmx3",
"idmx4",
"idmx5",
"idmx6",
"idmx7",
"idmx8",

"osc1",
"osc2",
"osc3",
"osc4",

"midi1",
"midi2",
"midi3",
"midi4",
"midi5",
"midi6",
"midi7",
"midi8",

"video_a",

"image1_a",
"image1_x",
"image1_y",
"image1_zoom",
"image2_a",
"image2_x",
"image2_y",
"image2_zoom"
};

static int pfv_from_name(const char *name)
static int pfv_from_sym(const struct sym *sym)
{
int i;

for(i=0;i<COMP_PFV_COUNT;i++) {
if(strcmp(pfv_names[i], name) == 0)
return i;
}

if(strcmp(name, "fDecay") == 0) return pfv_decay;
if(strcmp(name, "nWaveMode") == 0) return pfv_wave_mode;
if(strcmp(name, "fWaveScale") == 0) return pfv_wave_scale;
if(strcmp(name, "bAdditiveWaves") == 0) return pfv_wave_additive;
if(strcmp(name, "bWaveDots") == 0) return pfv_wave_usedots;
if(strcmp(name, "bMaximizeWaveColor") == 0) return pfv_wave_brighten;
if(strcmp(name, "bWaveThick") == 0) return pfv_wave_thick;
if(strcmp(name, "fWaveAlpha") == 0) return pfv_wave_a;
return -1;
return sym->pfv_idx;
}

static void pfv_update_patch_requires(struct compiler_sc *sc, int pfv)
@@ -314,12 +185,12 @@ static void all_initials_to_pfv(struct compiler_sc *sc)
initial_to_pfv(sc, i);
}

static void pfv_bind_callback(void *_sc, const char *sym, int reg)
static void pfv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
{
struct compiler_sc *sc = _sc;
int pfv;

pfv = pfv_from_name(sym);
pfv = pfv_from_sym(FPVM2SYM(sym));
if(pfv >= 0) {
pfv_update_patch_requires(sc, pfv);
sc->p->pfv_allocation[pfv] = reg;
@@ -377,76 +248,9 @@ static bool schedule_pfv(struct compiler_sc *sc)
/* PER-VERTEX VARIABLES */
/****************************************************************/

const char pvv_names[COMP_PVV_COUNT][FPVM_MAXSYMLEN] = {
/* System */
"_texsize",
"_hmeshsize",
"_vmeshsize",

/* MilkDrop */
"sx",
"sy",
"cx",
"cy",
"rot",
"dx",
"dy",
"zoom",

"time",
"bass",
"mid",
"treb",
"bass_att",
"mid_att",
"treb_att",

"warp",
"fWarpAnimSpeed",
"fWarpScale",

"q1",
"q2",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8",

"idmx1",
"idmx2",
"idmx3",
"idmx4",
"idmx5",
"idmx6",
"idmx7",
"idmx8",

"osc1",
"osc2",
"osc3",
"osc4",

"midi1",
"midi2",
"midi3",
"midi4",
"midi5",
"midi6",
"midi7",
"midi8",
};

static int pvv_from_name(const char *name)
static int pvv_from_sym(const struct sym *sym)
{
int i;

for(i=0;i<COMP_PVV_COUNT;i++) {
if(strcmp(pvv_names[i], name) == 0)
return i;
}
return -1;
return sym->pvv_idx;
}

static void pvv_update_patch_requires(struct compiler_sc *sc, int pvv)
@@ -459,12 +263,12 @@ static void pvv_update_patch_requires(struct compiler_sc *sc, int pvv)
sc->p->require |= REQUIRE_MIDI;
}

static void pvv_bind_callback(void *_sc, const char *sym, int reg)
static void pvv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
{
struct compiler_sc *sc = _sc;
int pvv;

pvv = pvv_from_name(sym);
pvv = pvv_from_sym(FPVM2SYM(sym));
if(pvv >= 0) {
pvv_update_patch_requires(sc, pvv);
sc->p->pvv_allocation[pvv] = reg;
@@ -540,13 +344,13 @@ static bool schedule_pvv(struct compiler_sc *sc)
/****************************************************************/

static const char *assign_default(struct parser_comm *comm,
const char *label, struct ast_node *node)
struct sym *sym, struct ast_node *node)
{
struct compiler_sc *sc = comm->u.sc;
int pfv;
float v;

pfv = pfv_from_name(label);
pfv = pfv_from_sym(sym);
if(pfv < 0)
return strdup("unknown parameter");

@@ -571,24 +375,24 @@ static const char *assign_default(struct parser_comm *comm,
}

static const char *assign_fragment(struct fpvm_fragment *frag,
const char *label, struct ast_node *node)
struct sym *sym, struct ast_node *node)
{
if(fpvm_do_assign(frag, label, node))
if(fpvm_do_assign(frag, &sym->fpvm_sym, node))
return NULL;
else
return strdup(fpvm_get_last_error(frag));
}

static const char *assign_per_frame(struct parser_comm *comm,
const char *label, struct ast_node *node)
struct sym *sym, struct ast_node *node)
{
return assign_fragment(&comm->u.sc->pfv_fragment, label, node);
return assign_fragment(&comm->u.sc->pfv_fragment, sym, node);
}

static const char *assign_per_vertex(struct parser_comm *comm,
const char *label, struct ast_node *node)
struct sym *sym, struct ast_node *node)
{
return assign_fragment(&comm->u.sc->pvv_fragment, label, node);
return assign_fragment(&comm->u.sc->pvv_fragment, sym, node);
}

static const char *assign_image_name(struct parser_comm *comm,
3 changes: 0 additions & 3 deletions src/compiler/compiler.h
Original file line number Diff line number Diff line change
@@ -236,9 +236,6 @@ struct patch {

typedef void (*report_message)(const char *);

extern const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN];
extern const char pvv_names[COMP_PVV_COUNT][FPVM_MAXSYMLEN];

struct patch *patch_compile(const char *basedir, const char *patch_code, report_message rmc);
struct patch *patch_compile_filename(const char *filename, const char *patch_code, report_message rmc);
struct patch *patch_copy(struct patch *p);
Loading