Modules | Files | Inheritance Tree | Inheritance Graph | Name Index | Config
package Synopsis::Parser::C++
class SWalker
Files: Synopsis/Parser/C++/syn/swalker.hh
SWalker-inheritance Scopes/Synopsis/Parser/C++/Walker.html Scopes/Synopsis/Parser/C++.html#LightObject

A walker that creates an AST. All Translate* methods have been overridden to remove the translation code.


Public Member functions Summary:
 constructorSWalker(FileFilter*, Parser*, Builder*, Program*)
Constructor [Source]
virtual destructor~SWalker() [Source]
 voidset_extract_tails(bool value)
Sets extract tails to true. [Source]
 voidset_store_links(LinkStore*)
Sets store links to true. [Source]
 std::stringparse_name(Ptree*)
Get a name from the ptree [Source]
 Parser*parser()
Get the Parser object [Source]
 Program*program()
Get the Program object [Source]
 Builder*builder()
Get the Builder object [Source]
 TypeFormatter*type_formatter()
Get the TypeFormatter object [Source]
 intline_of_ptree(Ptree*)
Get the line number of the given Ptree node [Source]
 voidupdate_line_number(Ptree*)
Update the line number [Source]
 voidadd_comments(AST::Declaration* decl, Ptree* comments) [Source]
 voidadd_comments(AST::Declaration* decl, CommentedLeaf* node) [Source]
 voidadd_comments(AST::Declaration* decl, PtreeDeclarator* node) [Source]
 voidadd_comments(AST::Declaration* decl, PtreeDeclaration* decl) [Source]
 voidadd_comments(AST::Declaration* decl, PtreeNamespaceSpec* decl) [Source]
 voidfind_comments(Ptree* node)
Traverses left side of tree till it finds a leaf, and if that is a CommentedLeaf then it adds those comments as spans [Source]
 voidTranslateFunctionArgs(Ptree* args) [Source]
 voidTranslateParameters(Ptree* p_params, std::vector<AST::Parameter*>& params) [Source]
 voidTranslateFunctionName(char* encname, std::string& realname, Types::Type*& returnType) [Source]
 Ptree*TranslateDeclarator(Ptree*) [Source]
 Ptree*TranslateFunctionDeclarator(Ptree*, bool is_const) [Source]
 Ptree*TranslateVariableDeclarator(Ptree*, bool is_const) [Source]
 voidTranslateTypedefDeclarator(Ptree* node) [Source]
std::vector<AST::Inheritance*>TranslateInheritanceSpec(Ptree* node) [Source]
 std::stringformat_parameters(std::vector<AST::Parameter*>& params)
Returns a formatter string of the parameters. [Source]
virtual Ptree*TranslatePtree(Ptree*) [Source]
 voidTranslate(Ptree*)
