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< VALUEm_ownedValues
 
VALUEm_stack [100]
 
int m_stackPtr
 
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback
 

Detailed Description

Definition at line 284 of file libeval_compiler.h.

Constructor & Destructor Documentation

◆ CONTEXT()

LIBEVAL::CONTEXT::CONTEXT ( )
inline

Definition at line 287 of file libeval_compiler.h.

287  :
288  m_stack(),
289  m_stackPtr( 0 )
290  {
291  m_ownedValues.reserve( 20 );
292  }
VALUE * m_stack[100]
std::vector< VALUE > m_ownedValues

References m_ownedValues.

◆ ~CONTEXT()

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

Definition at line 294 of file libeval_compiler.h.

295  {
296  }

Member Function Documentation

◆ AllocValue()

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

◆ HasErrorCallback()

bool LIBEVAL::CONTEXT::HasErrorCallback ( )
inline

Definition at line 330 of file libeval_compiler.h.

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

References m_errorCallback.

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

◆ Pop()

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

Definition at line 309 of file libeval_compiler.h.

310  {
311  if( m_stackPtr == 0 )
312  {
313  ReportError( _( "Malformed expression" ) );
314  return AllocValue();
315  }
316 
317  return m_stack[ --m_stackPtr ];
318  }
VALUE * m_stack[100]
#define _(s)
void ReportError(const wxString &aErrorMsg)

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

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

◆ Push()

◆ ReportError()

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

Definition at line 659 of file libeval_compiler.cpp.

660 {
661  if( m_errorCallback )
662  m_errorCallback( aErrorMsg, -1 );
663 }
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback

References m_errorCallback.

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

◆ SetErrorCallback()

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

Definition at line 325 of file libeval_compiler.h.

326  {
327  m_errorCallback = std::move( aCallback );
328  }
std::function< void(const wxString &aMessage, int aOffset)> m_errorCallback

References m_errorCallback.

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

◆ SP()

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

Definition at line 320 of file libeval_compiler.h.

321  {
322  return m_stackPtr;
323  };

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 339 of file libeval_compiler.h.

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

◆ m_ownedValues

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

Definition at line 335 of file libeval_compiler.h.

Referenced by AllocValue(), and CONTEXT().

◆ m_stack

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

Definition at line 336 of file libeval_compiler.h.

Referenced by Pop(), and Push().

◆ m_stackPtr

int LIBEVAL::CONTEXT::m_stackPtr
private

Definition at line 337 of file libeval_compiler.h.

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


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