PUMA Library Reference Manual
Puma::CSemantic Class Reference

#include <CSemantic.h>

+ Inheritance diagram for Puma::CSemantic:

Public Member Functions

 CSemantic (CSyntax &, CBuilder &)
 
virtual void init (CSemDatabase &, Unit &)
 Initialize the semantic analysis. More...
 
void configure (Config &)
 Configure the semantic analysis. More...
 
virtual CTreeid_expr ()
 
virtual CTreetypedef_name ()
 
virtual CTreeinit_declarator ()
 
virtual CTreeabst_declarator ()
 
virtual CTreedirect_abst_declarator ()
 
virtual CTreeparam_decl_clause ()
 
virtual CTreefinish_fct_def ()
 
virtual CTreearg_decl_seq ()
 
virtual CTreedecl_spec_seq1 ()
 
virtual CTreedecl_spec_seq_err ()
 
virtual CTreedeclare_parameter ()
 
virtual CTreeidentifier_list ()
 
virtual bool finish_param_check (bool)
 
virtual CTreebegin_decl ()
 
virtual CTreearray_delim ()
 
virtual CTreeenumerator_def ()
 
virtual CTreetrans_unit ()
 
virtual CTreeclass_spec ()
 
virtual CTreecmpd_stmt ()
 
virtual CTreeselect_stmt ()
 
virtual CTreeiter_stmt ()
 
virtual void introduce_label (CTree *&)
 
virtual CTreeintroduce_object (CTree *=0)
 
virtual CTreeintroduce_named_type ()
 
virtual CTreeintroduce_enum ()
 
virtual CTreeintroduce_enumerator ()
 
virtual CTreeintroduce_function ()
 
virtual CTreeintroduce_parameter ()
 
virtual CTreeintroduce_class ()
 
virtual CTreeintroduce_member ()
 
virtual CTreeintroduce_tag ()
 
void enter_arg_decl_seq ()
 
void leave_arg_decl_seq ()
 
void begin_param_check ()
 
bool in_arg_decl_seq () const
 
bool decl_spec_seq ()
 
bool empty_decl_spec_seq ()
 
virtual bool implicit_int ()
 
virtual CProtection::Type protection () const
 
void reenter_class_scope ()
 
void enter_scope (CStructure *scp)
 Enter the given scope. More...
 
void reenter_scope (CStructure *scp)
 Reenter the given scope. More...
 
void leave_scopes ()
 Leave all scopes entered up to the current scope. More...
 
- Public Member Functions inherited from Puma::Semantic
void error_sink (ErrorSink &e)
 Set the error output stream object. More...
 
void undo (CTree *tree)
 Undo the declaration analysis of the given syntax tree node. More...
 
CTreePrivateName ()
 Create a new anonymous (private) name. More...
 
void save_state ()
 Save the current semantic analysis state. More...
 
void forget_state ()
 Discard the saved semantic analysis state. More...
 
void restore_state ()
 Restore the saved semantic analysis state. More...
 
CFileInfogetFile ()
 Get the root node of the semantic tree. More...
 
void enter_local_scope ()
 Enter a local scope. More...
 
virtual void enter_param_decl_clause ()
 Enter a function parameter declaration clause. More...
 
virtual void leave_param_decl_clause ()
 Leave a function parameter declaration clause. More...
 
bool in_param_decl_clause ()
 Check if in the declaration of a function parameter clause. More...
 
void finish_decl ()
 Finish the analysis of the current declaration. More...
 
void finish_declarator ()
 Finish the analysis of the current declarator. More...
 
- Public Member Functions inherited from Puma::PtrStack< CObjectInfo >
 PtrStack (long size=8192, long incr=8192)
 Construct a new layered stack. More...
 
virtual ~PtrStack ()
 Destructor. More...
 
void Push (const CObjectInfo *item)
 Add a new item on the top of the current layer. More...
 
void Pop ()
 Remove the top item from the current layer. More...
 
CObjectInfoTop () const
 Get the top item from the current layer. More...
 
long Length () const
 Get the number of items added to the current layer. More...
 
CObjectInfoGet (long n) const
 Get the n-th item on the current layer. More...
 
void New ()
 Create a new layer. More...
 
void Forget ()
 Remove the top layer and add its items to the underlying layer. More...
 
void Reject ()
 Remove the top layer. More...
 
void Destroy ()
 Remove the top layer and delete its items. More...
 
long Stacks () const
 Get the number of layers. More...
 
void Reset ()
 Remove all layers. More...
 

Protected Types