Overridden to catch exceptions [Source]
virtual Ptree*TranslateTypedef(Ptree*) [Source]
virtual Ptree*TranslateTemplateDecl(Ptree*) [Source]
virtual Ptree*TranslateTemplateInstantiation(Ptree*) [Source]
virtual Ptree*TranslateExternTemplate(Ptree*) [Source]
virtual Ptree*TranslateTemplateClass(Ptree*, Ptree*) [Source]
virtual Ptree*TranslateTemplateFunction(Ptree*, Ptree*) [Source]
virtual Ptree*TranslateMetaclassDecl(Ptree*) [Source]
virtual Ptree*TranslateLinkageSpec(Ptree*) [Source]
virtual Ptree*TranslateNamespaceSpec(Ptree*) [Source]
virtual Ptree*TranslateUsing(Ptree*) [Source]
virtual Ptree*TranslateDeclaration(Ptree*) [Source]
virtual Ptree*TranslateStorageSpecifiers(Ptree*) [Source]
virtual Ptree*TranslateDeclarators(Ptree*) [Source]
virtual Ptree*TranslateArgDeclList(bool, Ptree*, Ptree*) [Source]
virtual Ptree*TranslateInitializeArgs(PtreeDeclarator*, Ptree*) [Source]
virtual Ptree*TranslateAssignInitializer(PtreeDeclarator*, Ptree*) [Source]
virtual Ptree*TranslateFunctionImplementation(Ptree*) [Source]
virtual Ptree*TranslateFunctionBody(Ptree*) [Source]
virtual Ptree*TranslateBrace(Ptree*) [Source]
virtual Ptree*TranslateBlock(Ptree*) [Source]
virtual Ptree*TranslateClassSpec(Ptree*) [Source]
virtual Ptree*TranslateEnumSpec(Ptree*) [Source]
virtual Ptree*TranslateAccessSpec(Ptree*) [Source]
virtual Ptree*TranslateAccessDecl(Ptree*) [Source]
virtual Ptree*TranslateUserAccessSpec(Ptree*) [Source]
virtual Ptree*TranslateIf(Ptree*) [Source]
virtual Ptree*TranslateSwitch(Ptree*) [Source]
virtual Ptree*TranslateWhile(Ptree*) [Source]
virtual Ptree*TranslateDo(Ptree*) [Source]
virtual Ptree*TranslateFor(Ptree*) [Source]
virtual Ptree*TranslateTry(Ptree*) [Source]
virtual Ptree*TranslateBreak(Ptree*) [Source]
virtual Ptree*TranslateContinue(Ptree*) [Source]
virtual Ptree*TranslateReturn(Ptree*) [Source]
virtual Ptree*TranslateGoto(Ptree*) [Source]
virtual Ptree*TranslateCase(Ptree*) [Source]
virtual Ptree*TranslateDefault(Ptree*) [Source]
virtual Ptree*TranslateLabel(Ptree*) [Source]
virtual Ptree*TranslateExprStatement(Ptree*) [Source]
virtual Ptree*TranslateTypespecifier(Ptree*) [Source]
virtual Ptree*TranslateTypeof(Ptree*, Ptree* declarations) [Source]
virtual Ptree*TranslateComma(Ptree*) [Source]
virtual Ptree*TranslateAssign(Ptree*) [Source]
virtual Ptree*TranslateCond(Ptree*) [Source]
virtual Ptree*TranslateInfix(Ptree*) [Source]
virtual Ptree*TranslatePm(Ptree*) [Source]
virtual Ptree*TranslateCast(Ptree*) [Source]
virtual Ptree*TranslateUnary(Ptree*) [Source]
virtual Ptree*TranslateThrow(Ptree*) [Source]
virtual Ptree*TranslateSizeof(Ptree*) [Source]
virtual Ptree*TranslateNew(Ptree*) [Source]
virtual Ptree*TranslateNew3(Ptree* type) [Source]
virtual Ptree*TranslateDelete(Ptree*) [Source]
virtual Ptree*TranslateThis(Ptree*) [Source]
virtual Ptree*TranslateVariable(Ptree*) [Source]
virtual Ptree*TranslateFstyleCast(Ptree*) [Source]
virtual Ptree*TranslateArray(Ptree*) [Source]
virtual Ptree*TranslateFuncall(Ptree*) [Source]
virtual Ptree*TranslatePostfix(Ptree*) [Source]
virtual Ptree*TranslateUserStatement(Ptree*) [Source]
virtual Ptree*TranslateDotMember(Ptree*) [Source]
virtual Ptree*TranslateArrowMember(Ptree*) [Source]
virtual Ptree*TranslateParen(Ptree*) [Source]
virtual Ptree*TranslateStaticUserStatement(Ptree*) [Source]
 AST::SourceFile*current_file() [Source]
 intcurrent_lineno() [Source]
static SWalker*instance() [Source]

Private Typedefs Summary:
std::vector<FuncImplCache>FuncImplVec
A vector of function impls [Source]
std::vector<FuncImplVec>FuncImplStack
A stack of function impl vectors [Source]

Private Structs Summary:
FuncImplCache
Info about one stored function impl. [Source]

Private Enums Summary:
Postfix_FlagPostfix_Var, Postfix_Func
The state of postfix translation. [Source]

Private Member functions Summary:
 intfind_col(const char* start, const char* find)
Finds the column given the start ptr and the current position. [Source]

Private Data members Summary:
SWalker*g_swalker [Source]
Parser*m_parser [Source]
Builder*m_builder [Source]
FileFilter*m_filter [Source]
Program*m_program [Source]
Decoder*m_decoder [Source]
Lookup*m_lookup [Source]
Ptree*m_declaration
A pointer to the currect declaration ptree, if any, used to get the return type and modifiers, etc. [Source]
std::vector<AST::Parameter*>*m_template
A pointer to the current template parameters, if any, used to get the template parameters and set in the declaration. [Source]
char*m_filename_ptr
This pointer is used as a comparison to avoid redundant effort. [Source]
AST::SourceFile*m_file
The current file, set by update_line_number [Source]
intm_lineno [Source]
boolm_extract_tails
True if should try and extract tail comments before }'s [Source]
LinkStore*m_links
Storage for links. [Source]
boolm_store_decl
True if this TranslateDeclarator should try to store the decl type [Source]
std::vector<std::string>m_dummyname
A dummy name used for tail comments [Source]
TypeFormatter*m_type_formatter
An instance of TypeFormatter for formatting types [Source]
AST::Function*m_function
The current function, if in a function block [Source]
std::vector<AST::Parameter*>m_param_cache
The params found before a function block. [Source]
std::vector<Types::Type*>m_params
The types accumulated for function parameters in function calls [Source]
Types::Type*m_type
The type returned from the expression-type translators [Source]
AST::Scope*m_scope
The Scope to use for name lookups, or NULL to use enclosing default scope rules. [Source]
Postfix_Flagm_postfix_flag
foo->var versus var or foo->var(). [Source]
FuncImplStackm_func_impl_stack
The stack of function impl vectors [Source]

