FreeTensor
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
freetensor::ASTPart Class Referenceabstract

#include <sub_tree.h>

Inheritance diagram for freetensor::ASTPart:
Inheritance graph
[legend]
Collaboration diagram for freetensor::ASTPart:
Collaboration graph
[legend]

Public Member Functions

virtual ~ASTPart ()
 
 ASTPart (ASTPart &&other)
 
 ASTPart (const ASTPart &other)
 
ASTPartoperator= (ASTPart &&)
 
ASTPartoperator= (const ASTPart &)
 
bool trySetParent (const Ref< ASTPart > &parent)
 
void resetParent ()
 
Ref< ASTPartparent () const
 
bool isSubTree () const
 
int depth () const
 
virtual void modifiedHook ()
 
size_t hash ()
 
virtual bool isAST () const
 
- Public Member Functions inherited from freetensor::EnableSelf< ASTPart >
Ref< ASTPartself () const
 

Protected Member Functions

void lock ()
 
void unlock ()
 
virtual void compHash ()=0
 
void resetHash ()
 

Protected Attributes

size_t hash_ = ~0ull
 
std::atomic_flag lock_ = ATOMIC_FLAG_INIT
 

Additional Inherited Members

- Public Types inherited from freetensor::EnableSelf< ASTPart >
typedef ASTPart Self
 

Detailed Description

The basic building block of an AST

A ASTPart can be derived as an ASTNode, or other classes that is a part of an ASTNode. ASTPart automatically manage the memory of the AST, and tracking each ASTPart's parent, as long as each ASTPart is "plugged in" a SubTree of its parent

An ASTPart must be constructed via factory functions like makeXXX, instead of a custom constructor. This is because the self() will be used to initialize is children, but self() is only available when a Ref of the ASTPart is present, after the ASTPart is constructed.

Read members from an ASTPart is thread-safe (even it computes hash). Write to members of an ASTPart is NOT thread-safe

Constructor & Destructor Documentation

◆ ~ASTPart()

virtual freetensor::ASTPart::~ASTPart ( )
inlinevirtual

◆ ASTPart() [1/2]

freetensor::ASTPart::ASTPart ( ASTPart &&  other)
inline

◆ ASTPart() [2/2]

freetensor::ASTPart::ASTPart ( const ASTPart other)
inline

Member Function Documentation

◆ compHash()

virtual void freetensor::ASTPart::compHash ( )
protectedpure virtual

◆ depth()

int freetensor::ASTPart::depth ( ) const

How many ancestors this ASTPart has. Counting from 0

This value is not cached. Please count it as few as possible

◆ hash()

size_t freetensor::ASTPart::hash ( )

◆ isAST()

virtual bool freetensor::ASTPart::isAST ( ) const
inlinevirtual

Reimplemented in freetensor::ASTNode.

◆ isSubTree()

bool freetensor::ASTPart::isSubTree ( ) const
inline

◆ lock()

void freetensor::ASTPart::lock ( )
inlineprotected

◆ modifiedHook()

virtual void freetensor::ASTPart::modifiedHook ( )
inlinevirtual

Called when a SubTree of ASTPart is modified

You can override this hook to clear some internal states of an ASTPart. Remember to call the base class' hook

This hook is NOT thread-safe

Reimplemented in freetensor::ExprNode.

◆ operator=() [1/2]

ASTPart & freetensor::ASTPart::operator= ( ASTPart &&  )
inline

◆ operator=() [2/2]

ASTPart & freetensor::ASTPart::operator= ( const ASTPart )
inline

◆ parent()

Ref< ASTPart > freetensor::ASTPart::parent ( ) const
inline

◆ resetHash()

void freetensor::ASTPart::resetHash ( )
protected

◆ resetParent()

void freetensor::ASTPart::resetParent ( )
inline

◆ trySetParent()

bool freetensor::ASTPart::trySetParent ( const Ref< ASTPart > &  parent)
inline

◆ unlock()

void freetensor::ASTPart::unlock ( )
inlineprotected

Member Data Documentation

◆ hash_

size_t freetensor::ASTPart::hash_ = ~0ull
protected

◆ lock_

std::atomic_flag freetensor::ASTPart::lock_ = ATOMIC_FLAG_INIT
protected

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