Commit 248a58a7
248a58a7f6c1Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
Merge pull request #104 from mame/feat/nested-class-in-class
feat(codegen): collect class-nested classes (follow-up to #27)
Details
- Commit
- 248a58a7f6c1
- Parent
- 4d740c228bdb
- Merge parent
- bdf7a4845e46
spinel_codegen.rbmodifiedView file
@@ -3800,6 +3800,12 @@
38003800
end38013801
end38023802
end3803+
if @nd_type[sid] == "ClassNode"3804+
collect_class_with_prefix(sid, cname)3805+
end3806+
if @nd_type[sid] == "ModuleNode"3807+
collect_module_with_prefix(sid, cname)3808+
end38033809
}38043810
body_stmts.each { |sid|38053811
if @nd_type[sid] == "CallNode"@@ -3951,6 +3957,16 @@
39513957
end39523958
end39533959
end3960+
# Nested class / module inside class. Mirroring the3961+
# nested-in-module path, the inner type is registered at top3962+
# level under its outer-class–prefixed name (e.g. `A::B` →3963+
# `A_B`) so a `A::B.new` call resolves via the same flat lookup.3964+
if @nd_type[sid] == "ClassNode"3965+
collect_class_with_prefix(sid, cname)3966+
end3967+
if @nd_type[sid] == "ModuleNode"3968+
collect_module_with_prefix(sid, cname)3969+
end39543970
}39553971
# Second pass: handle includes (after all own methods are known)39563972
body_stmts.each { |sid|test/nested_class_in_class.rbaddedView file
Loading diff…