enum  SemObjType {
  CLASS,
  UNION,
  ENUM,
  TYPEDEF,
  FCT,
  ATTRIB,
  ARG,
  TAG,
  NON_TAG,
  ANY
}
 

Protected Member Functions

void declareImplicitFcts ()
 
virtual CBuilderbuilder () const
 
virtual CSyntaxsyntax () const
 
virtual void Delete ()
 Delete the top item on the semantic stack. More...
 
CObjectInfolookup (const char *, SemObjType, bool=false) const
 
CObjectInfolookup (CT_SimpleName *, SemObjType, bool=false) const
 
CObjectInfolookup (const char *, CStructure *, SemObjType, bool) const
 
CObjectInfolookupBuiltin (const char *name) const
 
CLinkage::Type determine_linkage (CSemDeclSpecs *, SemObjType, CObjectInfo *=(CObjectInfo *) 0) const
 
CStorage::Type determine_storage_class (CSemDeclSpecs *, SemObjType, CLinkage::Type) const
 
bool typeMatch (CTypeInfo *, CTypeInfo *) const
 
CStructurefindParent () const
 
void setSpecifiers (CObjectInfo *, CSemDeclSpecs *) const
 
bool isRedefiningTypedef (CObjectInfo *, int obj_type) const
 
bool isRedefinedFunction (CFunctionInfo *) const
 
CAttributeInfocreateAttribute (const char *, CStructure *, CTypeInfo *, bool=false)
 
CTypedefInfocreateTypedef (const char *, CStructure *, CTypeInfo *)
 
void createParameter (CFunctionInfo *, CTypeInfo *)
 
CFunctionInfocreateFunction (const char *, CStructure *, CTypeInfo *)
 
CTypeInforesolveExpr (CTree *expr, CTree *base) const
 
- Protected Member Functions inherited from Puma::Semantic
 Semantic ()
 Constructor. More...
 
virtual ~Semantic ()
 Destructor. More...
 
void common_settings (CObjectInfo *info, CTree *tree)
 Apply command settings on the given semantic object. More...
 
void common_settings (CObjectInfo *info, CTree *tree, CSemDeclarator *d)
 Apply command settings on the given semantic object. More...
 
void Push (CObjectInfo *info)
 Push the given semantic information object on the semantic stack. More...
 
bool in_decl () const
 Check if currently analysing a declaration. More...
 
void decl_begin (CSemDeclSpecs *ds)
 Begin analysing a declaration. More...
 
void decl_end ()
 Finish analysing a declaration. More...
 
void decl_specs_begin (CT_DeclSpecSeq *dss)
 Begin analysing a declaration specifier sequence. More...
 
void decl_specs_end ()
 Finish analysing a declaration specifier sequence. More...
 
CSemDeclSpecssem_decl_specs () const
 Get the semantic information for the currently analysed declaration specifier sequence. More...
 
CT_DeclSpecSeqdecl_specs () const
 Get the currently analysed declaration specifier sequence. More...
 
- Protected Member Functions inherited from Puma::PtrStack< CObjectInfo >
virtual void Remove ()
 Remove the top item of the current layer. More...
 

Protected Attributes

bool in_arg_decl
 
bool _in_arg_decl_seq
 
bool is_type_name
 
bool support_implicit_int
 
PtrStack< CStructurenon_record_scopes
 
- Protected Attributes inherited from Puma::Semantic
CSemDatabase_db
 Database of all semantic objects of the semantic tree. More...
 
CFileInfo_file
 Top level semantic object representing the file scope. More...
 
ErrorSink_err
 Error output stream. More...
 
long _Anonymous
 Counter for generating anonymous (private) names. More...
 
CEnumInfocurrent_enum
 The current enumeration, if inside the definition of an enumeration. More...
 
CStructurecurrent_fct
 The current function, if inside the definition of a function. More...
 
CStructurecurrent_scope
 The current scope. More...
 
BCStack< CSemDeclSpecs *, 256 > _sem_decl_specs
 Stack for the type analysis of declarations. More...
 
BCStack< CT_DeclSpecSeq *, 256 > _decl_specs
 Stack for collecting declaration specifiers. More...
 
BCStack< bool, 256 > _in_param_decl_clause
 Stack for the state of analysing a function parameter list. More...
 
BCStack< bool, 256 > _in_decl
 Stack for the state of analysing a declaration. More...
 

Member Enumeration Documentation

◆ SemObjType

Enumerator
CLASS 
UNION 
ENUM 
TYPEDEF 
FCT 
ATTRIB 
ARG 
TAG 
NON_TAG 
ANY 

