//======================================================================================== // SgUntypedInitializedNameList //---------------------------------------------------------------------------------------- ATbool traverse_SgUntypedInitializedNameList(ATerm term, SgUntypedInitializedNameList** var_SgUntypedInitializedNameList) { #ifdef PRINT_ATERM_TRAVERSAL printf("... traverse_SgUntypedInitializedNameList: %s\n", ATwriteToString(term)); #endif ATerm term1; *var_SgUntypedInitializedNameList = NULL; if (ATmatch(term, "SgUntypedInitializedNameList(<term>)", &term1)) { SgUntypedInitializedNameList* plist = new SgUntypedInitializedNameList(); ATermList tail = (ATermList) ATmake("<term>", term1); while (! ATisEmpty(tail)) { SgUntypedInitializedName* arg; ATerm head = ATgetFirst(tail); tail = ATgetNext(tail); if (traverse_SgUntypedInitializedName(head, (SgUntypedInitializedName**) &arg)) { // SgUntypedInitializedName plist->get_name_list().push_back(arg); continue; } delete plist; return ATfalse; } *var_SgUntypedInitializedNameList = plist; } else return ATfalse; // turn on build functions (using BuildStmt) in sage-to-traverse.str return ATtrue; }
//======================================================================================== // R501 type-declaration-stmt //---------------------------------------------------------------------------------------- void UntypedASTBuilder::build_TypeDeclarationStmt(TypeDeclarationStmt * typeDeclarationStmt) { #if 0 Sg_File_Info * start = NULL; SgUntypedType * type = NULL; SgUntypedVariableDeclaration * stmt = NULL; SgUntypedInitializedNameList * parameters = NULL; // DeclarationTypeSpec // type = isSgUntypedType(typeDeclarationStmt->getDeclarationTypeSpec()->getPayload()); start = type->get_startOfConstruct(); stmt = new SgUntypedVariableDeclaration(start, type); #if UNPARSER_AVAILABLE stmt->set_has_unparse(true); #endif if (typeDeclarationStmt->getLabel()) stmt->set_label_string(typeDeclarationStmt->getLabel()->getValue()); stmt->set_parameters(new SgUntypedInitializedNameList(start)); #ifdef OFP_BUILD_DEBUG printf("build_TypeDeclarationStmt: .........\n"); #endif // OptAttrSpecList //TODO-CER- implement // // EntityDeclList // std::vector<EntityDecl*>* declList = typeDeclarationStmt->getEntityDeclList()->getEntityDeclList(); //TODO-CER-2014.3.7 should this be variables or parameters? #ifdef OFP_BUILD_DEBUG printf(" parameters: ......... "); #endif parameters = stmt->get_parameters(); for (unsigned int i = 0; i < declList->size(); i++) { std::string name = declList->at(i)->getObjectName()->getIdent()->getName(); parameters->get_name_list().push_back(new SgUntypedInitializedName(start, type, name)); #ifdef OFP_BUILD_DEBUG printf("%s ", name.c_str()); #endif } #ifdef OFP_BUILD_DEBUG printf("\n"); #endif typeDeclarationStmt->setPayload(stmt); #endif }
//======================================================================================== // R501 type-declaration-stmt //---------------------------------------------------------------------------------------- void UntypedASTBuilder::build_TypeDeclarationStmt(TypeDeclarationStmt * typeDeclarationStmt) { Sg_File_Info * start = NULL; SgUntypedType * type = NULL; SgUntypedVariableDeclaration * stmt = NULL; SgUntypedInitializedNameList * parameters = NULL; // DeclarationTypeSpec // type = isSgUntypedType(typeDeclarationStmt->getDeclarationTypeSpec()->getPayload()); start = type->get_startOfConstruct(); stmt = new SgUntypedVariableDeclaration(start, type); if (typeDeclarationStmt->getLabel()) stmt->set_label_string(typeDeclarationStmt->getLabel()->getValue()); stmt->set_parameters(new SgUntypedInitializedNameList(start)); printf("build_TypeDeclarationStmt: .........\n"); // OptAttrSpecList //TODO-CER- implement // // EntityDeclList // std::vector<EntityDecl*>* declList = typeDeclarationStmt->getEntityDeclList()->getEntityDeclList(); #ifdef NOT_NEEDED if (declSpec->getOptionType() == DeclarationTypeSpec::DeclarationTypeSpec_ITS) { IntrinsicTypeSpec* ispec = declSpec->getIntrinsicTypeSpec(); if (ispec->getOptionType() == IntrinsicTypeSpec::IntrinsicTypeSpec_INT) { type = new SgUntypedType(start, false); //TODO - set intrinsic type (FORTRAN_INTEGER) printf(" type_spec: ......... INTEGER\n"); } } #endif //TODO-CER-2014.3.7 should this be variables or parameters? printf(" parameters: ......... "); parameters = stmt->get_parameters(); for (int i = 0; i < declList->size(); i++) { std::string name = declList->at(i)->getObjectName()->getIdent()->getName(); parameters->get_name_list().push_back(new SgUntypedInitializedName(start, type, name)); printf("%s ", name.c_str()); } printf("\n"); typeDeclarationStmt->setPayload(stmt); }