PUMA Library Reference Manual
Loading...
Searching...
No Matches
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.
void configure (Config &)
 Configure the semantic analysis.
virtual CTree * id_expr ()
virtual CTree * typedef_name ()
virtual CTree * init_declarator ()
virtual CTree * abst_declarator ()
virtual CTree * direct_abst_declarator ()
virtual CTree * param_decl_clause ()
virtual CTree * finish_fct_def ()
virtual CTree * arg_decl_seq ()
virtual CTree * decl_spec_seq1 ()
virtual CTree * decl_spec_seq_err ()
virtual CTree * declare_parameter ()
virtual CTree * identifier_list ()
virtual bool finish_param_check (bool)
virtual CTree * begin_decl ()
virtual CTree * array_delim ()
virtual CTree * enumerator_def ()
virtual CTree * trans_unit ()
virtual CTree * class_spec ()
virtual CTree * cmpd_stmt ()
virtual CTree * select_stmt ()
virtual CTree * iter_stmt ()
virtual void introduce_label (CTree *&)
virtual CTree * introduce_object (CTree *=0)
virtual CTree * introduce_named_type ()
virtual CTree * introduce_enum ()
virtual CTree * introduce_enumerator ()
virtual CTree * introduce_function ()
virtual CTree * introduce_parameter ()
virtual CTree * introduce_class ()
virtual CTree * introduce_member ()
virtual CTree * introduce_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.
void reenter_scope (CStructure *scp)
 Reenter the given scope.
void leave_scopes ()
 Leave all scopes entered up to the current scope.
Public Member Functions inherited from Puma::Semantic
void error_sink (ErrorSink &e)
 Set the error output stream object.
void undo (CTree *tree)
 Undo the declaration analysis of the given syntax tree node.
CTree * PrivateName ()
 Create a new anonymous (private) name.
void save_state ()
 Save the current semantic analysis state.
void forget_state ()
 Discard the saved semantic analysis state.
void restore_state ()
 Restore the saved semantic analysis state.
CFileInfo * getFile ()
 Get the root node of the semantic tree.
void enter_local_scope ()
 Enter a local scope.
virtual void enter_param_decl_clause ()
 Enter a function parameter declaration clause.
virtual void leave_param_decl_clause ()
 Leave a function parameter declaration clause.
bool in_param_decl_clause ()
 Check if in the declaration of a function parameter clause.
void finish_decl ()
 Finish the analysis of the current declaration.
void finish_declarator ()
 Finish the analysis of the current declarator.
Public Member Functions inherited from Puma::PtrStack< CObjectInfo >
 PtrStack (long size=8192, long incr=8192)
 Construct a new layered stack.
virtual ~PtrStack ()
 Destructor.
void Push (const CObjectInfo *item)
 Add a new item on the top of the current layer.
void Pop ()
 Remove the top item from the current layer.
CObjectInfo * Top () const
 Get the top item from the current layer.
long Length () const
 Get the number of items added to the current layer.
CObjectInfo * Get (long n) const
 Get the n-th item on the current layer.
void New ()
 Create a new layer.
void Forget ()
 Remove the top layer and add its items to the underlying layer.
void Reject ()
 Remove the top layer.
void Destroy ()
 Remove the top layer and delete its items.
long Stacks () const
 Get the number of layers.
void Reset ()
 Remove all layers.

Protected Types

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

Protected Member Functions

void declareImplicitFcts ()
virtual CBuilder & builder () const
virtual CSyntax & syntax () const
virtual void Delete ()
 Delete the top item on the semantic stack.
CObjectInfo * lookup (const char *, SemObjType, bool=false) const
CObjectInfo * lookup (CT_SimpleName *, SemObjType, bool=false) const
CObjectInfo * lookup (const char *, CStructure *, SemObjType, bool) const
CObjectInfo * lookupBuiltin (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
CStructure * findParent () const
void setSpecifiers (CObjectInfo *, CSemDeclSpecs *) const
bool isRedefiningTypedef (CObjectInfo *, int obj_type) const
bool isRedefinedFunction (CFunctionInfo *) const
CAttributeInfo * createAttribute (const char *, CStructure *, CTypeInfo *, bool=false)
CTypedefInfo * createTypedef (const char *, CStructure *, CTypeInfo *)
void createParameter (CFunctionInfo *, CTypeInfo *)
CFunctionInfo * createFunction (const char *, CStructure *, CTypeInfo *)
CTypeInfo * resolveExpr (CTree *expr, CTree *base) const
Protected Member Functions inherited from Puma::Semantic
 Semantic ()
 Constructor.
virtual ~Semantic ()
 Destructor.
void common_settings (CObjectInfo *info, CTree *tree)
 Apply command settings on the given semantic object.
void common_settings (CObjectInfo *info, CTree *tree, CSemDeclarator *d)
 Apply command settings on the given semantic object.
void Push (CObjectInfo *info)
 Push the given semantic information object on the semantic stack.
bool in_decl () const
 Check if currently analysing a declaration.
void decl_begin (CSemDeclSpecs *ds)
 Begin analysing a declaration.
void decl_end ()
 Finish analysing a declaration.
void decl_specs_begin (CT_DeclSpecSeq *dss)
 Begin analysing a declaration specifier sequence.
void decl_specs_end ()
 Finish analysing a declaration specifier sequence.
CSemDeclSpecs * sem_decl_specs () const
 Get the semantic information for the currently analysed declaration specifier sequence.
CT_DeclSpecSeq * decl_specs () const
 Get the currently analysed declaration specifier sequence.
virtual void Remove ()
 Remove the top item of the current layer.

Protected Attributes

bool in_arg_decl
bool _in_arg_decl_seq
bool is_type_name
bool support_implicit_int
PtrStack< CStructure > non_record_scopes
Protected Attributes inherited from Puma::Semantic
CSemDatabase * _db
 Database of all semantic objects of the semantic tree.
CFileInfo * _file
 Top level semantic object representing the file scope.
ErrorSink * _err
 Error output stream.
long _Anonymous
 Counter for generating anonymous (private) names.
CEnumInfo * current_enum
 The current enumeration, if inside the definition of an enumeration.
CStructure * current_fct
 The current function, if inside the definition of a function.
CStructure * current_scope
 The current scope.
BCStack< CSemDeclSpecs *, 256 > _sem_decl_specs
 Stack for the type analysis of declarations.
BCStack< CT_DeclSpecSeq *, 256 > _decl_specs
 Stack for collecting declaration specifiers.
BCStack< bool, 256 > _in_param_decl_clause
 Stack for the state of analysing a function parameter list.
BCStack< bool, 256 > _in_decl
 Stack for the state of analysing a declaration.

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