MayaFlux 0.1.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

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

Private Member Functions

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

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: