Zen
A cross-platform functional programming language

TypeSpec Class Reference

Base node class for all type specifications. More...

#include <Ast.hpp>

Inheritance diagram for TypeSpec:
Node ChildTypeSpec RootTypeSpec EnumMemberDef Namespace TemplateTypeSpec UserDefinedTypeSpec Unit DictTemplate ListTemplate OwnerTemplate EnumDef MethodTypeSpec OutParam SharedDef StructDef TypeDefTypeSpec

List of all members.

Classes

struct  AccessType
 Outer struct for AccessType enumeration. More...
class  Visitor
 TypeSpec Visitor interface class. More...

Public Types

typedef z::list< ChildTypeSpec * > ChildList
 List of child types.
typedef z::dict< z::string,
ChildTypeSpec * > 
ChildMap
 Helper to ChildList. Maps the child type name to the child type for faster search.

Public Member Functions

bool isPublic () const
 If this function returns true, this is an externally accessible type.
const AccessType::TgetAccessType () const
 Returns the access level for this type.
const z::stringgetName () const
 Returns the type name.
void setAccessType (const AccessType::T &accessType)
 Sets the access level for this type.
void setName (const z::string &name)
 Sets the type name.
template<typename T >
T & addChild (T &child)
 Adds a type as a child to this type.
template<typename T >
T * hasChild (const z::string &name) const
 Checks if a child type exists by name.
const ChildListgetChildList () const
 Returns the list of all child types.
virtual void visit (Visitor &visitor) const =0
 Abstract visitor function.
virtual z::string getFullName (const z::string &sep) const =0
 Gets the full qualified name of this type. For example: "MyNamespace::MyType".
virtual const Ast::VariableDefhasMember (const z::string &name) const
 Checks whether this type has a member variable This is used for struct's only.

Protected Member Functions

 TypeSpec (const AccessType::T &accessType, const z::string &name)
 The constructor for the type.

Private Attributes

AccessType::T _accessType
 Stores the access type for this type.
z::string _name
 Stores the name of this type.
ChildList _childList
 Owner of the list of child types.
ChildMap _childMap
 Stores a mappinbg between child type name and type object.

Detailed Description

Base node class for all type specifications.

The derived classes include various internal types such as typedef's and enum's, as well as all user-defined types such as struct's and function's. If a TypeSpec is one of the container types, it may have child types defined within itself. For example, a function may have inner functions.


Constructor & Destructor Documentation

TypeSpec ( const AccessType::T accessType,
const z::string name 
) [inline, protected]

The constructor for the type.

Parameters:
accessTypeSpecifies the AccessType for this type, for example, whether it is a public or a private type.
nameThe name of the type.

Member Function Documentation

T & addChild ( T &  child) [inline]

Adds a type as a child to this type.

Parameters:
childThe child type to be added
Returns:
Returns a reference to the newly added type.
const AccessType::T& getAccessType ( ) const [inline]

Returns the access level for this type.

Returns:
The access level for this type.
const ChildList& getChildList ( ) const [inline]

Returns the list of all child types.

Returns:
A const-ref to the list of child types.
virtual z::string getFullName ( const z::string sep) const [pure virtual]

Gets the full qualified name of this type. For example: "MyNamespace::MyType".

Parameters:
sepThe separator between each component of the type name.
Returns:
Returns the full-qualified name of the type

Implemented in RootTypeSpec, and ChildTypeSpec.

const z::string& getName ( ) const [inline]

Returns the type name.

Returns:
The type name
T * hasChild ( const z::string name) const [inline]

Checks if a child type exists by name.

Parameters:
nameThe name of the child type to check.
Returns:
Returns a pointer to the child if it exists, otherwise null.
virtual const Ast::VariableDef* hasMember ( const z::string name) const [inline, virtual]

Checks whether this type has a member variable This is used for struct's only.

Parameters:
nameThe name of the member variable to be checked.
Returns:
A pointer to the member variable if it exists, else 0.

Reimplemented in StructDef, OutParam, and SharedDef.

bool isPublic ( ) const [inline]

If this function returns true, this is an externally accessible type.

Returns:
true if this type is externally accessible.
void setAccessType ( const AccessType::T accessType) [inline]

Sets the access level for this type.

Parameters:
accessTypeThe access level for this type.
void setName ( const z::string name) [inline]

Sets the type name.

Parameters:
nameThe new name for this type
virtual void visit ( Visitor visitor) const [pure virtual]

Abstract visitor function.

Parameters:
visitorThe visitor object.

Implemented in StructDef, EnumMemberDef, EnumDef, OutParam, SharedDef, TypeDecl, TypeDef, OwnerTemplate, ListTemplate, DictTemplate, FunctionDef, Namespace, and Unit.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines