Zen
A cross-platform functional programming language
|
Base node class for all type specifications. More...
#include <Ast.hpp>
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::T & | getAccessType () const |
Returns the access level for this type. | |
const z::string & | getName () 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 ChildList & | getChildList () 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::VariableDef * | hasMember (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. |
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.
TypeSpec | ( | const AccessType::T & | accessType, |
const z::string & | name | ||
) | [inline, protected] |
The constructor for the type.
accessType | Specifies the AccessType for this type, for example, whether it is a public or a private type. |
name | The name of the type. |
T & addChild | ( | T & | child | ) | [inline] |
Adds a type as a child to this type.
child | The child type to be added |
const AccessType::T& getAccessType | ( | ) | const [inline] |
Returns the access level for this type.
const ChildList& getChildList | ( | ) | const [inline] |
Returns the list of all child types.
Gets the full qualified name of this type. For example: "MyNamespace::MyType".
sep | The separator between each component of the type name. |
Implemented in RootTypeSpec, and ChildTypeSpec.
const z::string& getName | ( | ) | const [inline] |
Returns the type name.
T * hasChild | ( | const z::string & | name | ) | const [inline] |
Checks if a child type exists by name.
name | The name of the child type to check. |
virtual const Ast::VariableDef* hasMember | ( | const z::string & | name | ) | const [inline, virtual] |
bool isPublic | ( | ) | const [inline] |
If this function returns true, this is an externally accessible type.
void setAccessType | ( | const AccessType::T & | accessType | ) | [inline] |
Sets the access level for this type.
accessType | The access level for this type. |
void setName | ( | const z::string & | name | ) | [inline] |
Sets the type name.
name | The new name for this type |
virtual void visit | ( | Visitor & | visitor | ) | const [pure virtual] |
Abstract visitor function.
visitor | The visitor object. |
Implemented in StructDef, EnumMemberDef, EnumDef, OutParam, SharedDef, TypeDecl, TypeDef, OwnerTemplate, ListTemplate, DictTemplate, FunctionDef, Namespace, and Unit.