Constructor & Destructor Documentation

◆ CSemantic()

Puma::CSemantic::CSemantic ( CSyntax s,
CBuilder b 
)
inline

Member Function Documentation

◆ abst_declarator()

virtual CTree* Puma::CSemantic::abst_declarator ( )
virtual

◆ arg_decl_seq()

virtual CTree* Puma::CSemantic::arg_decl_seq ( )
virtual

◆ array_delim()

virtual CTree* Puma::CSemantic::array_delim ( )
virtual

◆ begin_decl()

virtual CTree* Puma::CSemantic::begin_decl ( )
virtual

◆ begin_param_check()

void Puma::CSemantic::begin_param_check ( )

◆ builder()

CBuilder & Puma::CSemantic::builder ( ) const
inlineprotectedvirtual

◆ class_spec()

virtual CTree* Puma::CSemantic::class_spec ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ cmpd_stmt()

virtual CTree* Puma::CSemantic::cmpd_stmt ( )
virtual

◆ configure()

void Puma::CSemantic::configure ( Config c)
virtual

Configure the semantic analysis.

Parameters
cThe configuration settings.

Reimplemented from Puma::Semantic.

◆ createAttribute()

CAttributeInfo* Puma::CSemantic::createAttribute ( const char *  ,
CStructure ,
CTypeInfo ,
bool  = false 
)
protected

◆ createFunction()

CFunctionInfo* Puma::CSemantic::createFunction ( const char *  ,
CStructure ,
CTypeInfo  
)
protected

◆ createParameter()

void Puma::CSemantic::createParameter ( CFunctionInfo ,
CTypeInfo  
)
protected

◆ createTypedef()

CTypedefInfo* Puma::CSemantic::createTypedef ( const char *  ,
CStructure ,
CTypeInfo  
)
protected

◆ decl_spec_seq()

bool Puma::CSemantic::decl_spec_seq ( )

◆ decl_spec_seq1()

virtual CTree* Puma::CSemantic::decl_spec_seq1 ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ decl_spec_seq_err()

virtual CTree* Puma::CSemantic::decl_spec_seq_err ( )
virtual

◆ declare_parameter()

virtual CTree* Puma::CSemantic::declare_parameter ( )
virtual

◆ declareImplicitFcts()

void Puma::CSemantic::declareImplicitFcts ( )
inlineprotected

◆ Delete()

virtual void Puma::CSemantic::Delete ( )
protectedvirtual

Delete the top item on the semantic stack.

To be implemented by derived classes.

Reimplemented from Puma::Semantic.

Reimplemented in Puma::CCSemantic.

◆ determine_linkage()

CLinkage::Type Puma::CSemantic::determine_linkage ( CSemDeclSpecs ,
SemObjType  ,
CObjectInfo = (CObjectInfo *) 0 
) const
protected

◆ determine_storage_class()

CStorage::Type Puma::CSemantic::determine_storage_class ( CSemDeclSpecs ,
SemObjType  ,
CLinkage::Type   
) const
protected

◆ direct_abst_declarator()

virtual CTree* Puma::CSemantic::direct_abst_declarator ( )
virtual

◆ empty_decl_spec_seq()

bool Puma::CSemantic::empty_decl_spec_seq ( )

◆ enter_arg_decl_seq()

void Puma::CSemantic::enter_arg_decl_seq ( )
inline

◆ enter_scope()

void Puma::CSemantic::enter_scope ( CStructure scope)
virtual

Enter the given scope.

Sets the parent of the entered scope to the current scope.

Parameters
scopeThe scope to enter.

Reimplemented from Puma::Semantic.

◆ enumerator_def()

virtual CTree* Puma::CSemantic::enumerator_def ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ findParent()

CStructure* Puma::CSemantic::findParent ( ) const
protected

◆ finish_fct_def()

virtual CTree* Puma::CSemantic::finish_fct_def ( )
virtual

◆ finish_param_check()

virtual bool Puma::CSemantic::finish_param_check ( bool  )
virtual

◆ id_expr()

virtual CTree* Puma::CSemantic::id_expr ( )
virtual

◆ identifier_list()

virtual CTree* Puma::CSemantic::identifier_list ( )
virtual

◆ implicit_int()

virtual bool Puma::CSemantic::implicit_int ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ in_arg_decl_seq()

bool Puma::CSemantic::in_arg_decl_seq ( ) const
inline

◆ init()

virtual void Puma::CSemantic::init ( CSemDatabase db,
Unit file 
)
virtual

Initialize the semantic analysis.

