Commit 5411c4a5
5411c4a5af99Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
Merge pull request #105 from sacckey/fix/poly-dispatch-args-ret
fix(codegen): box polymorphic method returns as sp_RbVal
Details
- Commit
- 5411c4a5af99
- Parent
- 248a58a7f6c1
- Merge parent
- a338974a4c3d
spinel_codegen.rbmodifiedView file
@@ -18619,6 +18619,18 @@
1861918619
if args_id >= 01862018620
arg_ids = get_args(args_id)1862118621
if arg_ids.length > 018622+
if @current_method_return == "poly"18623+
ret_expr = box_expr_to_poly(arg_ids[0])18624+
if @in_gc_scope == 118625+
tmp = new_temp18626+
emit(" sp_RbVal " + tmp + " = " + ret_expr + ";")18627+
emit(" SP_GC_RESTORE();")18628+
emit(" return " + tmp + ";")18629+
else18630+
emit(" return " + ret_expr + ";")18631+
end18632+
return18633+
end1862218634
rt = infer_type(arg_ids[0])1862318635
# return nil in a nullable pointer method → return NULL1862418636
if rt == "nil" && is_nullable_pointer_type(@current_method_return) == 1@@ -23645,6 +23657,18 @@
2364523657
return2364623658
end2364723659
if return_type != "void"23660+
if return_type == "poly"23661+
ret_expr = box_expr_to_poly(last)23662+
if @in_gc_scope == 123663+
tmp = new_temp23664+
emit(" sp_RbVal " + tmp + " = " + ret_expr + ";")23665+
emit(" SP_GC_RESTORE();")23666+
emit(" return " + tmp + ";")23667+
else23668+
emit(" return " + ret_expr + ";")23669+
end23670+
return23671+
end2364823672
val = compile_expr(last)2364923673
expr_type = infer_type(last)2365023674
if expr_type == "lambda"test/poly_dispatch_args_ret.rbaddedView file
Loading diff…