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: 96baf34
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: 1c031ff
Choose a head ref
  • 13 commits
  • 13 files changed
  • 1 contributor

Commits on Dec 29, 2011

  1. parser.y: use <...> instead of "..." for external includes (by Xiangf…

    …u Liu)
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    c292e09 View commit details
  2. parser_helper.c: don't leak last "struct id"

    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    69f7012 View commit details
  3. parser.y: plug various memory leaks in the parser

    lemon auto-frees only tokens and nodes that are not referenced in
    the rule's action. Since most of these are malloc'ed containers
    from which we only use some of the content, we need to explicitly
    free them.
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    433f03e View commit details
  4. compiler/: only get unique tokens for things looking like identifiers

    This patch removes the special-casing of tokens beginning with
    non-alphanumeric characters and teaches fpvm_parse which tokens
    should be treated like identifiers.
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    d5b5d59 View commit details
  5. ptest.c: new option -n runs for repeated execution; extended usage

    -n runs is for profiling and easier memory leak hunting.
    ptest now also detects that -c and -f conflict.
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    39ee78e View commit details
  6. ptest/Makefile: access FPVM includes via MMDIR, not RTEMS_MAKEFILE_PATH

    Sanity, at last ! :-)
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    31e40c7 View commit details
  7. ptest.c: free the patch (PFPU code) after dumping; free file buffer

    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    2101059 View commit details
  8. compiler.c: free unique names only after we're done with them

    This left a small but non-growing memory leak.
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    d8568ec View commit details
  9. compiler: rename fpvm_parse* to parse*

    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    211cdc5 View commit details
  10. merge compiler/fpvm.c into compiler/compiler.o and stop using fpvm_* …

    …prefix
    
    We don't need the fpvm.c "bridge" anymore. Also, since these elements
    are no longer in libfpvm, the old names would be confusing.
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    1429021 View commit details
  11. compiler: file2h -c passes input through cpp -P; use this to shrink i…

    …nfra-fnp.h
    
    This removes comments and redundant whitespace at build time, speeding
    up run-time parsing.
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    2a81e8c View commit details
  12. compiler/test/patches: enable memory leak checking when using valgrind

    To do: we should always check for memory leaks with valgrind. However,
    there are still a few left in error handling that would trip the test.
    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    af80c5d View commit details
  13. compiler/test/patches: if using valgrind, enable memory leak checking

    wpwrak authored and Sebastien Bourdeauducq committed Dec 29, 2011
    Copy the full SHA
    1c031ff View commit details
5 changes: 2 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ OBJS += $(addprefix translations/,french.o german.o)
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 fpvm.o parser_helper.o scanner.o \
OBJS += $(addprefix compiler/,compiler.o parser_helper.o scanner.o \
parser.o unique.o)

POBJS=$(addprefix $(OBJDIR)/,$(OBJS))
@@ -94,12 +94,11 @@ bandfilters.h: bandfilters.sce

compiler/infra-fnp.h: \
compiler/finish-pfv.fnp compiler/init-pvv.fnp compiler/finish-pvv.fnp
$(GEN) compiler/file2h $^ >$@ || { rm -f $@; }
$(GEN) compiler/file2h -c $^ >$@ || { rm -f $@; }

compiler/parser.h: compiler/parser.c
obj/compiler/scanner.o: compiler/parser.h
obj/compiler/parser_helper.o: compiler/parser.h
obj/compiler/fpvm.o: compiler/parser.h
obj/compiler/unique.o: compiler/fnp.inc
obj/compiler/compiler.o: compiler/infra-fnp.h compiler/parser.h

62 changes: 54 additions & 8 deletions src/compiler/compiler.c
Original file line number Diff line number Diff line change
@@ -23,11 +23,11 @@
#include <string.h>

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

