|
FAUST compiler
0.9.9.6b8
|
#include <stdio.h>#include <assert.h>#include <iostream>#include <fstream>#include <time.h>#include "sigtype.hh"#include "sigprint.hh"#include "ppsig.hh"#include "prim2.hh"#include "tlib.hh"#include "sigtyperules.hh"#include "xtended.hh"#include "recursivness.hh"
Go to the source code of this file.
Defines | |
| #define | TRACE(x) 0; |
Functions | |
| static void | setSigType (Tree sig, Type t) |
| Set the type annotation of sig. | |
| static Type | getSigType (Tree sig) |
| Retrieve the type annotation of sig. | |
| static Type | initialRecType (Tree t) |
| Compute an initial type solution for a recursive block E1,E2,...En -> TREC,TREC,...TREC. | |
| static Type | T (Tree term, Tree ignoreenv) |
| Shortcut to getOrInferType, retrieve or infere the type of a term according to its surrounding type environment. | |
| static Type | infereSigType (Tree sig, Tree env) |
| Infere the type of a term according to its surrounding type environment. | |
| static Type | infereFFType (Tree ff, Tree ls, Tree env) |
| Infere the type of a foreign function call. | |
| static Type | infereFConstType (Tree type) |
| Infere the type of a foreign constant. | |
| static Type | infereFVarType (Tree type) |
| Infere the type of a foreign variable. | |
| static Type | infereRecType (Tree sig, Tree body, Tree env) |
| Infere the type of e recursive block by trying solutions of increasing generality. | |
| static Type | infereReadTableType (Type tbl, Type ri) |
| Infere the type of the result of reading a table. | |
| static Type | infereWriteTableType (Type tbl, Type wi, Type wd) |
| Infere the type of the result of writing into a table. | |
| static Type | infereProjType (Type t, int i, int vec) |
| Infere the type of a projection (selection) of a tuplet element. | |
| static Type | infereXType (Tree sig, Tree env) |
| Infere the type of an extended (primitive) block. | |
| static Type | infereDocConstantTblType (Type size, Type init) |
| static Type | infereDocWriteTblType (Type size, Type init, Type widx, Type wsig) |
| static Type | infereDocAccessTblType (Type tbl, Type ridx) |
| static interval | arithmetic (int opcode, const interval &x, const interval &y) |
| Compute the resulting interval of an arithmetic operation. | |
| void | typeAnnotation (Tree sig) |
| Fully annotate every subtree of term with type information. | |
| void | annotationStatistics () |
| print annotation statistics | |
| Type | getCertifiedSigType (Tree sig) |
| Retrieve the type of sig and check it exists. | |
Variables | |
| static Tree | NULLTYPEENV = tree(symbol("NullTypeEnv")) |
| The empty type environment (also property key for closed term type) | |
| static int | countInferences |
| static int | countMaximal |
| #define TRACE | ( | x | ) | 0; |
Definition at line 69 of file sigtyperules.cpp.
Referenced by getSigType(), setSigType(), and T().
| void annotationStatistics | ( | ) |
print annotation statistics
Definition at line 141 of file sigtyperules.cpp.
References AudioType::gAllocationCount, and TABBER.
{
cerr << TABBER << "COUNT INFERENCE " << countInferences << " AT TIME " << clock()/CLOCKS_PER_SEC << 's' << endl;
cerr << TABBER << "COUNT ALLOCATION " << AudioType::gAllocationCount << endl;
cerr << TABBER << "COUNT MAXIMAL " << countMaximal << endl;
}
| static interval arithmetic | ( | int | opcode, |
| const interval & | x, | ||
| const interval & | y | ||
| ) | [static] |
Compute the resulting interval of an arithmetic operation.
| op | code of the operation |
| s1 | interval of the left operand |
| s2 | interval of the right operand |
Definition at line 600 of file sigtyperules.cpp.
References kAdd, kAND, kDiv, kEQ, kGE, kGT, kLE, kLsh, kLT, kMul, kNE, kOR, kRem, kRsh, kSub, and kXOR.
Referenced by infereSigType().
{
switch (opcode) {
case kAdd: return x+y;
case kSub: return x-y;
case kMul: return x*y;
case kDiv: return x/y;
case kRem: return x%y;
case kLsh: return x<<y;
case kRsh: return x>>y;
case kGT: return x>y;
case kLT: return x<y;
case kGE: return x>=y;
case kLE: return x<=y;
case kEQ: return x==y;
case kNE: return x!=y;
case kAND: return x&y;
case kOR: return x|y;
case kXOR: return x^y;
default:
cerr << "Unrecognized opcode : " << opcode << endl;
exit(1);
}
return interval();
}

| Type getCertifiedSigType | ( | Tree | sig | ) |
Retrieve the type of sig and check it exists.
Return the type of a previously annotated signal term.
Produces an error if the signal has no type associated
| sig | the signal we want to know the type |
Definition at line 154 of file sigtyperules.cpp.
References getSigType().
Referenced by VectorCompiler::CS(), 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().
{
Type ty = getSigType(sig);
assert(ty);
return ty;
}


| static Type getSigType | ( | Tree | sig | ) | [static] |
Retrieve the type annotation of sig.
| sig | the signal we want to know the type |
Definition at line 185 of file sigtyperules.cpp.
References CTree::getType(), TABBER, and TRACE.
Referenced by getCertifiedSigType(), T(), and typeAnnotation().
{
AudioType* ty = (AudioType*) sig->getType();
if (ty == 0)
TRACE(cerr << TABBER << "GET FIX TYPE OF " << *sig << " HAS NO TYPE YET" << endl;)
else
TRACE(cerr << TABBER << "GET FIX TYPE OF " << *sig << " IS TYPE " << *ty << endl;)
return ty;
}


| static Type infereDocAccessTblType | ( | Type | tbl, |
| Type | ridx | ||
| ) | [static] |
Definition at line 485 of file sigtyperules.cpp.
Referenced by infereSigType().
{
Type temp = tbl
->promoteVariability(ridx->variability())
->promoteComputability(ridx->computability())
->promoteVectorability(ridx->vectorability())
;
return temp;
}

| static Type infereDocConstantTblType | ( | Type | size, |
| Type | init | ||
| ) | [static] |
Definition at line 464 of file sigtyperules.cpp.
References checkInit(), checkInt(), and checkKonst().
Referenced by infereSigType().
{
checkKonst(checkInt(checkInit(size)));
return init;
}


Definition at line 471 of file sigtyperules.cpp.
References checkInit(), checkInt(), checkKonst(), kSamp, and kScal.
Referenced by infereSigType().
{
checkKonst(checkInt(checkInit(size)));
Type temp = init
->promoteVariability(kSamp) // difficult to tell, therefore kSamp to be safe
->promoteComputability(widx->computability()|wsig->computability())
->promoteVectorability(kScal) // difficult to tell, therefore kScal to be safe
->promoteNature(wsig->nature()) // nature of the initial and written signal
->promoteBoolean(wsig->boolean()) // booleanity of the initial and written signal
;
return temp;
}


| static Type infereFConstType | ( | Tree | type | ) | [static] |
Infere the type of a foreign constant.
Definition at line 554 of file sigtyperules.cpp.
References kInit, kKonst, kNum, kVect, makeSimpleType(), and tree2int().
Referenced by infereSigType().
{
// une constante externe ne peut pas se calculer au plus tot qu'a
// l'initialisation. Elle est constante, auquel cas on considere que c'est comme
// rand() c'est a dire que le resultat varie a chaque appel.
return makeSimpleType(tree2int(type),kKonst,kInit,kVect,kNum, interval());
}


| static Type infereFFType | ( | Tree | ff, |
| Tree | ls, | ||
| Tree | env | ||
| ) | [static] |
Infere the type of a foreign function call.
Definition at line 524 of file sigtyperules.cpp.
References ffarity(), ffrestype(), hd(), isList(), kInit, kInt, kKonst, kNum, kSamp, kVect, makeSimpleType(), T(), and tl().
Referenced by infereSigType().
{
// une primitive externe ne peut pas se calculer au plus tot qu'a
// l'initialisation. Sa variabilite depend de celle de ses arguments
// sauf si elle n'en pas, auquel cas on considere que c'est comme
// rand() c'est a dire que le resultat varie a chaque appel.
if (ffarity(ff)==0) {
// case of functions like rand()
return makeSimpleType(ffrestype(ff),kSamp,kInit,kVect,kNum, interval());
} else {
// otherwise variability and computability depends
// arguments (OR of all arg types)
Type t = makeSimpleType(kInt,kKonst,kInit,kVect,kNum, interval());
while (isList(ls)) { t = t|T(hd(ls),env); ls=tl(ls); }
// but the result type is defined by the function
//return t;
return makeSimpleType( ffrestype(ff),
t->variability(),
t->computability(),
t->vectorability(),
t->boolean(),
interval() );
}
}


