15 #ifndef OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED 16 #define OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED 25 #include <openvdb/version.h> 44 class FunctionRegistry;
54 using Ptr = std::shared_ptr<Compiler>;
78 template <
typename ExecutableT>
79 typename ExecutableT::Ptr
94 template <
typename ExecutableT>
95 typename ExecutableT::Ptr
102 if (syntaxTree)
return compile<ExecutableT>(*syntaxTree, logger, data);
114 template <
typename ExecutableT>
115 typename ExecutableT::Ptr
119 std::vector<std::string> errors;
120 openvdb::ax::Logger logger(
121 [&errors] (
const std::string& error) {
122 errors.emplace_back(error +
"\n");
124 [] (
const std::string&) {}
127 if (!errors.empty()) {
128 std::ostringstream os;
129 for (
const auto& e : errors) os << e <<
"\n";
133 typename ExecutableT::Ptr exe = this->compile<ExecutableT>(*syntaxTree, logger, data);
134 if (!errors.empty()) {
135 std::ostringstream os;
136 for (
const auto& e : errors) os << e <<
"\n";
149 template <
typename ExecutableT>
150 typename ExecutableT::Ptr
154 std::vector<std::string> errors;
155 openvdb::ax::Logger logger(
156 [&errors] (
const std::string& error) {
157 errors.emplace_back(error +
"\n");
159 [] (
const std::string&) {}
161 auto exe = compile<ExecutableT>(syntaxTree, logger, data);
162 if (!errors.empty()) {
163 std::ostringstream os;
164 for (
const auto& e : errors) os << e <<
"\n";
177 void setFunctionRegistry(std::unique_ptr<codegen::FunctionRegistry>&& functionRegistry);
182 template <
typename ExeT,
typename GenT>
185 const std::string& moduleName,
186 const std::vector<std::string>& functions,
191 std::shared_ptr<llvm::LLVMContext> mContext;
193 std::shared_ptr<codegen::FunctionRegistry> mFunctionRegistry;
201 #endif // OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED Definition: Compiler.h:32
A Tree is the highest concrete (non-abstract) node in the entire AX AST hierarchy. It represents an entire conversion of a valid AX string.
Definition: AST.h:562
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
Settings which control how a Compiler class object behaves.
Definition: CompilerOptions.h:47
Parsing methods for creating abstract syntax trees out of AX code.
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:565
Definition: Exceptions.h:39
Single header include which provides methods for initializing AX and running a full AX pipeline (pars...
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.
Definition: Compiler.h:96
OPENVDB_AX_API openvdb::ax::ast::Tree::ConstPtr parse(const char *code, ax::Logger &logger)
Construct an abstract syntax tree from a code snippet.
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.
Definition: Compiler.h:116
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
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.
Definition: Compiler.h:151
Definition: Exceptions.h:13
OpenVDB AX Compiler Options.
std::shared_ptr< CustomData > Ptr
Definition: CustomData.h:37
Logging system to collect errors and warnings throughout the different stages of parsing and compilat...
The compiler class. This holds an llvm context and set of compiler options, and constructs executable...
Definition: Compiler.h:50
void clear()
Clear the tree-code mapping and reset the number of errors/warnings.
std::shared_ptr< Compiler > Ptr
Definition: Compiler.h:54
Access to the CustomData class which can provide custom user user data to the OpenVDB AX Compiler...
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:57
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
Definition: Exceptions.h:37
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
std::unique_ptr< Compiler > UniquePtr
Definition: Compiler.h:55