Commit c449295b authored by Kenton Varda's avatar Kenton Varda

Add loadCompiledTypeAndDependencies() to SchemaParser so that compiled constants…

Add loadCompiledTypeAndDependencies() to SchemaParser so that compiled constants can be cast to static types.
parent 9f6e055f
......@@ -162,6 +162,7 @@ public:
// nodes can be found in the SchemaLoader returned by `getLoader()`.
const SchemaLoader& getLoader() const { return loader; }
SchemaLoader& getLoader() { return loader; }
// Get a SchemaLoader backed by this compiler. Schema nodes will be lazily constructed as you
// traverse them using this loader.
......
......@@ -196,6 +196,10 @@ SchemaParser::ModuleImpl& SchemaParser::getModuleImpl(kj::Own<SchemaFile>&& file
return *insertResult.first->second;
}
SchemaLoader& SchemaParser::getLoader() {
return impl->compiler.getLoader();
}
kj::Maybe<ParsedSchema> ParsedSchema::findNested(kj::StringPtr name) const {
return parser->impl->compiler.lookup(getProto().getId(), name).map(
[this](uint64_t childId) {
......
......@@ -75,6 +75,12 @@ public:
// normally. In this case, the result is a best-effort attempt to compile the schema, but it
// may be invalid or corrupt, and using it for anything may cause exceptions to be thrown.
template <typename T>
inline void loadCompiledTypeAndDependencies() {
// See SchemaLoader::loadCompiledTypeAndDependencies().
getLoader().loadCompiledTypeAndDependencies<T>();
}
private:
struct Impl;
class ModuleImpl;
......@@ -82,6 +88,7 @@ private:
mutable bool hadErrors = false;
ModuleImpl& getModuleImpl(kj::Own<SchemaFile>&& file) const;
SchemaLoader& getLoader();
friend class ParsedSchema;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment