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
|
/************************************************************************
************************************************************************
FAUST compiler
Copyright (C) 2003-2018 GRAME, Centre National de Creation Musicale
---------------------------------------------------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************
************************************************************************/
#ifndef _COMPILE_
#define _COMPILE_
#include <list>
#include <map>
#include <stack>
#include <string>
#include "Text.hh"
#include "klass.hh"
#include "signals.hh"
#include "uitree.hh"
#include "description.hh"
#include "faust/gui/JSONUI.h"
////////////////////////////////////////////////////////////////////////
/**
* compileSignals : listOfSignal -> klass
*
* Compile a list of FAUST signals into a C++ class
*/
///////////////////////////////////////////////////////////////////////
#define kMaxHeight 1024
enum class DelayType {
kNotADelay = 0,
kZeroDelay, // delay = 0
kMonoDelay, // 1 sample delay where 1 single variable can be used (the delay appears once in
// the expression)
kSingleDelay, // 1 sample delay where the delay appears several times in the expression, so a
// buffer of size 2 is used
kCopyDelay, // longer delay with a cache
kDenseDelay, // longer delay with a cache, only when the read density is high enough
kMaskRingDelay, // sparse delay without cache, using wrapping index (based on a power-of-two
// size and a mask)
kSelectRingDelay // sparse delay without cache, using wrapping index (based on an if/select)
};
std::string nameDelayType(DelayType dt);
class Compiler : public virtual Garbageable {
protected:
Klass* fClass;
bool fNeedToDeleteClass;
Tree fUIRoot;
Description* fDescription;
JSONUI fJSON;
UITree fUITree;
public:
Compiler(const std::string& name, const std::string& super, int numInputs, int numOutputs,
bool vec);
Compiler(Klass* k);
virtual ~Compiler();
virtual void compileMultiSignal(Tree lsig) = 0;
virtual void compileSingleSignal(Tree lsig) = 0;
Klass* getClass() { return (Klass*)fClass; }
void setDescription(Description* descr) { fDescription = descr; }
Description* getDescription() { return fDescription; }
protected:
virtual Tree prepare(Tree L0) = 0;
virtual Tree prepare2(Tree L0) = 0;
// management of includes and libraries
void addIncludeFile(const std::string& str) { fClass->addIncludeFile(str); }
void addLibrary(const std::string& str) { fClass->addLibrary(str); }
// management of the tree-like description of the UI
void generateWidgetCode(Tree fulllabel, Tree varname, Tree sig);
void generateMetaData();
void generateUserInterfaceTree(Tree t, bool root = false);
void generateUserInterfaceElements(Tree elements);
void generateMacroInterfaceTree(const std::string& pathname, Tree t);
void generateMacroInterfaceElements(const std::string& pathname, Tree elements);
void generateWidgetMacro(const std::string& pathname, Tree fulllabel, Tree varname, Tree sig);
// Analyze delay type
virtual DelayType analyzeDelayType(Tree sig) = 0;
};
#define generateEquivRecGroup generateRecGroup
void compileSignals(const std::string& name, const std::string& super, int numInputs,
int numOutputs, Tree lsig);
#endif
|