cfront::CAnalyzer Class Reference

#include <CAnalyzer.hpp>

Collaboration diagram for cfront::CAnalyzer:

Collaboration graph
[legend]

Public Member Functions

void initialize ()
void setASTFactory (antlr::ASTFactory *astFactory)
void setSupportVectorExtension (bool b)
bool isSupportedVectorExt ()
bool isTypedefName (const std::string &name)
const TypegetOriginalType (const Type *t, bool withFuncArrPointerConv)
std::string getDeclaratorName (const antlr::RefAST declNode) const
EnvironmentgetCurrentEnv () const
void addEnv ()
EnvironmentremoveEnv ()
void setCurrentFunctionType (FunctionType *ft)
FunctionTypegetCurrentFunctionType () const
TypebuildPointerDeclaratorType (std::list< PointerType * > &pointerTypes, Type **&lastPointerType, Type *baseType)
TypebuildDeclaratorPostfixType (std::list< Type * > &types, Type **&lastType, Type *baseType)
TypebuildCompositeDeclaratorType (Type *innerLastType, Type *innerDeclType, Type *baseType)
void addQualifier (Type *t, QualFlags qflags)
bool addNameAndType (const std::string &name, Type *t, NameDescription::StorageClassSpecTag ssTag, NameDescription::DeclarationLocation dloc, Attributes *attrs)
void makeBasicType (Type **t, BasicType::PrimitiveTag primTypeTag)
bool isGccBuiltinName (const std::string &name) const
ExtensionparseGccAttribute (const std::string &name, RefNode paramNode, RefNode locationNode)
void setVariableAttribute (NameDescription *nd, Attributes &attrs)
TypesetTypeAttribute (Type *t, Attributes &attrs, RefNode locationNode)
FieldInclusionTypecheckStructOrUnionDefinition (const std::string &name, bool isStruct, bool isDefinition, RefNode locationNode)
void initializeTypes ()
std::string generateName ()
void parseCharConst (RefNode cNode)
void parseStringConstant (RefNode sNode, std::stringstream &ss, bool *isWide)
void parseIntegerConstant (RefNode intNode, int base)
bool isConstantZeroValue (RefNode constExprNode)
RefNode makeImplicitCastNode (RefNode expr, const Type *castTo, const Type *rand)
const TypegetInitializerListElemType (const Type *listType, int elemIndex, RefNode locationNode)
void checkArrayInitializer (Type *t, int numElems, RefNode locationNode)
const TypecheckPointerArithmeticAdditive (const Type *pt, const Type *it)
const TypecheckPointerSubtraction (const Type *lt, const Type *rt)
const TypecheckBinaryArithmetic (const Type *lt, const Type *rt, RefNode locationNode)
const TypetypeCastExpr (RefNode ec, RefNode es)
AssignmentErrorTag checkAssignment (const Type *lt, RefNode rn)
RefNode typeAssignmentExpr (RefNode en)
RefNode typeComparisonExpr (RefNode en)
const TypeconvertUnaryExprType (const Type *t)
RefNode typeUnaryExpr (RefNode e)
BasicType::PrimitiveTag getArithmeticTypeTag (const Type *t)
BasicType::PrimitiveTag typeBinaryExpr (const Type *type1, const Type *type2)
RefNode typeFunctionArguments (ParameterTypes::const_iterator &i, ParameterTypes::const_iterator &end, RefNode argNode, bool hasVararg, RefNode locationNode)
RefNode typeUnknownTypeFunctionArguments (RefNode argNode, RefNode locationNode)
RefNode typeFunctionArgument (RefNode argNode, const Type *paramType, RefNode locationNode)
const TypecheckCondOperands (RefNode e1, RefNode e2)
RefNode typeExpr (RefNode en)
eint evalConstExpr (antlr::RefAST en) throw (EvalFailedException)
void setLogs (Logs *logs)
void setTargetInfo (TargetInfo *info)

Static Public Member Functions

static eint parseNumber (std::string::const_iterator &i, int base)
static eint parseEscape (std::string::const_iterator &i)
static void parseDoubleQuotedString (std::string::const_iterator &i, std::stringstream &ss)

Protected Attributes

EnvironmentcurrentEnv_
FunctionTypecurrentFunctionType_
bool supportVectorExt_
Logslogs_
TargetInfotargetInfo_
antlr::ASTFactory * astFactory_

Static Protected Attributes

