toplevel, codegen: implement boxing functions