Add abstrat type matrix and data.
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / compiler / generator / compile.hh
1 /************************************************************************
2 ************************************************************************
3 FAUST compiler
4 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale
5 ---------------------------------------------------------------------
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ************************************************************************
20 ************************************************************************/
21
22
23
24 #ifndef _COMPILE_
25 #define _COMPILE_
26
27
28 #include "signals.hh"
29 #include "klass.hh"
30 #include "Text.hh"
31 #include "uitree.hh"
32 #include <string>
33 #include <list>
34 #include <stack>
35 #include <map>
36
37 #include "description.hh"
38
39 ////////////////////////////////////////////////////////////////////////
40 /**
41 * compileSignals : listOfSignal -> klass
42 *
43 * Compile a list of FAUST signals into a C++ class
44 */
45 ///////////////////////////////////////////////////////////////////////
46
47 #define kMaxHeight 1024
48
49
50 class Compiler
51 {
52 protected:
53 Klass* fClass;
54 bool fNeedToDeleteClass;
55 Tree fUIRoot;
56 Description* fDescription;
57
58 public:
59 Compiler (const string& name, const string& super, int numInputs, int numOutputs, bool vec);
60 Compiler (Klass* k);
61
62 virtual ~Compiler();
63
64 virtual void compileMultiSignal (Tree lsig) = 0;
65 virtual void compileSingleSignal (Tree lsig) = 0;
66
67 Klass* getClass() { return (Klass*)fClass; }
68
69 void setDescription(Description* descr) { fDescription= descr; }
70 Description* getDescription() { return fDescription; }
71
72 protected:
73 virtual Tree prepare (Tree L0) = 0;
74 virtual Tree prepare2 (Tree L0) = 0;
75
76 // gestion des includes et librairies
77 void addIncludeFile (const string& str) { fClass->addIncludeFile(str); }
78 void addLibrary (const string& str) { fClass->addLibrary(str); }
79
80 // gestion de la description arborescente de l'IU
81 void addUIWidget(Tree path, Tree widget);
82 void generateWidgetCode(Tree fulllabel, Tree varname, Tree sig);
83 void generateUserInterfaceTree(Tree t);
84 void generateUserInterfaceElements(Tree elements);
85 Tree prepareUserInterfaceTree(Tree t);
86
87 void generateMacroInterfaceTree(const string& pathname, Tree t);
88 void generateMacroInterfaceElements(const string& pathname, Tree elements);
89 void generateWidgetMacro(const string& pathname, Tree fulllabel, Tree varname, Tree sig);
90
91
92 };
93 #define generateEquivRecGroup generateRecGroup
94
95
96 void compileSignals (const string& name, const string& super, int numInputs, int numOutputs, Tree lsig);
97
98 #endif