OpenVDB  12.0.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Compiler Class Reference

The compiler class. This holds an llvm context and set of compiler options, and constructs executable objects (e.g. PointExecutable or VolumeExecutable) from a syntax tree or snippet of code. More...

#include <openvdb_ax/compiler/Compiler.h>

Public Types

using Ptr = std::shared_ptr< Compiler >
 
using UniquePtr = std::unique_ptr< Compiler >
 

Public Member Functions

 Compiler (const CompilerOptions &options=CompilerOptions())
 Construct a compiler object with given settings. More...
 
 ~Compiler ()=default
 
template<typename ExecutableT >
ExecutableT::Ptr compile (const ast::Tree &syntaxTree, Logger &logger, const CustomData::Ptr data=CustomData::Ptr())
 Compile a given AST into an executable object of the given type. More...
 
template<typename ExecutableT >
ExecutableT::Ptr compile (const std::string &code, Logger &logger, const CustomData::Ptr data=CustomData::Ptr())
 Compile a given snippet of AX code into an executable object of the given type. More...
 
template<typename ExecutableT >
ExecutableT::Ptr compile (const std::string &code, const CustomData::Ptr data=CustomData::Ptr())
 Compile a given snippet of AX code into an executable object of the given type. More...
 
template<typename ExecutableT >
ExecutableT::Ptr compile (const ast::Tree &syntaxTree, const CustomData::Ptr data=CustomData::Ptr())
 Compile a given AST into an executable object of the given type. More...
 
void setFunctionRegistry (std::unique_ptr< codegen::FunctionRegistry > &&functionRegistry)
 Sets the compiler's function registry object. More...
 

Static Public Member Functions

static UniquePtr create (const CompilerOptions &options=CompilerOptions())
 Static method for creating Compiler objects. More...
 

Detailed Description

The compiler class. This holds an llvm context and set of compiler options, and constructs executable objects (e.g. PointExecutable or VolumeExecutable) from a syntax tree or snippet of code.

Member Typedef Documentation

using Ptr = std::shared_ptr<Compiler>
using UniquePtr = std::unique_ptr<Compiler>

Constructor & Destructor Documentation

Compiler ( const CompilerOptions options = CompilerOptions())

Construct a compiler object with given settings.

Parameters
optionsCompilerOptions object with various settings
~Compiler ( )
default

Member Function Documentation

ExecutableT::Ptr compile ( const ast::Tree syntaxTree,
Logger logger,
const CustomData::Ptr  data = CustomData::Ptr() 
)

Compile a given AST into an executable object of the given type.

Parameters
syntaxTreeAn abstract syntax tree to compile
loggerLogger for errors and warnings during compilation, this should be linked to an ast::Tree and populated with AST node + line number mappings for this Tree, e.g. during ast::parse(). This Tree can be different from the syntaxTree argument.
dataOptional external/custom data which is to be referenced by the executable object. It allows one to reference data held elsewhere, such as inside of a DCC, from inside the AX code
Note
If the logger has not been populated with AST node and line mappings, all messages will appear without valid line and column numbers.
ExecutableT::Ptr compile ( const std::string &  code,
Logger logger,
const CustomData::Ptr  data = CustomData::Ptr() 
)
inline

Compile a given snippet of AX code into an executable object of the given type.

Parameters
codeA string of AX code
loggerLogger for errors and warnings during compilation, will be cleared of existing data
dataOptional external/custom data which is to be referenced by the executable object. It allows one to reference data held elsewhere, such as inside of a DCC, from inside the AX code
Note
If compilation is unsuccessful, will return nullptr. Logger can then be queried for errors.
ExecutableT::Ptr compile ( const std::string &  code,
const CustomData::Ptr  data = CustomData::Ptr() 
)
inline

Compile a given snippet of AX code into an executable object of the given type.

Parameters
codeA string of AX code
dataOptional external/custom data which is to be referenced by the executable object. It allows one to reference data held elsewhere, such as inside of a DCC, from inside the AX code
Note
Parser errors are handled separately from compiler errors. Each are collected and produce runtime errors.
ExecutableT::Ptr compile ( const ast::Tree syntaxTree,
const CustomData::Ptr  data = CustomData::Ptr() 
)
inline

Compile a given AST into an executable object of the given type.

Parameters
syntaxTreeAn abstract syntax tree to compile
dataOptional external/custom data which is to be referenced by the executable object. It allows one to reference data held elsewhere, such as inside of a DCC, from inside the AX code
Note
Any errors encountered are collected into a single runtime error
static UniquePtr create ( const CompilerOptions options = CompilerOptions())
static

Static method for creating Compiler objects.

void setFunctionRegistry ( std::unique_ptr< codegen::FunctionRegistry > &&  functionRegistry)

Sets the compiler's function registry object.

Parameters
functionRegistryA unique pointer to a FunctionRegistry object. The compiler will take ownership of the registry that was passed in.