FAUST compiler  0.9.9.6b8
Functions | Variables
sigtyperules.hh File Reference

API to the typing system of signals. More...

#include "signals.hh"
#include "sigtype.hh"
Include dependency graph for sigtyperules.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void typeAnnotation (Tree term)
 Annotates a signal term and its subterms with type information. More...
 
Type getCertifiedSigType (Tree term)
 Return the type of a previously annotated signal term. More...
 
void annotationStatistics ()
 print annotation statistics More...
 

Variables

bool gVectorSwitch
 

Detailed Description

API to the typing system of signals.

Two functions are provided :

TypeAnnotation must be called first to annotate a signal or a list of signals, before being able to call getCertifiedType on any subterms. GetCertifiedType will produce an error if a term was not previously annotated.

Definition in file sigtyperules.hh.

Function Documentation

void annotationStatistics ( )

print annotation statistics

Definition at line 146 of file sigtyperules.cpp.

References AudioType::gAllocationCount, and TABBER.

147 {
148  cerr << TABBER << "COUNT INFERENCE " << countInferences << " AT TIME " << clock()/CLOCKS_PER_SEC << 's' << endl;
149  cerr << TABBER << "COUNT ALLOCATION " << AudioType::gAllocationCount << endl;
150  cerr << TABBER << "COUNT MAXIMAL " << countMaximal << endl;
151 }
static int gAllocationCount
Definition: sigtype.hh:85
static int countMaximal
Tabber TABBER(1)
Definition: tree.cpp:87
static int countInferences
Type getCertifiedSigType ( Tree  sig)

Return the type of a previously annotated signal term.

Return the type of a previously annotated signal term.

Produces an error if the signal has no type associated

Parameters
sigthe signal we want to know the type
Returns
the type of the signal

Definition at line 159 of file sigtyperules.cpp.

References getSigType().

Referenced by VectorCompiler::CS(), ScalarCompiler::declareWaveform(), ScalarCompiler::forceCacheCode(), ScalarCompiler::generateBinOp(), DocCompiler::generateBinOp(), VectorCompiler::generateCacheCode(), ScalarCompiler::generateCacheCode(), DocCompiler::generateCacheCode(), ScalarCompiler::generateDelayVec(), DocCompiler::generateDelayVec(), DocCompiler::generateDocConstantTbl(), DocCompiler::generateDocWriteTbl(), ScalarCompiler::generateFConst(), DocCompiler::generateFConst(), DocCompiler::generateFVar(), ScalarCompiler::generateHBargraph(), DocCompiler::generateHBargraph(), ScalarCompiler::generateNumber(), DocCompiler::generateNumber(), ScalarCompiler::generatePrefix(), ScalarCompiler::generateRec(), DocCompiler::generateRec(), ScalarCompiler::generateStaticTable(), ScalarCompiler::generateTable(), VectorCompiler::generateVariableStore(), ScalarCompiler::generateVariableStore(), DocCompiler::generateVariableStore(), ScalarCompiler::generateVBargraph(), DocCompiler::generateVBargraph(), ScalarCompiler::generateXtended(), DocCompiler::generateXtended(), OccMarkup::incOcc(), VectorCompiler::needSeparateLoop(), recdraw(), ScalarCompiler::sharingAnnotation(), DocCompiler::sharingAnnotation(), signal2klass(), and sigToGraph().

160 {
161  Type ty = getSigType(sig);
162  assert(ty);
163  return ty;
164 }
static Type getSigType(Tree sig)
Retrieve the type annotation of sig.

Here is the call graph for this function:

Here is the caller graph for this function:

void typeAnnotation ( Tree  sig)

Annotates a signal term and its subterms with type information.

Annotates a signal term and its subterms with type information.

Parameters
sigthe signal term tree to annotate

Definition at line 89 of file sigtyperules.cpp.

References getSigType(), hd(), initialRecType(), isList(), isRec(), len(), setSigType(), CTree::startNewVisit(), symlist(), T(), and tl().

Referenced by DocCompiler::annotate(), ScalarCompiler::prepare(), and ScalarCompiler::prepare2().

90 {
91  Tree sl = symlist(sig);
92  int n = len(sl);
93 
94  vector<Tree> vrec, vdef;
95  vector<Type> vtype;
96 
97  //cerr << "Symlist " << *sl << endl;
98  for (Tree l=sl; isList(l); l=tl(l)) {
99  Tree id, body;
100  assert(isRec(hd(l), id, body));
101  if (!isRec(hd(l), id, body)) {
102  continue;
103  }
104 
105  vrec.push_back(hd(l));
106  vdef.push_back(body);
107  }
108 
109  // init recursive types
110  for (int i=0; i<n; i++) {
111  vtype.push_back(initialRecType(vdef[i]));
112  }
113 
114  assert (int(vrec.size())==n);
115  assert (int(vdef.size())==n);
116  assert (int(vtype.size())==n);
117 
118  // find least fixpoint
119  for (bool finished = false; !finished; ) {
120 
121  // init recursive types
123  for (int i=0; i<n; i++) {
124  setSigType(vrec[i], vtype[i]);
125  vrec[i]->setVisited();
126  }
127 
128  // compute recursive types
129  for (int i=0; i<n; i++) {
130  vtype[i] = T(vdef[i], NULLTYPEENV);
131  }
132 
133  // check finished
134  finished = true;
135  for (int i=0; i<n; i++) {
136  //cerr << i << "-" << *vrec[i] << ":" << *getSigType(vrec[i]) << " => " << *vtype[i] << endl;
137  finished = finished & (getSigType(vrec[i]) == vtype[i]);
138  }
139  }
140 
141  // type full term
142  T(sig, NULLTYPEENV);
143 }
static void setSigType(Tree sig, Type t)
Set the type annotation of sig.
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree hd(Tree l)
Definition: list.hh:133
static Type initialRecType(Tree t)
Compute an initial type solution for a recursive block E1,E2,...En -> TREC,TREC,...TREC.
static Type getSigType(Tree sig)
Retrieve the type annotation of sig.
static void startNewVisit()
Definition: tree.hh:161
bool isList(Tree l)
Definition: list.hh:138
static Tree NULLTYPEENV
The empty type environment (also property key for closed term type)
static Type T(Tree term, Tree env)
Shortcut to getOrInferType, retrieve or infere the type of a term according to its surrounding type e...
bool isRec(Tree t, Tree &body)
is t a de Bruijn recursive tree
Tree symlist(Tree sig)
int len(Tree l)
Definition: list.cpp:198
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

bool gVectorSwitch

Definition at line 138 of file main.cpp.

Referenced by main(), and process_cmdline().