#include "../pixbuf/pixbuf.h"
#include "fpvm.h"
#include "unique.h"
#include "parser_helper.h"
#include "parser.h"
@@ -58,6 +58,51 @@ static void comp_report(struct compiler_sc *sc, const char *format, ...)
sc->rmc(outbuf);
}

static void init_fpvm(struct fpvm_fragment *fragment, int vector_mode)
{
/*
* We need to pass these through unique() because the parser does
* the same. We can get rid of these calls to unique() later.
*/

_Xi = unique("_Xi");
_Xo = unique("_Xo");
_Yi = unique("_Yi");
_Yo = unique("_Yo");
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)
{
if(fpvm_do_assign(comm->u.fragment, label, node))
return NULL;
else
return strdup(fpvm_get_last_error(comm->u.fragment));
}

static int compile_chunk(struct fpvm_fragment *fragment, const char *chunk)
{
struct parser_comm comm = {
.u.fragment = fragment,
.assign_default = assign_chunk,
.assign_per_frame = NULL, /* crash ... */
.assign_per_vertex = NULL, /* and burn */
};
const char *error;

error = parse(chunk, TOK_START_ASSIGN, &comm);
if(error) {
snprintf(fragment->last_error, FPVM_MAXERRLEN, "%s", error);
free((void *) error);
}
return !error;
}


/****************************************************************/
/* PER-FRAME VARIABLES */
/****************************************************************/
@@ -285,7 +330,7 @@ static bool init_pfv(struct compiler_sc *sc)
{
int i;

fpvm_init(&sc->pfv_fragment, 0);
init_fpvm(&sc->pfv_fragment, 0);
fpvm_set_bind_mode(&sc->pfv_fragment, FPVM_BIND_ALL);
for(i=0;i<COMP_PFV_COUNT;i++)
sc->p->pfv_allocation[i] = -1;
@@ -296,7 +341,7 @@ static bool init_pfv(struct compiler_sc *sc)
static bool finalize_pfv(struct compiler_sc *sc)
{
/* assign dummy values for output */
if(!fpvm_chunk(&sc->pfv_fragment, FINISH_PFV_FNP))
if(!compile_chunk(&sc->pfv_fragment, FINISH_PFV_FNP))
goto fail_fpvm;
#ifdef COMP_DEBUG
printf("per-frame FPVM fragment:\n");
@@ -430,13 +475,13 @@ static bool init_pvv(struct compiler_sc *sc)
{
int i;

fpvm_init(&sc->pvv_fragment, 1);
init_fpvm(&sc->pvv_fragment, 1);
for(i=0;i<COMP_PVV_COUNT;i++)
sc->p->pvv_allocation[i] = -1;
fpvm_set_bind_callback(&sc->pvv_fragment, pvv_bind_callback, sc);

fpvm_set_bind_mode(&sc->pvv_fragment, FPVM_BIND_SOURCE);
if(!fpvm_chunk(&sc->pvv_fragment, INIT_PVV_FNP))
if(!compile_chunk(&sc->pvv_fragment, INIT_PVV_FNP))
goto fail_assign;
fpvm_set_bind_mode(&sc->pvv_fragment, FPVM_BIND_ALL);

@@ -452,7 +497,7 @@ static int finalize_pvv(struct compiler_sc *sc)
{
fpvm_set_bind_mode(&sc->pvv_fragment, FPVM_BIND_SOURCE);

if(!fpvm_chunk(&sc->pvv_fragment, FINISH_PVV_FNP))
if(!compile_chunk(&sc->pvv_fragment, FINISH_PVV_FNP))
goto fail_assign;
if(!fpvm_finalize(&sc->pvv_fragment)) goto fail_finalize;
#ifdef COMP_DEBUG
@@ -584,7 +629,7 @@ static bool parse_patch(struct compiler_sc *sc, const char *patch_code)
};
const char *error;

error = fpvm_parse(patch_code, TOK_START_ASSIGN, &comm);
error = parse(patch_code, TOK_START_ASSIGN, &comm);
if(error) {
sc->rmc(error);
free((void *) error);
@@ -626,13 +671,14 @@ struct patch *patch_compile(const char *basedir, const char *patch_code,

if(!parse_patch(sc, patch_code))
goto fail;
unique_free();

if(!finalize_pfv(sc)) goto fail;
if(!schedule_pfv(sc)) goto fail;
if(!finalize_pvv(sc)) goto fail;
if(!schedule_pvv(sc)) goto fail;

unique_free();

free(sc);
return p;

30 changes: 29 additions & 1 deletion src/compiler/file2h
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
#!/bin/sh -e
#
# file2h - Embed file content in #define expanding to a string
#
# Copyright 2011 by Werner Almesberger
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#


usage()
{
echo "usage: $0 [-c] file ..." 1>&2
exit 1
}


filter=cat
while [ "$1" ]; do
case "$1" in
-c) filter="cpp -P";;
-*) usage;;
*) break;
esac
shift
done

while [ "$1" ]; do
echo -n "#define "
basename $1 | sed 's/[^a-zA-Z0-9]/_/g' | tr a-z A-Z | tr -d '\n'
echo ' "" \'
sed 's/\\/\\\\/g;s/"/\\"/g;s/.*/ "&\\n" \\/' <$1
cat $1 | $filter | sed 's/\\/\\\\/g;s/"/\\"/g;s/.*/ "&\\n" \\/'
echo
shift
done
80 changes: 0 additions & 80 deletions src/compiler/fpvm.c

This file was deleted.

34 changes: 0 additions & 34 deletions src/compiler/fpvm.h

This file was deleted.

17 changes: 14 additions & 3 deletions src/compiler/parser.y
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include "fpvm/ast.h"
#include "fpvm/fpvm.h"
#include <fpvm/ast.h>
#include <fpvm/fpvm.h>
#include "parser_itf.h"
#include "parser_helper.h"
#include "parser.h"
@@ -121,22 +121,28 @@ assignments ::= .

assignment ::= ident(I) TOK_ASSIGN node(N) opt_semi. {
state->error = state->comm->assign_default(state->comm, I->label, N);
free(I);
if(state->error) {
syntax_error(state);
yy_parse_failed(yypParser);
return;
}
fpvm_parse_free(N);
parse_free(N);
}

assignment ::= TOK_IMAGEFILE(I) TOK_ASSIGN TOK_FNAME(N). {
state->error = state->comm->assign_image_name(state->comm,
atoi(I->label+9), N->label);
free(I);
if(state->error) {
syntax_error(state);
yy_parse_failed(yypParser);
free((void *) N->label);
free(N);
return;
}
free((void *) N->label);
free(N);
}

assignment ::= context(C). {
@@ -171,10 +177,12 @@ opt_semi ::= .
node(N) ::= TOK_CONSTANT(C). {
N = node(TOK_CONSTANT, "", NULL, NULL, NULL);
N->contents.constant = C->constant;
free(C);
}

node(N) ::= ident(I). {
N = node(I->token, I->label, NULL, NULL, NULL);
free(I);
}

%left TOK_PLUS TOK_MINUS.
@@ -207,15 +215,18 @@ node(N) ::= TOK_MINUS node(A). [TOK_NOT] {

node(N) ::= unary(I) TOK_LPAREN node(A) TOK_RPAREN. {
N = node(I->token, I->label, A, NULL, NULL);
free(I);
}

node(N) ::= binary(I) TOK_LPAREN node(A) TOK_COMMA node(B) TOK_RPAREN. {
N = node(I->token, I->label, A, B, NULL);
free(I);
}

node(N) ::= ternary(I) TOK_LPAREN node(A) TOK_COMMA node(B) TOK_COMMA node(C)
TOK_RPAREN. {
N = node(I->token, I->label, A, B, C);
free(I);
}

node(N) ::= TOK_LPAREN node(A) TOK_RPAREN. {
Loading