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::isOnHeap hilti::NodeBase hilti::trait::isType hilti::trait::isNode hilti::trait::isNode

Public Member Functions

 Unit (std::vector< type::function::Parameter > p, std::vector< unit::Item > i, const std::optional< AttributeSet > &={}, Meta m=Meta())
 
 Unit (Wildcard, Meta m=Meta())
 
auto parameters () const
 
auto items () const
 
std::optional< AttributeSetattributes () const
 
auto types () const
 
std::optional< Type > contextType () const
 
std::optional< unit::Item > field (const ID &id) const
 
template<typename T >
auto items () const
 
std::optional< 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
 
bool operator== (const Unit &other) const
 
auto isEqual (const Type &other) const
 
auto typeParameters () const
 
auto isWildcard () const
 
auto properties () const
 
- Public Member Functions inherited from hilti::TypeBase
bool hasFlag (type::Flag f) const
 
type::Flags flags () const
 
bool _isConstant () const
 
std::optional< IDtypeID () const
 
std::optional< IDcxxID () const
 
const type::detail::State_state () const
 
type::detail::State_state ()
 
- 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 >
std::vector< T > childs (int begin, int end) const
 
template<typename T >
std::vector< T > childsOfType () const
 
template<typename T >
auto nodesOfType () const
 
template<typename T >
auto nodesOfType ()
 
void addChild (Node n)
 
auto & childs () const
 
auto & childs ()
 
auto & meta () const
 
void setMeta (Meta m)
 
const NodeReforiginalNode () const
 
void setOriginalNode (const NodeRef &n)
 
void clearCache ()
 

Static Public Member Functions

static Unit setPublic (const Unit &unit, bool p)
 
static Unit addItems (const Unit &unit, std::vector< unit::Item > items)
 
static Unit addAttributes (const Unit &unit, AttributeSet attrs)
 
static Unit setGrammar (const Unit &unit, std::shared_ptr< spicy::detail::codegen::Grammar > g)
 

Detailed Description

AST node for a Spicy unit.

Member Function Documentation

◆ addAttributes()

static Unit spicy::type::Unit::addAttributes ( const Unit unit,
AttributeSet  attrs 
)
inlinestatic

Copies an existing unit type, adding further attributes.

Parameters
unitoriginal unit type
attrsadditional attributes to add
Returns
new unit type that includes the additional attributes

◆ addItems()

static Unit spicy::type::Unit::addItems ( const Unit unit,
std::vector< unit::Item >  items 
)
inlinestatic

Copies an existing unit type, adding further unit items.

Parameters
unitoriginal unit type
itemsadditional items to add
Returns
new unit type that includes the additional items

◆ contextType()

std::optional<Type> spicy::type::Unit::contextType ( ) const
inline

Returns the type set through `context, if available.

◆ field()

std::optional< type::unit::Item > type::Unit::field ( const ID id) const

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

◆ 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.

◆ items()

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

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

◆ propertyItem()

std::optional<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.

◆ setGrammar()

static Unit spicy::type::Unit::setGrammar ( const Unit unit,
std::shared_ptr< spicy::detail::codegen::Grammar g 
)
inlinestatic

Copies an existing unit type, setting its accociated grammar.

Parameters
unitoriginal unit type
gthe grammar
Returns
new type with the grammar associated

◆ setPublic()

static Unit spicy::type::Unit::setPublic ( const Unit unit,
bool  p 
)
inlinestatic

Copies an existing unit type but changes it public state.

Parameters
unitoriginal unit type
ptrue if the copied type is to be public
Returns
new type with public state set as requested

◆ 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: