Evaluates a code snippet.
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
283 return result;
284}
std::unique_ptr< Impl > m_impl
Internal implementation details.