Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: m-labs/flickernoise
base: d755a0b
...
head fork: m-labs/flickernoise
compare: 6259a03
Checking mergeability… Don't worry, you can still create the pull request.
  • 10 commits
  • 27 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 12, 2012
@wpwrak wpwrak compiler: rename unique_{free,dump} to symtab_*
Leaving "unique" and "unique_n" for now because I can't decide on a
good name.
5cdc43b
@wpwrak wpwrak compiler: optionally warn if using a variable in the wrong section (WIP)
This warning is currently only accessible via ptest, with the option
-Wsection.

To do:
- generalize the notification mechanism (currently printf)
- consider also handling variables like x, y, rad
5fa3a61
@wpwrak wpwrak compiler: added per-symbol flags to symbol table edecc6e
@wpwrak wpwrak compiler: -Wundefined to warn about undefined variables (WIP)
Limitations:
- complains about iterative calculations like  avg = A*avg+(1-A)*VALUE
- no way to explicitly initialize variables to zero (making the warning
  go away)
cb6d92a
@wpwrak wpwrak regression tests: attempt only valid assignments in initial/global se…
…ction

Many tests consisted of a single line like  x = something
which are not valid, because "x" is not a per-frame variable.

The next commit will slightly tighten the checks the compiler
performs even without code generation, so we need to make the
test cases a little more correct.
eaffaac
@wpwrak wpwrak compiler: allow explicit zero-initialization to suppress warning
This is applicable to all variables, not only per-frame variables.
6e7d6c1
@wpwrak wpwrak symtab: rename "syms" to user_syms, for export; minor cleanup ab35e12
@wpwrak wpwrak compiler: symbol table can now be iterated
symtab.h defines a macro forall_syms() that iterates over all symbols.
This means that it's now trivial to implement symtab_dump, and we can
therefore remove it.
068cfc9
@wpwrak wpwrak compiler: -Wundefined now also works for old-style patches
Old style assumes everything is implicitly initialized to zero.
We can still report identifiers that are never assigned to, though.

