Commit e11004db authored by maitre's avatar maitre
Browse files

Support for gpnode

parent ff5dc5d5
......@@ -1159,6 +1159,7 @@ if(OPERATING_SYSTEM=WINDOWS)
<GENOME_ANALYSIS>"float" {yylval.pSymbol = pSymbolTable->find("float"); return FLOAT;}
<GENOME_ANALYSIS>"char" {yylval.pSymbol = pSymbolTable->find("char"); return CHAR;}
<GENOME_ANALYSIS>"pointer" {yylval.pSymbol = pSymbolTable->find("pointer"); return POINTER;}
//<GENOME_ANALYSIS>"pointer" {yylval.pSymbol = pSymbolTable->find("pointer"); return POINTER;}
<GENOME_ANALYSIS>"\\end" {rewind(fpGenomeFile);yyin = fpTemplateFile;BEGIN TEMPLATE_ANALYSIS;} // Back to the template file
<GENOME_ANALYSIS>"GenomeClass" {return GENOME; }
......
......@@ -319,8 +319,24 @@ Object
pCURRENT_CLASS->pSymbolList->addFirst((CSymbol *)($2));
if (bVERBOSE) printf(" %s pointer declared (%d bytes)\n",$2->sName,$2->nSize);
}
| '*''*' Symbol {
$3->nSize=sizeof (char *);
$3->pClass=pCURRENT_CLASS;
$3->pType=pCURRENT_TYPE;
$3->ObjectType=oPointer;
$3->ObjectQualifier=pCURRENT_TYPE->ObjectQualifier;
pCURRENT_CLASS->nSize+=$3->nSize;
pCURRENT_CLASS->pSymbolList->addFirst((CSymbol *)($3));
if (bVERBOSE) printf(" %s pointer of pointer declared (%d bytes)\n",$3->sName,$3->nSize);
fprintf(stderr,"Pointer of pointer doesn't work properly yet\n");
exit(-1);
}
| Symbol '[' Expr ']' {
if((TARGET_FLAVOR==STD_FLAVOR_CMAES || TARGET_FLAVOR==CUDA_FLAVOR_CMAES) && nPROBLEM_DIM==0 && strcmp(pCURRENT_CLASS->sName,"Genome")==0) { nGENOME_NAME=$1->sName; nPROBLEM_DIM=(int)$3;}
printf("DEBUG : size of $3 %d nSize %d\n",(int)$3,pCURRENT_TYPE->nSize);
$1->nSize=pCURRENT_TYPE->nSize*(int)$3;
$1->pClass=pCURRENT_CLASS;
$1->pType=pCURRENT_TYPE;
......@@ -330,6 +346,26 @@ Object
pCURRENT_CLASS->pSymbolList->addFirst((CSymbol *)($1));
if (bVERBOSE) printf(" %s array declared (%d bytes)\n",$1->sName,$1->nSize);
}
| '*' Symbol '[' Expr ']' {
// this is for support of pointer array. This should be done in a more generic way in a later version
if((TARGET_FLAVOR==STD_FLAVOR_CMAES || TARGET_FLAVOR==CUDA_FLAVOR_CMAES) && nPROBLEM_DIM==0 && strcmp(pCURRENT_CLASS->sName,"Genome")==0) {
nGENOME_NAME=$2->sName; nPROBLEM_DIM=(int)$4;
}
//pCURRENT_CLASS->nSize
$2->nSize=sizeof(char*)*(int)$4;
$2->pClass=pCURRENT_CLASS;
$2->pType=pCURRENT_TYPE;
$2->ObjectType=oArrayPointer;
$2->ObjectQualifier=pCURRENT_TYPE->ObjectQualifier;
pCURRENT_CLASS->nSize+=$2->nSize;
pCURRENT_CLASS->pSymbolList->addFirst((CSymbol *)($2));
printf("DEBUG : size of $4 %d nSize %d\n",(int)$4,pCURRENT_TYPE->nSize);
if (bVERBOSE) printf(" %s array of pointers declared (%d bytes)\n",$2->sName,$2->nSize);
}
;
BaseConstructorParameters
......
......@@ -145,9 +145,14 @@ void CSymbol::print(FILE *fp){
fprintf(fp," %s(){ // Constructor\n",sName); // constructor
pSymbolList->reset(); // in which we initialise all pointers to NULL
while (pSym=pSymbolList->walkToNextItem())
while (pSym=pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectType==oPointer)
fprintf(fp," %s=NULL;\n",pSym->Object->sName);
if (pSym->Object->ObjectType==oArrayPointer){
fprintf(fp," for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
fprintf(fp," %s[EASEA_Ndx]=NULL;\n",pSym->Object->sName);
}
}
fprintf(fp," }\n"); // constructor
fprintf(fp," %s(%s &EASEA_Var) { // Copy constructor\n",sName,sName); // copy constructor
......@@ -162,6 +167,7 @@ void CSymbol::print(FILE *fp){
if (pSym->Object->ObjectType==oPointer){
fprintf(fp," %s=(EASEA_Var.%s ? new %s(*(EASEA_Var.%s)) : NULL);\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->pType->sName,pSym->Object->sName);
}
}
fprintf(fp," }\n"); // copy constructor
......@@ -170,7 +176,12 @@ void CSymbol::print(FILE *fp){
while (pSym=pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectType==oPointer)
fprintf(fp," if (%s) delete %s;\n %s=NULL;\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->sName);
if( pSym->Object->ObjectType==oArrayPointer ){
fprintf(fp," for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/sizeof(char*));
fprintf(fp," if( %s[EASEA_Ndx] ) delete %s[EASEA_Ndx];\n",pSym->Object->sName,pSym->Object->sName);
}
}
fprintf(fp," }\n"); // destructor
fprintf(fp," %s& operator=(%s &EASEA_Var) { // Operator=\n",sName,sName); // operator=
......@@ -182,6 +193,10 @@ void CSymbol::print(FILE *fp){
if (pSym->Object->ObjectType==oArray){
fprintf(fp," {for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
fprintf(fp," %s[EASEA_Ndx] = EASEA_Var.%s[EASEA_Ndx];}\n",pSym->Object->sName,pSym->Object->sName);
}
if (pSym->Object->ObjectType==oArrayPointer){
fprintf(fp," for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/sizeof(char*));
fprintf(fp," if(EASEA_Var.%s[EASEA_Ndx]) %s[EASEA_Ndx] = new %s(*(EASEA_Var.%s[EASEA_Ndx]));\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->pType->sName,pSym->Object->sName);
}
if (pSym->Object->ObjectType==oPointer){
fprintf(fp," if (%s) delete %s;\n",pSym->Object->sName,pSym->Object->sName);
......@@ -196,9 +211,13 @@ void CSymbol::print(FILE *fp){
if (TARGET==CUDA || TARGET==STD){
if (pSym->Object->ObjectType==oObject)
fprintf(fp," if (%s!=EASEA_Var.%s) return false;\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oArray){
if (pSym->Object->ObjectType==oArray ){
fprintf(fp," {for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
fprintf(fp," if (%s[EASEA_Ndx]!=EASEA_Var.%s[EASEA_Ndx]) return false;}\n",pSym->Object->sName,pSym->Object->sName);
}
if ( pSym->Object->ObjectType==oArrayPointer){
fprintf(fp," {for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/sizeof(char*));
fprintf(fp," if (%s[EASEA_Ndx]!=EASEA_Var.%s[EASEA_Ndx]) return false;}\n",pSym->Object->sName,pSym->Object->sName);
}
if (pSym->Object->ObjectType==oPointer){
fprintf(fp," if (((%s) && (!EASEA_Var.%s)) || ((!%s) && (EASEA_Var.%s))) return false;\n",pSym->Object->sName,pSym->Object->sName, pSym->Object->sName,pSym->Object->sName,pSym->Object->sName);
......@@ -215,27 +234,32 @@ void CSymbol::print(FILE *fp){
while (pSym=pSymbolList->walkToNextItem()){
if (pSym->Object->ObjectType==oObject)
fprintf(fp," os << \"%s:\" << EASEA_Var.%s << \"\\n\";\n",pSym->Object->sName,pSym->Object->sName);
if (pSym->Object->ObjectType==oArray){
if (pSym->Object->ObjectType==oArray ){
fprintf(fp," {os << \"Array %s : \";\n",pSym->Object->sName);
fprintf(fp," for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
fprintf(fp," os << \"[\" << EASEA_Ndx << \"]:\" << EASEA_Var.%s[EASEA_Ndx] << \"\\t\";}\n os << \"\\n\";\n",pSym->Object->sName);
}
if( pSym->Object->ObjectType==oArrayPointer){
fprintf(fp," {os << \"Array %s : \";\n",pSym->Object->sName);
fprintf(fp," for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/sizeof(char*));
fprintf(fp," if( EASEA_Var.%s[EASEA_Ndx] ) os << \"[\" << EASEA_Ndx << \"]:\" << *(EASEA_Var.%s[EASEA_Ndx]) << \"\\t\";}\n os << \"\\n\";\n",pSym->Object->sName,pSym->Object->sName);
}
if (pSym->Object->ObjectType==oPointer)
fprintf(fp," if (EASEA_Var.%s) os << \"%s:\" << *(EASEA_Var.%s) << \"\\n\";\n",pSym->Object->sName,pSym->Object->sName,pSym->Object->sName);
}
fprintf(fp," return os;\n }\n\n"); // Output stream insertion operator
fprintf(fp," friend istream& operator>> (istream& is, %s& EASEA_Var) { // Input stream extraction operator\n",sName); // Output stream insertion operator
pSymbolList->reset();
while (pSym=pSymbolList->walkToNextItem()){
if ((pSym->Object->ObjectType==oObject)&&(strcmp(pSym->Object->pType->sName, "bool")))
fprintf(fp," is >> EASEA_Var.%s;\n",pSym->Object->sName);
if ((pSym->Object->ObjectType==oArray)&&(strcmp(pSym->Object->pType->sName, "bool"))) {
fprintf(fp," {for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
fprintf(fp," is >> EASEA_Var.%s[EASEA_Ndx];}\n",pSym->Object->sName);
}
}
fprintf(fp," return is;\n }\n\n"); // Input stream extraction operator
// fprintf(fp," friend istream& operator>> (istream& is, %s& EASEA_Var) { // Input stream extraction operator\n",sName); // Output stream insertion operator
// pSymbolList->reset();
// while (pSym=pSymbolList->walkToNextItem()){
// if ((pSym->Object->ObjectType==oObject)&&(strcmp(pSym->Object->pType->sName, "bool")))
// fprintf(fp," is >> EASEA_Var.%s;\n",pSym->Object->sName);
// if ((pSym->Object->ObjectType==oArray)&&(strcmp(pSym->Object->pType->sName, "bool"))) {
// fprintf(fp," {for(int EASEA_Ndx=0; EASEA_Ndx<%d; EASEA_Ndx++)\n",pSym->Object->nSize/pSym->Object->pType->nSize);
// fprintf(fp," is >> EASEA_Var.%s[EASEA_Ndx];}\n",pSym->Object->sName);
// }
// }
// fprintf(fp," return is;\n }\n\n"); // Input stream extraction operator
if (sString) {
if (bVERBOSE) printf ("Inserting Methods into %s Class.\n",sName);
......@@ -254,6 +278,9 @@ void CSymbol::print(FILE *fp){
fprintf(fp," %s *%s;\n",pSym->Object->pType->sName,pSym->Object->sName);
if ((pSym->Object->ObjectType==oArray))
fprintf(fp," %s %s[%d];\n",pSym->Object->pType->sName,pSym->Object->sName,pSym->Object->nSize/pSym->Object->pType->nSize);
if ((pSym->Object->ObjectType==oArrayPointer))
fprintf(fp," %s* %s[%d];\n",pSym->Object->pType->sName,pSym->Object->sName,pSym->Object->nSize/sizeof(char*));
}
if (strcmp(sName,"Genome"))
......
......@@ -16,7 +16,7 @@ Rocquencourt BP 105
extern void debug (char *);
enum EObjectType {oUserClass, oBaseClass, oObject, oPointer, oArray, oMacro, oUndefined};
enum EObjectType {oUserClass, oBaseClass, oObject, oPointer, oArray, oMacro, oUndefined, oArrayPointer};
/////////////////////////////////////////////////////////////////////////////
// Object
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment