Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'symtab'

  • Loading branch information...
commit 6cd45f7bb8abaed204628ec8566fa1690b84bf97 2 parents 6bc121b + 7496b45
Werner Almesberger authored January 13, 2012

Showing 47 changed files with 1,742 additions and 1,395 deletions. Show diff stats Hide diff stats

  1. 15  patches/Unchained - A Matter Of Taste (Remix).fnp
  2. 5  src/Makefile
  3. 18  src/compiler/Makefile
  4. 275  src/compiler/compiler.c
  5. 5  src/compiler/compiler.h
  6. 396  src/compiler/fnp.ids
  7. 22  src/compiler/idgen
  8. 472  src/compiler/parser.y
  9. 128  src/compiler/parser_helper.c
  10. 23  src/compiler/parser_helper.h
  11. 14  src/compiler/parser_itf.h
  12. 10  src/compiler/ptest/Makefile
  13. 105  src/compiler/ptest/ptest.c
  14. 8  src/compiler/scanner.h
  15. 16  src/compiler/scanner.re
  16. 158  src/compiler/symtab.c
  17. 44  src/compiler/symtab.h
  18. 7  src/compiler/test/Common
  19. 73  src/compiler/test/Patches
  20. 30  src/compiler/test/arith
  21. 4  src/compiler/test/codegen
  22. 94  src/compiler/test/comment
  23. 24  src/compiler/test/cond
  24. 34  src/compiler/test/dualuse
  25. 51  src/compiler/test/eqnum
  26. 22  src/compiler/test/error
  27. 36  src/compiler/test/fcond
  28. 106  src/compiler/test/fold
  29. 6  src/compiler/test/image
  30. 48  src/compiler/test/initial
  31. 86  src/compiler/test/location
  32. 68  src/compiler/test/not
  33. 32  src/compiler/test/nsyms
  34. 36  src/compiler/test/number
  35. 75  src/compiler/test/patches
  36. 84  src/compiler/test/prec
  37. 112  src/compiler/test/relop
  38. 28  src/compiler/test/sections
  39. 46  src/compiler/test/wrap
  40. 79  src/compiler/test/wsection
  41. 77  src/compiler/test/wundef
  42. 135  src/compiler/unique.c
  43. 18  src/compiler/unique.h
  44. 4  src/gui/monitor.c
  45. 2  src/renderer/eval.c
  46. 1  src/renderer/framedescriptor.h
  47. 5  src/renderer/sampler.c
15  patches/Unchained - A Matter Of Taste (Remix).fnp
@@ -38,16 +38,17 @@ ib_r=0.250000
38 38
 ib_g=0.250000
39 39
 ib_b=0.250000
40 40
 ib_a=0.000000
41  
-per_frame=pulse=above(bass,0.7)//if(above(abs(pulse),9.42),-9.42,pulse+.1*bor(bor(bass_changed*bnot(treb_changed),treb_changed*bnot(bass_changed))*bnot(mid_changed),mid_changed)+(mid+bass+treb)*entropy*.01);
42  
-per_frame=q1=mid_residual;
43  
-per_frame=q2=bass_residual;
44  
-per_frame=q3=treb_residual;
  41
+per_frame=pulse=above(bass,0.7);
  42
+//if(above(abs(pulse),9.42),-9.42,pulse+.1*bor(bor(bass_changed*bnot(treb_changed),treb_changed*bnot(bass_changed))*bnot(mid_changed),mid_changed)+(mid+bass+treb)*entropy*.01);
  43
+//per_frame=q1=mid_residual;
  44
+//per_frame=q2=bass_residual;
  45
+//per_frame=q3=treb_residual;
45 46
 per_frame=q4=sin(pulse);
46 47
 per_frame=q5=cos(pulse);
47 48
 per_frame=wave_mystery=-.2+.2*q4;
48  
-per_frame=wave_r=wave_r+.5*bass_residual;
49  
-per_frame=wave_r=wave_g+.5*mid_residual;
50  
-per_frame=wave_r=wave_b+.5*treb_residual;
  49
+//per_frame=wave_r=wave_r+.5*bass_residual;
  50
+//per_frame=wave_r=wave_g+.5*mid_residual;
  51
+//per_frame=wave_r=wave_b+.5*treb_residual;
51 52
 per_frame=zoom=zoom-.0035*q1;
52 53
 per_frame=decay=decay+.003*sin(pulse);
53 54
 per_vertex=anti_rad=(1-rad);
5  src/Makefile
@@ -34,6 +34,7 @@ endif
34 34
 
35 35
 CFLAGS = -O9 -Wall -Wstrict-prototypes -Wmissing-prototypes \
36 36
 	 -Wold-style-declaration -Wold-style-definition \
  37
+	 -Wno-char-subscripts \
37 38
 	 -mbarrel-shift-enabled -mmultiply-enabled \
38 39
 	 -mdivide-enabled -msign-extend-enabled -fsingle-precision-constant \
39 40
 	 -I$(RTEMS_MAKEFILE_PATH)/lib/include -g
@@ -63,7 +64,7 @@ OBJS += $(addprefix renderer/,framedescriptor.o analyzer.o sampler.o \
63 64
 	eval.o line.o wave.o font.o osd.o raster.o renderer.o \
64 65
 	videoinreconf.o)
65 66
 OBJS += $(addprefix compiler/,compiler.o parser_helper.o scanner.o \
66  
-	parser.o unique.o)
  67
+	parser.o symtab.o)
67 68
 
68 69
 POBJS=$(addprefix $(OBJDIR)/,$(OBJS))
69 70
 
@@ -99,7 +100,7 @@ compiler/infra-fnp.h: \
99 100
 compiler/parser.h: compiler/parser.c
100 101
 obj/compiler/scanner.o: compiler/parser.h
101 102
 obj/compiler/parser_helper.o: compiler/parser.h
102  
-obj/compiler/unique.o: compiler/fnp.inc
  103
