summaryrefslogtreecommitdiff
path: root/src/expr/node_manager.h
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2019-12-16 11:56:39 -0600
committerAndres Noetzli <andres.noetzli@gmail.com>2019-12-16 09:56:39 -0800
commitc101a6b42d1f14bc750fb2328ddd83261148d7ae (patch)
tree3155d3edd7c26690088cbc9a223de5c854941475 /src/expr/node_manager.h
parentd15d44b3c91b5be2c19adac292f137d2a67eb848 (diff)
Move Datatype management to ExprManager (#3568)
This is further work towards decoupling the Expr layer from the Node layer. This commit makes it so that ExprManager does memory management for Datatype while NodeManager maintains a list of DType. As a reminder, the ownership policy (and level of indirection through DatatypeIndex) is necessary due to not being able to store Datatype within Node since this leads to circular dependencies in the Node AST.
Diffstat (limited to 'src/expr/node_manager.h')
-rw-r--r--src/expr/node_manager.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h
index 61ef1d39d..eced00c48 100644
--- a/src/expr/node_manager.h
+++ b/src/expr/node_manager.h
@@ -178,7 +178,7 @@ class NodeManager {
std::vector<NodeManagerListener*> d_listeners;
/** A list of datatypes owned by this node manager. */
- std::vector<Datatype*> d_ownedDatatypes;
+ std::vector<std::shared_ptr<DType> > d_ownedDTypes;
/**
* A map of tuple and record types to their corresponding datatype.
@@ -428,9 +428,17 @@ public:
}
/** register datatype */
- unsigned registerDatatype(Datatype* dt);
- /** get datatype for index */
- const Datatype & getDatatypeForIndex( unsigned index ) const;
+ size_t registerDatatype(std::shared_ptr<DType> dt);
+ /**
+ * Return the datatype at the given index owned by this class. Type nodes are
+ * associated with datatypes through the DatatypeIndexConstant class. The
+ * argument index is intended to be a value taken from that class.
+ *
+ * Type nodes must access their DTypes through a level of indirection to
+ * prevent cycles in the Node AST (as DTypes themselves contain Nodes), which
+ * would lead to memory leaks. Thus TypeNode are given a DatatypeIndexConstant
+ * which is used as an index to retrieve the DType via this call.
+ */
const DType& getDTypeForIndex(unsigned index) const;
/** Get a Kind from an operator expression */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback