Merge branch 'master' of https://scm.cri.ensmp.fr/git/Faustine
[Faustine.git] / interpretor / faust-0.9.47mr3 / compiler / signals / sigvisitor.hh
1 #ifndef __SIGVISITOR__
2 #define __SIGVISITOR__
3
4 #include "signals.hh"
5
6 struct sigvisitor
7 {
8 // predefined visit scheme
9 void visit(Tree sig);
10
11 // Unrecognized signal (default handler)
12 virtual void visitError (Tree sig);
13
14 virtual ~sigvisitor() {}
15
16 //---------------abstract methods---------------
17 // numbers
18 virtual void visitInt (Tree sig, int i) = 0;
19 virtual void visitReal (Tree sig, double r) = 0;
20
21 // audio inputs-outputs
22 virtual void visitInput (Tree sig, int i) = 0;
23 virtual void visitOutput (Tree sig, int i, Tree s) = 0;
24
25 // fixed size delays
26 virtual void visitDelay1 (Tree sig, Tree s) = 0;
27 virtual void visitPrefix (Tree sig, Tree s1, Tree s2) = 0;
28 virtual void visitFixDelay (Tree sig, Tree s1, Tree s2) = 0;
29
30 // numerical operations
31 virtual void visitBinOp (Tree sig, int opcode, Tree s1, Tree s2) = 0;
32 virtual void visitIntCast (Tree sig, Tree s) = 0;
33 virtual void visitFloatCast (Tree sig, Tree s) = 0;
34 virtual void visitFFun (Tree sig, Tree ff, Tree ls) = 0;
35 virtual void visitFConst (Tree sig, Tree type, Tree name, Tree file) = 0;
36 virtual void visitFVar (Tree sig, Tree type, Tree name, Tree file) = 0;
37
38 // user interface
39 virtual void visitButton (Tree sig, Tree label) = 0;
40 virtual void visitCheckbox (Tree sig, Tree label) = 0;
41 virtual void visitVSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step) = 0;
42 virtual void visitHSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step) = 0;
43 virtual void visitNumEntry (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step) = 0;
44 virtual void visitVBargraph (Tree sig, Tree label, Tree min, Tree max, Tree s1) = 0;
45 virtual void visitHBargraph (Tree sig, Tree label, Tree min, Tree max, Tree s1) = 0;
46 virtual void visitAttach (Tree sig, Tree s1, Tree s2) = 0;
47
48 // recursive
49 virtual void visitRec (Tree sig, Tree var, Tree body) = 0;
50 virtual void visitRef (Tree sig, Tree var) = 0;
51 virtual void visitProj (Tree sig, int i, Tree s1) = 0;
52
53 // Tables
54 virtual void visitTable (Tree sig, Tree id, Tree s1, Tree s2) = 0;
55 virtual void visitWRTbl (Tree sig, Tree id, Tree s1, Tree s2, Tree s3) = 0;
56 virtual void visitRDTbl (Tree sig, Tree s1, Tree s2) = 0;
57 virtual void visitGen (Tree sig, Tree s1) = 0;
58
59 virtual void visitDocConstantTbl (Tree sig, Tree s1, Tree s2) = 0;
60 virtual void visitDocWriteTbl (Tree sig, Tree s1, Tree s2, Tree s3, Tree s4) = 0;
61 virtual void visitDocAccessTbl (Tree sig, Tree s1, Tree s2) = 0;
62
63 // Selectors
64 virtual void visitSelect2 (Tree sig, Tree sel, Tree s1, Tree s2) = 0;
65 virtual void visitSelect3 (Tree sig, Tree sel, Tree s1, Tree s2, Tree s3) = 0;
66
67 // Tuples
68 virtual void visitTuple (Tree sig, int mod, Tree ls) = 0;
69 virtual void visitTupleAccess (Tree sig, Tree ts, Tree idx) = 0;
70
71 // List of signals
72 virtual void visitList (Tree lsig) = 0;
73 };
74
75 struct fullvisitor : sigvisitor
76 {
77 // numbers
78 virtual void visitInt (Tree sig, int i) {}
79 virtual void visitReal (Tree sig, double r) {}
80
81 // audio inputs-outputs
82 virtual void visitInput (Tree sig, int i) {}
83 virtual void visitOutput (Tree sig, int i, Tree s) { visit(s);}
84
85 // fixed size delays
86 virtual void visitDelay1 (Tree sig, Tree s) { visit(s);}
87 virtual void visitPrefix (Tree sig, Tree s1, Tree s2) { visit(s1); visit(s2); }
88 virtual void visitFixDelay (Tree sig, Tree s1, Tree s2) { visit(s1); visit(s2); }
89
90 // numerical operations
91 virtual void visitIntCast (Tree sig, Tree s) { visit(s);}
92 virtual void visitFloatCast (Tree sig, Tree s) { visit(s);}
93 virtual void visitBinOp (Tree sig, int op, Tree s1, Tree s2) { visit(s1); visit(s2); }
94 virtual void visitFFun (Tree sig, Tree ff, Tree ls) { visit(ls); }
95 virtual void visitFConst (Tree sig, Tree type, Tree name, Tree file) {}
96 virtual void visitFVar (Tree sig, Tree type, Tree name, Tree file) {}
97
98 // user interface
99 virtual void visitButton (Tree sig, Tree label) {}
100 virtual void visitCheckbox (Tree sig, Tree label) {}
101 virtual void visitVSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step) {}
102 virtual void visitHSlider (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step) {}
103 virtual void visitNumEntry (Tree sig, Tree label, Tree cur, Tree min, Tree max, Tree step) {}
104 virtual void visitVBargraph (Tree sig, Tree label, Tree min, Tree max, Tree s) { visit(s);}
105 virtual void visitHBargraph (Tree sig, Tree label, Tree min, Tree max, Tree s) { visit(s);}
106 virtual void visitAttach (Tree sig, Tree s1, Tree s2) { visit(s1); visit(s2); }
107
108 // recursive
109 virtual void visitRec (Tree sig, Tree var, Tree body) { visit(body); }
110 virtual void visitRef (Tree sig, Tree var) { }
111 virtual void visitProj (Tree sig, int i, Tree s) { visit(s); }
112
113 // Tables
114 virtual void visitTable (Tree sig, Tree id, Tree s1, Tree s2) { visit(s1); visit(s2); }
115 virtual void visitWRTbl (Tree sig, Tree id, Tree s1, Tree s2, Tree s3) { visit(s1); visit(s2); visit(s3); }
116 virtual void visitRDTbl (Tree sig, Tree s1, Tree s2) { visit(s1); visit(s2); }
117 virtual void visitGen (Tree sig, Tree s1) { visit(s1); }
118
119 // Selectors
120 virtual void visitSelect2 (Tree sig, Tree sel, Tree s1, Tree s2) { visit(sel); visit(s1); visit(s2); }
121 virtual void visitSelect3 (Tree sig, Tree sel, Tree s1, Tree s2, Tree s3) { visit(sel); visit(s1); visit(s2); visit(s3); }
122
123 // Tuples
124 virtual void visitTuple (Tree sig, int mod, Tree ls) { visit(ls); }
125 virtual void visitTupleAccess (Tree sig, Tree ts, Tree idx) { visit(ts); visit(idx); }
126
127 // List of signals
128 virtual void visitList (Tree lsig) { while (!isNil(lsig)) { visit(hd(lsig)); lsig=tl(lsig); }}
129 };
130
131 #endif