static const char *const gccBuiltinNames []

Private Attributes

unsigned int nameCount_

Detailed Description

Semantic Analyzer of C.

Definition at line 104 of file CAnalyzer.hpp.


Member Function Documentation

void cfront::CAnalyzer::initialize (  )  [inline]

Definition at line 106 of file CAnalyzer.hpp.

References currentEnv_, currentFunctionType_, nameCount_, and supportVectorExt_.

Referenced by ctrump_parse(), and parseString().

void cfront::CAnalyzer::setASTFactory ( antlr::ASTFactory *  astFactory  )  [inline]

Definition at line 115 of file CAnalyzer.hpp.

References astFactory_.

Referenced by ctrump_parse(), and parseString().

void cfront::CAnalyzer::setSupportVectorExtension ( bool  b  )  [inline]

Definition at line 120 of file CAnalyzer.hpp.

References supportVectorExt_.

Referenced by ctrump_parse().

bool cfront::CAnalyzer::isSupportedVectorExt (  )  [inline]

Definition at line 125 of file CAnalyzer.hpp.

References supportVectorExt_.

bool cfront::CAnalyzer::isTypedefName ( const std::string &  name  )  [inline]

const Type* cfront::CAnalyzer::getOriginalType ( const Type t,
bool  withFuncArrPointerConv 
) [inline]

std::string cfront::CAnalyzer::getDeclaratorName ( const antlr::RefAST  declNode  )  const [inline]

Definition at line 180 of file CAnalyzer.hpp.

Environment* cfront::CAnalyzer::getCurrentEnv (  )  const [inline]

Definition at line 185 of file CAnalyzer.hpp.

References currentEnv_.

void cfront::CAnalyzer::addEnv (  )  [inline]

Create the new Environment and set it to currentEnv_

Definition at line 193 of file CAnalyzer.hpp.

References currentEnv_.

Environment* cfront::CAnalyzer::removeEnv (  )  [inline]

Remove the current Environment and set to the outer one.

Returns:
Removed Environment.

Definition at line 202 of file CAnalyzer.hpp.

References currentEnv_, and cfront::Environment::getOuterEnv().

void cfront::CAnalyzer::setCurrentFunctionType ( FunctionType ft  )  [inline]

Definition at line 210 of file CAnalyzer.hpp.

References currentFunctionType_.

FunctionType* cfront::CAnalyzer::getCurrentFunctionType (  )  const [inline]

Definition at line 215 of file CAnalyzer.hpp.

References currentFunctionType_.

Type* cfront::CAnalyzer::buildPointerDeclaratorType ( std::list< PointerType * > &  pointerTypes,
Type **&  lastPointerType,
Type baseType 
) [inline]

Combine the PointeType::baseType in pointerTypes in series.

Parameters:
[in] pointerTypes 
[out] lastPointerType If not NULL, set the last PointerType in the pointerTypes.
[in] baseType The type to set as baseType of the last type in the pointerTypes.
Returns:
The first PointerType in the pointerTypes.
See also:
CParser::declarator

Definition at line 231 of file CAnalyzer.hpp.

References cfront::PointerType::setBaseType().

Type* cfront::CAnalyzer::buildDeclaratorPostfixType ( std::list< Type * > &  types,
Type **&  lastType,
Type baseType 
) [inline]

Parameters:
[in] types The sequence of the FunctionType or ArrayType. If the first element is a FunctionType, the length of the sequence must be 1.
[out] lastType 
[in] baseType 

Definition at line 258 of file CAnalyzer.hpp.

References cfront::ArrayType::setBaseType(), and cfront::FunctionType::setReturnType().

Type* cfront::CAnalyzer::buildCompositeDeclaratorType ( Type innerLastType,
Type innerDeclType,
Type baseType 
) [inline]

void cfront::CAnalyzer::addQualifier ( Type t,
QualFlags  qflags 
) [inline]

Merge qflags and the t's one and set to t.

Definition at line 311 of file CAnalyzer.hpp.

References MERGE_QFS.

Referenced by getOriginalType().

bool cfront::CAnalyzer::addNameAndType ( const std::string &  name,
Type t,
NameDescription::StorageClassSpecTag  ssTag,
NameDescription::DeclarationLocation  dloc,
Attributes attrs 
) [inline]

void cfront::CAnalyzer::makeBasicType ( Type **  t,
BasicType::PrimitiveTag  primTypeTag 
) [inline]

