Commit 8868f3f3
8868f3f3b8d9Merged
sacckey <[email protected]> · 7 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): support built-in .new for absolute ConstantPath
Details
- Commit
- 8868f3f3b8d9
- Parent
- 2702b38e73cf
spinel_codegen.rbmodifiedView file
@@ -1454,13 +1454,12 @@
14541454
end14551455
if mname == "new"14561456
if recv >= 01457-
if @nd_type[recv] == "ConstantReadNode"1458-
if @nd_name[recv] == "Proc"1459-
return "proc"1460-
end1461-
if @nd_name[recv] == "Fiber"1462-
return "fiber"1463-
end1457+
rcname = constructor_class_name(recv)1458+
if rcname == "Proc"1459+
return "proc"1460+
end1461+
if rcname == "Fiber"1462+
return "fiber"14641463
end14651464
end14661465
end@@ -1476,10 +1475,9 @@
14761475
# Fiber.yield returns poly14771476
if mname == "yield"14781477
if recv >= 01479-
if @nd_type[recv] == "ConstantReadNode"1480-
if @nd_name[recv] == "Fiber"1481-
return "poly"1482-
end1478+
rcname = constructor_class_name(recv)1479+
if rcname == "Fiber"1480+
return "poly"14831481
end14841482
end14851483
end@@ -1504,10 +1502,9 @@
15041502
# Fiber.current returns fiber15051503
if mname == "current"15061504
if recv >= 01507-
if @nd_type[recv] == "ConstantReadNode"1508-
if @nd_name[recv] == "Fiber"1509-
return "fiber"1510-
end1505+
rcname = constructor_class_name(recv)1506+
if rcname == "Fiber"1507+
return "fiber"15111508
end15121509
end15131510
end@@ -2450,7 +2447,7 @@
24502447
if recv >= 024512448
rn = constructor_class_name(recv)24522449
if rn != ""2453-
if @nd_type[recv] == "ConstantReadNode" && rn == "Array"2450+
if rn == "Array"24542451
# Check fill value type24552452
args_id = @nd_arguments[nid]24562453
if args_id >= 0@@ -2467,16 +2464,16 @@
24672464
end24682465
return "int_array"24692466
end2470-
if @nd_type[recv] == "ConstantReadNode" && rn == "Hash"2467+
if rn == "Hash"24712468
return "str_int_hash"24722469
end2473-
if @nd_type[recv] == "ConstantReadNode" && rn == "Proc"2470+
if rn == "Proc"24742471
return "proc"24752472
end2476-
if @nd_type[recv] == "ConstantReadNode" && rn == "StringIO"2473+
if rn == "StringIO"24772474
return "stringio"24782475
end2479-
if @nd_type[recv] == "ConstantReadNode" && rn == "Fiber"2476+
if rn == "Fiber"24802477
return "fiber"24812478
end24822479
return "obj_" + rn@@ -2521,7 +2518,7 @@
25212518
if recv >= 025222519
rcname = constructor_class_name(recv)25232520
if rcname != ""2524-
if @nd_type[recv] == "ConstantReadNode" && rcname == "Fiber"2521+
if rcname == "Fiber"25252522
if mname == "new"25262523
return "fiber"25272524
end@@ -4166,10 +4163,10 @@
41664163
if r >= 041674164
rname = constructor_class_name(r)41684165
if rname != ""4169-
if @nd_type[r] == "ConstantReadNode" && rname == "Array"4166+
if rname == "Array"41704167
return "int_array"41714168
end4172-
if @nd_type[r] == "ConstantReadNode" && rname == "Hash"4169+
if rname == "Hash"41734170
return "str_int_hash"41744171
end41754172
if rname == "StringIO"@@ -11920,7 +11917,7 @@
1192011917
mn = @nd_name[nid]1192111918
if mn == "new"1192211919
rv = @nd_receiver[nid]11923-
if rv >= 0 && @nd_type[rv] == "ConstantReadNode" && @nd_name[rv] == "Fiber"11920+
if rv >= 0 && constructor_class_name(rv) == "Fiber"1192411921
return1192511922
end1192611923
end@@ -12213,10 +12210,8 @@
1221312210
1221412211
# Fiber.new { block }1221512212
if mname == "new" && recv >= 012216-
if @nd_type[recv] == "ConstantReadNode"12217-
if @nd_name[recv] == "Fiber"12218-
return compile_fiber_new(nid)12219-
end12213+
if constructor_class_name(recv) == "Fiber"12214+
return compile_fiber_new(nid)1222012215
end1222112216
end1222212217
# fiber.resume(val)@@ -12236,17 +12231,16 @@
1223612231
end1223712232
# Fiber.yield(val)1223812233
if mname == "yield" && recv >= 012239-
if @nd_type[recv] == "ConstantReadNode"12240-
if @nd_name[recv] == "Fiber"12241-
args_id = @nd_arguments[nid]12242-
if args_id >= 012243-
arg_ids = get_args(args_id)12244-
if arg_ids.length > 012245-
return "sp_Fiber_yield(" + box_expr_to_poly(arg_ids[0]) + ")"12246-
end12234+
if constructor_class_name(recv) == "Fiber"12235+
@needs_fiber = 112236+
args_id = @nd_arguments[nid]12237+
if args_id >= 012238+
arg_ids = get_args(args_id)12239+
if arg_ids.length > 012240+
return "sp_Fiber_yield(" + box_expr_to_poly(arg_ids[0]) + ")"1224712241
end12248-
return "sp_Fiber_yield(sp_box_nil())"1224912242
end12243+
return "sp_Fiber_yield(sp_box_nil())"1225012244
end1225112245
end1225212246
# fiber.alive?@@ -12274,10 +12268,9 @@
1227412268
end1227512269
# Fiber.current1227612270
if mname == "current" && recv >= 012277-
if @nd_type[recv] == "ConstantReadNode"12278-
if @nd_name[recv] == "Fiber"12279-
return "sp_fiber_current"12280-
end12271+
if constructor_class_name(recv) == "Fiber"12272+
@needs_fiber = 112273+
return "sp_fiber_current"1228112274
end1228212275
end1228312276
@@ -13247,13 +13240,13 @@
1324713240
def compile_constructor_expr(nid, recv)1324813241
cname = constructor_class_name(recv)1324913242
if cname != ""13250-
if @nd_type[recv] == "ConstantReadNode" && cname == "Proc"13243+
if cname == "Proc"1325113244
if @nd_block[nid] >= 01325213245
@needs_proc = 11325313246
return compile_proc_literal(nid)1325413247
end1325513248
end13256-
if @nd_type[recv] == "ConstantReadNode" && cname == "Array"13249+
if cname == "Array"1325713250
@needs_gc = 11325813251
args_id = @nd_arguments[nid]1325913252
if args_id >= 0@@ -13285,7 +13278,7 @@
1328513278
@needs_int_array = 11328613279
return "sp_IntArray_new()"1328713280
end13288-
if @nd_type[recv] == "ConstantReadNode" && cname == "Hash"13281+
if cname == "Hash"1328913282
@needs_str_int_hash = 11329013283
@needs_gc = 11329113284
args_id = @nd_arguments[nid]@@ -13305,7 +13298,7 @@
1330513298
end1330613299
return "sp_StrIntHash_new()"1330713300
end13308-
if @nd_type[recv] == "ConstantReadNode" && cname == "StringIO"13301+
if cname == "StringIO"1330913302
@needs_stringio = 11331013303
args_id = @nd_arguments[nid]1331113304
if args_id >= 0@@ -14307,13 +14300,7 @@
1430714300
end1430814301
# Array methods1430914302
if recv_type == "int_array" || recv_type == "sym_array"14310-
if mname == "length"14311-
if @hoisted_strlen_var != "" && @hoisted_strlen_recv == rc14312-
return @hoisted_strlen_var14313-
end14314-
return "sp_IntArray_length(" + rc + ")"14315-
end14316-
if mname == "size"14303+
if mname == "length" || mname == "size"1431714304
if @hoisted_strlen_var != "" && @hoisted_strlen_recv == rc1431814305
return @hoisted_strlen_var1431914306
endtest/bm_constant_path_builtin_new.rbaddedView file
Loading diff…