Parameters
dbThe semantic object database.
fileThe input file.

Reimplemented from Puma::Semantic.

Reimplemented in Puma::CCSemantic.

◆ init_declarator()

virtual CTree* Puma::CSemantic::init_declarator ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ introduce_class()

virtual CTree* Puma::CSemantic::introduce_class ( )
virtual

◆ introduce_enum()

virtual CTree* Puma::CSemantic::introduce_enum ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ introduce_enumerator()

virtual CTree* Puma::CSemantic::introduce_enumerator ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ introduce_function()

virtual CTree* Puma::CSemantic::introduce_function ( )
virtual

◆ introduce_label()

virtual void Puma::CSemantic::introduce_label ( CTree *&  )
virtual

◆ introduce_member()

virtual CTree* Puma::CSemantic::introduce_member ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ introduce_named_type()

virtual CTree* Puma::CSemantic::introduce_named_type ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ introduce_object()

virtual CTree* Puma::CSemantic::introduce_object ( CTree = 0)
virtual

◆ introduce_parameter()

virtual CTree* Puma::CSemantic::introduce_parameter ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ introduce_tag()

virtual CTree* Puma::CSemantic::introduce_tag ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ isRedefinedFunction()

bool Puma::CSemantic::isRedefinedFunction ( CFunctionInfo ) const
protected

◆ isRedefiningTypedef()

bool Puma::CSemantic::isRedefiningTypedef ( CObjectInfo ,
int  obj_type 
) const
protected

◆ iter_stmt()

virtual CTree* Puma::CSemantic::iter_stmt ( )
virtual

◆ leave_arg_decl_seq()

void Puma::CSemantic::leave_arg_decl_seq ( )
inline

◆ leave_scopes()

void Puma::CSemantic::leave_scopes ( )
virtual

Leave all scopes entered up to the current scope.

Make the parent scope of the current scope to the current scope.

Reimplemented from Puma::Semantic.

◆ lookup() [1/3]

CObjectInfo* Puma::CSemantic::lookup ( const char *  ,
CStructure ,
SemObjType  ,
bool   
) const
protected

◆ lookup() [2/3]

CObjectInfo * Puma::CSemantic::lookup ( const char *  id,
SemObjType  type,
bool  nested = false 
) const
inlineprotected

◆ lookup() [3/3]

CObjectInfo * Puma::CSemantic::lookup ( CT_SimpleName id,
SemObjType  type,
bool  nested = false 
) const
inlineprotected

◆ lookupBuiltin()

CObjectInfo* Puma::CSemantic::lookupBuiltin ( const char *  name) const
protected

◆ param_decl_clause()

virtual CTree* Puma::CSemantic::param_decl_clause ( )
virtual

◆ protection()

CProtection::Type Puma::CSemantic::protection ( ) const
inlinevirtual

Reimplemented in Puma::CCSemantic.

◆ reenter_class_scope()

void Puma::CSemantic::reenter_class_scope ( )

◆ reenter_scope()

void Puma::CSemantic::reenter_scope ( CStructure scope)
virtual

Reenter the given scope.

Does not reset the parent of entered scope.

Parameters
scopeThe scope to reenter.

Reimplemented from Puma::Semantic.

◆ resolveExpr()

CTypeInfo* Puma::CSemantic::resolveExpr ( CTree expr,
CTree base 
) const
protected

◆ select_stmt()

virtual CTree* Puma::CSemantic::select_stmt ( )
virtual

◆ setSpecifiers()

void Puma::CSemantic::setSpecifiers ( CObjectInfo ,
CSemDeclSpecs  
) const
protected

◆ syntax()

CSyntax & Puma::CSemantic::syntax ( ) const
inlineprotectedvirtual

◆ trans_unit()

virtual CTree* Puma::CSemantic::trans_unit ( )
virtual

◆ typedef_name()

virtual CTree* Puma::CSemantic::typedef_name ( )
virtual

Reimplemented in Puma::CCSemantic.

◆ typeMatch()

bool Puma::CSemantic::typeMatch ( CTypeInfo ,
CTypeInfo  
) const
protected

Member Data Documentation

◆ _in_arg_decl_seq

bool Puma::CSemantic::_in_arg_decl_seq
protected

◆ in_arg_decl

bool Puma::CSemantic::in_arg_decl
protected

◆ is_type_name

bool Puma::CSemantic::is_type_name
protected

◆ non_record_scopes

PtrStack<CStructure> Puma::CSemantic::non_record_scopes
protected

◆ support_implicit_int

bool Puma::CSemantic::support_implicit_int
protected