New style allows explicit initialization and thus can report
uninitialized variables immediately when they're read.
1f53fb2
@wpwrak wpwrak parser.y: tok2op wasn't "static", oops 6259a03
View
6 src/compiler/compiler.c
@@ -469,6 +469,8 @@ struct patch *patch_compile(const char *basedir, const char *patch_code,
sc->rmc = rmc;
sc->linenr = 0;
+ symtab_init();
+
load_defaults(sc);
if(!init_pfv(sc)) goto fail;
if(!init_pvv(sc)) goto fail;
@@ -481,13 +483,13 @@ struct patch *patch_compile(const char *basedir, const char *patch_code,
if(!finalize_pvv(sc)) goto fail;
if(!schedule_pvv(sc)) goto fail;
- unique_free();
+ symtab_free();
free(sc);
return p;
fail:
- unique_free();
+ symtab_free();
free(sc->p);
free(sc);
return NULL;
View
1  src/compiler/idgen
@@ -50,6 +50,7 @@ sed 's/#.*//;/^ *$/d' $1 | sort | {
.fpvm_sym = { .name = "$1" },
.pfv_idx = $2,
.pvv_idx = $3,
+ .flags = SF_SYSTEM,
},
EOF
i=`expr $i + 1`
View
66 src/compiler/parser.y
@@ -32,6 +32,9 @@
#include "parser.h"
+ int warn_section = 0;
+ int warn_undefined = 0;
+
struct yyParser;
static void yy_parse_failed(struct yyParser *yypParser);
@@ -56,7 +59,7 @@
state->style = which; \
} while (0)
- const enum ast_op tok2op[] = {
+ static const enum ast_op tok2op[] = {
[TOK_IDENT] = op_ident,
[TOK_CONSTANT] = op_constant,
[TOK_PLUS] = op_plus,
@@ -225,6 +228,14 @@ start ::= TOK_START_EXPR expr(N). {
}
start ::= TOK_START_ASSIGN sections. {
+ if(warn_undefined && state->style == old_style) {
+ const struct sym *sym;
+
+ forall_syms(sym)
+ if(!(sym->flags & (SF_SYSTEM | SF_ASSIGNED)))
+ printf("variable %s is only read, never set\n",
+ sym->fpvm_sym.name);
+ }
state->success = 1;
}
@@ -253,11 +264,33 @@ assignments ::= assignments assignment.
assignments ::= .
assignment ::= ident(I) TOK_ASSIGN expr(N) opt_semi. {
- state->error = state->comm->assign_default(state->comm, I->sym, N);
- free(I);
- if(state->error) {
- FAIL;
- return;
+ I->sym->flags |= SF_ASSIGNED;
+ /*
+ * The conditions are as follows:
+ * - we must be outside compile_chunk (has different rules)
+ * - must be in the initial section
+ * - must not assign to a per-frame system variable
+ */
+ if(state->comm->assign_per_frame &&
+ state->comm->assign_default != state->comm->assign_per_frame &&
+ state->comm->assign_default != state->comm->assign_per_vertex &&
+ I->sym->pfv_idx == -1) {
+ free(I);
+ if(N->op != op_constant || N->contents.constant) {
+ state->error = strdup("can initialize non-system "
+ "variables only to zero");
+ FAIL;
+ return;
+ }
+ IS_STYLE(new_style);
+ } else {
+ state->error =
+ state->comm->assign_default(state->comm, I->sym, N);
+ free(I);
+ if(state->error) {
+ FAIL;
+ return;
+ }
}
parse_free(N);
}
@@ -475,6 +508,10 @@ primary_expr(N) ::= TOK_CONSTANT(C). {
}
primary_expr(N) ::= ident(I). {
+ if(warn_undefined && state->style == new_style &&
+ !(I->sym->flags & (SF_SYSTEM | SF_ASSIGNED)))
+ printf("accessing undefined variable %s\n",
+ I->sym->fpvm_sym.name);
N = node(I->token, I->sym, NULL, NULL, NULL);
free(I);
}
@@ -495,7 +532,22 @@ primary_expr(N) ::= ident(I). {
* for variables should be a rare condition anyway.
*/
-ident(O) ::= TOK_IDENT(I). { O = I; }
+ident(O) ::= TOK_IDENT(I). {
+ if(warn_section) {
+ if(state->comm->assign_default ==
+ state->comm->assign_per_frame &&
+ I->sym->pfv_idx == -1 && I->sym->pvv_idx != -1)
+ printf("using per-vertex variable %s in "
+ "per-frame section\n", I->sym->fpvm_sym.name);
+ if(state->comm->assign_default ==
+ state->comm->assign_per_vertex &&
+ I->sym->pfv_idx != -1 && I->sym->pvv_idx == -1)
+ printf("using per-frame variable %s in "
+ "per-vertex section\n", I->sym->fpvm_sym.name);
+ }
+ O = I;
+}
+
ident(O) ::= unary(I). { O = symbolify(I); }
ident(O) ::= unary_misc(I). { O = symbolify(I); }
ident(O) ::= binary(I). { O = symbolify(I); }
View
3  src/compiler/parser_helper.h
@@ -45,6 +45,9 @@ struct parser_comm {
int number, const char *name);
};
+extern int warn_section;
+extern int warn_undefined;
+
const char *parse(const char *expr, int start_token, struct parser_comm *comm);
void parse_free_one(struct ast_node *node);
void parse_free(struct ast_node *node);
View
24 src/compiler/ptest/ptest.c
@@ -238,10 +238,15 @@ static void parse_only(const char *pgm)
};
const char *error;
+ symtab_init();
error = parse(pgm, TOK_START_ASSIGN, &comm);
- if (symbols)
- unique_dump();
- unique_free();
+ if (symbols) {
+ const struct sym *sym;
+
+ forall_syms(sym)
+ printf("%s\n", sym->fpvm_sym.name);
+ }
+ symtab_free();
if (!error)
return;
fflush(stdout);
@@ -326,12 +331,13 @@ static void free_buffer(void)
static void usage(const char *name)
{
fprintf(stderr,
-"usage: %s [-c|-f error] [-n runs] [-q] [-s] [expr]\n\n"
+"usage: %s [-c|-f error] [-n runs] [-q] [-s] [-Wwarning...] [expr]\n\n"
" -c generate code and dump generated code (unless -q is set)\n"
" -f error fail any assignment with specified error message\n"
" -n runs run compilation repeatedly (default: run only once)\n"
" -q quiet operation\n"
" -s dump symbol table after parsing (only if -c is not set)\n"
+" -Wwarning enable compiler warning (one of: section, undefined)\n"
, name);
exit(1);
}
@@ -344,7 +350,7 @@ int main(int argc, char **argv)
unsigned long repeat = 1;
char *end;
- while ((c = getopt(argc, argv, "cf:n:qs")) != EOF)
+ while ((c = getopt(argc, argv, "cf:n:qsW:")) != EOF)
switch (c) {
case 'c':
codegen = 1;
@@ -363,6 +369,14 @@ int main(int argc, char **argv)
case 's':
symbols = 1;
break;
+ case 'W':
+ if (!strcmp(optarg, "section"))
+ warn_section = 1;
+ else if (!strcmp(optarg, "undefined"))
+ warn_undefined = 1;
+ else
+ usage(*argv);
+ break;
default:
usage(*argv);
}
View
70 src/compiler/symtab.c
@@ -29,9 +29,12 @@ struct key_n {
struct sym well_known[] = {
#include "fnp.inc"
};
+int num_well_known;
-static struct sym *syms = NULL;
-static int num_syms = 0, allocated = 0;
+struct sym *user_syms = NULL;
+int num_user_syms = 0;
+
+static int allocated = 0;
/*
@@ -64,11 +67,11 @@ static char *strdup_n(const char *s, int n)
static void grow_table(void)
{
- if(num_syms != allocated)
+ if(num_user_syms != allocated)
return;
allocated = allocated ? allocated*2 : INITIAL_ALLOC;
- syms = realloc(syms, allocated*sizeof(*syms));
+ user_syms = realloc(user_syms, allocated*sizeof(*user_syms));
}
@@ -91,20 +94,20 @@ static int cmp_n(const void *a, const void *b)
struct sym *unique(const char *s)
{
- struct sym *res;
- struct sym *walk;
+ struct sym *res, *walk, *new;
- res = bsearch(s, well_known, sizeof(well_known)/sizeof(*well_known),
- sizeof(*well_known), cmp);
+ res = bsearch(s, well_known, num_well_known, sizeof(*well_known), cmp);
if(res)
return res;
- for(walk = syms; walk != syms+num_syms; walk++)
+ for(walk = user_syms; walk != user_syms+num_user_syms; walk++)
if(!strcmp(walk->fpvm_sym.name, s))
return walk;
grow_table();
- syms[num_syms].fpvm_sym.name = strdup(s);
- syms[num_syms].pfv_idx = syms[num_syms].pvv_idx = -1;
- return syms+num_syms++;
+ new = user_syms+num_user_syms++;
+ new->fpvm_sym.name = strdup(s);
+ new->pfv_idx = new->pvv_idx = -1;
+ new->flags = 0;
+ return new;
}
@@ -114,47 +117,42 @@ struct sym *unique_n(const char *s, int n)
.s = s,
.n = n,
};
- struct sym *res;
- struct sym *walk;
+ struct sym *res, *walk, *new;
assert(n);
- res = bsearch(&key, well_known, sizeof(well_known)/sizeof(*well_known),
- sizeof(*well_known), cmp_n);
+ res = bsearch(&key, well_known, num_well_known, sizeof(*well_known),
+ cmp_n);
if(res)
return res;
- for(walk = syms; walk != syms+num_syms; walk++)
+ for(walk = user_syms; walk != user_syms+num_user_syms; walk++)
if(!strcmp_n(s, walk->fpvm_sym.name, n))
return walk;
grow_table();
- syms[num_syms].fpvm_sym.name = strdup_n(s, n);
- syms[num_syms].pfv_idx = syms[num_syms].pvv_idx = -1;
- return syms+num_syms++;
+ new = user_syms+num_user_syms++;
+ new->fpvm_sym.name = strdup_n(s, n);
+ new->pfv_idx = new->pvv_idx = -1;
+ new->flags = 0;
+ return new;
}
-void unique_free(void)
+void symtab_init(void)
{
int i;
- for(i = 0; i != num_syms; i++)
- free((void *) syms[i].fpvm_sym.name);
- free(syms);
- syms = NULL;
- num_syms = allocated = 0;
+ num_well_known = sizeof(well_known)/sizeof(*well_known);
+ for(i = 0; i != num_well_known; i++)
+ well_known[i].flags &= SF_FIXED;
}
-#ifdef STANDALONE
-
-void unique_dump(void)
+void symtab_free(void)
{
int i;
- for(i = 0; i != sizeof(well_known)/sizeof(*well_known); i++)
- printf("%s\n", well_known[i].fpvm_sym.name);
- printf("\n");
- for(i = 0; i != num_syms; i++)
- printf("%s\n", syms[i].fpvm_sym.name);
+ for(i = 0; i != num_user_syms; i++)
+ free((void *) user_syms[i].fpvm_sym.name);
+ free(user_syms);
+ user_syms = NULL;
+ num_user_syms = allocated = 0;
}
-
-#endif /* STANDALONE */
View
18 src/compiler/symtab.h
@@ -14,17 +14,31 @@
#include <fpvm/symbol.h>
+#define SF_SYSTEM (1 << 0)
+#define SF_ASSIGNED (1 << 1)
+#define SF_FIXED SF_SYSTEM
+
struct sym {
struct fpvm_sym fpvm_sym;
int pfv_idx, pvv_idx; /* index; -1 if not a variable known to FN */
+ int flags;
};
+extern struct sym well_known[];
+extern int num_well_known;
+extern struct sym *user_syms;
+extern int num_user_syms;
+
#define FPVM2SYM(fpvm_sym) ((struct sym *) (fpvm_sym))
+#define forall_syms(p) \
+ for ((p) = well_known; (p) != user_syms+num_user_syms; \
+ (p) = (p) == well_known+num_well_known ? user_syms : (p)+1)
+
+void symtab_init(void);
struct sym *unique(const char *s);
struct sym *unique_n(const char *s, int n);
-void unique_free(void);
-void unique_dump(void);
+void symtab_free(void);
#endif /* !SYMTAB_H */
View
30 src/compiler/test/arith
@@ -3,47 +3,47 @@
###############################################################################
-ptest "arithmetic: x = a+b" <<EOF
-x = a+b
+ptest "arithmetic: sx = a+b" <<EOF
+sx = a+b
EOF
expect <<EOF
-x = (+ a b)
+sx = (+ a b)
EOF
#------------------------------------------------------------------------------
-ptest "arithmetic: x = a-b" <<EOF
-x = a-b
+ptest "arithmetic: sx = a-b" <<EOF
+sx = a-b
EOF
expect <<EOF
-x = (- a b)
+sx = (- a b)
EOF
#------------------------------------------------------------------------------
-ptest "arithmetic: x = a*b" <<EOF
-x = a*b
+ptest "arithmetic: sx = a*b" <<EOF
+sx = a*b
EOF
expect <<EOF
-x = (* a b)
+sx = (* a b)
EOF
#------------------------------------------------------------------------------
-ptest "arithmetic: x = a/b" <<EOF
-x = a/b
+ptest "arithmetic: sx = a/b" <<EOF
+sx = a/b
EOF
expect <<EOF
-x = (/ a b)
+sx = (/ a b)
EOF
#------------------------------------------------------------------------------
-ptest "arithmetic: x = a%b" <<EOF
-x = a/b
+ptest "arithmetic: sx = a%b" <<EOF
+sx = a/b
EOF
expect <<EOF
-x = (/ a b)
+sx = (/ a b)
EOF
###############################################################################
View
2  src/compiler/test/codegen
@@ -15,7 +15,7 @@ ptest_fail "codegen: global foo = 1" -c -q <<EOF
foo = 1
EOF
expect <<EOF
-FPVM, line 2: unknown parameter near 'EOF'
+FPVM, line 2: can initialize non-system variables only to zero near 'EOF'
EOF
#------------------------------------------------------------------------------
View
88 src/compiler/test/comment
@@ -5,112 +5,112 @@
ptest "comment: line with just // " <<EOF
// this is a comment
-a = b + c
+sx = b + c
EOF
expect <<EOF
-a = (+ b c)
+sx = (+ b c)
EOF
#------------------------------------------------------------------------------
ptest "comment: line ending with // comment" <<EOF
-a = b + c // comment
-d = e + f
+sx = b + c // comment
+sy = e + f
EOF
expect <<EOF
-a = (+ b c)
-d = (+ e f)
+sx = (+ b c)
+sy = (+ e f)
EOF
#------------------------------------------------------------------------------
ptest "comment: // after //" <<EOF
-a = b + c // comment // more
-d = e + f
+sx = b + c // comment // more
+sy = e + f
EOF
expect <<EOF
-a = (+ b c)
-d = (+ e f)
+sx = (+ b c)
+sy = (+ e f)
EOF
#------------------------------------------------------------------------------
-ptest "comment: // ending with EOF" "a = b// end"
+ptest "comment: // ending with EOF" "sx = b// end"
expect <<EOF
-a = b
+sx = b
EOF
#------------------------------------------------------------------------------
ptest "comment: /* ... */" <<EOF
-a = b + c /* comment */
-d = e + f
+sx = b + c /* comment */
+sy = e + f
EOF
expect <<EOF
-a = (+ b c)
-d = (+ e f)
+sx = (+ b c)
+sy = (+ e f)
EOF
#------------------------------------------------------------------------------
ptest "comment: /* ... newline ... */" <<EOF
-a = b + c /* comment
-more */ d = e + f
+sx = b + c /* comment
+more */ sy = e + f
EOF
expect <<EOF
-a = (+ b c)
-d = (+ e f)
+sx = (+ b c)
+sy = (+ e f)
EOF
#------------------------------------------------------------------------------
ptest "comment: /* ... * ... */" <<EOF
-a = 1 /* comment * more */
-b = 2
+sx = 1 /* comment * more */
+sy = 2
EOF
expect <<EOF
-a = 1
-b = 2
+sx = 1
+sy = 2
EOF
#------------------------------------------------------------------------------
ptest "comment: /* ... ** ... */" <<EOF
-a = 3 /* comment ** more */
-b = 4
+sx = 3 /* comment ** more */
+sy = 4
EOF
expect <<EOF
-a = 3
-b = 4
+sx = 3
+sy = 4
EOF
#------------------------------------------------------------------------------
ptest "comment: /* ... **/" <<EOF
-a = 5 /* comment **/
-b = 6
+sx = 5 /* comment **/
+sy = 6
EOF
expect <<EOF
-a = 5
-b = 6
+sx = 5
+sy = 6
EOF
#------------------------------------------------------------------------------
ptest "comment: /**/" <<EOF
-a = 7 /**/
-b = 8
+sx = 7 /**/
+sy = 8
EOF
expect <<EOF
-a = 7
-b = 8
+sx = 7
+sy = 8
EOF
#------------------------------------------------------------------------------
ptest_fail "comment: /*/ (error)" <<EOF
-a = 9 /*/
-b = a
+sx = 9 /*/
+sy = a
EOF
expect <<EOF
FPVM, line 1: parse error near '*/'
@@ -119,8 +119,8 @@ EOF
#------------------------------------------------------------------------------
ptest_fail "comment: unterminated /* ... with newline" <<EOF
-a = b + c /* comment
-d = e + f
+sx = b + c /* comment
+sy = e + f
EOF
expect <<EOF
FPVM, line 1: parse error near '*'
@@ -136,22 +136,22 @@ EOF
#------------------------------------------------------------------------------
ptest "comment: multiple /*...*/ comments" <<EOF
-/* */ a /* */
+/* */ sx /* */
/***/ = /**/
/**/ b /* */
EOF
expect <<EOF
-a = b
+sx = b
EOF
#------------------------------------------------------------------------------
ptest "comment: [preset00]" <<EOF
[preset00]
-x=y
+sx=y
EOF
expect <<EOF
-x = y
+sx = y
EOF
###############################################################################
View
24 src/compiler/test/cond
@@ -3,38 +3,38 @@
###############################################################################
-ptest "conditional: x = a ? b : c" <<EOF
-x = a ? b : c
+ptest "conditional: sx = a ? b : c" <<EOF
+sx = a ? b : c
EOF
expect <<EOF
-x = (if a b c)
+sx = (if a b c)
EOF
#------------------------------------------------------------------------------
-ptest "conditional: x = a+b ? c+d : e+f" <<EOF
-x = a+b ? c+d : e+f
+ptest "conditional: sx = a+b ? c+d : e+f" <<EOF
+sx = a+b ? c+d : e+f
EOF
expect <<EOF
-x = (if (+ a b) (+ c d) (+ e f))
+sx = (if (+ a b) (+ c d) (+ e f))
EOF
#------------------------------------------------------------------------------
-ptest "conditional: x = a ? b ? c : d : e" <<EOF
-x = a ? b ? c : d : e
+ptest "conditional: sx = a ? b ? c : d : e" <<EOF
+sx = a ? b ? c : d : e
EOF
expect <<EOF
-x = (if a (if b c d) e)
+sx = (if a (if b c d) e)
EOF
#------------------------------------------------------------------------------
-ptest "conditional: x = a ? b : c ? d : e" <<EOF
-x = a ? b : c ? d : e
+ptest "conditional: sx = a ? b : c ? d : e" <<EOF
+sx = a ? b : c ? d : e
EOF
expect <<EOF
-x = (if a b (if c d e))
+sx = (if a b (if c d e))
EOF
###############################################################################
View
9 src/compiler/test/dualuse
@@ -4,28 +4,31 @@
###############################################################################
ptest "dual use: min = sin+cos" <<EOF
+per_frame:
min = sin+cos
EOF
expect <<EOF
-min = (+ (sin) (cos))
+per_frame = min = (+ (sin) (cos))
EOF
#------------------------------------------------------------------------------
ptest "dual use: sin = sqr-if" <<EOF
+per_frame:
sin = sqr-if
EOF
expect <<EOF
-sin = (- (sqr) (if))
+per_frame = sin = (- (sqr) (if))
EOF
#------------------------------------------------------------------------------
ptest "dual use: if = max*int" <<EOF
+per_frame:
if = max*int
EOF
expect <<EOF
-if = (* (max) (int))
+per_frame = if = (* (max) (int))
EOF
###############################################################################
View
12 src/compiler/test/error
@@ -12,18 +12,18 @@ EOF
#------------------------------------------------------------------------------
-ptest_fail "syntax error: x = a b" <<EOF
-x = a b
+ptest_fail "syntax error: sx = a b" <<EOF
+sx = a b
EOF
expect <<EOF
-x = a
+sx = a
FPVM, line 2: parse error near 'EOF'
EOF
#------------------------------------------------------------------------------
-ptest_fail "syntax error: x = a + + b" <<EOF
-x = a + + b
+ptest_fail "syntax error: sx = a + + b" <<EOF
+sx = a + + b
EOF
expect <<EOF
FPVM, line 1: parse error near '+'
@@ -32,7 +32,7 @@ EOF
#------------------------------------------------------------------------------
ptest_fail "inject code generation error" -f "codegen" <<EOF
-x = a + b
+sx = a + b
EOF
expect <<EOF
FPVM, line 2: codegen near 'EOF'
View
36 src/compiler/test/fcond
@@ -3,56 +3,56 @@
###############################################################################
-ptest "fold conditional: x = a ? b : c (nothing to fold)" << EOF
-x = a ? b : c
+ptest "fold conditional: sx = a ? b : c (nothing to fold)" << EOF
+sx = a ? b : c
EOF
expect <<EOF
-x = (if a b c)
+sx = (if a b c)
EOF
#------------------------------------------------------------------------------
-ptest "fold conditional: x = 1 ? b : c" << EOF
-x = 1 ? b : c
+ptest "fold conditional: sx = 1 ? b : c" << EOF
+sx = 1 ? b : c
EOF
expect <<EOF
-x = b
+sx = b
EOF
#------------------------------------------------------------------------------
-ptest "fold conditional: x = 0 ? b : c" << EOF
-x = 0 ? b : c
+ptest "fold conditional: sx = 0 ? b : c" << EOF
+sx = 0 ? b : c
EOF
expect <<EOF
-x = c
+sx = c
EOF
#------------------------------------------------------------------------------
-ptest "fold conditional: x = if(a, b, c) (nothing to fold)" << EOF
-x = if(a, b, c)
+ptest "fold conditional: sx = if(a, b, c) (nothing to fold)" << EOF
+sx = if(a, b, c)
EOF
expect <<EOF
-x = (if a b c)
+sx = (if a b c)
EOF
#------------------------------------------------------------------------------
-ptest "fold conditional: x = if(1, b, c)" << EOF
-x = if(1, b, c)
+ptest "fold conditional: sx = if(1, b, c)" << EOF
+sx = if(1, b, c)
EOF
expect <<EOF
-x = b
+sx = b
EOF
#------------------------------------------------------------------------------
-ptest "fold conditional: x = if(0, b,c)" << EOF
-x = if(0, b, c)
+ptest "fold conditional: sx = if(0, b,c)" << EOF
+sx = if(0, b, c)
EOF
expect <<EOF
-x = c
+sx = c
EOF
###############################################################################
View
106 src/compiler/test/fold
@@ -3,153 +3,153 @@
###############################################################################
-ptest "constant folding: x = 1+2" << EOF
-x = 1+2
+ptest "constant folding: sx = 1+2" << EOF
+sx = 1+2
EOF
expect <<EOF
-x = 3
+sx = 3
EOF
#------------------------------------------------------------------------------
-ptest "constant folding: x = 1-2" << EOF
-x = 1-2
+ptest "constant folding: sx = 1-2" << EOF
+sx = 1-2
EOF
expect <<EOF
-x = -1
+sx = -1
EOF
#------------------------------------------------------------------------------
-ptest "constant folding: x = 2*3" << EOF
-x = 2*3
+ptest "constant folding: sx = 2*3" << EOF
+sx = 2*3
EOF
expect <<EOF
-x = 6
+sx = 6
EOF
#------------------------------------------------------------------------------
-ptest "constant folding: x = 4/5" << EOF
-x = 4/5
+ptest "constant folding: sx = 4/5" << EOF
+sx = 4/5
EOF
expect <<EOF
-x = 0.8
+sx = 0.8
EOF
#------------------------------------------------------------------------------
-ptest "constant folding: x = 2.8 % 0.5" << EOF
-x = 2.8 % 0.5
+ptest "constant folding: sx = 2.8 % 0.5" << EOF
+sx = 2.8 % 0.5
EOF
expect <<EOF
-x = 0.3
+sx = 0.3
EOF
#------------------------------------------------------------------------------
-ptest "constant folding: x = a+1 (nothign to fold)" << EOF
-x = a+1
+ptest "constant folding: sx = a+1 (nothign to fold)" << EOF
+sx = a+1
EOF
expect <<EOF
-x = (+ a 1)
+sx = (+ a 1)
EOF
#------------------------------------------------------------------------------
-ptest "constant folding: x = 1+b (nothign to fold)" << EOF
-x = 1+b
+ptest "constant folding: sx = 1+b (nothign to fold)" << EOF
+sx = 1+b
EOF
expect <<EOF
-x = (+ 1 b)
+sx = (+ 1 b)
EOF
#------------------------------------------------------------------------------
ptest "constant folding: above" << EOF
-x = above(1, 2)
-y = above(2, 1)
-z = above(1, 1)
+sx = above(1, 2)
+sy = above(2, 1)
+cx = above(1, 1)
EOF
expect <<EOF
-x = 0
-y = 1
-z = 0
+sx = 0
+sy = 1
+cx = 0
EOF
#------------------------------------------------------------------------------
ptest "constant folding: below" << EOF
-x = below(1, 2)
-y = below(2, 1)
-z = below(1, 1)
+sx = below(1, 2)
+sy = below(2, 1)
+cx = below(1, 1)
EOF
expect <<EOF
-x = 1
-y = 0
-z = 0
+sx = 1
+sy = 0
+cx = 0
EOF
#------------------------------------------------------------------------------
ptest "constant folding: equal" << EOF
-x = equal(1, 2)
-y = equal(2, 1)
-z = equal(1, 1)
+sx = equal(1, 2)
+sy = equal(2, 1)
+cx = equal(1, 1)
EOF
expect <<EOF
-x = 0
-y = 0
-z = 1
+sx = 0
+sy = 0
+cx = 1
EOF
#------------------------------------------------------------------------------
ptest "constant folding: max" << EOF
-x = max(2, 3)
-y = max(3, 2)
+sx = max(2, 3)
+sy = max(3, 2)
EOF
expect <<EOF
-x = 3
-y = 3
+sx = 3
+sy = 3
EOF
#------------------------------------------------------------------------------
ptest "constant folding: min" << EOF
-x = min(2, 3)
-y = min(3, 2)
+sx = min(2, 3)
+sy = min(3, 2)
EOF
expect <<EOF
-x = 2
-y = 2
+sx = 2
+sy = 2
EOF
#------------------------------------------------------------------------------
ptest "constant folding: unary minus" << EOF
-x = -2
+sx = -2
EOF
expect <<EOF
-x = -2
+sx = -2
EOF
#------------------------------------------------------------------------------
ptest "constant folding: sqr" << EOF
-x = sqr(3)
+sx = sqr(3)
EOF
expect <<EOF
-x = 9
+sx = 9
EOF
#------------------------------------------------------------------------------
ptest "constant folding: sqrt" << EOF
-x = sqrt(2.25)
+sx = sqrt(2.25)
EOF
expect <<EOF
-x = 1.5
+sx = 1.5
EOF
###############################################################################
View
6 src/compiler/test/image
@@ -32,13 +32,13 @@ EOF
#------------------------------------------------------------------------------
-ptest "image: imagefile2 = hel<nl>lo" <<EOF
+ptest "image: imagefile2 = hel<nl>sx" <<EOF
imagefile2 = hel
-lo = u
+sx = u
EOF
expect <<EOF
image 2 = "hel"
-lo = u
+sx = u
EOF
#------------------------------------------------------------------------------
View
48 src/compiler/test/initial
@@ -0,0 +1,48 @@
+#!/bin/sh
+. ./Common
+
+###############################################################################
+
+ptest "initial: initialize non-system to zero" <<EOF
+foo = 0
+EOF
+expect <<EOF
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest "initial: initialize per-frame to non-zero" <<EOF
+wave_x = 1
+EOF
+expect <<EOF
+wave_x = 1
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "initial: initialize per-vertex to non-zero" <<EOF
+_texsize = 1
+EOF
+expect <<EOF
+FPVM, line 2: can initialize non-system variables only to zero near 'EOF'
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "initial: initialize non-system to non-zero" <<EOF
+foo = 1
+EOF
+expect <<EOF
+FPVM, line 2: can initialize non-system variables only to zero near 'EOF'
+EOF
+
+#------------------------------------------------------------------------------
+
+ptest_fail "initial: initialize non-system to non-number" <<EOF
+foo = bar
+EOF
+expect <<EOF
+FPVM, line 2: can initialize non-system variables only to zero near 'EOF'
+EOF
+
+###############################################################################
View
60 src/compiler/test/location
@@ -4,12 +4,12 @@
###############################################################################
ptest_fail "location: scanner, inside line" <<EOF
-a = b
+rot = b
x = \` y
c = d
EOF
expect <<EOF
-a = b
+rot = b
FPVM, line 2: scan error near '\`'
EOF
@@ -27,72 +27,72 @@ EOF
#------------------------------------------------------------------------------
ptest_fail "location: scanner, end of line" <<EOF
-a = b
+sx = b
x = y\`
c = d
EOF
expect <<EOF
-a = b
+sx = b
FPVM, line 2: scan error near '\`'
EOF
#------------------------------------------------------------------------------
ptest_fail "location: parser, inside line" <<EOF
-a = b
+sx = b
x = * y
c = d
EOF
expect <<EOF
-a = b
+sx = b
FPVM, line 2: parse error near '*'
EOF
#------------------------------------------------------------------------------
ptest_fail "location: parser, beginning of line" <<EOF
-a = b
+sx = b
)x = y
c = d
EOF
expect <<EOF
-a = b
+sx = b
FPVM, line 2: parse error near ')x'
EOF
#------------------------------------------------------------------------------
ptest_fail "location: parser, end of line (1)" <<EOF
-a = b
-x = y(
+sx = b
+sy = y(
c = d
EOF
expect <<EOF
-a = b
-x = y
+sx = b
+sy = y
FPVM, line 2: parse error near '('
EOF
#------------------------------------------------------------------------------
ptest_fail "location: parser, end of line (2)" <<EOF
-a = b
+sx = b
x = )
c = d
EOF
expect <<EOF
-a = b
+sx = b
FPVM, line 2: parse error near ')'
EOF
#------------------------------------------------------------------------------
ptest_fail "location: error is end of line" <<EOF
-a = b
+sx = b
x =
EOF
expect <<EOF
-a = b
+sx = b
FPVM, line 3: parse error near 'EOF'
EOF
@@ -106,23 +106,23 @@ EOF
#------------------------------------------------------------------------------
ptest_fail "location: error is identifier" <<EOF
-foo = this is an error
+sx = this is an error
EOF
expect <<EOF
-foo = this
+sx = this
FPVM, line 1: parse error near 'an'
EOF
#------------------------------------------------------------------------------
ptest_fail "location: 3rd line" <<EOF
-a = b
-c = d
+sx = b
+sy = d
)
EOF
expect <<EOF
-a = b
-c = d
+sx = b
+sy = d
FPVM, line 3: parse error near ')'
EOF
@@ -130,28 +130,28 @@ EOF
ptest_fail "location: 5th line, with // comments" <<EOF
// assign a
-a = b
+sx = b
// assign c
-c = d
+sy = d
)
EOF
expect <<EOF
-a = b
-c = d
+sx = b
+sy = d
FPVM, line 5: parse error near ')'
EOF
#------------------------------------------------------------------------------
ptest_fail "location: 4th line, with /*...*/ comments" <<EOF
-a = b /* some
+sx = b /* some
comment */
-c = d
+sy = d
)
EOF
expect <<EOF
-a = b
-c = d
+sx = b
+sy = d
FPVM, line 4: parse error near ')'
EOF
View
40 src/compiler/test/not
@@ -4,10 +4,10 @@
###############################################################################
ptest "not: !a" << EOF
-x = !a
+sx = !a
EOF
expect <<EOF
-x = (! a)
+sx = (! a)
EOF
#------------------------------------------------------------------------------
@@ -22,82 +22,82 @@ EOF
#------------------------------------------------------------------------------
ptest "not: !0" << EOF
-x = !0
+sx = !0
EOF
expect <<EOF
-x = 1
+sx = 1
EOF
#------------------------------------------------------------------------------
ptest "not: !1" << EOF
-x = !1
+sx = !1
EOF
expect <<EOF
-x = 0
+sx = 0
EOF
#------------------------------------------------------------------------------
ptest "not: !a*b" << EOF
-x = !a*b
+sx = !a*b
EOF
expect <<EOF
-x = (* (! a) b)
+sx = (* (! a) b)
EOF
#------------------------------------------------------------------------------
ptest "not: -!a" << EOF
-x = -!a
+sx = -!a
EOF
expect <<EOF
-x = (- (! a))
+sx = (- (! a))
EOF
#------------------------------------------------------------------------------
ptest "not: !-b" << EOF
-x = !-b
+sx = !-b
EOF
expect <<EOF
-x = (! (- b))
+sx = (! (- b))
EOF
#------------------------------------------------------------------------------
ptest "not: if (!a, b, c)" << EOF
-x = if (!a, b, c)
+sx = if (!a, b, c)
EOF
expect <<EOF
-x = (if a c b)
+sx = (if a c b)
EOF
#------------------------------------------------------------------------------
ptest "not: !a ? b : c" << EOF
-x = !a ? b : c
+sx = !a ? b : c
EOF
expect <<EOF
-x = (if a c b)
+sx = (if a c b)
EOF
#------------------------------------------------------------------------------
ptest "not: !0 ? b : c" << EOF
-x = !0 ? b : c
+sx = !0 ? b : c
EOF
expect <<EOF
-x = b
+sx = b
EOF
#------------------------------------------------------------------------------
ptest "not: !1 ? b : c" << EOF
-x = !1 ? b : c
+sx = !1 ? b : c
EOF
expect <<EOF
-x = c
+sx = c
EOF
###############################################################################
View
34 src/compiler/test/number
@@ -3,53 +3,53 @@
###############################################################################
-ptest "number: a = 1" <<EOF
-a = 1
+ptest "number: sx = 1" <<EOF
+sx = 1
EOF
expect <<EOF
-a = 1
+sx = 1
EOF
#------------------------------------------------------------------------------
-ptest "number: b = 1.2" <<EOF
-b = 1.2
+ptest "number: sx = 1.2" <<EOF
+sx = 1.2
EOF
expect <<EOF
-b = 1.2
+sx = 1.2
EOF
#------------------------------------------------------------------------------
-ptest "number: c = .3" <<EOF
-c = .3
+ptest "number: sx = .3" <<EOF
+sx = .3
EOF
expect <<EOF
-c = 0.3
+sx = 0.3
EOF
#------------------------------------------------------------------------------
-ptest "number: d = 4." <<EOF
-d = 4.
+ptest "number: sx = 4." <<EOF
+sx = 4.
EOF
expect <<EOF
-d = 4
+sx = 4
EOF
#------------------------------------------------------------------------------
-ptest "number: e = 51.23" <<EOF
-e = 51.23
+ptest "number: sx = 51.23" <<EOF
+sx = 51.23
EOF
expect <<EOF
-e = 51.23
+sx = 51.23
EOF
#------------------------------------------------------------------------------
-ptest_fail "number: f = ." <<EOF
-f = .
+ptest_fail "number: sx = ." <<EOF
+sx = .
EOF
expect <<EOF
FPVM, line 1: scan error near '.'
View
2  src/compiler/test/patches
@@ -18,7 +18,7 @@ PATCHDIR=../../../patches
do_test()
{
- ptest "patch: $n" -c -q <"$PATCHDIR/$n"
+ ptest "patch: $n" -Wsection -c -q <"$PATCHDIR/$n"
expect </dev/null
}
View
84 src/compiler/test/prec
@@ -3,128 +3,128 @@
###############################################################################
-ptest "precedence: x = a+b*c+d" <<EOF
-x = a+b*c+d
+ptest "precedence: sx = a+b*c+d" <<EOF
+sx = a+b*c+d
EOF
expect <<EOF
-x = (+ (+ a (* b c)) d)
+sx = (+ (+ a (* b c)) d)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a+b/c+d" <<EOF
-x = a+b/c+d
+ptest "precedence: sx = a+b/c+d" <<EOF
+sx = a+b/c+d
EOF
expect <<EOF
-x = (+ (+ a (/ b c)) d)
+sx = (+ (+ a (/ b c)) d)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a+b%c+d" <<EOF
-x = a+b%c+d
+ptest "precedence: sx = a+b%c+d" <<EOF
+sx = a+b%c+d
EOF
expect <<EOF
-x = (+ (+ a (% b c)) d)
+sx = (+ (+ a (% b c)) d)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a-b*c-d" <<EOF
-x = a-b*c-d
+ptest "precedence: sx = a-b*c-d" <<EOF
+sx = a-b*c-d
EOF
expect <<EOF
-x = (- (- a (* b c)) d)
+sx = (- (- a (* b c)) d)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a-b/c-d" <<EOF
-x = a-b/c-d
+ptest "precedence: sx = a-b/c-d" <<EOF
+sx = a-b/c-d
EOF
expect <<EOF
-x = (- (- a (/ b c)) d)
+sx = (- (- a (/ b c)) d)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a-b%c-d" <<EOF
-x = a-b%c-d
+ptest "precedence: sx = a-b%c-d" <<EOF
+sx = a-b%c-d
EOF
expect <<EOF
-x = (- (- a (% b c)) d)
+sx = (- (- a (% b c)) d)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = -a*b" <<EOF
-x = -a*b
+ptest "precedence: sx = -a*b" <<EOF
+sx = -a*b
EOF
expect <<EOF
-x = (* (- a) b)
+sx = (* (- a) b)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a/b" <<EOF
-x = -a/b
+ptest "precedence: sx = a/b" <<EOF
+sx = -a/b
EOF
expect <<EOF
-x = (/ (- a) b)
+sx = (/ (- a) b)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a%b" <<EOF
-x = -a%b
+ptest "precedence: sx = a%b" <<EOF
+sx = -a%b
EOF
expect <<EOF
-x = (% (- a) b)
+sx = (% (- a) b)
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = -sin(a)" <<EOF
-x = -sin(a)
+ptest "precedence: sx = -sin(a)" <<EOF
+sx = -sin(a)
EOF
expect <<EOF
-x = (- (sin a))
+sx = (- (sin a))
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = -max(a, b)" <<EOF
-x = -max(a, b)
+ptest "precedence: sx = -max(a, b)" <<EOF
+sx = -max(a, b)
EOF
expect <<EOF
-x = (- (max a b))
+sx = (- (max a b))
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = -if(a, b, c)" <<EOF
-x = -if(a, b, c)
+ptest "precedence: sx = -if(a, b, c)" <<EOF
+sx = -if(a, b, c)
EOF
expect <<EOF
-x = (- (if a b c))
+sx = (- (if a b c))
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = -(a+b)" <<EOF
-x = -(a+b)
+ptest "precedence: sx = -(a+b)" <<EOF
+sx = -(a+b)
EOF
expect <<EOF
-x = (- (+ a b))
+sx = (- (+ a b))
EOF
#------------------------------------------------------------------------------
-ptest "precedence: x = a--b" <<EOF
-x = a--b
+ptest "precedence: sx = a--b" <<EOF
+sx = a--b
EOF
expect <<EOF
-x = (- a (- b))
+sx = (- a (- b))
EOF
###############################################################################
View
112 src/compiler/test/relop
@@ -4,211 +4,211 @@
###############################################################################
ptest "relop: a == b" << EOF
-x = a == b
+sx = a == b
EOF
expect <<EOF
-x = (equal a b)
+sx = (equal a b)
EOF
#------------------------------------------------------------------------------
ptest "relop: a < b" << EOF
-x = a < b
+sx = a < b
EOF
expect <<EOF
-x = (below a b)
+sx = (below a b)
EOF
#------------------------------------------------------------------------------
ptest "relop: a > b" << EOF
-x = a > b
+sx = a > b
EOF
expect <<EOF
-x = (above a b)
+sx = (above a b)
EOF
#------------------------------------------------------------------------------
ptest "relop: fold ==" << EOF
-x = 1 == 2
-y = 2 == 2
-z = 3 == 2
+sx = 1 == 2
+sy = 2 == 2
+cx = 3 == 2
EOF
expect <<EOF
-x = 0
-y = 1
-z = 0
+sx = 0
+sy = 1
+cx = 0
EOF
#------------------------------------------------------------------------------
ptest "relop: fold <" << EOF
-x = 1 < 2
-y = 2 < 2
-z = 3 < 2
+sx = 1 < 2
+sy = 2 < 2
+cx = 3 < 2
EOF
expect <<EOF
-x = 1
-y = 0
-z = 0
+sx = 1
+sy = 0
+cx = 0
EOF
#------------------------------------------------------------------------------
ptest "relop: fold >" << EOF
-x = 1 > 2
-y = 2 > 2
-z = 3 > 2
+sx = 1 > 2
+sy = 2 > 2
+cx = 3 > 2
EOF
expect <<EOF
-x = 0
-y = 0
-z = 1
+sx = 0
+sy = 0
+cx = 1
EOF
#------------------------------------------------------------------------------
ptest "relop: a == b ? c : d" << EOF
-x = a == b ? c : d
+sx = a == b ? c : d
EOF
expect <<EOF
-x = (if (equal a b) c d)
+sx = (if (equal a b) c d)
EOF
#------------------------------------------------------------------------------
ptest "relop: a ? b : c == d" << EOF
-x = a ? b : c == d
+sx = a ? b : c == d
EOF
expect <<EOF
-x = (if a b (equal c d))
+sx = (if a b (equal c d))
EOF
#------------------------------------------------------------------------------
ptest "relop: a < b == c > d" << EOF
-x = a < b == c > d
+sx = a < b == c > d
EOF
expect <<EOF
-x = (equal (below a b) (above c d))
+sx = (equal (below a b) (above c d))
EOF
#------------------------------------------------------------------------------
ptest "relop: a+b < c-d" << EOF
-x = a+b < c-d
+sx = a+b < c-d
EOF
expect <<EOF
-x = (below (+ a b) (- c d))
+sx = (below (+ a b) (- c d))
EOF
#------------------------------------------------------------------------------
ptest "relop: a-b > c+d" << EOF
-x = a-b > c+d
+sx = a-b > c+d
EOF
expect <<EOF
-x = (above (- a b) (+ c d))
+sx = (above (- a b) (+ c d))
EOF
#------------------------------------------------------------------------------
ptest "relop: a != b" << EOF
-x = a != b
+sx = a != b
EOF
expect <<EOF
-x = (! (equal a b))
+sx = (! (equal a b))
EOF
#------------------------------------------------------------------------------
ptest "relop: a <= b" << EOF
-x = a <= b
+sx = a <= b
EOF
expect <<EOF
-x = (! (above a b))
+sx = (! (above a b))
EOF
#------------------------------------------------------------------------------
ptest "relop: a >= b" << EOF
-x = a >= b
+sx = a >= b
EOF
expect <<EOF
-x = (! (below a b))
+sx = (! (below a b))
EOF
#------------------------------------------------------------------------------
ptest "relop: a < b != c >= d" << EOF
-x = a < b != c >= d
+sx = a < b != c >= d
EOF
expect <<EOF
-x = (! (equal (below a b) (! (below c d))))
+sx = (! (equal (below a b) (! (below c d))))
EOF
#------------------------------------------------------------------------------
ptest "relop: a+b <= c-d" << EOF
-x = a+b <= c-d
+sx = a+b <= c-d
EOF
expect <<EOF
-x = (! (above (+ a b) (- c d)))
+sx = (! (above (+ a b) (- c d)))
EOF
#------------------------------------------------------------------------------
ptest "relop: a-b >= c+d" << EOF
-x = a-b >= c+d
+sx = a-b >= c+d
EOF
expect <<EOF
-x = (! (below (- a b) (+ c d)))
+sx = (! (below (- a b) (+ c d)))
EOF
#------------------------------------------------------------------------------
ptest "relop: a != b ? c : d" << EOF
-x = a != b ? c : d
+sx = a != b ? c : d
EOF
expect <<EOF
-x = (if (equal a b) d c)
+sx = (if (equal a b) d c)
EOF
#------------------------------------------------------------------------------
ptest "relop: a <= b ? c : d" << EOF
-x = a <= b ? c : d
+sx = a <= b ? c : d
EOF
expect <<EOF
-x = (if (above a b) d c)
+sx = (if (above a b) d c)
EOF
#------------------------------------------------------------------------------
ptest "relop: a >= b ? c : d" << EOF
-x = a >= b ? c : d
+sx = a >= b ? c : d
EOF
expect <<EOF
-x = (if (below a b) d c)
+sx = (if (below a b) d c)
EOF
#------------------------------------------------------------------------------
ptest "relop: 1 != 2 ? c : d" << EOF
-x = 1 != 2 ? c : d
+sx = 1 != 2 ? c : d
EOF
expect <<EOF
-x = c
+sx = c
EOF
#------------------------------------------------------------------------------
ptest "relop: 2 != 2 ? c : d" << EOF
-x = 2 != 2 ? c : d
+sx = 2 != 2 ? c : d
EOF
expect <<EOF
-x = d
+sx = d
EOF
###############################################################################
View
8 src/compiler/test/sections
@@ -4,10 +4,10 @@
###############################################################################
ptest "sections: only global" <<EOF
-foo = bar
+sx = bar
EOF
expect <<EOF
-foo = bar
+sx = bar
EOF
#------------------------------------------------------------------------------
@@ -53,7 +53,7 @@ EOF
#------------------------------------------------------------------------------
ptest "sections: global, per frame, then per vertex" <<EOF
-x = y
+sx = y
per_frame:
a = b
c = d
@@ -62,7 +62,7 @@ per_vertex:
g = h
EOF
expect <<EOF
-x = y
+sx = y
per_frame = a = b
per_frame = c = d
per_vertex = e = f
View
42 src/compiler/test/wrap
@@ -4,75 +4,75 @@
###############################################################################
ptest "wrap: baseline" <<EOF
-a = b + c
+sx = b + c
EOF
expect <<EOF
-a = (+ b c)
+sx = (+ b c)
EOF
#------------------------------------------------------------------------------
ptest "wrap: with newline" <<EOF
-a = b +
+sx = b +
c
EOF
expect <<EOF
-a = (+ b c)
+sx = (+ b c)
EOF
#------------------------------------------------------------------------------
ptest "wrap: two assignments on two lines" <<EOF
-a = b + c
-d = e + f
+sx = b + c
+sy = e + f
EOF
expect <<EOF
-a = (+ b c)
-d = (+ e f)
+sx = (+ b c)
+sy = (+ e f)
EOF
#------------------------------------------------------------------------------
ptest "wrap: two assignments on one line" <<EOF
-a = b + c d = e + f
+sx = b + c sy = e + f
EOF
expect <<EOF
-a = (+ b c)
-d = (+ e f)
+sx = (+ b c)
+sy = (+ e f)
EOF
#------------------------------------------------------------------------------
ptest "wrap: one assignment ending with semicolon" <<EOF
-a = b + c;
+sx = b + c;
EOF
expect <<EOF
-a = (+ b c)
+sx = (+ b c)
EOF
#------------------------------------------------------------------------------
ptest "wrap: one assignment ending with multiple semicolons" <<EOF
-a = b + c;;;;;;;;;;;
+sx = b + c;;;;;;;;;;;
EOF
expect <<EOF
-a = (+ b c)
+sx = (+ b c)
EOF
#------------------------------------------------------------------------------
ptest "wrap: two assignments separated by semicolon" <<EOF
-a = b + c; d = e + f
+sx = b + c; sy = e + f
EOF
expect <<EOF
-a = (+ b c)
-d = (+ e f)
+sx = (+ b c)
+sy = (+ e f)
EOF
#------------------------------------------------------------------------------
ptest_fail "wrap: one assignment containing semicolon (1)" <<EOF
-a = b +; c
+sx = b +; c
EOF
expect <<EOF
FPVM, line 1: parse error near ';'
@@ -81,10 +81,10 @@ EOF
#------------------------------------------------------------------------------
ptest_fail "wrap: one assignment containing semicolon (2)" <<EOF
-a = b; + c
+sx = b; + c
EOF
expect <<EOF
-a = b
+sx = b
FPVM, line 1: parse error near '+'
EOF
View
79 src/compiler/test/wsection
@@ -0,0 +1,79 @@
+#!/bin/sh
+. ./Common
+
+###############################################################################