Commit a68f2831
a68f283157ffMerged
sacckey <[email protected]> · 7 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): namespace relative ConstantPath and reject dynamic flatten
Details
- Commit
- a68f283157ff
- Parent
- 8868f3f3b8d9
spinel_codegen.rbmodifiedView file
@@ -704,13 +704,38 @@
704704
end705705
base = const_ref_flat_name(parent)706706
if base == ""707-
return leaf707+
return ""708708
end709709
return base + "_" + leaf710710
end711711
""712712
end713713
714+
def const_ref_is_relative(nid)715+
if nid < 0716+
return 0717+
end718+
t = @nd_type[nid]719+
if t == "ConstantReadNode"720+
return 1721+
end722+
if t == "ConstantPathNode"723+
parent = @nd_receiver[nid]724+
if parent < 0725+
return 0726+
end727+
pt = @nd_type[parent]728+
if pt == "ConstantReadNode"729+
return 1730+
end731+
if pt == "ConstantPathNode"732+
return const_ref_is_relative(parent)733+
end734+
return 0735+
end736+
0737+
end738+
714739
def constructor_class_name(recv_nid)715740
if recv_nid < 0716741
return ""@@ -3385,7 +3410,7 @@
33853410
cname = const_ref_flat_name(cp)33863411
# For `module M; class C; ... end; end`, Prism gives class name as33873412
# ConstantReadNode("C"), so attach lexical module prefix.3388-
if module_prefix != "" && @nd_type[cp] == "ConstantReadNode"3413+
if module_prefix != "" && const_ref_is_relative(cp) == 133893414
cname = module_prefix + "_" + cname33903415
end33913416
end@@ -4322,7 +4347,7 @@
43224347
cp = @nd_constant_path[nid]43234348
if cp >= 043244349
mname = const_ref_flat_name(cp)4325-
if module_prefix != "" && @nd_type[cp] == "ConstantReadNode"4350+
if module_prefix != "" && const_ref_is_relative(cp) == 143264351
mname = module_prefix + "_" + mname43274352
end43284353
endtest/bm_module_relative_constant_path.rbaddedView file
Loading diff…