15 #ifndef OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED 16 #define OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED 25 #include <openvdb/version.h> 40 class FunctionRegistry;
53 using Ptr = std::shared_ptr<Compiler>;
81 template <
typename ExecutableT>
82 typename ExecutableT::Ptr
97 template <
typename ExecutableT>
98 typename ExecutableT::Ptr
105 if (syntaxTree)
return compile<ExecutableT>(*syntaxTree, logger, data);
117 template <
typename ExecutableT>
118 typename ExecutableT::Ptr
122 std::vector<std::string> errors;
123 openvdb::ax::Logger logger(
124 [&errors] (
const std::string& error) {
125 errors.emplace_back(error +
"\n");
127 [] (
const std::string&) {}
130 if (!errors.empty()) {
131 std::ostringstream os;
132 for (
const auto& e : errors) os << e <<
"\n";
136 typename ExecutableT::Ptr exe = this->compile<ExecutableT>(*syntaxTree, logger, data);
137 if (!errors.empty()) {
138 std::ostringstream os;
139 for (
const auto& e : errors) os << e <<
"\n";
152 template <
typename ExecutableT>
153 typename ExecutableT::Ptr
157 std::vector<std::string> errors;
158 openvdb::ax::Logger logger(
159 [&errors] (
const std::string& error) {
160 errors.emplace_back(error +
"\n");
162 [] (
const std::string&) {}
164 auto exe = compile<ExecutableT>(syntaxTree, logger, data);
165 if (!errors.empty()) {
166 std::ostringstream os;
167 for (
const auto& e : errors) os << e <<
"\n";
180 void setFunctionRegistry(std::unique_ptr<codegen::FunctionRegistry>&& functionRegistry);
185 template <
typename ExeT,
typename GenT>
188 const std::string& moduleName,
189 const std::vector<std::string>& functions,
195 std::unique_ptr<codegen::FunctionRegistry> mFunctionRegistry;
203 #endif // OPENVDB_AX_COMPILER_HAS_BEEN_INCLUDED #define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
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
Parsing methods for creating abstract syntax trees out of AX code.
Single header include which provides methods for initializing AX and running a full AX pipeline (pars...
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
std::unique_ptr< Compiler > UniquePtr
Definition: Compiler.h:54
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:119
Definition: Exceptions.h:13
OpenVDB AX Compiler Options.
std::shared_ptr< CustomData > Ptr
Definition: CustomData.h:37
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:99
Definition: Exceptions.h:39
The compiler class. This holds a set of compiler options and constructs executable objects (e...
Definition: Compiler.h:50
Logging system to collect errors and warnings throughout the different stages of parsing and compilat...
Definition: Exceptions.h:37
Logger for collecting errors and warnings that occur during AX compilation.
Definition: Logger.h:57
void clear()
Clear the tree-code mapping and reset the number of errors/warnings.
Settings which control how a Compiler class object behaves.
Definition: CompilerOptions.h:47
Access to the CustomData class which can provide custom user user data to the OpenVDB AX Compiler...
std::shared_ptr< Compiler > Ptr
Definition: Compiler.h:53
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:154
OPENVDB_AX_API openvdb::ax::ast::Tree::ConstPtr parse(const char *code, ax::Logger &logger)
Construct an abstract syntax tree from a code snippet.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
std::shared_ptr< const Tree > ConstPtr
Definition: AST.h:565
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218