+obj/compiler/symtab.o: compiler/fnp.inc
103 104
 obj/compiler/compiler.o: compiler/infra-fnp.h compiler/parser.h
104 105
 
105 106
 # boot images for Milkymist One
18  src/compiler/Makefile
@@ -7,18 +7,24 @@ all:
7 7
 # ----- Tests -----------------------------------------------------------------
8 8
 
9 9
 test tests:     all
10  
-		LANG= sh -c \
11  
-		    'passed=0 && cd test && \
12  
-		    for n in [a-z]*; do \
13  
-		    [ $$n != core ] && SCRIPT=$$n . ./$$n; done; \
14  
-		    echo "Passed all $$passed tests"'
  10
+		LANG= sh -c						\
  11
+		    'passed=0 && failed=0 && cd test &&			\
  12
+		    for n in [a-z]*; do					\
  13
+		    [ $$n != core ] && SCRIPT=$$n . ./$$n; done;	\
  14
+		    if [ $$failed = 0 ]; then				\
  15
+		        echo "Passed all $$passed tests";		\
  16
+		    else						\
  17
+			total=`expr $$passed + $$failed`;		\
  18
+		        echo "Failed $$failed/$$total tests";		\
  19
+			exit 1;						\
  20
+		    fi'
15 21
 
16 22
 valgrind:
17 23
 		VALGRIND="valgrind -q" $(MAKE) tests
18 24
 
19 25
 leak leaks:
20 26
 		VALGRIND="valgrind -q --leak-check=full --show-reachable=yes" \
21  
-		    $(MAKE) tests
  27
+		    FAIL_ON_ERROR=false $(MAKE) tests
22 28
 
23 29
 # ----- Cleanup ---------------------------------------------------------------
24 30
 
275  src/compiler/compiler.c
@@ -23,12 +23,13 @@
23 23
 #include <string.h>
24 24
 
25 25
 #include <fpvm/fpvm.h>
  26
+#include <fpvm/symbol.h>
26 27
 #include <fpvm/ast.h>
27 28
 #include <fpvm/schedulers.h>
28 29
 #include <fpvm/pfpu.h>
29 30
 
30 31
 #include "../pixbuf/pixbuf.h"
31  
-#include "unique.h"
  32
+#include "symtab.h"
32 33
 #include "parser_helper.h"
33 34
 #include "parser.h"
34 35
 #include "compiler.h"
@@ -65,10 +66,10 @@ static void init_fpvm(struct fpvm_fragment *fragment, int vector_mode)
65 66
 	 * the same. We can get rid of these calls to unique() later.
66 67
 	 */
67 68
 
68  
-	_Xi = unique("_Xi");
69  
-	_Xo = unique("_Xo");
70  
-	_Yi = unique("_Yi");
71  
-	_Yo = unique("_Yo");
  69
+	_Xi = &unique("_Xi")->fpvm_sym;
  70
+	_Xo = &unique("_Xo")->fpvm_sym;
  71
+	_Yi = &unique("_Yi")->fpvm_sym;
  72
+	_Yo = &unique("_Yo")->fpvm_sym;
72 73
 	fpvm_do_init(fragment, vector_mode);
73 74
 }
74 75
 
@@ -76,9 +77,9 @@ static void init_fpvm(struct fpvm_fragment *fragment, int vector_mode)
76 77
 
77 78
 
78 79
 static const char *assign_chunk(struct parser_comm *comm,
79  
-    const char *label, struct ast_node *node)
  80
+    struct sym *sym, struct ast_node *node)
80 81
 {
81  
-	if(fpvm_do_assign(comm->u.fragment, label, node))
  82
+	if(fpvm_do_assign(comm->u.fragment, &sym->fpvm_sym, node))
82 83
 		return NULL;
83 84
 	else
84 85
 		return strdup(fpvm_get_last_error(comm->u.fragment));
@@ -92,14 +93,12 @@ static int compile_chunk(struct fpvm_fragment *fragment, const char *chunk)
92 93
 		.assign_per_frame = NULL,	/* crash ... */
93 94
 		.assign_per_vertex = NULL,	/* and burn */
94 95
 	};
95  
-	const char *error;
96 96
 
97  
-	error = parse(chunk, TOK_START_ASSIGN, &comm);
98  
-	if(error) {
99  
-		snprintf(fragment->last_error, FPVM_MAXERRLEN, "%s", error);
100  
-		free((void *) error);
101  
-	}
102  
-	return !error;
  97
+	if(parse(chunk, TOK_START_ASSIGN, &comm))
  98
+		return 1;
  99
+	snprintf(fragment->last_error, FPVM_MAXERRLEN, "%s", comm.msg);
  100
+	free((void *) comm.msg);
  101
+	return 0;
103 102
 }
104 103
 
105 104
 
@@ -107,139 +106,9 @@ static int compile_chunk(struct fpvm_fragment *fragment, const char *chunk)
107 106
 /* PER-FRAME VARIABLES                                          */
108 107
 /****************************************************************/
109 108
 
110  
-const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN] = {
111  
-	"sx",
112  
-	"sy",
113  
-	"cx",
114  
-	"cy",
115  
-	"rot",
116  
-	"dx",
117  
-	"dy",
118  
-	"zoom",
119  
-	"decay",
120  
-	"wave_mode",
121  
-	"wave_scale",
122  
-	"wave_additive",
123  
-	"wave_usedots",
124  
-	"wave_brighten",
125  
-	"wave_thick",
126  
-	"wave_x",
127  
-	"wave_y",
128  
-	"wave_r",
129  
-	"wave_g",
130  
-	"wave_b",
131  
-	"wave_a",
132  
-
133  
-	"ob_size",
134  
-	"ob_r",
135  
-	"ob_g",
136  
-	"ob_b",
137  
-	"ob_a",
138  
-	"ib_size",
139  
-	"ib_r",
140  
-	"ib_g",
141  
-	"ib_b",
142  
-	"ib_a",
143  
-
144  
-	"nMotionVectorsX",
145  
-	"nMotionVectorsY",
146  
-	"mv_dx",
147  
-	"mv_dy",
148  
-	"mv_l",
149  
-	"mv_r",
150  
-	"mv_g",
151  
-	"mv_b",
152  
-	"mv_a",
153  
-
154  
-	"bTexWrap",
155  
-
156  
-	"time",
157  
-	"bass",
158  
-	"mid",
159  
-	"treb",
160  
-	"bass_att",
161  
-	"mid_att",
162  
-	"treb_att",
163  
-
164  
-	"warp",
165  
-	"fWarpAnimSpeed",
166  
-	"fWarpScale",
167  
-
168  
-	"q1",
169  
-	"q2",
170  
-	"q3",
171  
-	"q4",
172  
-	"q5",
173  
-	"q6",
174  
-	"q7",
175  
-	"q8",
176  
-
177  
-	"fVideoEchoAlpha",
178  
-	"fVideoEchoZoom",
179  
-	"nVideoEchoOrientation",
180  
-
181  
-	"dmx1",
182  
-	"dmx2",
183  
-	"dmx3",
184  
-	"dmx4",
185  
-	"dmx5",
186  
-	"dmx6",
187  
-	"dmx7",
188  
-	"dmx8",
189  
-
190  
-	"idmx1",
191  
-	"idmx2",
192  
-	"idmx3",
193  
-	"idmx4",
194  
-	"idmx5",
195  
-	"idmx6",
196  
-	"idmx7",
197  
-	"idmx8",
198  
-
199  
-	"osc1",
200  
-	"osc2",
201  
-	"osc3",
202  
-	"osc4",
203  
-
204  
-	"midi1",
205  
-	"midi2",
206  
-	"midi3",
207  
-	"midi4",
208  
-	"midi5",
209  
-	"midi6",
210  
-	"midi7",
211  
-	"midi8",
212  
-
213  
-	"video_a",
214  
-
215  
-	"image1_a",
216  
-	"image1_x",
217  
-	"image1_y",
218  
-	"image1_zoom",
219  
-	"image2_a",
220  
-	"image2_x",
221  
-	"image2_y",
222  
-	"image2_zoom"
223  
-};
224  
-
225  
-static int pfv_from_name(const char *name)
  109
+static int pfv_from_sym(const struct sym *sym)
226 110
 {
227  
-	int i;
228  
-
229  
-	for(i=0;i<COMP_PFV_COUNT;i++) {
230  
-		if(strcmp(pfv_names[i], name) == 0)
231  
-			return i;
232  
-	}
233  
-
234  
-	if(strcmp(name, "fDecay") == 0) return pfv_decay;
235  
-	if(strcmp(name, "nWaveMode") == 0) return pfv_wave_mode;
236  
-	if(strcmp(name, "fWaveScale") == 0) return pfv_wave_scale;
237  
-	if(strcmp(name, "bAdditiveWaves") == 0) return pfv_wave_additive;
238  
-	if(strcmp(name, "bWaveDots") == 0) return pfv_wave_usedots;
239  
-	if(strcmp(name, "bMaximizeWaveColor") == 0) return pfv_wave_brighten;
240  
-	if(strcmp(name, "bWaveThick") == 0) return pfv_wave_thick;
241  
-	if(strcmp(name, "fWaveAlpha") == 0) return pfv_wave_a;
242  
-	return -1;
  111
+	return sym->pfv_idx;
243 112
 }
244 113
 
245 114
 static void pfv_update_patch_requires(struct compiler_sc *sc, int pfv)
@@ -314,12 +183,12 @@ static void all_initials_to_pfv(struct compiler_sc *sc)
314 183
 		initial_to_pfv(sc, i);
315 184
 }
316 185
 
317  
-static void pfv_bind_callback(void *_sc, const char *sym, int reg)
  186
