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 end
38013801 end
38023802 end
3803+ if @nd_type[sid] == "ClassNode"
3804+ collect_class_with_prefix(sid, cname)
3805+ end
3806+ if @nd_type[sid] == "ModuleNode"
3807+ collect_module_with_prefix(sid, cname)
3808+ end
38033809 }
38043810 body_stmts.each { |sid|
38053811 if @nd_type[sid] == "CallNode"
@@ -3951,6 +3957,16 @@
39513957 end
39523958 end
39533959 end
3960+ # Nested class / module inside class. Mirroring the
3961+ # nested-in-module path, the inner type is registered at top
3962+ # 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+ end
3967+ if @nd_type[sid] == "ModuleNode"
3968+ collect_module_with_prefix(sid, cname)
3969+ end
39543970 }
39553971 # Second pass: handle includes (after all own methods are known)
39563972 body_stmts.each { |sid|