15 #ifndef OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED 16 #define OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED 25 #include <openvdb/version.h> 43 class FunctionRegistry;
53 using Ptr = std::shared_ptr<Compiler>;
77 template <
typename ExecutableT>
78 typename ExecutableT::Ptr
93 template <
typename ExecutableT>
94 typename ExecutableT::Ptr
101 if (syntaxTree)
return compile<ExecutableT>(*syntaxTree, logger, data);
113 template <
typename ExecutableT>
114 typename ExecutableT::Ptr
118 std::vector<std::string> errors;
119 openvdb::ax::Logger logger(
120 [&errors] (
const std::string& error) {
121 errors.emplace_back(error +
"\n");
123 [] (
const std::string&) {}
126 if (!errors.empty()) {
127 std::ostringstream os;
128 for (
const auto& e : errors) os << e <<
"\n";
132 typename ExecutableT::Ptr exe = this->compile<ExecutableT>(*syntaxTree, logger, data);
133 if (!errors.empty()) {
134 std::ostringstream os;
135 for (
const auto& e : errors) os << e <<
"\n";
148 template <
typename ExecutableT>
149 typename ExecutableT::Ptr
153 std::vector<std::string> errors;
154 openvdb::ax::Logger logger(
155 [&errors] (
const std::string& error) {
156 errors.emplace_back(error +
"\n");
158 [] (
const std::string&) {}
160 auto exe = compile<ExecutableT>(syntaxTree, logger, data);
161 if (!errors.empty()) {
162 std::ostringstream os;
163 for (
const auto& e : errors) os << e <<
"\n";
176 void setFunctionRegistry(std::unique_ptr<codegen::FunctionRegistry>&& functionRegistry);
181 template <
typename ExeT,
typename GenT>
184 const std::string& moduleName,
185 const std::vector<std::string>& functions,
190 std::shared_ptr<llvm::LLVMContext> mContext;
192 std::shared_ptr<codegen::FunctionRegistry> mFunctionRegistry;
200 #endif // OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED std::shared_ptr< CustomData > Ptr
Definition: CustomData.h:37
Definition: Compiler.h:31
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
std::unique_ptr< Compiler > UniquePtr
Definition: Compiler.h:54
Settings which control how a Compiler class object behaves.
Definition: CompilerOptions.h:47
Parsing methods for creating abstract syntax trees out of AX code.
void clear()
Clear the tree-code mapping and reset the number of errors/warnings.
Single header include which provides methods for initializing AX and running a full AX pipeline (pars...
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:150
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:95
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:115
Definition: Exceptions.h:13
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:57
OpenVDB AX Compiler Options.
OPENVDB_AX_API openvdb::ax::ast::Tree::ConstPtr parse(const char *code, ax::Logger &logger)
Construct an abstract syntax tree from a code snippet.
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:49
Definition: Exceptions.h:39
Access to the CustomData class which can provide custom user user data to the OpenVDB AX Compiler...
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:564
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
std::shared_ptr< Compiler > Ptr
Definition: Compiler.h:53
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:561
Definition: Exceptions.h:37
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212