1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-13 09:39:13 +03:00

[Mach-O] wip

This commit is contained in:
Rui Ueyama 2021-10-17 20:46:17 +09:00
parent 88e714db09
commit b7993a5f74
3 changed files with 6 additions and 6 deletions

View File

@ -235,8 +235,8 @@ exports:
)");
for (YamlNode &node : nodes) {
dump_yaml(ctx, node);
SyncOut(ctx) << "---";
dump_yaml(ctx, node);
}
exit(0);
}

View File

@ -438,7 +438,7 @@ void dump_file(std::string path);
struct YamlNode {
std::variant<std::string_view,
std::vector<YamlNode>,
std::unordered_map<std::string_view, YamlNode>> data;
std::vector<std::pair<std::string_view, YamlNode>>> data;
};
std::vector<YamlNode> parse_yaml(Context &ctx, std::string_view str);

View File

@ -286,7 +286,7 @@ YamlNode YamlParser::parse_list(Context &ctx, std::span<Token> &tok) {
}
YamlNode YamlParser::parse_map(Context &ctx, std::span<Token> &tok) {
std::unordered_map<std::string_view, YamlNode> map;
std::vector<std::pair<std::string_view, YamlNode>> map;
while (tok[0].kind != Token::END && tok[0].kind != Token::DEDENT) {
if (tok.size() < 2 || tok[0].kind != Token::STRING || tok[1].kind != ':')
@ -294,7 +294,7 @@ YamlNode YamlParser::parse_map(Context &ctx, std::span<Token> &tok) {
std::string_view key = tok[0].str;
tok = tok.subspan(2);
map[key] = parse_element(ctx, tok);
map.push_back({key, parse_element(ctx, tok)});
}
return {map};
}
@ -348,11 +348,11 @@ void dump_yaml(Context &ctx, YamlNode &node, i64 depth) {
}
auto *elem =
std::get_if<std::unordered_map<std::string_view, YamlNode>>(&node.data);
std::get_if<std::vector<std::pair<std::string_view, YamlNode>>>(&node.data);
assert(elem);
SyncOut(ctx) << std::string(depth * 2, ' ') << "map:";
for (std::pair<const std::string_view, YamlNode> &kv : *elem) {
for (std::pair<std::string_view, YamlNode> &kv : *elem) {
SyncOut(ctx) << std::string(depth * 2 + 2, ' ') << "key: " << kv.first;
dump_yaml(ctx, kv.second, depth + 1);
}