fed7a957e97ecdcb915be0853a4e0edaa57a835b
1 /************************************************************************
2 ************************************************************************
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.
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.
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 ************************************************************************/
24 /*****************************************************************************
25 ******************************************************************************
27 Y. Orlarey, (c) Grame 2002
28 ------------------------------------------------------------------------------
29 Compile a list of FAUST signals into a LaTeX equation.
33 2002-02-08 : First version (of sharing.cpp)
34 2009-08-18 : Doc version (Karim Barkati)
36 ******************************************************************************
37 *****************************************************************************/
43 //#include "compile_vect.hh"
44 //#include "compile_scal.hh"
45 //#include "doc_compile_vect.hh"
46 #include "doc_compile.hh"
48 #include "sigtyperules.hh"
49 #include "sigprint.hh"
51 //#include "doc_sharing.hh"
54 /*****************************************************************************
55 ******************************************************************************
59 ******************************************************************************
60 *****************************************************************************/
62 //------------------------------------------------------------------------------
63 // Create a specific property key for the sharing count of subtrees of t
64 //------------------------------------------------------------------------------
66 int DocCompiler::getSharingCount(Tree sig
)
67 //int getSharingCount(Tree sig, int count)
69 //cerr << "getSharingCount of : " << *sig << " = ";
71 if (getProperty(sig
, fSharingKey
, c
)) {
72 //cerr << c->node().getInt() << endl;
73 return c
->node().getInt();
81 void DocCompiler::setSharingCount(Tree sig
, int count
)
82 //void setSharingCount(Tree sig, int count)
84 //cerr << "setSharingCount of : " << *sig << " <- " << count << endl;
85 setProperty(sig
, fSharingKey
, tree(count
));
90 //------------------------------------------------------------------------------
91 // Create a specific property key for the sharing count of subtrees of t
92 //------------------------------------------------------------------------------
96 void DocCompiler::sharingAnalysis(Tree t
)
97 //void sharingAnalysis(Tree t)
99 fSharingKey
= shprkey(t
);
102 sharingAnnotation(kSamp
, hd(t
));
106 sharingAnnotation(kSamp
, t
);
112 //------------------------------------------------------------------------------
113 // Create a specific property key for the sharing count of subtrees of t
114 //------------------------------------------------------------------------------
117 void DocCompiler::sharingAnnotation(int vctxt
, Tree sig
)
118 //void sharingAnnotation(int vctxt, Tree sig)
120 //cerr << "START sharing annotation of " << *sig << endl;
121 int count
= getSharingCount(sig
);
124 // it is not our first visit
125 setSharingCount(sig
, count
+1);
128 // it is our first visit,
129 int v
= getCertifiedSigType(sig
)->variability();
131 // check "time sharing" cases
133 setSharingCount(sig
, 2); // time sharing occurence : slower expression in faster context
135 setSharingCount(sig
, 1); // regular occurence
138 // Annotate the sub signals
140 int n
= getSubSignals(sig
, subsig
);
141 if (n
>0 && ! isSigGen(sig
)) {
142 for (int i
=0; i
<n
; i
++) sharingAnnotation(v
, subsig
[i
]);
145 //cerr << "END sharing annotation of " << *sig << endl;