Skip to content

Commit

Permalink
Used fixed key for type information in internal IO stream json.
Browse files Browse the repository at this point in the history
Now uses "relation" key instead of <relation_name>.
  • Loading branch information
azreika committed Jul 17, 2020
1 parent 6b54958 commit cb762fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/SerialisationStream.h
Expand Up @@ -49,21 +49,18 @@ class SerialisationStream {
auxiliaryArity(auxArity) {}

SerialisationStream(
RO<SymbolTable>& symTab, RO<RecordTable>& recTab, Json types, char const* const relationName)
RO<SymbolTable>& symTab, RO<RecordTable>& recTab, Json types)
: symbolTable(symTab), recordTable(recTab), types(std::move(types)) {
setupFromJson(relationName);
setupFromJson();
}

SerialisationStream(RO<SymbolTable>& symTab, RO<RecordTable>& recTab,
const std::map<std::string, std::string>& rwOperation)
: symbolTable(symTab), recordTable(recTab) {
auto&& relationName = rwOperation.at("name");

std::string parseErrors;
types = Json::parse(rwOperation.at("types"), parseErrors);
assert(parseErrors.size() == 0 && "Internal JSON parsing failed.");

setupFromJson(relationName.c_str());
setupFromJson();
}

RO<SymbolTable>& symbolTable;
Expand All @@ -75,8 +72,8 @@ class SerialisationStream {
size_t auxiliaryArity = 0;

private:
void setupFromJson(char const* const relationName) {
auto&& relInfo = types[relationName];
void setupFromJson() {
auto&& relInfo = types["relation"];
arity = static_cast<size_t>(relInfo["arity"].long_value());
auxiliaryArity = static_cast<size_t>(relInfo["auxArity"].long_value());

Expand Down
2 changes: 1 addition & 1 deletion src/ast/transform/IOAttributesTransformer.h
Expand Up @@ -102,7 +102,7 @@ class IOAttributesTransformer : public AstTransformer {
{"types", Json::array(attributesTypes.begin(), attributesTypes.end())}};

Json types = Json::object{
{getRelationName(io), relJson}, {"records", getRecordsTypes(translationUnit)}};
{"relation", relJson}, {"records", getRecordsTypes(translationUnit)}};

io->addDirective("types", types.dump());
changed = true;
Expand Down

0 comments on commit cb762fa

Please sign in to comment.