Commit 33fbfa3b

33fbfa3b8755Merged

sacckey <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

fix(codegen): box polymorphic method returns as sp_RbVal

Details

Commit
33fbfa3b8755
Parent
c98048e104bd

spinel_codegen.rbmodifiedView file

@@ -18488,6 +18488,18 @@
1848818488 if args_id >= 0
1848918489 arg_ids = get_args(args_id)
1849018490 if arg_ids.length > 0
18491+ if @current_method_return == "poly"
18492+ ret_expr = box_expr_to_poly(arg_ids[0])
18493+ if @in_gc_scope == 1
18494+ tmp = new_temp
18495+ emit(" sp_RbVal " + tmp + " = " + ret_expr + ";")
18496+ emit(" SP_GC_RESTORE();")
18497+ emit(" return " + tmp + ";")
18498+ else
18499+ emit(" return " + ret_expr + ";")
18500+ end
18501+ return
18502+ end
1849118503 rt = infer_type(arg_ids[0])
1849218504 # return nil in a nullable pointer method → return NULL
1849318505 if rt == "nil" && is_nullable_pointer_type(@current_method_return) == 1
@@ -23442,6 +23454,10 @@
2344223454 return
2344323455 end
2344423456 if return_type != "void"
23457+ if return_type == "poly"
23458+ emit(" return " + box_expr_to_poly(last) + ";")
23459+ return
23460+ end
2344523461 val = compile_expr(last)
2344623462 expr_type = infer_type(last)
2344723463 if expr_type == "lambda"