mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
688d483c0c
We previously moved container identification later in CodeGen in order to preserve information for AlignmentCalc. However, Flattener needs to know if a class is a container in order to apply its special handling for this case. This new approach moves container identification in front of Flattener, but has Container own a type node, representing its layout. This underlying type node can be used for calculating a container's alignment in a later pass.
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <unordered_map>
|
|
|
|
#include "oi/type_graph/Types.h"
|
|
|
|
namespace oi::detail::type_graph {
|
|
class TypeGraph;
|
|
} // namespace oi::detail::type_graph
|
|
|
|
using namespace oi::detail::type_graph;
|
|
|
|
/*
|
|
* TypeGraphParser
|
|
*
|
|
* Parses a textual type graph, as emitted by Printer.
|
|
*/
|
|
class TypeGraphParser {
|
|
public:
|
|
TypeGraphParser(TypeGraph& typeGraph) : typeGraph_(typeGraph) {
|
|
}
|
|
|
|
void parse(std::string_view input);
|
|
|
|
private:
|
|
TypeGraph& typeGraph_;
|
|
std::unordered_map<NodeId, std::reference_wrapper<Type>> nodesById_;
|
|
|
|
Type& parseType(std::string_view& input, size_t rootIndent);
|
|
template <typename T>
|
|
void parseParams(T& c, std::string_view& input, size_t rootIndent);
|
|
void parseParents(Class& c, std::string_view& input, size_t rootIndent);
|
|
void parseMembers(Class& c, std::string_view& input, size_t rootIndent);
|
|
void parseFunctions(Class& c, std::string_view& input, size_t rootIndent);
|
|
void parseChildren(Class& c, std::string_view& input, size_t rootIndent);
|
|
void parseUnderlying(Container& c,
|
|
std::string_view& input,
|
|
size_t rootIndent);
|
|
};
|
|
|
|
class TypeGraphParserError : public std::runtime_error {
|
|
public:
|
|
TypeGraphParserError(const std::string& msg) : std::runtime_error{msg} {
|
|
}
|
|
};
|