| static Type infereFVarType | ( | Tree | type | ) | [static] |
Infere the type of a foreign variable.
Definition at line 566 of file sigtyperules.cpp.
References kBlock, kExec, kNum, kVect, makeSimpleType(), and tree2int().
Referenced by infereSigType().
{
// une variable externe ne peut pas se calculer au plus tot qu'a
// l'execution. Elle est varie par blocs comme les éléments d'interface utilisateur.
return makeSimpleType(tree2int(type),kBlock,kExec,kVect,kNum, interval());
}


| static Type infereProjType | ( | Type | t, |
| int | i, | ||
| int | vec | ||
| ) | [static] |
Infere the type of a projection (selection) of a tuplet element.
Definition at line 388 of file sigtyperules.cpp.
References isTupletType(), kVect, and vecCast().
Referenced by infereSigType().
{
TupletType* tt = isTupletType(t);
if (tt == 0) {
cerr << "ERROR infering projection type, not a tuplet type : " << t << endl;
exit(1);
}
//return (*tt)[i] ->promoteVariability(t->variability())
// ->promoteComputability(t->computability());
Type temp = (*tt)[i] ->promoteVariability(t->variability())
->promoteComputability(t->computability())
->promoteVectorability(vec/*t->vectorability()*/);
//->promoteBooleanity(t->boolean());
if(vec==kVect) temp = vecCast(temp);
//cerr << "infereProjType(" << t << ',' << i << ',' << vec << ")" << " -> " << temp << endl;
return temp;
}


| static Type infereReadTableType | ( | Type | tbl, |
| Type | ri | ||
| ) | [static] |
Infere the type of the result of reading a table.
Definition at line 440 of file sigtyperules.cpp.
References AudioType::boolean(), AudioType::computability(), TableType::content(), isSimpleType(), isTableType(), kInt, AudioType::nature(), AudioType::variability(), and AudioType::vectorability().
Referenced by infereSigType().
{
TableType* tt = isTableType(tbl);
if (tt == 0) {
cerr << "ERROR infering read table type, wrong table type : " << tbl << endl;
exit(1);
}
SimpleType* st = isSimpleType(ri);
if (st == 0 || st->nature() > kInt) {
cerr << "ERROR infering read table type, wrong write index type : " << ri << endl;
exit(1);
}
Type temp = tt->content()->promoteVariability(ri->variability()|tt->variability())
->promoteComputability(ri->computability()|tt->computability())
->promoteVectorability(ri->vectorability()|tt->vectorability())
->promoteBoolean(ri->boolean()|tt->boolean())
;
return temp;
}


| static Type infereRecType | ( | Tree | var, |
| Tree | body, | ||
| Tree | env | ||
| ) | [static] |
Infere the type of e recursive block by trying solutions of increasing generality.
Definition at line 514 of file sigtyperules.cpp.
Referenced by infereSigType().
{
assert(false); // we should not come here
return 0;
}

| static Type infereSigType | ( | Tree | sig, |
| Tree | env | ||
| ) | [static] |
Infere the type of a term according to its surrounding type environment.
| sig | the signal to aanlyze |
| env | the type environment |
Definition at line 244 of file sigtyperules.cpp.
References arithmetic(), AudioType::boolean(), castInterval(), checkInit(), checkInt(), AudioType::computability(), floatCast(), AudioType::getInterval(), getUserData(), hd(), infereDocAccessTblType(), infereDocConstantTblType(), infereDocWriteTblType(), infereFConstType(), infereFFType(), infereFVarType(), infereProjType(), infereReadTableType(), infereRecType(), infereWriteTableType(), infereXType(), intCast(), isList(), isNil(), isProj(), isRec(), isSigAttach(), isSigBinOp(), isSigButton(), isSigCheckbox(), isSigDelay1(), isSigDocAccessTbl(), isSigDocConstantTbl(), isSigDocWriteTbl(), isSigFConst(), isSigFFun(), isSigFixDelay(), isSigFloatCast(), isSigFVar(), isSigGen(), isSigHBargraph(), isSigHSlider(), isSigInput(), isSigInt(), isSigIntCast(), isSigNumEntry(), isSigOutput(), isSigPrefix(), isSigRDTbl(), isSigReal(), isSigSelect2(), isSigSelect3(), isSigTable(), isSigVBargraph(), isSigVSlider(), isSigWRTbl(), isSimpleType(), kComp, kGT, kInt, kKonst, kNE, kNum, kReal, kScal, kVect, interval::lo, makeSimpleType(), makeTableType(), max(), min(), name(), AudioType::nature(), print(), reunion(), sampCast(), T(), TGUI, TGUI01, TINPUT, tl(), tree2float(), interval::valid, AudioType::variability(), and AudioType::vectorability().
Referenced by T().
{
int i;
double r;
Tree sel, s1, s2, s3, ff, id, ls, l, x, y, z, u, var, body, type, name, file;
Tree label, cur, min, max, step;
countInferences++;
if ( getUserData(sig) ) return infereXType(sig, env);
else if (isSigInt(sig, &i)) { Type t = makeSimpleType(kInt, kKonst, kComp, kVect, kNum, interval(i));
/*sig->setType(t);*/ return t; }
else if (isSigReal(sig, &r)) { Type t = makeSimpleType(kReal, kKonst, kComp, kVect, kNum, interval(r));
/*sig->setType(t);*/ return t; }
else if (isSigInput(sig, &i)) { /*sig->setType(TINPUT);*/ return TINPUT; }
else if (isSigOutput(sig, &i, s1)) return sampCast(T(s1,env));
else if (isSigDelay1(sig, s1)) {
Type t = T(s1,env);
return castInterval(sampCast(t), reunion(t->getInterval(), interval(0,0)));
}
else if (isSigPrefix(sig, s1, s2)) {
Type t1 = T(s1,env);
Type t2 = T(s2,env);
checkInit(t1);
return castInterval(sampCast(t1|t2), reunion(t1->getInterval(), t2->getInterval()));
}
else if (isSigFixDelay(sig, s1, s2)) {
Type t1 = T(s1,env);
Type t2 = T(s2,env);
interval i = t2->getInterval();
// cerr << "for sig fix delay : s1 = "
// << t1 << ':' << ppsig(s1) << ", s2 = "
// << t2 << ':' << ppsig(s2) << endl;
if (!i.valid) {
cerr << "ERROR : can't compute the min and max values of : " << ppsig(s2) << endl;
cerr << " used in delay expression : " << ppsig(sig) << endl;
cerr << " (probably a recursive signal)" << endl;
exit(1);
} else if (i.lo < 0) {
cerr << "ERROR : possible negative values of : " << ppsig(s2) << endl;
cerr << " used in delay expression : " << ppsig(sig) << endl;
cerr << " " << i << endl;
exit(1);
}
return castInterval(sampCast(t1), reunion(t1->getInterval(), interval(0,0)));
}
else if (isSigBinOp(sig, &i, s1, s2)) {
//Type t = T(s1,env)|T(s2,env);
Type t1 = T(s1,env);
Type t2 = T(s2,env);
Type t3 = castInterval(t1 | t2, arithmetic(i, t1->getInterval(), t2->getInterval()));
//cerr <<"type rule for : " << ppsig(sig) << " -> " << *t3 << endl;
//return (!gVectorSwitch && (i>=kGT) && (i<=kNE)) ? intCast(t3) : t3; // for comparaison operation the result is int
return ((i>=kGT) && (i<=kNE)) ? intCast(t3) : t3; // for comparaison operation the result is int
}
else if (isSigIntCast(sig, s1)) return intCast(T(s1,env));
else if (isSigFloatCast(sig, s1)) return floatCast(T(s1,env));
else if (isSigFFun(sig, ff, ls)) return infereFFType(ff,ls,env);
else if (isSigFConst(sig,type,name,file)) return infereFConstType(type);
else if (isSigFVar(sig,type,name,file)) return infereFVarType(type);
else if (isSigButton(sig)) { /*sig->setType(TGUI01);*/ return TGUI01; }
else if (isSigCheckbox(sig)) { /*sig->setType(TGUI01);*/ return TGUI01; }
else if (isSigVSlider(sig,label,cur,min,max,step))
return castInterval(TGUI,interval(tree2float(min),tree2float(max)));
else if (isSigHSlider(sig,label,cur,min,max,step))
return castInterval(TGUI,interval(tree2float(min),tree2float(max)));
else if (isSigNumEntry(sig,label,cur,min,max,step))
return castInterval(TGUI,interval(tree2float(min),tree2float(max)));
else if (isSigHBargraph(sig, l, x, y, s1)) return T(s1,env);
else if (isSigVBargraph(sig, l, x, y, s1)) return T(s1,env);
else if (isSigAttach(sig, s1, s2)) { T(s2,env); return T(s1,env); }
else if (isRec(sig, var, body)) return infereRecType(sig, body, env);
else if (isProj(sig, &i, s1)) return infereProjType(T(s1,env),i,kScal);
else if (isSigTable(sig, id, s1, s2)) { checkInt(checkInit(T(s1,env))); return makeTableType(checkInit(T(s2,env))); }
else if (isSigWRTbl(sig, id, s1, s2, s3)) return infereWriteTableType(T(s1,env), T(s2,env), T(s3,env));
else if (isSigRDTbl(sig, s1, s2)) return infereReadTableType(T(s1,env), T(s2,env));
else if (isSigGen(sig, s1)) return T(s1,NULLTYPEENV);
else if ( isSigDocConstantTbl(sig, x, y) ) return infereDocConstantTblType(T(x,env), T(y,env));
else if ( isSigDocWriteTbl(sig,x,y,z,u) ) return infereDocWriteTblType(T(x,env), T(y,env), T(z,env), T(u,env));
else if ( isSigDocAccessTbl(sig, x, y) ) return infereDocAccessTblType(T(x,env), T(y,env));
else if (isSigSelect2(sig,sel,s1,s2)) {
SimpleType *st1, *st2, *stsel;
st1 = isSimpleType(T(s1,env));
st2 = isSimpleType(T(s2,env));
stsel = isSimpleType(T(sel,env));
return makeSimpleType( st1->nature()|st2->nature(),
st1->variability()|st2->variability()|stsel->variability(),
st1->computability()|st2->computability()|stsel->computability(),
st1->vectorability()|st2->vectorability()|stsel->vectorability(),
st1->boolean()|st2->boolean(),
reunion(st1->getInterval(), st2->getInterval())
);
}
else if (isSigSelect3(sig,sel,s1,s2,s3)) { return T(sel,env)|T(s1,env)|T(s2,env)|T(s3,env); }
else if (isNil(sig)) { Type t = new TupletType(); /*sig->setType(t);*/ return t; }
else if (isList(sig)) { return T( hd(sig),env ) * T( tl(sig),env ); }
// unrecognized signal here
fprintf(stderr, "ERROR infering signal type : unrecognized signal : "); print(sig, stderr); fprintf(stderr, "\n");
exit(1);
return 0;
}

| static Type infereWriteTableType | ( | Type | tbl, |
| Type | wi, | ||
| Type | wd | ||
| ) | [static] |
Infere the type of the result of writing into a table.
Definition at line 413 of file sigtyperules.cpp.
References TableType::content(), isSimpleType(), isTableType(), kInt, makeTableType(), and AudioType::nature().
Referenced by infereSigType().
{
TableType* tt = isTableType(tbl);
if (tt == 0) {
cerr << "ERROR infering write table type, wrong table type : " << tbl << endl;
exit(1);
}
SimpleType* st = isSimpleType(wi);
if (st == 0 || st->nature() > kInt) {
cerr << "ERROR infering write table type, wrong write index type : " << wi << endl;
exit(1);
}
int n = tt->nature();
int v = wi->variability() | wd->variability();
int c = wi->computability() | wd->computability();
int vec = wi->vectorability() | wd->vectorability();
return makeTableType(tt->content(), n, v, c, vec);
}


| static Type infereXType | ( | Tree | sig, |
| Tree | env | ||
| ) | [static] |
Infere the type of an extended (primitive) block.
Definition at line 577 of file sigtyperules.cpp.
References CTree::arity(), CTree::branch(), getUserData(), xtended::infereSigType(), and T().
Referenced by infereSigType().
{
//cerr << "infereXType :" << endl;
//cerr << "infereXType of " << *sig << endl;
xtended* p = (xtended*) getUserData(sig);
vector<Type> vt;
for (int i = 0; i < sig->arity(); i++) vt.push_back(T(sig->branch(i), env));
return p->infereSigType(vt);
}


