33
44#include " ax.h"
55#include " ast/AST.h"
6- #include " compiler/Logger.h"
76#include " compiler/Compiler.h"
87#include " compiler/PointExecutable.h"
98#include " compiler/VolumeExecutable.h"
@@ -27,23 +26,16 @@ namespace ax {
2726
2827void run (const char * ax, openvdb::GridBase& grid, const AttributeBindings& bindings)
2928{
30- // Construct a logger that will output errors to cerr and suppress warnings
31- openvdb::ax::Logger logger;
3229 // Construct a generic compiler
3330 openvdb::ax::Compiler compiler;
34- // Parse the provided code and produce an abstract syntax tree
35- // @note Throws with parser errors if invalid. Parsable code does not
36- // necessarily equate to compilable code
37- const openvdb::ax::ast::Tree::ConstPtr
38- ast = openvdb::ax::ast::parse (ax, logger);
39- if (!ast) return ;
4031
4132 if (grid.isType <points::PointDataGrid>()) {
4233 // Compile for Point support and produce an executable
4334 // @note Throws compiler errors on invalid code. On success, returns
4435 // the executable which can be used multiple times on any inputs
4536 const openvdb::ax::PointExecutable::Ptr exe =
46- compiler.compile <openvdb::ax::PointExecutable>(*ast, logger);
37+ compiler.compile <openvdb::ax::PointExecutable>(ax);
38+ assert (exe);
4739
4840 // Set the attribute bindings
4941 exe->setAttributeBindings (bindings);
@@ -56,7 +48,9 @@ void run(const char* ax, openvdb::GridBase& grid, const AttributeBindings& bindi
5648 // @note Throws compiler errors on invalid code. On success, returns
5749 // the executable which can be used multiple times on any inputs
5850 const openvdb::ax::VolumeExecutable::Ptr exe =
59- compiler.compile <openvdb::ax::VolumeExecutable>(*ast, logger);
51+ compiler.compile <openvdb::ax::VolumeExecutable>(ax);
52+ assert (exe);
53+
6054 // Set the attribute bindings
6155 exe->setAttributeBindings (bindings);
6256 // Execute on the provided numerical grid
@@ -78,23 +72,17 @@ void run(const char* ax, openvdb::GridPtrVec& grids, const AttributeBindings& bi
7872 " a single invocation of ax::run()" );
7973 }
8074 }
81- // Construct a logger that will output errors to cerr and suppress warnings
82- openvdb::ax::Logger logger;
8375 // Construct a generic compiler
8476 openvdb::ax::Compiler compiler;
85- // Parse the provided code and produce an abstract syntax tree
86- // @note Throws with parser errors if invalid. Parsable code does not
87- // necessarily equate to compilable code
88- const openvdb::ax::ast::Tree::ConstPtr
89- ast = openvdb::ax::ast::parse (ax, logger);
90- if (!ast) return ;
9177
9278 if (points) {
9379 // Compile for Point support and produce an executable
9480 // @note Throws compiler errors on invalid code. On success, returns
9581 // the executable which can be used multiple times on any inputs
9682 const openvdb::ax::PointExecutable::Ptr exe =
97- compiler.compile <openvdb::ax::PointExecutable>(*ast, logger);
83+ compiler.compile <openvdb::ax::PointExecutable>(ax);
84+ assert (exe);
85+
9886 // Set the attribute bindings
9987 exe->setAttributeBindings (bindings);
10088 // Execute on the provided points individually
@@ -108,7 +96,9 @@ void run(const char* ax, openvdb::GridPtrVec& grids, const AttributeBindings& bi
10896 // @note Throws compiler errors on invalid code. On success, returns
10997 // the executable which can be used multiple times on any inputs
11098 const openvdb::ax::VolumeExecutable::Ptr exe =
111- compiler.compile <openvdb::ax::VolumeExecutable>(*ast, logger);
99+ compiler.compile <openvdb::ax::VolumeExecutable>(ax);
100+ assert (exe);
101+
112102 // Set the attribute bindings
113103 exe->setAttributeBindings (bindings);
114104 // Execute on the provided volumes
0 commit comments