@@ -50,7 +50,7 @@ using namespace std;
50
50
// prototypes
51
51
// --------------------------------------------------------------------------
52
52
53
- static void setSigType (Tree sig, Type t);
53
+ void setSigType (Tree sig, Type t);
54
54
static Type getSigType (Tree sig);
55
55
static TupletType* initialRecType (Tree t);
56
56
static TupletType* maximalRecType (Tree t);
@@ -297,7 +297,7 @@ void typeAnnotation(Tree sig, bool causality)
297
297
finished = true ;
298
298
for (int i = 0 ; i < n; i++) {
299
299
newTuplet.clear ();
300
- // cerr << i << "-" << *vrec[i] << ":" << *getSigType(vrec[i]) << " => " << *vtype[i] << endl;
300
+ // cerr << i << "-" << *vrec[i] << ":" << *getSigType(vrec[i]) << " => " << *vtype[i] << endl;
301
301
if (vtype[i] != getSigType (vrec[i])) {
302
302
finished = false ;
303
303
newRecType = derefRecCert (vtype[i]);
@@ -373,7 +373,7 @@ ::Type getCertifiedSigType(Tree sig)
373
373
* @param sig the signal we want to type
374
374
* @param t the type of the signal
375
375
*/
376
- static void setSigType (Tree sig, Type t)
376
+ void setSigType (Tree sig, Type t)
377
377
{
378
378
TRACE (cerr << gGlobal ->TABBER << " SET FIX TYPE OF " << ppsig (sig, MAX_ERROR_SIZE) << " TO TYPE " << *t << endl;)
379
379
sig->setType (t);
@@ -564,12 +564,12 @@ static Type infereSigType(Tree sig, Tree env)
564
564
565
565
else if (isSigButton (sig)) {
566
566
return castInterval (gGlobal ->TGUI ,
567
- gAlgebra .Button (interval (0 ,0 ))); // todo replace the name
567
+ gAlgebra .Button (interval (0 , 0 ))); // todo replace the name
568
568
}
569
569
570
570
else if (isSigCheckbox (sig)) {
571
571
return castInterval (gGlobal ->TGUI ,
572
- gAlgebra .Checkbox (interval (0 ,0 ))); // todo replace the name
572
+ gAlgebra .Checkbox (interval (0 , 0 ))); // todo replace the name
573
573
}
574
574
575
575
else if (isSigVSlider (sig, label, cur, min, max, step)) {
@@ -578,7 +578,7 @@ static Type infereSigType(Tree sig, Tree env)
578
578
Type t3 = T (max, env);
579
579
Type t4 = T (step, env);
580
580
return castInterval (gGlobal ->TGUI ,
581
- gAlgebra .VSlider (interval (0 ,0 ), // todo replace the name
581
+ gAlgebra .VSlider (interval (0 , 0 ), // todo replace the name
582
582
t1->getInterval (),
583
583
t2->getInterval (),
584
584
t3->getInterval (),
@@ -591,7 +591,7 @@ static Type infereSigType(Tree sig, Tree env)
591
591
Type t3 = T (max, env);
592
592
Type t4 = T (step, env);
593
593
return castInterval (gGlobal ->TGUI ,
594
- gAlgebra .HSlider (interval (0 ,0 ), // todo replace the name
594
+ gAlgebra .HSlider (interval (0 , 0 ), // todo replace the name
595
595
t1->getInterval (),
596
596
t2->getInterval (),
597
597
t3->getInterval (),
@@ -604,7 +604,7 @@ static Type infereSigType(Tree sig, Tree env)
604
604
Type t3 = T (max, env);
605
605
Type t4 = T (step, env);
606
606
return castInterval (gGlobal ->TGUI ,
607
- gAlgebra .NumEntry (interval (0 ,0 ), // todo replace the name
607
+ gAlgebra .NumEntry (interval (0 , 0 ), // todo replace the name
608
608
t1->getInterval (),
609
609
t2->getInterval (),
610
610
t3->getInterval (),
@@ -649,7 +649,7 @@ static Type infereSigType(Tree sig, Tree env)
649
649
Type tp = T (part, env);
650
650
T (z, env);
651
651
checkPartInterval (sig, tp);
652
- return makeSimpleType (kReal , kSamp , kExec , kVect , kNum , interval ());
652
+ return makeSimpleType (kReal , kSamp , kExec , kVect , kNum , interval (- 1 , 1 ));
653
653
}
654
654
655
655
else if (isSigAttach (sig, s1, s2)) {
@@ -806,8 +806,8 @@ static Type infereWriteTableType(Type tbl, Type wi, Type ws)
806
806
int v = wi->variability () | ws->variability ();
807
807
int c = wi->computability () | ws->computability ();
808
808
int vec = wi->vectorability () | ws->vectorability ();
809
- interval i = reunion (ws-> getInterval (), tbl-> getInterval ());
810
-
809
+ // Interval is the reunion of tbl (and its init signal) and ws
810
+ interval i = reunion (tbl-> getInterval (), ws-> getInterval ());
811
811
TRACE (cerr << gGlobal ->TABBER << " infering write table type : n="
812
812
<< " NR" [n] << " , v="
813
813
<< " KB?S" [v] << " , c="
@@ -954,31 +954,28 @@ static Type infereFVarType(Tree type)
954
954
* - the waveform is known at compile time
955
955
* - it can be vectorized because all values are known
956
956
* - knum ???
957
- * - the interval is min and max of values
957
+ * - the resulting interval is the reunion of all values intervals
958
958
*/
959
959
static Type infereWaveformType (Tree wfsig, Tree env)
960
960
{
961
- bool iflag = isInt (wfsig->branch (0 )->node ());
961
+ // start with the first item interval
962
+ Tree v = wfsig->branch (0 );
963
+ bool iflag1 = isInt (v->node ());
962
964
int n = wfsig->arity ();
963
- double lo, hi;
964
-
965
- lo = hi = tree2float (wfsig->branch (0 ));
966
- T (wfsig->branch (0 ), env);
965
+ interval res = (iflag1) ? gAlgebra .IntNum (tree2int (v)) : gAlgebra .FloatNum (tree2float (v));
966
+ T (v, env);
967
967
968
+ // loop for remaining items
968
969
for (int i = 1 ; i < n; i++) {
969
- Tree v = wfsig->branch (i);
970
+ v = wfsig->branch (i);
970
971
T (v, env);
971
- // compute range
972
- double f = tree2float (v);
973
- if (f < lo) {
974
- lo = f;
975
- } else if (f > hi) {
976
- hi = f;
977
- }
978
- iflag &= isInt (v->node ());
972
+ // compute interval
973
+ bool iflag2 = isInt (v->node ());
974
+ res = reunion (res, iflag2 ? gAlgebra .IntNum (tree2int (v)) : gAlgebra .FloatNum (tree2float (v)));
975
+ iflag1 &= iflag2;
979
976
}
980
977
981
- return makeSimpleType ((iflag ) ? kInt : kReal , kSamp , kComp , kScal , kNum , interval (lo, hi) );
978
+ return makeSimpleType ((iflag1 ) ? kInt : kReal , kSamp , kComp , kScal , kNum , res );
982
979
}
983
980
984
981
/* *
0 commit comments