Definition at line 378 of file CAnalyzer.hpp.

bool cfront::CAnalyzer::isGccBuiltinName ( const std::string &  name  )  const

Extension* cfront::CAnalyzer::parseGccAttribute ( const std::string &  name,
RefNode  paramNode,
RefNode  locationNode 
) [inline]

void cfront::CAnalyzer::setVariableAttribute ( NameDescription nd,
Attributes attrs 
) [inline]

Type* cfront::CAnalyzer::setTypeAttribute ( Type t,
Attributes attrs,
RefNode  locationNode 
) [inline]

FieldInclusionType* cfront::CAnalyzer::checkStructOrUnionDefinition ( const std::string &  name,
bool  isStruct,
bool  isDefinition,
RefNode  locationNode 
) [inline]

void cfront::CAnalyzer::initializeTypes (  ) 

std::string cfront::CAnalyzer::generateName (  )  [inline]

This member function is used for name the unnamed struct/union/enum.

Definition at line 543 of file CAnalyzer.hpp.

References nameCount_.

static eint cfront::CAnalyzer::parseNumber ( std::string::const_iterator &  i,
int  base 
) [inline, static]

Parse the number string and return the value.

Definition at line 553 of file CAnalyzer.hpp.

Referenced by parseEscape().

static eint cfront::CAnalyzer::parseEscape ( std::string::const_iterator &  i  )  [inline, static]

Definition at line 568 of file CAnalyzer.hpp.

References parseNumber().

Referenced by parseCharConst(), and parseDoubleQuotedString().

void cfront::CAnalyzer::parseCharConst ( RefNode  cNode  )  [inline]

Definition at line 600 of file CAnalyzer.hpp.

References parseEscape(), and cfront::BasicType::SINT.

static void cfront::CAnalyzer::parseDoubleQuotedString ( std::string::const_iterator &  i,
std::stringstream &  ss 
) [inline, static]

Definition at line 616 of file CAnalyzer.hpp.

References parseEscape().

Referenced by parseStringConstant().

void cfront::CAnalyzer::parseStringConstant ( RefNode  sNode,
std::stringstream &  ss,
bool *  isWide 
) [inline]

Definition at line 633 of file CAnalyzer.hpp.

References parseDoubleQuotedString().

void cfront::CAnalyzer::parseIntegerConstant ( RefNode  intNode,
int  base 
) [inline]

bool cfront::CAnalyzer::isConstantZeroValue ( RefNode  constExprNode  )  [inline]

RefNode cfront::CAnalyzer::makeImplicitCastNode ( RefNode  expr,
const Type castTo,
const Type rand 
) [inline]

Make the implicit cast node if necessary.

Implicit cast node is an imaginary node, used for holding the type that occurred by implicit type conversion.

Definition at line 787 of file CAnalyzer.hpp.

References astFactory_, and cfront::Type::isCompatibleType().

Referenced by typeAssignmentExpr(), typeComparisonExpr(), typeExpr(), typeFunctionArgument(), and typeUnaryExpr().

const Type* cfront::CAnalyzer::getInitializerListElemType ( const Type listType,
int  elemIndex,
RefNode  locationNode 
) [inline]

void cfront::CAnalyzer::checkArrayInitializer ( Type t,
int  numElems,
RefNode  locationNode 
) [inline]

const Type* cfront::CAnalyzer::checkPointerArithmeticAdditive ( const Type pt,
const Type it 
) [inline]

Check type pt is a pointer and type it is an integer at the binary +/- or subscripting. return the base type of pt if applicable, or NULL if invalid.

Definition at line 870 of file CAnalyzer.hpp.

References cfront::PointerType::getBaseType(), and cfront::Type::isIntegerType().

Referenced by typeExpr().

const Type* cfront::CAnalyzer::checkPointerSubtraction ( const Type lt,
const Type rt 
) [inline]

Definition at line 879 of file CAnalyzer.hpp.

References cfront::PointerType::isCompatibleType(), and cfront::BasicType::SLONG.

Referenced by typeExpr().

const Type* cfront::CAnalyzer::checkBinaryArithmetic ( const Type lt,
const Type rt,
RefNode  locationNode 
) [inline]

Definition at line 890 of file CAnalyzer.hpp.

References ERROR1, logs_, cfront::BasicType::NONE, and typeBinaryExpr().

Referenced by typeExpr().

const Type* cfront::CAnalyzer::typeCastExpr ( RefNode  ec,
RefNode  es 
) [inline]

AssignmentErrorTag cfront::CAnalyzer::checkAssignment ( const Type lt,
RefNode  rn 
) [inline]

RefNode cfront::CAnalyzer::typeAssignmentExpr ( RefNode  en  )  [inline]

RefNode cfront::CAnalyzer::typeComparisonExpr ( RefNode  en  )  [inline]

const Type* cfront::CAnalyzer::convertUnaryExprType ( const Type t  )  [inline]

RefNode cfront::CAnalyzer::typeUnaryExpr ( RefNode  e  )  [inline]

Definition at line 1177 of file CAnalyzer.hpp.

References convertUnaryExprType(), and makeImplicitCastNode().

Referenced by typeExpr(), and typeFunctionArgument().

BasicType::PrimitiveTag cfront::CAnalyzer::getArithmeticTypeTag ( const Type t  )  [inline]

BasicType::PrimitiveTag cfront::CAnalyzer::typeBinaryExpr ( const Type type1,
const Type type2 
) [inline]

RefNode cfront::CAnalyzer::typeFunctionArguments ( ParameterTypes::const_iterator &  i,
ParameterTypes::const_iterator &  end,
RefNode  argNode,
bool  hasVararg,
RefNode  locationNode 
) [inline]

Definition at line 1269 of file CAnalyzer.hpp.

References ERROR1, logs_, typeFunctionArgument(), and typeUnknownTypeFunctionArguments().

Referenced by typeExpr().

RefNode cfront::CAnalyzer::typeUnknownTypeFunctionArguments ( RefNode  argNode,
RefNode  locationNode 
) [inline]

Definition at line 1301 of file CAnalyzer.hpp.

References typeFunctionArgument().

Referenced by typeFunctionArguments().

RefNode cfront::CAnalyzer::typeFunctionArgument ( RefNode  argNode,
const Type paramType,
RefNode  locationNode 
) [inline]

const Type* cfront::CAnalyzer::checkCondOperands ( RefNode  e1,
RefNode  e2 
) [inline]

RefNode cfront::CAnalyzer::typeExpr ( RefNode  en  )  [inline]

eint cfront::CAnalyzer::evalConstExpr ( antlr::RefAST  en  )  throw (EvalFailedException) [inline]

Evaluate the integer value of the constant expression node.

If the node is not a kind of constant expression node, throw EvalFailedException.

Definition at line 1775 of file CAnalyzer.hpp.

References AND, currentEnv_, cfront::NameDescription::ENUM, cfront::NameDescription::getConstantValue(), cfront::NameDescription::getLocation(), cfront::Environment::lookupOrdinaryName(), OR, and targetInfo_.

Referenced by isConstantZeroValue(), and parseGccAttribute().

void cfront::CAnalyzer::setLogs ( Logs logs  )  [inline]

Definition at line 1890 of file CAnalyzer.hpp.

References logs_.

Referenced by ctrump_parse(), and parseString().

void cfront::CAnalyzer::setTargetInfo ( TargetInfo info  )  [inline]

Definition at line 1895 of file CAnalyzer.hpp.

References targetInfo_.

Referenced by ctrump_parse(), and parseString().


Field Documentation

Definition at line 1903 of file CAnalyzer.hpp.

Referenced by getCurrentFunctionType(), initialize(), and setCurrentFunctionType().

const char* const cfront::CAnalyzer::gccBuiltinNames[] [static, protected]

Definition at line 1905 of file CAnalyzer.hpp.

Definition at line 1907 of file CAnalyzer.hpp.

Referenced by initialize(), isSupportedVectorExt(), and setSupportVectorExtension().

Definition at line 1911 of file CAnalyzer.hpp.

Referenced by evalConstExpr(), and setTargetInfo().

antlr::ASTFactory* cfront::CAnalyzer::astFactory_ [protected]

Definition at line 1913 of file CAnalyzer.hpp.

Referenced by makeImplicitCastNode(), and setASTFactory().

unsigned int cfront::CAnalyzer::nameCount_ [private]

Definition at line 1916 of file CAnalyzer.hpp.

Referenced by generateName(), and initialize().


The documentation for this class was generated from the following file:

Generated on Tue Mar 31 20:19:53 2009 for ctrump by  doxygen 1.5.6