MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Lila::ClangInterpreter Class Reference

Embedded Clang interpreter for live code evaluation in MayaFlux. More...

#include <ClangInterpreter.hpp>

+ Collaboration diagram for Lila::ClangInterpreter:

Classes

struct  EvalResult
 Result of code evaluation. More...
 
struct  Impl
 

Public Member Functions

void add_compile_flag (const std::string &flag)
 Adds a compile flag for code evaluation.
 
void add_include_path (const std::string &path)
 Adds an include path for code evaluation.
 
void add_library_path (const std::string &path)
 Adds a library path (not yet implemented)
 
 ClangInterpreter ()
 Constructs a ClangInterpreter instance.
 
 ClangInterpreter (ClangInterpreter &&) noexcept
 
 ClangInterpreter (const ClangInterpreter &)=delete
 
EvalResult eval (const std::string &code)
 Evaluates a code snippet.
 
EvalResult eval_file (const std::string &filepath)
 Evaluates a code file by including it.
 
std::vector< std::string > get_defined_symbols ()
 Gets a list of all defined symbols.
 
std::string get_last_error () const
 Gets the last error message.
 
void * get_symbol_address (const std::string &name)
 Gets the address of a symbol defined in the interpreter.
 
bool initialize (bool skip_host_library_load=false)
 Initialize the Clang interpreter.
 
ClangInterpreteroperator= (ClangInterpreter &&) noexcept
 
ClangInterpreteroperator= (const ClangInterpreter &)=delete
 
void reset ()
 Resets the interpreter, clearing all state.
 
void set_target_triple (const std::string &triple)
 Sets the target triple for code generation.
 
void shutdown ()
 Shuts down the interpreter and releases resources.
 
 ~ClangInterpreter ()
 Destructor; shuts down the interpreter if active.
 

Private Member Functions

bool create_interpreter ()
 
void detect_system_includes ()
 
void extract_symbols_from_code (const std::string &code)
 
std::string preprocess_code (const std::string &code)
 
bool setup_compiler_instance ()
 

Private Attributes

std::unique_ptr< Implm_impl
 Internal implementation details.
 
std::string m_last_error
 

Detailed Description

Embedded Clang interpreter for live code evaluation in MayaFlux.

The ClangInterpreter class provides an interface for compiling and executing C++ code snippets at runtime using Clang's incremental interpreter. It is the core engine behind Lila's live coding capabilities, enabling real-time code evaluation, symbol lookup, and dynamic integration of user code.

Core Responsibilities

  • Initialize and manage the Clang interpreter instance
  • Evaluate code snippets and files, returning results and errors
  • Track and expose defined symbols for runtime introspection
  • Allow configuration of include paths, compile flags, and target triple
  • Provide error reporting and reset functionality

Usage Flow

  1. Construct a ClangInterpreter instance
  2. Call initialize() to set up the interpreter
  3. Use eval() or eval_file() to execute code
  4. Query symbols or errors as needed
  5. Optionally configure include paths, flags, or target triple before initialization
  6. Call shutdown() or reset() to clean up

This class is intended for internal use by Lila and is not exposed to end users directly.

Definition at line 35 of file ClangInterpreter.hpp.


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