9 #define LAZY_WRAPPING_MACRO false
15 class AtermToNodeConverter
21 std::map<std::string, SgScopeStatement*> translationScopeMap;
22 std::map<std::string, SgType*> translationTypeMap;
23 std::map<std::string, SgDeclarationStatement*> translationDeclarationMap;
24 std::map<std::string, SgInitializedName*> translationInitializedNameMap;
32 void updateTypeMap (std::string key,
SgType* scope);
33 SgType* lookupType (std::string key);
38 SgNode* convertAtermToNode(ATerm term);
41 template <
class TranslationMap,
class TranslationMapElement>
42 void updateMap_support (std::string key, TranslationMap & translationMap, TranslationMapElement* node);
44 template <
class TranslationMap,
class TranslationMapElement>
45 TranslationMapElement* lookupMap_support (std::string key, TranslationMap & tranlationMap);
48 extern std::map<std::string, SgNode*> translationNodeMap;
50 extern std::map<std::string, SgScopeStatement*> translationScopeMap;
51 extern std::map<std::string, SgType*> translationTypeMap;
52 extern std::map<std::string, SgDeclarationStatement*> translationDeclarationMap;
53 extern std::map<std::string, SgInitializedName*> translationInitializedNameMap;
56 void initializeTypeSystem();
58 std::string aterm_type_name( ATerm term );
60 std::string uniqueId(
SgNode* n);
64 std::string uniqueId(uint64_t n);
77 Sg_File_Info* getAtermFileInfo(ATerm term, std::string annotationName);
79 ATerm convertVectorToAterm(
const std::vector<ATerm>& v,
int start,
int len);
81 template <
typename Iter>
82 ATerm convertRangeToAterm(Iter b, Iter e);
84 template <
typename Iter>
85 ATerm convertSgNodeRangeToAterm(Iter b, Iter e);
87 std::string getShortVariantName(VariantT var);
89 ATerm getTraversalChildrenAsAterm(
SgNode* n);
91 ATerm convertNodeToAterm(
SgNode* n);
93 ATerm getAtermAnnotation(ATerm term,
char* annotation_name );
96 SgNode* generate_AST(ATerm & term);
99 std::vector<ATerm> getAtermList(ATerm ls);
101 std::string getAtermStringAttribute(ATerm term,
const std::string & annotationName );
102 int getAtermIntegerAttribute(ATerm term,
const std::string & annotationName );
113 SgNode* getAtermNodeAttribute(ATerm term,
const std::string & annotationName );
115 SgType* getAtermTypeNodeAttribute (ATerm term,
const std::string & annotationName );
116 SgScopeStatement* getAtermScopeNodeAttribute (ATerm term,
const std::string & annotationName );
119 SgDeclarationStatement* getAtermDeclarationNodeAttribute (ATerm term,
const std::string & annotationName );
124 #ifdef ROSE_USE_ROSE_ATERM_SUPPORT
126 template <
typename Iter>
128 AtermSupport::convertRangeToAterm(Iter b, Iter e)
130 ATermList ls = ATmakeList0();
133 ls = ATappend(ls, *b);
136 return ATmake(
"<term>", ls);
139 template <
typename Iter>
140 ATerm AtermSupport::convertSgNodeRangeToAterm(Iter b, Iter e)
142 bool lazyWrapping = LAZY_WRAPPING_MACRO;
144 ROSE_ASSERT(lazyWrapping ==
false);
146 if ( (b != e) && (*b != NULL) )
152 printf (
"warning: parent == NULL: *b = %p = %s \n",*b,(*b)->class_name().c_str());
157 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): Building an ATerm list for (*b)->get_parent() = %p = %s \n",parent,(parent != NULL) ? parent->
class_name().c_str() :
"NULL");
163 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): Building an empty list \n");
167 ATermList ls = ATmakeList0();
170 ATerm child_term = NULL;
171 if (lazyWrapping ==
true)
173 child_term = ATmake(
"lazyWrap(<str>)",
"lazyWrap");
178 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): Calling convertNodeToAterm() *b = %p = %s\n",*b,(*b != NULL) ? (*b)->class_name().c_str() :
"NULL");
180 child_term = convertNodeToAterm(*b);
184 int atermKind = ATgetType(child_term);
185 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): child_term: atermKind = %d = %s \n",atermKind,aterm_type_name(child_term).c_str());
188 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): DONE: Calling convertNodeToAterm() *b = %p = %s \n",*b,(*b != NULL) ? (*b)->class_name().c_str() :
"NULL");
191 cout <<
"In AtermSupport::convertSgNodeRangeToAterm(): DONE: output child_term: -> " << ATwriteToString(child_term) << endl;
196 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): Calling ATappend() \n");
199 ls = ATappend(ls,child_term);
203 int atermKind = ATgetType(ls);
205 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): ATappend(): atermKind = %d \n",atermKind);
208 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): DONE: Calling ATappend() \n");
213 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): building aterm to return \n");
217 ATerm returnTerm = ATmake(
"<term>", ls);
221 int atermKind = ATgetType(returnTerm);
222 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): atermKind = %d = %s \n",atermKind,aterm_type_name(returnTerm).c_str());
225 printf (
"In AtermSupport::convertSgNodeRangeToAterm(): returnTerm = %p ls = %p \n",returnTerm,ls);
228 cout <<
"AtermSupport::convertSgNodeRangeToAterm(): returning the aterm -> " << ATwriteToString(returnTerm) << endl;
This class represents the concept of a scope in C++ (e.g. global scope, fuction scope, etc.).
This class represents the base class for all types.
This class represents the location of the code associated with the IR node in the original source cod...
This class represents the notion of a declared variable.
Describes (part of) a physical CPU register.
This class represents the base class for all IR nodes within Sage III.
A relative virtual address optionally associated with a SgAsmSection.
virtual std::string class_name() const
returns a string representing the class name
SgNode * get_parent() const
Access function for parent node.
This class represents the concept of a declaration statement.