KiCad PCB EDA Suite
LIBEVAL::UCODE Class Reference

#include <libeval_compiler.h>

Inheritance diagram for LIBEVAL::UCODE:
PCB_EXPR_UCODE

Public Member Functions

virtual ~UCODE ()
 
void AddOp (UOP *uop)
 
VALUERun (CONTEXT *ctx)
 
wxString Dump () const
 
virtual std::unique_ptr< VAR_REFCreateVarRef (const wxString &var, const wxString &field)
 
virtual FUNC_CALL_REF CreateFuncCall (const wxString &name)
 

Protected Attributes

std::vector< UOP * > m_ucode
 

Detailed Description

Definition at line 372 of file libeval_compiler.h.

Constructor & Destructor Documentation

◆ ~UCODE()

LIBEVAL::UCODE::~UCODE ( )
virtual

Definition at line 181 of file libeval_compiler.cpp.

182{
183 for ( auto op : m_ucode )
184 {
185 delete op;
186 }
187}
std::vector< UOP * > m_ucode

References m_ucode.

Member Function Documentation

◆ AddOp()

void LIBEVAL::UCODE::AddOp ( UOP uop)
inline

Definition at line 377 of file libeval_compiler.h.

378 {
379 m_ucode.push_back(uop);
380 }

References m_ucode.

Referenced by LIBEVAL::COMPILER::generateUCode().

◆ CreateFuncCall()

virtual FUNC_CALL_REF LIBEVAL::UCODE::CreateFuncCall ( const wxString &  name)
inlinevirtual

Reimplemented in PCB_EXPR_UCODE.

Definition at line 390 of file libeval_compiler.h.

391 {
392 return nullptr;
393 };

Referenced by LIBEVAL::COMPILER::generateUCode().

◆ CreateVarRef()

virtual std::unique_ptr< VAR_REF > LIBEVAL::UCODE::CreateVarRef ( const wxString &  var,
const wxString &  field 
)
inlinevirtual

Reimplemented in PCB_EXPR_UCODE.

Definition at line 385 of file libeval_compiler.h.

386 {
387 return nullptr;
388 };

Referenced by LIBEVAL::COMPILER::generateUCode().

◆ Dump()

wxString LIBEVAL::UCODE::Dump ( ) const

Definition at line 190 of file libeval_compiler.cpp.

191{
192 wxString rv;
193
194 for( auto op : m_ucode )
195 {
196 rv += op->Format();
197 rv += "\n";
198 }
199
200 return rv;
201};

References m_ucode.

Referenced by LIBEVAL::COMPILER::generateUCode().

◆ Run()

VALUE * LIBEVAL::UCODE::Run ( CONTEXT ctx)

Definition at line 1223 of file libeval_compiler.cpp.

1224{
1225 static VALUE g_false( 0 );
1226
1227 try
1228 {
1229 for( UOP* op : m_ucode )
1230 op->Exec( ctx );
1231 }
1232 catch(...)
1233 {
1234 // rules which fail outright should not be fired
1235 return &g_false;
1236 }
1237
1238 if( ctx->SP() == 1 )
1239 {
1240 return ctx->Pop();
1241 }
1242 else
1243 {
1244 // If stack is corrupted after execution it suggests a problem with the compiler, not
1245 // the rule....
1246
1247 // do not use "assert"; it crashes outright on OSX
1248 wxASSERT( ctx->SP() == 1 );
1249
1250 // non-well-formed rules should not be fired on a release build
1251 return &g_false;
1252 }
1253}

References m_ucode, LIBEVAL::CONTEXT::Pop(), and LIBEVAL::CONTEXT::SP().

Referenced by PCB_EXPR_EVALUATOR::Evaluate(), and testEvalExpr().

Member Data Documentation

◆ m_ucode

std::vector<UOP*> LIBEVAL::UCODE::m_ucode
protected

Definition at line 397 of file libeval_compiler.h.

Referenced by AddOp(), Dump(), Run(), and ~UCODE().


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