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

Constructor & Destructor Documentation

◆ ~UCODE()

LIBEVAL::UCODE::~UCODE ( )
virtual

Definition at line 180 of file libeval_compiler.cpp.

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

References m_ucode.

Member Function Documentation

◆ AddOp()

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

Definition at line 348 of file libeval_compiler.h.

349  {
350  m_ucode.push_back(uop);
351  }
std::vector< UOP * > m_ucode

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

362  {
363  return nullptr;
364  };

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

357  {
358  return nullptr;
359  };

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

◆ Dump()

wxString LIBEVAL::UCODE::Dump ( ) const

Definition at line 189 of file libeval_compiler.cpp.

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

References m_ucode.

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

◆ Run()

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

Definition at line 1210 of file libeval_compiler.cpp.

1211 {
1212  static VALUE g_false( 0 );
1213 
1214  try
1215  {
1216  for( UOP* op : m_ucode )
1217  op->Exec( ctx );
1218  }
1219  catch(...)
1220  {
1221  // rules which fail outright should not be fired
1222  return &g_false;
1223  }
1224 
1225  if( ctx->SP() == 1 )
1226  {
1227  return ctx->Pop();
1228  }
1229  else
1230  {
1231  // If stack is corrupted after execution it suggests a problem with the compiler, not
1232  // the rule....
1233 
1234  // do not use "assert"; it crashes outright on OSX
1235  wxASSERT( ctx->SP() == 1 );
1236 
1237  // non-well-formed rules should not be fired on a release build
1238  return &g_false;
1239  }
1240 }
std::vector< UOP * > m_ucode

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

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


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