File: faust-mr.cpp

package info (click to toggle)
faust 2.14.4~repack2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 276,136 kB
  • sloc: cpp: 231,578; ansic: 15,403; sh: 10,871; java: 6,917; objc: 4,085; makefile: 3,002; cs: 1,077; ruby: 951; python: 885; xml: 550; yacc: 516; lex: 233; lisp: 201
file content (345 lines) | stat: -rw-r--r-- 10,363 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <map>

using namespace std;

#include "TType.hh"
#include "Text.hh"
#include "TLang.hh"
#include "TCompiler.hh"

int gVecSize = 32;
TBlockStatement* gExternalBlock = NULL;
TBlockStatement* gDecBlock = NULL;

bool gPrim = true;
bool gVec = true;
bool gSer = true;
bool gConcat = true;

static void Display(const string& test)
{
    cout << "// ====================="<< endl;
    cout << "// "<< test<< endl;
    cout << "// ====================="<< endl;
}

// Not compatible type  (input ==> int)
TSignal* test1(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test1");
    return new TInt(5);
}

TSignal* test2(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test2");
    return new TFloat(10.f);
}

TSignal* test3(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test3");
    return new TInput(0, 1);
}

TSignal* test4(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test4");
    return new TPrimOp(new TInput(0, 1), new TInput(1, 1), "+");
}

TSignal* test5(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test5");
    return new TPrimOp(new TPrimOp(new TInput(0, 1), new TFloat(10.f), "+"), new TPrimOp(new TInput(0, 1), new TInput(1, 1), "+"), "*");
}

TSignal* test6(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test6");
    return new TPrimOp(new TPrimOp(new TInput(0, 1), new TFloat(10.f), "+"), new TFloat(10.f), "*");
}

// Not compatible type  (input ==> float[4])
TSignal* test10(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test10");
    return new TVectorize(new TInput(0, 4), 4);
}

TSignal* test11(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    Display("test11");
    return new TSerialize(new TVectorize(new TInput(0, 4), 4));
}

// Not compatible type  (input ==> float[4][3])
TSignal* test11bis(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gConcat = concat;
    gSer = ser;
    Display("test11bis");
    return new TVectorize(new TVectorize(new TInput(0, 12), 4), 3);
}

TSignal* test12(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test12");
    return new TSerialize(new TSerialize(new TVectorize(new TVectorize(new TInput(0, 12), 4), 3)));
}

TSignal* test13(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test13");
    return new TSerialize(new TVectorize(new TSerialize(new TVectorize(new TInput(0, 12), 4)), 3));
}

// Not compatible type  (input ==> float[4])
TSignal* test14(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test14");
    return new TPrimOp(new TVectorize(new TInput(0, 4), 4), new TVectorize(new TInput(1, 4), 4), "+");
}

TSignal* test15(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test15");
    return new TSerialize(new TPrimOp(new TVectorize(new TInput(0, 4), 4), new TVectorize(new TInput(1, 4), 4), "+"));
}

TSignal* test15bis(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test15bis");
    return new TPrimOp(new TSerialize(new TVectorize(new TInput(0, 4), 4)), new TSerialize(new TVectorize(new TInput(1, 4), 4)), "+");
}

TSignal* test15ter(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test15ter");
    return new TSerialize(new TSerialize(new TPrimOp(
        new TVectorize(new TVectorize(new TInput(0, 12), 4), 3),
        new TVectorize(new TVectorize(new TInput(1, 12), 4), 3), "+")));
}

TSignal* test16(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test16");
    return new TSerialize(new TSerialize(new TPrimOp(new TVectorize(new TVectorize(new TInput(0, 12), 4), 3), new TVectorize(new TVectorize(new TInput(1, 12), 4), 3), "+")));
}

TSignal* test21(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test21");
    return new TSerialize(new TConcat(new TVectorize(new TInput(0, 4), 4), new TVectorize(new TInput(1, 3), 3)));
}

TSignal* test22(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test22");
    return new TVectorAt(new TVectorize(new TInput(0, 4), 4), new TInt(3));
}

TSignal* test23(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test23");
    return new TVectorAt(new TConcat(new TVectorize(new TInput(0, 4), 4), new TVectorize(new TInput(1, 3), 3)), new TInt(0));
}

TSignal* test30(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test30");
    return new TDelayAt(new TDelayLine(new TInput(0, 1), 100), new TInt(3));
}

