AST Builder. This class manages the building of an AST, including queries on the existing AST such as name and type lookups. The building functions are called by SWalker as it walks the parse tree.
Public Member functions Summary: | |
constructor | Builder(AST::SourceFile* file) Constructor [Source] |
destructor | ~Builder() Destructor. [Source] |
void | set_swalker(SWalker* swalker) Sets the swalker [Source] |
void | set_access(AST::Access) Changes the current accessability for the current scope [Source] |
AST::SourceFile* | file() Returns the current file [Source] |
void | set_file(AST::SourceFile*) Changes the current file [Source] |
const AST::Declaration::vector& | builtin_decls() Returns the list of builtin decls ("__null_t", "true", etc.) [Source] |
AST::Scope* | scope() Returns the current scope [Source] |
ScopeInfo* | scopeinfo() Returns the current ScopeInfo for the current Scope [Source] |
AST::Scope* | global() Returns the global scope [Source] |
Builder::Lookup* | lookup() Returns the Lookup object for the builder [Source] |
void | add(AST::Declaration* declaration, bool is_template = false) Add the given Declaration to the current scope. [Source] |
void | add(Types::Named* named) Add the given non-declaration type to the current scope [Source] |
void | add_macros(const std::vector<AST::Macro*>&) Adds the given Macros to the global scope. [Source] |
AST::Namespace* | start_namespace(const std::string& name, NamespaceType type) Construct and open a new Namespace. [Source] |
void | end_namespace() End the current namespace and pop the previous Scope off the stack [Source] |
AST::Namespace* | start_template() Starts a new template namespace [Source] |
void | end_template() End the current template namespace [Source] |
AST::Class* | start_class(int, const std::string& type, const std::string& name, AST::Parameter::vector* templ_params) Construct and open a new Class. [Source] |
AST::Class* | start_class(int, const std::string& type, const ScopedName& names) Construct and open a new Class with a qualified name [Source] |
void | update_class_base_search() Update the search to include base classes. [Source] |
void | end_class() End the current class and pop the previous Scope off the stack [Source] |
void | start_function_impl(const ScopedName& name) Start function impl scope [Source] |
void | end_function_impl() End function impl scope [Source] |
AST::Function* | add_function(int, const std::string& name, const std::vector<std::string>& premod, Types::Type* ret, const std::string& realname, AST::Parameter::vector* templ_params) Add an function [Source] |
AST::Variable* | add_variable(int, const std::string& name, Types::Type* vtype, bool constr, const std::string& type) Add a variable [Source] |
void | add_this_variable() Add a variable to represent 'this', iff we are in a method [Source] |
AST::Typedef* | add_typedef(int, const std::string& name, Types::Type* alias, bool constr) Add a typedef [Source] |
AST::Enumerator* | add_enumerator(int, const std::string& name, const std::string& value) Add an enumerator [Source] |
AST::Enum* | add_enum(int, const std::string& name, const AST::Enumerator::vector&) Add an enum [Source] |
AST::Declaration* | add_tail_comment(int line) Add a tail comment. [Source] |
void | add_using_namespace(Types::Named* type) Add a namespace using declaration. [Source] |
void | add_aliased_using_namespace(Types::Named* type, const std::string& alias) Add a namespace alias using declaration. [Source] |
void | add_using_declaration(Types::Named* type) Add a using declaration. [Source] |
bool | mapName(const ScopedName& name, std::vector<AST::Scope*>&, Types::Named*&) Maps a scoped name into a vector of scopes and the final type. [Source] |
Types::Base* | create_base(const std::string& name) Create a Base type for the given name in the current scope [Source] |
Types::Dependent* | create_dependent(const std::string& name) Create a Dependent type for the given name in the current scope [Source] |
Types::Unknown* | create_unknown(const std::string& name) Create an Unknown type for the given name in the current scope [Source] |
Types::Template* | create_template(const std::string& name, const std::vector<Types::Type*>&) Create a Template type for the given name in the current scope [Source] |
Types::Unknown* | add_unknown(const std::string& name) Add an Unknown decl for given name if it doesnt already exist [Source] |
AST::Forward* | add_forward(int lineno, const std::string& name, AST::Parameter::vector* templ_params) Add an Templated Forward decl for given name if it doesnt already exist [Source] |
Private Member functions Summary: | |
ScopeInfo* | find_info(AST::Scope*) Return a ScopeInfo* for the given Declaration. [Source] |
void | add_class_bases(AST::Class* clas, ScopeSearch& search) Utility method to recursively add base classes to given search [Source] |
std::string | dump_search(ScopeInfo* scope) Formats the search of the given Scope for logging [Source] |
void | do_add_using_namespace(ScopeInfo* target, ScopeInfo* scope) Recursively adds 'target' as using in 'scope' [Source] |
Private Data members Summary: | |
AST::SourceFile* | m_file Current file [Source] |
AST::Scope* | m_global The global scope object [Source] |
AST::Scope* | m_scope Current scope object [Source] |
int | m_unique A counter used to generate unique namespace names [Source] |
std::vector<ScopeInfo*> | m_scopes The stack of Builder::Scopes [Source] |
Private* | m Private data which uses map instance [Source] |
SWalker* | m_swalker A pointer to the SWalker. [Source] |
Builder::Lookup* | m_lookup A pointer to the Lookup [Source] |
Classes Summary: | |
EqualScope [Source] |
Structs Summary: | |
Private [Source] |
Public Member function Details: |
Destructor. Recursively destroys all AST objects
Add the given Declaration to the current scope. If is_template is true, then it is added to the parent of the current scope, assuming that the current scope is the temporary template scope
Adds the given Macros to the global scope. This method should only be called once, with the macros stored in order from the preprocessing stage.
Construct and open a new Namespace. The Namespace becomes the current scope, and the old one is pushed onto the stack. If name is empty then a unique name is generated of the form `ns1
Construct and open a new Class. The Class becomes the current scope, and the old one is pushed onto the stack. The type argument is the type, ie: "class" or "struct". This is tested to determine the default accessability. If this is a template class, the templ_params vector must be non-null pointer
Update the search to include base classes. Call this method after startClass(), and after filling in the parents() vector of the returned AST::Class object. After calling this method, name and type lookups will correctly search the base classes of this class.
Add a tail comment. This will be a dummy declaration with an empty name and type "dummy"
Maps a scoped name into a vector of scopes and the final type. Returns true on success.
Private Member function Details: |
Return a ScopeInfo* for the given Declaration. This method first looks for an existing Scope* in the Private map.
Private Data member Details: |
A pointer to the SWalker. This is set explicitly by the SWalker during its constructor (which takes a Builder).