Fixed warnings in generated code nextnn variables unused.
* maxlevel is determined to create the amount of variables needed in the generated code, no more, no less.
This commit is contained in:
1 parent
2b0da3fd41
commit
c1b57435b2
4 files changed
+46
-10
No files matched your search
@@ -135,8 +135,9 @@ class EntList {
|
||||
MatchType viableVal() {
|
||||
return viable;
|
||||
}
|
||||
virtual void setLevel( int l ) {
|
||||
virtual int setLevel( int l ) {
|
||||
level = l;
|
||||
return level;
|
||||
}
|
||||
virtual int contains( const char * ) = 0;
|
||||
virtual int hit( const char * ) = 0;
|
||||
@@ -236,7 +237,7 @@ class MultList : public EntList {
|
||||
public:
|
||||
MultList( JoinType j ) : EntList( j ), numchildren( 0 ), childList( 0 ) {}
|
||||
~MultList();
|
||||
void setLevel( int );
|
||||
int setLevel( int );
|
||||
int contains( const char * );
|
||||
int hit( const char * );
|
||||
int isDependent( const char * );
|
||||
@@ -342,7 +343,7 @@ class ComplexList {
|
||||
public:
|
||||
ComplexList( AndList * alist = NULL ) : list( 0 ), head( alist ), next( 0 ),
|
||||
abstract( 0 ), dependent( 0 ),
|
||||
multSupers( 0 ) {}
|
||||
multSupers( 0 ), maxlevel( 0 ) {}
|
||||
ComplexList( Entity, ComplexCollect * );
|
||||
~ComplexList();
|
||||
void buildList();
|
||||
@@ -359,6 +360,9 @@ class ComplexList {
|
||||
const char * supertype() {
|
||||
return ( ( SimpleList * )head->childList )->name;
|
||||
}
|
||||
int getMaxlevel( void ) {
|
||||
return maxlevel;
|
||||
}
|
||||
// Based on knowledge that ComplexList always created by ANDing supertype
|
||||
// with subtypes.
|
||||
int toplevel( const char * );
|
||||
@@ -385,7 +389,9 @@ class ComplexList {
|
||||
int abstract; // is our supertype abstract?
|
||||
int dependent; // is our supertype also a subtype of other supertype(s)?
|
||||
int multSupers; // am I a combo-CList created to test a subtype which has
|
||||
}; // >1 supertypes?
|
||||
// >1 supertypes?
|
||||
int maxlevel;
|
||||
};
|
||||
|
||||
class ComplexCollect {
|
||||
// The collection of all the ComplexLists defined by the current schema.
|
||||
|
||||
@@ -115,6 +115,7 @@ ComplexList::ComplexList( Entity ent, ComplexCollect * col )
|
||||
ent->search_id = TRUE;
|
||||
list = NULL;
|
||||
next = NULL;
|
||||
maxlevel = 0;
|
||||
|
||||
addSuper( ent );
|
||||
if( ( exp = ent->u.entity->subtype_expression ) != NULL ) {
|
||||
@@ -134,7 +135,7 @@ ComplexList::ComplexList( Entity ent, ComplexCollect * col )
|
||||
// Rebuild list in case implicit subs were added (we had to build the
|
||||
// first time also so addImplicitSubs() would work).
|
||||
buildList();
|
||||
head->setLevel( 0 );
|
||||
maxlevel = head->setLevel( 0 );
|
||||
} else {
|
||||
// If this List has supertypes, we don't really need it as a List -
|
||||
// it will ultimately be a part of its super(s)' List(s). We need it
|
||||
|
||||
@@ -28,18 +28,24 @@ MultList::~MultList()
|
||||
}
|
||||
}
|
||||
|
||||
void MultList::setLevel( int l )
|
||||
int MultList::setLevel( int l )
|
||||
/*
|
||||
* Sets this's level, and tells all its children to set their level to our
|
||||
* level +1.
|
||||
* Returns the maxlevel of children.
|
||||
*/
|
||||
{
|
||||
EntList * child = childList;
|
||||
int maxlevel, childlevel;
|
||||
|
||||
level = l;
|
||||
maxlevel = l;
|
||||
for( ; child != NULL; child = child->next ) {
|
||||
child->setLevel( l + 1 );
|
||||
childlevel = child->setLevel( l + 1 );
|
||||
if (childlevel > maxlevel)
|
||||
maxlevel = childlevel;
|
||||
}
|
||||
return maxlevel;
|
||||
}
|
||||
|
||||
int MultList::contains( const char * nm )
|
||||
|
||||
+26
-3
@@ -43,7 +43,8 @@ void ComplexCollect::write( const char * fname )
|
||||
*/
|
||||
{
|
||||
ofstream complex;
|
||||
ComplexList * clist = clists;
|
||||
ComplexList * clist;
|
||||
int maxlevel;
|
||||
|
||||
// Open the stream:
|
||||
complex.open( fname );
|
||||
@@ -73,18 +74,40 @@ void ComplexCollect::write( const char * fname )
|
||||
* records which variable is being used. Perhaps we can track max(level) and only
|
||||
* write that many variables here.
|
||||
*/
|
||||
complex << " EntList *node, *child, *next1, *next2, *next3, *next4,\n"
|
||||
/* complex << " EntList *node, *child, *next1, *next2, *next3, *next4,\n"
|
||||
<< " *next5, *next6, *next7, *next8, *next9, *next10,\n"
|
||||
<< " *next11, *next12, *next13, *next14, *next15,\n"
|
||||
<< " *next16, *next17, *next18, *next19, *next20,\n"
|
||||
<< " *next21, *next22, *next23, *next24, *next25,\n"
|
||||
<< " *next26, *next27, *next28, *next29, *next30;"
|
||||
<< endl << endl;
|
||||
<< endl << endl;*/
|
||||
// Frankly, I'd hate to see a schema which needs so many variables. But
|
||||
// AP210 gets to `next23'.
|
||||
complex << " EntList *node, *child;\n";
|
||||
/* Determine maximum level to know how many variables to create */
|
||||
maxlevel = 0;
|
||||
for ( clist = clists; clist != NULL; clist = clist->next )
|
||||
{
|
||||
if ( clist->getMaxlevel() > maxlevel)
|
||||
maxlevel = clist->getMaxlevel();
|
||||
}
|
||||
/* Create maxlevel variables, maximum 4 variables for each line */
|
||||
for ( int level = 1; level < maxlevel ; level ++ ) {
|
||||
if ( ( ( level - 1 ) & 3 ) == 0 ) {
|
||||
if ( level > 1 ) {
|
||||
complex << ";\n";
|
||||
}
|
||||
complex << " EntList *next" << level;
|
||||
}
|
||||
else {
|
||||
complex << ", *next" << level;
|
||||
}
|
||||
}
|
||||
complex << ";\n\n";
|
||||
|
||||
// Next create the CCollect and CLists:
|
||||
complex << " cc = new ComplexCollect;\n";
|
||||
clist = clists;
|
||||
while( clist ) {
|
||||
complex << endl;
|
||||
complex << " // ComplexList with supertype \"" << clist->supertype()
|
||||
|
||||
Reference in new issue
Block a user