Spicy
Classes | Public Member Functions | List of all members
hilti::Scope Class Reference

#include <scope.h>

Inheritance diagram for hilti::Scope:
hilti::rt::intrusive_ptr::ManagedObject

Classes

struct  Referee
 

Public Member Functions

void insert (const ID &id, NodeRef n)
 
void insert (const ID &id, Node &&n)
 
bool has (const ID &id) const
 
std::vector< RefereelookupAll (const ID &id) const
 
std::optional< Refereelookup (const ID &id) const
 
void clear ()
 
const auto & items () const
 
void copyInto (Scope *dst) const
 
void moveInto (Scope *dst)
 
void render (std::ostream &out, const std::string &prefix="") const
 
 Scope (const Scope &other)=delete
 
 Scope (Scope &&other)=delete
 
Scopeoperator= (const Scope &other)=delete
 
Scopeoperator= (Scope &&other)=delete
 

Detailed Description

Identifier scope. A scope maps identifiers to AST nodes (more precisely: to referneces to AST nodes). An identifier can be mapped to more than one node.

Member Function Documentation

◆ clear()

void hilti::Scope::clear ( )
inline

Empties the scope.

◆ copyInto()

void hilti::Scope::copyInto ( Scope dst) const
inline

Copies the scope's mappings into another one.

◆ has()

bool hilti::Scope::has ( const ID id) const
inline

Returns true if there's at least one mapping for an ID.

◆ insert() [1/2]

void Scope::insert ( const ID id,
NodeRef  n 
)

Inserts a new identifier mapping. If a mapping for the ID already exists, the new one is appended to it.

Parameters
idid to map
nreference to the node that id is to be mapped to

◆ insert() [2/2]

void Scope::insert ( const ID id,
Node &&  n 
)

Inserts a new identifier mapping.

Parameters
idid to map
nnode to map to; as a scope always maps to references, this takes ownership of the node and stores it internally

◆ items()

const auto& hilti::Scope::items ( ) const
inline

Returns all mappings of the scope.

◆ lookup()

std::optional<Referee> hilti::Scope::lookup ( const ID id) const
inline

Returns first mapping for an ID.

◆ lookupAll()

std::vector<Referee> hilti::Scope::lookupAll ( const ID id) const
inline

Returns all mappings for an ID.

◆ moveInto()

void hilti::Scope::moveInto ( Scope dst)
inline

Moves the scope's mappings into another one. The source scope will be empty afterwards.

◆ render()

void Scope::render ( std::ostream &  out,
const std::string &  prefix = "" 
) const

Prints out a debugging representation of the scope's content.

Parameters
outstream to print to
prefixstring to prefix each printed scope item with

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