MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ eval()

ClangInterpreter::EvalResult Lila::ClangInterpreter::eval ( const std::string &  code)

Evaluates a code snippet.

Parameters
codeC++ code to execute
Returns
EvalResult containing success, output, and error info

Definition at line 239 of file ClangInterpreter.cpp.

240{
241#ifdef MAYAFLUX_PLATFORM_MACOS
242 __block EvalResult result;
243#else
244 EvalResult result;
245#endif
246
247 if (!m_impl->interpreter) {
248 result.error = "Interpreter not initialized";
249 LILA_ERROR(Emitter::INTERPRETER, result.error);
250 return result;
251 }
252
253 LILA_DEBUG(Emitter::INTERPRETER, "Evaluating code...");
254
255#ifdef MAYAFLUX_PLATFORM_MACOS
256 dispatch_sync(dispatch_get_main_queue(), ^{
257 auto eval_result = m_impl->interpreter->ParseAndExecute(code);
258
259 if (!eval_result) {
260 result.success = true;
261 LILA_DEBUG(Emitter::INTERPRETER, "Code evaluation succeeded");
262 } else {
263 result.success = false;
264 result.error = "Execution failed: " + llvm::toString(std::move(eval_result));
265 LILA_ERROR(Emitter::INTERPRETER, result.error);
266 }
267 });
268
269#else
270 auto eval_result = m_impl->interpreter->ParseAndExecute(code);
271
272 if (!eval_result) {
273 result.success = true;
274 LILA_DEBUG(Emitter::INTERPRETER, "Code evaluation succeeded");
275 } else {
276 result.success = false;
277 result.error = "Execution failed: " + llvm::toString(std::move(eval_result));
278 LILA_ERROR(Emitter::INTERPRETER, result.error);
279 }
280#endif
281
282 m_impl->eval_counter++;
283 return result;
284}
#define LILA_ERROR(emitter, msg)
#define LILA_DEBUG(emitter, msg)
std::unique_ptr< Impl > m_impl
Internal implementation details.

References Lila::ClangInterpreter::EvalResult::error, LILA_DEBUG, LILA_ERROR, and m_impl.

Referenced by eval_file().

+ Here is the caller graph for this function: