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

Constructor & Destructor Documentation

◆ ~UCODE()

LIBEVAL::UCODE::~UCODE ( )
virtual

Definition at line 166 of file libeval_compiler.cpp.

167 {
168  for ( auto op : m_ucode )
169  {
170  delete op;
171  }
172 }
std::vector< UOP * > m_ucode

References m_ucode.

Member Function Documentation

◆ AddOp()

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

Definition at line 324 of file libeval_compiler.h.

325  {
326  m_ucode.push_back(uop);
327  }
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 337 of file libeval_compiler.h.

338  {
339  return nullptr;
340  };

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

333  {
334  return nullptr;
335  };

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

◆ Dump()

wxString LIBEVAL::UCODE::Dump ( ) const

Definition at line 175 of file libeval_compiler.cpp.

176 {
177  wxString rv;
178 
179  for( auto op : m_ucode )
180  {
181  rv += op->Format();
182  rv += "\n";
183  }
184 
185  return rv;
186 };
std::vector< UOP * > m_ucode

References m_ucode.

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

◆ Run()

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

Definition at line 1165 of file libeval_compiler.cpp.

1166 {
1167  static VALUE g_false( 0 );
1168 
1169  try
1170  {
1171  for( UOP* op : m_ucode )
1172  op->Exec( ctx );
1173  }
1174  catch(...)
1175  {
1176  // rules which fail outright should not be fired
1177  return &g_false;
1178  }
1179 
1180  if( ctx->SP() == 1 )
1181  {
1182  return ctx->Pop();
1183  }
1184  else
1185  {
1186  // If stack is corrupted after execution it suggests a problem with the compiler, not
1187  // the rule....
1188 
1189  // do not use "assert"; it crashes outright on OSX
1190  wxASSERT( ctx->SP() == 1 );
1191 
1192  // non-well-formed rules should not be fired on a release build
1193  return &g_false;
1194  }
1195 }
Field Value of part, i.e. "3.3K".
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 340 of file libeval_compiler.h.

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


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