00001 /************************************************************************ 00002 ************************************************************************ 00003 FAUST compiler 00004 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale 00005 --------------------------------------------------------------------- 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 ************************************************************************ 00020 ************************************************************************/ 00021 00022 00023 00024 #ifndef _LOOP_H 00025 #define _LOOP_H 00026 00027 /********************************************************************** 00028 - loop.hh : loop C++ à remplir (projet FAUST) - 00029 00030 00031 Historique : 00032 ----------- 00033 21-01-2008 : implementation initiale (yo) 00034 00035 ***********************************************************************/ 00036 using namespace std; 00037 00038 #include <string> 00039 #include <list> 00040 #include <stack> 00041 #include <set> 00042 #include <map> 00043 #include "tlib.hh" 00044 00045 #define kMaxCategory 32 00046 00047 /* 00048 * Loops are lines of code that correspond to a recursive expression or a vector expression. 00049 */ 00050 00051 struct Loop 00052 { 00053 const bool fIsRecursive; 00054 const Tree fRecSymbol; 00055 Loop* const fEnclosingLoop; 00056 const string fSize; 00057 // fields concerned by absorbsion 00058 set<Tree> fRecDependencies; 00059 set<Loop*> fBackwardLoopDependencies; 00060 set<Loop*> fForwardLoopDependencies; 00061 list<string> fPreCode; 00062 list<string> fExecCode; 00063 list<string> fPostCode; 00064 // for topological sort 00065 int fOrder; 00066 int fIndex; 00067 // new fields 00068 int fUseCount; 00069 list<Loop*> fExtraLoops; 00070 00071 public: 00072 Loop(Tree recsymbol, Loop* encl, const string& size); 00073 Loop(Loop* encl, const string& size); 00074 00075 bool isEmpty(); 00076 bool hasRecDependencies(); 00077 void addRecDependency(Tree t); 00078 bool findRecDefinition(Tree t); 00079 00080 void addPreCode (const string& str); 00081 void addExecCode (const string& str); 00082 void addPostCode (const string& str); 00083 void println (int n, ostream& fout); 00084 void printoneln (int n, ostream& fout); 00085 00086 void absorb(Loop* l); 00087 // new method 00088 void concat(Loop* l); 00089 }; 00090 00091 #endif