KiCad PCB EDA Suite
LIBEVAL::CONTEXT Class Reference

#include <libeval_compiler.h>

Inheritance diagram for LIBEVAL::CONTEXT:
PCB_EXPR_CONTEXT

Public Member Functions

 CONTEXT ()
 
virtual ~CONTEXT ()
 
VALUEAllocValue ()
 
void Push (VALUE *v)
 
VALUEPop ()
 
int SP () const
 
void SetErrorCallback (std::function< void(const wxString &aMessage, int aOffset)> aCallback)
 
bool HasErrorCallback ()
 
void ReportError (const wxString &aErrorMsg)
 

Private Attributes

std::vector< VALUE * > m_ownedValues
 
VALUEm_stack [100]
 
int m_stackPtr
 
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback
 

Detailed Description

Definition at line 303 of file libeval_compiler.h.

Constructor & Destructor Documentation

◆ CONTEXT()

LIBEVAL::CONTEXT::CONTEXT ( )
inline

Definition at line 306 of file libeval_compiler.h.

306 :
307 m_stack(),
308 m_stackPtr( 0 )
309 {
310 m_ownedValues.reserve( 20 );
311 }
std::vector< VALUE * > m_ownedValues
VALUE * m_stack[100]

References m_ownedValues.

◆ ~CONTEXT()

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

Definition at line 313 of file libeval_compiler.h.

314 {
315 for( auto &v : m_ownedValues )
316 {
317 delete v;
318 }
319 }

References m_ownedValues.

Member Function Documentation

◆ AllocValue()

◆ HasErrorCallback()

bool LIBEVAL::CONTEXT::HasErrorCallback ( )
inline

Definition at line 353 of file libeval_compiler.h.

353{ return m_errorCallback != nullptr; }
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback

References m_errorCallback.

Referenced by calcIsInsideArea(), LIBEVAL::UOP::Exec(), existsOnLayer(), getField(), inDiffPair(), insideArea(), insideBackCourtyard(), insideCourtyard(), insideFrontCourtyard(), and memberOf().

◆ Pop()

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

Definition at line 332 of file libeval_compiler.h.

333 {
334 if( m_stackPtr == 0 )
335 {
336 ReportError( _( "Malformed expression" ) );
337 return AllocValue();
338 }
339
340 return m_stack[ --m_stackPtr ];
341 }
void ReportError(const wxString &aErrorMsg)
#define _(s)

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

Referenced by LIBEVAL::UOP::Exec(), existsOnLayer(), exprFromTo(), LIBEVAL::COMPILER::generateUCode(), getField(), inDiffPair(), insideArea(), insideBackCourtyard(), insideCourtyard(), insideFrontCourtyard(), memberOf(), and LIBEVAL::UCODE::Run().

◆ Push()

◆ ReportError()

void LIBEVAL::CONTEXT::ReportError ( const wxString &  aErrorMsg)

◆ SetErrorCallback()

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

Definition at line 348 of file libeval_compiler.h.

349 {
350 m_errorCallback = std::move( aCallback );
351 }

References m_errorCallback.

Referenced by DRC_RULE_CONDITION::EvaluateFor(), and LIBEVAL::COMPILER::generateUCode().

◆ SP()

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

Definition at line 343 of file libeval_compiler.h.

344 {
345 return m_stackPtr;
346 };

References m_stackPtr.

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

Member Data Documentation

◆ m_errorCallback

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

Definition at line 362 of file libeval_compiler.h.

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

◆ m_ownedValues

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

Definition at line 358 of file libeval_compiler.h.

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

◆ m_stack

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

Definition at line 359 of file libeval_compiler.h.

Referenced by Pop(), and Push().

◆ m_stackPtr

int LIBEVAL::CONTEXT::m_stackPtr
private

Definition at line 360 of file libeval_compiler.h.

Referenced by Pop(), Push(), and SP().


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