Skip to content

Commit 81a2f40

Browse files
committed
Revert translation_rule to master
1 parent f1ce30d commit 81a2f40

2 files changed

Lines changed: 1 addition & 11 deletions

File tree

cpp2rust/converter/translation_rule.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ RuleMap LoadTgtFromIR(const std::filesystem::path &json_path) {
897897
Rule rule;
898898
if (name[0] == 'f') {
899899
rule.tgt = ParseExprTgtJSON(*obj);
900-
std::get<ExprTgt>(rule.tgt).name = name;
900+
std::get<ExprTgt>(rule.tgt).validate(json_path.string() + ":" + name);
901901
} else if (name[0] == 't') {
902902
rule.tgt = ParseTypeTgtJSON(*obj);
903903
} else {
@@ -1039,8 +1039,6 @@ void ExprTgt::validate(const std::string &context) const {
10391039
ValidateConsecutiveKeys(params, 'a', 0, context + " params");
10401040
ValidateConsecutiveKeys(generics, 'T', 1, context + " generics");
10411041
assert(!body.empty() && "ExprTgt body must not be empty");
1042-
assert(!name.empty() && "ExprTgt name must not be empty");
1043-
assert(!module.empty() && "ExprTgt module must not be empty");
10441042
}
10451043

10461044
std::vector<Rule> Load(const std::filesystem::path &path, Model model) {
@@ -1063,9 +1061,6 @@ std::vector<Rule> Load(const std::filesystem::path &path, Model model) {
10631061
}
10641062
for (auto &[name, src_rule] : src_rules) {
10651063
rules.at(name).src = std::move(src_rule.src);
1066-
if (auto *expr_tgt = std::get_if<ExprTgt>(&rules.at(name).tgt)) {
1067-
expr_tgt->module = dir.filename().string();
1068-
}
10691064
}
10701065

10711066
std::vector<Rule> result;
@@ -1080,9 +1075,6 @@ std::vector<Rule> Load(const std::filesystem::path &path, Model model) {
10801075
}
10811076
}
10821077
assert(!rule.src.empty() && "Rule loaded from IR but has no src");
1083-
if (auto *expr_tgt = std::get_if<ExprTgt>(&rule.tgt)) {
1084-
expr_tgt->validate(path.string() + ':' + name);
1085-
}
10861078
result.push_back(std::move(rule));
10871079
}
10881080
return result;

cpp2rust/converter/translation_rule.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ struct TypeInfo {
6161
};
6262

6363
struct ExprTgt {
64-
std::string name;
65-
std::string module;
6664
std::unordered_map<std::string, TypeInfo> params; // "a0" -> TypeInfo
6765
TypeInfo return_type;
6866
std::unordered_map<std::string, std::vector<std::string>>

0 commit comments

Comments
 (0)