SynthesizedAttribute visitorTraversal::evaluateSynthesizedAttribute ( SgNode* n, SynthesizedAttributesList childAttributes ) { SynthesizedAttribute localResult; // printf ("In evaluateSynthesizedAttribute(n = %p = %s) \n",n,n->class_name().c_str()); // Build the list from children (in reverse order to preserve the final ordering) for (SynthesizedAttributesList::reverse_iterator child = childAttributes.rbegin(); child != childAttributes.rend(); child++) { localResult.accumulatedList.splice(localResult.accumulatedList.begin(),child->accumulatedList); } // Add in the information from the current node SgLocatedNode* locatedNode = isSgLocatedNode(n); if (locatedNode != NULL) { AttachedPreprocessingInfoType* commentsAndDirectives = locatedNode->getAttachedPreprocessingInfo(); if (commentsAndDirectives != NULL) { // printf ("Found attached comments (to IR node at %p of type: %s): \n",locatedNode,locatedNode->class_name().c_str()); // int counter = 0; // Use a reverse iterator so that we preserve the order when using push_front to add each directive to the accumulatedList AttachedPreprocessingInfoType::reverse_iterator i; for (i = commentsAndDirectives->rbegin(); i != commentsAndDirectives->rend(); i++) { // The different classifications of comments and directives are in ROSE/src/frontend/SageIII/rose_attributes_list.h if ((*i)->getTypeOfDirective() == PreprocessingInfo::CpreprocessorDefineDeclaration) { #if 0 printf (" Attached Comment #%d in file %s (relativePosition=%s): classification %s :\n%s\n", counter++,(*i)->get_file_info()->get_filenameString().c_str(), ((*i)->getRelativePosition() == PreprocessingInfo::before) ? "before" : "after", PreprocessingInfo::directiveTypeName((*i)->getTypeOfDirective()).c_str(), (*i)->getString().c_str()); #endif // use push_front() to end up with source ordering of final list of directives localResult.accumulatedList.push_front(*i); } } } } // printf ("localResult after adding current node info \n"); // localResult.display(); return localResult; }
InterleaveAcrossArraysCheckSynthesizedAttributeType interleaveAcrossArraysCheck::evaluateSynthesizedAttribute ( SgNode* n, SynthesizedAttributesList childAttributes ) { //cout << " Node: " << n->unparseToString() << endl; InterleaveAcrossArraysCheckSynthesizedAttributeType localResult; for (SynthesizedAttributesList::reverse_iterator child = childAttributes.rbegin(); child != childAttributes.rend(); child++) { InterleaveAcrossArraysCheckSynthesizedAttributeType childResult = *child; localResult.isArrayRef |= childResult.isArrayRef; localResult.isFunctionRefExp |= childResult.isFunctionRefExp; } if(isSgVariableDeclaration(n)) { SgVariableDeclaration* varDecl = isSgVariableDeclaration(n); SgInitializedNamePtrList & varList = varDecl->get_variables(); for(SgInitializedNamePtrList::iterator initIter = varList.begin(); initIter!=varList.end() ; initIter++) { SgInitializedName* var = *initIter; ROSE_ASSERT(var!=NULL); SgType *variableType = var->get_type(); ROSE_ASSERT (variableType != NULL); string type = TransformationSupport::getTypeName(variableType); string variableName = var->get_name().str(); //Case 6 if(outputName == variableName) { cout << " ERROR: Substituting Array " << outputName << " already declared in the file." << endl; ROSE_ABORT(); } if(type!="doubleArray" && type !="floatArray" && type!="intArray") return localResult; #if DEBUG cout << " Var Name: " << variableName << " Type: " << type << endl; #endif storeArrayReference(var, variableName, type ); } } else if(isSgPntrArrRefExp(n)) { SgVarRefExp* varRefExp = isSgVarRefExp(isSgPntrArrRefExp(n)->get_lhs_operand()); if(varRefExp != NULL) { SgVariableSymbol* variableSymbol = varRefExp->get_symbol(); ROSE_ASSERT (variableSymbol != NULL); SgInitializedName* initializedName = variableSymbol->get_declaration(); ROSE_ASSERT (initializedName != NULL); string variableName = initializedName->get_name().str(); SgType* type = variableSymbol->get_type(); ROSE_ASSERT (type != NULL); string typeName = TransformationSupport::getTypeName(type); // A++ Supported Arrays if(typeName !="doubleArray" && typeName !="floatArray" && typeName !="intArray") return localResult; // Check if variableName matches the input list if(transformation->containsInput(variableName)) localResult.isArrayRef = true; } } else if(isSgFunctionCallExp(n)) { // Case 1 // Check for array being present in function Call if(localResult.isFunctionRefExp && localResult.isArrayRef) { cout << " ERROR: Array Reference present in a function call " << endl; ROSE_ABORT(); } } else if(isSgFunctionRefExp(n)) { localResult.isFunctionRefExp = true; } else if(isSgStatement(n)) { //Case 2 if(isContigousDecl) { cout << " ERROR: Array Declaration are not contigous. " << endl; ROSE_ABORT(); } } return localResult; }