Public Structs Inherited from Walker
NameScope

Public Member functions Inherited from Walker
Typeof, IsClassWalker, TypeofPtree, MakeTemplateInstantiationMetaobject, MakeTemplateClassMetaobject, GetArgDeclList, TranslateArgDeclList2, FillArgumentName, RecordArgsAndTranslateFbody, TranslateClassBody, MakeClassMetaobject, TranslateTypeid, TranslateNew2, TypeofComma, TypeofAssign, TypeofCond, TypeofInfix, TypeofPm, TypeofCast, TypeofUnary, TypeofThrow, TypeofSizeof, TypeofTypeid, TypeofTypeof, TypeofNew, TypeofDelete, TypeofThis, TypeofVariable, TypeofFstyleCast, TypeofArray, TypeofFuncall, TypeofPostfix, TypeofUserStatement, TypeofDotMember, TypeofArrowMember, TypeofParen, TypeofStaticUserStatement, NewScope, NewScope, ExitScope, RecordBaseclassEnv, ChangeScope, RestoreScope, TranslateNewDeclarator, TranslateNewDeclarator2, TranslateArguments, GetClassOrEnumSpec, GetClassTemplateSpec, StripCvFromIntegralType, SetDeclaratorComments, FindLeftLeaf, SetLeafComments, NthDeclarator, FindDeclarator, MatchedDeclarator, WhichDeclarator, ErrorMessage, WarningMessage, InaccurateErrorMessage, InaccurateWarningMessage, ChangeDefaultMetaclass, GetParser

Public Data members Inherited from Walker
argument_name

Protected Member functions Inherited from Walker
LookupMetaclass

Protected Data members Inherited from Walker
env

Public Member function Details:
 void set_extract_tails(bool value)

Sets extract tails to true. This will cause the parser to create dummy declarations for comments before close braces or the end of the file


 void set_store_links(LinkStore*)

Sets store links to true. This will cause the whole ptree to be traversed, and any linkable identifiers found will be stored


 std::string format_parameters(std::vector<AST::Parameter*>& params)

Returns a formatter string of the parameters. The idea is that this string will be appended to the function name to form the 'name' of the function.


Private Enum Details:
enum Postfix_Flag
Postfix_Var
Postfix_Func

< Lookup as a variable

The state of postfix translation. This is needed for constructs like foo->var versus var or foo->var(). The function call resolution needs to be done in the final TranslateVariable, since that's where the last name (which is to be linked) is handled.


Private Member function Details:
 int find_col(const char* start, const char* find)

Finds the column given the start ptr and the current position. The derived column number is processed with the link_map before returning, so -1 may be returned to indicate "inside macro".


Private Data member Details:
std::vector<AST::Parameter*>* m_template

A pointer to the current template parameters, if any, used to get the template parameters and set in the declaration. Should be NULL if not in a template.


char* m_filename_ptr

This pointer is used as a comparison to avoid redundant effort. Do not use it to get the filename, since the string is a reference to the preprocessed file in memory and is *not* null terminated!


LinkStore* m_links

Storage for links. This is only set if we should be storing links, so it must be checked before every use


std::vector<AST::Parameter*> m_param_cache

The params found before a function block. These may be different from the ones that are in the original declaration(s), but it is these names we need for referencing names inside the block, so a reference is stored here.


AST::Scope* m_scope

The Scope to use for name lookups, or NULL to use enclosing default scope rules. This is for when we are at a Variable, and already know it must be part of a given class (eg, foo->bar .. bar must be in foo's class)


Postfix_Flag m_postfix_flag

foo->var versus var or foo->var(). The function call resolution needs to be done in the final TranslateVariable, since that's where the last name (which is to be linked) is handled.