Loading...
Searching...
No Matches
by::frame Class Reference

Execution frame. More...

#include <frame.hpp>

Inheritance diagram for by::frame:
by::node by::frameInteractable

Public Member Functions

void add (const scope &existing)
 Adds an existing scope to the frame's scope chain.
 
void add (const scope *it) BY_SIDE_FUNC(add)
 
void add (const nbicontainer &existing)
 
void add (const nbicontainer *it) BY_SIDE_FUNC(add)
 
void add (const node &owner)
 
void add (const node *it) BY_SIDE_FUNC(add)
 
virtual void add (const node *owner, const scope &s)
 Adds a scope associated with a specific owner node to the frame's scope chain.
 
void add (const node *owner, const scope *s) BY_SIDE_FUNC(s
 
void add (owner, *s)
 
void void ())
 
virtual void addLocal (const std::string &name, const node &n)
 Adds a local symbol to the innermost local scope of the current frame.
 
void addLocal (const std::string *name, const node &n) BY_SIDE_FUNC(name
 
void addLocal void ())
 
void addLocal (const std::string &name, const node *n) BY_SIDE_FUNC(n
 
void addLocal (name, *n)
 
void void ())
 
void addLocal (const std::string *name, const node *n) BY_SIDE_FUNC(name &&n
 
void addLocal void ())
 
void addLocal (const nchar *name, const node &n) BY_SIDE_FUNC(name
 
void addLocal (std::string(name), n)
 
void void ())
 
void addLocal (const nchar *name, const node *n) BY_SIDE_FUNC(name &&n
 
void addLocal (std::string(name), *n)
 
void void ())
 
virtual void del ()
 Deletes the top-most scope from the frame's scope chain.
 
virtual nbool setMe (const node &obj)
 Sets the "me" object (context) for the current frame.
 
nbool setMe (const node *it) BY_SIDE_FUNC(setMe)
 
void setMe ()
 
const nodegetMe () const BY_CONST_FUNC(getMe()) node *getMe()
 
scopegetLocals ()
 
const scopegetLocals () const BY_CONST_FUNC(getLocals()) virtual nbool addFunc(const baseFunc &new 1)
 Adds a function to the current frame.
 
nbool addFunc (const baseFunc *it) BY_SIDE_FUNC(addFunc)
 
void delFunc ()
 Deletes the function associated with the current frame.
 
baseFuncgetFunc ()
 
const baseFuncgetFunc () const BY_CONST_FUNC(getFunc()) node *getMeHaving(const node &sub)
 Finds the "me" object (owner) within the frame that contains the specified sub-node.
 
nodegetMeHaving (const node *it) BY_SIDE_FUNC(getMeHaving)
 
const nodegetMeHaving (const node &sub) const BY_CONST_FUNC(getMeHaving(sub)) const node *getMeHaving(const node *sub) const BY_CONST_FUNC(getMeHaving(sub)) scope *getScopeHaving(const node &sub)
 Finds the scope within the frame that contains the specified sub-node.
 
scopegetScopeHaving (const node *it) BY_SIDE_FUNC(getScopeHaving)
 
tstr< nbicontainermySubs () const override
 
priorType prioritize (const args &a) const override
 
str eval (const args &a) override
 
void rel () override
 
const std::vector< scopeRegister > & getScopeRegisters () const
 
virtual nbool setRet (const node &newRet) const
 Sets the return value for the current frame.
 
virtual nbool setRet (const node *it) const
 
nodegetRet () const
 
void dump () const override
 
- Public Member Functions inherited from by::node
me & operator[] (const std::string &name)
 
const me & operator[] (const std::string &name) const BY_CONST_FUNC(operator[](name))
 
me & operator[] (const std::string *it)
 
const me & operator[] (const std::string *it) const BY_CONST_FUNC(operator[](it))
 
me & operator[] (const nchar *name)
 
const me & operator[] (const nchar *name) const BY_CONST_FUNC(operator[](name))
 
nbool in (const node &elem) const
 
nbool in (const node *elem) const
 
virtual scopesubs ()=0
 
const scopesubs () const BY_CONST_FUNC(subs()) virtual tstr< nbicontainer > mySubs() const
 Returns a tstr to a container of immediate sub-nodes (excluding inherited or chained ones).
 
const nodepromote (const node &it) const
 
const nodepromote (const node *it) const BY_SIDE_FUNC(promote)
 
template<typename T >
T * sub (std::function< nbool(const std::string &, const T &)> l)
 
template<typename T >
const T * sub (std::function< nbool(const std::string &, const T &)> l) const BY_CONST_FUNC(sub< T >(l)) template< typename T
 
template<typename T = me>
const T * sub () const BY_CONST_FUNC(sub< T >()) template< typename T
 
template<typename T = me>
T * sub (const std::string *it) BY_SIDE_FUNC(sub)
 
template<typename T = me>
const T * sub (const std::string &name) const BY_CONST_FUNC(sub< T >(name)) template< typename T
 
template<typename T = me>
T * sub (const std::string *name, const args &a) BY_SIDE_FUNC(name
 
template<typename T = me>
const T * sub (const std::string &name, const args &a) const BY_CONST_FUNC(sub< T >(name
 
template<typename T = me>
const T a const T * sub (const std::string *name, const args &a) const BY_CONST_FUNC(sub< T >(name
 
template<typename T >
const T a const T a tnarr< T, strTactic > subAll (std::function< nbool(const std::string &, const T &)> l) const
 
template<typename T = me>
tnarr< T, strTactic > subAll () const
 
template<typename T = me>
tpriorities< T > subAll (const std::string &name) const
 
template<typename T = me>
tpriorities< T > subAll (const std::string *it) const BY_SIDE_FUNC(subAll< T >) template< typename T
 
template<typename T = me>
tpriorities< T > subAll (const std::string &name, const args &a) const
 
template<typename T = me>
tpriorities< T > subAll (const std::string *name, const args *a) const BY_SIDE_FUNC(name
 
tpriorities< T > subAll< T > tpriorities ())
 
template<typename T = me>
tpriorities< T > subAll (const std::string *name, const args &a) const BY_SIDE_FUNC(name
 
tpriorities< T > subAll< T > tpriorities ())
 
bool canEval (const args &a) const
 
priorType prioritize (const args *it) const BY_SIDE_FUNC(it
 
str eval (const args *it) BY_SIDE_FUNC(eval)
 
str eval (const std::string &name, const args &a)
 
str eval (const std::string &name, const args *a) BY_SIDE_FUNC(a
 
str eval (name, a)
 
str str ())
 
str eval (const std::string *name, const args &a) BY_SIDE_FUNC(name
 
str eval str ())
 
str eval (const std::string *name, const args *a) BY_SIDE_FUNC(name &&a
 
str eval str ())
 
str eval (const std::string &name)
 
str eval (const std::string *it) BY_SIDE_FUNC(eval)
 
str eval ()
 
template<typename T >
nbool is () const
 
nbool is (const typeProvidable &to) const
 
nbool is (const typeProvidable *it) const BY_SIDE_FUNC(is)
 
nbool is (const type &to) const
 
nbool is (const type *it) const BY_SIDE_FUNC(is)
 
template<typename T >
tstr< T > as () const
 
str as (const typeProvidable &to) const
 
str as (const typeProvidable *it) const BY_SIDE_FUNC(as)
 
str as (const type &to) const
 
str as (const type *it) const BY_SIDE_FUNC(as)
 
template<typename T >
nbool isImpli () const
 
virtual nbool isImpli (const type &to) const
 
nbool isImpli (const typeProvidable &to) const
 
nbool isImpli (const typeProvidable *it) const BY_SIDE_FUNC(isImpli)
 
template<typename T >
tstr< T > asImpli () const
 
virtual str asImpli (const type &to) const
 
str asImpli (const typeProvidable &to) const
 
str asImpli (const typeProvidable *it) const BY_SIDE_FUNC(asImpli)
 
virtual const srcgetSrc () const
 
virtual nbool isComplete () const
 
virtual str infer () const
 
virtual void accept (const visitInfo &i, visitor &v)
 
void inFrame (const bicontainable *args) const override
 
void outFrame () const override
 
virtual const modifiergetModifier () const
 
virtual void inFrame (const bicontainable *args) const=0
 
void inFrame () const
 
virtual void outFrame () const=0
 
- Public Member Functions inherited from by::frameInteractable
void inFrame () const
 

Public Attributes

void addLocal name
 
const scope *getScopeHaving(const node &sub) const BY_CONST_FUNC(getScopeHaving(sub)) const scope *getScopeHaving(const node *sub) const BY_CONST_FUNC(getScopeHaving(sub)) using node scope subs )() override
 
- Public Attributes inherited from by::node
T sub name
 
T sub nullptr
 
tpriorities< T > subAll< T > name
 
priorType prioritize it
 
priorType prioritize NO_MATCH
 
str eval name
 

Additional Inherited Members

- Protected Member Functions inherited from by::node
virtual str _onEvalSub (node &sub, const args &a)
 Protected virtual method for evaluating a sub-node.
 
virtual void _setSrc (const src &s)
 
void _setSrc (const src *it) BY_SIDE_FUNC(_setSrc)
 

Detailed Description

Execution frame.

A class that manages accessible symbols in the currently executing code block. Provides symbol lists in an optimized way by dynamically chaining multiple scopes. You should know scope and tnchain in advance.

Frames are Created with Function Calls

When baseFunc is eval()ed, baseFunc calls inFrame() using frameInteract for scope owners obj, this, and blockExpr respectively. Each class's inFrame() operates by appropriately add()ing its owned scope to the frame.

Scope Linkage

baseFunc is the starting point that triggers all these frameInteracts. It calls in order: obj, func, blockExpr. baseObj creates a new frame object, adds it to frames, and places its subs() and me reference. obj adds its current file's scope in addition to baseObj's behavior. (pod scope is also added along with this.) func registers its scope subs() to the frame and adds args to the frame. blockExpr creates an empty scope to use as local scope.

Through the above process, when func is eval()ed, the new frame object has at least 5 scopes registered.

Frame Lookup

Looking only at the scope section above, you might misunderstand that "frame has an array of scopes". Since frame inherits from node, it provides subs(). subs() returns only the scope type rather than an array like vector<scope>, so it returns a scope object with multiple scopes linked together. When accessing to find symbols, you can write code concisely as if traversing a single container from the start, rather than having multiple scopes connected. This is possible because scope is implemented with tnchain.

Member Function Documentation

◆ add() [1/2]

virtual void by::frame::add ( const node * owner,
const scope & s )
virtual

Adds a scope associated with a specific owner node to the frame's scope chain.

This is typically used to add object scopes or function scopes where the owner provides context.

Parameters
ownerThe node that "owns" the scope being added (e.g., an obj or baseFunc instance).
sThe scope to add, associated with the owner.

◆ add() [2/2]

void by::frame::add ( const scope & existing)

Adds an existing scope to the frame's scope chain.

Parameters
existingdon't need to cloneChain() before passing this func.

This integrates the provided scope into the current frame's lookup hierarchy.

Parameters
existingThe scope to add.

◆ addLocal()

virtual void by::frame::addLocal ( const std::string & name,
const node & n )
virtual

Adds a local symbol to the innermost local scope of the current frame.

This method is used to define variables or functions that are accessible only within the current execution context's most specific local scope.

Parameters
nameThe name of the local symbol.
nThe node representing the local symbol (e.g., a variable or function).

◆ del()

virtual void by::frame::del ( )
virtual

Deletes the top-most scope from the frame's scope chain.

This method is typically called when exiting a block or function scope, removing the local symbols associated with that scope from the frame.

◆ delFunc()

void by::frame::delFunc ( )

Deletes the function associated with the current frame.

This typically refers to the function that was most recently added or is currently active within this frame's context.

◆ eval()

str by::frame::eval ( const args & a)
overridevirtual

Implements by::node.

◆ getFunc()

const baseFunc * by::frame::getFunc ( ) const &

Finds the "me" object (owner) within the frame that contains the specified sub-node.

Parameters
subThe sub-node to search for.
Returns
A pointer to the "me" object that owns the sub-node, or nullptr if not found.

◆ getLocals()

const scope * by::frame::getLocals ( ) const &
new

Adds a function to the current frame.

This function becomes the "current" function for this frame, allowing its context to be used for symbol resolution or evaluation.

Parameters
new1The baseFunc object to add.
Returns
true if the function was successfully added, false otherwise.

◆ getMeHaving()

const node * by::frame::getMeHaving ( const node & sub) const &

Finds the scope within the frame that contains the specified sub-node.

Parameters
subThe sub-node to search for.
Returns
A pointer to the scope that contains the sub-node, or nullptr if not found.

◆ prioritize()

priorType by::frame::prioritize ( const args & a) const
overridevirtual

Implements by::node.

◆ rel()

void by::frame::rel ( )
overridevirtual

Release all held resources and prepare for termination.

Remarks
Some classes won't be able to reinitialize after rel() is called.

Reimplemented from by::node.

◆ setMe()

virtual nbool by::frame::setMe ( const node & obj)
virtual

Sets the "me" object (context) for the current frame.

The "me" object typically represents the instance on which a method is being invoked or the current object context.

Parameters
objThe node representing the "me" object.
Returns
true if the "me" object was successfully set, false otherwise.
Note
The "me" object can be a mockNode during verification.

◆ setRet()

virtual nbool by::frame::setRet ( const node & newRet) const
virtual

Sets the return value for the current frame.

This method is typically used to store the result of a function or block execution within the frame. The method is const because the _ret member is mutable, allowing the return value to be set even for const frame instances.

Parameters
newRetThe node representing the return value.
Returns
true if the return value was successfully set, false otherwise.

The documentation for this class was generated from the following file:
to Top