| static Type initialRecType | ( | Tree | t | ) | [static] |
Compute an initial type solution for a recursive block E1,E2,...En -> TREC,TREC,...TREC.
Definition at line 500 of file sigtyperules.cpp.
References isList(), tl(), and TREC.
Referenced by typeAnnotation().
{
assert (isList(t));
vector<Type> v;
while (isList(t)) { v.push_back(TREC); t = tl(t); };
return new TupletType(v);
}


| static void setSigType | ( | Tree | sig, |
| Type | t | ||
| ) | [static] |
Set the type annotation of sig.
| sig | the signal we want to type |
| t | the type of the signal |
Definition at line 174 of file sigtyperules.cpp.
References CTree::setType(), TABBER, and TRACE.
Referenced by T(), and typeAnnotation().
{
TRACE(cerr << TABBER << "SET FIX TYPE OF " << *sig << " TO TYPE " << *t << endl;)
sig->setType(t);
}


Shortcut to getOrInferType, retrieve or infere the type of a term according to its surrounding type environment.
| sig | the signal to analyze |
| env | the type environment |
Definition at line 218 of file sigtyperules.cpp.
References getSigType(), infereSigType(), CTree::isAlreadyVisited(), setSigType(), CTree::setVisited(), TABBER, and TRACE.
{
TRACE(cerr << ++TABBER << "ENTER T() " << *term << endl;)
if (term->isAlreadyVisited()) {
Type ty = getSigType(term);
TRACE(cerr << --TABBER << "EXIT 1 T() " << *term << " AS TYPE " << *ty << endl);
return ty;
} else {
Type ty = infereSigType(term, ignoreenv);
setSigType(term,ty);
term->setVisited();
TRACE(cerr << --TABBER << "EXIT 2 T() " << *term << " AS TYPE " << *ty << endl);
return ty;
}
}

| void typeAnnotation | ( | Tree | sig | ) |
Fully annotate every subtree of term with type information.
Annotates a signal term and its subterms with type information.
| sig | the signal term tree to annotate |
Definition at line 87 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().
{
Tree sl = symlist(sig);
int n = len(sl);
vector<Tree> vrec, vdef;
vector<Type> vtype;
//cerr << "Symlist " << *sl << endl;
for (Tree l=sl; isList(l); l=tl(l)) {
Tree id, body;
assert(isRec(hd(l), id, body));
vrec.push_back(hd(l));
vdef.push_back(body);
}
// init recursive types
for (int i=0; i<n; i++) {
vtype.push_back(initialRecType(vdef[i]));
}
assert (int(vrec.size())==n);
assert (int(vdef.size())==n);
assert (int(vtype.size())==n);
// find least fixpoint
for (bool finished = false; !finished; ) {
// init recursive types
CTree::startNewVisit();
for (int i=0; i<n; i++) {
setSigType(vrec[i], vtype[i]);
vrec[i]->setVisited();
}
// compute recursive types
for (int i=0; i<n; i++) {
vtype[i] = T(vdef[i], NULLTYPEENV);
}
// check finished
finished = true;
for (int i=0; i<n; i++) {
//cerr << i << "-" << *vrec[i] << ":" << *getSigType(vrec[i]) << " => " << *vtype[i] << endl;
finished = finished & (getSigType(vrec[i]) == vtype[i]);
}
}
// type full term
T(sig, NULLTYPEENV);
}


int countInferences [static] |
Definition at line 77 of file sigtyperules.cpp.
int countMaximal [static] |
Definition at line 78 of file sigtyperules.cpp.
Tree NULLTYPEENV = tree(symbol("NullTypeEnv")) [static] |
The empty type environment (also property key for closed term type)
Definition at line 75 of file sigtyperules.cpp.
1.8.0