1#ifndef abstract_handle_INCLUDED
2#define abstract_handle_INCLUDED
20#if defined(__APPLE__) && defined(__MACH__)
23#include<linux/limits.h>
83 typedef enum {e_name, e_position, e_numbering, e_int_label, e_str_label}
88 char str_v[PATH_MAX+256];
105 std::string toString();
145 #pragma message ("WARNING: MSVC does not handle covariant return types properly.")
148 virtual void *
getNode()
const {
return NULL;};
158 virtual std::string getFileName()
const;
164 virtual std::string toString()
const;
232 void set_parent_handle(abstract_handle* parent){ parent_handle= parent;}
237 {
return m_node == x.getNode();}
257 extern std::map<abstract_node*, abstract_handle*>
handle_map;
to specify a construct using a specifier Can be used alone or with parent handles when relative speci...
abstract_handle(abstract_handle *phandle, const std::string &handle_string)
construct a handle from a handle string within the scope of an existing handle e.g: <SourceFile<name,...
virtual std::string get_construct_type_name()
the language construct type name
abstract_handle(abstract_node *node)
Create a handle from a node, using the source position as the specifier by default Or use name if sou...
abstract_handle(abstract_node *node, specifier_type_t stype, abstract_handle *p_handle=NULL)
Create a handle using specified type, automatically fill out the corresponding value Most useful to c...
virtual std::string toString()
Output the handle to a string, including all parent handles.
abstract_handle(abstract_node *node, specifier_type_t stype, specifier_value_t svalue, abstract_handle *p_handle=NULL)
Create a handle from an optional parent handle, with explicit type and numbering information availabl...
virtual void fromStringSelf(abstract_handle *p_handle, const std::string &handle_str_item)
Instantiate a handle using a handle element's string (a single handle only),the handle refers to a no...
virtual std::string toStringSelf()
Only output the handle itself to a string, excluding parent handles.
virtual bool fromString(abstract_handle *ancester_handle, const std::string &handle_str_multiple)
Initialize a handle from a handle string, generate full parent handles when necessary.
specifier * get_specifier()
allow multiple specifiers or not?
abstract_handle()
Constructors.
Users should provide a concrete node implementation especially a constructor/builder to avoid duplica...
virtual bool hasName() const
If the node has legal names defined by language standards.
virtual void * getNode() const
Get the raw IR node associated with the current abstract node.
virtual abstract_node * findNode(std::string construct_type_str, specifier mspecifier) const
Find a node of a given type, it also matches the specifier.
virtual std::string getStringLabel() const
Get string label.
virtual abstract_node * getFileNode() const
Get the start source file position of the construct Get the abstract node for file containing the cur...
virtual abstract_node * findNode(std::string handle_str) const
Find a node from a string for a abstract handle's string format, starting from this node eg.
virtual size_t getNumbering(const abstract_node *another_node) const
Get the ordering of the construct relative to another construct in a higher scope Numbering start fro...
virtual bool hasSourcePos() const
If the node has meaningful line and column numbers associated with a file.
virtual size_t getIntLabel() const
Get integer label.
virtual std::string getName() const
Get the name of the construct if it is named, like function name.
virtual abstract_node * getParent() const
Get parent node, used for generate parent handle automatically.
virtual std::string getConstructTypeName() const
Get the construct' s type name, like function.
construct specifier could be used to specify a construct by name, position, numbering,...
String annotations to uniquely indicate any source constructs.
specifier_type_t
specifier type and values
std::map< abstract_node *, abstract_handle * > handle_map
maintain a map between nodes and handles, used for fast indexing and avoid redundant creation of hand...
void fromString(source_position &, const std::string &input)
Parse a string (such as 12.10, 13, 0 etc )into source position data structure.
source position information: