Spicy
Public Member Functions | Static Public Member Functions | List of all members
spicy::type::Unit Class Reference

#include <unit.h>

Inheritance diagram for spicy::type::Unit:
spicy::type::detail::AssignIndices hilti::TypeBase hilti::type::trait::isAllocable hilti::type::trait::isParameterized hilti::type::trait::takesArguments hilti::type::trait::isMutable hilti::NodeBase hilti::trait::isType hilti::trait::isNode hilti::trait::isNode

Public Member Functions

 Unit (std::vector< type::function::Parameter > params, std::vector< unit::Item > i, const std::optional< AttributeSet > &={}, Meta m=Meta())
 
 Unit (Wildcard, Meta m=Meta())
 
NodeRef selfRef () const
 
auto id () const
 
auto parameters () const
 
auto parameterRefs () const
 
auto items () const
 
auto itemRefs () const
 
auto attributes () const
 
hilti::optional_ref< const TypecontextType () const
 
hilti::optional_ref< const type::unit::Item > itemByName (const ID &id) const
 
NodeRef itemRefByName (const ID &id) const
 
template<typename T >
auto items () const
 
hilti::optional_ref< const unit::item::PropertypropertyItem (const std::string &name) const
 
auto propertyItems (const std::string &name) const
 
auto isPublic () const
 
bool usesRandomAccess () const
 
bool supportsSinks () const
 
bool supportsFilters () const
 
bool isFilter () const
 
const spicy::detail::codegen::Grammargrammar () const
 
void addItems (std::vector< unit::Item > items)
 
void setAttributes (AttributeSet attrs)
 
void setGrammar (std::shared_ptr< spicy::detail::codegen::Grammar > g)
 
void setID (ID id)
 
void setPublic (bool p)
 
bool operator== (const Unit &other) const
 
auto isEqual (const Type &other) const
 
auto _isResolved (ResolvedState *rstate) const
 
auto typeParameters () const
 
auto isWildcard () const
 
auto properties () const
 
- Public Member Functions inherited from hilti::NodeBase
 NodeBase (Meta meta)
 
 NodeBase (std::vector< Node > childs, Meta meta)
 
template<typename T >
const T & child (int i) const
 
template<typename T >
void assertChildIsA (int i)
 
template<typename T >
auto childs (int begin, int end) const
 
auto childRefs (int begin, int end)
 
template<typename T >
hilti::node::Set< T > childsOfType () const
 
template<typename T >
std::vector< NodeRefchildRefsOfType () const
 
void addChild (Node n)
 
const auto & childs () const
 
auto & childs ()
 
auto & meta () const
 
void setMeta (Meta m)
 
bool pruneWalk () const
 

Static Public Member Functions

static void setSelf (Node *n)
 

Detailed Description

AST node for a Spicy unit.

Member Function Documentation

◆ addItems()

void spicy::type::Unit::addItems ( std::vector< unit::Item >  items)
inline

Adds a number of new items to the unit.

◆ contextType()

hilti::optional_ref<const Type> spicy::type::Unit::contextType ( ) const
inline

Returns the type set through `context, if available.

◆ grammar()

const spicy::detail::codegen::Grammar& spicy::type::Unit::grammar ( ) const
inline

Returns the grammar associated with the type. It must have been set before through setGrammar().

◆ isFilter()

bool spicy::type::Unit::isFilter ( ) const
inline

Returns true if this unit type can act as a filter.

Todo:
Currently we tie this capability to unit types being public, which is just a hack until we get something better. Eventually we should support this automatically as needed, through static analysis.

◆ isPublic()

auto spicy::type::Unit::isPublic ( ) const
inline

Returns true if the unit has been declared as publically/externally accessible.

◆ itemByName()

hilti::optional_ref< const type::unit::Item > type::Unit::itemByName ( const ID id) const

Returns the item of a given name if it exists. This descends recursively into childs as well.

◆ itemRefByName()

NodeRef type::Unit::itemRefByName ( const ID id) const

Returns a reference to an item give by its ID.

◆ items()

template<typename T >
auto spicy::type::Unit::items ( ) const
inline

Returns all of the unit's items of a particular subtype T.

◆ propertyItem()

hilti::optional_ref<const unit::item::Property> spicy::type::Unit::propertyItem ( const std::string &  name) const
inline

Returns the property of a given name if it exists. If it exists more than once, it's undefined which one is returned.

◆ propertyItems()

auto spicy::type::Unit::propertyItems ( const std::string &  name) const
inline

Returns all properties of a given name.

◆ setSelf()

static void spicy::type::Unit::setSelf ( Node n)
inlinestatic

Given an existing node wrapping a unit type, updates the contained unit type to have its self declaration initialized. Note that the unit type's constructor cannot do this because we need the Node shell for this.

◆ supportsFilters()

bool spicy::type::Unit::supportsFilters ( ) const
inline

Returns true if this unit type supports connecting a filter.

Todo:
Currently we tie this capability to unit types being public, which is just a hack until we get something better. Eventually we should support this automatically as needed, through static analysis.

◆ supportsSinks()

bool spicy::type::Unit::supportsSinks ( ) const
inline

Returns true if this unit type supports connecting to a sink.

Todo:
Currently we tie this capability to unit types being public, which is just a hack until we get something better. Eventually we should support this automatically as needed, through static analysis.

◆ usesRandomAccess()

bool spicy::type::Unit::usesRandomAccess ( ) const
inline

Returns true if for this unit the parser generator needs to generate code facilitating random access within the data that an instance is being parsed from.

Todo:
Currently this feature gets enabled through an attribute (random-access). Eventually we should enable this automatically as needed, through static analysis.

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