+static void pfv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
318 187
 {
319 188
 	struct compiler_sc *sc = _sc;
320 189
 	int pfv;
321 190
 
322  
-	pfv = pfv_from_name(sym);
  191
+	pfv = pfv_from_sym(FPVM2SYM(sym));
323 192
 	if(pfv >= 0) {
324 193
 		pfv_update_patch_requires(sc, pfv);
325 194
 		sc->p->pfv_allocation[pfv] = reg;
@@ -377,76 +246,9 @@ static bool schedule_pfv(struct compiler_sc *sc)
377 246
 /* PER-VERTEX VARIABLES                                         */
378 247
 /****************************************************************/
379 248
 
380  
-const char pvv_names[COMP_PVV_COUNT][FPVM_MAXSYMLEN] = {
381  
-	/* System */
382  
-	"_texsize",
383  
-	"_hmeshsize",
384  
-	"_vmeshsize",
385  
-
386  
-	/* MilkDrop */
387  
-	"sx",
388  
-	"sy",
389  
-	"cx",
390  
-	"cy",
391  
-	"rot",
392  
-	"dx",
393  
-	"dy",
394  
-	"zoom",
395  
-
396  
-	"time",
397  
-	"bass",
398  
-	"mid",
399  
-	"treb",
400  
-	"bass_att",
401  
-	"mid_att",
402  
-	"treb_att",
403  
-
404  
-	"warp",
405  
-	"fWarpAnimSpeed",
406  
-	"fWarpScale",
407  
-
408  
-	"q1",
409  
-	"q2",
410  
-	"q3",
411  
-	"q4",
412  
-	"q5",
413  
-	"q6",
414  
-	"q7",
415  
-	"q8",
416  
-
417  
-	"idmx1",
418  
-	"idmx2",
419  
-	"idmx3",
420  
-	"idmx4",
421  
-	"idmx5",
422  
-	"idmx6",
423  
-	"idmx7",
424  
-	"idmx8",
425  
-
426  
-	"osc1",
427  
-	"osc2",
428  
-	"osc3",
429  
-	"osc4",
430  
-
431  
-	"midi1",
432  
-	"midi2",
433  
-	"midi3",
434  
-	"midi4",
435  
-	"midi5",
436  
-	"midi6",
437  
-	"midi7",
438  
-	"midi8",
439  
-};
440  
-
441  
-static int pvv_from_name(const char *name)
  249
+static int pvv_from_sym(const struct sym *sym)
442 250
 {
443  
-	int i;
444  
-
445  
-	for(i=0;i<COMP_PVV_COUNT;i++) {
446  
-		if(strcmp(pvv_names[i], name) == 0)
447  
-			return i;
448  
-	}
449  
-	return -1;
  251
+	return sym->pvv_idx;
450 252
 }
451 253
 
452 254
 static void pvv_update_patch_requires(struct compiler_sc *sc, int pvv)
@@ -459,12 +261,12 @@ static void pvv_update_patch_requires(struct compiler_sc *sc, int pvv)
459 261
 		sc->p->require |= REQUIRE_MIDI;
460 262
 }
461 263
 
462  
-static void pvv_bind_callback(void *_sc, const char *sym, int reg)
  264
+static void pvv_bind_callback(void *_sc, struct fpvm_sym *sym, int reg)
463 265
 {
464 266
 	struct compiler_sc *sc = _sc;
465 267
 	int pvv;
466 268
 
467  
-	pvv = pvv_from_name(sym);
  269
+	pvv = pvv_from_sym(FPVM2SYM(sym));
468 270
 	if(pvv >= 0) {
469 271
 		pvv_update_patch_requires(sc, pvv);
470 272
 		sc->p->pvv_allocation[pvv] = reg;
@@ -540,13 +342,13 @@ static bool schedule_pvv(struct compiler_sc *sc)
540 342
 /****************************************************************/
541 343
 
542 344
 static const char *assign_default(struct parser_comm *comm,
543  
-    const char *label, struct ast_node *node)
  345
+    struct sym *sym, struct ast_node *node)
544 346
 {
545 347
 	struct compiler_sc *sc = comm->u.sc;
546 348
 	int pfv;
547 349
 	float v;
548 350
 
549  
-	pfv = pfv_from_name(label);
  351
+	pfv = pfv_from_sym(sym);
550 352
 	if(pfv < 0)
551 353
 		return strdup("unknown parameter");
552 354
 
@@ -571,24 +373,24 @@ static const char *assign_default(struct parser_comm *comm,
571 373
 }
572 374
 
573 375
 static const char *assign_fragment(struct fpvm_fragment *frag,
574  
-    const char *label, struct ast_node *node)
  376
+    struct sym *sym, struct ast_node *node)
575 377
 {
576  
-	if(fpvm_do_assign(frag, label, node))
  378
+	if(fpvm_do_assign(frag, &sym->fpvm_sym, node))
577 379
 		return NULL;
578 380
 	else
579 381
 		return strdup(fpvm_get_last_error(frag));
580 382
 }
581 383
 
582 384
 static const char *assign_per_frame(struct parser_comm *comm,
583  
-    const char *label, struct ast_node *node)
  385
+    struct sym *sym, struct ast_node *node)
584 386
 {
585  
-	return assign_fragment(&comm->u.sc->pfv_fragment, label, node);
  387
+	return assign_fragment(&comm->u.sc->pfv_fragment, sym, node);
586 388
 }
587 389
 
588 390
 static const char *assign_per_vertex(struct parser_comm *comm,
589  
-    const char *label, struct ast_node *node)
  391
+    struct sym *sym, struct ast_node *node)
590 392
 {
591  
-	return assign_fragment(&comm->u.sc->pvv_fragment, label, node);
  393
+	return assign_fragment(&comm->u.sc->pvv_fragment, sym, node);
592 394
 }
593 395
 
594 396
 static const char *assign_image_name(struct parser_comm *comm,
@@ -627,14 +429,13 @@ static bool parse_patch(struct compiler_sc *sc, const char *patch_code)
627 429
 		.assign_per_vertex = assign_per_vertex,
628 430
 		.assign_image_name = assign_image_name,
629 431
 	};
630  
-	const char *error;
  432
+	int ok;
631 433
 
632  
-	error = parse(patch_code, TOK_START_ASSIGN, &comm);
633  
-	if(error) {
634  
-		sc->rmc(error);
635  
-		free((void *) error);
636  
-	}
637  
-	return !error;
  434
+	ok = parse(patch_code, TOK_START_ASSIGN, &comm);
  435
+	if(comm.msg)
  436
+		sc->rmc(comm.msg);
  437
+	free((void *) comm.msg);
  438
+	return ok;
638 439
 }
639 440
 
640 441
 struct patch *patch_compile(const char *basedir, const char *patch_code,
@@ -665,6 +466,8 @@ struct patch *patch_compile(const char *basedir, const char *patch_code,
665 466
 	sc->rmc = rmc;
666 467
 	sc->linenr = 0;
667 468
 
  469
+	symtab_init();
  470
+
668 471
 	load_defaults(sc);
669 472
 	if(!init_pfv(sc)) goto fail;
670 473
 	if(!init_pvv(sc)) goto fail;
@@ -677,13 +480,13 @@ struct patch *patch_compile(const char *basedir, const char *patch_code,
677 480
 	if(!finalize_pvv(sc)) goto fail;
678 481
 	if(!schedule_pvv(sc)) goto fail;
679 482
 
680  
-	unique_free();
  483
+	symtab_free();
681 484
 
682 485
 	free(sc);
683 486
 	return p;
684 487
 
685 488
 fail:
686  
-	unique_free();
  489
+	symtab_free();
687 490
 	free(sc->p);
688 491
 	free(sc);
689 492
 	return NULL;
5  src/compiler/compiler.h
@@ -77,6 +77,7 @@ enum {
77 77
 	pfv_tex_wrap,
78 78
 
79 79
 	pfv_time,
  80
+	pfv_frame,
80 81
 	pfv_bass,
81 82
 	pfv_mid,
82 83
 	pfv_treb,
@@ -164,6 +165,7 @@ enum {
164 165
 	pvv_zoom,
165 166
 
166 167
 	pvv_time,
  168
+	pvv_frame,
167 169
 	pvv_bass,
168 170
 	pvv_mid,
169 171
 	pvv_treb,
@@ -236,9 +238,6 @@ struct patch {
236 238
 
237 239
 typedef void (*report_message)(const char *);
238 240
 
239  
-extern const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN];
240  
-extern const char pvv_names[COMP_PVV_COUNT][FPVM_MAXSYMLEN];
241  
-
242 241
 struct patch *patch_compile(const char *basedir, const char *patch_code, report_message rmc);
243 242
 struct patch *patch_compile_filename(const char *filename, const char *patch_code, report_message rmc);
244 243
 struct patch *patch_copy(struct patch *p);
396  src/compiler/fnp.ids
@@ -11,232 +11,152 @@
11 11
 #
12 12
 
13 13
 #
14  
-# Built-in functions
15  
-#
16  
-
17  
-above
18  
-abs
19  
-below
20  
-cos
21  
-equal
22  
-f2i
23  
-icos
24  
-i2f
25  
-if
26  
-int
27  
-invsqrt
28  
-isin
29  
-max
30  
-min
31  
-quake
32  
-sin
33  
-sqr
34  
-sqrt
35  
-tsign
36  
-
37  
-#
38  
-#
39  
-# Per-Frame Variables
40  
-#
41  
-
42  
-sx
43  
-sy
44  
-cx
45  
-cy
46  
-rot
47  
-dx
48  
-dy
49  
-zoom
50  
-decay
51  
-wave_mode
52  
-wave_scale
53  
-wave_additive
54  
-wave_usedots
55  
-wave_brighten
56  
-wave_thick
57  
-wave_x
58  
-wave_y
59  
-wave_r
60  
-wave_g
61  
-wave_b
62  
-wave_a
63  
-
64  
-ob_size
65  
-ob_r
66  
-ob_g
67  
-ob_b
68  
-ob_a
69  
-ib_size
70  
-ib_r
71  
-ib_g
72  
-ib_b
73  
-ib_a
74  
-
75  
-nMotionVectorsY
76  
-mv_dx
77  
-mv_dy
78  
-mv_l
79  
-mv_r
80  
-mv_g
81  
-mv_b
82  
-mv_a
83  
-
84  
-bTexWrap
85  
-
86  
-time
87  
-bass
88  
-mid
89  
-treb
90  
-bass_att
91  
-mid_att
92  
-treb_att
93  
-
94  
-warp
95  
-fWarpAnimSpeed
96  
-fWarpScale
97  
-
98  
-q1
99  
-q2
100  
-q3
101  
-q4
102  
-q5
103  
-q6
104  
-q7
105  
-q8
106  
-
107  
-fVideoEchoAlpha
108  
-fVideoEchoZoom
109  
-nVideoEchoOrientation
110  
-
111  
-dmx1
112  
-dmx2
113  
-dmx3
114  
-dmx4
115  
-dmx5
116  
-dmx6
117  
-dmx7
118  
-dmx8
119  
-
120  
-idmx1
121  
-idmx2
122  
-idmx3
123  
-idmx4
124  
-idmx5
125  
-idmx6
126  
-idmx7
127  
-idmx8
128  
-
129  
-osc1
130  
-osc2
131  
-osc3
132  
-osc4
133  
-
134  
-midi1
135  
-midi2
136  
-midi3
137  
-midi4
138  
-midi5
139  
-midi6
140  
-midi7
141  
-midi8
142  
-
143  
-video_a
144  
-
145  
-image1_a
146  
-image1_x
147  
-image1_y
148  
-image1_zoom
149  
-image2_a
150  
-image2_x
151  
-image2_y
152  
-image2_zoom
  14
+# Per-Frame and Per-Vertex Variables
  15
+#
  16
+
  17
+sx		pfv_sx		pvv_sx
  18
+sy		pfv_sy		pvv_sy
  19
+cx		pfv_cx		pvv_cx
  20
+cy		pfv_cy		pvv_cy
  21
+rot		pfv_rot		pvv_rot
  22
+dx		pfv_dx		pvv_dx
  23
+dy		pfv_dy		pvv_dy
  24
+zoom		pfv_zoom	pvv_zoom
  25
+decay		pfv_decay	-1
  26
+wave_mode	pfv_wave_mode	-1
  27
+wave_scale	pfv_wave_scale	-1
  28
+wave_additive	pfv_wave_additive -1
  29
+wave_usedots	pfv_wave_usedots -1
  30
+wave_brighten	pfv_wave_brighten -1
  31
+wave_thick	pfv_wave_thick	-1
  32
+wave_x		pfv_wave_x	-1
  33
+wave_y		pfv_wave_y	-1
  34
+wave_r		pfv_wave_r	-1
  35
+wave_g		pfv_wave_g	-1
  36
+wave_b		pfv_wave_b	-1
  37
+wave_a		pfv_wave_a	-1
  38
+
  39
+ob_size		pfv_ob_size	-1
  40
+ob_r		pfv_ob_r	-1
  41
+ob_g		pfv_ob_g	-1
  42
+ob_b		pfv_ob_b	-1
  43
+ob_a		pfv_ob_a	-1
  44
+ib_size		pfv_ib_size	-1
  45
+ib_r		pfv_ib_r	-1
  46
+ib_g		pfv_ib_g	-1
  47
+ib_b		pfv_ib_b	-1
  48
+ib_a		pfv_ib_a	-1
  49
+
  50
+nMotionVectorsX	pfv_mv_x	-1
  51
+nMotionVectorsY	pfv_mv_y	-1
  52
+mv_dx		pfv_mv_dx	-1
  53
+mv_dy		pfv_mv_dy	-1
  54
+mv_l		pfv_mv_l	-1
  55
+mv_r		pfv_mv_r	-1
  56
+mv_g		pfv_mv_g	-1
  57
+mv_b		pfv_mv_b	-1
  58
+mv_a		pfv_mv_a	-1
  59
+
  60
+bTexWrap	pfv_tex_wrap	-1
  61
+
  62
+time		pfv_time	pvv_time
  63
+frame		pfv_frame	pvv_frame
  64
+bass		pfv_bass	pvv_bass
  65
+mid		pfv_mid		pvv_mid
  66
+treb		pfv_treb	pvv_treb
  67
+bass_att	pfv_bass_att	pvv_bass_att
  68
+mid_att		pfv_mid_att	pvv_mid_att
  69
+treb_att	pfv_treb_att	pvv_treb_att
  70
+
  71
+warp		pfv_warp	pvv_warp
  72
+fWarpAnimSpeed	pfv_warp_anim_speed pvv_warp_anim_speed
  73
+fWarpScale	pfv_warp_scale	pvv_warp_scale
  74
+
  75
+q1		pfv_q1		pvv_q1
  76
+q2		pfv_q2		pvv_q2
  77
+q3		pfv_q3		pvv_q3
  78
+q4		pfv_q4		pvv_q4
  79
+q5		pfv_q5		pvv_q5
  80
+q6		pfv_q6		pvv_q6
  81
+q7		pfv_q7		pvv_q7
  82
+q8		pfv_q8		pvv_q8
  83
+
  84
+fVideoEchoAlpha	pfv_video_echo_alpha -1
  85
+fVideoEchoZoom	pfv_video_echo_zoom -1
  86
+nVideoEchoOrientation pfv_video_echo_orientation -1
  87
+
  88
+dmx1		pfv_dmx1	-1
  89
+dmx2		pfv_dmx2	-1
  90
+dmx3		pfv_dmx3	-1
  91
+dmx4		pfv_dmx4	-1
  92
+dmx5		pfv_dmx5	-1
  93
+dmx6		pfv_dmx6	-1
  94
+dmx7		pfv_dmx7	-1
  95
+dmx8		pfv_dmx8	-1
  96
+
  97
+idmx1		pfv_idmx1	pvv_idmx1
  98
+idmx2		pfv_idmx2	pvv_idmx2
  99
+idmx3		pfv_idmx3	pvv_idmx3
  100
+idmx4		pfv_idmx4	pvv_idmx4
  101
+idmx5		pfv_idmx5	pvv_idmx5
  102
+idmx6		pfv_idmx6	pvv_idmx6
  103
+idmx7		pfv_idmx7	pvv_idmx7
  104
+idmx8		pfv_idmx8	pvv_idmx8
  105
+
  106
+osc1		pfv_osc1	pvv_osc1
  107
+osc2		pfv_osc2	pvv_osc2
  108
+osc3		pfv_osc3	pvv_osc3
  109
+osc4		pfv_osc4	pvv_osc4
  110
+
  111
+midi1		pfv_midi1	pvv_midi1
  112
+midi2		pfv_midi2	pvv_midi2
  113
+midi3		pfv_midi3	pvv_midi3
  114
+midi4		pfv_midi4	pvv_midi4
  115
+midi5		pfv_midi5	pvv_midi5
  116
+midi6		pfv_midi6	pvv_midi6
  117
+midi7		pfv_midi7	pvv_midi7
  118
+midi8		pfv_midi8	pvv_midi8
  119
+
  120
+video_a		pfv_video_a	-1
  121
+
  122
+image1_a	pfv_image1_a	-1
  123
+image1_x	pfv_image1_x	-1
  124
+image1_y	pfv_image1_y	-1
  125
+image1_zoom	pfv_image1_zoom	-1
  126
+image2_a	pfv_image2_a	-1
  127
+image2_x	pfv_image2_x	-1
  128
+image2_y	pfv_image2_y	-1
  129
+image2_zoom	pfv_image2_zoom	-1
153 130
 
154 131
 #
155 132
 # Aliases
156 133
 #
157 134
 
158  
-fDecay
159  
-nWaveMode
160  
-fWaveScale
161  
-bAdditiveWaves
162  
-bWaveDots
163  
-bMaximizeWaveColor
164  
-bWaveThick
165  
-fWaveAlpha
  135
+fDecay		pfv_decay	-1
  136
+nWaveMode	pfv_wave_mode	-1
  137
+fWaveScale	pfv_wave_scale	-1
  138
+bAdditiveWaves	pfv_wave_additive -1
  139
+bWaveDots	pfv_wave_usedots -1
  140
+bMaximizeWaveColor pfv_wave_brighten -1
  141
+bWaveThick	pfv_wave_thick	-1
  142
+fWaveAlpha	pfv_wave_a	-1
166 143
 
167 144
 #
168  
-# Per-Vertex Variables
  145
+# Per-Vertex Variables (system)
169 146
 #
170 147
 
171  
-# System
172  
-
173  
-_texsize
174  
-_hmeshsize
175  
-_vmeshsize
176  
-
177  
-# MilkDrop
178  
-
179  
-sx
180  
-sy
181  
-cx
182  
-cy
183  
-rot
184  
-dx
185  
-dy
186  
-zoom
187  
-
188  
-time
189  
-bass
190  
-mid
191  
-treb
192  
-bass_att
193  
-mid_att
194  
-treb_att
195  
-
196  
-warp
197  
-fWarpAnimSpeed
198  
-fWarpScale
199  
-
200  
-q1
201  
-q2
202  
-q3
203  
-q4
204  
-q5
205  
-q6
206  
-q7
207  
-q8
208  
-
209  
-idmx1
210  
-idmx2
211  
-idmx3
212  
-idmx4
213  
-idmx5
214  
-idmx6
215  
-idmx7
216  
-idmx8
217  
-
218  
-osc1
219  
-osc2
220  
-osc3
221  
-osc4
222  
-
223  
-midi1
224  
-midi2
225  
-midi3
226  
-midi4
227  
-midi5
228  
-midi6
229  
-midi7
230  
-midi8
  148
+_texsize	-1		pvv_texsize
  149
+_hmeshsize	-1		pvv_hmeshsize
  150
+_vmeshsize	-1		pvv_vmeshsize
231 151
 
232 152
 #
233 153
 # FPVM internal variables
234 154
 #
235 155
 
236  
-_Xo
237  
-_Yo
238  
-_Xi
239  
-_Yi
  156
+_Xo		-1		-1
  157
+_Yo		-1		-1
  158
+_Xi		-1		-1
  159
+_Yi		-1		-1
240 160
 
241 161
 #
242 162
 # PVV internal variables
@@ -244,41 +164,41 @@ _Yi
244 164
 
245 165
 # Initialization
246 166
 
247  
-x
248  
-y
249  
-rad
  167
+x		-1		-1
  168
+y		-1		-1
  169
+rad		-1		-1
250 170
 
251 171
 # Zoom
252 172
 
253  
-_invzoom
254  
-_xy
255  
-_yz
  173
+_invzoom	-1		-1
  174
+_xy		-1		-1
  175
+_yz		-1		-1
256 176
 
257 177
 # Scale
258 178
 
259  
-_xs
260  
-_ys
  179
+_xs		-1		-1
  180
+_ys		-1		-1
261 181
 
262 182
 # Warp
263 183
 
264  
-_warptime
265  
-_invwarpscale
266  
-_f0
267  
-_f1
268  
-_f2
269  
-_f3
270  
-_ox2
271  
-_oy2
272  
-_xw
273  
-_yw
  184
+_warptime	-1		-1
  185
+_invwarpscale	-1		-1
  186
+_f0		-1		-1
  187
+_f1		-1		-1
  188
+_f2		-1		-1
  189
+_f3		-1		-1
  190
+_ox2		-1		-1
  191
+_oy2		-1		-1
  192
+_xw		-1		-1
  193
+_yw		-1		-1
274 194
 
275 195
 # Rotate
276 196
 
277  
-_cosr
278  
-_sinr
279  
-_u
280  
-_v
281  
-_xr
282  
-_yr
283  
-_xd
284  
-_yd
  197
+_cosr		-1		-1
  198
+_sinr		-1		-1
  199
+_u		-1		-1
  200
+_v		-1		-1
  201
+_xr		-1		-1
  202
+_yr		-1		-1
  203
+_xd		-1		-1
  204
+_yd		-1		-1
22  src/compiler/idgen
@@ -2,7 +2,7 @@
2 2
 #
3 3
 # idgen - Identifier table generator
4 4
 #
5  
-# Copyright 2011 by Werner Almesberger
  5
+# Copyright 2011-2012 by Werner Almesberger
6 6
 #
7 7
 # This program is free software: you can redistribute it and/or modify
8 8
 # it under the terms of the GNU General Public License as published by
@@ -21,17 +21,17 @@ usage()
21 21
 [ "$2" ] && usage
22 22
 [ -r "$1" ] || { echo "$1: not found" 1&2; exit 1; }
23 23
 
24  
-trap "echo $1.h $1.inc" 0
25  
-
26 24
 f=`basename "$1" .ids`
27 25
 
  26
+trap "rm $f.h $f.inc" 0
  27
+
28 28
 cat <<EOF >$f.h
29 29
 /* MACHINE-GENERATED. DO NOT EDIT ! */
30 30
 
31 31
 #ifndef	IDS_H
32 32
 #define	IDS_H
33 33
 
34  
-extern const char *well_known[];
  34
+extern struct sym *well_known[];
35 35
 
36 36
 EOF
37 37
 
@@ -40,11 +40,19 @@ cat <<EOF >$f.inc
40 40
 
41 41
 EOF
42 42
 
43  
-sed 's/#.*//;s/ //g;/^$/d' $1 | sort | uniq | {
  43
+sed 's/#.*//;/^ *$/d' $1 | sort | {
44 44
 	i=0
45 45
 	while read n; do
46  
-		echo "#define ID_$n (well_known[$i])" >>$f.h
47  
-		echo "\"$n\"," >>$f.inc
  46
+		set - $n
  47
+		echo "#define ID_$1 (well_known[$i])" >>$f.h
  48
+		cat <<EOF >>$f.inc
  49
+{
  50
+	.fpvm_sym = { .name = "$1" },
  51
+	.pfv_idx = $2,
  52
+	.pvv_idx = $3,
  53
+	.flags = SF_SYSTEM,
  54
+},
  55
+EOF
48 56
 		i=`expr $i + 1`
49 57
 	done
50 58
 }
472  src/compiler/parser.y
@@ -16,160 +16,170 @@
16 16
  */
17 17
 
18 18
 %include {
19  
-	#include <assert.h>
20  
-	#include <string.h>
21  
-	#include <stdlib.h>
22  
-	#include <malloc.h>
23  
-	#include <math.h>
24  
-	#include <fpvm/ast.h>
25  
-	#include <fpvm/fpvm.h>
26  
-	#include "parser_itf.h"
27  
-	#include "parser_helper.h"
28  
-	#include "parser.h"
29  
-
30  
-
31  
-	struct yyParser;
32  
-	static void yy_parse_failed(struct yyParser *yypParser);
33  
-
34  
-	typedef const char *(*assign_callback)(struct parser_comm *comm,
35  
-	    const char *label, struct ast_node *node);
36  
-
37  
-	#define	FAIL					\
38  
-		do {					\
39  
-			syntax_error(state);		\
40  
-			yy_parse_failed(yypParser);	\
41  
-		} while (0)
42  
-
43  
-	#define	OTHER_STYLE_new_style	old_style
44  
-	#define	OTHER_STYLE_old_style	new_style
45  
-
46  
-	#define	IS_STYLE(which)						\
47  
-		do {							\
48  
-			if(state->style == OTHER_STYLE_##which) {	\
49  
-				FAIL;					\
50  
-				return;					\
51  
-			}						\
52  
-			state->style = which;				\
53  
-		} while (0)
54  
-
55  
-	const enum ast_op tok2op[] = {
56  
-		[TOK_IDENT]	= op_ident,
57  
-		[TOK_CONSTANT]	= op_constant,
58  
-		[TOK_PLUS]	= op_plus,
59  
-		[TOK_MINUS]	= op_minus,
60  
-		[TOK_MULTIPLY]	= op_multiply,
61  
-		[TOK_DIVIDE]	= op_divide,
62  
-		[TOK_PERCENT]	= op_percent,
63  
-		[TOK_ABS]	= op_abs,
64  
-		[TOK_ISIN]	= op_isin,
65  
-		[TOK_ICOS]	= op_icos,
66  
-		[TOK_SIN]	= op_sin,
67  
-		[TOK_COS]	= op_cos,
68  
-		[TOK_ABOVE]	= op_above,
69  
-		[TOK_BELOW]	= op_below,
70  
-		[TOK_EQUAL]	= op_equal,
71  
-		[TOK_I2F]	= op_i2f,
72  
-		[TOK_F2I]	= op_f2i,
73  
-		[TOK_IF]	= op_if,
74  
-		[TOK_TSIGN]	= op_tsign,
75  
-		[TOK_QUAKE]	= op_quake,
76  
-		[TOK_SQR]	= op_sqr,
77  
-		[TOK_SQRT]	= op_sqrt,
78  
-		[TOK_INVSQRT]	= op_invsqrt,
79  
-		[TOK_MIN]	= op_min,
80  
-		[TOK_MAX]	= op_max,
81  
-		[TOK_INT]	= op_int,
82  
-	};
83  
-
84  
-	static struct ast_node *node_op(enum ast_op op, const char *id,
85  
-	    struct ast_node *a, struct ast_node *b, struct ast_node *c)
86  
-	{
87  
-		struct ast_node *n;
88  
-
89  
-		n = malloc(sizeof(struct ast_node));
90  
-		n->op = op;
91  
-		n->label = id;
92  
-		n->contents.branches.a = a;
93  
-		n->contents.branches.b = b;
94  
-		n->contents.branches.c = c;
95  
-		return n;
96  
-	}
97 19
 
98  
-	static struct ast_node *node(int token, const char *id,
99  
-	    struct ast_node *a, struct ast_node *b, struct ast_node *c)
100  
-	{
101  
-		return node_op(tok2op[token], id, a, b, c);
  20
+#include <assert.h>
  21
+#include <string.h>
  22
+#include <ctype.h>
  23
+#include <stdlib.h>
  24
+#include <malloc.h>
  25
+#include <math.h>
  26
+
  27
+#include <fpvm/ast.h>
  28
+#include <fpvm/fpvm.h>
  29
+
  30
+#include "symtab.h"
  31
+#include "parser_itf.h"
  32
+#include "parser_helper.h"
  33
+#include "parser.h"
  34
+
  35
+
  36
+struct yyParser;
  37
+static void yy_parse_failed(struct yyParser *yypParser);
  38
+
  39
+typedef const char *(*assign_callback)(struct parser_comm *comm,
  40
+	    struct sym *sym, struct ast_node *node);
  41
+
  42
+#define	FAIL(msg)				\
  43
+	do {					\
  44
+		error(state, msg);		\
  45
+		yy_parse_failed(yypParser);	\
  46
+	} while (0)
  47
+
  48
+#define	OTHER_STYLE_new_style	old_style
  49
+#define	OTHER_STYLE_old_style	new_style
  50
+
  51
+#define	IS_STYLE(which)						\
  52
+	do {							\
  53
+		if(state->style == OTHER_STYLE_##which) {	\
  54
+			FAIL("style mismatch");			\
  55
+			return;					\
  56
+		}						\
  57
+		state->style = which;				\
  58
+	} while (0)
  59
+
  60
+static const enum ast_op tok2op[] = {
  61
+	[TOK_IDENT]	= op_ident,
  62
+	[TOK_CONSTANT]	= op_constant,
  63
+	[TOK_PLUS]	= op_plus,
  64
+	[TOK_MINUS]	= op_minus,
  65
+	[TOK_MULTIPLY]	= op_multiply,
  66
+	[TOK_DIVIDE]	= op_divide,
  67
+	[TOK_PERCENT]	= op_percent,
  68
+	[TOK_ABS]	= op_abs,
  69
+	[TOK_ISIN]	= op_isin,
  70
+	[TOK_ICOS]	= op_icos,
  71
+	[TOK_SIN]	= op_sin,
  72
+	[TOK_COS]	= op_cos,
  73
+	[TOK_ABOVE]	= op_above,
  74
+	[TOK_BELOW]	= op_below,
  75
+	[TOK_EQUAL]	= op_equal,
  76
+	[TOK_I2F]	= op_i2f,
  77
+	[TOK_F2I]	= op_f2i,
  78
+	[TOK_IF]	= op_if,
  79
+	[TOK_TSIGN]	= op_tsign,
  80
+	[TOK_QUAKE]	= op_quake,
  81
+	[TOK_SQR]	= op_sqr,
  82
+	[TOK_SQRT]	= op_sqrt,
  83
+	[TOK_INVSQRT]	= op_invsqrt,
  84
+	[TOK_MIN]	= op_min,
  85
+	[TOK_MAX]	= op_max,
  86
+	[TOK_INT]	= op_int,
  87
+};
  88
+
  89
+static struct ast_node *node_op(enum ast_op op,