Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tbv2: name array member types correctly #456

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions oi/FuncGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,14 +742,7 @@ return tail.finish();
oiArray.codegen.processors.emplace_back(ContainerInfo::Processor{
.type = "types::st::List<DB, typename TypeHandler<Ctx, T0>::type>",
.func = R"(
static constexpr std::array<std::string_view, 1> names{"TODO"};
static constexpr auto childField = inst::Field{
sizeof(T0),
"[]",
names,
TypeHandler<Ctx, T0>::fields,
TypeHandler<Ctx, T0>::processors,
};
static constexpr auto childField = make_field<Ctx, T0>("[]");

el.exclusive_size = 0;
el.container_stats.emplace(result::Element::ContainerStats{ .capacity = N0, .length = N0 });
Expand Down
5 changes: 5 additions & 0 deletions oi/type_graph/TopoSorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ void TopoSorter::visit(Incomplete& i) {
sortedTypes_.push_back(i);
}

void TopoSorter::visit(Array& a) {
RecursiveVisitor::visit(a);
sortedTypes_.push_back(a);
}

/*
* A type graph may contain cycles, so we need to slightly tweak the standard
* topological sorting algorithm. Cycles can only be introduced by certain
Expand Down
1 change: 1 addition & 0 deletions oi/type_graph/TopoSorter.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TopoSorter : public RecursiveVisitor {
void visit(Primitive& p) override;
void visit(CaptureKeys& p) override;
void visit(Incomplete& i) override;
void visit(Array& i) override;

private:
std::unordered_set<Type*> visited_;
Expand Down
4 changes: 2 additions & 2 deletions test/integration/arrays.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ definitions = '''
expect_json_v2 = '''[
{"staticSize":24, "exclusiveSize":0, "size":24, "members":[
{"staticSize":24, "exclusiveSize":0, "size":24, "length":2, "capacity":2, "members":[
{"staticSize":12, "exclusiveSize":0, "size":12, "length":3, "capacity":3},
{"staticSize":12, "exclusiveSize":0, "size":12, "length":3, "capacity":3}]
{"typeNames":["int32_t[3]"], "staticSize":12, "exclusiveSize":0, "size":12, "length":3, "capacity":3},
{"typeNames":["int32_t[3]"], "staticSize":12, "exclusiveSize":0, "size":12, "length":3, "capacity":3}]
}]}]'''
[cases.direct_int10]
skip = "Direct array arguments don't work"
Expand Down
5 changes: 4 additions & 1 deletion test/test_topo_sorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ TEST(TopoSorterTest, Arrays) {
auto myclass = Class{0, Class::Kind::Class, "MyClass", 69};
auto myarray = Array{1, myclass, 10};

test({myarray}, "MyClass\n");
test({myarray}, R"(
MyClass
OIArray<MyClass, 10>
)");
}

TEST(TopoSorterTest, Typedef) {
Expand Down