KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LIBEVAL::CONTEXT Class Reference

#include <libeval_compiler.h>

Inheritance diagram for LIBEVAL::CONTEXT:
PCBEXPR_CONTEXT

Public Member Functions

 CONTEXT ()
 
virtual ~CONTEXT ()
 
 CONTEXT (const CONTEXT &)=delete
 
CONTEXToperator= (const CONTEXT &)=delete
 
virtual void Reset ()
 Release every value allocated by the previous evaluation and rewind the stack so the same CONTEXT can be reused for another Run() without being reconstructed.
 
VALUEAllocValue ()
 
VALUEStoreValue (VALUE *aValue)
 
void Push (VALUE *v)
 
VALUEPop ()
 
VALUETop ()
 Peek the top of the stack without popping (used by the short-circuit jumps).
 
int SP () const
 
void SetErrorCallback (std::function< void(const wxString &aMessage, int aOffset)> aCallback)
 
bool HasErrorCallback ()
 
void ReportError (const wxString &aErrorMsg)
 

Private Member Functions

VALUEinlineValue (std::size_t aIndex)
 

Private Attributes

std::vector< VALUE * > m_ownedValues
 
VALUEm_stack [100]
 
int m_stackPtr
 
unsigned char m_inlineStorage [INLINE_VALUE_COUNT *sizeof(VALUE)]
 
std::size_t m_inlineUsed
 
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback
 

Static Private Attributes

static constexpr std::size_t INLINE_VALUE_COUNT = 32
 

Detailed Description

Definition at line 344 of file libeval_compiler.h.

Constructor & Destructor Documentation

◆ CONTEXT() [1/2]

LIBEVAL::CONTEXT::CONTEXT ( )
inline

Definition at line 347 of file libeval_compiler.h.

References m_inlineUsed, m_ownedValues, m_stack, and m_stackPtr.

Referenced by CONTEXT(), and operator=().

◆ ~CONTEXT()

virtual LIBEVAL::CONTEXT::~CONTEXT ( )
inlinevirtual

Definition at line 355 of file libeval_compiler.h.

References Reset().

◆ CONTEXT() [2/2]

LIBEVAL::CONTEXT::CONTEXT ( const CONTEXT & )
delete

References CONTEXT().

Member Function Documentation

◆ AllocValue()

◆ HasErrorCallback()

◆ inlineValue()

VALUE * LIBEVAL::CONTEXT::inlineValue ( std::size_t aIndex)
inlineprivate

Definition at line 454 of file libeval_compiler.h.

References m_inlineStorage.

Referenced by AllocValue(), and Reset().

◆ operator=()

CONTEXT & LIBEVAL::CONTEXT::operator= ( const CONTEXT & )
delete

References CONTEXT().

◆ Pop()

◆ Push()

◆ ReportError()

◆ Reset()

virtual void LIBEVAL::CONTEXT::Reset ( )
inlinevirtual

Release every value allocated by the previous evaluation and rewind the stack so the same CONTEXT can be reused for another Run() without being reconstructed.

This keeps the owned- value vector's buffer allocated, so a reused context performs zero heap allocation for the common evaluation. Overrides must chain to this base after rewinding their own per-run state.

Reimplemented in PCBEXPR_CONTEXT.

Definition at line 371 of file libeval_compiler.h.

References inlineValue(), m_errorCallback, m_inlineUsed, m_ownedValues, and m_stackPtr.

Referenced by PCBEXPR_CONTEXT::Reset(), and ~CONTEXT().

◆ SetErrorCallback()

void LIBEVAL::CONTEXT::SetErrorCallback ( std::function< void(const wxString &aMessage, int aOffset)> aCallback)
inline

◆ SP()

int LIBEVAL::CONTEXT::SP ( ) const
inline

Definition at line 437 of file libeval_compiler.h.

References m_stackPtr.

Referenced by LIBEVAL::UCODE::Run().

◆ StoreValue()

VALUE * LIBEVAL::CONTEXT::StoreValue ( VALUE * aValue)
inline

Definition at line 403 of file libeval_compiler.h.

References m_ownedValues.

Referenced by LIBEVAL::UOP::Exec(), and LIBEVAL::UCODE::Run().

◆ Top()

VALUE * LIBEVAL::CONTEXT::Top ( )
inline

Peek the top of the stack without popping (used by the short-circuit jumps).

Definition at line 426 of file libeval_compiler.h.

References _, AllocValue(), m_stack, m_stackPtr, and ReportError().

Referenced by LIBEVAL::UOP::Exec().

Member Data Documentation

◆ INLINE_VALUE_COUNT

std::size_t LIBEVAL::CONTEXT::INLINE_VALUE_COUNT = 32
staticconstexprprivate

Definition at line 452 of file libeval_compiler.h.

Referenced by AllocValue().

◆ m_errorCallback

std::function<void( const wxString& aMessage, int aOffset )> LIBEVAL::CONTEXT::m_errorCallback
private

Definition at line 466 of file libeval_compiler.h.

Referenced by HasErrorCallback(), ReportError(), Reset(), and SetErrorCallback().

◆ m_inlineStorage

unsigned char LIBEVAL::CONTEXT::m_inlineStorage[INLINE_VALUE_COUNT *sizeof(VALUE)]
private

Definition at line 463 of file libeval_compiler.h.

Referenced by inlineValue().

◆ m_inlineUsed

std::size_t LIBEVAL::CONTEXT::m_inlineUsed
private

Definition at line 464 of file libeval_compiler.h.

Referenced by AllocValue(), CONTEXT(), and Reset().

◆ m_ownedValues

std::vector<VALUE*> LIBEVAL::CONTEXT::m_ownedValues
private

Definition at line 459 of file libeval_compiler.h.

Referenced by AllocValue(), CONTEXT(), Reset(), and StoreValue().

◆ m_stack

VALUE* LIBEVAL::CONTEXT::m_stack[100]
private

Definition at line 460 of file libeval_compiler.h.

Referenced by CONTEXT(), Pop(), Push(), and Top().

◆ m_stackPtr

int LIBEVAL::CONTEXT::m_stackPtr
private

Definition at line 461 of file libeval_compiler.h.

Referenced by CONTEXT(), Pop(), Push(), Reset(), SP(), and Top().


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