TSignal* test40(bool prim, bool vec, bool ser, bool concat)
{
    gPrim = prim;
    gVec = vec;
    gSer = ser;
    gConcat = concat;
    Display("test40");
    TRecGroup* rec_group = new TRecGroup("RecGroup1");
    rec_group->fCode.push_back(new TPrimOp(new TInput(0, 1), new TRecProj(rec_group, 0), "+"));
    rec_group->fCode.push_back(new TPrimOp(new TInput(1, 1), new TRecProj(rec_group, 1), "*"));
    rec_group->fCode.push_back(new TInput(2, 1));
    return new TRecProj(rec_group, 1);
}

// vectorize(4):*(2):serialize:+(1);
TSignal* test50(bool prim, bool vec, bool ser, bool concat)
{
    return new TPrimOp(new TSerialize(new TPrimOp(new TVectorize(new TInput(0, 4), 4), new TFloat(2.f), "*")),  new TFloat(1.f), "+");
}

int main()
{
    TCompiler compiler;

    //compiler.compileTop(test1());
    //compiler.compileTop(test2(true, true, true, true));
    //compiler.compileTop(test3(true, true, true, true));
    //compiler.compileTop(test4(true, true, true, true));
    //compiler.compileTop(test5(true, true, true, true));
    //compiler.compileTop(test6(true, true, true, true));

    //compiler.compileTop(test10(true, true, true, true));

    //compiler.compileTop(test11(true, true, true, true));
    //compiler.compileTop(test11(true, false, true, true));
    //compiler.compileTop(test11(true, true, false, true));
    //compiler.compileTop(test11(true, false, false, true));

    //compiler.compileTop(test11bis(true, true, true, true));
    //compiler.compileTop(test12(true, true, true, true));
    //compiler.compileTop(test12(true, false, true, true));
    //compiler.compileTop(test12(true, true, false, true));
    //compiler.compileTop(test12(true, false, false, true));

    //compiler.compileTop(test13(true, true, true, true));
    //compiler.compileTop(test13(true, false, true, true));
    //compiler.compileTop(test13(true, true, false, true));
    //compiler.compileTop(test13(true, false, false, true));

    //compiler.compileTop(test14(true, true, true, true));

    //compiler.compileTop(test15(true, true, true, true));
    //compiler.compileTop(test15(true, false, true, true));
    //compiler.compileTop(test15(true, true, false, true));
    //compiler.compileTop(test15(true, false, false, true));

    //compiler.compileTop(test15(false, true, true, true));
    //compiler.compileTop(test15(false, false, true, true));
    //compiler.compileTop(test15(false, true, false, true));
    //compiler.compileTop(test15(false, false, false, true));

    //compiler.compileTop(test15bis(true, true, true, true));
    //compiler.compileTop(test15bis(true, false, true, true));
    //compiler.compileTop(test15bis(true, true, false, true));
    //compiler.compileTop(test15bis(true, false, false, true));

    //compiler.compileTop(test15bis(false, true, true, true));
    //compiler.compileTop(test15bis(false, false, true, true));
    //compiler.compileTop(test15bis(false, true, false, true));
    //compiler.compileTop(test15bis(false, false, false, true));

    //compiler.compileTop(test15ter(false, true, true, true));
    //compiler.compileTop(test15ter(false, false, true, true));
    //compiler.compileTop(test15ter(false, true, false, true));
    //compiler.compileTop(test15ter(false, false, false, true));

    //compiler.compileTop(test16(true, true, true, true));

    //compiler.compileTop(test21(true, true, true, true));
    //compiler.compileTop(test21(true, false, true, true));
    //compiler.compileTop(test21(true, true, false, true));
    //compiler.compileTop(test21(true, false, false, true));

    //compiler.compileTop(test21(true, true, true, false));
    //compiler.compileTop(test21(true, false, true, false));
    //compiler.compileTop(test21(true, true, false, false));
    //compiler.compileTop(test21(true, false, false, false));

    //compiler.compileTop(test22(true, true, true, false));
    //compiler.compileTop(test22(true, false, true, false));
    //compiler.compileTop(test22(true, true, false, false));
    //compiler.compileTop(test22(true, false, false, false));


    //compiler.compileTop(test22(true, true, true, true));

    //compiler.compileTop(test23(true, true, true, true));
    //compiler.compileTop(test23(true, false, true, true));
    //compiler.compileTop(test23(true, true, false, true));
    //compiler.compileTop(test23(true, false, false, true));

    //compiler.compileTop(test30(true, true, true, true));

    //compiler.compileTop(test40(true, true, true, true));

    compiler.compileTop(test50(true, true, true, true));

	return 0;
}