Commit 896090d0
896090d00e56Merged
sacckey <[email protected]> · 7 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): support nested ConstantPath constant reads in classes/modules
Details
- Commit
- 896090d00e56
- Parent
- 7f910a3027cd
spinel_codegen.rbmodifiedView file
@@ -1070,8 +1070,11 @@
10701070
end10711071
if t == "ConstantPathNode"10721072
if @nd_receiver[nid] >= 01073-
rname = @nd_name[@nd_receiver[nid]]1073+
rname = const_ref_flat_name(@nd_receiver[nid])10741074
nname = @nd_name[nid]1075+
if rname == ""1076+
return "int"1077+
end10751078
cpname = rname + "_" + nname10761079
ci = find_const_idx(cpname)10771080
if ci >= 0@@ -3468,6 +3471,24 @@
34683471
collect_class_with_prefix(nid, "")34693472
end34703473
3474+
def collect_scoped_constant(scope_name, nid)3475+
cname = scope_name + "_" + @nd_name[nid]3476+
expr_id = @nd_expression[nid]3477+
ct = "int"3478+
if expr_id >= 03479+
ct = infer_type(expr_id)3480+
end3481+
ci = find_const_idx(cname)3482+
if ci >= 03483+
@const_types[ci] = ct3484+
@const_expr_ids[ci] = expr_id3485+
return3486+
end3487+
@const_names.push(cname)3488+
@const_types.push(ct)3489+
@const_expr_ids.push(expr_id)3490+
end3491+
34713492
def collect_class_with_prefix(nid, module_prefix)34723493
ci = @cls_names.length34733494
cname = ""@@ -3523,6 +3544,9 @@
35233544
if @nd_type[sid] == "DefNode"35243545
collect_class_method(ci, sid)35253546
end3547+
if @nd_type[sid] == "ConstantWriteNode"3548+
collect_scoped_constant(cname, sid)3549+
end35263550
if @nd_type[sid] == "CallNode"35273551
cn = @nd_name[sid]35283552
if cn != "include"@@ -3669,6 +3693,9 @@
36693693
if @nd_type[sid] == "DefNode"36703694
collect_class_method(ci, sid)36713695
end3696+
if @nd_type[sid] == "ConstantWriteNode"3697+
collect_scoped_constant(cname, sid)3698+
end36723699
if @nd_type[sid] == "CallNode"36733700
cn = @nd_name[sid]36743701
if cn != "include"@@ -11405,8 +11432,11 @@
1140511432
end1140611433
if t == "ConstantPathNode"1140711434
if @nd_receiver[nid] >= 011408-
rname = @nd_name[@nd_receiver[nid]]11435+
rname = const_ref_flat_name(@nd_receiver[nid])1140911436
nname = @nd_name[nid]11437+
if rname == ""11438+
return @nd_name[nid]11439+
end1141011440
cpname = rname + "_" + nname1141111441
ci = find_const_idx(cpname)1141211442
if ci >= 0test/bm_constant_path_nested_read.rbaddedView file
Loading diff…