1 /************************************************************************
2  ************************************************************************
3     FAUST compiler
4     Copyright (C) 2003-2018 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 #ifndef _CLANG_CODE_CONTAINER_H
23 #define _CLANG_CODE_CONTAINER_H
24 
25 #include <fstream>
26 #include <iostream>
27 #include <sstream>
28 
29 #include "c_code_container.hh"
30 #include "cpp_code_container.hh"
31 #include "dag_instructions_compiler.hh"
32 
33 using namespace std;
34 
35 struct LLVMResult;
36 
37 class ClangCodeContainer : public virtual CodeContainer {
38    protected:
39     InstructionsCompiler* fCompiler;
40     CodeContainer*        fContainer;
41     std::ofstream*        fOut;
42     string                fTmpFile;
43 
getTempName()44     const char* getTempName()
45     {
46         /*
47         if (fTmpFile == "") {
48             char path[256];
49             fTmpFile = string(tmpnam(path)) + ".c";
50         }
51         return fTmpFile.c_str();
52         */
53         // TODO
54         return "";
55     }
56 
57    public:
58     ClangCodeContainer(const string& name, int numInputs, int numOutputs);
59     virtual ~ClangCodeContainer();
60 
61     virtual LLVMResult* produceModule(Tree signals, const string& filename);
62 
produceInternal()63     virtual void produceInternal() { fContainer->produceInternal(); }
64 
createScalarContainer(const string & name,int sub_container_type)65     CodeContainer* createScalarContainer(const string& name, int sub_container_type)
66     {
67         faustassert(false);
68         return nullptr;
69     }  // Not used
70 
71     static CodeContainer* createContainer(const string& name, int numInputs, int numOutputs);
72 };
73 
74 #endif
75