MayaFlux 0.2.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 171 of file ClangInterpreter.cpp.

172{
173#ifdef MAYAFLUX_PLATFORM_MACOS
174 __block EvalResult result;
175#else
176 EvalResult result;
177#endif
178
179 if (!m_impl->interpreter) {
180 result.error = "Interpreter not initialized";
181 LILA_ERROR(Emitter::INTERPRETER, result.error);
182 return result;
183 }
184
185 LILA_DEBUG(Emitter::INTERPRETER, "Evaluating code...");
186
187#ifdef MAYAFLUX_PLATFORM_MACOS
188 dispatch_sync(dispatch_get_main_queue(), ^{
189 auto eval_result = m_impl->interpreter->ParseAndExecute(code);
190
191 if (!eval_result) {
192 result.success = true;
193 LILA_DEBUG(Emitter::INTERPRETER, "Code evaluation succeeded");
194 } else {
195 result.success = false;
196 result.error = "Execution failed: " + llvm::toString(std::move(eval_result));
197 LILA_ERROR(Emitter::INTERPRETER, result.error);
198 }
199 });
200#else
201 auto eval_result = m_impl->interpreter->ParseAndExecute(code);
202
203 if (!eval_result) {
204 result.success = true;
205 LILA_DEBUG(Emitter::INTERPRETER, "Code evaluation succeeded");
206 } else {
207 result.success = false;
208 result.error = "Execution failed: " + llvm::toString(std::move(eval_result));
209 LILA_ERROR(Emitter::INTERPRETER, result.error);
210 }
211#endif
212
213 m_impl->eval_counter++;
214 return result;
215}
#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: